Start exit confirmation implementation
authorunc0rr
Sun, 22 Jun 2008 19:26:01 +0000
changeset 1022 f6a3fcb329ca
parent 1021 a6dcb1412a29
child 1023 2a32ee7affa3
Start exit confirmation implementation
QTfrontend/binds.cpp
QTfrontend/binds.h
hedgewars/CCHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uConsole.pas
hedgewars/uConsts.pas
hedgewars/uKeys.pas
--- a/QTfrontend/binds.cpp	Thu Jun 19 20:34:53 2008 +0000
+++ b/QTfrontend/binds.cpp	Sun Jun 22 19:26:01 2008 +0000
@@ -48,6 +48,7 @@
 	{"chat",	"t",	QT_TRANSLATE_NOOP("binds", "chat"),	false},
 	{"history",	"`",	QT_TRANSLATE_NOOP("binds", "chat history"),	false},
 	{"pause",	"p",	QT_TRANSLATE_NOOP("binds", "pause"),	false},
+	{"confirm",	"y",	QT_TRANSLATE_NOOP("binds", "confirmation"),	false},
 	{"+voldown",	"9",	QT_TRANSLATE_NOOP("binds", "volume down"),	false},
 	{"+volup",	"0",	QT_TRANSLATE_NOOP("binds", "volume up"),	false},
 	{"fullscr",	"f",	QT_TRANSLATE_NOOP("binds", "change mode"),	false},
--- a/QTfrontend/binds.h	Thu Jun 19 20:34:53 2008 +0000
+++ b/QTfrontend/binds.h	Sun Jun 22 19:26:01 2008 +0000
@@ -21,7 +21,7 @@
 
 #include <QString>
 
-#define BINDS_NUMBER 34
+#define BINDS_NUMBER 35
 
 struct BindAction
 {
--- a/hedgewars/CCHandlers.inc	Thu Jun 19 20:34:53 2008 +0000
+++ b/hedgewars/CCHandlers.inc	Sun Jun 22 19:26:01 2008 +0000
@@ -29,9 +29,23 @@
 end;
 ////////////////////////////////////////////////////////////////////////////////
 procedure chQuit(var s: shortstring);
+const prevGState: TGameState = gsConfirm;
 begin
-SendIPC('Q');
-GameState:= gsExit
+if GameState <> gsConfirm then
+        begin
+        prevGState:= GameState;
+        GameState:= gsConfirm
+        end else
+        GameState:= prevGState
+end;
+
+procedure chConfirm(var s: shortstring);
+begin
+if GameState = gsConfirm then
+	begin
+	SendIPC('Q');
+	GameState:= gsExit
+	end
 end;
 
 procedure chCheckProto(var s: shortstring);
--- a/hedgewars/hwengine.dpr	Thu Jun 19 20:34:53 2008 +0000
+++ b/hedgewars/hwengine.dpr	Sun Jun 22 19:26:01 2008 +0000
@@ -99,6 +99,7 @@
               FinishProgress;
               GameState:= gsGame
               end;
+   gsConfirm,
       gsGame: begin
               ProcessKbd;
               DoGameTick(Lag);
--- a/hedgewars/uConsole.pas	Thu Jun 19 20:34:53 2008 +0000
+++ b/hedgewars/uConsole.pas	Sun Jun 22 19:26:01 2008 +0000
@@ -218,7 +218,6 @@
 
 initialization
 InitConsole;
-RegisterVariable('quit'    , vtCommand, @chQuit         , true );
 RegisterVariable('proto'   , vtCommand, @chCheckProto   , true );
 RegisterVariable('capture' , vtCommand, @chCapture      , true );
 RegisterVariable('rotmask' , vtCommand, @chRotateMask   , true );
@@ -239,6 +238,8 @@
 RegisterVariable('addhh'   , vtCommand, @chAddHH        , false);
 RegisterVariable('hhcoords', vtCommand, @chSetHHCoords  , false);
 RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false);
+RegisterVariable('quit'    , vtCommand, @chQuit         , true );
+RegisterVariable('confirm' , vtCommand, @chConfirm      , true );
 RegisterVariable('+speedup', vtCommand, @chSpeedup_p    , true );
 RegisterVariable('-speedup', vtCommand, @chSpeedup_m    , true );
 RegisterVariable('skip'    , vtCommand, @chSkip         , false);
--- a/hedgewars/uConsts.pas	Thu Jun 19 20:34:53 2008 +0000
+++ b/hedgewars/uConsts.pas	Sun Jun 22 19:26:01 2008 +0000
@@ -23,7 +23,7 @@
 {$INCLUDE proto.inc}
 type
 
-     TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsExit);
+     TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
 
      TGameType  = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview);
 
--- a/hedgewars/uKeys.pas	Thu Jun 19 20:34:53 2008 +0000
+++ b/hedgewars/uKeys.pas	Sun Jun 22 19:26:01 2008 +0000
@@ -122,6 +122,7 @@
 DefaultBinds[112]:= 'pause';
 DefaultBinds[115]:= '+speedup';
 DefaultBinds[116]:= 'chat';
+DefaultBinds[121]:= 'confirm';
 DefaultBinds[127]:= 'rotmask';
 SetDefaultBinds
 end;