← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/remove_make_infrastructure_tool into lp:widelands

 

SirVer has proposed merging lp:~widelands-dev/widelands/remove_make_infrastructure_tool into lp:widelands.

Commit message:
Remove make infrastructure tool.

This tool was supposed to make it possible to create an economy in the editor. This would be great for scenarios, but did not work properly (that is why the UI was not wired up). It is also unclear how this would interact with Lua scripting (which came after this prototype was implemented). Time to kill this dead code.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/remove_make_infrastructure_tool/+merge/329201
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/remove_make_infrastructure_tool into lp:widelands.
=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt	2017-05-14 14:40:24 +0000
+++ src/editor/CMakeLists.txt	2017-08-17 13:39:35 +0000
@@ -23,8 +23,6 @@
     tools/increase_resources_tool.h
     tools/info_tool.cc
     tools/info_tool.h
-    tools/make_infrastructure_tool.cc
-    tools/make_infrastructure_tool.h
     tools/multi_select.h
     tools/noise_height_tool.cc
     tools/noise_height_tool.h

=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h	2017-08-14 13:54:01 +0000
+++ src/editor/editorinteractive.h	2017-08-17 13:39:35 +0000
@@ -26,7 +26,6 @@
 #include "editor/tools/increase_height_tool.h"
 #include "editor/tools/increase_resources_tool.h"
 #include "editor/tools/info_tool.h"
-#include "editor/tools/make_infrastructure_tool.h"
 #include "editor/tools/noise_height_tool.h"
 #include "editor/tools/place_critter_tool.h"
 #include "editor/tools/place_immovable_tool.h"
@@ -84,7 +83,6 @@
 		EditorSetPortSpaceTool set_port_space;
 		EditorUnsetPortSpaceTool unset_port_space;
 		EditorSetOriginTool set_origin;
-		EditorMakeInfrastructureTool make_infrastructure;
 	};
 	explicit EditorInteractive(Widelands::EditorGameBase&);
 

=== removed file 'src/editor/tools/make_infrastructure_tool.cc'
--- src/editor/tools/make_infrastructure_tool.cc	2017-08-13 18:02:53 +0000
+++ src/editor/tools/make_infrastructure_tool.cc	1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2002-2017 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 "editor/tools/make_infrastructure_tool.h"
-
-#include "editor/editorinteractive.h"
-#include "logic/editor_game_base.h"
-#include "logic/field.h"
-#include "logic/map.h"
-#include "logic/player.h"
-#include "wui/fieldaction.h"
-
-/**
- * Callback function to calculate correct overlays
- */
-int32_t editor_make_infrastructure_tool_callback(const Widelands::FCoords& c,
-                                                 Widelands::EditorGameBase& egbase,
-                                                 int32_t const player) {
-	return egbase.player(player).get_buildcaps(c);
-}
-
-/**
- * This is the most complex of all tool functions: check where was clicked,
- * offer the correct user dialog and act accordingly.
- *
- * Obviously, this function ignores the sel radius
-*/
-int32_t EditorMakeInfrastructureTool::handle_click_impl(const Widelands::World&,
-                                                        const Widelands::NodeAndTriangle<>&,
-                                                        EditorInteractive& parent,
-                                                        EditorActionArgs* /* args */,
-                                                        Widelands::Map*) {
-	show_field_action(&parent, parent.egbase().get_player(player_), &registry_);
-
-	//  Not really needed, since Player Immovables are taken care of while
-	//  placing on map.
-	return 5;
-}

=== removed file 'src/editor/tools/make_infrastructure_tool.h'
--- src/editor/tools/make_infrastructure_tool.h	2017-08-13 18:02:53 +0000
+++ src/editor/tools/make_infrastructure_tool.h	1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2002-2017 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.
- *
- */
-
-#ifndef WL_EDITOR_TOOLS_MAKE_INFRASTRUCTURE_TOOL_H
-#define WL_EDITOR_TOOLS_MAKE_INFRASTRUCTURE_TOOL_H
-
-#include "editor/tools/tool.h"
-#include "ui_basic/unique_window.h"
-
-namespace Widelands {
-class EditorGameBase;
-}  // namespace Widelands
-
-/**
- * This places immovables on the map
- */
-// TODO(unknown):  Implement undo for this tool
-struct EditorMakeInfrastructureTool : public EditorTool {
-	EditorMakeInfrastructureTool() : EditorTool(*this, *this, false), player_(0) {
-	}
-
-	void set_player(Widelands::PlayerNumber const n) {
-		player_ = n;
-	}
-	Widelands::PlayerNumber get_player() const {
-		return player_;
-	}
-
-	int32_t handle_click_impl(const Widelands::World& world,
-	                          const Widelands::NodeAndTriangle<>& center,
-	                          EditorInteractive& parent,
-	                          EditorActionArgs* args,
-	                          Widelands::Map* map) override;
-
-	const Image* get_sel_impl() const override {
-		return g_gr->images().get("images/ui_basic/fsel.png");
-	}  //  Standard sel icon, most complex tool of all
-
-private:
-	Widelands::PlayerNumber player_;
-	UI::UniqueWindow::Registry registry_;
-};
-
-int32_t editor_make_infrastructure_tool_callback(const Widelands::FCoords& c,
-                                                 Widelands::EditorGameBase& egbase,
-                                                 int32_t const player);
-
-#endif  // end of include guard: WL_EDITOR_TOOLS_MAKE_INFRASTRUCTURE_TOOL_H

=== modified file 'src/editor/ui_menus/player_menu.cc'
--- src/editor/ui_menus/player_menu.cc	2017-05-03 07:24:06 +0000
+++ src/editor/ui_menus/player_menu.cc	2017-08-17 13:39:35 +0000
@@ -89,7 +89,6 @@
 		plr_names_[i] = nullptr;
 		plr_set_pos_buts_[i] = nullptr;
 		plr_set_tribes_buts_[i] = nullptr;
-		plr_make_infrastructure_buts_[i] = nullptr;
 	}
 	update();
 
@@ -308,63 +307,3 @@
 	plr_names_[m]->set_text(map.get_scenario_player_name(m + 1));
 	menu.set_need_save(true);
 }
-
-/*
- * Make infrastructure button clicked
- */
-void EditorPlayerMenu::make_infrastructure_clicked(uint8_t n) {
-	EditorInteractive& parent = dynamic_cast<EditorInteractive&>(*get_parent());
-	// Check if starting position is valid (was checked before
-	// so must be true)
-	Widelands::EditorGameBase& egbase = parent.egbase();
-	Widelands::Map& map = egbase.map();
-	auto* overlay_manager = parent.mutable_field_overlay_manager();
-	const Widelands::Coords start_pos = map.get_starting_pos(n);
-	assert(start_pos);
-
-	Widelands::Player* p = egbase.get_player(n);
-	if (!p) {
-		// This player is unknown, register it,
-		// place a hq and reference the tribe
-		// so that this tribe can not be changed
-		egbase.add_player(n, 0,  // TODO(SirVer): initialization index makes no sense here
-		                  Widelands::get_tribeinfo(selected_tribes_[n]).descname,
-		                  plr_names_[n - 1]->text());
-
-		p = egbase.get_player(n);
-	}
-
-	// If the player is already created in the editor, this means
-	// that there might be already a hq placed somewhere. This needs to be
-	// deleted before a starting position change can occure
-	const Widelands::PlayerNumber player_number = p->player_number();
-	const Widelands::Coords starting_pos = map.get_starting_pos(player_number);
-	Widelands::BaseImmovable* const imm = map[starting_pos].get_immovable();
-	if (!imm) {
-		// place HQ
-		const Widelands::TribeDescr& tribe = p->tribe();
-		const Widelands::DescriptionIndex idx = tribe.headquarters();
-		if (!tribe.has_building(idx))
-			throw wexception("Tribe %s lacks headquarters", tribe.name().c_str());
-		// Widelands::Warehouse & headquarter = dynamic_cast<Widelands::Warehouse &>
-		//         (egbase.warp_building(starting_pos, player_number, idx));
-		// egbase.conquer_area
-		//         (PlayerArea
-		//          (player_number, Area(starting_pos, headquarter.get_conquers())));
-		// tribe.load_warehouse_with_start_wares(editor, headquarter);
-
-		parent.reference_player_tribe(n, &tribe);
-
-		// Remove the player overlay from this starting pos.
-		// A HQ is overlay enough
-		const Image* player_image = playercolor_image(n - 1, "images/players/player_position.png");
-		assert(player_image);
-		overlay_manager->remove_overlay(start_pos, player_image);
-	}
-
-	parent.select_tool(parent.tools()->make_infrastructure, EditorTool::First);
-	parent.tools()->make_infrastructure.set_player(n);
-	overlay_manager->register_overlay_callback_function(
-	   boost::bind(&editor_make_infrastructure_tool_callback, _1, boost::ref(egbase), n));
-	map.recalc_whole_map(egbase.world());
-}

=== modified file 'src/editor/ui_menus/player_menu.h'
--- src/editor/ui_menus/player_menu.h	2017-01-25 18:55:59 +0000
+++ src/editor/ui_menus/player_menu.h	2017-08-17 13:39:35 +0000
@@ -49,8 +49,7 @@
 	UI::Textarea* nr_of_players_ta_;
 	UI::EditBox* plr_names_[kMaxPlayers];
 	UI::Button add_player_, remove_last_player_;
-	UI::Button *plr_make_infrastructure_buts_[kMaxPlayers], *plr_set_pos_buts_[kMaxPlayers],
-	   *plr_set_tribes_buts_[kMaxPlayers];
+	UI::Button *plr_set_pos_buts_[kMaxPlayers], *plr_set_tribes_buts_[kMaxPlayers];
 
 	std::vector<std::string> tribenames_;
 
@@ -66,7 +65,6 @@
 	void set_starting_pos_clicked(uint8_t);
 	void update();
 	void think() override;
-	void make_infrastructure_clicked(uint8_t);
 };
 
 #endif  // end of include guard: WL_EDITOR_UI_MENUS_PLAYER_MENU_H


Follow ups