1 /*
2  * Dialog window for defining a schedule
3  *
4  * Hj. Malthaner
5  *
6  * Juli 2000
7  */
8 
9 #ifndef gui_schedule_gui_h
10 #define gui_schedule_gui_h
11 
12 #include "gui_frame.h"
13 
14 #include "components/gui_label.h"
15 #include "components/gui_numberinput.h"
16 #include "components/gui_combobox.h"
17 #include "components/gui_button.h"
18 #include "components/action_listener.h"
19 
20 #include "components/gui_scrollpane.h"
21 
22 #include "../convoihandle_t.h"
23 #include "../linehandle_t.h"
24 #include "simwin.h"
25 #include "../tpl/vector_tpl.h"
26 
27 
28 class schedule_t;
29 class player_t;
30 class cbuffer_t;
31 class loadsave_t;
32 class schedule_gui_stats_t;
33 
34 
35 /**
36  * GUI for Schedule dialog
37  *
38  * @author Hj. Malthaner
39  */
40 class schedule_gui_t :	public gui_frame_t,
41 						public action_listener_t
42 {
43 	enum mode_t {adding, inserting, removing, undefined_mode};
44 
45 	mode_t mode;
46 
47 	// only active with lines
48 	button_t bt_promote_to_line;
49 	gui_combobox_t line_selector;
50 	gui_label_buf_t lb_waitlevel;
51 
52 	// always needed
53 	button_t bt_add, bt_insert, bt_remove; // stop management
54 	button_t bt_return;
55 
56 	gui_label_t lb_wait, lb_load;
57 	gui_numberinput_t numimp_load;
58 	gui_combobox_t wait_load;
59 
60 	schedule_gui_stats_t* stats;
61 	gui_scrollpane_t scrolly;
62 
63 	// to add new lines automatically
64 	uint32 old_line_count;
65 	uint32 last_schedule_count;
66 
67 	// set the correct tool now ...
68 	void update_tool(bool set);
69 
70 	// changes the waiting/loading levels if allowed
71 	void update_selection();
72 protected:
73 	schedule_t *schedule;
74 	schedule_t* old_schedule;
75 	player_t *player;
76 	convoihandle_t cnv;
77 
78 	linehandle_t new_line, old_line;
79 
80 	void init(schedule_t* schedule, player_t* player, convoihandle_t cnv);
81 
82 public:
83 	schedule_gui_t(schedule_t* schedule = NULL, player_t* player = NULL, convoihandle_t cnv = convoihandle_t());
84 
85 	virtual ~schedule_gui_t();
86 
87 	// for updating info ...
88 	void init_line_selector();
89 
90 	bool infowin_event(event_t const*) OVERRIDE;
91 
get_help_filename()92 	const char *get_help_filename() const OVERRIDE {return "schedule.txt";}
93 
94 	/**
95 	 * Draw the Frame
96 	 * @author Hansj�rg Malthaner
97 	 */
98 	void draw(scr_coord pos, scr_size size) OVERRIDE;
99 
100 	/**
101 	 * Set window size and adjust component sizes and/or positions accordingly
102 	 * @author Hj. Malthaner
103 	 */
104 	void set_windowsize(scr_size size) OVERRIDE;
105 
106 	bool action_triggered(gui_action_creator_t*, value_t) OVERRIDE;
107 
108 	/**
109 	 * Map rotated, rotate schedules too
110 	 */
111 	void map_rotate90( sint16 ) OVERRIDE;
112 
113 	void rdwr( loadsave_t *file ) OVERRIDE;
114 
get_rdwr_id()115 	uint32 get_rdwr_id() OVERRIDE { return magic_schedule_rdwr_dummy; }
116 };
117 
118 #endif
119