Special script parameter variable in game scheme
authorunc0rr
Wed, 01 Jan 2014 14:16:01 +0400
changeset 9902 eb8e8b09b2f0
parent 9900 34ba1d8e0e9a
child 9904 ef3321c86912
Special script parameter variable in game scheme
QTfrontend/model/ammoSchemeModel.cpp
QTfrontend/ui/page/pagescheme.cpp
QTfrontend/ui/page/pagescheme.h
QTfrontend/ui/widget/gamecfgwidget.cpp
hedgewars/uCommandHandlers.pas
hedgewars/uScript.pas
hedgewars/uVariables.pas
share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua
--- a/QTfrontend/model/ammoSchemeModel.cpp	Wed Jan 01 13:42:38 2014 +0400
+++ b/QTfrontend/model/ammoSchemeModel.cpp	Wed Jan 01 14:16:01 2014 +0400
@@ -65,6 +65,7 @@
                                 << QVariant(100)           // rope modfier   39
                                 << QVariant(100)           // get away time  40
                                 << QVariant(0)             // world edge     41
+                                << QVariant()              // scriptparam    42
                                 ;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -130,6 +131,7 @@
               << "ropepct"             // 39
               << "getawaytime"         // 40
               << "worldedge"           // 41
+              << "scriptparam"         // scriptparam    42
               ;
 
     QList<QVariant> proMode;
@@ -176,6 +178,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> shoppa;
@@ -222,6 +225,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> cleanslate;
@@ -268,6 +272,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> minefield;
@@ -314,6 +319,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> barrelmayhem;
@@ -360,6 +366,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> tunnelhogs;
@@ -406,6 +413,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> forts;
@@ -452,6 +460,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> timeless;
@@ -498,6 +507,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> thinkingportals;
@@ -544,6 +554,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> kingmode;
@@ -590,6 +601,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
 
--- a/QTfrontend/ui/page/pagescheme.cpp	Wed Jan 01 13:42:38 2014 +0400
+++ b/QTfrontend/ui/page/pagescheme.cpp	Wed Jan 01 14:16:01 2014 +0400
@@ -390,6 +390,7 @@
     l->setFixedSize(32,32);
     l->setPixmap(QPixmap(":/res/iconEarth.png"));
     glBSLayout->addWidget(l,15,1,1,1);
+
     CB_WorldEdge = new QComboBox(gbBasicSettings);
     CB_WorldEdge->insertItem(0, tr("None (Default)"));
     CB_WorldEdge->insertItem(1, tr("Wrap (World wraps)"));
@@ -400,6 +401,20 @@
 
 
     l = new QLabel(gbBasicSettings);
+    l->setText(QLabel::tr("Script parameter"));
+    l->setWordWrap(true);
+    glBSLayout->addWidget(l,16,0,1,1);
+    l = new QLabel(gbBasicSettings);
+    l->setFixedSize(32,32);
+    l->setPixmap(QPixmap(":/res/iconBox.png"));
+    glBSLayout->addWidget(l,16,1,1,1);
+
+    LE_ScriptParam = new QLineEdit(gbBasicSettings);
+    LE_ScriptParam->setMaxLength(240);
+    glBSLayout->addWidget(LE_ScriptParam,16,2,1,1);
+
+
+    l = new QLabel(gbBasicSettings);
     l->setText(QLabel::tr("Scheme Name:"));
 
     LE_name = new QLineEdit(this);
@@ -489,6 +504,7 @@
     mapper->addMapping(SB_RopeModifier, 39);
     mapper->addMapping(SB_GetAwayTime, 40);
     mapper->addMapping(CB_WorldEdge, 41, "currentIndex");
+    mapper->addMapping(LE_ScriptParam, 42);
 
     mapper->toFirst();
 }
--- a/QTfrontend/ui/page/pagescheme.h	Wed Jan 01 13:42:38 2014 +0400
+++ b/QTfrontend/ui/page/pagescheme.h	Wed Jan 01 14:16:01 2014 +0400
@@ -93,6 +93,7 @@
         QSpinBox * SB_GetAwayTime;
         QComboBox * CB_WorldEdge;
         QLineEdit * LE_name;
+        QLineEdit * LE_ScriptParam;
 
         QGroupBox * gbGameModes;
         QGroupBox * gbBasicSettings;
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Wed Jan 01 13:42:38 2014 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Wed Jan 01 14:16:01 2014 +0400
@@ -324,7 +324,8 @@
     bcfg << QString("e$worldedge %1").arg(schemeData(41).toInt()).toUtf8();
     bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
     bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
-
+    if(!schemeData(42).isNull())
+        bcfg << QString("e$scriptparam %1").arg(schemeData(42).toString()).toUtf8();
 
 
     switch (mapgen)
--- a/hedgewars/uCommandHandlers.pas	Wed Jan 01 13:42:38 2014 +0400
+++ b/hedgewars/uCommandHandlers.pas	Wed Jan 01 14:16:01 2014 +0400
@@ -119,6 +119,11 @@
 ScriptLoad(s)
 end;
 
+procedure chScriptParam(var s: shortstring);
+begin
+    cScriptParam:= s;
+end;
+
 procedure chCurU_p(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
@@ -796,6 +801,7 @@
 //////// End top by freq analysis
     RegisterVariable('gencmd'  , @chGenCmd       , false);
     RegisterVariable('script'  , @chScript       , false);
+    RegisterVariable('scriptparam', @chScriptParam, false);
     RegisterVariable('proto'   , @chCheckProto   , true );
     RegisterVariable('spectate', @chFastUntilLag   , false);
     RegisterVariable('capture' , @chCapture      , true );
--- a/hedgewars/uScript.pas	Wed Jan 01 13:42:38 2014 +0400
+++ b/hedgewars/uScript.pas	Wed Jan 01 14:16:01 2014 +0400
@@ -2042,9 +2042,9 @@
 ScriptSetInteger('HealthDecrease', cHealthDecrease);
 ScriptSetInteger('GetAwayTime', cGetAwayTime);
 ScriptSetString('Map', cMapName);
-
 ScriptSetString('Theme', '');
 ScriptSetString('Goals', '');
+ScriptSetString('ScriptParam', cScriptParam);
 
 ScriptCall('onGameInit');
 
@@ -2444,7 +2444,6 @@
 ScriptSetInteger('gmPrecise', gmPrecise);
 ScriptSetInteger('gmAllStoppable', gmAllStoppable);
 
-
 // speech bubbles
 ScriptSetInteger('SAY_SAY', 1);
 ScriptSetInteger('SAY_THINK', 2);
--- a/hedgewars/uVariables.pas	Wed Jan 01 13:42:38 2014 +0400
+++ b/hedgewars/uVariables.pas	Wed Jan 01 14:16:01 2014 +0400
@@ -147,6 +147,7 @@
     cExplosives     : Longword;
 
     cScriptName     : shortstring;
+    cScriptParam    : shortstring;
     cSeed           : shortstring;
     cVolumeDelta    : LongInt;
     cHasFocus       : boolean;
@@ -2551,6 +2552,7 @@
     fastScrolling   := false;
     autoCameraOn    := true;
     cScriptName     := '';
+    cScriptParam    := '';
     cSeed           := '';
     cVolumeDelta    := 0;
     cHasFocus       := true;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Wed Jan 01 13:42:38 2014 +0400
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Wed Jan 01 14:16:01 2014 +0400
@@ -21,8 +21,7 @@
 end
 
 function onGameInit()
-    gravity = GetAwayTime
-    GetAwayTime = 100
+    gravity = ScriptParam
 end
 
 function onGameStart()
@@ -30,4 +29,4 @@
                 loc("Current value is ") .. gravity .. "%",
                 loc("Set any gravity value you want by adjusting get away time"),
                 0, 5000)
-end
\ No newline at end of file
+end