widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #01450
[Merge] lp:~widelands-dev/widelands/ship_progress into lp:widelands
cghislai has proposed merging lp:~widelands-dev/widelands/ship_progress into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1194194 in widelands: "Show build progress of the current ship"
https://bugs.launchpad.net/widelands/+bug/1194194
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ship_progress/+merge/177318
Add progress to immovable in construction, the same way as construction site.
--
https://code.launchpad.net/~widelands-dev/widelands/ship_progress/+merge/177318
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ship_progress into lp:widelands.
=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc 2013-07-26 20:19:36 +0000
+++ src/logic/immovable.cc 2013-07-29 06:50:44 +0000
@@ -19,14 +19,15 @@
#include "logic/immovable.h"
+#include <boost/format.hpp>
+#include <config.h>
#include <cstdio>
-#include <config.h>
-
#include "container_iterate.h"
#include "graphic/animation_gfx.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
+#include "graphic/font_handler1.h"
#include "helper.h"
#include "logic/editor_game_base.h"
#include "logic/field.h"
@@ -42,8 +43,10 @@
#include "logic/worker.h"
#include "profile/profile.h"
#include "sound/sound_handler.h"
+#include "text_layout.h"
#include "upcast.h"
#include "wexception.h"
+#include "wui/interactive_base.h"
namespace Widelands {
@@ -534,6 +537,15 @@
assert(lines <= curh);
dst.drawanimrect
(pos, m_anim, current_frame * frametime, get_owner(), Rect(Point(0, curh - lines), curw, lines));
+
+ // Additionnaly, if statistics are enabled, draw a progression string
+ if (game.get_ibase()->get_display_flags() & Interactive_Base::dfShowStatistics) {
+ unsigned int percent = (100 * done / total);
+ m_construct_string =
+ (boost::format("<font color=%1$s>%2$i%% built</font>") % UI_FONT_CLR_DARK_HEX % percent).str();
+ m_construct_string = as_uifont(m_construct_string);
+ dst.blit(pos - Point(0, 48), UI::g_fh1->render(m_construct_string), CM_Normal, UI::Align_Center);
+ }
}
=== modified file 'src/logic/immovable.h'
--- src/logic/immovable.h 2013-07-26 20:19:36 +0000
+++ src/logic/immovable.h 2013-07-29 06:50:44 +0000
@@ -212,6 +212,7 @@
uint32_t m_anim_construction_done;
int32_t m_program_step; ///< time of next step
#endif
+ std::string m_construct_string;
/**
* Private persistent data for the currently active program action.
Follow ups