@@ -63,6 +63,8 @@ extern uchar curr_vol_lev;
63
63
extern uchar curr_sfx_vol ;
64
64
extern uchar curr_alog_vol ;
65
65
66
+ extern uchar audiolog_setting ;
67
+
66
68
static const char * PREF_LANGUAGE = "language" ;
67
69
static const char * PREF_CAPTUREMOUSE = "capture-mouse" ;
68
70
static const char * PREF_MUSIC_VOL = "music-volume" ;
@@ -75,6 +77,8 @@ static const char *PREF_USE_OPENGL = "use-opengl";
75
77
static const char * PREF_LIN_SCALING = "linear-scaling" ;
76
78
static const char * PREF_ONSCR_HELP = "onscreen-help" ;
77
79
static const char * PREF_GAMMA = "gamma" ;
80
+ static const char * PREF_MSG_LENGTH = "message-length" ;
81
+ static const char * PREF_ALOG_SETTING = "alog-setting" ;
78
82
79
83
static void SetShockGlobals (void );
80
84
@@ -85,7 +89,6 @@ void SetDefaultPrefs(void) {
85
89
86
90
gShockPrefs .prefVer = 0 ;
87
91
gShockPrefs .prefPlayIntro = 1 ; // First time through, play the intro
88
- gShockPrefs .goMsgLength = 0 ; // Normal
89
92
gShockPrefs .goPopupLabels = true;
90
93
gShockPrefs .soBackMusic = true;
91
94
gShockPrefs .soSoundFX = true;
@@ -105,16 +108,30 @@ void SetDefaultPrefs(void) {
105
108
gShockPrefs .doLinearScaling = false;
106
109
gShockPrefs .goOnScreenHelp = true;
107
110
gShockPrefs .doGamma = 29 ; // Default gamma (29 out of 100).
111
+ gShockPrefs .goMsgLength = 0 ; // Normal
112
+ audiolog_setting = 1 ;
108
113
109
114
SetShockGlobals ();
110
115
}
111
116
112
- static FILE * open_prefs (const char * mode ) {
113
- char fullname [512 ];
114
- char * path = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
115
- snprintf (fullname , sizeof (fullname ), "%s%s" , path , PREFS_FILENAME );
116
- free (path );
117
- return fopen (fullname , mode );
117
+ static char * GetPrefsPathFilename (void )
118
+ {
119
+ static char filename [512 ];
120
+
121
+ FILE * f = fopen (PREFS_FILENAME , "r" );
122
+ if (f != NULL )
123
+ {
124
+ fclose (f );
125
+ strcpy (filename , PREFS_FILENAME );
126
+ }
127
+ else
128
+ {
129
+ char * p = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
130
+ snprintf (filename , sizeof (filename ), "%s%s" , p , PREFS_FILENAME );
131
+ free (p );
132
+ }
133
+
134
+ return filename ;
118
135
}
119
136
120
137
static char * trim (char * s ) {
@@ -134,7 +151,7 @@ static bool is_true(const char *s) {
134
151
// Locate the preferences file and load them to set our global pref settings.
135
152
//--------------------------------------------------------------------
136
153
OSErr LoadPrefs (void ) {
137
- FILE * f = open_prefs ( "r" );
154
+ FILE * f = fopen ( GetPrefsPathFilename (), "r" );
138
155
if (!f ) {
139
156
// file can't be open, write default preferences
140
157
return SavePrefs ();
@@ -192,6 +209,14 @@ OSErr LoadPrefs(void) {
192
209
if (gamma < 10 ) gamma = 10 ;
193
210
if (gamma > 100 ) gamma = 100 ;
194
211
gShockPrefs .doGamma = gamma ;
212
+ } else if (strcasecmp (key , PREF_MSG_LENGTH ) == 0 ) {
213
+ int ml = atoi (value );
214
+ if (ml >= 0 && ml <= 1 )
215
+ gShockPrefs .goMsgLength = ml ;
216
+ } else if (strcasecmp (key , PREF_ALOG_SETTING ) == 0 ) {
217
+ int as = atoi (value );
218
+ if (as >= 0 && as <= 2 )
219
+ audiolog_setting = as ;
195
220
}
196
221
}
197
222
@@ -206,7 +231,7 @@ OSErr LoadPrefs(void) {
206
231
OSErr SavePrefs (void ) {
207
232
INFO ("Saving preferences" );
208
233
209
- FILE * f = open_prefs ( "w" );
234
+ FILE * f = fopen ( GetPrefsPathFilename (), "w" );
210
235
if (!f ) {
211
236
printf ("ERROR: Failed to open preferences file\n" );
212
237
return -1 ;
@@ -224,6 +249,8 @@ OSErr SavePrefs(void) {
224
249
fprintf (f , "%s = %s\n" , PREF_LIN_SCALING , gShockPrefs .doLinearScaling ? "yes" : "no" );
225
250
fprintf (f , "%s = %s\n" , PREF_ONSCR_HELP , gShockPrefs .goOnScreenHelp ? "yes" : "no" );
226
251
fprintf (f , "%s = %d\n" , PREF_GAMMA , gShockPrefs .doGamma );
252
+ fprintf (f , "%s = %d\n" , PREF_MSG_LENGTH , gShockPrefs .goMsgLength );
253
+ fprintf (f , "%s = %d\n" , PREF_ALOG_SETTING , audiolog_setting );
227
254
fclose (f );
228
255
return 0 ;
229
256
}
@@ -543,6 +570,28 @@ int FireKeys[MAX_FIRE_KEYS+1]; //see input.c
543
570
544
571
545
572
573
+ static char * GetKeybindsPathFilename (void )
574
+ {
575
+ static char filename [512 ];
576
+
577
+ FILE * f = fopen (KEYBINDS_FILENAME , "r" );
578
+ if (f != NULL )
579
+ {
580
+ fclose (f );
581
+ strcpy (filename , KEYBINDS_FILENAME );
582
+ }
583
+ else
584
+ {
585
+ char * p = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
586
+ snprintf (filename , sizeof (filename ), "%s%s" , p , KEYBINDS_FILENAME );
587
+ free (p );
588
+ }
589
+
590
+ return filename ;
591
+ }
592
+
593
+
594
+
546
595
//all hotkey initialization and hotkey_add()s are done in this function
547
596
//also handles setting fire keybinds
548
597
void LoadHotkeyKeybinds (void )
@@ -563,12 +612,7 @@ void LoadHotkeyKeybinds(void)
563
612
i ++ ;
564
613
}
565
614
566
- //get path and filename of keybinds file
567
- p = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
568
- snprintf (temp , sizeof (temp ), "%s%s" , p , KEYBINDS_FILENAME );
569
- free (p );
570
-
571
- f = fopen (temp , "r" );
615
+ f = fopen (GetKeybindsPathFilename (), "r" );
572
616
if (f )
573
617
{
574
618
//scan keybinds file line by line
@@ -887,12 +931,7 @@ void LoadMoveKeybinds(void)
887
931
//keep track of which moves are specified so we can add default ones for those that are missing
888
932
memset (move_used , 0 , NUM_MOVES );
889
933
890
- //get path and filename of keybinds file
891
- p = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
892
- snprintf (temp , sizeof (temp ), "%s%s" , p , KEYBINDS_FILENAME );
893
- free (p );
894
-
895
- f = fopen (temp , "r" );
934
+ f = fopen (GetKeybindsPathFilename (), "r" );
896
935
if (f )
897
936
{
898
937
//scan keybinds file line by line
@@ -1086,20 +1125,15 @@ static void WriteMoveName(int move, FILE *f)
1086
1125
void CreateDefaultKeybindsFile (void )
1087
1126
{
1088
1127
FILE * f ;
1089
- char temp [ 512 ], * p ;
1128
+ char * filename = GetKeybindsPathFilename () ;
1090
1129
int i , ch ;
1091
1130
1092
- //get path and filename of keybinds file
1093
- p = SDL_GetPrefPath ("Interrupt" , "SystemShock" );
1094
- snprintf (temp , sizeof (temp ), "%s%s" , p , KEYBINDS_FILENAME );
1095
- free (p );
1096
-
1097
1131
//check if file already exists; if so, return
1098
- f = fopen (temp , "r" );
1132
+ f = fopen (filename , "r" );
1099
1133
if (f != NULL ) {fclose (f ); return ;}
1100
1134
1101
1135
//open new file for writing
1102
- f = fopen (temp , "w" );
1136
+ f = fopen (filename , "w" );
1103
1137
if (f == NULL ) return ;
1104
1138
1105
1139
//write default hotkey keybinds
0 commit comments