Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
mapwindow.hpp
1 //////////////////////////////
2 //
3 // File: lxs/game/mapwindow.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Feb 27 2013
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_MAPWINDOW__
15 #define __LXS_MAPWINDOW__
16 #include "lxs/windowing/containerwindow.hpp"
17 #include "lxs/game/character.hpp"
18 namespace LxS
19 {
20  namespace Windowing
21  {
22  class Button;
23  }
24  namespace Game
25  {
26  namespace Help
27  {
28  class HintBox;
29  }
30  class BattleResult;
31  class SimpleCSE;
32  class Map;
33  class MapWindowOverlay;
34  //! Class representing game itself (not the main window or main menu)
36  {
37  public:
38  // making these classes friends for purposes of Enter Mode (and hiding it from all other classes)
39  friend class Map;
40  friend class SimpleCSE;
41  //! modes
42  enum mode_t {
43  //! screen for battling with NPC enemies
45  //! immediately after killing NPCs in battle mode,
46  //! victory animation plays (this always transitions to Bttle result)
48  //! Battle result is a screen detailing how much XP/loot was gained from this particular fight
50  //! immediately after losing battle, this mode appears -
51  //! triumphant NPC and bleeding player character - always transitions to
52  //! GameOverScreen
54  //! main interactive map exploration mode
56  //! menu mode
57  Menu,
58  //! Screen that reads "game over"
60  //! Screen displayed when "you have won the game"
62  //! Talk mode
63  Talk};
64  private:
65  //! mode selected
66  mode_t mode;
67  //! previous mode
68  mode_t prev_mode;
69  //! proper map object
70  Map * currentMap;
71  //! is map being moved?
72  int moving;
73  //! where tapped (for calculation of mowenemt direction)
74  float tap_x;
75  //! where tapped
76  float tap_y;
77  // CSE is shorthand form "Character sheet editor"
78  SimpleCSE * menu;
79  //! battle result window; default 0, created when battle ends
81  //! button for entering menu
82  LxS::Windowing::Button * menubutton;
83  //! messages etc.
84  MapWindowOverlay * overlay;
85  //! where to move
86  void SetTarget(float x, float y);
87  //! enter (battle/menu/other) mode
88  void EnterMode(mode_t target_mode);
89  //! enter previous mode (return from menu)
90  void EnterPreviousMode();
91  //! if reduced to 0, save;
92  float time_to_autosave;
93  std::string saved_game;
94 
95  Help::HintBox * HB;
96  public:
97  //! get current game mode
99  {
100  return mode;
101  }
102  //! serialize game state!
103  void SaveFile();
104  //! victory screen!
106  void MenuButtonPressed()
107  ;
108  void BackButtonPressed()
109  ;
110  //! to start with saved game, not a new game
111  void SetFilename(std::string s) {saved_game.assign(s);}
112  MapWindow();
113  //! return main character
115  virtual void Render(Rendermode mode);
116  //! if hint named "hint" wasn't displayed,
117  //! display it right now.
118  void DisplayHintBoxIfRequired(std::string hint);
119 
120  virtual void Animate(float dt);
121  virtual void Initialize();
122  virtual void UnloadResources();
123  // centimeters from bottom-left
124  void ResizeHandler();
125  virtual void JoystickAxes(int Axis, const float *direction);
126  virtual void Released(float x, float y);
127  virtual void Clicked(float x, float y);
128  // within interface
129  virtual void Dragged(float x, float y);
130  // as degrees given current camera angle!
131  virtual void DraggedAngle(float x, float y);
132  unsigned long GetTexelsCount();
133  unsigned long GetFacesCount();
134  float GetInitializedPercentage();
135  //! delete and reinitialize self in place thus freeing the state but remaining correct object
136  void SelfDestruct();
137  ~MapWindow();
138  };
139  // end of class MapWindow
140  }
141 }
142 #endif