GunChleoc has proposed merging lp:~widelands-dev/widelands/get-rid-of-transport-draw into lp:widelands.
Commit message: Move draw functions from transport_draw.cc to the map objects' files. Make draw functions in Road and PortDock private. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/get-rid-of-transport-draw/+merge/369263 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. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/get-rid-of-transport-draw into lp:widelands.
=== modified file 'src/economy/flag.cc' --- src/economy/flag.cc 2019-02-23 11:00:49 +0000 +++ src/economy/flag.cc 2019-06-24 19:08:56 +0000 @@ -784,6 +784,36 @@ PlayerImmovable::cleanup(egbase); } + +void Flag::draw(uint32_t gametime, + const TextToDraw, + const Vector2f& field_on_dst, + const Coords& coords, + float scale, + RenderTarget* dst) { + static struct { + float x, y; + } ware_offsets[8] = {{-5.f, 1.f}, {-1.f, 3.f}, {3.f, 3.f}, {7.f, 1.f}, + {-6.f, -3.f}, {-1.f, -2.f}, {3.f, -2.f}, {8.f, -3.f}}; + + const RGBColor& player_color = owner().get_playercolor(); + dst->blit_animation(field_on_dst, coords, scale, owner().tribe().flag_animation(), + gametime - animstart_, &player_color); + + for (int32_t i = 0; i < ware_filled_; ++i) { // draw wares + Vector2f warepos = field_on_dst; + if (i < 8) { + warepos.x += ware_offsets[i].x * scale; + warepos.y += ware_offsets[i].y * scale; + } else { + warepos.y -= (6.f + (i - 8.f) * 3.f) * scale; + } + dst->blit_animation(warepos, Widelands::Coords::null(), scale, + wares_[i].ware->descr().get_animation("idle", wares_[i].ware), 0, + &player_color); + } +} + /** * Destroy the building as well. * === modified file 'src/economy/portdock.h' --- src/economy/portdock.h 2019-04-24 06:51:31 +0000 +++ src/economy/portdock.h 2019-06-24 19:08:56 +0000 @@ -95,12 +95,6 @@ Flag& base_flag() override; PositionList get_positions(const EditorGameBase&) const override; - void draw(uint32_t gametime, - TextToDraw draw_text, - const Vector2f& point_on_dst, - const Coords&, - float scale, - RenderTarget* dst) override; bool init(EditorGameBase&) override; void cleanup(EditorGameBase&) override; @@ -140,6 +134,14 @@ private: friend struct Fleet; + // Does nothing + void draw(uint32_t gametime, + TextToDraw draw_text, + const Vector2f& point_on_dst, + const Coords&, + float scale, + RenderTarget* dst) override; + void init_fleet(EditorGameBase& egbase); void set_fleet(Fleet* fleet); void update_shippingitem(Game&, std::list<ShippingItem>::iterator); === modified file 'src/economy/road.cc' --- src/economy/road.cc 2019-02-23 11:00:49 +0000 +++ src/economy/road.cc 2019-06-24 19:08:56 +0000 @@ -299,6 +299,10 @@ PlayerImmovable::cleanup(egbase); } +/** The road is drawn by the terrain renderer via marked fields. */ +void Road::draw(uint32_t, const TextToDraw, const Vector2f&, const Coords&, float, RenderTarget*) { +} + /** * Workers' economies are fixed by PlayerImmovable, but we need to handle * any requests ourselves. === modified file 'src/economy/road.h' --- src/economy/road.h 2019-04-24 06:01:37 +0000 +++ src/economy/road.h 2019-06-24 19:08:56 +0000 @@ -130,6 +130,8 @@ bool init(EditorGameBase&) override; void cleanup(EditorGameBase&) override; +private: + // Does nothing void draw(uint32_t gametime, TextToDraw draw_text, const Vector2f&, @@ -137,7 +139,6 @@ float scale, RenderTarget* dst) override; -private: void set_path(EditorGameBase&, const Path&); void mark_map(EditorGameBase&); === modified file 'src/wui/CMakeLists.txt' --- src/wui/CMakeLists.txt 2019-05-29 06:24:42 +0000 +++ src/wui/CMakeLists.txt 2019-06-24 19:08:56 +0000 @@ -263,7 +263,6 @@ story_message_box.h trainingsitewindow.cc trainingsitewindow.h - transport_draw.cc tribal_encyclopedia.cc tribal_encyclopedia.h unique_window_handler.cc === removed file 'src/wui/transport_draw.cc' --- src/wui/transport_draw.cc 2019-05-18 20:43:25 +0000 +++ src/wui/transport_draw.cc 1970-01-01 00:00:00 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2002-2019 by the Widelands Development Team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "economy/flag.h" -#include "economy/road.h" -#include "economy/ware_instance.h" -#include "graphic/rendertarget.h" -#include "logic/editor_game_base.h" -#include "logic/player.h" - -namespace Widelands { - -void Flag::draw(uint32_t gametime, - const TextToDraw, - const Vector2f& field_on_dst, - const Coords& coords, - float scale, - RenderTarget* dst) { - static struct { - float x, y; - } ware_offsets[8] = {{-5.f, 1.f}, {-1.f, 3.f}, {3.f, 3.f}, {7.f, 1.f}, - {-6.f, -3.f}, {-1.f, -2.f}, {3.f, -2.f}, {8.f, -3.f}}; - - const RGBColor& player_color = owner().get_playercolor(); - dst->blit_animation(field_on_dst, coords, scale, owner().tribe().flag_animation(), - gametime - animstart_, &player_color); - - for (int32_t i = 0; i < ware_filled_; ++i) { // draw wares - Vector2f warepos = field_on_dst; - if (i < 8) { - warepos.x += ware_offsets[i].x * scale; - warepos.y += ware_offsets[i].y * scale; - } else { - warepos.y -= (6.f + (i - 8.f) * 3.f) * scale; - } - dst->blit_animation(warepos, Widelands::Coords::null(), scale, - wares_[i].ware->descr().get_animation("idle", wares_[i].ware), 0, - &player_color); - } -} - -/** The road is drawn by the terrain renderer via marked fields. */ -void Road::draw(uint32_t, const TextToDraw, const Vector2f&, const Coords&, float, RenderTarget*) { -} -} // namespace Widelands
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp