Merge lp:~widelands-dev/widelands/bug-768826 into lp:widelands

Proposed by TiborB
Status: Merged
Merged at revision: 7281
Proposed branch: lp:~widelands-dev/widelands/bug-768826
Merge into: lp:widelands
Diff against target: 59 lines (+27/-11)
1 file modified
src/wui/interactive_base.cc (+27/-11)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-768826
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+242544@code.launchpad.net

Description of the change

This adds information about height into bottom right corner - next to x,y coordinates, hope you will find this useful.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

draw_overlay needs to know if it's drawing for the editor or for a game/replay. I don't know how the control flow is here and what is accessible from the function; you might need to add a function parameter.

Some more comments in the diff.

review: Needs Fixing
Revision history for this message
TiborB (tiborb95) wrote :

Hey, I implemented your comments. Also now the height is shown only in editor.

Revision history for this message
TiborB (tiborb95) wrote :

Also, I can see that the elapsed time is shown in editor - is it needed?

Revision history for this message
GunChleoc (gunchleoc) wrote :

No, that was just me being lazy when I added it to the debug screen.

Revision history for this message
TiborB (tiborb95) wrote :

OK, going to hide it

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have had a liik at the code now - maybe you could move the dst.blit( part outside the if/else again, this way we get less code. const std::string node_text will then also need to be declared outside and lose the const.

When you remove the gametime from the editor, don't forget to move the FPS up to the (5,5) coordinate for the editor only.

Revision history for this message
TiborB (tiborb95) wrote :

@GunChleoc: done, can check it now :)

Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM, except for a couple more nits. One functionality change:

- In the editor, remove the blank space between ( and the first coordinate

And two code style nits:

- add operator padding to (is_game)?25:5 (codecheck doesn't catch this case, but it should look like this: (is_game) ? 25 : 5)

- Properly align the closing parenthesis for dst.blit(. It should either be where it was, or at the end of the last parameter - I think the last option is preferred.

Revision history for this message
TiborB (tiborb95) wrote :

re: "- In the editor, remove the blank space between ( and the first coordinate"

Talking about this line?

static boost::format node_format("(%3i, %3i, %2i)");

Because there is no space. But I can say that numbers between % and i are flatly ignored, if you know how to make them work...

Revision history for this message
GunChleoc (gunchleoc) wrote :

They are, except for the first variable. That looks weird, so I have removed it. Going to merge now.

review: Approve
Revision history for this message
TiborB (tiborb95) wrote :

OK, and thanks for saving me from this work, I am struggling with that LUA testing now...

Revision history for this message
GunChleoc (gunchleoc) wrote :

No problem. Let me know if you need help with the Lua tests, I have written a few simple ones for the building descriptions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/interactive_base.cc'
2--- src/wui/interactive_base.cc 2014-11-24 07:25:21 +0000
3+++ src/wui/interactive_base.cc 2014-11-27 11:20:36 +0000
4@@ -406,21 +406,37 @@
5 */
6 void InteractiveBase::draw_overlay(RenderTarget& dst) {
7
8+ const Map & map = egbase().map();
9+ const bool is_game = dynamic_cast<const Game*>(&egbase());
10+
11 // Blit node information when in debug mode.
12- if (get_display_flag(dfDebug) || !dynamic_cast<const Game*>(&egbase())) {
13- const std::string gametime(gametimestring(egbase().get_gametime()));
14- const std::string gametime_text = as_uifont(gametime, UI_FONT_SIZE_SMALL);
15- dst.blit(Point(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha, UI::Align_TopLeft);
16- static boost::format node_format("(%i, %i)");
17-
18- const std::string node_text = as_uifont
19- ((node_format % m_sel.pos.node.x % m_sel.pos.node.y).str(), UI_FONT_SIZE_SMALL);
20+ if (get_display_flag(dfDebug) || !is_game) {
21+
22+ std::string node_text;
23+
24+ if (is_game) {
25+
26+ const std::string gametime(gametimestring(egbase().get_gametime()));
27+ const std::string gametime_text = as_uifont(gametime, UI_FONT_SIZE_SMALL);
28+ dst.blit(Point(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha, UI::Align_TopLeft);
29+
30+ static boost::format node_format("(%i, %i)");
31+ node_text = as_uifont
32+ ((node_format % m_sel.pos.node.x % m_sel.pos.node.y).str(), UI_FONT_SIZE_SMALL);
33+
34+ } else { //this is an editor
35+
36+ static boost::format node_format("(%i, %i, %i)");
37+ const int32_t height = map[m_sel.pos.node].get_height();
38+ node_text = as_uifont
39+ ((node_format % m_sel.pos.node.x % m_sel.pos.node.y % height).str(), UI_FONT_SIZE_SMALL);
40+ }
41+
42 dst.blit(
43 Point(get_w() - 5, get_h() - 5),
44 UI::g_fh1->render(node_text),
45 BlendMode::UseAlpha,
46- UI::Align_BottomRight
47- );
48+ UI::Align_BottomRight);
49 }
50
51 // Blit FPS when in debug mode.
52@@ -430,7 +446,7 @@
53 ((fps_format %
54 (1000.0 / m_frametime) % (1000.0 / (m_avg_usframetime / 1000)))
55 .str(), UI_FONT_SIZE_SMALL);
56- dst.blit(Point(5, 25), UI::g_fh1->render(fps_text), BlendMode::UseAlpha, UI::Align_Left);
57+ dst.blit(Point(5, (is_game) ? 25 : 5), UI::g_fh1->render(fps_text), BlendMode::UseAlpha, UI::Align_Left);
58 }
59 }
60

Subscribers

People subscribed via source and target branches

to status/vote changes: