blob: 8bdc4f5a6d169b96b0131741c4b06f97513908c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
unit UCommandLine;
interface
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
{$I switches.inc}
type
//-----------
// TCMDParams - Class Reads Infos from ParamStr and set some easy Interface Variables
//-----------
TCMDParams = class
private
sLanguage: String;
sResolution: String;
public
//Some Boolean Variables Set when Reading Infos
Debug: Boolean;
Benchmark: Boolean;
NoLog: Boolean;
FullScreen: Boolean;
Joypad: Boolean;
//Some Value Variables Set when Reading Infos {-1: Not Set, others: Value}
Depth: Integer;
Screens: Integer;
//Some Strings Set when Reading Infos {Length=0 Not Set}
SongPath: String;
ConfigFile: String;
ScoreFile: String;
procedure showhelp();
//Pseudo Integer Values
Function GetLanguage: Integer;
Property Language: Integer read GetLanguage;
Function GetResolution: Integer;
Property Resolution: Integer read GetResolution;
//Some Procedures for Reading Infos
Constructor Create;
Procedure ResetVariables;
Procedure ReadParamInfo;
end;
var
Params: TCMDParams;
const
cHelp = 'help';
cDebug = 'debug';
cMediaInterfaces = 'showinterfaces';
implementation
uses SysUtils,
uPlatform;
// uINI -- Nasty requirement... ( removed with permission of blindy )
//-------------
// Constructor - Create class, Reset Variables and Read Infos
//-------------
Constructor TCMDParams.Create;
begin
inherited;
if FindCmdLineSwitch( cHelp ) or FindCmdLineSwitch( 'h' ) then
showhelp();
ResetVariables;
ReadParamInfo;
end;
procedure TCMDParams.showhelp();
function s( aString : String ) : string;
begin
result := aString + StringofChar( ' ', 15 - length( aString ) );
end;
begin
writeln( '' );
writeln( '**************************************************************' );
writeln( ' UltraStar Deluxe - Command line switches ' );
writeln( '**************************************************************' );
writeln( '' );
writeln( ' '+s( 'Switch' ) +' : Purpose' );
writeln( ' ----------------------------------------------------------' );
writeln( ' '+s( cMediaInterfaces ) + #9 + ' : Show in-use media interfaces' );
writeln( ' '+s( cDebug ) + #9 + ' : Display Debugging info' );
writeln( '' );
platform.halt;
end;
//-------------
// ResetVariables - Reset Class Variables
//-------------
Procedure TCMDParams.ResetVariables;
begin
Debug := False;
Benchmark := False;
NoLog := False;
FullScreen := False;
Joypad := False;
//Some Value Variables Set when Reading Infos {-1: Not Set, others: Value}
sResolution := '';
sLanguage := '';
Depth := -1;
Screens := -1;
//Some Strings Set when Reading Infos {Length=0 Not Set}
SongPath := '';
ConfigFile := '';
ScoreFile := '';
end;
//-------------
// ReadParamInfo - Read Infos from Parameters
//-------------
Procedure TCMDParams.ReadParamInfo;
var
I: Integer;
PCount: Integer;
Command: String;
begin
PCount := ParamCount;
//Log.LogError('ParamCount: ' + Inttostr(PCount));
//Check all Parameters
For I := 1 to PCount do
begin
Command := Paramstr(I);
//Log.LogError('Start parsing Command: ' + Command);
//Is String Parameter ?
if (Length(Command) > 1) AND (Command[1] = '-') then
begin
//Remove - from Command
Command := Lowercase(Trim(Copy(Command, 2, Length(Command) - 1)));
//Log.LogError('Command prepared: ' + Command);
//Check Command
// Boolean Triggers:
if (Command = 'debug') then
Debug := True
else if (Command = 'benchmark') then
Benchmark := True
else if (Command = 'nolog') then
NoLog := True
else if (Command = 'fullscreen') then
Fullscreen := True
else if (Command = 'window') then
Fullscreen := False
else if (Command = 'joypad') then
Joypad := True
//Integer Variables
else if (Command = 'depth') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
Command := ParamStr(I + 1);
//Check for valid Value
If (Command = '16') then
Depth := 0
Else If (Command = '32') then
Depth := 1;
end;
end
else if (Command = 'screens') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
Command := ParamStr(I + 1);
//Check for valid Value
If (Command = '1') then
Screens := 0
Else If (Command = '2') then
Screens := 1;
end;
end
//Pseudo Integer Values
else if (Command = 'language') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
//Write Value to String
sLanguage := Lowercase(ParamStr(I + 1));
end;
end
else if (Command = 'resolution') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
//Write Value to String
sResolution := Lowercase(ParamStr(I + 1));
end;
end
//String Values
else if (Command = 'songpath') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
//Write Value to String
SongPath := ParamStr(I + 1);
end;
end
else if (Command = 'configfile') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
//Write Value to String
ConfigFile := ParamStr(I + 1);
//is this a relative PAth -> then add Gamepath
if Not ((Length(ConfigFile) > 2) AND (ConfigFile[2] = ':')) then
ConfigFile := ExtractFilePath(ParamStr(0)) + Configfile;
end;
end
else if (Command = 'scorefile') then
begin
//Check if there is another Parameter to get the Value from
if (PCount > I) then
begin
//Write Value to String
ScoreFile := ParamStr(I + 1);
end;
end;
end;
end;
{ Log.LogError('Values: ');
if Debug then
Log.LogError('Debug');
if Benchmark then
Log.LogError('Benchmark');
if NoLog then
Log.LogError('NoLog');
if Fullscreen then
Log.LogError('FullScreen');
if JoyStick then
Log.LogError('Joystick');
Log.LogError('Screens: ' + Inttostr(Screens));
Log.LogError('Depth: ' + Inttostr(Depth));
Log.LogError('Resolution: ' + Inttostr(Resolution));
Log.LogError('Resolution: ' + Inttostr(Language));
Log.LogError('sResolution: ' + sResolution);
Log.LogError('sLanguage: ' + sLanguage);
Log.LogError('ConfigFile: ' + ConfigFile);
Log.LogError('SongPath: ' + SongPath);
Log.LogError('ScoreFile: ' + ScoreFile); }
end;
//-------------
// GetLanguage - Get Language ID from saved String Information
//-------------
Function TCMDParams.GetLanguage: Integer;
var
I: integer;
begin
Result := -1;
{* JB - 12sep07 to remove uINI dependency
//Search for Language
For I := 0 to high(ILanguage) do
if (LowerCase(ILanguage[I]) = sLanguage) then
begin
Result := I;
Break;
end;
*}
end;
//-------------
// GetResolution - Get Resolution ID from saved String Information
//-------------
Function TCMDParams.GetResolution: Integer;
var
I: integer;
begin
Result := -1;
{* JB - 12sep07 to remove uINI dependency
//Search for Resolution
For I := 0 to high(IResolution) do
if (LowerCase(IResolution[I]) = sResolution) then
begin
Result := I;
Break;
end;
*}
end;
end.
|