diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-15 09:41:41 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-15 09:41:41 +0000 |
commit | be3de7a824381249d32e301646503afe4f1aca66 (patch) | |
tree | d63b52bfb6f6df0d489c47f6560deaa6d6680632 /src/base | |
parent | b277ee24fdac7c45e159262ac9645d7cc42c5f22 (diff) | |
download | usdx-be3de7a824381249d32e301646503afe4f1aca66.tar.gz usdx-be3de7a824381249d32e301646503afe4f1aca66.tar.xz usdx-be3de7a824381249d32e301646503afe4f1aca66.zip |
- It is not possible to handle the window/fullscreen command-line parameters with a single boolean member like TCMDParams.Fullscreen. It was replaced by ScreenMode: TScreenMode with TScreenMode = (scmDefault, scmFullscreen, scmWindowed)
- cleanup
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1384 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/UCommandLine.pas | 250 | ||||
-rw-r--r-- | src/base/UGraphic.pas | 21 |
2 files changed, 130 insertions, 141 deletions
diff --git a/src/base/UCommandLine.pas b/src/base/UCommandLine.pas index 8bdc4f5a..cd1b0352 100644 --- a/src/base/UCommandLine.pas +++ b/src/base/UCommandLine.pas @@ -10,44 +10,46 @@ interface type - //----------- - // TCMDParams - Class Reads Infos from ParamStr and set some easy Interface Variables - //----------- + TScreenMode = (scmDefault, scmFullscreen, scmWindowed); + + {** + * 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; + fLanguage: string; + fResolution: string; - procedure showhelp(); + procedure ShowHelp(); - //Pseudo Integer Values - Function GetLanguage: Integer; - Property Language: Integer read GetLanguage; + procedure ReadParamInfo; + procedure ResetVariables; - Function GetResolution: Integer; - Property Resolution: Integer read GetResolution; - - //Some Procedures for Reading Infos - Constructor Create; - - Procedure ResetVariables; - Procedure ReadParamInfo; + function GetLanguage: integer; + function GetResolution: integer; + public + // some boolean variables set when reading infos + Debug: boolean; + Benchmark: boolean; + NoLog: boolean; + ScreenMode: TScreenMode; + 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; + + // pseudo integer values + property Language: integer read GetLanguage; + property Resolution: integer read GetResolution; + + // some procedures for reading infos + constructor Create; end; var @@ -62,98 +64,93 @@ const implementation uses SysUtils, - uPlatform; -// uINI -- Nasty requirement... ( removed with permission of blindy ) + UPlatform; - -//------------- -// Constructor - Create class, Reset Variables and Read Infos -//------------- -Constructor TCMDParams.Create; +{** + * Resets variables and reads info + *} +constructor TCMDParams.Create; begin inherited; if FindCmdLineSwitch( cHelp ) or FindCmdLineSwitch( 'h' ) then - showhelp(); + ShowHelp(); ResetVariables; ReadParamInfo; end; -procedure TCMDParams.showhelp(); +procedure TCMDParams.ShowHelp(); - function s( aString : String ) : string; + function Fmt(aString : string) : string; begin - result := aString + StringofChar( ' ', 15 - length( aString ) ); + Result := Format('%-15s', [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( '' ); +begin + writeln; + writeln('**************************************************************'); + writeln(' UltraStar Deluxe - Command line switches '); + writeln('**************************************************************'); + writeln; + writeln(' '+ Fmt('Switch') +' : Purpose'); + writeln(' ----------------------------------------------------------'); + writeln(' '+ Fmt(cMediaInterfaces) +' : Show in-use media interfaces'); + writeln(' '+ Fmt(cDebug) +' : Display Debugging info'); + writeln; platform.halt; end; -//------------- -// ResetVariables - Reset Class Variables -//------------- -Procedure TCMDParams.ResetVariables; +{** + * Reset Class Variables + *} +procedure TCMDParams.ResetVariables; begin Debug := False; Benchmark := False; NoLog := False; - FullScreen := False; + ScreenMode := scmDefault; Joypad := False; - //Some Value Variables Set when Reading Infos {-1: Not Set, others: Value} - sResolution := ''; - sLanguage := ''; + // some value variables set when reading infos {-1: Not Set, others: Value} + fResolution := ''; + fLanguage := ''; Depth := -1; Screens := -1; - //Some Strings Set when Reading Infos {Length=0 Not Set} + // some strings set when reading infos {Length=0 Not Set} SongPath := ''; ConfigFile := ''; ScoreFile := ''; end; -//------------- -// ReadParamInfo - Read Infos from Parameters -//------------- -Procedure TCMDParams.ReadParamInfo; +{** + * Read command-line parameters + *} +procedure TCMDParams.ReadParamInfo; var - I: Integer; - PCount: Integer; - Command: String; + I: integer; + PCount: integer; + Command: string; begin PCount := ParamCount; //Log.LogError('ParamCount: ' + Inttostr(PCount)); - - //Check all Parameters - For I := 1 to PCount do + // 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 + Command := ParamStr(I); + // check if the string is a parameter + if (Length(Command) > 1) and (Command[1] = '-') then begin - //Remove - from Command - Command := Lowercase(Trim(Copy(Command, 2, Length(Command) - 1))); + // remove '-' from command + Command := LowerCase(Trim(Copy(Command, 2, Length(Command) - 1))); //Log.LogError('Command prepared: ' + Command); - //Check Command + // check command - // Boolean Triggers: + // boolean triggers if (Command = 'debug') then Debug := True else if (Command = 'benchmark') then @@ -161,21 +158,22 @@ begin else if (Command = 'nolog') then NoLog := True else if (Command = 'fullscreen') then - Fullscreen := True + ScreenMode := scmFullscreen else if (Command = 'window') then - Fullscreen := False + ScreenMode := scmWindowed else if (Command = 'joypad') then Joypad := True - //Integer Variables + // integer variables else if (Command = 'depth') then begin - //Check if there is another Parameter to get the Value from + // check if there is another Parameter to get the Value from if (PCount > I) then begin Command := ParamStr(I + 1); - //Check for valid Value + // check for valid value + // FIXME: guessing an array-index of depth is very error prone. If (Command = '16') then Depth := 0 Else If (Command = '32') then @@ -185,12 +183,12 @@ begin else if (Command = 'screens') then begin - //Check if there is another Parameter to get the Value from + // check if there is another parameter to get the value from if (PCount > I) then begin Command := ParamStr(I + 1); - //Check for valid Value + // check for valid value If (Command = '1') then Screens := 0 Else If (Command = '2') then @@ -198,47 +196,47 @@ begin end; end - //Pseudo Integer Values + // pseudo integer values else if (Command = 'language') then begin - //Check if there is another Parameter to get the Value from + // 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)); + // write value to string + fLanguage := Lowercase(ParamStr(I + 1)); end; end else if (Command = 'resolution') then begin - //Check if there is another Parameter to get the Value from + // 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)); + // write value to string + fResolution := Lowercase(ParamStr(I + 1)); end; end - //String Values + // string values else if (Command = 'songpath') then begin - //Check if there is another Parameter to get the Value from + // check if there is another parameter to get the value from if (PCount > I) then begin - //Write Value to String + // 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 + // check if there is another parameter to get the value from if (PCount > I) then begin - //Write Value to String + // write value to string ConfigFile := ParamStr(I + 1); - //is this a relative PAth -> then add Gamepath + // is this a relative path -> then add gamepath if Not ((Length(ConfigFile) > 2) AND (ConfigFile[2] = ':')) then ConfigFile := ExtractFilePath(ParamStr(0)) + Configfile; end; @@ -246,10 +244,10 @@ begin else if (Command = 'scorefile') then begin - //Check if there is another Parameter to get the Value from + // check if there is another parameter to get the value from if (PCount > I) then begin - //Write Value to String + // write value to string ScoreFile := ParamStr(I + 1); end; end; @@ -258,43 +256,27 @@ begin 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.LogInfo('Screens: ' + Inttostr(Screens)); + Log.LogInfo('Depth: ' + Inttostr(Depth)); - Log.LogError('Resolution: ' + Inttostr(Resolution)); - Log.LogError('Resolution: ' + Inttostr(Language)); + Log.LogInfo('Resolution: ' + Inttostr(Resolution)); + Log.LogInfo('Resolution: ' + Inttostr(Language)); - Log.LogError('sResolution: ' + sResolution); - Log.LogError('sLanguage: ' + sLanguage); + Log.LogInfo('sResolution: ' + sResolution); + Log.LogInfo('sLanguage: ' + sLanguage); - Log.LogError('ConfigFile: ' + ConfigFile); - Log.LogError('SongPath: ' + SongPath); - Log.LogError('ScoreFile: ' + ScoreFile); } + Log.LogInfo('ConfigFile: ' + ConfigFile); + Log.LogInfo('SongPath: ' + SongPath); + Log.LogInfo('ScoreFile: ' + ScoreFile); +} end; //------------- // GetLanguage - Get Language ID from saved String Information //------------- -Function TCMDParams.GetLanguage: Integer; +function TCMDParams.GetLanguage: integer; var I: integer; begin @@ -314,7 +296,7 @@ end; //------------- // GetResolution - Get Resolution ID from saved String Information //------------- -Function TCMDParams.GetResolution: Integer; +function TCMDParams.GetResolution: integer; var I: integer; begin diff --git a/src/base/UGraphic.pas b/src/base/UGraphic.pas index 35d8fd3b..724e3bed 100644 --- a/src/base/UGraphic.pas +++ b/src/base/UGraphic.pas @@ -549,6 +549,7 @@ var I: integer; W, H: integer; Depth: Integer; + Fullscreen: boolean; begin if (Params.Screens <> -1) then Screens := Params.Screens + 1 @@ -592,16 +593,22 @@ begin Log.LogStatus('SDL_SetVideoMode', 'Initialize3D'); - if (Ini.FullScreen = 0) and (Not Params.FullScreen) then - begin - Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Windowed'); - screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE) - end - else + // check whether to start in fullscreen or windowed mode. + // The command-line parameters take precedence over the ini settings. + Fullscreen := ((Ini.FullScreen = 1) or (Params.ScreenMode = scmFullscreen)) and + not (Params.ScreenMode = scmWindowed); + + if Fullscreen then begin Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Full Screen'); screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN ); SDL_ShowCursor(0); + end + else + begin + Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Windowed'); + screen := SDL_SetVideoMode(W, H, 0, SDL_OPENGL or SDL_RESIZABLE); + SDL_ShowCursor(1); end; if (screen = nil) then @@ -631,7 +638,7 @@ begin Display.CurrentScreen := @ScreenLoading; - swapbuffers; + SwapBuffers; ScreenLoading.Draw; Display.Draw; |