Merge lp:~widelands-dev/widelands/ui_improvments into lp:widelands
- ui_improvments
- Merge into trunk
Proposed by
cghislai
Status: | Merged | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 6629 | ||||||||||||||||||||||||||||||||||||
Proposed branch: | lp:~widelands-dev/widelands/ui_improvments | ||||||||||||||||||||||||||||||||||||
Merge into: | lp:widelands | ||||||||||||||||||||||||||||||||||||
Diff against target: |
1269 lines (+309/-216) 36 files modified
src/chat.h (+6/-0) src/constants.h (+1/-1) src/debugconsole.cc (+4/-0) src/gamecontroller.cc (+31/-3) src/logic/building.cc (+6/-0) src/logic/building.h (+5/-0) src/logic/production_program.cc (+2/-2) src/logic/productionsite.cc (+1/-1) src/logic/trainingsite.cc (+1/-6) src/network/internet_gaming.cc (+8/-1) src/network/internet_gaming.h (+3/-0) src/network/netclient.cc (+9/-0) src/network/netclient.h (+1/-0) src/network/nethost.cc (+7/-0) src/save_handler.cc (+10/-2) src/timestring.cc (+15/-0) src/timestring.h (+5/-0) src/ui_basic/progressbar.cc (+9/-12) src/ui_basic/table.cc (+11/-22) src/ui_fsmenu/loadgame.cc (+3/-8) src/ui_fsmenu/loadreplay.cc (+3/-8) src/ui_fsmenu/mapselect.cc (+3/-3) src/wlapplication.cc (+7/-5) src/wui/building_ui.cc (+8/-1) src/wui/buildingwindow.cc (+5/-46) src/wui/buildingwindow.h (+0/-1) src/wui/fieldaction.cc (+1/-43) src/wui/game_main_menu_save_game.cc (+20/-13) src/wui/game_main_menu_save_game.h (+1/-1) src/wui/game_message_menu.cc (+5/-13) src/wui/interactive_base.cc (+64/-0) src/wui/interactive_base.h (+3/-0) src/wui/interactive_player.cc (+13/-10) src/wui/interactive_player.h (+3/-0) src/wui/productionsitewindow.cc (+34/-13) src/wui/productionsitewindow.h (+1/-1) |
||||||||||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/ui_improvments | ||||||||||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email: mp+175090@code.launchpad.net |
Commit message
Description of the change
Some fixes and features related to ui. See linked bugs and commit messages for details.
I tried to make commits as atomic as possible, so they could be merged separately if needed.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'pics/workarea12.png' | |||
2 | 0 | Binary files pics/workarea12.png 1970-01-01 00:00:00 +0000 and pics/workarea12.png 2013-07-16 17:39:34 +0000 differ | 0 | Binary files pics/workarea12.png 1970-01-01 00:00:00 +0000 and pics/workarea12.png 2013-07-16 17:39:34 +0000 differ |
3 | === added file 'pics/workarea123.png' | |||
4 | 1 | Binary files pics/workarea123.png 1970-01-01 00:00:00 +0000 and pics/workarea123.png 2013-07-16 17:39:34 +0000 differ | 1 | Binary files pics/workarea123.png 1970-01-01 00:00:00 +0000 and pics/workarea123.png 2013-07-16 17:39:34 +0000 differ |
5 | === removed file 'pics/workarea1cumulative.png' | |||
6 | 2 | Binary files pics/workarea1cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea1cumulative.png 1970-01-01 00:00:00 +0000 differ | 2 | Binary files pics/workarea1cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea1cumulative.png 1970-01-01 00:00:00 +0000 differ |
7 | === added file 'pics/workarea23.png' | |||
8 | 3 | Binary files pics/workarea23.png 1970-01-01 00:00:00 +0000 and pics/workarea23.png 2013-07-16 17:39:34 +0000 differ | 3 | Binary files pics/workarea23.png 1970-01-01 00:00:00 +0000 and pics/workarea23.png 2013-07-16 17:39:34 +0000 differ |
9 | === removed file 'pics/workarea2cumulative.png' | |||
10 | 4 | Binary files pics/workarea2cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea2cumulative.png 1970-01-01 00:00:00 +0000 differ | 4 | Binary files pics/workarea2cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea2cumulative.png 1970-01-01 00:00:00 +0000 differ |
11 | === removed file 'pics/workarea3cumulative.png' | |||
12 | 5 | Binary files pics/workarea3cumulative.png 2009-11-09 19:01:11 +0000 and pics/workarea3cumulative.png 1970-01-01 00:00:00 +0000 differ | 5 | Binary files pics/workarea3cumulative.png 2009-11-09 19:01:11 +0000 and pics/workarea3cumulative.png 1970-01-01 00:00:00 +0000 differ |
13 | === modified file 'src/chat.h' | |||
14 | --- src/chat.h 2013-02-10 19:36:24 +0000 | |||
15 | +++ src/chat.h 2013-07-16 17:39:34 +0000 | |||
16 | @@ -106,6 +106,12 @@ | |||
17 | 106 | virtual void send(const std::string &) = 0; | 106 | virtual void send(const std::string &) = 0; |
18 | 107 | 107 | ||
19 | 108 | /** | 108 | /** |
20 | 109 | * Sends the given message to the local player only | ||
21 | 110 | * This may be used to display useful log messages. | ||
22 | 111 | */ | ||
23 | 112 | virtual void send_local(const std::string &) = 0; | ||
24 | 113 | |||
25 | 114 | /** | ||
26 | 109 | * \return a (chronological) list of received chat messages. | 115 | * \return a (chronological) list of received chat messages. |
27 | 110 | * This list need not be stable or monotonic. In other words, | 116 | * This list need not be stable or monotonic. In other words, |
28 | 111 | * subsequent calls to this functions may return a smaller or | 117 | * subsequent calls to this functions may return a smaller or |
29 | 112 | 118 | ||
30 | === modified file 'src/constants.h' | |||
31 | --- src/constants.h 2013-07-13 14:32:49 +0000 | |||
32 | +++ src/constants.h 2013-07-16 17:39:34 +0000 | |||
33 | @@ -131,7 +131,7 @@ | |||
34 | 131 | * C++ is really bad at integer types. For example this constant is not | 131 | * C++ is really bad at integer types. For example this constant is not |
35 | 132 | * recognized as a valid value of type Workarea_Info::size_type without a cast. | 132 | * recognized as a valid value of type Workarea_Info::size_type without a cast. |
36 | 133 | */ | 133 | */ |
38 | 134 | #define NUMBER_OF_WORKAREA_PICS static_cast<Workarea_Info::size_type>(3) | 134 | #define NUMBER_OF_WORKAREA_PICS static_cast<Workarea_Info::size_type>(6) |
39 | 135 | 135 | ||
40 | 136 | /// The size of the transient (i.e. temporary) surfaces in the cache in bytes. | 136 | /// The size of the transient (i.e. temporary) surfaces in the cache in bytes. |
41 | 137 | /// These are all surfaces that are not loaded from disk. | 137 | /// These are all surfaces that are not loaded from disk. |
42 | 138 | 138 | ||
43 | === modified file 'src/debugconsole.cc' | |||
44 | --- src/debugconsole.cc 2013-02-10 19:36:24 +0000 | |||
45 | +++ src/debugconsole.cc 2013-07-16 17:39:34 +0000 | |||
46 | @@ -85,6 +85,10 @@ | |||
47 | 85 | it->second(arg); | 85 | it->second(arg); |
48 | 86 | } | 86 | } |
49 | 87 | 87 | ||
50 | 88 | void send_local(const std::string& msg) { | ||
51 | 89 | send(msg); | ||
52 | 90 | } | ||
53 | 91 | |||
54 | 88 | const std::vector<ChatMessage> & getMessages() const | 92 | const std::vector<ChatMessage> & getMessages() const |
55 | 89 | { | 93 | { |
56 | 90 | return messages; | 94 | return messages; |
57 | 91 | 95 | ||
58 | === modified file 'src/gamecontroller.cc' | |||
59 | --- src/gamecontroller.cc 2012-02-15 21:25:34 +0000 | |||
60 | +++ src/gamecontroller.cc 2013-07-16 17:39:34 +0000 | |||
61 | @@ -25,8 +25,10 @@ | |||
62 | 25 | #include "logic/playercommand.h" | 25 | #include "logic/playercommand.h" |
63 | 26 | #include "profile/profile.h" | 26 | #include "profile/profile.h" |
64 | 27 | #include "wlapplication.h" | 27 | #include "wlapplication.h" |
65 | 28 | #include "chat.h" | ||
66 | 29 | #include "wui/interactive_player.h" | ||
67 | 28 | 30 | ||
69 | 29 | struct SinglePlayerGameController : public GameController { | 31 | struct SinglePlayerGameController : public GameController, public ChatProvider { |
70 | 30 | SinglePlayerGameController | 32 | SinglePlayerGameController |
71 | 31 | (Widelands::Game &, bool useai, Widelands::Player_Number local); | 33 | (Widelands::Game &, bool useai, Widelands::Player_Number local); |
72 | 32 | ~SinglePlayerGameController(); | 34 | ~SinglePlayerGameController(); |
73 | @@ -42,6 +44,10 @@ | |||
74 | 42 | bool isPaused(); | 44 | bool isPaused(); |
75 | 43 | void setPaused(bool paused); | 45 | void setPaused(bool paused); |
76 | 44 | 46 | ||
77 | 47 | // Chat provider implementation | ||
78 | 48 | void send(const std::string & msg); | ||
79 | 49 | void send_local(const std::string & msg); | ||
80 | 50 | const std::vector<ChatMessage> & getMessages() const; | ||
81 | 45 | private: | 51 | private: |
82 | 46 | Widelands::Game & m_game; | 52 | Widelands::Game & m_game; |
83 | 47 | bool m_useai; | 53 | bool m_useai; |
84 | @@ -52,13 +58,14 @@ | |||
85 | 52 | uint32_t m_player_cmdserial; | 58 | uint32_t m_player_cmdserial; |
86 | 53 | Widelands::Player_Number m_local; | 59 | Widelands::Player_Number m_local; |
87 | 54 | std::vector<Computer_Player *> m_computerplayers; | 60 | std::vector<Computer_Player *> m_computerplayers; |
88 | 61 | std::vector<ChatMessage> m_chatmessages; | ||
89 | 55 | }; | 62 | }; |
90 | 56 | 63 | ||
91 | 57 | SinglePlayerGameController::SinglePlayerGameController | 64 | SinglePlayerGameController::SinglePlayerGameController |
92 | 58 | (Widelands::Game & game, | 65 | (Widelands::Game & game, |
93 | 59 | bool const useai, | 66 | bool const useai, |
94 | 60 | Widelands::Player_Number const local) | 67 | Widelands::Player_Number const local) |
96 | 61 | : | 68 | : ChatProvider(), |
97 | 62 | m_game (game), | 69 | m_game (game), |
98 | 63 | m_useai (useai), | 70 | m_useai (useai), |
99 | 64 | m_lastframe (WLApplication::get()->get_time()), | 71 | m_lastframe (WLApplication::get()->get_time()), |
100 | @@ -156,10 +163,31 @@ | |||
101 | 156 | m_paused = paused; | 163 | m_paused = paused; |
102 | 157 | } | 164 | } |
103 | 158 | 165 | ||
104 | 166 | void SinglePlayerGameController::send_local(const std::string& msg) | ||
105 | 167 | { | ||
106 | 168 | ChatMessage c; | ||
107 | 169 | c.msg = msg; | ||
108 | 170 | c.time = time(0); | ||
109 | 171 | m_chatmessages.push_back(c); | ||
110 | 172 | ChatProvider::send(c); | ||
111 | 173 | } | ||
112 | 174 | |||
113 | 175 | void SinglePlayerGameController::send(const std::string& msg) | ||
114 | 176 | { | ||
115 | 177 | log("SinglePlayerGameController:: Cannot send chat messages in single player game!"); | ||
116 | 178 | } | ||
117 | 179 | |||
118 | 180 | const std::vector< ChatMessage >& SinglePlayerGameController::getMessages() const | ||
119 | 181 | { | ||
120 | 182 | return m_chatmessages; | ||
121 | 183 | } | ||
122 | 184 | |||
123 | 159 | GameController * GameController::createSinglePlayer | 185 | GameController * GameController::createSinglePlayer |
124 | 160 | (Widelands::Game & game, | 186 | (Widelands::Game & game, |
125 | 161 | bool const cpls, | 187 | bool const cpls, |
126 | 162 | Widelands::Player_Number const local) | 188 | Widelands::Player_Number const local) |
127 | 163 | { | 189 | { |
129 | 164 | return new SinglePlayerGameController(game, cpls, local); | 190 | SinglePlayerGameController* spgc = new SinglePlayerGameController(game, cpls, local); |
130 | 191 | game.get_ipl()->set_chat_provider(*spgc); | ||
131 | 192 | return spgc; | ||
132 | 165 | } | 193 | } |
133 | 166 | 194 | ||
134 | === modified file 'src/logic/building.cc' | |||
135 | --- src/logic/building.cc 2013-07-14 10:38:26 +0000 | |||
136 | +++ src/logic/building.cc 2013-07-16 17:39:34 +0000 | |||
137 | @@ -19,6 +19,7 @@ | |||
138 | 19 | 19 | ||
139 | 20 | #include <cstdio> | 20 | #include <cstdio> |
140 | 21 | #include <sstream> | 21 | #include <sstream> |
141 | 22 | #include <boost/foreach.hpp> | ||
142 | 22 | 23 | ||
143 | 23 | #include "upcast.h" | 24 | #include "upcast.h" |
144 | 24 | #include "wexception.h" | 25 | #include "wexception.h" |
145 | @@ -436,6 +437,9 @@ | |||
146 | 436 | } | 437 | } |
147 | 437 | 438 | ||
148 | 438 | PlayerImmovable::cleanup(egbase); | 439 | PlayerImmovable::cleanup(egbase); |
149 | 440 | |||
150 | 441 | BOOST_FOREACH(boost::signals::connection& c, options_window_connections) | ||
151 | 442 | c.disconnect(); | ||
152 | 439 | } | 443 | } |
153 | 440 | 444 | ||
154 | 441 | 445 | ||
155 | @@ -855,6 +859,7 @@ | |||
156 | 855 | set_seeing(true); | 859 | set_seeing(true); |
157 | 856 | } | 860 | } |
158 | 857 | PlayerImmovable::add_worker(worker); | 861 | PlayerImmovable::add_worker(worker); |
159 | 862 | workers_changed(); | ||
160 | 858 | } | 863 | } |
161 | 859 | 864 | ||
162 | 860 | 865 | ||
163 | @@ -862,6 +867,7 @@ | |||
164 | 862 | PlayerImmovable::remove_worker(worker); | 867 | PlayerImmovable::remove_worker(worker); |
165 | 863 | if (not get_workers().size()) | 868 | if (not get_workers().size()) |
166 | 864 | set_seeing(false); | 869 | set_seeing(false); |
167 | 870 | workers_changed(); | ||
168 | 865 | } | 871 | } |
169 | 866 | 872 | ||
170 | 867 | /** | 873 | /** |
171 | 868 | 874 | ||
172 | === modified file 'src/logic/building.h' | |||
173 | --- src/logic/building.h 2013-07-14 10:38:26 +0000 | |||
174 | +++ src/logic/building.h 2013-07-16 17:39:34 +0000 | |||
175 | @@ -34,6 +34,7 @@ | |||
176 | 34 | #include <string> | 34 | #include <string> |
177 | 35 | #include <cstring> | 35 | #include <cstring> |
178 | 36 | #include <vector> | 36 | #include <vector> |
179 | 37 | #include <boost/signal.hpp> | ||
180 | 37 | 38 | ||
181 | 38 | namespace UI {class Window;} | 39 | namespace UI {class Window;} |
182 | 39 | struct BuildingHints; | 40 | struct BuildingHints; |
183 | @@ -223,6 +224,7 @@ | |||
184 | 223 | 224 | ||
185 | 224 | void add_worker(Worker &); | 225 | void add_worker(Worker &); |
186 | 225 | void remove_worker(Worker &); | 226 | void remove_worker(Worker &); |
187 | 227 | mutable boost::signal<void ()> workers_changed; | ||
188 | 226 | 228 | ||
189 | 227 | void send_message | 229 | void send_message |
190 | 228 | (Game & game, | 230 | (Game & game, |
191 | @@ -268,6 +270,9 @@ | |||
192 | 268 | 270 | ||
193 | 269 | /// Whether we see our vision_range area based on workers in the building | 271 | /// Whether we see our vision_range area based on workers in the building |
194 | 270 | bool m_seeing; | 272 | bool m_seeing; |
195 | 273 | |||
196 | 274 | // Signals connected for the option window | ||
197 | 275 | std::vector<boost::signals::connection> options_window_connections; | ||
198 | 271 | }; | 276 | }; |
199 | 272 | 277 | ||
200 | 273 | } | 278 | } |
201 | 274 | 279 | ||
202 | === modified file 'src/logic/production_program.cc' | |||
203 | --- src/logic/production_program.cc 2013-04-27 16:55:46 +0000 | |||
204 | +++ src/logic/production_program.cc 2013-07-16 17:39:34 +0000 | |||
205 | @@ -1288,7 +1288,7 @@ | |||
206 | 1288 | snprintf | 1288 | snprintf |
207 | 1289 | (ps.m_result_buffer, sizeof(ps.m_result_buffer), | 1289 | (ps.m_result_buffer, sizeof(ps.m_result_buffer), |
208 | 1290 | _("No soldier for this training level found!")); | 1290 | _("No soldier for this training level found!")); |
210 | 1291 | return ps.program_end(game, Failed); | 1291 | return ps.program_end(game, Skipped); |
211 | 1292 | } | 1292 | } |
212 | 1293 | if (attribute == atrHP) { | 1293 | if (attribute == atrHP) { |
213 | 1294 | if ((*it)->get_hp_level() == level) | 1294 | if ((*it)->get_hp_level() == level) |
214 | @@ -1378,7 +1378,7 @@ | |||
215 | 1378 | snprintf | 1378 | snprintf |
216 | 1379 | (ps.m_result_buffer, sizeof(ps.m_result_buffer), | 1379 | (ps.m_result_buffer, sizeof(ps.m_result_buffer), |
217 | 1380 | _("No soldier for this training level found!")); | 1380 | _("No soldier for this training level found!")); |
219 | 1381 | return ps.program_end(game, Failed); | 1381 | return ps.program_end(game, Skipped); |
220 | 1382 | } | 1382 | } |
221 | 1383 | if (attribute == atrHP) { | 1383 | if (attribute == atrHP) { |
222 | 1384 | if ((*it)->get_hp_level () == level) | 1384 | if ((*it)->get_hp_level () == level) |
223 | 1385 | 1385 | ||
224 | === modified file 'src/logic/productionsite.cc' | |||
225 | --- src/logic/productionsite.cc 2013-05-25 09:30:35 +0000 | |||
226 | +++ src/logic/productionsite.cc 2013-07-16 17:39:34 +0000 | |||
227 | @@ -457,7 +457,6 @@ | |||
228 | 457 | 457 | ||
229 | 458 | if (upcast(Game, game, &egbase)) | 458 | if (upcast(Game, game, &egbase)) |
230 | 459 | try_start_working(*game); | 459 | try_start_working(*game); |
231 | 460 | |||
232 | 461 | return 0; | 460 | return 0; |
233 | 462 | } | 461 | } |
234 | 463 | 462 | ||
235 | @@ -874,6 +873,7 @@ | |||
236 | 874 | for (uint32_t i = descr().nr_working_positions(); i;) | 873 | for (uint32_t i = descr().nr_working_positions(); i;) |
237 | 875 | m_working_positions[--i].worker->gain_experience(game); | 874 | m_working_positions[--i].worker->gain_experience(game); |
238 | 876 | m_result_buffer[0] = '\0'; | 875 | m_result_buffer[0] = '\0'; |
239 | 876 | Building::workers_changed(); | ||
240 | 877 | } | 877 | } |
241 | 878 | calc_statistics(); | 878 | calc_statistics(); |
242 | 879 | break; | 879 | break; |
243 | 880 | 880 | ||
244 | === modified file 'src/logic/trainingsite.cc' | |||
245 | --- src/logic/trainingsite.cc 2013-06-16 16:29:48 +0000 | |||
246 | +++ src/logic/trainingsite.cc 2013-07-16 17:39:34 +0000 | |||
247 | @@ -192,12 +192,7 @@ | |||
248 | 192 | */ | 192 | */ |
249 | 193 | std::string TrainingSite::get_statistics_string() | 193 | std::string TrainingSite::get_statistics_string() |
250 | 194 | { | 194 | { |
257 | 195 | if (State * const state = get_state()) | 195 | return ProductionSite::get_statistics_string(); |
252 | 196 | return state->program->descname(); | ||
253 | 197 | else if (m_result == Completed) | ||
254 | 198 | return _("Resting"); | ||
255 | 199 | else | ||
256 | 200 | return _("Not Working"); | ||
258 | 201 | } | 196 | } |
259 | 202 | 197 | ||
260 | 203 | /** | 198 | /** |
261 | 204 | 199 | ||
262 | === modified file 'src/network/internet_gaming.cc' | |||
263 | --- src/network/internet_gaming.cc 2013-04-20 20:20:34 +0000 | |||
264 | +++ src/network/internet_gaming.cc 2013-07-16 17:39:34 +0000 | |||
265 | @@ -768,7 +768,14 @@ | |||
266 | 768 | s.send(m_sock); | 768 | s.send(m_sock); |
267 | 769 | } | 769 | } |
268 | 770 | 770 | ||
270 | 771 | 771 | void InternetGaming::send_local(const std::string& msg) | |
271 | 772 | { | ||
272 | 773 | ChatMessage c; | ||
273 | 774 | c.msg = msg; | ||
274 | 775 | c.time = time(0); | ||
275 | 776 | messages.push_back(c); | ||
276 | 777 | ChatProvider::send(c); | ||
277 | 778 | } | ||
278 | 772 | 779 | ||
279 | 773 | /** | 780 | /** |
280 | 774 | * \returns the boolean value of a string received from the metaserver. | 781 | * \returns the boolean value of a string received from the metaserver. |
281 | 775 | 782 | ||
282 | === modified file 'src/network/internet_gaming.h' | |||
283 | --- src/network/internet_gaming.h 2013-02-10 19:36:24 +0000 | |||
284 | +++ src/network/internet_gaming.h 2013-07-16 17:39:34 +0000 | |||
285 | @@ -114,6 +114,9 @@ | |||
286 | 114 | // ChatProvider: sends a message via the metaserver. | 114 | // ChatProvider: sends a message via the metaserver. |
287 | 115 | void send(const std::string &); | 115 | void send(const std::string &); |
288 | 116 | 116 | ||
289 | 117 | // ChatProvider: sends local messages | ||
290 | 118 | void send_local(const std::string &); | ||
291 | 119 | |||
292 | 117 | /// ChatProvider: adds the message to the message list and calls parent. | 120 | /// ChatProvider: adds the message to the message list and calls parent. |
293 | 118 | void receive(const ChatMessage & msg) {messages.push_back(msg); ChatProvider::send(msg);} | 121 | void receive(const ChatMessage & msg) {messages.push_back(msg); ChatProvider::send(msg);} |
294 | 119 | 122 | ||
295 | 120 | 123 | ||
296 | === modified file 'src/network/netclient.cc' | |||
297 | --- src/network/netclient.cc 2013-04-22 20:15:00 +0000 | |||
298 | +++ src/network/netclient.cc 2013-07-16 17:39:34 +0000 | |||
299 | @@ -628,6 +628,15 @@ | |||
300 | 628 | s.send(d->sock); | 628 | s.send(d->sock); |
301 | 629 | } | 629 | } |
302 | 630 | 630 | ||
303 | 631 | void NetClient::send_local(const std::string& msg) | ||
304 | 632 | { | ||
305 | 633 | ChatMessage c; | ||
306 | 634 | c.msg = msg; | ||
307 | 635 | c.time = time(0); | ||
308 | 636 | d->chatmessages.push_back(c); | ||
309 | 637 | ChatProvider::send(c); | ||
310 | 638 | } | ||
311 | 639 | |||
312 | 631 | const std::vector<ChatMessage> & NetClient::getMessages() const | 640 | const std::vector<ChatMessage> & NetClient::getMessages() const |
313 | 632 | { | 641 | { |
314 | 633 | return d->chatmessages; | 642 | return d->chatmessages; |
315 | 634 | 643 | ||
316 | === modified file 'src/network/netclient.h' | |||
317 | --- src/network/netclient.h 2013-02-10 19:36:24 +0000 | |||
318 | +++ src/network/netclient.h 2013-07-16 17:39:34 +0000 | |||
319 | @@ -92,6 +92,7 @@ | |||
320 | 92 | 92 | ||
321 | 93 | // ChatProvider interface | 93 | // ChatProvider interface |
322 | 94 | void send(const std::string & msg); | 94 | void send(const std::string & msg); |
323 | 95 | void send_local(const std::string & msg); | ||
324 | 95 | const std::vector<ChatMessage> & getMessages() const; | 96 | const std::vector<ChatMessage> & getMessages() const; |
325 | 96 | 97 | ||
326 | 97 | private: | 98 | private: |
327 | 98 | 99 | ||
328 | === modified file 'src/network/nethost.cc' | |||
329 | --- src/network/nethost.cc 2013-07-15 05:18:12 +0000 | |||
330 | +++ src/network/nethost.cc 2013-07-16 17:39:34 +0000 | |||
331 | @@ -498,6 +498,13 @@ | |||
332 | 498 | h->send(c); | 498 | h->send(c); |
333 | 499 | } | 499 | } |
334 | 500 | 500 | ||
335 | 501 | void send_local(const std::string & msg) { | ||
336 | 502 | ChatMessage c; | ||
337 | 503 | c.time = time(0); | ||
338 | 504 | c.msg = msg; | ||
339 | 505 | ChatProvider::send(c); | ||
340 | 506 | } | ||
341 | 507 | |||
342 | 501 | const std::vector<ChatMessage> & getMessages() const { | 508 | const std::vector<ChatMessage> & getMessages() const { |
343 | 502 | return messages; | 509 | return messages; |
344 | 503 | } | 510 | } |
345 | 504 | 511 | ||
346 | === modified file 'src/save_handler.cc' | |||
347 | --- src/save_handler.cc 2013-07-14 11:48:13 +0000 | |||
348 | +++ src/save_handler.cc 2013-07-16 17:39:34 +0000 | |||
349 | @@ -25,6 +25,8 @@ | |||
350 | 25 | #include "io/filesystem/filesystem.h" | 25 | #include "io/filesystem/filesystem.h" |
351 | 26 | #include "game_io/game_saver.h" | 26 | #include "game_io/game_saver.h" |
352 | 27 | #include "profile/profile.h" | 27 | #include "profile/profile.h" |
353 | 28 | #include "wui/interactive_player.h" | ||
354 | 29 | #include "chat.h" | ||
355 | 28 | 30 | ||
356 | 29 | #include "log.h" | 31 | #include "log.h" |
357 | 30 | 32 | ||
358 | @@ -51,7 +53,10 @@ | |||
359 | 51 | if (elapsed < autosaveInterval) | 53 | if (elapsed < autosaveInterval) |
360 | 52 | return; | 54 | return; |
361 | 53 | 55 | ||
363 | 54 | log("Autosave: interval elapsed (%d s), saving\n", elapsed); | 56 | // TODO: defer saving to next tick so that this message is shown |
364 | 57 | // before the actual save, or put the saving logic in another thread | ||
365 | 58 | game.get_ipl()->get_chat_provider()->send_local | ||
366 | 59 | (_("Saving game...")); | ||
367 | 55 | 60 | ||
368 | 56 | // save the game | 61 | // save the game |
369 | 57 | std::string complete_filename = | 62 | std::string complete_filename = |
370 | @@ -70,6 +75,8 @@ | |||
371 | 70 | static std::string error; | 75 | static std::string error; |
372 | 71 | if (!save_game(game, complete_filename, &error)) { | 76 | if (!save_game(game, complete_filename, &error)) { |
373 | 72 | log("Autosave: ERROR! - %s\n", error.c_str()); | 77 | log("Autosave: ERROR! - %s\n", error.c_str()); |
374 | 78 | game.get_ipl()->get_chat_provider()->send_local | ||
375 | 79 | (_("Saving failed!")); | ||
376 | 73 | 80 | ||
377 | 74 | // if backup file was created, move it back | 81 | // if backup file was created, move it back |
378 | 75 | if (backup_filename.length() > 0) { | 82 | if (backup_filename.length() > 0) { |
379 | @@ -88,6 +95,8 @@ | |||
380 | 88 | } | 95 | } |
381 | 89 | 96 | ||
382 | 90 | log("Autosave: save took %d ms\n", m_last_saved_time - realtime); | 97 | log("Autosave: save took %d ms\n", m_last_saved_time - realtime); |
383 | 98 | game.get_ipl()->get_chat_provider()->send_local | ||
384 | 99 | (_("Game saved")); | ||
385 | 91 | } | 100 | } |
386 | 92 | 101 | ||
387 | 93 | /** | 102 | /** |
388 | @@ -98,7 +107,6 @@ | |||
389 | 98 | return; | 107 | return; |
390 | 99 | 108 | ||
391 | 100 | m_last_saved_time = currenttime; | 109 | m_last_saved_time = currenttime; |
392 | 101 | log("Autosave: initialized\n"); | ||
393 | 102 | m_initialized = true; | 110 | m_initialized = true; |
394 | 103 | } | 111 | } |
395 | 104 | 112 | ||
396 | 105 | 113 | ||
397 | === modified file 'src/timestring.cc' | |||
398 | --- src/timestring.cc 2013-03-21 10:45:51 +0000 | |||
399 | +++ src/timestring.cc 2013-07-16 17:39:34 +0000 | |||
400 | @@ -75,3 +75,18 @@ | |||
401 | 75 | } | 75 | } |
402 | 76 | return timestring_buffer; | 76 | return timestring_buffer; |
403 | 77 | } | 77 | } |
404 | 78 | |||
405 | 79 | char gamestringbuffer[] = "000:00:00"; | ||
406 | 80 | char * gametimestring(uint32_t gametime) | ||
407 | 81 | { | ||
408 | 82 | uint32_t time = gametime / 1000; | ||
409 | 83 | gamestringbuffer[8] = '0' + time % 10; | ||
410 | 84 | gamestringbuffer[7] = '0' + (time /= 10) % 6; | ||
411 | 85 | gamestringbuffer[5] = '0' + (time /= 6) % 10; | ||
412 | 86 | gamestringbuffer[4] = '0' + (time /= 10) % 6; | ||
413 | 87 | gamestringbuffer[2] = '0' + (time /= 6) % 10; | ||
414 | 88 | gamestringbuffer[1] = '0' + (time /= 10) % 10; | ||
415 | 89 | gamestringbuffer[0] = '0' + (time /= 10); | ||
416 | 90 | return gamestringbuffer; | ||
417 | 91 | } | ||
418 | 92 | |||
419 | 78 | 93 | ||
420 | === modified file 'src/timestring.h' | |||
421 | --- src/timestring.h 2012-02-15 21:25:34 +0000 | |||
422 | +++ src/timestring.h 2013-07-16 17:39:34 +0000 | |||
423 | @@ -21,3 +21,8 @@ | |||
424 | 21 | /// seconds since the Epoch). The return value points to a statically allocated | 21 | /// seconds since the Epoch). The return value points to a statically allocated |
425 | 22 | /// string which might be overwritten by subsequent calls. | 22 | /// string which might be overwritten by subsequent calls. |
426 | 23 | char * timestring(); | 23 | char * timestring(); |
427 | 24 | |||
428 | 25 | /// Get a string representation of the game time | ||
429 | 26 | /// as hhh:mm:ss. If Time represents more than | ||
430 | 27 | /// 999 hours, it wraps around | ||
431 | 28 | char * gametimestring(uint32_t gametime); | ||
432 | 24 | 29 | ||
433 | === modified file 'src/ui_basic/progressbar.cc' | |||
434 | --- src/ui_basic/progressbar.cc 2012-02-15 21:25:34 +0000 | |||
435 | +++ src/ui_basic/progressbar.cc 2013-07-16 17:39:34 +0000 | |||
436 | @@ -21,10 +21,12 @@ | |||
437 | 21 | 21 | ||
438 | 22 | #include "constants.h" | 22 | #include "constants.h" |
439 | 23 | #include "graphic/font.h" | 23 | #include "graphic/font.h" |
441 | 24 | #include "graphic/font_handler.h" | 24 | #include "graphic/font_handler1.h" |
442 | 25 | #include "text_layout.h" | ||
443 | 25 | #include "graphic/rendertarget.h" | 26 | #include "graphic/rendertarget.h" |
444 | 26 | 27 | ||
445 | 27 | #include <cstdio> | 28 | #include <cstdio> |
446 | 29 | #include <boost/format.hpp> | ||
447 | 28 | 30 | ||
448 | 29 | 31 | ||
449 | 30 | namespace UI { | 32 | namespace UI { |
450 | @@ -103,16 +105,11 @@ | |||
451 | 103 | } | 105 | } |
452 | 104 | 106 | ||
453 | 105 | // Print the state in percent | 107 | // Print the state in percent |
464 | 106 | char buffer[30]; | 108 | // TODO use UI_FNT_COLOR_BRIGHT when merged |
465 | 107 | 109 | uint32_t percent = static_cast<uint32_t>(fraction * 100); | |
466 | 108 | snprintf | 110 | const std::string progress_text = |
467 | 109 | (buffer, sizeof(buffer), "%u%%", static_cast<uint32_t>(fraction * 100)); | 111 | (boost::format("<font color=%1$s>%2$i%%</font>") % "ffffff" % percent).str(); |
468 | 110 | 112 | const Point pos(get_w() / 2, get_h() / 2); | |
469 | 111 | UI::g_fh->draw_text | 113 | dst.blit(pos, UI::g_fh1->render(as_uifont(progress_text)), CM_Normal, Align_Center); |
460 | 112 | (dst, UI::TextStyle::ui_small(), | ||
461 | 113 | Point(get_w() / 2, get_h() / 2), | ||
462 | 114 | buffer, | ||
463 | 115 | Align_Center); | ||
470 | 116 | } | 114 | } |
471 | 117 | |||
472 | 118 | } | 115 | } |
473 | 119 | 116 | ||
474 | === modified file 'src/ui_basic/table.cc' | |||
475 | --- src/ui_basic/table.cc 2013-07-13 14:25:41 +0000 | |||
476 | +++ src/ui_basic/table.cc 2013-07-16 17:39:34 +0000 | |||
477 | @@ -23,11 +23,13 @@ | |||
478 | 23 | #include "graphic/font_handler.h" | 23 | #include "graphic/font_handler.h" |
479 | 24 | #include "graphic/graphic.h" | 24 | #include "graphic/graphic.h" |
480 | 25 | #include "graphic/rendertarget.h" | 25 | #include "graphic/rendertarget.h" |
481 | 26 | #include "graphic/font_handler1.h" | ||
482 | 26 | 27 | ||
483 | 27 | #include "button.h" | 28 | #include "button.h" |
484 | 28 | #include "mouse_constants.h" | 29 | #include "mouse_constants.h" |
485 | 29 | #include "scrollbar.h" | 30 | #include "scrollbar.h" |
486 | 30 | #include "wlapplication.h" | 31 | #include "wlapplication.h" |
487 | 32 | #include "text_layout.h" | ||
488 | 31 | 33 | ||
489 | 32 | #include "container_iterate.h" | 34 | #include "container_iterate.h" |
490 | 33 | #include <boost/bind.hpp> | 35 | #include <boost/bind.hpp> |
491 | @@ -273,21 +275,13 @@ | |||
492 | 273 | const std::string & entry_string = er.get_string (i); | 275 | const std::string & entry_string = er.get_string (i); |
493 | 274 | uint32_t picw = 0; | 276 | uint32_t picw = 0; |
494 | 275 | uint32_t pich = 0; | 277 | uint32_t pich = 0; |
497 | 276 | uint32_t stringw = 0; | 278 | |
496 | 277 | uint32_t stringh = g_fh->get_fontheight(m_fontname, m_fontsize); | ||
498 | 278 | if (entry_picture) { | 279 | if (entry_picture) { |
499 | 279 | picw = entry_picture->width(); | 280 | picw = entry_picture->width(); |
500 | 280 | pich = entry_picture->height(); | 281 | pich = entry_picture->height(); |
501 | 281 | } | 282 | } |
511 | 282 | Point point = | 283 | Point point(curx, y); |
512 | 283 | Point(curx, y) | 284 | if (entry_picture) { |
504 | 284 | + | ||
505 | 285 | Point | ||
506 | 286 | (alignment & Align_Right ? curw - (picw + stringw) - 1 : | ||
507 | 287 | alignment & Align_HCenter ? (curw - (picw + stringw)) / 2 : | ||
508 | 288 | 1, | ||
509 | 289 | 0); | ||
510 | 290 | if (entry_picture) | ||
513 | 291 | dst.blit | 285 | dst.blit |
514 | 292 | (point + | 286 | (point + |
515 | 293 | Point | 287 | Point |
516 | @@ -296,18 +290,13 @@ | |||
517 | 296 | static_cast<int32_t>(pich)) | 290 | static_cast<int32_t>(pich)) |
518 | 297 | / 2), | 291 | / 2), |
519 | 298 | entry_picture); | 292 | entry_picture); |
520 | 293 | point.x += picw; | ||
521 | 294 | } | ||
522 | 299 | 295 | ||
534 | 300 | UI::g_fh->draw_text | 296 | const Image* entry_text_im = UI::g_fh1->render(as_uifont(entry_string, m_fontsize)); |
535 | 301 | (dst, | 297 | // Crop to column width |
536 | 302 | TextStyle::makebold(Font::get(m_fontname, m_fontsize), er.use_clr ? er.clr : UI_FONT_CLR_FG), | 298 | UI::correct_for_align(alignment, entry_text_im->width(), entry_text_im->height(), &point); |
537 | 303 | point + | 299 | dst.blitrect(point, entry_text_im, Rect(0, 0, curw - picw, lineheight)); |
527 | 304 | Point | ||
528 | 305 | (picw, | ||
529 | 306 | (static_cast<int32_t>(lineheight) - | ||
530 | 307 | static_cast<int32_t>(stringh)) | ||
531 | 308 | / 2), | ||
532 | 309 | entry_string, | ||
533 | 310 | alignment); | ||
538 | 311 | 300 | ||
539 | 312 | curx += curw; | 301 | curx += curw; |
540 | 313 | } | 302 | } |
541 | 314 | 303 | ||
542 | === modified file 'src/ui_fsmenu/loadgame.cc' | |||
543 | --- src/ui_fsmenu/loadgame.cc 2013-07-15 05:18:12 +0000 | |||
544 | +++ src/ui_fsmenu/loadgame.cc 2013-07-16 17:39:34 +0000 | |||
545 | @@ -29,6 +29,7 @@ | |||
546 | 29 | #include "log.h" | 29 | #include "log.h" |
547 | 30 | #include "logic/game.h" | 30 | #include "logic/game.h" |
548 | 31 | #include "ui_basic/messagebox.h" | 31 | #include "ui_basic/messagebox.h" |
549 | 32 | #include "timestring.h" | ||
550 | 32 | 33 | ||
551 | 33 | #include <cstdio> | 34 | #include <cstdio> |
552 | 34 | 35 | ||
553 | @@ -203,15 +204,9 @@ | |||
554 | 203 | m_tamapname.set_text(_(gpdp.get_mapname())); | 204 | m_tamapname.set_text(_(gpdp.get_mapname())); |
555 | 204 | } | 205 | } |
556 | 205 | 206 | ||
558 | 206 | char buf[200]; | 207 | char buf[20]; |
559 | 207 | uint32_t gametime = gpdp.get_gametime(); | 208 | uint32_t gametime = gpdp.get_gametime(); |
567 | 208 | 209 | m_tagametime.set_text(gametimestring(gametime)); | |
561 | 209 | int32_t hours = gametime / 3600000; | ||
562 | 210 | gametime -= hours * 3600000; | ||
563 | 211 | int32_t minutes = gametime / 60000; | ||
564 | 212 | |||
565 | 213 | sprintf(buf, "%02i:%02i", hours, minutes); | ||
566 | 214 | m_tagametime.set_text(buf); | ||
568 | 215 | 210 | ||
569 | 216 | sprintf(buf, "%i", gpdp.get_player_nr()); | 211 | sprintf(buf, "%i", gpdp.get_player_nr()); |
570 | 217 | m_ta_players.set_text(buf); | 212 | m_ta_players.set_text(buf); |
571 | 218 | 213 | ||
572 | === modified file 'src/ui_fsmenu/loadreplay.cc' | |||
573 | --- src/ui_fsmenu/loadreplay.cc 2013-07-14 16:11:41 +0000 | |||
574 | +++ src/ui_fsmenu/loadreplay.cc 2013-07-16 17:39:34 +0000 | |||
575 | @@ -28,6 +28,7 @@ | |||
576 | 28 | #include "logic/game.h" | 28 | #include "logic/game.h" |
577 | 29 | #include "logic/replay.h" | 29 | #include "logic/replay.h" |
578 | 30 | #include "ui_basic/messagebox.h" | 30 | #include "ui_basic/messagebox.h" |
579 | 31 | #include "timestring.h" | ||
580 | 31 | 32 | ||
581 | 32 | Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay() : | 33 | Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay() : |
582 | 33 | Fullscreen_Menu_Base("choosemapmenu.jpg"), | 34 | Fullscreen_Menu_Base("choosemapmenu.jpg"), |
583 | @@ -186,15 +187,9 @@ | |||
584 | 186 | m_delete.set_enabled(true); | 187 | m_delete.set_enabled(true); |
585 | 187 | m_tamapname.set_text(gpdp.get_mapname()); | 188 | m_tamapname.set_text(gpdp.get_mapname()); |
586 | 188 | 189 | ||
588 | 189 | char buf[200]; | 190 | char buf[20]; |
589 | 190 | uint32_t gametime = gpdp.get_gametime(); | 191 | uint32_t gametime = gpdp.get_gametime(); |
597 | 191 | 192 | m_tagametime.set_text(gametimestring(gametime)); | |
591 | 192 | int32_t hours = gametime / 3600000; | ||
592 | 193 | gametime -= hours * 3600000; | ||
593 | 194 | int32_t minutes = gametime / 60000; | ||
594 | 195 | |||
595 | 196 | sprintf(buf, "%02i:%02i", hours, minutes); | ||
596 | 197 | m_tagametime.set_text(buf); | ||
598 | 198 | 193 | ||
599 | 199 | sprintf(buf, "%i", gpdp.get_player_nr()); | 194 | sprintf(buf, "%i", gpdp.get_player_nr()); |
600 | 200 | m_ta_players.set_text(buf); | 195 | m_ta_players.set_text(buf); |
601 | 201 | 196 | ||
602 | === modified file 'src/ui_fsmenu/mapselect.cc' | |||
603 | --- src/ui_fsmenu/mapselect.cc 2013-06-15 14:35:17 +0000 | |||
604 | +++ src/ui_fsmenu/mapselect.cc 2013-07-16 17:39:34 +0000 | |||
605 | @@ -172,11 +172,11 @@ | |||
606 | 172 | vbox->set_size(get_w(), 25); | 172 | vbox->set_size(get_w(), 25); |
607 | 173 | vbox = new UI::Box(this, m_table.get_x(), m_table.get_y() - 60, UI::Box::Horizontal, m_table.get_w()); | 173 | vbox = new UI::Box(this, m_table.get_x(), m_table.get_y() - 60, UI::Box::Horizontal, m_table.get_w()); |
608 | 174 | _add_tag_checkbox(vbox, "1v1", _("1v1")); | 174 | _add_tag_checkbox(vbox, "1v1", _("1v1")); |
611 | 175 | _add_tag_checkbox(vbox, "2teams", _("2 Player Teams")); | 175 | _add_tag_checkbox(vbox, "2teams", _("Teams of 2")); |
612 | 176 | _add_tag_checkbox(vbox, "3teams", _("3 Player Teams")); | 176 | _add_tag_checkbox(vbox, "3teams", _("Teams of 3")); |
613 | 177 | vbox->set_size(get_w(), 25); | 177 | vbox->set_size(get_w(), 25); |
614 | 178 | vbox = new UI::Box(this, m_table.get_x(), m_table.get_y() - 30, UI::Box::Horizontal, m_table.get_w()); | 178 | vbox = new UI::Box(this, m_table.get_x(), m_table.get_y() - 30, UI::Box::Horizontal, m_table.get_w()); |
616 | 179 | _add_tag_checkbox(vbox, "4teams", _("4 Player Teams")); | 179 | _add_tag_checkbox(vbox, "4teams", _("Teams of 4")); |
617 | 180 | _add_tag_checkbox(vbox, "ffa", _("Free for all")); | 180 | _add_tag_checkbox(vbox, "ffa", _("Free for all")); |
618 | 181 | _add_tag_checkbox(vbox, "unbalanced", _("Unbalanced")); | 181 | _add_tag_checkbox(vbox, "unbalanced", _("Unbalanced")); |
619 | 182 | vbox->set_size(get_w(), 25); | 182 | vbox->set_size(get_w(), 25); |
620 | 183 | 183 | ||
621 | === modified file 'src/wlapplication.cc' | |||
622 | --- src/wlapplication.cc 2013-07-15 05:18:12 +0000 | |||
623 | +++ src/wlapplication.cc 2013-07-16 17:39:34 +0000 | |||
624 | @@ -2036,9 +2036,14 @@ | |||
625 | 2036 | } | 2036 | } |
626 | 2037 | } else { // normal singleplayer | 2037 | } else { // normal singleplayer |
627 | 2038 | uint8_t const pn = sp.settings().playernum + 1; | 2038 | uint8_t const pn = sp.settings().playernum + 1; |
628 | 2039 | boost::scoped_ptr<GameController> ctrl | ||
629 | 2040 | (GameController::createSinglePlayer(game, true, pn)); | ||
630 | 2041 | try { | 2039 | try { |
631 | 2040 | // Game controller needs the ibase pointer to init | ||
632 | 2041 | // the chat | ||
633 | 2042 | game.set_ibase | ||
634 | 2043 | (new Interactive_Player | ||
635 | 2044 | (game, g_options.pull_section("global"), pn, false, false)); | ||
636 | 2045 | boost::scoped_ptr<GameController> ctrl | ||
637 | 2046 | (GameController::createSinglePlayer(game, true, pn)); | ||
638 | 2042 | UI::ProgressWindow loaderUI; | 2047 | UI::ProgressWindow loaderUI; |
639 | 2043 | std::vector<std::string> tipstext; | 2048 | std::vector<std::string> tipstext; |
640 | 2044 | tipstext.push_back("general_game"); | 2049 | tipstext.push_back("general_game"); |
641 | @@ -2052,9 +2057,6 @@ | |||
642 | 2052 | loaderUI.step(_("Preparing game")); | 2057 | loaderUI.step(_("Preparing game")); |
643 | 2053 | 2058 | ||
644 | 2054 | game.set_game_controller(ctrl.get()); | 2059 | game.set_game_controller(ctrl.get()); |
645 | 2055 | game.set_ibase | ||
646 | 2056 | (new Interactive_Player | ||
647 | 2057 | (game, g_options.pull_section("global"), pn, false, false)); | ||
648 | 2058 | game.init_newgame(&loaderUI, sp.settings()); | 2060 | game.init_newgame(&loaderUI, sp.settings()); |
649 | 2059 | game.run(&loaderUI, Widelands::Game::NewNonScenario); | 2061 | game.run(&loaderUI, Widelands::Game::NewNonScenario); |
650 | 2060 | } catch (const std::exception & e) { | 2062 | } catch (const std::exception & e) { |
651 | 2061 | 2063 | ||
652 | === modified file 'src/wui/building_ui.cc' | |||
653 | --- src/wui/building_ui.cc 2013-07-09 05:53:39 +0000 | |||
654 | +++ src/wui/building_ui.cc 2013-07-16 17:39:34 +0000 | |||
655 | @@ -17,6 +17,8 @@ | |||
656 | 17 | * | 17 | * |
657 | 18 | */ | 18 | */ |
658 | 19 | 19 | ||
659 | 20 | #include <boost/foreach.hpp> | ||
660 | 21 | #include <boost/lexical_cast.hpp> | ||
661 | 20 | #include "buildingwindow.h" | 22 | #include "buildingwindow.h" |
662 | 21 | #include "logic/building.h" | 23 | #include "logic/building.h" |
663 | 22 | #include "ui_basic/window.h" | 24 | #include "ui_basic/window.h" |
664 | @@ -30,14 +32,17 @@ | |||
665 | 30 | */ | 32 | */ |
666 | 31 | void Building::show_options(Interactive_GameBase & igbase, bool avoid_fastclick) | 33 | void Building::show_options(Interactive_GameBase & igbase, bool avoid_fastclick) |
667 | 32 | { | 34 | { |
668 | 35 | // Reset tooltip before opening the window | ||
669 | 36 | igbase.set_tooltip(""); | ||
670 | 33 | if (m_optionswindow) { | 37 | if (m_optionswindow) { |
671 | 34 | if (m_optionswindow->is_minimal()) | 38 | if (m_optionswindow->is_minimal()) |
672 | 35 | m_optionswindow->restore(); | 39 | m_optionswindow->restore(); |
673 | 36 | m_optionswindow->move_to_top(); | 40 | m_optionswindow->move_to_top(); |
674 | 37 | } else { | 41 | } else { |
675 | 38 | create_options_window(igbase, m_optionswindow); | 42 | create_options_window(igbase, m_optionswindow); |
677 | 39 | if (upcast(Building_Window, bw, m_optionswindow)) | 43 | if (upcast(Building_Window, bw, m_optionswindow)) { |
678 | 40 | bw->set_avoid_fastclick(avoid_fastclick); | 44 | bw->set_avoid_fastclick(avoid_fastclick); |
679 | 45 | } | ||
680 | 41 | // Run a first think here so that certain things like caps buttons | 46 | // Run a first think here so that certain things like caps buttons |
681 | 42 | // get properly initialized | 47 | // get properly initialized |
682 | 43 | m_optionswindow->think(); | 48 | m_optionswindow->think(); |
683 | @@ -49,6 +54,8 @@ | |||
684 | 49 | */ | 54 | */ |
685 | 50 | void Building::hide_options() | 55 | void Building::hide_options() |
686 | 51 | { | 56 | { |
687 | 57 | BOOST_FOREACH(boost::signals::connection& c, options_window_connections) | ||
688 | 58 | c.disconnect(); | ||
689 | 52 | delete m_optionswindow; | 59 | delete m_optionswindow; |
690 | 53 | m_optionswindow = NULL; | 60 | m_optionswindow = NULL; |
691 | 54 | } | 61 | } |
692 | 55 | 62 | ||
693 | === modified file 'src/wui/buildingwindow.cc' | |||
694 | --- src/wui/buildingwindow.cc 2013-07-13 15:58:52 +0000 | |||
695 | +++ src/wui/buildingwindow.cc 2013-07-16 17:39:34 +0000 | |||
696 | @@ -79,13 +79,6 @@ | |||
697 | 79 | set_center_panel(vbox); | 79 | set_center_panel(vbox); |
698 | 80 | set_think(true); | 80 | set_think(true); |
699 | 81 | 81 | ||
700 | 82 | char filename[] = "pics/workarea0cumulative.png"; | ||
701 | 83 | compile_assert(NUMBER_OF_WORKAREA_PICS <= 9); | ||
702 | 84 | for (Workarea_Info::size_type i = 0; i < NUMBER_OF_WORKAREA_PICS; ++i) { | ||
703 | 85 | ++filename[13]; | ||
704 | 86 | workarea_cumulative_pic[i] = g_gr->images().get(filename); | ||
705 | 87 | } | ||
706 | 88 | |||
707 | 89 | show_workarea(); | 82 | show_workarea(); |
708 | 90 | 83 | ||
709 | 91 | set_fastclick_panel(this); | 84 | set_fastclick_panel(this); |
710 | @@ -327,7 +320,7 @@ | |||
711 | 327 | (capsbuttons, "workarea", | 320 | (capsbuttons, "workarea", |
712 | 328 | 0, 0, 34, 34, | 321 | 0, 0, 34, 34, |
713 | 329 | g_gr->images().get("pics/but4.png"), | 322 | g_gr->images().get("pics/but4.png"), |
715 | 330 | g_gr->images().get("pics/workarea3cumulative.png"), | 323 | g_gr->images().get("pics/workarea123.png"), |
716 | 331 | _("Hide workarea")); | 324 | _("Hide workarea")); |
717 | 332 | m_toggle_workarea->sigclicked.connect | 325 | m_toggle_workarea->sigclicked.connect |
718 | 333 | (boost::bind(&Building_Window::toggle_workarea, boost::ref(*this))); | 326 | (boost::bind(&Building_Window::toggle_workarea, boost::ref(*this))); |
719 | @@ -512,41 +505,11 @@ | |||
720 | 512 | */ | 505 | */ |
721 | 513 | void Building_Window::show_workarea() | 506 | void Building_Window::show_workarea() |
722 | 514 | { | 507 | { |
724 | 515 | if (m_workarea_job_id) | 508 | if (m_workarea_job_id) { |
725 | 516 | return; // already shown, nothing to be done | 509 | return; // already shown, nothing to be done |
727 | 517 | 510 | } | |
728 | 518 | const Workarea_Info & workarea_info = m_building.descr().m_workarea_info; | 511 | const Workarea_Info & workarea_info = m_building.descr().m_workarea_info; |
760 | 519 | if (workarea_info.size() == 0) | 512 | m_workarea_job_id = igbase().show_work_area(workarea_info, m_building.get_position()); |
730 | 520 | return; // building has no workarea | ||
731 | 521 | |||
732 | 522 | Widelands::Map & map = | ||
733 | 523 | ref_cast<const Interactive_GameBase, UI::Panel>(*get_parent()).egbase() | ||
734 | 524 | .map(); | ||
735 | 525 | Overlay_Manager & overlay_manager = map.overlay_manager(); | ||
736 | 526 | m_workarea_job_id = overlay_manager.get_a_job_id(); | ||
737 | 527 | |||
738 | 528 | Widelands::HollowArea<> hollow_area | ||
739 | 529 | (Widelands::Area<>(m_building.get_position(), 0), 0); | ||
740 | 530 | Workarea_Info::const_iterator it = workarea_info.begin(); | ||
741 | 531 | for | ||
742 | 532 | (Workarea_Info::size_type i = | ||
743 | 533 | std::min(workarea_info.size(), NUMBER_OF_WORKAREA_PICS); | ||
744 | 534 | i; | ||
745 | 535 | ++it) | ||
746 | 536 | { | ||
747 | 537 | --i; | ||
748 | 538 | hollow_area.radius = it->first; | ||
749 | 539 | Widelands::MapHollowRegion<> mr(map, hollow_area); | ||
750 | 540 | do | ||
751 | 541 | overlay_manager.register_overlay | ||
752 | 542 | (mr.location(), | ||
753 | 543 | workarea_cumulative_pic[i], | ||
754 | 544 | 0, | ||
755 | 545 | Point::invalid(), | ||
756 | 546 | m_workarea_job_id); | ||
757 | 547 | while (mr.advance(map)); | ||
758 | 548 | hollow_area.hole_radius = hollow_area.radius; | ||
759 | 549 | } | ||
761 | 550 | 513 | ||
762 | 551 | configure_workarea_button(); | 514 | configure_workarea_button(); |
763 | 552 | } | 515 | } |
764 | @@ -557,11 +520,7 @@ | |||
765 | 557 | void Building_Window::hide_workarea() | 520 | void Building_Window::hide_workarea() |
766 | 558 | { | 521 | { |
767 | 559 | if (m_workarea_job_id) { | 522 | if (m_workarea_job_id) { |
773 | 560 | Widelands::Map & map = | 523 | igbase().hide_work_area(m_workarea_job_id); |
769 | 561 | ref_cast<const Interactive_GameBase, UI::Panel>(*get_parent()).egbase() | ||
770 | 562 | .map(); | ||
771 | 563 | Overlay_Manager & overlay_manager = map.overlay_manager(); | ||
772 | 564 | overlay_manager.remove_overlay(m_workarea_job_id); | ||
774 | 565 | m_workarea_job_id = Overlay_Manager::Job_Id::Null(); | 524 | m_workarea_job_id = Overlay_Manager::Job_Id::Null(); |
775 | 566 | 525 | ||
776 | 567 | configure_workarea_button(); | 526 | configure_workarea_button(); |
777 | 568 | 527 | ||
778 | === modified file 'src/wui/buildingwindow.h' | |||
779 | --- src/wui/buildingwindow.h 2013-07-08 03:35:09 +0000 | |||
780 | +++ src/wui/buildingwindow.h 2013-07-16 17:39:34 +0000 | |||
781 | @@ -94,7 +94,6 @@ | |||
782 | 94 | bool m_caps_setup; | 94 | bool m_caps_setup; |
783 | 95 | 95 | ||
784 | 96 | Overlay_Manager::Job_Id m_workarea_job_id; | 96 | Overlay_Manager::Job_Id m_workarea_job_id; |
785 | 97 | const Image* workarea_cumulative_pic[NUMBER_OF_WORKAREA_PICS]; | ||
786 | 98 | bool m_avoid_fastclick; | 97 | bool m_avoid_fastclick; |
787 | 99 | }; | 98 | }; |
788 | 100 | 99 | ||
789 | 101 | 100 | ||
790 | === modified file 'src/wui/fieldaction.cc' | |||
791 | --- src/wui/fieldaction.cc 2013-02-09 23:36:30 +0000 | |||
792 | +++ src/wui/fieldaction.cc 2013-07-16 17:39:34 +0000 | |||
793 | @@ -231,7 +231,6 @@ | |||
794 | 231 | bool m_fastclick; // if true, put the mouse over first button in first tab | 231 | bool m_fastclick; // if true, put the mouse over first button in first tab |
795 | 232 | uint32_t m_best_tab; | 232 | uint32_t m_best_tab; |
796 | 233 | Overlay_Manager::Job_Id m_workarea_preview_job_id; | 233 | Overlay_Manager::Job_Id m_workarea_preview_job_id; |
797 | 234 | const Image* workarea_cumulative_pic[NUMBER_OF_WORKAREA_PICS]; | ||
798 | 235 | 234 | ||
799 | 236 | /// Variables to use with attack dialog. | 235 | /// Variables to use with attack dialog. |
800 | 237 | AttackBox * m_attack_box; | 236 | AttackBox * m_attack_box; |
801 | @@ -297,13 +296,6 @@ | |||
802 | 297 | 296 | ||
803 | 298 | 297 | ||
804 | 299 | set_center_panel(&m_tabpanel); | 298 | set_center_panel(&m_tabpanel); |
805 | 300 | |||
806 | 301 | char filename[] = "pics/workarea0cumulative.png"; | ||
807 | 302 | compile_assert(NUMBER_OF_WORKAREA_PICS <= 9); | ||
808 | 303 | for (Workarea_Info::size_type i = 0; i < NUMBER_OF_WORKAREA_PICS; ++i) { | ||
809 | 304 | ++filename[13]; | ||
810 | 305 | workarea_cumulative_pic[i] = g_gr->images().get(filename); | ||
811 | 306 | } | ||
812 | 307 | } | 299 | } |
813 | 308 | 300 | ||
814 | 309 | 301 | ||
815 | @@ -856,44 +848,10 @@ | |||
816 | 856 | (const Widelands::Building_Index::value_t idx) | 848 | (const Widelands::Building_Index::value_t idx) |
817 | 857 | { | 849 | { |
818 | 858 | if (ibase().m_show_workarea_preview and not m_workarea_preview_job_id) { | 850 | if (ibase().m_show_workarea_preview and not m_workarea_preview_job_id) { |
819 | 859 | m_workarea_preview_job_id = m_overlay_manager.get_a_job_id(); | ||
820 | 860 | Widelands::HollowArea<> hollow_area(Widelands::Area<>(m_node, 0), 0); | ||
821 | 861 | const Workarea_Info & workarea_info = | 851 | const Workarea_Info & workarea_info = |
822 | 862 | m_plr->tribe().get_building_descr(Widelands::Building_Index(idx)) | 852 | m_plr->tribe().get_building_descr(Widelands::Building_Index(idx)) |
823 | 863 | ->m_workarea_info; | 853 | ->m_workarea_info; |
857 | 864 | Workarea_Info::const_iterator it = workarea_info.begin(); | 854 | m_workarea_preview_job_id = ibase().show_work_area(workarea_info, m_node); |
825 | 865 | for | ||
826 | 866 | (Workarea_Info::size_type i = | ||
827 | 867 | std::min(workarea_info.size(), NUMBER_OF_WORKAREA_PICS); | ||
828 | 868 | i; | ||
829 | 869 | ++it) | ||
830 | 870 | { | ||
831 | 871 | --i; | ||
832 | 872 | hollow_area.radius = it->first; | ||
833 | 873 | assert(hollow_area.radius); | ||
834 | 874 | assert(hollow_area.hole_radius < hollow_area.radius); | ||
835 | 875 | Widelands::MapHollowRegion<> mr(*m_map, hollow_area); | ||
836 | 876 | do | ||
837 | 877 | m_overlay_manager.register_overlay | ||
838 | 878 | (mr.location(), | ||
839 | 879 | workarea_cumulative_pic[i], | ||
840 | 880 | 0, | ||
841 | 881 | Point::invalid(), | ||
842 | 882 | m_workarea_preview_job_id); | ||
843 | 883 | while (mr.advance(*m_map)); | ||
844 | 884 | hollow_area.hole_radius = hollow_area.radius; | ||
845 | 885 | } | ||
846 | 886 | |||
847 | 887 | #if 0 | ||
848 | 888 | // This is debug output. | ||
849 | 889 | // Improvement suggestion: add to sign explanation window instead. | ||
850 | 890 | container_iterate_const(Workarea_Info, workarea_info, i) { | ||
851 | 891 | log("Radius: %i\n", i.current->first); | ||
852 | 892 | container_iterate_const(std::set<std::string>, i.current->second, j) | ||
853 | 893 | log(" %s\n", j.current->c_str()); | ||
854 | 894 | } | ||
855 | 895 | #endif | ||
856 | 896 | |||
858 | 897 | } | 855 | } |
859 | 898 | } | 856 | } |
860 | 899 | 857 | ||
861 | 900 | 858 | ||
862 | === modified file 'src/wui/game_main_menu_save_game.cc' | |||
863 | --- src/wui/game_main_menu_save_game.cc 2013-07-15 11:01:59 +0000 | |||
864 | +++ src/wui/game_main_menu_save_game.cc 2013-07-16 17:39:34 +0000 | |||
865 | @@ -28,10 +28,13 @@ | |||
866 | 28 | #include "game_io/game_saver.h" | 28 | #include "game_io/game_saver.h" |
867 | 29 | #include "i18n.h" | 29 | #include "i18n.h" |
868 | 30 | #include "interactive_gamebase.h" | 30 | #include "interactive_gamebase.h" |
869 | 31 | #include "gamecontroller.h" | ||
870 | 31 | #include "io/filesystem/filesystem.h" | 32 | #include "io/filesystem/filesystem.h" |
871 | 32 | #include "io/filesystem/layered_filesystem.h" | 33 | #include "io/filesystem/layered_filesystem.h" |
872 | 33 | #include "logic/game.h" | 34 | #include "logic/game.h" |
873 | 34 | #include "profile/profile.h" | 35 | #include "profile/profile.h" |
874 | 36 | #include "interactive_player.h" | ||
875 | 37 | #include "timestring.h" | ||
876 | 35 | 38 | ||
877 | 36 | using boost::format; | 39 | using boost::format; |
878 | 37 | 40 | ||
879 | @@ -125,6 +128,10 @@ | |||
880 | 125 | } | 128 | } |
881 | 126 | 129 | ||
882 | 127 | m_editbox->focus(); | 130 | m_editbox->focus(); |
883 | 131 | if (!parent.game().get_ipl()->is_multiplayer()) { | ||
884 | 132 | // Pause the game | ||
885 | 133 | parent.game().gameController()->setPaused(true); | ||
886 | 134 | } | ||
887 | 128 | } | 135 | } |
888 | 129 | 136 | ||
889 | 130 | 137 | ||
890 | @@ -144,20 +151,11 @@ | |||
891 | 144 | m_button_ok->set_enabled(true); | 151 | m_button_ok->set_enabled(true); |
892 | 145 | 152 | ||
893 | 146 | m_name.set_text(gpdp.get_mapname()); | 153 | m_name.set_text(gpdp.get_mapname()); |
894 | 154 | |||
895 | 155 | uint32_t gametime = gpdp.get_gametime(); | ||
896 | 156 | m_gametime.set_text(gametimestring(gametime)); | ||
897 | 157 | |||
898 | 147 | char buf[200]; | 158 | char buf[200]; |
899 | 148 | uint32_t gametime = gpdp.get_gametime(); | ||
900 | 149 | #define SPLIT_GAMETIME(unit, factor) \ | ||
901 | 150 | uint32_t const unit = gametime / factor; gametime %= factor; | ||
902 | 151 | SPLIT_GAMETIME(days, 86400000); | ||
903 | 152 | SPLIT_GAMETIME(hours, 3600000); | ||
904 | 153 | SPLIT_GAMETIME(minutes, 60000); | ||
905 | 154 | SPLIT_GAMETIME(seconds, 1000); | ||
906 | 155 | sprintf | ||
907 | 156 | (buf, | ||
908 | 157 | _("%02ud%02uh%02u'%02u\"%03u"), | ||
909 | 158 | days, hours, minutes, seconds, gametime); | ||
910 | 159 | m_gametime.set_text(buf); | ||
911 | 160 | |||
912 | 161 | sprintf | 159 | sprintf |
913 | 162 | (buf, "%i %s", gpdp.get_player_nr(), | 160 | (buf, "%i %s", gpdp.get_player_nr(), |
914 | 163 | ngettext(_("player"), _("players"), gpdp.get_player_nr())); | 161 | ngettext(_("player"), _("players"), gpdp.get_player_nr())); |
915 | @@ -293,6 +291,15 @@ | |||
916 | 293 | } | 291 | } |
917 | 294 | } | 292 | } |
918 | 295 | 293 | ||
919 | 294 | void Game_Main_Menu_Save_Game::die() | ||
920 | 295 | { | ||
921 | 296 | UI::UniqueWindow::die(); | ||
922 | 297 | if (!igbase().game().get_ipl()->is_multiplayer()) { | ||
923 | 298 | igbase().game().gameController()->setPaused(false); | ||
924 | 299 | } | ||
925 | 300 | } | ||
926 | 301 | |||
927 | 302 | |||
928 | 296 | 303 | ||
929 | 297 | struct DeletionMessageBox : public UI::WLMessageBox { | 304 | struct DeletionMessageBox : public UI::WLMessageBox { |
930 | 298 | DeletionMessageBox | 305 | DeletionMessageBox |
931 | 299 | 306 | ||
932 | === modified file 'src/wui/game_main_menu_save_game.h' | |||
933 | --- src/wui/game_main_menu_save_game.h 2013-07-13 15:17:51 +0000 | |||
934 | +++ src/wui/game_main_menu_save_game.h 2013-07-16 17:39:34 +0000 | |||
935 | @@ -43,7 +43,7 @@ | |||
936 | 43 | void select_by_name(std::string name); | 43 | void select_by_name(std::string name); |
937 | 44 | private: | 44 | private: |
938 | 45 | Interactive_GameBase & igbase(); | 45 | Interactive_GameBase & igbase(); |
940 | 46 | void die() {UI::UniqueWindow::die();} | 46 | void die(); |
941 | 47 | void selected (uint32_t); | 47 | void selected (uint32_t); |
942 | 48 | void double_clicked(uint32_t); | 48 | void double_clicked(uint32_t); |
943 | 49 | void edit_box_changed(); | 49 | void edit_box_changed(); |
944 | 50 | 50 | ||
945 | === modified file 'src/wui/game_message_menu.cc' | |||
946 | --- src/wui/game_message_menu.cc 2013-07-12 15:11:32 +0000 | |||
947 | +++ src/wui/game_message_menu.cc 2013-07-16 17:39:34 +0000 | |||
948 | @@ -28,6 +28,7 @@ | |||
949 | 28 | #include "logic/playercommand.h" | 28 | #include "logic/playercommand.h" |
950 | 29 | 29 | ||
951 | 30 | #include "container_iterate.h" | 30 | #include "container_iterate.h" |
952 | 31 | #include "timestring.h" | ||
953 | 31 | 32 | ||
954 | 32 | using Widelands::Message; | 33 | using Widelands::Message; |
955 | 33 | using Widelands::Message_Id; | 34 | using Widelands::Message_Id; |
956 | @@ -109,6 +110,8 @@ | |||
957 | 109 | 110 | ||
958 | 110 | list->set_column_compare | 111 | list->set_column_compare |
959 | 111 | (ColStatus, boost::bind(&GameMessageMenu::status_compare, this, _1, _2)); | 112 | (ColStatus, boost::bind(&GameMessageMenu::status_compare, this, _1, _2)); |
960 | 113 | list->set_sort_column(ColTimeSent); | ||
961 | 114 | list->set_sort_descending(true); | ||
962 | 112 | 115 | ||
963 | 113 | set_can_focus(true); | 116 | set_can_focus(true); |
964 | 114 | focus(); | 117 | focus(); |
965 | @@ -200,19 +203,8 @@ | |||
966 | 200 | g_gr->images().get(status_picture_filename[message.status()])); | 203 | g_gr->images().get(status_picture_filename[message.status()])); |
967 | 201 | er.set_string(ColTitle, message.title()); | 204 | er.set_string(ColTitle, message.title()); |
968 | 202 | 205 | ||
982 | 203 | uint32_t time = message.sent(); | 206 | const uint32_t time = message.sent(); |
983 | 204 | char timestring[] = "000:00:00.000"; | 207 | er.set_string(ColTimeSent, gametimestring(time)); |
971 | 205 | timestring[12] += time % 10; | ||
972 | 206 | timestring[11] += (time /= 10) % 10; | ||
973 | 207 | timestring[10] += (time /= 10) % 10; | ||
974 | 208 | timestring [8] += (time /= 10) % 10; | ||
975 | 209 | timestring [7] += (time /= 10) % 6; | ||
976 | 210 | timestring [5] += (time /= 6) % 10; | ||
977 | 211 | timestring [4] += (time /= 10) % 6; | ||
978 | 212 | timestring [2] += (time /= 6) % 10; | ||
979 | 213 | timestring [1] += (time /= 10) % 10; | ||
980 | 214 | timestring [0] += time /= 10; | ||
981 | 215 | er.set_string(ColTimeSent, time < 10 ? timestring : "-------------"); | ||
984 | 216 | } | 208 | } |
985 | 217 | 209 | ||
986 | 218 | /* | 210 | /* |
987 | 219 | 211 | ||
988 | === modified file 'src/wui/interactive_base.cc' | |||
989 | --- src/wui/interactive_base.cc 2013-06-15 13:38:19 +0000 | |||
990 | +++ src/wui/interactive_base.cc 2013-07-16 17:39:34 +0000 | |||
991 | @@ -36,6 +36,7 @@ | |||
992 | 36 | #include "logic/maptriangleregion.h" | 36 | #include "logic/maptriangleregion.h" |
993 | 37 | #include "logic/player.h" | 37 | #include "logic/player.h" |
994 | 38 | #include "logic/productionsite.h" | 38 | #include "logic/productionsite.h" |
995 | 39 | #include "logic/maphollowregion.h" | ||
996 | 39 | #include "mapviewpixelconstants.h" | 40 | #include "mapviewpixelconstants.h" |
997 | 40 | #include "mapviewpixelfunctions.h" | 41 | #include "mapviewpixelfunctions.h" |
998 | 41 | #include "minimap.h" | 42 | #include "minimap.h" |
999 | @@ -119,6 +120,15 @@ | |||
1000 | 119 | // funny results. | 120 | // funny results. |
1001 | 120 | m_sel.pic = g_gr->images().get("pics/fsel.png"); | 121 | m_sel.pic = g_gr->images().get("pics/fsel.png"); |
1002 | 121 | 122 | ||
1003 | 123 | // Load workarea images. | ||
1004 | 124 | // Start at idx 0 for 2 enhancements, idx 3 for 1, idx 5 if none | ||
1005 | 125 | workarea_pics[0] = g_gr->images().get("pics/workarea123.png"); | ||
1006 | 126 | workarea_pics[1] = g_gr->images().get("pics/workarea23.png"); | ||
1007 | 127 | workarea_pics[2] = g_gr->images().get("pics/workarea3.png"); | ||
1008 | 128 | workarea_pics[3] = g_gr->images().get("pics/workarea12.png"); | ||
1009 | 129 | workarea_pics[4] = g_gr->images().get("pics/workarea2.png"); | ||
1010 | 130 | workarea_pics[5] = g_gr->images().get("pics/workarea1.png"); | ||
1011 | 131 | |||
1012 | 122 | m_label_speed.set_visible(false); | 132 | m_label_speed.set_visible(false); |
1013 | 123 | m_label_speed_shadow.set_visible(false); | 133 | m_label_speed_shadow.set_visible(false); |
1014 | 124 | 134 | ||
1015 | @@ -229,6 +239,60 @@ | |||
1016 | 229 | egbase().map().overlay_manager().show_buildhelp(t); | 239 | egbase().map().overlay_manager().show_buildhelp(t); |
1017 | 230 | } | 240 | } |
1018 | 231 | 241 | ||
1019 | 242 | // Show the given workareas at the given coords and returns the overlay job id associated | ||
1020 | 243 | Overlay_Manager::Job_Id Interactive_Base::show_work_area | ||
1021 | 244 | (const Workarea_Info & workarea_info, Widelands::Coords coords) | ||
1022 | 245 | { | ||
1023 | 246 | uint8_t workareas_nrs = workarea_info.size(); | ||
1024 | 247 | Workarea_Info::size_type wa_index; | ||
1025 | 248 | switch (workareas_nrs) { | ||
1026 | 249 | case 0: return Overlay_Manager::Job_Id::Null(); break; // no workarea | ||
1027 | 250 | case 1: wa_index = 5; break; | ||
1028 | 251 | case 2: wa_index = 3; break; | ||
1029 | 252 | case 3: wa_index = 0; break; | ||
1030 | 253 | default: assert(false); break; | ||
1031 | 254 | } | ||
1032 | 255 | Widelands::Map & map = m_egbase.map(); | ||
1033 | 256 | Overlay_Manager & overlay_manager = map.overlay_manager(); | ||
1034 | 257 | Overlay_Manager::Job_Id job_id = overlay_manager.get_a_job_id(); | ||
1035 | 258 | |||
1036 | 259 | Widelands::HollowArea<> hollow_area(Widelands::Area<>(coords, 0), 0); | ||
1037 | 260 | |||
1038 | 261 | // Iterate through the work areas, from building to its enhancement | ||
1039 | 262 | Workarea_Info::const_iterator it = workarea_info.begin(); | ||
1040 | 263 | for (; it != workarea_info.end(); ++it) { | ||
1041 | 264 | assert(wa_index < NUMBER_OF_WORKAREA_PICS); | ||
1042 | 265 | hollow_area.radius = it->first; | ||
1043 | 266 | Widelands::MapHollowRegion<> mr(map, hollow_area); | ||
1044 | 267 | do | ||
1045 | 268 | overlay_manager.register_overlay | ||
1046 | 269 | (mr.location(), | ||
1047 | 270 | workarea_pics[wa_index], | ||
1048 | 271 | 0, | ||
1049 | 272 | Point::invalid(), | ||
1050 | 273 | job_id); | ||
1051 | 274 | while (mr.advance(map)); | ||
1052 | 275 | wa_index++; | ||
1053 | 276 | hollow_area.hole_radius = hollow_area.radius; | ||
1054 | 277 | } | ||
1055 | 278 | return job_id; | ||
1056 | 279 | #if 0 | ||
1057 | 280 | // This is debug output. | ||
1058 | 281 | // Improvement suggestion: add to sign explanation window instead. | ||
1059 | 282 | container_iterate_const(Workarea_Info, workarea_info, i) { | ||
1060 | 283 | log("Radius: %i\n", i.current->first); | ||
1061 | 284 | container_iterate_const(std::set<std::string>, i.current->second, j) | ||
1062 | 285 | log(" %s\n", j.current->c_str()); | ||
1063 | 286 | } | ||
1064 | 287 | #endif | ||
1065 | 288 | } | ||
1066 | 289 | |||
1067 | 290 | void Interactive_Base::hide_work_area(Overlay_Manager::Job_Id job_id) { | ||
1068 | 291 | Widelands::Map & map = m_egbase.map(); | ||
1069 | 292 | Overlay_Manager & overlay_manager = map.overlay_manager(); | ||
1070 | 293 | overlay_manager.remove_overlay(job_id); | ||
1071 | 294 | } | ||
1072 | 295 | |||
1073 | 232 | 296 | ||
1074 | 233 | /** | 297 | /** |
1075 | 234 | * Called by \ref Game::postload at the end of the game loading | 298 | * Called by \ref Game::postload at the end of the game loading |
1076 | 235 | 299 | ||
1077 | === modified file 'src/wui/interactive_base.h' | |||
1078 | --- src/wui/interactive_base.h 2013-02-10 19:36:24 +0000 | |||
1079 | +++ src/wui/interactive_base.h 2013-07-16 17:39:34 +0000 | |||
1080 | @@ -60,6 +60,8 @@ | |||
1081 | 60 | virtual void reference_player_tribe(Widelands::Player_Number, const void * const) {} | 60 | virtual void reference_player_tribe(Widelands::Player_Number, const void * const) {} |
1082 | 61 | 61 | ||
1083 | 62 | bool m_show_workarea_preview; | 62 | bool m_show_workarea_preview; |
1084 | 63 | Overlay_Manager::Job_Id show_work_area(const Workarea_Info & workarea_info, Widelands::Coords coords); | ||
1085 | 64 | void hide_work_area(Overlay_Manager::Job_Id job_id); | ||
1086 | 63 | 65 | ||
1087 | 64 | // point of view for drawing | 66 | // point of view for drawing |
1088 | 65 | virtual Widelands::Player * get_player() const throw () = 0; | 67 | virtual Widelands::Player * get_player() const throw () = 0; |
1089 | @@ -151,6 +153,7 @@ | |||
1090 | 151 | Overlay_Manager::Job_Id m_road_buildhelp_overlay_jobid; | 153 | Overlay_Manager::Job_Id m_road_buildhelp_overlay_jobid; |
1091 | 152 | Widelands::CoordPath * m_buildroad; // path for the new road | 154 | Widelands::CoordPath * m_buildroad; // path for the new road |
1092 | 153 | Widelands::Player_Number m_road_build_player; | 155 | Widelands::Player_Number m_road_build_player; |
1093 | 156 | const Image* workarea_pics[NUMBER_OF_WORKAREA_PICS]; | ||
1094 | 154 | 157 | ||
1095 | 155 | protected: | 158 | protected: |
1096 | 156 | void toggle_minimap(); | 159 | void toggle_minimap(); |
1097 | 157 | 160 | ||
1098 | === modified file 'src/wui/interactive_player.cc' | |||
1099 | --- src/wui/interactive_player.cc 2013-02-21 19:02:21 +0000 | |||
1100 | +++ src/wui/interactive_player.cc 2013-07-16 17:39:34 +0000 | |||
1101 | @@ -85,7 +85,8 @@ | |||
1102 | 85 | : | 85 | : |
1103 | 86 | Interactive_GameBase (_game, global_s), | 86 | Interactive_GameBase (_game, global_s), |
1104 | 87 | m_auto_roadbuild_mode(global_s.get_bool("auto_roadbuild_mode", true)), | 87 | m_auto_roadbuild_mode(global_s.get_bool("auto_roadbuild_mode", true)), |
1106 | 88 | m_flag_to_connect(Widelands::Coords::Null()), | 88 | m_flag_to_connect(Widelands::Coords::Null()), |
1107 | 89 | m_multiplayer(multiplayer), | ||
1108 | 89 | 90 | ||
1109 | 90 | // Chat is different, as m_chatProvider needs to be checked when toggling | 91 | // Chat is different, as m_chatProvider needs to be checked when toggling |
1110 | 91 | // Buildhelp is different as it does not toggle a UniqueWindow | 92 | // Buildhelp is different as it does not toggle a UniqueWindow |
1111 | @@ -152,16 +153,16 @@ | |||
1112 | 152 | m_toolbar.add(&m_toggle_statistics_menu, UI::Box::AlignLeft); | 153 | m_toolbar.add(&m_toggle_statistics_menu, UI::Box::AlignLeft); |
1113 | 153 | m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft); | 154 | m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft); |
1114 | 154 | m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft); | 155 | m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft); |
1115 | 156 | // Limit chat width to half the screen, to limit the damage lamers can do | ||
1116 | 157 | // by flooding chat messages | ||
1117 | 158 | m_chatOverlay = | ||
1118 | 159 | new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25); | ||
1119 | 155 | if (multiplayer) { | 160 | if (multiplayer) { |
1120 | 156 | m_toolbar.add(&m_toggle_chat, UI::Box::AlignLeft); | 161 | m_toolbar.add(&m_toggle_chat, UI::Box::AlignLeft); |
1121 | 157 | // Limit chat width to half the screen, to limit the damage lamers can do | ||
1122 | 158 | // by flooding chat messages | ||
1123 | 159 | m_chatOverlay = | ||
1124 | 160 | new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25); | ||
1125 | 161 | m_toggle_chat.set_visible(false); | 162 | m_toggle_chat.set_visible(false); |
1126 | 162 | m_toggle_chat.set_enabled(false); | 163 | m_toggle_chat.set_enabled(false); |
1129 | 163 | } else | 164 | } |
1130 | 164 | m_toggle_chat.set_visible(false); | 165 | |
1131 | 165 | m_toolbar.add(&m_toggle_help, UI::Box::AlignLeft); | 166 | m_toolbar.add(&m_toggle_help, UI::Box::AlignLeft); |
1132 | 166 | if (not scenario) | 167 | if (not scenario) |
1133 | 167 | m_toggle_objectives.set_visible(false); | 168 | m_toggle_objectives.set_visible(false); |
1134 | @@ -283,8 +284,10 @@ | |||
1135 | 283 | m_flag_to_connect = Widelands::Coords::Null(); | 284 | m_flag_to_connect = Widelands::Coords::Null(); |
1136 | 284 | } | 285 | } |
1137 | 285 | } | 286 | } |
1140 | 286 | m_toggle_chat.set_visible(m_chatenabled); | 287 | if (m_multiplayer) { |
1141 | 287 | m_toggle_chat.set_enabled(m_chatenabled); | 288 | m_toggle_chat.set_visible(m_chatenabled); |
1142 | 289 | m_toggle_chat.set_enabled(m_chatenabled); | ||
1143 | 290 | } | ||
1144 | 288 | { | 291 | { |
1145 | 289 | char buffer[128]; | 292 | char buffer[128]; |
1146 | 290 | char const * msg_icon = "pics/menu_toggle_oldmessage_menu.png"; | 293 | char const * msg_icon = "pics/menu_toggle_oldmessage_menu.png"; |
1147 | @@ -452,7 +455,7 @@ | |||
1148 | 452 | 455 | ||
1149 | 453 | case SDLK_KP_ENTER: | 456 | case SDLK_KP_ENTER: |
1150 | 454 | case SDLK_RETURN: | 457 | case SDLK_RETURN: |
1152 | 455 | if (!m_chatProvider | !m_chatenabled) | 458 | if (!m_chatProvider | !m_chatenabled || !m_multiplayer) |
1153 | 456 | break; | 459 | break; |
1154 | 457 | 460 | ||
1155 | 458 | if (!m_chat.window) | 461 | if (!m_chat.window) |
1156 | 459 | 462 | ||
1157 | === modified file 'src/wui/interactive_player.h' | |||
1158 | --- src/wui/interactive_player.h 2013-02-10 19:36:24 +0000 | |||
1159 | +++ src/wui/interactive_player.h 2013-07-16 17:39:34 +0000 | |||
1160 | @@ -88,12 +88,15 @@ | |||
1161 | 88 | 88 | ||
1162 | 89 | void popup_message(Widelands::Message_Id, const Widelands::Message &); | 89 | void popup_message(Widelands::Message_Id, const Widelands::Message &); |
1163 | 90 | 90 | ||
1164 | 91 | bool is_multiplayer() {return m_multiplayer;} | ||
1165 | 92 | |||
1166 | 91 | private: | 93 | private: |
1167 | 92 | void cmdSwitchPlayer(const std::vector<std::string> & args); | 94 | void cmdSwitchPlayer(const std::vector<std::string> & args); |
1168 | 93 | 95 | ||
1169 | 94 | Widelands::Player_Number m_player_number; | 96 | Widelands::Player_Number m_player_number; |
1170 | 95 | bool m_auto_roadbuild_mode; | 97 | bool m_auto_roadbuild_mode; |
1171 | 96 | Widelands::Coords m_flag_to_connect; | 98 | Widelands::Coords m_flag_to_connect; |
1172 | 99 | bool m_multiplayer; | ||
1173 | 97 | 100 | ||
1174 | 98 | UI::Button m_toggle_chat; | 101 | UI::Button m_toggle_chat; |
1175 | 99 | UI::Button m_toggle_options_menu; | 102 | UI::Button m_toggle_options_menu; |
1176 | 100 | 103 | ||
1177 | === modified file 'src/wui/productionsitewindow.cc' | |||
1178 | --- src/wui/productionsitewindow.cc 2013-02-10 19:36:24 +0000 | |||
1179 | +++ src/wui/productionsitewindow.cc 2013-07-16 17:39:34 +0000 | |||
1180 | @@ -105,13 +105,41 @@ | |||
1181 | 105 | worker_box, | 105 | worker_box, |
1182 | 106 | productionsite().descr().nr_working_positions() > 1 ? | 106 | productionsite().descr().nr_working_positions() > 1 ? |
1183 | 107 | _("Workers") : _("Worker")); | 107 | _("Workers") : _("Worker")); |
1184 | 108 | update_worker_table(); | ||
1185 | 108 | } | 109 | } |
1186 | 109 | } | 110 | } |
1187 | 110 | 111 | ||
1188 | 111 | void ProductionSite_Window::think() | 112 | void ProductionSite_Window::think() |
1189 | 112 | { | 113 | { |
1190 | 113 | Building_Window::think(); | 114 | Building_Window::think(); |
1192 | 114 | 115 | // If we have pending requests, update table as the worker might be coming | |
1193 | 116 | for | ||
1194 | 117 | (unsigned int i = 0; | ||
1195 | 118 | i < productionsite().descr().nr_working_positions(); ++i) | ||
1196 | 119 | { | ||
1197 | 120 | if (productionsite().working_positions()[i].worker_request) { | ||
1198 | 121 | update_worker_table(); | ||
1199 | 122 | break; | ||
1200 | 123 | } | ||
1201 | 124 | } | ||
1202 | 125 | } | ||
1203 | 126 | |||
1204 | 127 | /* | ||
1205 | 128 | =============== | ||
1206 | 129 | Create the production site information window. | ||
1207 | 130 | =============== | ||
1208 | 131 | */ | ||
1209 | 132 | void ProductionSite::create_options_window | ||
1210 | 133 | (Interactive_GameBase & parent, UI::Window * & registry) | ||
1211 | 134 | { | ||
1212 | 135 | ProductionSite_Window* win = new ProductionSite_Window(parent, *this, registry); | ||
1213 | 136 | options_window_connections.push_back | ||
1214 | 137 | (workers_changed.connect(boost::bind | ||
1215 | 138 | (&ProductionSite_Window::update_worker_table, boost::ref(*win)))); | ||
1216 | 139 | } | ||
1217 | 140 | |||
1218 | 141 | void ProductionSite_Window::update_worker_table() | ||
1219 | 142 | { | ||
1220 | 115 | if (m_worker_table) { | 143 | if (m_worker_table) { |
1221 | 116 | assert | 144 | assert |
1222 | 117 | (productionsite().descr().nr_working_positions() == | 145 | (productionsite().descr().nr_working_positions() == |
1223 | @@ -155,7 +183,7 @@ | |||
1224 | 155 | er.set_string(1, "---"); | 183 | er.set_string(1, "---"); |
1225 | 156 | er.set_string(2, "---"); | 184 | er.set_string(2, "---"); |
1226 | 157 | } | 185 | } |
1228 | 158 | } else { | 186 | } else if (request) { |
1229 | 159 | const Widelands::Worker_Descr * desc = | 187 | const Widelands::Worker_Descr * desc = |
1230 | 160 | productionsite().tribe().get_worker_descr(request->get_index()); | 188 | productionsite().tribe().get_worker_descr(request->get_index()); |
1231 | 161 | er.set_picture | 189 | er.set_picture |
1232 | @@ -164,20 +192,13 @@ | |||
1233 | 164 | 192 | ||
1234 | 165 | er.set_string(1, ""); | 193 | er.set_string(1, ""); |
1235 | 166 | er.set_string(2, ""); | 194 | er.set_string(2, ""); |
1236 | 195 | } else { | ||
1237 | 196 | // Occurs during cleanup | ||
1238 | 197 | return; | ||
1239 | 167 | } | 198 | } |
1240 | 168 | } | 199 | } |
1241 | 169 | } | 200 | } |
1253 | 170 | } | 201 | m_worker_table->update(); |
1243 | 171 | |||
1244 | 172 | /* | ||
1245 | 173 | =============== | ||
1246 | 174 | Create the production site information window. | ||
1247 | 175 | =============== | ||
1248 | 176 | */ | ||
1249 | 177 | void ProductionSite::create_options_window | ||
1250 | 178 | (Interactive_GameBase & parent, UI::Window * & registry) | ||
1251 | 179 | { | ||
1252 | 180 | new ProductionSite_Window(parent, *this, registry); | ||
1254 | 181 | } | 202 | } |
1255 | 182 | 203 | ||
1256 | 183 | void ProductionSite_Window::evict_worker() { | 204 | void ProductionSite_Window::evict_worker() { |
1257 | 184 | 205 | ||
1258 | === modified file 'src/wui/productionsitewindow.h' | |||
1259 | --- src/wui/productionsitewindow.h 2013-02-02 14:42:48 +0000 | |||
1260 | +++ src/wui/productionsitewindow.h 2013-07-16 17:39:34 +0000 | |||
1261 | @@ -33,7 +33,7 @@ | |||
1262 | 33 | Widelands::ProductionSite & productionsite() { | 33 | Widelands::ProductionSite & productionsite() { |
1263 | 34 | return ref_cast<Widelands::ProductionSite, Widelands::Building>(building()); | 34 | return ref_cast<Widelands::ProductionSite, Widelands::Building>(building()); |
1264 | 35 | } | 35 | } |
1266 | 36 | 36 | void update_worker_table(); | |
1267 | 37 | protected: | 37 | protected: |
1268 | 38 | virtual void think(); | 38 | virtual void think(); |
1269 | 39 | void evict_worker(); | 39 | void evict_worker(); |
No complaints from my site. Merged!