Rebuild autotool system
[construo.git] / controller.hxx
blob0dd1edd7d6cd18318814beaa4e1269d5bd789b17
1 // $Id: controller.hxx,v 1.6 2003/01/10 20:44:09 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_CONTROLLER_HXX
21 #define HEADER_CONSTRUO_CONTROLLER_HXX
23 #include "world.hxx"
24 #include "delta_manager.hxx"
26 /** Holds all the different World states, handles undo and things like that */
27 class Controller
29 private:
30 std::vector<World*> undo_world_stack;
31 std::vector<World*> redo_world_stack;
33 bool running;
34 bool slow_down;
35 bool action_cam;
36 bool hide_dots;
38 /** The current active world, don't delete this, delet is handled in
39 the undo stacks */
40 World* world;
42 DeltaManager delta_manager;
44 static Controller* instance_;
45 public:
46 /** Create an empty world workspace */
47 Controller ();
48 Controller (const std::string& filename);
49 ~Controller ();
51 static inline Controller* instance() { return instance_; }
53 bool has_been_run () { return world && world->get_has_been_run (); }
55 bool is_running () { return running; }
56 bool slow_down_active () { return slow_down; }
57 void set_slow_down (bool s) { slow_down = s; }
59 void set_action_cam(bool);
60 bool get_action_cam();
62 void set_hide_dots (bool);
63 bool get_hide_dots ();
65 World* get_world () { assert(world); return world; }
67 /** Load a world by name, name is relative to the construo user directory */
68 void load_world (const std::string& name);
70 /** Save a world by name, name is relative to the construo user directory */
71 void save_world (const std::string& name);
73 std::string get_slot_filename(int n);
74 void save_to_slot (int n);
75 void load_from_slot (int n);
77 /** Updates the state of the controller and also the world */
78 void update ();
80 void clear_world ();
82 void undo ();
83 void redo ();
85 /** Push the current world to the undo stack */
86 void push_undo();
88 /** start or stops the simulation */
89 void start_simulation ();
92 #endif
94 /* EOF */