Merge lp:~widelands-dev/widelands/get-rid-of-transport-draw into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9163
Proposed branch: lp:~widelands-dev/widelands/get-rid-of-transport-draw
Merge into: lp:widelands
Diff against target: 191 lines (+44/-78)
6 files modified
src/economy/flag.cc (+30/-0)
src/economy/portdock.cc (+0/-5)
src/economy/portdock.h (+8/-6)
src/economy/road.h (+6/-5)
src/wui/CMakeLists.txt (+0/-1)
src/wui/transport_draw.cc (+0/-61)
To merge this branch: bzr merge lp:~widelands-dev/widelands/get-rid-of-transport-draw
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+369263@code.launchpad.net

Commit message

Move draw functions from transport_draw.cc to the map objects' files. Make draw functions in Road and PortDock private.

Description of the change

I always found it confusing that the draw functions for flags and roads are not in the objects' cc files like for all other objects.

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

Continuous integration builds have changed state:

Travis build 5241. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/549898990.
Appveyor build 5020. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_get_rid_of_transport_draw-5020.

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Looks good, one suggestion in the diff

Revision history for this message
GunChleoc (gunchleoc) wrote :

Excellent suggestion - done!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/economy/flag.cc'
2--- src/economy/flag.cc 2019-02-23 11:00:49 +0000
3+++ src/economy/flag.cc 2019-07-05 07:08:52 +0000
4@@ -784,6 +784,36 @@
5 PlayerImmovable::cleanup(egbase);
6 }
7
8+
9+void Flag::draw(uint32_t gametime,
10+ const TextToDraw,
11+ const Vector2f& field_on_dst,
12+ const Coords& coords,
13+ float scale,
14+ RenderTarget* dst) {
15+ static struct {
16+ float x, y;
17+ } ware_offsets[8] = {{-5.f, 1.f}, {-1.f, 3.f}, {3.f, 3.f}, {7.f, 1.f},
18+ {-6.f, -3.f}, {-1.f, -2.f}, {3.f, -2.f}, {8.f, -3.f}};
19+
20+ const RGBColor& player_color = owner().get_playercolor();
21+ dst->blit_animation(field_on_dst, coords, scale, owner().tribe().flag_animation(),
22+ gametime - animstart_, &player_color);
23+
24+ for (int32_t i = 0; i < ware_filled_; ++i) { // draw wares
25+ Vector2f warepos = field_on_dst;
26+ if (i < 8) {
27+ warepos.x += ware_offsets[i].x * scale;
28+ warepos.y += ware_offsets[i].y * scale;
29+ } else {
30+ warepos.y -= (6.f + (i - 8.f) * 3.f) * scale;
31+ }
32+ dst->blit_animation(warepos, Widelands::Coords::null(), scale,
33+ wares_[i].ware->descr().get_animation("idle", wares_[i].ware), 0,
34+ &player_color);
35+ }
36+}
37+
38 /**
39 * Destroy the building as well.
40 *
41
42=== modified file 'src/economy/portdock.cc'
43--- src/economy/portdock.cc 2019-05-26 10:09:28 +0000
44+++ src/economy/portdock.cc 2019-07-05 07:08:52 +0000
45@@ -145,11 +145,6 @@
46 expedition_bootstrap_->set_economy(e);
47 }
48
49-void PortDock::draw(
50- uint32_t, const TextToDraw, const Vector2f&, const Widelands::Coords&, float, RenderTarget*) {
51- // do nothing
52-}
53-
54 bool PortDock::init(EditorGameBase& egbase) {
55 PlayerImmovable::init(egbase);
56
57
58=== modified file 'src/economy/portdock.h'
59--- src/economy/portdock.h 2019-04-24 06:51:31 +0000
60+++ src/economy/portdock.h 2019-07-05 07:08:52 +0000
61@@ -95,12 +95,6 @@
62
63 Flag& base_flag() override;
64 PositionList get_positions(const EditorGameBase&) const override;
65- void draw(uint32_t gametime,
66- TextToDraw draw_text,
67- const Vector2f& point_on_dst,
68- const Coords&,
69- float scale,
70- RenderTarget* dst) override;
71
72 bool init(EditorGameBase&) override;
73 void cleanup(EditorGameBase&) override;
74@@ -140,6 +134,14 @@
75 private:
76 friend struct Fleet;
77
78+ // Does nothing - we do not show them on the map
79+ void draw(uint32_t,
80+ TextToDraw,
81+ const Vector2f&,
82+ const Coords&,
83+ float,
84+ RenderTarget*) override {}
85+
86 void init_fleet(EditorGameBase& egbase);
87 void set_fleet(Fleet* fleet);
88 void update_shippingitem(Game&, std::list<ShippingItem>::iterator);
89
90=== modified file 'src/economy/road.h'
91--- src/economy/road.h 2019-04-24 06:01:37 +0000
92+++ src/economy/road.h 2019-07-05 07:08:52 +0000
93@@ -130,14 +130,15 @@
94 bool init(EditorGameBase&) override;
95 void cleanup(EditorGameBase&) override;
96
97- void draw(uint32_t gametime,
98- TextToDraw draw_text,
99+private:
100+ /** The road is drawn by the terrain renderer via marked fields. */
101+ void draw(uint32_t,
102+ TextToDraw,
103 const Vector2f&,
104 const Coords&,
105- float scale,
106- RenderTarget* dst) override;
107+ float,
108+ RenderTarget*) override {}
109
110-private:
111 void set_path(EditorGameBase&, const Path&);
112
113 void mark_map(EditorGameBase&);
114
115=== modified file 'src/wui/CMakeLists.txt'
116--- src/wui/CMakeLists.txt 2019-05-29 06:24:42 +0000
117+++ src/wui/CMakeLists.txt 2019-07-05 07:08:52 +0000
118@@ -263,7 +263,6 @@
119 story_message_box.h
120 trainingsitewindow.cc
121 trainingsitewindow.h
122- transport_draw.cc
123 tribal_encyclopedia.cc
124 tribal_encyclopedia.h
125 unique_window_handler.cc
126
127=== removed file 'src/wui/transport_draw.cc'
128--- src/wui/transport_draw.cc 2019-05-18 20:43:25 +0000
129+++ src/wui/transport_draw.cc 1970-01-01 00:00:00 +0000
130@@ -1,61 +0,0 @@
131-/*
132- * Copyright (C) 2002-2019 by the Widelands Development Team
133- *
134- * This program is free software; you can redistribute it and/or
135- * modify it under the terms of the GNU General Public License
136- * as published by the Free Software Foundation; either version 2
137- * of the License, or (at your option) any later version.
138- *
139- * This program is distributed in the hope that it will be useful,
140- * but WITHOUT ANY WARRANTY; without even the implied warranty of
141- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142- * GNU General Public License for more details.
143- *
144- * You should have received a copy of the GNU General Public License
145- * along with this program; if not, write to the Free Software
146- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
147- *
148- */
149-
150-#include "economy/flag.h"
151-#include "economy/road.h"
152-#include "economy/ware_instance.h"
153-#include "graphic/rendertarget.h"
154-#include "logic/editor_game_base.h"
155-#include "logic/player.h"
156-
157-namespace Widelands {
158-
159-void Flag::draw(uint32_t gametime,
160- const TextToDraw,
161- const Vector2f& field_on_dst,
162- const Coords& coords,
163- float scale,
164- RenderTarget* dst) {
165- static struct {
166- float x, y;
167- } ware_offsets[8] = {{-5.f, 1.f}, {-1.f, 3.f}, {3.f, 3.f}, {7.f, 1.f},
168- {-6.f, -3.f}, {-1.f, -2.f}, {3.f, -2.f}, {8.f, -3.f}};
169-
170- const RGBColor& player_color = owner().get_playercolor();
171- dst->blit_animation(field_on_dst, coords, scale, owner().tribe().flag_animation(),
172- gametime - animstart_, &player_color);
173-
174- for (int32_t i = 0; i < ware_filled_; ++i) { // draw wares
175- Vector2f warepos = field_on_dst;
176- if (i < 8) {
177- warepos.x += ware_offsets[i].x * scale;
178- warepos.y += ware_offsets[i].y * scale;
179- } else {
180- warepos.y -= (6.f + (i - 8.f) * 3.f) * scale;
181- }
182- dst->blit_animation(warepos, Widelands::Coords::null(), scale,
183- wares_[i].ware->descr().get_animation("idle", wares_[i].ware), 0,
184- &player_color);
185- }
186-}
187-
188-/** The road is drawn by the terrain renderer via marked fields. */
189-void Road::draw(uint32_t, const TextToDraw, const Vector2f&, const Coords&, float, RenderTarget*) {
190-}
191-} // namespace Widelands

Subscribers

People subscribed via source and target branches

to status/vote changes: