DlgBox.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 **
00004 ** Copyright (C) 2006-2010 The TBT Team.
00005 **
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 **
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 **
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef DLGBOX_HH_
00018 # define DLGBOX_HH_
00019 
00020 # include "Sprite.hh"
00021 # include "TextSurface.hh"
00022 # include "VirtualSurface.hh"
00023 
00024 BEGIN_NS(sdlvisu);
00025 
00027 enum eDlgBoxIcon {
00028   eDlgIconReferee = 1,
00029   eDlgIconError,
00030   eDlgIconWarning,
00031   eDlgIconSmile,
00032   eDlgIconSulk,
00033   eDlgIconQuestion,
00034   eDlgIconInfo,
00035   eDlgIconKickOff,
00036   eDlgIconReserve,
00037   eDlgIconArgh,
00038   eDlgIconOuch,
00039   eDlgIconKO,
00040   eDlgIconEjected,
00041   eDlgIconInjured,
00042   eDlgIconDead,
00043 };
00044 
00046 enum eDlgBoxButton {
00047   eDlgBoxYesNo,
00048   eDlgBoxOk,
00049   eDlgBoxBlock,
00050 };
00051 
00052 class Game;
00053 
00058 class DialogBoxCb
00059 {
00060 public:
00061   DialogBoxCb() {}
00062   virtual ~DialogBoxCb() {}
00063 
00064   virtual void clicked(int btn_index) = 0;
00065 };
00066 
00076 class DialogBox : public VirtualSurface
00077 {
00078 public:
00079   DialogBox(Game& game, enum eDlgBoxButton style, enum eDlgBoxIcon icon);
00080   virtual ~DialogBox();
00081 
00082   void setStyle(enum eDlgBoxButton style, enum eDlgBoxIcon icon);
00083   void setText(const std::string& msg);
00084   void setIcon(enum eDlgBoxIcon icon);
00085   void setActionHandler(DialogBoxCb* handler);
00086 
00087   DialogBoxCb* getActionHandler() const;
00088 
00092   void addBlockButton(int dice_face);
00093 
00096   int addRerollLabel();
00097   
00098   virtual void enable();
00099   virtual void disable();
00100   virtual void update();
00101 
00102 private:
00103   Game& game_;
00104   DialogBoxCb* handler_;
00105 
00106   Surface bg_;
00107   TextSurface text_;
00108   Sprite icon_;
00109 
00110   // Only for eDlgBoxBlock. -->
00111   typedef std::vector<Surface*> ButtonList;
00112   ButtonList button_;
00113   // <--
00114 
00115   bool dragging_;
00116   Point drag_delta_;
00117   int button_pressed_index_;
00118   bool always_display_button_;
00119 };
00120 
00121 END_NS(sdlvisu);
00122 
00123 #endif /* !DLGBOX_HH_ */
Generated on Mon Apr 5 21:17:12 2010 for Stechec/TBT by  doxygen 1.6.3