]> git.tdb.fi Git - r2c2.git/blob - source/engineer/userinterface.h
Persist most dialogs across runs
[r2c2.git] / source / engineer / userinterface.h
1 #ifndef USERINTERFACE_H_
2 #define USERINTERFACE_H_
3
4 #include <msp/gltk/resources.h>
5 #include <msp/gltk/root.h>
6 #include "libr2c2/driver.h"
7 #include "libr2c2/train.h"
8 #include "libr2c2/zone.h"
9 #include "mainwindow.h"
10
11 class DynamicDialog;
12
13 class UserInterface
14 {
15 public:
16         class Loader: public Msp::DataFile::ObjectLoader<UserInterface>
17         {
18         public:
19                 Loader(UserInterface &);
20
21         private:
22                 template<typename T>
23                 void dialog(T &);
24
25                 template<typename T>
26                 void basic_dialog();
27
28                 void traindialog(unsigned);
29         };
30
31 private:
32         Engineer &engineer;
33         Msp::GLtk::Resources resources;
34         Msp::GLtk::Root root;
35         Msp::GLtk::Arrangement *root_arrangement;
36
37         MainWindow main_wnd;
38         std::set<DynamicDialog *> dyn_dialogs;
39         bool import_active;
40
41         Msp::Time::TimeStamp status_timeout;
42
43 public:
44         UserInterface(Engineer &, Msp::Graphics::Window &, Msp::Input::Keyboard &, Msp::Input::Mouse &);
45         ~UserInterface();
46
47         const Msp::GLtk::Resources &get_resources() const { return resources; }
48
49         void set_status(const std::string &);
50         void add_dynamic_dialog(DynamicDialog &);
51         void remove_dynamic_dialog(DynamicDialog &);
52
53         void show_train(R2C2::Train &);
54         void show_zone(R2C2::Zone &);
55 private:
56         void locomotive_detected(const R2C2::Driver::DetectedLocomotive &);
57         void import_finished(int);
58
59 public:
60         void tick();
61         void render() const;
62
63         void save_state(const std::string &) const;
64 };
65
66 #endif