Merge lp:~widelands-dev/widelands/ui_improvments into lp:widelands

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
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+175090@code.launchpad.net

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.
Revision history for this message
SirVer (sirver) wrote :

No complaints from my site. Merged!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'pics/workarea12.png'
0Binary files pics/workarea12.png 1970-01-01 00:00:00 +0000 and pics/workarea12.png 2013-07-16 17:39:34 +0000 differ0Binary files pics/workarea12.png 1970-01-01 00:00:00 +0000 and pics/workarea12.png 2013-07-16 17:39:34 +0000 differ
=== added file 'pics/workarea123.png'
1Binary files pics/workarea123.png 1970-01-01 00:00:00 +0000 and pics/workarea123.png 2013-07-16 17:39:34 +0000 differ1Binary files pics/workarea123.png 1970-01-01 00:00:00 +0000 and pics/workarea123.png 2013-07-16 17:39:34 +0000 differ
=== removed file 'pics/workarea1cumulative.png'
2Binary files pics/workarea1cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea1cumulative.png 1970-01-01 00:00:00 +0000 differ2Binary files pics/workarea1cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea1cumulative.png 1970-01-01 00:00:00 +0000 differ
=== added file 'pics/workarea23.png'
3Binary files pics/workarea23.png 1970-01-01 00:00:00 +0000 and pics/workarea23.png 2013-07-16 17:39:34 +0000 differ3Binary files pics/workarea23.png 1970-01-01 00:00:00 +0000 and pics/workarea23.png 2013-07-16 17:39:34 +0000 differ
=== removed file 'pics/workarea2cumulative.png'
4Binary files pics/workarea2cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea2cumulative.png 1970-01-01 00:00:00 +0000 differ4Binary files pics/workarea2cumulative.png 2005-12-29 01:10:07 +0000 and pics/workarea2cumulative.png 1970-01-01 00:00:00 +0000 differ
=== removed file 'pics/workarea3cumulative.png'
5Binary files pics/workarea3cumulative.png 2009-11-09 19:01:11 +0000 and pics/workarea3cumulative.png 1970-01-01 00:00:00 +0000 differ5Binary files pics/workarea3cumulative.png 2009-11-09 19:01:11 +0000 and pics/workarea3cumulative.png 1970-01-01 00:00:00 +0000 differ
=== modified file 'src/chat.h'
--- src/chat.h 2013-02-10 19:36:24 +0000
+++ src/chat.h 2013-07-16 17:39:34 +0000
@@ -106,6 +106,12 @@
106 virtual void send(const std::string &) = 0;106 virtual void send(const std::string &) = 0;
107107
108 /**108 /**
109 * Sends the given message to the local player only
110 * This may be used to display useful log messages.
111 */
112 virtual void send_local(const std::string &) = 0;
113
114 /**
109 * \return a (chronological) list of received chat messages.115 * \return a (chronological) list of received chat messages.
110 * This list need not be stable or monotonic. In other words,116 * This list need not be stable or monotonic. In other words,
111 * subsequent calls to this functions may return a smaller or117 * subsequent calls to this functions may return a smaller or
112118
=== modified file 'src/constants.h'
--- src/constants.h 2013-07-13 14:32:49 +0000
+++ src/constants.h 2013-07-16 17:39:34 +0000
@@ -131,7 +131,7 @@
131 * C++ is really bad at integer types. For example this constant is not131 * C++ is really bad at integer types. For example this constant is not
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.
133 */133 */
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)
135135
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.
137/// These are all surfaces that are not loaded from disk.137/// These are all surfaces that are not loaded from disk.
138138
=== modified file 'src/debugconsole.cc'
--- src/debugconsole.cc 2013-02-10 19:36:24 +0000
+++ src/debugconsole.cc 2013-07-16 17:39:34 +0000
@@ -85,6 +85,10 @@
85 it->second(arg);85 it->second(arg);
86 }86 }
8787
88 void send_local(const std::string& msg) {
89 send(msg);
90 }
91
88 const std::vector<ChatMessage> & getMessages() const92 const std::vector<ChatMessage> & getMessages() const
89 {93 {
90 return messages;94 return messages;
9195
=== modified file 'src/gamecontroller.cc'
--- src/gamecontroller.cc 2012-02-15 21:25:34 +0000
+++ src/gamecontroller.cc 2013-07-16 17:39:34 +0000
@@ -25,8 +25,10 @@
25#include "logic/playercommand.h"25#include "logic/playercommand.h"
26#include "profile/profile.h"26#include "profile/profile.h"
27#include "wlapplication.h"27#include "wlapplication.h"
28#include "chat.h"
29#include "wui/interactive_player.h"
2830
29struct SinglePlayerGameController : public GameController {31struct SinglePlayerGameController : public GameController, public ChatProvider {
30 SinglePlayerGameController32 SinglePlayerGameController
31 (Widelands::Game &, bool useai, Widelands::Player_Number local);33 (Widelands::Game &, bool useai, Widelands::Player_Number local);
32 ~SinglePlayerGameController();34 ~SinglePlayerGameController();
@@ -42,6 +44,10 @@
42 bool isPaused();44 bool isPaused();
43 void setPaused(bool paused);45 void setPaused(bool paused);
4446
47 // Chat provider implementation
48 void send(const std::string & msg);
49 void send_local(const std::string & msg);
50 const std::vector<ChatMessage> & getMessages() const;
45private:51private:
46 Widelands::Game & m_game;52 Widelands::Game & m_game;
47 bool m_useai;53 bool m_useai;
@@ -52,13 +58,14 @@
52 uint32_t m_player_cmdserial;58 uint32_t m_player_cmdserial;
53 Widelands::Player_Number m_local;59 Widelands::Player_Number m_local;
54 std::vector<Computer_Player *> m_computerplayers;60 std::vector<Computer_Player *> m_computerplayers;
61 std::vector<ChatMessage> m_chatmessages;
55};62};
5663
57SinglePlayerGameController::SinglePlayerGameController64SinglePlayerGameController::SinglePlayerGameController
58 (Widelands::Game & game,65 (Widelands::Game & game,
59 bool const useai,66 bool const useai,
60 Widelands::Player_Number const local)67 Widelands::Player_Number const local)
61 :68 : ChatProvider(),
62 m_game (game),69 m_game (game),
63 m_useai (useai),70 m_useai (useai),
64 m_lastframe (WLApplication::get()->get_time()),71 m_lastframe (WLApplication::get()->get_time()),
@@ -156,10 +163,31 @@
156 m_paused = paused;163 m_paused = paused;
157}164}
158165
166void SinglePlayerGameController::send_local(const std::string& msg)
167{
168 ChatMessage c;
169 c.msg = msg;
170 c.time = time(0);
171 m_chatmessages.push_back(c);
172 ChatProvider::send(c);
173}
174
175void SinglePlayerGameController::send(const std::string& msg)
176{
177 log("SinglePlayerGameController:: Cannot send chat messages in single player game!");
178}
179
180const std::vector< ChatMessage >& SinglePlayerGameController::getMessages() const
181{
182 return m_chatmessages;
183}
184
159GameController * GameController::createSinglePlayer185GameController * GameController::createSinglePlayer
160 (Widelands::Game & game,186 (Widelands::Game & game,
161 bool const cpls,187 bool const cpls,
162 Widelands::Player_Number const local)188 Widelands::Player_Number const local)
163{189{
164 return new SinglePlayerGameController(game, cpls, local);190 SinglePlayerGameController* spgc = new SinglePlayerGameController(game, cpls, local);
191 game.get_ipl()->set_chat_provider(*spgc);
192 return spgc;
165}193}
166194
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2013-07-14 10:38:26 +0000
+++ src/logic/building.cc 2013-07-16 17:39:34 +0000
@@ -19,6 +19,7 @@
1919
20#include <cstdio>20#include <cstdio>
21#include <sstream>21#include <sstream>
22#include <boost/foreach.hpp>
2223
23#include "upcast.h"24#include "upcast.h"
24#include "wexception.h"25#include "wexception.h"
@@ -436,6 +437,9 @@
436 }437 }
437438
438 PlayerImmovable::cleanup(egbase);439 PlayerImmovable::cleanup(egbase);
440
441 BOOST_FOREACH(boost::signals::connection& c, options_window_connections)
442 c.disconnect();
439}443}
440444
441445
@@ -855,6 +859,7 @@
855 set_seeing(true);859 set_seeing(true);
856 }860 }
857 PlayerImmovable::add_worker(worker);861 PlayerImmovable::add_worker(worker);
862 workers_changed();
858}863}
859864
860865
@@ -862,6 +867,7 @@
862 PlayerImmovable::remove_worker(worker);867 PlayerImmovable::remove_worker(worker);
863 if (not get_workers().size())868 if (not get_workers().size())
864 set_seeing(false);869 set_seeing(false);
870 workers_changed();
865}871}
866872
867/**873/**
868874
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2013-07-14 10:38:26 +0000
+++ src/logic/building.h 2013-07-16 17:39:34 +0000
@@ -34,6 +34,7 @@
34#include <string>34#include <string>
35#include <cstring>35#include <cstring>
36#include <vector>36#include <vector>
37#include <boost/signal.hpp>
3738
38namespace UI {class Window;}39namespace UI {class Window;}
39struct BuildingHints;40struct BuildingHints;
@@ -223,6 +224,7 @@
223224
224 void add_worker(Worker &);225 void add_worker(Worker &);
225 void remove_worker(Worker &);226 void remove_worker(Worker &);
227 mutable boost::signal<void ()> workers_changed;
226228
227 void send_message229 void send_message
228 (Game & game,230 (Game & game,
@@ -268,6 +270,9 @@
268270
269 /// Whether we see our vision_range area based on workers in the building271 /// Whether we see our vision_range area based on workers in the building
270 bool m_seeing;272 bool m_seeing;
273
274 // Signals connected for the option window
275 std::vector<boost::signals::connection> options_window_connections;
271};276};
272277
273}278}
274279
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2013-04-27 16:55:46 +0000
+++ src/logic/production_program.cc 2013-07-16 17:39:34 +0000
@@ -1288,7 +1288,7 @@
1288 snprintf1288 snprintf
1289 (ps.m_result_buffer, sizeof(ps.m_result_buffer),1289 (ps.m_result_buffer, sizeof(ps.m_result_buffer),
1290 _("No soldier for this training level found!"));1290 _("No soldier for this training level found!"));
1291 return ps.program_end(game, Failed);1291 return ps.program_end(game, Skipped);
1292 }1292 }
1293 if (attribute == atrHP) {1293 if (attribute == atrHP) {
1294 if ((*it)->get_hp_level() == level)1294 if ((*it)->get_hp_level() == level)
@@ -1378,7 +1378,7 @@
1378 snprintf1378 snprintf
1379 (ps.m_result_buffer, sizeof(ps.m_result_buffer),1379 (ps.m_result_buffer, sizeof(ps.m_result_buffer),
1380 _("No soldier for this training level found!"));1380 _("No soldier for this training level found!"));
1381 return ps.program_end(game, Failed);1381 return ps.program_end(game, Skipped);
1382 }1382 }
1383 if (attribute == atrHP) {1383 if (attribute == atrHP) {
1384 if ((*it)->get_hp_level () == level)1384 if ((*it)->get_hp_level () == level)
13851385
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2013-05-25 09:30:35 +0000
+++ src/logic/productionsite.cc 2013-07-16 17:39:34 +0000
@@ -457,7 +457,6 @@
457457
458 if (upcast(Game, game, &egbase))458 if (upcast(Game, game, &egbase))
459 try_start_working(*game);459 try_start_working(*game);
460
461 return 0;460 return 0;
462}461}
463462
@@ -874,6 +873,7 @@
874 for (uint32_t i = descr().nr_working_positions(); i;)873 for (uint32_t i = descr().nr_working_positions(); i;)
875 m_working_positions[--i].worker->gain_experience(game);874 m_working_positions[--i].worker->gain_experience(game);
876 m_result_buffer[0] = '\0';875 m_result_buffer[0] = '\0';
876 Building::workers_changed();
877 }877 }
878 calc_statistics();878 calc_statistics();
879 break;879 break;
880880
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2013-06-16 16:29:48 +0000
+++ src/logic/trainingsite.cc 2013-07-16 17:39:34 +0000
@@ -192,12 +192,7 @@
192 */192 */
193std::string TrainingSite::get_statistics_string()193std::string TrainingSite::get_statistics_string()
194{194{
195 if (State * const state = get_state())195 return ProductionSite::get_statistics_string();
196 return state->program->descname();
197 else if (m_result == Completed)
198 return _("Resting");
199 else
200 return _("Not Working");
201}196}
202197
203/**198/**
204199
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc 2013-04-20 20:20:34 +0000
+++ src/network/internet_gaming.cc 2013-07-16 17:39:34 +0000
@@ -768,7 +768,14 @@
768 s.send(m_sock);768 s.send(m_sock);
769}769}
770770
771771void InternetGaming::send_local(const std::string& msg)
772{
773 ChatMessage c;
774 c.msg = msg;
775 c.time = time(0);
776 messages.push_back(c);
777 ChatProvider::send(c);
778}
772779
773/**780/**
774 * \returns the boolean value of a string received from the metaserver.781 * \returns the boolean value of a string received from the metaserver.
775782
=== modified file 'src/network/internet_gaming.h'
--- src/network/internet_gaming.h 2013-02-10 19:36:24 +0000
+++ src/network/internet_gaming.h 2013-07-16 17:39:34 +0000
@@ -114,6 +114,9 @@
114 // ChatProvider: sends a message via the metaserver.114 // ChatProvider: sends a message via the metaserver.
115 void send(const std::string &);115 void send(const std::string &);
116116
117 // ChatProvider: sends local messages
118 void send_local(const std::string &);
119
117 /// ChatProvider: adds the message to the message list and calls parent.120 /// ChatProvider: adds the message to the message list and calls parent.
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);}
119122
120123
=== modified file 'src/network/netclient.cc'
--- src/network/netclient.cc 2013-04-22 20:15:00 +0000
+++ src/network/netclient.cc 2013-07-16 17:39:34 +0000
@@ -628,6 +628,15 @@
628 s.send(d->sock);628 s.send(d->sock);
629}629}
630630
631void NetClient::send_local(const std::string& msg)
632{
633 ChatMessage c;
634 c.msg = msg;
635 c.time = time(0);
636 d->chatmessages.push_back(c);
637 ChatProvider::send(c);
638}
639
631const std::vector<ChatMessage> & NetClient::getMessages() const640const std::vector<ChatMessage> & NetClient::getMessages() const
632{641{
633 return d->chatmessages;642 return d->chatmessages;
634643
=== modified file 'src/network/netclient.h'
--- src/network/netclient.h 2013-02-10 19:36:24 +0000
+++ src/network/netclient.h 2013-07-16 17:39:34 +0000
@@ -92,6 +92,7 @@
9292
93 // ChatProvider interface93 // ChatProvider interface
94 void send(const std::string & msg);94 void send(const std::string & msg);
95 void send_local(const std::string & msg);
95 const std::vector<ChatMessage> & getMessages() const;96 const std::vector<ChatMessage> & getMessages() const;
9697
97private:98private:
9899
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2013-07-15 05:18:12 +0000
+++ src/network/nethost.cc 2013-07-16 17:39:34 +0000
@@ -498,6 +498,13 @@
498 h->send(c);498 h->send(c);
499 }499 }
500500
501 void send_local(const std::string & msg) {
502 ChatMessage c;
503 c.time = time(0);
504 c.msg = msg;
505 ChatProvider::send(c);
506 }
507
501 const std::vector<ChatMessage> & getMessages() const {508 const std::vector<ChatMessage> & getMessages() const {
502 return messages;509 return messages;
503 }510 }
504511
=== modified file 'src/save_handler.cc'
--- src/save_handler.cc 2013-07-14 11:48:13 +0000
+++ src/save_handler.cc 2013-07-16 17:39:34 +0000
@@ -25,6 +25,8 @@
25#include "io/filesystem/filesystem.h"25#include "io/filesystem/filesystem.h"
26#include "game_io/game_saver.h"26#include "game_io/game_saver.h"
27#include "profile/profile.h"27#include "profile/profile.h"
28#include "wui/interactive_player.h"
29#include "chat.h"
2830
29#include "log.h"31#include "log.h"
3032
@@ -51,7 +53,10 @@
51 if (elapsed < autosaveInterval)53 if (elapsed < autosaveInterval)
52 return;54 return;
5355
54 log("Autosave: interval elapsed (%d s), saving\n", elapsed);56 // TODO: defer saving to next tick so that this message is shown
57 // before the actual save, or put the saving logic in another thread
58 game.get_ipl()->get_chat_provider()->send_local
59 (_("Saving game..."));
5560
56 // save the game61 // save the game
57 std::string complete_filename =62 std::string complete_filename =
@@ -70,6 +75,8 @@
70 static std::string error;75 static std::string error;
71 if (!save_game(game, complete_filename, &error)) {76 if (!save_game(game, complete_filename, &error)) {
72 log("Autosave: ERROR! - %s\n", error.c_str());77 log("Autosave: ERROR! - %s\n", error.c_str());
78 game.get_ipl()->get_chat_provider()->send_local
79 (_("Saving failed!"));
7380
74 // if backup file was created, move it back81 // if backup file was created, move it back
75 if (backup_filename.length() > 0) {82 if (backup_filename.length() > 0) {
@@ -88,6 +95,8 @@
88 }95 }
8996
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);
98 game.get_ipl()->get_chat_provider()->send_local
99 (_("Game saved"));
91}100}
92101
93/**102/**
@@ -98,7 +107,6 @@
98 return;107 return;
99108
100 m_last_saved_time = currenttime;109 m_last_saved_time = currenttime;
101 log("Autosave: initialized\n");
102 m_initialized = true;110 m_initialized = true;
103}111}
104112
105113
=== modified file 'src/timestring.cc'
--- src/timestring.cc 2013-03-21 10:45:51 +0000
+++ src/timestring.cc 2013-07-16 17:39:34 +0000
@@ -75,3 +75,18 @@
75 }75 }
76 return timestring_buffer;76 return timestring_buffer;
77}77}
78
79char gamestringbuffer[] = "000:00:00";
80char * gametimestring(uint32_t gametime)
81{
82 uint32_t time = gametime / 1000;
83 gamestringbuffer[8] = '0' + time % 10;
84 gamestringbuffer[7] = '0' + (time /= 10) % 6;
85 gamestringbuffer[5] = '0' + (time /= 6) % 10;
86 gamestringbuffer[4] = '0' + (time /= 10) % 6;
87 gamestringbuffer[2] = '0' + (time /= 6) % 10;
88 gamestringbuffer[1] = '0' + (time /= 10) % 10;
89 gamestringbuffer[0] = '0' + (time /= 10);
90 return gamestringbuffer;
91}
92
7893
=== modified file 'src/timestring.h'
--- src/timestring.h 2012-02-15 21:25:34 +0000
+++ src/timestring.h 2013-07-16 17:39:34 +0000
@@ -21,3 +21,8 @@
21/// seconds since the Epoch). The return value points to a statically allocated21/// seconds since the Epoch). The return value points to a statically allocated
22/// string which might be overwritten by subsequent calls.22/// string which might be overwritten by subsequent calls.
23char * timestring();23char * timestring();
24
25/// Get a string representation of the game time
26/// as hhh:mm:ss. If Time represents more than
27/// 999 hours, it wraps around
28char * gametimestring(uint32_t gametime);
2429
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2012-02-15 21:25:34 +0000
+++ src/ui_basic/progressbar.cc 2013-07-16 17:39:34 +0000
@@ -21,10 +21,12 @@
2121
22#include "constants.h"22#include "constants.h"
23#include "graphic/font.h"23#include "graphic/font.h"
24#include "graphic/font_handler.h"24#include "graphic/font_handler1.h"
25#include "text_layout.h"
25#include "graphic/rendertarget.h"26#include "graphic/rendertarget.h"
2627
27#include <cstdio>28#include <cstdio>
29#include <boost/format.hpp>
2830
2931
30namespace UI {32namespace UI {
@@ -103,16 +105,11 @@
103 }105 }
104106
105 // Print the state in percent107 // Print the state in percent
106 char buffer[30];108 // TODO use UI_FNT_COLOR_BRIGHT when merged
107109 uint32_t percent = static_cast<uint32_t>(fraction * 100);
108 snprintf110 const std::string progress_text =
109 (buffer, sizeof(buffer), "%u%%", static_cast<uint32_t>(fraction * 100));111 (boost::format("<font color=%1$s>%2$i%%</font>") % "ffffff" % percent).str();
110112 const Point pos(get_w() / 2, get_h() / 2);
111 UI::g_fh->draw_text113 dst.blit(pos, UI::g_fh1->render(as_uifont(progress_text)), CM_Normal, Align_Center);
112 (dst, UI::TextStyle::ui_small(),
113 Point(get_w() / 2, get_h() / 2),
114 buffer,
115 Align_Center);
116}114}
117
118}115}
119116
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2013-07-13 14:25:41 +0000
+++ src/ui_basic/table.cc 2013-07-16 17:39:34 +0000
@@ -23,11 +23,13 @@
23#include "graphic/font_handler.h"23#include "graphic/font_handler.h"
24#include "graphic/graphic.h"24#include "graphic/graphic.h"
25#include "graphic/rendertarget.h"25#include "graphic/rendertarget.h"
26#include "graphic/font_handler1.h"
2627
27#include "button.h"28#include "button.h"
28#include "mouse_constants.h"29#include "mouse_constants.h"
29#include "scrollbar.h"30#include "scrollbar.h"
30#include "wlapplication.h"31#include "wlapplication.h"
32#include "text_layout.h"
3133
32#include "container_iterate.h"34#include "container_iterate.h"
33#include <boost/bind.hpp>35#include <boost/bind.hpp>
@@ -273,21 +275,13 @@
273 const std::string & entry_string = er.get_string (i);275 const std::string & entry_string = er.get_string (i);
274 uint32_t picw = 0;276 uint32_t picw = 0;
275 uint32_t pich = 0;277 uint32_t pich = 0;
276 uint32_t stringw = 0;278
277 uint32_t stringh = g_fh->get_fontheight(m_fontname, m_fontsize);
278 if (entry_picture) {279 if (entry_picture) {
279 picw = entry_picture->width();280 picw = entry_picture->width();
280 pich = entry_picture->height();281 pich = entry_picture->height();
281 }282 }
282 Point point =283 Point point(curx, y);
283 Point(curx, y)284 if (entry_picture) {
284 +
285 Point
286 (alignment & Align_Right ? curw - (picw + stringw) - 1 :
287 alignment & Align_HCenter ? (curw - (picw + stringw)) / 2 :
288 1,
289 0);
290 if (entry_picture)
291 dst.blit285 dst.blit
292 (point +286 (point +
293 Point287 Point
@@ -296,18 +290,13 @@
296 static_cast<int32_t>(pich))290 static_cast<int32_t>(pich))
297 / 2),291 / 2),
298 entry_picture);292 entry_picture);
293 point.x += picw;
294 }
299295
300 UI::g_fh->draw_text296 const Image* entry_text_im = UI::g_fh1->render(as_uifont(entry_string, m_fontsize));
301 (dst,297 // Crop to column width
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);
303 point +299 dst.blitrect(point, entry_text_im, Rect(0, 0, curw - picw, lineheight));
304 Point
305 (picw,
306 (static_cast<int32_t>(lineheight) -
307 static_cast<int32_t>(stringh))
308 / 2),
309 entry_string,
310 alignment);
311300
312 curx += curw;301 curx += curw;
313 }302 }
314303
=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc 2013-07-15 05:18:12 +0000
+++ src/ui_fsmenu/loadgame.cc 2013-07-16 17:39:34 +0000
@@ -29,6 +29,7 @@
29#include "log.h"29#include "log.h"
30#include "logic/game.h"30#include "logic/game.h"
31#include "ui_basic/messagebox.h"31#include "ui_basic/messagebox.h"
32#include "timestring.h"
3233
33#include <cstdio>34#include <cstdio>
3435
@@ -203,15 +204,9 @@
203 m_tamapname.set_text(_(gpdp.get_mapname()));204 m_tamapname.set_text(_(gpdp.get_mapname()));
204 }205 }
205206
206 char buf[200];207 char buf[20];
207 uint32_t gametime = gpdp.get_gametime();208 uint32_t gametime = gpdp.get_gametime();
208209 m_tagametime.set_text(gametimestring(gametime));
209 int32_t hours = gametime / 3600000;
210 gametime -= hours * 3600000;
211 int32_t minutes = gametime / 60000;
212
213 sprintf(buf, "%02i:%02i", hours, minutes);
214 m_tagametime.set_text(buf);
215210
216 sprintf(buf, "%i", gpdp.get_player_nr());211 sprintf(buf, "%i", gpdp.get_player_nr());
217 m_ta_players.set_text(buf);212 m_ta_players.set_text(buf);
218213
=== modified file 'src/ui_fsmenu/loadreplay.cc'
--- src/ui_fsmenu/loadreplay.cc 2013-07-14 16:11:41 +0000
+++ src/ui_fsmenu/loadreplay.cc 2013-07-16 17:39:34 +0000
@@ -28,6 +28,7 @@
28#include "logic/game.h"28#include "logic/game.h"
29#include "logic/replay.h"29#include "logic/replay.h"
30#include "ui_basic/messagebox.h"30#include "ui_basic/messagebox.h"
31#include "timestring.h"
3132
32Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay() :33Fullscreen_Menu_LoadReplay::Fullscreen_Menu_LoadReplay() :
33 Fullscreen_Menu_Base("choosemapmenu.jpg"),34 Fullscreen_Menu_Base("choosemapmenu.jpg"),
@@ -186,15 +187,9 @@
186 m_delete.set_enabled(true);187 m_delete.set_enabled(true);
187 m_tamapname.set_text(gpdp.get_mapname());188 m_tamapname.set_text(gpdp.get_mapname());
188189
189 char buf[200];190 char buf[20];
190 uint32_t gametime = gpdp.get_gametime();191 uint32_t gametime = gpdp.get_gametime();
191192 m_tagametime.set_text(gametimestring(gametime));
192 int32_t hours = gametime / 3600000;
193 gametime -= hours * 3600000;
194 int32_t minutes = gametime / 60000;
195
196 sprintf(buf, "%02i:%02i", hours, minutes);
197 m_tagametime.set_text(buf);
198193
199 sprintf(buf, "%i", gpdp.get_player_nr());194 sprintf(buf, "%i", gpdp.get_player_nr());
200 m_ta_players.set_text(buf);195 m_ta_players.set_text(buf);
201196
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2013-06-15 14:35:17 +0000
+++ src/ui_fsmenu/mapselect.cc 2013-07-16 17:39:34 +0000
@@ -172,11 +172,11 @@
172 vbox->set_size(get_w(), 25);172 vbox->set_size(get_w(), 25);
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());
174 _add_tag_checkbox(vbox, "1v1", _("1v1"));174 _add_tag_checkbox(vbox, "1v1", _("1v1"));
175 _add_tag_checkbox(vbox, "2teams", _("2 Player Teams"));175 _add_tag_checkbox(vbox, "2teams", _("Teams of 2"));
176 _add_tag_checkbox(vbox, "3teams", _("3 Player Teams"));176 _add_tag_checkbox(vbox, "3teams", _("Teams of 3"));
177 vbox->set_size(get_w(), 25);177 vbox->set_size(get_w(), 25);
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());
179 _add_tag_checkbox(vbox, "4teams", _("4 Player Teams"));179 _add_tag_checkbox(vbox, "4teams", _("Teams of 4"));
180 _add_tag_checkbox(vbox, "ffa", _("Free for all"));180 _add_tag_checkbox(vbox, "ffa", _("Free for all"));
181 _add_tag_checkbox(vbox, "unbalanced", _("Unbalanced"));181 _add_tag_checkbox(vbox, "unbalanced", _("Unbalanced"));
182 vbox->set_size(get_w(), 25);182 vbox->set_size(get_w(), 25);
183183
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2013-07-15 05:18:12 +0000
+++ src/wlapplication.cc 2013-07-16 17:39:34 +0000
@@ -2036,9 +2036,14 @@
2036 }2036 }
2037 } else { // normal singleplayer2037 } else { // normal singleplayer
2038 uint8_t const pn = sp.settings().playernum + 1;2038 uint8_t const pn = sp.settings().playernum + 1;
2039 boost::scoped_ptr<GameController> ctrl
2040 (GameController::createSinglePlayer(game, true, pn));
2041 try {2039 try {
2040 // Game controller needs the ibase pointer to init
2041 // the chat
2042 game.set_ibase
2043 (new Interactive_Player
2044 (game, g_options.pull_section("global"), pn, false, false));
2045 boost::scoped_ptr<GameController> ctrl
2046 (GameController::createSinglePlayer(game, true, pn));
2042 UI::ProgressWindow loaderUI;2047 UI::ProgressWindow loaderUI;
2043 std::vector<std::string> tipstext;2048 std::vector<std::string> tipstext;
2044 tipstext.push_back("general_game");2049 tipstext.push_back("general_game");
@@ -2052,9 +2057,6 @@
2052 loaderUI.step(_("Preparing game"));2057 loaderUI.step(_("Preparing game"));
20532058
2054 game.set_game_controller(ctrl.get());2059 game.set_game_controller(ctrl.get());
2055 game.set_ibase
2056 (new Interactive_Player
2057 (game, g_options.pull_section("global"), pn, false, false));
2058 game.init_newgame(&loaderUI, sp.settings());2060 game.init_newgame(&loaderUI, sp.settings());
2059 game.run(&loaderUI, Widelands::Game::NewNonScenario);2061 game.run(&loaderUI, Widelands::Game::NewNonScenario);
2060 } catch (const std::exception & e) {2062 } catch (const std::exception & e) {
20612063
=== modified file 'src/wui/building_ui.cc'
--- src/wui/building_ui.cc 2013-07-09 05:53:39 +0000
+++ src/wui/building_ui.cc 2013-07-16 17:39:34 +0000
@@ -17,6 +17,8 @@
17 *17 *
18 */18 */
1919
20#include <boost/foreach.hpp>
21#include <boost/lexical_cast.hpp>
20#include "buildingwindow.h"22#include "buildingwindow.h"
21#include "logic/building.h"23#include "logic/building.h"
22#include "ui_basic/window.h"24#include "ui_basic/window.h"
@@ -30,14 +32,17 @@
30 */32 */
31void Building::show_options(Interactive_GameBase & igbase, bool avoid_fastclick)33void Building::show_options(Interactive_GameBase & igbase, bool avoid_fastclick)
32{34{
35 // Reset tooltip before opening the window
36 igbase.set_tooltip("");
33 if (m_optionswindow) {37 if (m_optionswindow) {
34 if (m_optionswindow->is_minimal())38 if (m_optionswindow->is_minimal())
35 m_optionswindow->restore();39 m_optionswindow->restore();
36 m_optionswindow->move_to_top();40 m_optionswindow->move_to_top();
37 } else {41 } else {
38 create_options_window(igbase, m_optionswindow);42 create_options_window(igbase, m_optionswindow);
39 if (upcast(Building_Window, bw, m_optionswindow))43 if (upcast(Building_Window, bw, m_optionswindow)) {
40 bw->set_avoid_fastclick(avoid_fastclick);44 bw->set_avoid_fastclick(avoid_fastclick);
45 }
41 // Run a first think here so that certain things like caps buttons46 // Run a first think here so that certain things like caps buttons
42 // get properly initialized47 // get properly initialized
43 m_optionswindow->think();48 m_optionswindow->think();
@@ -49,6 +54,8 @@
49 */54 */
50void Building::hide_options()55void Building::hide_options()
51{56{
57 BOOST_FOREACH(boost::signals::connection& c, options_window_connections)
58 c.disconnect();
52 delete m_optionswindow;59 delete m_optionswindow;
53 m_optionswindow = NULL;60 m_optionswindow = NULL;
54}61}
5562
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2013-07-13 15:58:52 +0000
+++ src/wui/buildingwindow.cc 2013-07-16 17:39:34 +0000
@@ -79,13 +79,6 @@
79 set_center_panel(vbox);79 set_center_panel(vbox);
80 set_think(true);80 set_think(true);
8181
82 char filename[] = "pics/workarea0cumulative.png";
83 compile_assert(NUMBER_OF_WORKAREA_PICS <= 9);
84 for (Workarea_Info::size_type i = 0; i < NUMBER_OF_WORKAREA_PICS; ++i) {
85 ++filename[13];
86 workarea_cumulative_pic[i] = g_gr->images().get(filename);
87 }
88
89 show_workarea();82 show_workarea();
9083
91 set_fastclick_panel(this);84 set_fastclick_panel(this);
@@ -327,7 +320,7 @@
327 (capsbuttons, "workarea",320 (capsbuttons, "workarea",
328 0, 0, 34, 34,321 0, 0, 34, 34,
329 g_gr->images().get("pics/but4.png"),322 g_gr->images().get("pics/but4.png"),
330 g_gr->images().get("pics/workarea3cumulative.png"),323 g_gr->images().get("pics/workarea123.png"),
331 _("Hide workarea"));324 _("Hide workarea"));
332 m_toggle_workarea->sigclicked.connect325 m_toggle_workarea->sigclicked.connect
333 (boost::bind(&Building_Window::toggle_workarea, boost::ref(*this)));326 (boost::bind(&Building_Window::toggle_workarea, boost::ref(*this)));
@@ -512,41 +505,11 @@
512 */505 */
513void Building_Window::show_workarea()506void Building_Window::show_workarea()
514{507{
515 if (m_workarea_job_id)508 if (m_workarea_job_id) {
516 return; // already shown, nothing to be done509 return; // already shown, nothing to be done
517510 }
518 const Workarea_Info & workarea_info = m_building.descr().m_workarea_info;511 const Workarea_Info & workarea_info = m_building.descr().m_workarea_info;
519 if (workarea_info.size() == 0)512 m_workarea_job_id = igbase().show_work_area(workarea_info, m_building.get_position());
520 return; // building has no workarea
521
522 Widelands::Map & map =
523 ref_cast<const Interactive_GameBase, UI::Panel>(*get_parent()).egbase()
524 .map();
525 Overlay_Manager & overlay_manager = map.overlay_manager();
526 m_workarea_job_id = overlay_manager.get_a_job_id();
527
528 Widelands::HollowArea<> hollow_area
529 (Widelands::Area<>(m_building.get_position(), 0), 0);
530 Workarea_Info::const_iterator it = workarea_info.begin();
531 for
532 (Workarea_Info::size_type i =
533 std::min(workarea_info.size(), NUMBER_OF_WORKAREA_PICS);
534 i;
535 ++it)
536 {
537 --i;
538 hollow_area.radius = it->first;
539 Widelands::MapHollowRegion<> mr(map, hollow_area);
540 do
541 overlay_manager.register_overlay
542 (mr.location(),
543 workarea_cumulative_pic[i],
544 0,
545 Point::invalid(),
546 m_workarea_job_id);
547 while (mr.advance(map));
548 hollow_area.hole_radius = hollow_area.radius;
549 }
550513
551 configure_workarea_button();514 configure_workarea_button();
552}515}
@@ -557,11 +520,7 @@
557void Building_Window::hide_workarea()520void Building_Window::hide_workarea()
558{521{
559 if (m_workarea_job_id) {522 if (m_workarea_job_id) {
560 Widelands::Map & map =523 igbase().hide_work_area(m_workarea_job_id);
561 ref_cast<const Interactive_GameBase, UI::Panel>(*get_parent()).egbase()
562 .map();
563 Overlay_Manager & overlay_manager = map.overlay_manager();
564 overlay_manager.remove_overlay(m_workarea_job_id);
565 m_workarea_job_id = Overlay_Manager::Job_Id::Null();524 m_workarea_job_id = Overlay_Manager::Job_Id::Null();
566525
567 configure_workarea_button();526 configure_workarea_button();
568527
=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h 2013-07-08 03:35:09 +0000
+++ src/wui/buildingwindow.h 2013-07-16 17:39:34 +0000
@@ -94,7 +94,6 @@
94 bool m_caps_setup;94 bool m_caps_setup;
9595
96 Overlay_Manager::Job_Id m_workarea_job_id;96 Overlay_Manager::Job_Id m_workarea_job_id;
97 const Image* workarea_cumulative_pic[NUMBER_OF_WORKAREA_PICS];
98 bool m_avoid_fastclick;97 bool m_avoid_fastclick;
99};98};
10099
101100
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2013-02-09 23:36:30 +0000
+++ src/wui/fieldaction.cc 2013-07-16 17:39:34 +0000
@@ -231,7 +231,6 @@
231 bool m_fastclick; // if true, put the mouse over first button in first tab231 bool m_fastclick; // if true, put the mouse over first button in first tab
232 uint32_t m_best_tab;232 uint32_t m_best_tab;
233 Overlay_Manager::Job_Id m_workarea_preview_job_id;233 Overlay_Manager::Job_Id m_workarea_preview_job_id;
234 const Image* workarea_cumulative_pic[NUMBER_OF_WORKAREA_PICS];
235234
236 /// Variables to use with attack dialog.235 /// Variables to use with attack dialog.
237 AttackBox * m_attack_box;236 AttackBox * m_attack_box;
@@ -297,13 +296,6 @@
297296
298297
299 set_center_panel(&m_tabpanel);298 set_center_panel(&m_tabpanel);
300
301 char filename[] = "pics/workarea0cumulative.png";
302 compile_assert(NUMBER_OF_WORKAREA_PICS <= 9);
303 for (Workarea_Info::size_type i = 0; i < NUMBER_OF_WORKAREA_PICS; ++i) {
304 ++filename[13];
305 workarea_cumulative_pic[i] = g_gr->images().get(filename);
306 }
307}299}
308300
309301
@@ -856,44 +848,10 @@
856 (const Widelands::Building_Index::value_t idx)848 (const Widelands::Building_Index::value_t idx)
857{849{
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) {
859 m_workarea_preview_job_id = m_overlay_manager.get_a_job_id();
860 Widelands::HollowArea<> hollow_area(Widelands::Area<>(m_node, 0), 0);
861 const Workarea_Info & workarea_info =851 const Workarea_Info & workarea_info =
862 m_plr->tribe().get_building_descr(Widelands::Building_Index(idx))852 m_plr->tribe().get_building_descr(Widelands::Building_Index(idx))
863 ->m_workarea_info;853 ->m_workarea_info;
864 Workarea_Info::const_iterator it = workarea_info.begin();854 m_workarea_preview_job_id = ibase().show_work_area(workarea_info, m_node);
865 for
866 (Workarea_Info::size_type i =
867 std::min(workarea_info.size(), NUMBER_OF_WORKAREA_PICS);
868 i;
869 ++it)
870 {
871 --i;
872 hollow_area.radius = it->first;
873 assert(hollow_area.radius);
874 assert(hollow_area.hole_radius < hollow_area.radius);
875 Widelands::MapHollowRegion<> mr(*m_map, hollow_area);
876 do
877 m_overlay_manager.register_overlay
878 (mr.location(),
879 workarea_cumulative_pic[i],
880 0,
881 Point::invalid(),
882 m_workarea_preview_job_id);
883 while (mr.advance(*m_map));
884 hollow_area.hole_radius = hollow_area.radius;
885 }
886
887#if 0
888 // This is debug output.
889 // Improvement suggestion: add to sign explanation window instead.
890 container_iterate_const(Workarea_Info, workarea_info, i) {
891 log("Radius: %i\n", i.current->first);
892 container_iterate_const(std::set<std::string>, i.current->second, j)
893 log(" %s\n", j.current->c_str());
894 }
895#endif
896
897 }855 }
898}856}
899857
900858
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2013-07-15 11:01:59 +0000
+++ src/wui/game_main_menu_save_game.cc 2013-07-16 17:39:34 +0000
@@ -28,10 +28,13 @@
28#include "game_io/game_saver.h"28#include "game_io/game_saver.h"
29#include "i18n.h"29#include "i18n.h"
30#include "interactive_gamebase.h"30#include "interactive_gamebase.h"
31#include "gamecontroller.h"
31#include "io/filesystem/filesystem.h"32#include "io/filesystem/filesystem.h"
32#include "io/filesystem/layered_filesystem.h"33#include "io/filesystem/layered_filesystem.h"
33#include "logic/game.h"34#include "logic/game.h"
34#include "profile/profile.h"35#include "profile/profile.h"
36#include "interactive_player.h"
37#include "timestring.h"
3538
36using boost::format;39using boost::format;
3740
@@ -125,6 +128,10 @@
125 }128 }
126129
127 m_editbox->focus();130 m_editbox->focus();
131 if (!parent.game().get_ipl()->is_multiplayer()) {
132 // Pause the game
133 parent.game().gameController()->setPaused(true);
134 }
128}135}
129136
130137
@@ -144,20 +151,11 @@
144 m_button_ok->set_enabled(true);151 m_button_ok->set_enabled(true);
145152
146 m_name.set_text(gpdp.get_mapname());153 m_name.set_text(gpdp.get_mapname());
154
155 uint32_t gametime = gpdp.get_gametime();
156 m_gametime.set_text(gametimestring(gametime));
157
147 char buf[200];158 char buf[200];
148 uint32_t gametime = gpdp.get_gametime();
149#define SPLIT_GAMETIME(unit, factor) \
150 uint32_t const unit = gametime / factor; gametime %= factor;
151 SPLIT_GAMETIME(days, 86400000);
152 SPLIT_GAMETIME(hours, 3600000);
153 SPLIT_GAMETIME(minutes, 60000);
154 SPLIT_GAMETIME(seconds, 1000);
155 sprintf
156 (buf,
157 _("%02ud%02uh%02u'%02u\"%03u"),
158 days, hours, minutes, seconds, gametime);
159 m_gametime.set_text(buf);
160
161 sprintf159 sprintf
162 (buf, "%i %s", gpdp.get_player_nr(),160 (buf, "%i %s", gpdp.get_player_nr(),
163 ngettext(_("player"), _("players"), gpdp.get_player_nr()));161 ngettext(_("player"), _("players"), gpdp.get_player_nr()));
@@ -293,6 +291,15 @@
293 }291 }
294}292}
295293
294void Game_Main_Menu_Save_Game::die()
295{
296 UI::UniqueWindow::die();
297 if (!igbase().game().get_ipl()->is_multiplayer()) {
298 igbase().game().gameController()->setPaused(false);
299 }
300}
301
302
296303
297struct DeletionMessageBox : public UI::WLMessageBox {304struct DeletionMessageBox : public UI::WLMessageBox {
298 DeletionMessageBox305 DeletionMessageBox
299306
=== modified file 'src/wui/game_main_menu_save_game.h'
--- src/wui/game_main_menu_save_game.h 2013-07-13 15:17:51 +0000
+++ src/wui/game_main_menu_save_game.h 2013-07-16 17:39:34 +0000
@@ -43,7 +43,7 @@
43 void select_by_name(std::string name);43 void select_by_name(std::string name);
44private:44private:
45 Interactive_GameBase & igbase();45 Interactive_GameBase & igbase();
46 void die() {UI::UniqueWindow::die();}46 void die();
47 void selected (uint32_t);47 void selected (uint32_t);
48 void double_clicked(uint32_t);48 void double_clicked(uint32_t);
49 void edit_box_changed();49 void edit_box_changed();
5050
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2013-07-12 15:11:32 +0000
+++ src/wui/game_message_menu.cc 2013-07-16 17:39:34 +0000
@@ -28,6 +28,7 @@
28#include "logic/playercommand.h"28#include "logic/playercommand.h"
2929
30#include "container_iterate.h"30#include "container_iterate.h"
31#include "timestring.h"
3132
32using Widelands::Message;33using Widelands::Message;
33using Widelands::Message_Id;34using Widelands::Message_Id;
@@ -109,6 +110,8 @@
109110
110 list->set_column_compare111 list->set_column_compare
111 (ColStatus, boost::bind(&GameMessageMenu::status_compare, this, _1, _2));112 (ColStatus, boost::bind(&GameMessageMenu::status_compare, this, _1, _2));
113 list->set_sort_column(ColTimeSent);
114 list->set_sort_descending(true);
112115
113 set_can_focus(true);116 set_can_focus(true);
114 focus();117 focus();
@@ -200,19 +203,8 @@
200 g_gr->images().get(status_picture_filename[message.status()]));203 g_gr->images().get(status_picture_filename[message.status()]));
201 er.set_string(ColTitle, message.title());204 er.set_string(ColTitle, message.title());
202205
203 uint32_t time = message.sent();206 const uint32_t time = message.sent();
204 char timestring[] = "000:00:00.000";207 er.set_string(ColTimeSent, gametimestring(time));
205 timestring[12] += time % 10;
206 timestring[11] += (time /= 10) % 10;
207 timestring[10] += (time /= 10) % 10;
208 timestring [8] += (time /= 10) % 10;
209 timestring [7] += (time /= 10) % 6;
210 timestring [5] += (time /= 6) % 10;
211 timestring [4] += (time /= 10) % 6;
212 timestring [2] += (time /= 6) % 10;
213 timestring [1] += (time /= 10) % 10;
214 timestring [0] += time /= 10;
215 er.set_string(ColTimeSent, time < 10 ? timestring : "-------------");
216}208}
217209
218/*210/*
219211
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2013-06-15 13:38:19 +0000
+++ src/wui/interactive_base.cc 2013-07-16 17:39:34 +0000
@@ -36,6 +36,7 @@
36#include "logic/maptriangleregion.h"36#include "logic/maptriangleregion.h"
37#include "logic/player.h"37#include "logic/player.h"
38#include "logic/productionsite.h"38#include "logic/productionsite.h"
39#include "logic/maphollowregion.h"
39#include "mapviewpixelconstants.h"40#include "mapviewpixelconstants.h"
40#include "mapviewpixelfunctions.h"41#include "mapviewpixelfunctions.h"
41#include "minimap.h"42#include "minimap.h"
@@ -119,6 +120,15 @@
119 // funny results.120 // funny results.
120 m_sel.pic = g_gr->images().get("pics/fsel.png");121 m_sel.pic = g_gr->images().get("pics/fsel.png");
121122
123 // Load workarea images.
124 // Start at idx 0 for 2 enhancements, idx 3 for 1, idx 5 if none
125 workarea_pics[0] = g_gr->images().get("pics/workarea123.png");
126 workarea_pics[1] = g_gr->images().get("pics/workarea23.png");
127 workarea_pics[2] = g_gr->images().get("pics/workarea3.png");
128 workarea_pics[3] = g_gr->images().get("pics/workarea12.png");
129 workarea_pics[4] = g_gr->images().get("pics/workarea2.png");
130 workarea_pics[5] = g_gr->images().get("pics/workarea1.png");
131
122 m_label_speed.set_visible(false);132 m_label_speed.set_visible(false);
123 m_label_speed_shadow.set_visible(false);133 m_label_speed_shadow.set_visible(false);
124134
@@ -229,6 +239,60 @@
229 egbase().map().overlay_manager().show_buildhelp(t);239 egbase().map().overlay_manager().show_buildhelp(t);
230}240}
231241
242// Show the given workareas at the given coords and returns the overlay job id associated
243Overlay_Manager::Job_Id Interactive_Base::show_work_area
244 (const Workarea_Info & workarea_info, Widelands::Coords coords)
245{
246 uint8_t workareas_nrs = workarea_info.size();
247 Workarea_Info::size_type wa_index;
248 switch (workareas_nrs) {
249 case 0: return Overlay_Manager::Job_Id::Null(); break; // no workarea
250 case 1: wa_index = 5; break;
251 case 2: wa_index = 3; break;
252 case 3: wa_index = 0; break;
253 default: assert(false); break;
254 }
255 Widelands::Map & map = m_egbase.map();
256 Overlay_Manager & overlay_manager = map.overlay_manager();
257 Overlay_Manager::Job_Id job_id = overlay_manager.get_a_job_id();
258
259 Widelands::HollowArea<> hollow_area(Widelands::Area<>(coords, 0), 0);
260
261 // Iterate through the work areas, from building to its enhancement
262 Workarea_Info::const_iterator it = workarea_info.begin();
263 for (; it != workarea_info.end(); ++it) {
264 assert(wa_index < NUMBER_OF_WORKAREA_PICS);
265 hollow_area.radius = it->first;
266 Widelands::MapHollowRegion<> mr(map, hollow_area);
267 do
268 overlay_manager.register_overlay
269 (mr.location(),
270 workarea_pics[wa_index],
271 0,
272 Point::invalid(),
273 job_id);
274 while (mr.advance(map));
275 wa_index++;
276 hollow_area.hole_radius = hollow_area.radius;
277 }
278 return job_id;
279#if 0
280 // This is debug output.
281 // Improvement suggestion: add to sign explanation window instead.
282 container_iterate_const(Workarea_Info, workarea_info, i) {
283 log("Radius: %i\n", i.current->first);
284 container_iterate_const(std::set<std::string>, i.current->second, j)
285 log(" %s\n", j.current->c_str());
286 }
287#endif
288}
289
290void Interactive_Base::hide_work_area(Overlay_Manager::Job_Id job_id) {
291 Widelands::Map & map = m_egbase.map();
292 Overlay_Manager & overlay_manager = map.overlay_manager();
293 overlay_manager.remove_overlay(job_id);
294}
295
232296
233/**297/**
234 * Called by \ref Game::postload at the end of the game loading298 * Called by \ref Game::postload at the end of the game loading
235299
=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h 2013-02-10 19:36:24 +0000
+++ src/wui/interactive_base.h 2013-07-16 17:39:34 +0000
@@ -60,6 +60,8 @@
60 virtual void reference_player_tribe(Widelands::Player_Number, const void * const) {}60 virtual void reference_player_tribe(Widelands::Player_Number, const void * const) {}
6161
62 bool m_show_workarea_preview;62 bool m_show_workarea_preview;
63 Overlay_Manager::Job_Id show_work_area(const Workarea_Info & workarea_info, Widelands::Coords coords);
64 void hide_work_area(Overlay_Manager::Job_Id job_id);
6365
64 // point of view for drawing66 // point of view for drawing
65 virtual Widelands::Player * get_player() const throw () = 0;67 virtual Widelands::Player * get_player() const throw () = 0;
@@ -151,6 +153,7 @@
151 Overlay_Manager::Job_Id m_road_buildhelp_overlay_jobid;153 Overlay_Manager::Job_Id m_road_buildhelp_overlay_jobid;
152 Widelands::CoordPath * m_buildroad; // path for the new road154 Widelands::CoordPath * m_buildroad; // path for the new road
153 Widelands::Player_Number m_road_build_player;155 Widelands::Player_Number m_road_build_player;
156 const Image* workarea_pics[NUMBER_OF_WORKAREA_PICS];
154157
155protected:158protected:
156 void toggle_minimap();159 void toggle_minimap();
157160
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2013-02-21 19:02:21 +0000
+++ src/wui/interactive_player.cc 2013-07-16 17:39:34 +0000
@@ -85,7 +85,8 @@
85 :85 :
86 Interactive_GameBase (_game, global_s),86 Interactive_GameBase (_game, global_s),
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)),
88m_flag_to_connect(Widelands::Coords::Null()),88 m_flag_to_connect(Widelands::Coords::Null()),
89 m_multiplayer(multiplayer),
8990
90// Chat is different, as m_chatProvider needs to be checked when toggling91// Chat is different, as m_chatProvider needs to be checked when toggling
91// Buildhelp is different as it does not toggle a UniqueWindow92// Buildhelp is different as it does not toggle a UniqueWindow
@@ -152,16 +153,16 @@
152 m_toolbar.add(&m_toggle_statistics_menu, UI::Box::AlignLeft);153 m_toolbar.add(&m_toggle_statistics_menu, UI::Box::AlignLeft);
153 m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft);154 m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft);
154 m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft);155 m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft);
156 // Limit chat width to half the screen, to limit the damage lamers can do
157 // by flooding chat messages
158 m_chatOverlay =
159 new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25);
155 if (multiplayer) {160 if (multiplayer) {
156 m_toolbar.add(&m_toggle_chat, UI::Box::AlignLeft);161 m_toolbar.add(&m_toggle_chat, UI::Box::AlignLeft);
157 // Limit chat width to half the screen, to limit the damage lamers can do
158 // by flooding chat messages
159 m_chatOverlay =
160 new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25);
161 m_toggle_chat.set_visible(false);162 m_toggle_chat.set_visible(false);
162 m_toggle_chat.set_enabled(false);163 m_toggle_chat.set_enabled(false);
163 } else164 }
164 m_toggle_chat.set_visible(false);165
165 m_toolbar.add(&m_toggle_help, UI::Box::AlignLeft);166 m_toolbar.add(&m_toggle_help, UI::Box::AlignLeft);
166 if (not scenario)167 if (not scenario)
167 m_toggle_objectives.set_visible(false);168 m_toggle_objectives.set_visible(false);
@@ -283,8 +284,10 @@
283 m_flag_to_connect = Widelands::Coords::Null();284 m_flag_to_connect = Widelands::Coords::Null();
284 }285 }
285 }286 }
286 m_toggle_chat.set_visible(m_chatenabled);287 if (m_multiplayer) {
287 m_toggle_chat.set_enabled(m_chatenabled);288 m_toggle_chat.set_visible(m_chatenabled);
289 m_toggle_chat.set_enabled(m_chatenabled);
290 }
288 {291 {
289 char buffer[128];292 char buffer[128];
290 char const * msg_icon = "pics/menu_toggle_oldmessage_menu.png";293 char const * msg_icon = "pics/menu_toggle_oldmessage_menu.png";
@@ -452,7 +455,7 @@
452455
453 case SDLK_KP_ENTER:456 case SDLK_KP_ENTER:
454 case SDLK_RETURN:457 case SDLK_RETURN:
455 if (!m_chatProvider | !m_chatenabled)458 if (!m_chatProvider | !m_chatenabled || !m_multiplayer)
456 break;459 break;
457460
458 if (!m_chat.window)461 if (!m_chat.window)
459462
=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h 2013-02-10 19:36:24 +0000
+++ src/wui/interactive_player.h 2013-07-16 17:39:34 +0000
@@ -88,12 +88,15 @@
8888
89 void popup_message(Widelands::Message_Id, const Widelands::Message &);89 void popup_message(Widelands::Message_Id, const Widelands::Message &);
9090
91 bool is_multiplayer() {return m_multiplayer;}
92
91private:93private:
92 void cmdSwitchPlayer(const std::vector<std::string> & args);94 void cmdSwitchPlayer(const std::vector<std::string> & args);
9395
94 Widelands::Player_Number m_player_number;96 Widelands::Player_Number m_player_number;
95 bool m_auto_roadbuild_mode;97 bool m_auto_roadbuild_mode;
96 Widelands::Coords m_flag_to_connect;98 Widelands::Coords m_flag_to_connect;
99 bool m_multiplayer;
97100
98 UI::Button m_toggle_chat;101 UI::Button m_toggle_chat;
99 UI::Button m_toggle_options_menu;102 UI::Button m_toggle_options_menu;
100103
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2013-02-10 19:36:24 +0000
+++ src/wui/productionsitewindow.cc 2013-07-16 17:39:34 +0000
@@ -105,13 +105,41 @@
105 worker_box,105 worker_box,
106 productionsite().descr().nr_working_positions() > 1 ?106 productionsite().descr().nr_working_positions() > 1 ?
107 _("Workers") : _("Worker"));107 _("Workers") : _("Worker"));
108 update_worker_table();
108 }109 }
109}110}
110111
111void ProductionSite_Window::think()112void ProductionSite_Window::think()
112{113{
113 Building_Window::think();114 Building_Window::think();
114115 // If we have pending requests, update table as the worker might be coming
116 for
117 (unsigned int i = 0;
118 i < productionsite().descr().nr_working_positions(); ++i)
119 {
120 if (productionsite().working_positions()[i].worker_request) {
121 update_worker_table();
122 break;
123 }
124 }
125}
126
127/*
128===============
129Create the production site information window.
130===============
131*/
132void ProductionSite::create_options_window
133 (Interactive_GameBase & parent, UI::Window * & registry)
134{
135 ProductionSite_Window* win = new ProductionSite_Window(parent, *this, registry);
136 options_window_connections.push_back
137 (workers_changed.connect(boost::bind
138 (&ProductionSite_Window::update_worker_table, boost::ref(*win))));
139}
140
141void ProductionSite_Window::update_worker_table()
142{
115 if (m_worker_table) {143 if (m_worker_table) {
116 assert144 assert
117 (productionsite().descr().nr_working_positions() ==145 (productionsite().descr().nr_working_positions() ==
@@ -155,7 +183,7 @@
155 er.set_string(1, "---");183 er.set_string(1, "---");
156 er.set_string(2, "---");184 er.set_string(2, "---");
157 }185 }
158 } else {186 } else if (request) {
159 const Widelands::Worker_Descr * desc =187 const Widelands::Worker_Descr * desc =
160 productionsite().tribe().get_worker_descr(request->get_index());188 productionsite().tribe().get_worker_descr(request->get_index());
161 er.set_picture189 er.set_picture
@@ -164,20 +192,13 @@
164192
165 er.set_string(1, "");193 er.set_string(1, "");
166 er.set_string(2, "");194 er.set_string(2, "");
195 } else {
196 // Occurs during cleanup
197 return;
167 }198 }
168 }199 }
169 }200 }
170}201 m_worker_table->update();
171
172/*
173===============
174Create the production site information window.
175===============
176*/
177void ProductionSite::create_options_window
178 (Interactive_GameBase & parent, UI::Window * & registry)
179{
180 new ProductionSite_Window(parent, *this, registry);
181}202}
182203
183void ProductionSite_Window::evict_worker() {204void ProductionSite_Window::evict_worker() {
184205
=== modified file 'src/wui/productionsitewindow.h'
--- src/wui/productionsitewindow.h 2013-02-02 14:42:48 +0000
+++ src/wui/productionsitewindow.h 2013-07-16 17:39:34 +0000
@@ -33,7 +33,7 @@
33 Widelands::ProductionSite & productionsite() {33 Widelands::ProductionSite & productionsite() {
34 return ref_cast<Widelands::ProductionSite, Widelands::Building>(building());34 return ref_cast<Widelands::ProductionSite, Widelands::Building>(building());
35 }35 }
3636 void update_worker_table();
37protected:37protected:
38 virtual void think();38 virtual void think();
39 void evict_worker();39 void evict_worker();

Subscribers

People subscribed via source and target branches

to status/vote changes: