1 #ifndef HEADER_LEVEL_H
2 #define HEADER_LEVEL_H
3 
4 class Cube;
5 class Unit;
6 class DescFinder;
7 class PhaseLocker;
8 class Picture;
9 class DemoMode;
10 class KeyStroke;
11 class MouseStroke;
12 class LevelScript;
13 class LevelLoading;
14 class LevelStatus;
15 class LevelCountDown;
16 class CommandQueue;
17 class Command;
18 class MultiDrawer;
19 class StatusDisplay;
20 
21 #include "Path.h"
22 #include "GameState.h"
23 #include "CountAdvisor.h"
24 
25 #include <string>
26 
27 /**
28  * Game level with room.
29  */
30 class Level : public GameState, public CountAdvisor {
31     private:
32         static const int SPEED_REPLAY = 1;
33 
34         int m_depth;
35         const DescFinder *m_desc;
36         std::string m_codename;
37         Path m_datafile;
38         PhaseLocker *m_locker;
39         bool m_newRound;
40         LevelScript *m_levelScript;
41         LevelLoading *m_loading;
42         LevelCountDown *m_countdown;
43         CommandQueue *m_show;
44         int m_restartCounter;
45         int m_undoSteps;
46         bool m_wasDangerousMove;
47         MultiDrawer *m_background;
48         StatusDisplay *m_statusDisplay;
49     private:
50         void initScreen();
51         void nextAction();
52         void updateLevel();
53         void saveUndo(const std::string &oldMoves);
54         void finishLevel();
55         void nextLoadAction();
56         void nextShowAction();
57         void nextUndoAction();
58         void nextPlayerAction();
59         void saveSolution();
60         void displaySaveStatus();
61         bool isUndoing() const;
62     protected:
63         virtual void own_initState();
64         virtual void own_updateState();
65         virtual void own_pauseState();
66         virtual void own_resumeState();
67         virtual void own_cleanState();
68         virtual void own_noteBg();
69         virtual void own_noteFg();
70     public:
71         Level(const std::string &codename, const Path &datafile, int depth);
72         virtual ~Level();
getName()73         virtual const char *getName() const { return "state_level"; };
fillDesc(const DescFinder * desc)74         void fillDesc(const DescFinder *desc) { m_desc = desc; }
75         void fillStatus(LevelStatus *status);
76 
77         void saveGame(const std::string &models);
78         void loadGame(const std::string &moves);
79         void loadReplay(const std::string &moves);
80 
81         bool action_restart(int increment);
82         bool action_move(char symbol);
83         bool action_save();
84         bool action_load();
85         void action_undo(int steps);
86         void action_undo_finish();
87 
88         void switchFish();
89         void controlEvent(const KeyStroke &stroke);
90         void controlMouse(const MouseStroke &button);
91 
92         std::string getLevelName() const;
getRestartCounter()93         int getRestartCounter() const { return m_restartCounter; }
getDepth()94         int getDepth() const { return m_depth; }
isNewRound()95         bool isNewRound() const { return m_newRound; }
96 
97         void createRoom(int w, int h, const std::string &picture);
98         void newDemo(const Path &demofile);
99 
100         bool isActing() const;
101         bool isLoading() const;
102         void togglePause();
103         bool isShowing() const;
104         void interruptShow();
105         void planShow(Command *new_command);
106 
107         virtual int getCountForSolved() const;
108         virtual int getCountForWrong() const;
109 };
110 
111 #endif
112