# HG changeset patch
# User RowanD
# Date 1355699898 -3600
# Node ID 8d7c52b24e28d2655c5badf6a9c5a5bd515e2df6
# Parent 039ceb443aca1083ec6cec8906ec8050daaacd81
GCI2012: Optional Second Argument
diff -r 039ceb443aca -r 8d7c52b24e28 QTfrontend/hwform.cpp
--- a/QTfrontend/hwform.cpp Sun Dec 16 18:50:00 2012 +0100
+++ b/QTfrontend/hwform.cpp Mon Dec 17 00:18:18 2012 +0100
@@ -1879,14 +1879,17 @@
// used for --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]
QString HWForm::getDemoArguments()
{
+
+ QString prefix = datadir->absolutePath();
+ QString userPrefix = cfgdir->absolutePath();
#ifdef Q_WS_WIN
- QString userdir = cfgdir->absolutePath().replace("/","\\");
-#else
- QString userdir = cfgdir->absolutePath();
+ prefix = prefix.replace("/","\\");
+ userPrefix = userPrefix.replace("/","\\");
#endif
QRect resolution = config->vid_Resolution();
- return QString("--user-dir " + userdir
+ return QString("--prefix " + prefix
+ + " --user-prefix " + userPrefix
+ " --width " + QString::number(resolution.width())
+ " --height " + QString::number(resolution.height())
+ " --volume " + QString::number(config->volume())
@@ -1912,8 +1915,8 @@
registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types"));
registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0");
registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0");
- registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
- registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
+ registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments);
+ registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments);
#elif defined __APPLE__
// only useful when other apps have taken precedence over our file extensions and you want to reset it
system("defaults write com.apple.LaunchServices LSHandlers -array-add 'LSHandlerContentTaghwdLSHandlerContentTagClasspublic.filename-extensionLSHandlerRoleAllorg.hedgewars.desktop'");
diff -r 039ceb443aca -r 8d7c52b24e28 hedgewars/ArgParsers.inc
--- a/hedgewars/ArgParsers.inc Sun Dec 16 18:50:00 2012 +0100
+++ b/hedgewars/ArgParsers.inc Mon Dec 17 00:18:18 2012 +0100
@@ -75,10 +75,11 @@
begin
WriteLn(stdout, 'Usage:');
WriteLn(stdout, '');
- WriteLn(stdout, ' hwengine [options]');
+ WriteLn(stdout, ' hwengine [options]');
WriteLn(stdout, '');
WriteLn(stdout, 'where [options] are any of the following:');
- WriteLn(stdout, ' --user-dir [path to user data folder]');
+ WriteLn(stdout, ' --prefix [path to folder]');
+ WriteLn(stdout, ' --user-prefix [path to folder]');
WriteLn(stdout, ' --locale [name of language file]');
WriteLn(stdout, ' --width [screen width in pixels]');
WriteLn(stdout, ' --height [screen height in pixels]');
@@ -127,8 +128,8 @@
const otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
const mediaArray: Array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen');
const allArray: Array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--time','--lowquality');
-const reallyAll: array[0..21] of shortstring = (
- '--user-dir', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
+const reallyAll: array[0..22] of shortstring = (
+ '--prefix', '--user-prefix', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality',
{deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
'--stats-only', '--gci', '--help');
@@ -142,33 +143,34 @@
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex);
case cmdIndex of
- {--user-dir} 0 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter);
- {--locale} 1 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter);
- {--width} 2 : cScreenWidth := getLongIntParameter(arg, paramIndex, parseParameter);
- {--height} 3 : cScreenHeight := getLongIntParameter(arg, paramIndex, parseParameter);
- {--frame-interval} 4 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter);
- {--volume} 5 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) );
- {--nomusic} 6 : SetMusic ( false );
- {--nosound} 7 : SetSound ( false );
- {--fullscreen} 8 : cFullScreen := true;
- {--showfps} 9 : cShowFPS := true;
- {--altdmg} 10 : cAltDamage := true;
- {--low-quality} 11 : cReducedQuality:= $FFFFFFFF xor rqLowRes;
- {--raw-quality} 12 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter);
+ {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter);
+ {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter);
+ {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter);
+ {--width} 3 : cScreenWidth := getLongIntParameter(arg, paramIndex, parseParameter);
+ {--height} 4 : cScreenHeight := getLongIntParameter(arg, paramIndex, parseParameter);
+ {--frame-interval} 5 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter);
+ {--volume} 6 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) );
+ {--nomusic} 7 : SetMusic ( false );
+ {--nosound} 8 : SetSound ( false );
+ {--fullscreen} 9 : cFullScreen := true;
+ {--showfps} 10 : cShowFPS := true;
+ {--altdmg} 11 : cAltDamage := true;
+ {--low-quality} 12 : cReducedQuality:= $FFFFFFFF xor rqLowRes;
+ {--raw-quality} 13 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter);
{deprecated options}
- {--depth} 13 : cBits := getLongIntParameter(arg, paramIndex, parseParameter);
- {--set-video} 14 : parseClassicParameter(videoArray,3,paramIndex);
- {--set-audio} 15 : parseClassicParameter(audioArray,3,paramIndex);
- {--set-other} 16 : parseClassicParameter(otherArray,3,paramIndex);
- {--set-multimedia} 17 : parseClassicParameter(mediaArray,8,paramIndex);
- {--set-everything} 18 : parseClassicParameter(allArray,12,paramIndex);
+ {--depth} 14 : cBits := getLongIntParameter(arg, paramIndex, parseParameter);
+ {--set-video} 15 : parseClassicParameter(videoArray,3,paramIndex);
+ {--set-audio} 16 : parseClassicParameter(audioArray,3,paramIndex);
+ {--set-other} 17 : parseClassicParameter(otherArray,3,paramIndex);
+ {--set-multimedia} 18 : parseClassicParameter(mediaArray,8,paramIndex);
+ {--set-everything} 19 : parseClassicParameter(allArray,12,paramIndex);
{anything else}
- {--stats-only} 19 : begin
+ {--stats-only} 20 : begin
cOnlyStats:= true;
cReducedQuality:= $FFFFFFFF xor rqLowRes;
SetSound(false);
end;
- {--gci} 20 : begin // We had to make up all this saved space some how... \\
+ {--gci} 21 : begin // We had to make up all this saved space some how... \\
WriteLn(stdout, ' ');
WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ ');
WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// ');
@@ -184,15 +186,21 @@
WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva ');
WriteLn(stdout, ' ');
end;
- {--help} 21 : begin
+ {--help} 22 : begin
DisplayUsage();
GameType:= gmtSyntax;
end;
else
begin
- WriteLn(stderr, 'ERROR: '+cmd+' is not a valid argument');
- parseParameter:= true;
- end
+ //Asusme the first "non parameter" is the replay file, anything else is invalid
+ if recordFileName = '' then
+ recordFileName := cmd
+ else
+ begin
+ WriteLn(stderr, 'ERROR: '+cmd+' is not a valid argument');
+ parseParameter:= true;
+ end;
+ end;
end;
end;
diff -r 039ceb443aca -r 8d7c52b24e28 hedgewars/config.inc.in
--- a/hedgewars/config.inc.in Sun Dec 16 18:50:00 2012 +0100
+++ b/hedgewars/config.inc.in Mon Dec 17 00:18:18 2012 +0100
@@ -24,3 +24,4 @@
const cNetProtoVersion = ${HEDGEWARS_PROTO_VER};
cVersionString = '${HEDGEWARS_VERSION}';
cLuaLibrary = '${LUA_LIBRARY}';
+ cDefaultPathPrefix = '${DATA_INSTALL_DIR}';
diff -r 039ceb443aca -r 8d7c52b24e28 hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas Sun Dec 16 18:50:00 2012 +0100
+++ b/hedgewars/hwengine.pas Mon Dec 17 00:18:18 2012 +0100
@@ -581,27 +581,21 @@
end
{$ENDIF};
- if (ParamCount < 2) then
+ UserPathPrefix := '.';
+ PathPrefix := cDefaultPathPrefix;
+ recordFileName := '';
+ startIndex := 1;
+ playReplayFileWithParameters(startIndex);
+
+ if (recordFileName = '') then
begin
DisplayUsage();
GameType:= gmtSyntax;
- end
- else
- begin
- if (ParamCount >= 2) then
- begin
- UserPathPrefix := '.';
- PathPrefix := ParamStr(1);
- recordFileName := ParamStr(2);
- startIndex := 3;
- end;
-
- playReplayFileWithParameters(startIndex);
end;
(*
- WriteLn(stdout,recordFilename);
- WriteLn(stdout,PathPrefix);
- WriteLn(stdout,UserPathPrefix);
+ WriteLn(stdout,'PathPrefix: ' + PathPrefix);
+ WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix);
+ WriteLn(stdout,'recordFilename: ' + recordFilename);
*)
end;