hedgewars/ArgParsers.inc
author Stepan777 <stepik-777@mail.ru>
Sun, 24 Jun 2012 20:57:02 +0400
changeset 7280 fd707afbc3a2
parent 7235 baa69bd025d9
child 7306 3cff5c769509
permissions -rw-r--r--
pagevideos is now much better that before: 1. Display list of video files. 2. For each file in progress display progress bar. 3. Description for each file (size, duration etc). 4. It is possible to remove and rename files. 5. Video file can be launched in external media player. 6. ... also fixed some bugs http://postimage.org/image/hk87cuqm9/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     1
(*
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6700
e04da46ee43c the most important commit of the year
koda
parents: 6580
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     4
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     8
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    12
 * GNU General Public License for more details.
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    13
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    14
 * You should have received a copy of the GNU General Public License
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    15
 * along with this program; if not, write to the Free Software
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
088d40d8aba2 Happy 2011 :)
koda
parents: 4004
diff changeset
    17
 *)
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    18
5130
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    19
procedure playReplayFileWithParameters(); forward;
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    20
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    21
procedure internalSetGameTypeLandPreviewFromParameters();
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    22
begin
5130
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    23
    if ParamStr(3) = '--stats-only' then
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    24
        playReplayFileWithParameters()
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    25
    else
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    26
        begin
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    27
        ipcPort:= StrToInt(ParamStr(2));
5130
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    28
        GameType:= gmtLandPreview;
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    29
        if ParamStr(3) <> 'landpreview' then
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    30
            GameType:= gmtSyntax
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
    31
        end
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    32
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    33
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    34
procedure internalStartGameWithParameters();
4004
b1c2c2f6fc5e update branch with latest head, most likely breaking water color in stereo mode
koda
parents: 3858
diff changeset
    35
var tmp: LongInt;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    36
begin
5239
f34f391a223b Bit more reusability
nemo
parents: 5238
diff changeset
    37
    UserPathPrefix:= ParamStr(1);
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    38
    cScreenWidth:= StrToInt(ParamStr(2));
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    39
    cScreenHeight:= StrToInt(ParamStr(3));
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    40
    cBits:= StrToInt(ParamStr(4));
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    41
    ipcPort:= StrToInt(ParamStr(5));
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    42
    cFullScreen:= ParamStr(6) = '1';
7021
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
    43
    SetSound(ParamStr(7) = '1');
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
    44
    SetMusic(ParamStr(8) = '1');
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    45
    SetVolume(StrToInt(ParamStr(9)));
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    46
    cTimerInterval:= StrToInt(ParamStr(10));
3709
c7849b74748d clean and reorder arguments passed to engine
koda
parents: 3708
diff changeset
    47
    PathPrefix:= ParamStr(11);
c7849b74748d clean and reorder arguments passed to engine
koda
parents: 3708
diff changeset
    48
    cShowFPS:= ParamStr(12) = '1';
c7849b74748d clean and reorder arguments passed to engine
koda
parents: 3708
diff changeset
    49
    cAltDamage:= ParamStr(13) = '1';
c7849b74748d clean and reorder arguments passed to engine
koda
parents: 3708
diff changeset
    50
    UserNick:= DecodeBase64(ParamStr(14));
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    51
    cReducedQuality:= StrToInt(ParamStr(15));
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    52
    tmp:= StrToInt(ParamStr(16));
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6700
diff changeset
    53
    GrayScale:= false;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5239
diff changeset
    54
    if (tmp > 9) and (tmp < 16) then 
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5239
diff changeset
    55
        begin
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6700
diff changeset
    56
        GrayScale:= true;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5239
diff changeset
    57
        cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9)))
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5239
diff changeset
    58
        end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6426
diff changeset
    59
    else if tmp <= 9 then 
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6426
diff changeset
    60
        cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp)))
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6426
diff changeset
    61
    else 
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6426
diff changeset
    62
        cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6)));
4004
b1c2c2f6fc5e update branch with latest head, most likely breaking water color in stereo mode
koda
parents: 3858
diff changeset
    63
    cLocaleFName:= ParamStr(17);
7198
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    64
{$IFDEF USE_VIDEO_RECORDING}
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    65
    cVideoFramerateNum:= StrToInt(ParamStr(18));
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    66
    cVideoFramerateDen:= StrToInt(ParamStr(19));
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    67
{$ENDIF}
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    68
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    69
7198
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    70
{$IFDEF USE_VIDEO_RECORDING}
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    71
procedure internalStartVideoRecordingWithParameters();
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    72
begin
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    73
    internalStartGameWithParameters();
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    74
    GameType:= gmtRecord;
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    75
    cRecPrefix:= ParamStr(20);
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    76
    cAVFormat:= ParamStr(21);
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    77
    cVideoCodec:= ParamStr(22);
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    78
    cVideoQuality:= StrToInt(ParamStr(23));
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    79
    cVideoPreset:= ParamStr(24);
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    80
    cAudioCodec:= ParamStr(25);
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    81
    cAudioQuality:= StrToInt(ParamStr(26));
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    82
end;
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    83
{$ENDIF}
5debd5fe526e 1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents: 7180
diff changeset
    84
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    85
procedure setVideo(screenWidth: LongInt; screenHeight: LongInt; bitsStr: LongInt);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    86
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    87
    cScreenWidth:= screenWidth;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    88
    cScreenHeight:= screenHeight;
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
    89
    cBits:= bitsStr
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    90
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    91
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    92
procedure setVideoWithParameters(screenWidthParam: string; screenHeightParam: string; bitsParam: string);
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    93
var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt, c: LongInt;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    94
begin
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    95
    val(screenWidthParam, screenWidthAsInt, c);
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    96
    val(screenHeightParam, screenHeightAsInt, c);
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
    97
    val(bitsParam, bitsStrAsInt, c);
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
    98
    setVideo(screenWidthAsInt,screenHeightAsInt,bitsStrAsInt)
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
    99
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   100
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   101
procedure setOtherOptions(languageFile: string; fullScreen: boolean);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   102
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   103
    cLocaleFName:= languageFile;
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   104
    cFullScreen:= fullScreen
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   105
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   106
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   107
procedure setShowFPS(showFPS: boolean);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   108
begin
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   109
    cShowFPS:= showFPS
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   110
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   111
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   112
procedure setOtherOptionsWithParameters(languageFileParam: string; fullScreenParam: string; showFPSParam: string);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   113
var fullScreen, showFPS: boolean;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   114
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   115
    fullScreen:= fullScreenParam = '1';
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   116
    showFPS:= showFPSParam = '1';
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   117
    setOtherOptions(languageFileParam,fullScreen);
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   118
    setShowFPS(showFPS)
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   119
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   120
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   121
procedure setAudio(initialVolume: LongInt; musicEnabled: boolean; soundEnabled: boolean);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   122
begin
7021
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
   123
    SetVolume(initialVolume);
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
   124
    SetMusic(musicEnabled);
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
   125
    SetSound(soundEnabled);
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   126
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   127
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   128
procedure setAudioWithParameters(initialVolumeParam: string; musicEnabledParam: string; soundEnabledParam: string);
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
   129
var initialVolumeAsInt, c: LongInt;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   130
    musicEnabled, soundEnabled: boolean;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   131
begin
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
   132
    val(initialVolumeParam, initialVolumeAsInt, c);
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   133
    musicEnabled:= musicEnabledParam = '1';
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   134
    soundEnabled:= soundEnabledParam = '1';
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   135
    setAudio(initialVolumeAsInt,musicEnabled, soundEnabled)
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   136
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   137
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   138
procedure setMultimediaOptionsWithParameters(screenWidthParam, screenHeightParam, bitsParam: string;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   139
                                             initialVolumeParam, musicEnabledParam, soundEnabledParam: string;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   140
                                             languageFileParam, fullScreenParam: string);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   141
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   142
    setVideoWithParameters(screenWidthParam,screenHeightParam, bitsParam);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   143
    setAudioWithParameters(initialVolumeParam,musicEnabledParam,soundEnabledParam);
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   144
    setOtherOptions(languageFileParam,fullScreenParam = '1')
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   145
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   146
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   147
procedure setAltDamageTimerValueAndQuality(altDamage: boolean; timeIterval: LongInt; reducedQuality: boolean);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   148
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   149
    cAltDamage:= altDamage;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   150
    cTimerInterval:= timeIterval;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   151
    if (reducedQuality) then        //HACK
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   152
        cReducedQuality:= $FFFFFFFF xor rqLowRes
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   153
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   154
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   155
procedure setAllOptionsWithParameters(screenWidthParam:string; screenHeightParam:string; bitsParam:string;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   156
                                      initialVolumeParam:string; musicEnabledParam:string; soundEnabledParam:string;
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   157
                                      languageFileParam:string; fullScreenParam:string; showFPSParam:string;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   158
                                      altDamageParam:string; timeItervalParam:string; reducedQualityParam: string);
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   159
var showFPS, altDamage, reducedQuality: boolean;
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
   160
    timeIterval, c: LongInt;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   161
begin
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   162
    setMultimediaOptionsWithParameters(screenWidthParam,screenHeightParam, bitsParam,
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   163
                                       initialVolumeParam,musicEnabledParam,soundEnabledParam,
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   164
                                       languageFileParam,fullScreenParam);
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   165
    showFPS := showFPSParam = '1';
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   166
    setShowFPS(showFPS);
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   167
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   168
    altDamage:= altDamageParam = '1';
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7021
diff changeset
   169
    val(timeItervalParam, timeIterval, c);
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   170
    reducedQuality:= reducedQualityParam = '1';
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   171
    setAltDamageTimerValueAndQuality(altDamage,timeIterval,reducedQuality);
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   172
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   173
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   174
procedure playReplayFileWithParameters();
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   175
var paramIndex: LongInt;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   176
    wrongParameter: boolean;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   177
begin
5239
f34f391a223b Bit more reusability
nemo
parents: 5238
diff changeset
   178
    UserPathPrefix:= ParamStr(1);
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5130
diff changeset
   179
    PathPrefix:= ParamStr(2);
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5130
diff changeset
   180
    recordFileName:= ParamStr(3);
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5130
diff changeset
   181
    paramIndex:= 4;
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   182
    wrongParameter:= false;
6426
2d44f6561e72 Help parser a bit
unc0rr
parents: 5441
diff changeset
   183
    while (paramIndex <= ParamCount) and (not wrongParameter) do
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   184
        begin
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   185
        if ParamStr(paramIndex) = '--set-video'  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   186
//--set-video [screen width] [screen height] [color dept]
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   187
            begin
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   188
            if(ParamCount-paramIndex < 3) then
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   189
                begin
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   190
                wrongParameter:= true;
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   191
                GameType:= gmtSyntax
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   192
                end;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   193
            setVideoWithParameters(ParamStr(paramIndex+1), ParamStr(paramIndex+2), ParamStr(paramIndex+3));
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   194
            paramIndex:= paramIndex + 4
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   195
            end
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   196
        else
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   197
//--set-audio [volume] [enable music] [enable sounds]
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   198
            if ParamStr(paramIndex) = '--set-audio'  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   199
                begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   200
                if(ParamCount-paramIndex < 3) then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   201
                    begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   202
                    wrongParameter := true;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   203
                    GameType:= gmtSyntax
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   204
                    end;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   205
                setAudioWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3));
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   206
                paramIndex:= paramIndex + 4
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   207
                end
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   208
            else
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   209
// --set-other [language file] [full screen] [show FPS]
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   210
                if ParamStr(paramIndex) = '--set-other'  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   211
                    begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   212
                    if(ParamCount-paramIndex < 3) then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   213
                        begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   214
                        wrongParameter:= true;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   215
                        GameType:= gmtSyntax
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   216
                        end;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   217
                    setOtherOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3));
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   218
                    paramIndex:= paramIndex + 4
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   219
                    end
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   220
                else
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   221
//--set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   222
                    if ParamStr(paramIndex) = '--set-multimedia'  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   223
                        begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   224
                        if ParamCount-paramIndex < 8  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   225
                            begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   226
                            wrongParameter:= true;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   227
                            GameType:= gmtSyntax
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   228
                            end;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   229
                        setMultimediaOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3),
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   230
                                                           ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6),
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   231
                                                           ParamStr(paramIndex+7),ParamStr(paramIndex+8));
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   232
                        paramIndex:= paramIndex + 9
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   233
                        end
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   234
                    else
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   235
//--set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   236
                        if ParamStr(paramIndex) = '--set-everything'  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   237
                            begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   238
                            if ParamCount-paramIndex < 12  then
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   239
                                begin
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   240
                                wrongParameter:= true;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   241
                                GameType:= gmtSyntax
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   242
                                end;
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   243
                            setAllOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3),
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   244
                                                        ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6),
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   245
                                                        ParamStr(paramIndex+7),ParamStr(paramIndex+8),ParamStr(paramIndex+9),
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   246
                                                        ParamStr(paramIndex+10),ParamStr(paramIndex+11),ParamStr(paramIndex+12));
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   247
                            paramIndex:= paramIndex + 13
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   248
                            end
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   249
                        else
5130
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   250
                            if ParamStr(paramIndex) = '--stats-only'  then
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   251
                                begin
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   252
                                cOnlyStats:= true;
7021
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
   253
                                SetSound(false);
0c75512a8920 adjust the scope of a few uSound variables and functions
koda
parents: 6982
diff changeset
   254
                                SetMusic(false);
5130
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   255
                                cReducedQuality:= $FFFFFFFF xor rqLowRes; // HACK
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   256
                                paramIndex:= paramIndex + 1
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   257
                                end
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   258
                            else
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   259
                                begin
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   260
                                wrongParameter:= true;
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   261
                                GameType:= gmtSyntax
3602ede67ec5 Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents: 4976
diff changeset
   262
                                end
3858
e40e5dfe9d5b clean up koda's indenting :-p
nemo
parents: 3709
diff changeset
   263
    end
3678
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   264
end;
00428183300f patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff changeset
   265