Make PositionLabels have direction status indicators
[cs356-p1-elevator.git] / main.cpp
1 #include "main.hpp"
2 #include "elevatorgui.hpp"
3
4 static ElevatorGUI *thegui = NULL;
5
6 int main (int argc, char *argv[])
7 {
8         int floors = 7;
9         int elevators = 3;
10
11 //#define USE_STATIC_FLOORS 1
12 #ifndef USE_STATIC_FLOORS
13         do
14         {
15                 std::cout << "Enter the number of floors to use [2-10]: ";
16                 std::cin >> floors;
17
18                 if (floors < 2 || floors > 10)
19                 {
20                         std::cout << "You entered: " << floors
21                                           << " which is outside the acceptable range." << std::endl;
22                         std::cout << "Please try again..." << std::endl << std::endl;
23                 }
24                 else
25                 {
26                         // Good input, leave now
27                         break;
28                 }
29         } while (true);
30
31         do
32         {
33                 std::cout << "Enter the number of elevators to use [1-5]: ";
34                 std::cin >> elevators;
35
36                 if (elevators < 1 || elevators > 5)
37                 {
38                         std::cout << "You entered: " << elevators
39                                           << " which is outside the acceptable range." << std::endl;
40                         std::cout << "Please try again..." << std::endl << std::endl;
41                 }
42                 else
43                 {
44                         // Good input, leave now
45                         break;
46                 }
47         } while (true);
48 #endif
49
50         // Start GTK
51         Gtk::Main app(argc, argv);
52
53         // Start the GUI
54         ElevatorGUI eg(floors, elevators);
55         thegui = &eg;
56
57         // Show the GUI
58         eg.show ();
59
60         // Run it!
61         Gtk::Main::run (eg);
62
63         return 0;
64 }
65
66
67 void gui_update_position_label (int elevator, float new_position, Direction direction)
68 {
69         thegui->gui_update_position_label (elevator, new_position, direction);
70 }
71
72 void gui_unpress_call_button (int floor, Direction direction)
73 {
74         thegui->gui_unpress_call_button (floor, direction);
75 }
76
77 void gui_unpress_request_button (int elevator, int floor)
78 {
79         thegui->gui_unpress_request_button (elevator, floor);
80 }
81
82 void gui_open_door (int elevator, int floor)
83 {
84         thegui->gui_open_door (elevator, floor);
85 }
86
87 void gui_close_door (int elevator, int floor)
88 {
89         thegui->gui_close_door (elevator, floor);
90 }
91
92 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */