1 /* 2 * Copyright (C) 2002-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_EDITOR_TOOLS_SET_RESOURCES_TOOL_H 21 #define WL_EDITOR_TOOLS_SET_RESOURCES_TOOL_H 22 23 #include "editor/tools/tool.h" 24 25 Widelands::NodeCaps resource_tools_nodecaps(const Widelands::FCoords& fcoords, 26 const Widelands::EditorGameBase& egbase, 27 Widelands::DescriptionIndex resource); 28 29 /// Decreases the resources of a node by a value. 30 struct EditorSetResourcesTool : public EditorTool { EditorSetResourcesToolEditorSetResourcesTool31 EditorSetResourcesTool() : EditorTool(*this, *this), cur_res_(0), set_to_(0) { 32 } 33 34 /** 35 * Sets the resources of the current to a fixed value 36 */ 37 int32_t handle_click_impl(const Widelands::NodeAndTriangle<>& center, 38 EditorInteractive& parent, 39 EditorActionArgs* args, 40 Widelands::Map* map) override; 41 42 int32_t handle_undo_impl(const Widelands::NodeAndTriangle<>& center, 43 EditorInteractive& parent, 44 EditorActionArgs* args, 45 Widelands::Map* map) override; 46 47 EditorActionArgs format_args_impl(EditorInteractive& parent) override; 48 get_sel_implEditorSetResourcesTool49 const Image* get_sel_impl() const override { 50 return g_gr->images().get("images/wui/editor/fsel_editor_set_resources.png"); 51 } 52 nodecaps_for_buildhelpEditorSetResourcesTool53 Widelands::NodeCaps nodecaps_for_buildhelp(const Widelands::FCoords& fcoords, 54 const Widelands::EditorGameBase& egbase) override { 55 return resource_tools_nodecaps(fcoords, egbase, cur_res_); 56 } 57 get_set_toEditorSetResourcesTool58 Widelands::ResourceAmount get_set_to() const { 59 return set_to_; 60 } set_set_toEditorSetResourcesTool61 void set_set_to(Widelands::ResourceAmount const n) { 62 set_to_ = n; 63 } get_cur_resEditorSetResourcesTool64 Widelands::DescriptionIndex get_cur_res() const { 65 return cur_res_; 66 } set_cur_resEditorSetResourcesTool67 void set_cur_res(Widelands::DescriptionIndex const res) { 68 cur_res_ = res; 69 } 70 71 private: 72 Widelands::DescriptionIndex cur_res_; 73 Widelands::ResourceAmount set_to_; 74 }; 75 76 #endif // end of include guard: WL_EDITOR_TOOLS_SET_RESOURCES_TOOL_H 77