Permalink
Browse files

Add confirmation on Escape

git-svn-id: http://trophy.svn.sourceforge.net/svnroot/trophy@40 ef5f324a-0337-0410-b96f-b1d68aca83c0
  • Loading branch information...
1 parent e968a88 commit c4d1f88dd9b6481f31c9c673b73ed0927fe33c34 mazipha committed Apr 23, 2011
Showing with 106 additions and 38 deletions.
  1. +1 −1 depcomp
  2. +1 −1 install-sh
  3. +1 −1 missing
  4. +2 −2 src/Makefile.am
  5. +12 −10 src/Makefile.in
  6. +1 −1 src/cadialog.cpp
  7. +1 −1 src/cadialog.h
  8. +38 −0 src/caescapedialog.cpp
  9. +23 −0 src/caescapedialog.h
  10. +3 −12 src/cainfodialog.cpp
  11. +4 −4 src/cainfodialog.h
  12. +19 −5 src/catrophy.cpp
View
View
View
View
@@ -1,6 +1,6 @@
bin_PROGRAMS = trophy
-trophy_SOURCES = cagoody.cpp cainfodialog.cpp camenu.h canetserver.cpp capositiontable.h casoundeffect.cpp \
- cagoody.h cainfodialog.h camenuinput.cpp canetserver.h capositiontableview.cpp casoundeffect.h shopscreen.h \
+trophy_SOURCES = cagoody.cpp cainfodialog.cpp caescapedialog.cpp camenu.h canetserver.cpp capositiontable.h casoundeffect.cpp \
+ cagoody.h cainfodialog.h caescapedialog.h camenuinput.cpp canetserver.h capositiontableview.cpp casoundeffect.h shopscreen.h \
cagoodytype.h cagoodytype.cpp calabel.cpp camenuinput.h capanel.cpp capositiontableview.h caconfigurekey.cpp shopscreen.cpp \
cartype.h cartype.cpp caimagehueselector.cpp calabel.h camenuitem.cpp camenuselect.cpp capanel.h caresources.cpp caconfigurekey.h \
utils/hsvcolor.h caimagehueselector.h calineedit.cpp camenuitem.h player.cpp caresources.h track.h track.cpp guibox.h guibox.cpp \
View
@@ -45,14 +45,15 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_trophy_OBJECTS = cagoody.$(OBJEXT) cainfodialog.$(OBJEXT) \
- canetserver.$(OBJEXT) casoundeffect.$(OBJEXT) \
- camenuinput.$(OBJEXT) capositiontableview.$(OBJEXT) \
- cagoodytype.$(OBJEXT) calabel.$(OBJEXT) capanel.$(OBJEXT) \
- caconfigurekey.$(OBJEXT) shopscreen.$(OBJEXT) \
- cartype.$(OBJEXT) caimagehueselector.$(OBJEXT) \
- camenuitem.$(OBJEXT) camenuselect.$(OBJEXT) \
- caresources.$(OBJEXT) calineedit.$(OBJEXT) player.$(OBJEXT) \
- track.$(OBJEXT) guibox.$(OBJEXT) cacredits.$(OBJEXT) \
+ caescapedialog.$(OBJEXT) canetserver.$(OBJEXT) \
+ casoundeffect.$(OBJEXT) camenuinput.$(OBJEXT) \
+ capositiontableview.$(OBJEXT) cagoodytype.$(OBJEXT) \
+ calabel.$(OBJEXT) capanel.$(OBJEXT) caconfigurekey.$(OBJEXT) \
+ shopscreen.$(OBJEXT) cartype.$(OBJEXT) \
+ caimagehueselector.$(OBJEXT) camenuitem.$(OBJEXT) \
+ camenuselect.$(OBJEXT) caresources.$(OBJEXT) \
+ calineedit.$(OBJEXT) player.$(OBJEXT) track.$(OBJEXT) \
+ guibox.$(OBJEXT) cacredits.$(OBJEXT) \
caimagemanipulation.$(OBJEXT) camenulabel.$(OBJEXT) \
cascreen.$(OBJEXT) catrophy.$(OBJEXT) cacarupgrades.$(OBJEXT) \
caloadingscreen.$(OBJEXT) caplayersettingsdialog.$(OBJEXT) \
@@ -172,8 +173,8 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-trophy_SOURCES = cagoody.cpp cainfodialog.cpp camenu.h canetserver.cpp capositiontable.h casoundeffect.cpp \
- cagoody.h cainfodialog.h camenuinput.cpp canetserver.h capositiontableview.cpp casoundeffect.h shopscreen.h \
+trophy_SOURCES = cagoody.cpp cainfodialog.cpp caescapedialog.cpp camenu.h canetserver.cpp capositiontable.h casoundeffect.cpp \
+ cagoody.h cainfodialog.h caescapedialog.h camenuinput.cpp canetserver.h capositiontableview.cpp casoundeffect.h shopscreen.h \
cagoodytype.h cagoodytype.cpp calabel.cpp camenuinput.h capanel.cpp capositiontableview.h caconfigurekey.cpp shopscreen.cpp \
cartype.h cartype.cpp caimagehueselector.cpp calabel.h camenuitem.cpp camenuselect.cpp capanel.h caresources.cpp caconfigurekey.h \
utils/hsvcolor.h caimagehueselector.h calineedit.cpp camenuitem.h player.cpp caresources.h track.h track.cpp guibox.h guibox.cpp \
@@ -276,6 +277,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caconfigurekey.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cacredits.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cadialog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caescapedialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cagoody.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cagoodytype.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caimagehueselector.Po@am__quote@
View
@@ -10,7 +10,7 @@
\param screen pointer to screen shown in the background if this dialog is modal.
zero if this dialog is not modal (default).
*/
-CADialog::CADialog( bool modal, CAScreen* screen )
+CADialog::CADialog( const bool modal, CAScreen* screen )
: CAScreen() {
width = height = 0;
left = top = right = bottom = 0;
View
@@ -13,7 +13,7 @@
*/
class CADialog : public CAScreen {
public:
- CADialog( bool modal=false, CAScreen* screen=0 );
+ CADialog( const bool modal=false, CAScreen* screen=0 );
~CADialog();
virtual int run();
View
@@ -0,0 +1,38 @@
+#include "caescapedialog.h"
+
+CAEscapeDialog::CAEscapeDialog( const std::string& title,
+ const std::string& text,
+ const InfoType type,
+ bool modal,
+ CAScreen* screen )
+ :CAInfoDialog(title, text, type, modal, screen),
+mustQuit(false),
+firstEscape(false)
+{}
+
+void CAEscapeDialog::on_key_released (const CL_InputEvent &key)
+{
+ switch( key.id ) {
+ case CL_KEY_Y:
+ mustQuit = true;
+ done = true;
+ break;
+ case CL_KEY_ESCAPE:
+ if (firstEscape)
+ done = true;
+ firstEscape = true;
+ mustQuit = false;
+ break;
+ case CL_KEY_ENTER:
+ mustQuit = false;
+ done = true;
+ break;
+ default:
+ break;
+ }
+}
+
+bool CAEscapeDialog::isMustQuit()
+{
+ return mustQuit;
+}
View
@@ -0,0 +1,23 @@
+#ifndef CAESCAPEDIALOG_H
+#define CAESCAPEDIALOG_H
+
+#include "cainfodialog.h"
+
+class CAEscapeDialog : public CAInfoDialog {
+public:
+ CAEscapeDialog( const std::string& title,
+ const std::string& text,
+ const InfoType type=Info,
+ bool modal=false,
+ CAScreen* screen=0 );
+
+ void on_key_released (const CL_InputEvent &key);
+
+bool isMustQuit();
+private:
+ bool mustQuit;
+ bool firstEscape;
+
+};
+
+#endif
View
@@ -12,9 +12,9 @@
\param screen pointer to screen shown in the background if this dialog is modal.
zero if this dialog is not modal (default).
*/
-CAInfoDialog::CAInfoDialog( const std::string title,
- const std::string text,
- InfoType type,
+CAInfoDialog::CAInfoDialog( const std::string& title,
+ const std::string& text,
+ const InfoType type,
bool modal,
CAScreen* screen )
: CADialog( modal, screen ) {
@@ -51,15 +51,6 @@ CAInfoDialog::CAInfoDialog( const std::string title,
}
-
-/** Destructor.
-*/
-CAInfoDialog::~CAInfoDialog() {
- //delete icon;
-}
-
-
-
/** Builds the info dialog screen.
*/
void
View
@@ -13,12 +13,11 @@ class CAInfoDialog : public CADialog {
public:
enum InfoType { Info, Warning };
- CAInfoDialog( const std::string title,
- const std::string text,
- InfoType type=Info,
+ CAInfoDialog( const std::string& title,
+ const std::string& text,
+ const InfoType type=Info,
bool modal=false,
CAScreen* screen=0 );
- ~CAInfoDialog();
virtual void buildScreen();
virtual void on_key_released (const CL_InputEvent &key);
@@ -32,4 +31,5 @@ class CAInfoDialog : public CADialog {
InfoType type;
};
+
#endif
View
@@ -19,6 +19,7 @@
#include "caconfigurekey.h"
#include "caimagemanipulation.h"
#include "cainfodialog.h"
+#include "caescapedialog.h"
#include "capositiontable.h"
#include "cagoody.h"
#include "catrophy.h"
@@ -1253,7 +1254,6 @@ CATrophy::run()
while( !isEscapePressed &&
(!raceOver || CL_System::get_time()-raceOverTime<3000) )
{
- // TODO: handle escape key (human player should be considered as dead)
measureFrameTime( true );
if( CL_Keyboard::get_keycode(CL_KEY_P) )
@@ -1368,16 +1368,30 @@ CATrophy::run()
measureFrameTime( false );
isEscapePressed = CL_Keyboard::get_keycode(CL_KEY_ESCAPE);
+
+ if (isEscapePressed)
+ {
+ CAEscapeDialog escapeDlg( "Quit Race?",
+ "Press Y to quit race",
+ CAInfoDialog::Info,
+ true, this );
+ escapeDlg.run();
+
+ if( escapeDlg.isMustQuit () )
+ {
+ m_RacePlayer[0]->kill();
+ }
+ else
+ {
+ isEscapePressed = false;
+ }
+ }
}
if( debug ) std::cout << "Stop game loop" << std::endl;
waitForSilence();
- if (isEscapePressed)
- {
- m_RacePlayer[0]->kill();
- }
// Finish all players manually
//
for( int rank=1; rank<=CA_RACEMAXPLAYERS; ++rank )

0 comments on commit c4d1f88

Please sign in to comment.