Map Editor

RD Core / Commit #3

Commit Map Editor

Alex Alex committed 18/10/2026 23:40 main Patch
436 files +250,791 -0
A RD_Map_Editor/source/main_menubar.h +370-0 View file
@@ -0,0 +1,370 @@
1+//////////////////////////////////////////////////////////////////////
2+// This file is part of Remere's Map Editor
3+//////////////////////////////////////////////////////////////////////
4+// Remere's Map Editor is free software: you can redistribute it and/or modify
5+// it under the terms of the GNU General Public License as published by
6+// the Free Software Foundation, either version 3 of the License, or
7+// (at your option) any later version.
8+//
9+// Remere's Map Editor 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, see <http://www.gnu.org/licenses/>.
16+//////////////////////////////////////////////////////////////////////
17+
18+#ifndef RME_MAIN_BAR_H_
19+#define RME_MAIN_BAR_H_
20+
21+#include <wx/docview.h>
22+
23+namespace MenuBar {
24+ struct Action;
25+
26+ enum ActionID {
27+ NEW,
28+ OPEN,
29+ SAVE,
30+ SAVE_AS,
31+ GENERATE_MAP,
32+ GENERATE_PROCEDURAL_MAP,
33+ CLOSE,
34+ IMPORT_MAP,
35+ IMPORT_MONSTERS,
36+ IMPORT_MINIMAP,
37+ EXPORT_MINIMAP,
38+ EXPORT_TILESETS,
39+ RELOAD_DATA,
40+ RECENT_FILES,
41+ PREFERENCES,
42+ EXIT,
43+ UNDO,
44+ REDO,
45+ FIND_ITEM,
46+ FIND_CREATURE,
47+ REPLACE_ITEMS,
48+ AUTOMAGIC,
49+ SEARCH_ON_MAP_EVERYTHING,
50+ SEARCH_ON_MAP_ZONES,
51+ SEARCH_ON_MAP_UNIQUE,
52+ SEARCH_ON_MAP_ACTION,
53+ SEARCH_ON_MAP_CONTAINER,
54+ SEARCH_ON_MAP_WRITEABLE,
55+ SEARCH_ON_SELECTION_EVERYTHING,
56+ SEARCH_ON_SELECTION_ZONES,
57+ SEARCH_ON_SELECTION_UNIQUE,
58+ SEARCH_ON_SELECTION_ACTION,
59+ SEARCH_ON_SELECTION_CONTAINER,
60+ SEARCH_ON_SELECTION_WRITEABLE,
61+ SEARCH_ON_SELECTION_ITEM,
62+ REPLACE_ON_SELECTION_ITEMS,
63+ REMOVE_ON_SELECTION_ITEM,
64+ SELECT_MODE_COMPENSATE,
65+ SELECT_MODE_CURRENT,
66+ SELECT_MODE_LOWER,
67+ SELECT_MODE_VISIBLE,
68+ // AUTOMAGIC removed - now controlled by 'A' hotkey
69+ BORDERIZE_SELECTION,
70+ BORDERIZE_MAP,
71+ RANDOMIZE_SELECTION,
72+ RANDOMIZE_MAP,
73+ GOTO_PREVIOUS_POSITION,
74+ GOTO_POSITION,
75+ JUMP_TO_BRUSH,
76+ JUMP_TO_ITEM_BRUSH,
77+ CLEAR_INVALID_HOUSES,
78+ CLEAR_MODIFIED_STATE,
79+ CUT,
80+ COPY,
81+ PASTE,
82+ EDIT_TOWNS,
83+ EDIT_ITEMS,
84+ EDIT_MONSTERS,
85+ MAP_CLEANUP,
86+ MAP_REMOVE_ITEMS,
87+ MAP_REMOVE_CORPSES,
88+ MAP_REMOVE_UNREACHABLE_TILES,
89+ MAP_CLEAN_HOUSE_ITEMS,
90+ MAP_PROPERTIES,
91+ MAP_STATISTICS,
92+ VIEW_TOOLBARS_BRUSHES,
93+ VIEW_TOOLBARS_POSITION,
94+ VIEW_TOOLBARS_SIZES,
95+ VIEW_TOOLBARS_STANDARD,
96+ NEW_VIEW,
97+ // RD
98+ NEW_DETACHED_VIEW,
99+ TOGGLE_FULLSCREEN,
100+ ZOOM_IN,
101+ ZOOM_OUT,
102+ ZOOM_NORMAL,
103+ SHOW_SHADE,
104+ SHOW_ALL_FLOORS,
105+ GHOST_ITEMS,
106+ GHOST_HIGHER_FLOORS,
107+ HIGHLIGHT_ITEMS,
108+ HIGHLIGHT_LOCKED_DOORS,
109+ SHOW_INGAME_BOX,
110+ SHOW_LIGHTS,
111+ SHOW_LIGHT_STR,
112+ SHOW_TECHNICAL_ITEMS,
113+ SHOW_WAYPOINTS,
114+ SHOW_GRID,
115+ SHOW_EXTRA,
116+ SHOW_CREATURES,
117+ SHOW_SPAWNS,
118+ SHOW_SPECIAL,
119+ SHOW_ZONES,
120+ SHOW_AS_MINIMAP,
121+ SHOW_ONLY_COLORS,
122+ SHOW_ONLY_MODIFIED,
123+ SHOW_HOUSES,
124+ SHOW_PATHING,
125+ SHOW_TOOLTIPS,
126+ SHOW_PREVIEW,
127+ SHOW_WALL_HOOKS,
128+ SHOW_TOWNS,
129+ ALWAYS_SHOW_ZONES,
130+ EXT_HOUSE_SHADER,
131+ REFRESH_ITEMS,
132+
133+ WIN_MINIMAP,
134+ NEW_PALETTE,
135+ TAKE_SCREENSHOT,
136+ LIVE_START,
137+ LIVE_JOIN,
138+ LIVE_CLOSE,
139+ SELECT_TERRAIN,
140+ SELECT_DOODAD,
141+ SELECT_ITEM,
142+ SELECT_COLLECTION,
143+ SELECT_CREATURE,
144+ SELECT_HOUSE,
145+ SELECT_WAYPOINT,
146+ SELECT_RAW,
147+ FLOOR_0,
148+ FLOOR_1,
149+ FLOOR_2,
150+ FLOOR_3,
151+ FLOOR_4,
152+ FLOOR_5,
153+ FLOOR_6,
154+ FLOOR_7,
155+ FLOOR_8,
156+ FLOOR_9,
157+ FLOOR_10,
158+ FLOOR_11,
159+ FLOOR_12,
160+ FLOOR_13,
161+ FLOOR_14,
162+ FLOOR_15,
163+ DEBUG_VIEW_DAT,
164+ EXTENSIONS,
165+ GOTO_WEBSITE,
166+ ABOUT,
167+ ID_MENU_SERVER_HOST,
168+ ID_MENU_SERVER_CONNECT,
169+
170+ EXPERIMENTAL_FOG,
171+ MAP_REMOVE_DUPLICATES,
172+ SHOW_HOTKEYS,
173+ MAP_MENU_REPLACE_ITEMS,
174+ MAP_MENU_GENERATE_ISLAND,
175+ MAP_VALIDATE_GROUND,
176+ MAP_CREATE_BORDER,
177+ MAP_SUMMARIZE,
178+
179+
180+
181+ };
182+}
183+
184+class MainFrame;
185+
186+class MainMenuBar : public wxEvtHandler {
187+public:
188+ MainMenuBar(MainFrame* frame);
189+ virtual ~MainMenuBar();
190+
191+ bool Load(const FileName&, wxArrayString& warnings, wxString& error);
192+
193+ // Update
194+ // Turn on/off all buttons according to current editor state
195+ void Update();
196+ void UpdateFloorMenu(); // Only concerns the floor menu
197+
198+ void AddRecentFile(FileName file);
199+ void LoadRecentFiles();
200+ void SaveRecentFiles();
201+ std::vector<wxString> GetRecentFiles();
202+
203+ // Interface
204+ void EnableItem(MenuBar::ActionID id, bool enable);
205+ void CheckItem(MenuBar::ActionID id, bool enable);
206+ bool IsItemChecked(MenuBar::ActionID id) const;
207+
208+ // Event handlers for all menu buttons
209+ // File Menu
210+ void OnNew(wxCommandEvent& event);
211+ void OnOpen(wxCommandEvent& event);
212+ void OnGenerateMap(wxCommandEvent& event);
213+ void OnGenerateProceduralMap(wxCommandEvent& event);
214+ void OnOpenRecent(wxCommandEvent& event);
215+ void OnSave(wxCommandEvent& event);
216+ void OnSaveAs(wxCommandEvent& event);
217+ void OnClose(wxCommandEvent& event);
218+ void OnPreferences(wxCommandEvent& event);
219+ void OnQuit(wxCommandEvent& event);
220+
221+ // Import Menu
222+ // Export Menu
223+ void OnImportMap(wxCommandEvent& event);
224+ void OnImportMonsterData(wxCommandEvent& event);
225+ void OnImportMinimap(wxCommandEvent& event);
226+ void OnExportMinimap(wxCommandEvent& event);
227+ void OnExportTilesets(wxCommandEvent& event);
228+ void OnReloadDataFiles(wxCommandEvent& event);
229+
230+ // Edit Menu
231+ void OnUndo(wxCommandEvent& event);
232+ void OnRedo(wxCommandEvent& event);
233+ void OnBorderizeSelection(wxCommandEvent& event);
234+ void OnBorderizeMap(wxCommandEvent& event);
235+ void OnRandomizeSelection(wxCommandEvent& event);
236+ void OnRandomizeMap(wxCommandEvent& event);
237+ void OnJumpToBrush(wxCommandEvent& event);
238+ void OnJumpToItemBrush(wxCommandEvent& event);
239+ void OnGotoPreviousPosition(wxCommandEvent& event);
240+ void OnGotoPosition(wxCommandEvent& event);
241+ void OnMapRemoveItems(wxCommandEvent& event);
242+ void OnMapRemoveCorpses(wxCommandEvent& event);
243+ void OnMapRemoveUnreachable(wxCommandEvent& event);
244+ void OnClearHouseTiles(wxCommandEvent& event);
245+ void OnClearModifiedState(wxCommandEvent& event);
246+ void OnSelectionTypeChange(wxCommandEvent& event);
247+ void OnCut(wxCommandEvent& event);
248+ void OnCopy(wxCommandEvent& event);
249+ void OnPaste(wxCommandEvent& event);
250+ void OnSearchForItem(wxCommandEvent& event);
251+ void OnSearchForCreature(wxCommandEvent& event);
252+ void OnReplaceItems(wxCommandEvent& event);
253+ void OnSearchForStuffOnMap(wxCommandEvent& event);
254+ void OnSearchForZonesOnMap(wxCommandEvent& event);
255+ void OnSearchForUniqueOnMap(wxCommandEvent& event);
256+ void OnSearchForActionOnMap(wxCommandEvent& event);
257+ void OnSearchForContainerOnMap(wxCommandEvent& event);
258+ void OnSearchForWriteableOnMap(wxCommandEvent& event);
259+
260+ // Select menu
261+ void OnSearchForStuffOnSelection(wxCommandEvent& event);
262+ void OnSearchForZonesOnSelection(wxCommandEvent& event);
263+ void OnSearchForUniqueOnSelection(wxCommandEvent& event);
264+ void OnSearchForActionOnSelection(wxCommandEvent& event);
265+ void OnSearchForContainerOnSelection(wxCommandEvent& event);
266+ void OnSearchForWriteableOnSelection(wxCommandEvent& event);
267+ void OnSearchForItemOnSelection(wxCommandEvent& event);
268+ void OnReplaceItemsOnSelection(wxCommandEvent& event);
269+ void OnRemoveItemOnSelection(wxCommandEvent& event);
270+
271+ // Map menu
272+ void OnMapEditTowns(wxCommandEvent& event);
273+ void OnMapEditItems(wxCommandEvent& event);
274+ void OnMapEditMonsters(wxCommandEvent& event);
275+ void OnMapCleanHouseItems(wxCommandEvent& event);
276+ void OnMapCleanup(wxCommandEvent& event);
277+ void OnMapProperties(wxCommandEvent& event);
278+ void OnMapStatistics(wxCommandEvent& event);
279+ void OnMapRemoveDuplicates(wxCommandEvent& event);
280+ void OnMapValidateGround(wxCommandEvent& event);
281+
282+ // View Menu
283+ void OnToolbars(wxCommandEvent& event);
284+ void OnNewView(wxCommandEvent& event);
285+ void OnNewDetachedView(wxCommandEvent& event);
286+ void OnToggleFullscreen(wxCommandEvent& event);
287+ void OnZoomIn(wxCommandEvent& event);
288+ void OnZoomOut(wxCommandEvent& event);
289+ void OnZoomNormal(wxCommandEvent& event);
290+ void OnChangeViewSettings(wxCommandEvent& event);
291+
292+ // Network menu
293+ void OnStartLive(wxCommandEvent& event);
294+ void OnJoinLive(wxCommandEvent& event);
295+ void OnCloseLive(wxCommandEvent& event);
296+ void onServerHost(wxCommandEvent& event);
297+ void onServerConnect(wxCommandEvent& event);
298+
299+ // Window Menu
300+ void OnMinimapWindow(wxCommandEvent& event);
301+ void OnNewPalette(wxCommandEvent& event);
302+ void OnTakeScreenshot(wxCommandEvent& event);
303+ void OnSelectTerrainPalette(wxCommandEvent& event);
304+ void OnSelectDoodadPalette(wxCommandEvent& event);
305+ void OnSelectItemPalette(wxCommandEvent& event);
306+ void OnSelectCollectionPalette(wxCommandEvent& event);
307+ void OnSelectHousePalette(wxCommandEvent& event);
308+ void OnSelectCreaturePalette(wxCommandEvent& event);
309+ void OnSelectWaypointPalette(wxCommandEvent& event);
310+ void OnSelectRawPalette(wxCommandEvent& event);
311+
312+ // Floor menu
313+ void OnChangeFloor(wxCommandEvent& event);
314+
315+ // About Menu
316+ void OnDebugViewDat(wxCommandEvent& event);
317+ void OnListExtensions(wxCommandEvent& event);
318+ void OnGotoWebsite(wxCommandEvent& event);
319+ void OnAbout(wxCommandEvent& event);
320+ void OnShowHotkeys(wxCommandEvent& event);
321+
322+ // Add to class MainMenuBar private section:
323+ void OnRefreshItems(wxCommandEvent& event);
324+ void OnGenerateIsland(wxCommandEvent& event);
325+ void OnCreateBorder(wxCommandEvent& event);
326+ void OnMapSummarize(wxCommandEvent& event);
327+
328+protected:
329+ // Load and returns a menu item, also sets accelerator
330+ wxObject* LoadItem(pugi::xml_node node, wxMenu* parent, wxArrayString& warnings, wxString& error);
331+ // Checks the items in the menus according to the settings (in config)
332+ void LoadValues();
333+ void SearchItems(bool unique, bool action, bool container, bool writable, bool zones, bool onSelection = false);
334+
335+protected:
336+ MainFrame* frame;
337+ wxMenuBar* menubar;
338+
339+ // Used so that calling Check on menu items don't trigger events (avoids infinite recursion)
340+ bool checking_programmaticly;
341+
342+ std::map<MenuBar::ActionID, std::list<wxMenuItem*>> items;
343+
344+ // Hardcoded recent files
345+ wxFileHistory recentFiles;
346+
347+ std::map<std::string, MenuBar::Action*> actions;
348+
349+ DECLARE_EVENT_TABLE();
350+};
351+
352+namespace MenuBar {
353+ struct Action {
354+ Action() :
355+ id(0), kind(wxITEM_NORMAL) { }
356+ Action(std::string s, int id, wxItemKind kind, wxCommandEventFunction handler) :
357+ id(id), setting(0), name(s), kind(kind), handler(handler) { }
358+
359+ int id;
360+ int setting;
361+ std::string name;
362+ wxItemKind kind;
363+ wxCommandEventFunction handler;
364+ };
365+}
366+
367+// Add this declaration before the MainMenuBar class
368+std::vector<std::pair<uint16_t, uint16_t>> ParseRangeString(const wxString& input);
369+
370+#endif
A RD_Map_Editor/source/main_toolbar.h +66-0 View file
@@ -0,0 +1,66 @@
1+//////////////////////////////////////////////////////////////////////
2+// This file is part of Remere's Map Editor
3+//////////////////////////////////////////////////////////////////////
4+// Remere's Map Editor is free software: you can redistribute it and/or modify
5+// it under the terms of the GNU General Public License as published by
6+// the Free Software Foundation, either version 3 of the License, or
7+// (at your option) any later version.
8+//
9+// Remere's Map Editor 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, see <http://www.gnu.org/licenses/>.
16+//////////////////////////////////////////////////////////////////////
17+
18+#ifndef RME_MAINTOOLBAR_H_
19+#define RME_MAINTOOLBAR_H_
20+
21+#include <wx/wx.h>
22+#include <wx/aui/aui.h>
23+#include <wx/aui/auibar.h>
24+
25+#include "gui_ids.h"
26+#include "numbertextctrl.h"
27+
28+class MainToolBar : public wxEvtHandler {
29+public:
30+ MainToolBar(wxWindow* parent, wxAuiManager* manager);
31+ ~MainToolBar();
32+
33+ wxAuiPaneInfo& GetPane(ToolBarID id);
34+ void UpdateButtons();
35+ void UpdateBrushButtons();
36+ void UpdateBrushSize(BrushShape shape, int size);
37+ void Show(ToolBarID id, bool show);
38+ void HideAll(bool update = true);
39+ void LoadPerspective();
40+ void SavePerspective();
41+ void RegisterHotkeys();
42+
43+ void OnStandardButtonClick(wxCommandEvent& event);
44+ void OnBrushesButtonClick(wxCommandEvent& event);
45+ void OnPositionButtonClick(wxCommandEvent& event);
46+ void OnPositionKeyUp(wxKeyEvent& event);
47+ void OnPastePositionText(wxClipboardTextEvent& event);
48+ void OnSizesButtonClick(wxCommandEvent& event);
49+
50+private:
51+ static const wxString STANDARD_BAR_NAME;
52+ static const wxString BRUSHES_BAR_NAME;
53+ static const wxString POSITION_BAR_NAME;
54+ static const wxString SIZES_BAR_NAME;
55+
56+ wxAuiToolBar* standard_toolbar;
57+ wxAuiToolBar* brushes_toolbar;
58+ wxAuiToolBar* position_toolbar;
59+ NumberTextCtrl* x_control;
60+ NumberTextCtrl* y_control;
61+ NumberTextCtrl* z_control;
62+ wxButton* go_button;
63+ wxAuiToolBar* sizes_toolbar;
64+};
65+
66+#endif // RME_MAINTOOLBAR_H_
A RD_Map_Editor/source/map.h +342-0 View file
@@ -0,0 +1,342 @@
1+//////////////////////////////////////////////////////////////////////
2+// This file is part of Remere's Map Editor
3+//////////////////////////////////////////////////////////////////////
4+// Remere's Map Editor is free software: you can redistribute it and/or modify
5+// it under the terms of the GNU General Public License as published by
6+// the Free Software Foundation, either version 3 of the License, or
7+// (at your option) any later version.
8+//
9+// Remere's Map Editor 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, see <http://www.gnu.org/licenses/>.
16+//////////////////////////////////////////////////////////////////////
17+
18+#ifndef RME_MAP_H_
19+#define RME_MAP_H_
20+
21+#include "basemap.h"
22+#include "tile.h"
23+#include "town.h"
24+#include "house.h"
25+#include "spawn.h"
26+#include "complexitem.h"
27+#include "waypoints.h"
28+#include "templates.h"
29+
30+// Add this struct before the Map class definition
31+struct PropertyFlags {
32+ bool ignore_unpassable;
33+ bool ignore_unmovable;
34+ bool ignore_block_missiles;
35+ bool ignore_block_pathfinder;
36+ bool ignore_readable;
37+ bool ignore_writeable;
38+ bool ignore_pickupable;
39+ bool ignore_stackable;
40+ bool ignore_rotatable;
41+ bool ignore_hangable;
42+ bool ignore_hook_east;
43+ bool ignore_hook_south;
44+ bool ignore_elevation;
45+
46+ // Constructor with default values
47+ PropertyFlags(
48+ bool unpassable = false,
49+ bool unmovable = false,
50+ bool block_missiles = false,
51+ bool block_pathfinder = false,
52+ bool readable = false,
53+ bool writeable = false,
54+ bool pickupable = false,
55+ bool stackable = false,
56+ bool rotatable = false,
57+ bool hangable = false,
58+ bool hook_east = false,
59+ bool hook_south = false,
60+ bool elevation = false
61+ ) :
62+ ignore_unpassable(unpassable),
63+ ignore_unmovable(unmovable),
64+ ignore_block_missiles(block_missiles),
65+ ignore_block_pathfinder(block_pathfinder),
66+ ignore_readable(readable),
67+ ignore_writeable(writeable),
68+ ignore_pickupable(pickupable),
69+ ignore_stackable(stackable),
70+ ignore_rotatable(rotatable),
71+ ignore_hangable(hangable),
72+ ignore_hook_east(hook_east),
73+ ignore_hook_south(hook_south),
74+ ignore_elevation(elevation)
75+ {}
76+};
77+
78+class Map : public BaseMap {
79+public:
80+ // ctor and dtor
81+ Map();
82+ virtual ~Map();
83+
84+ // Operations on the entire map
85+ void cleanInvalidTiles(bool showdialog = false);
86+ void convertHouseTiles(uint32_t fromId, uint32_t toId);
87+
88+ // Save a bmp image of the minimap
89+ bool exportMinimap(FileName filename, int floor = GROUND_LAYER, bool showdialog = false);
90+ //
91+ bool convert(MapVersion to, bool showdialog = false);
92+ bool convert(const ConversionMap& cm, bool showdialog = false);
93+
94+ // Query information about the map
95+
96+ MapVersion getVersion() const;
97+ // Returns true if any change has been done since last save
98+ bool hasChanged() const;
99+ // Makes a change, doesn't matter what. Just so that it asks when saving (Also adds a * to the window title)
100+ bool doChange();
101+ // Clears any changes
102+ bool clearChanges();
103+
104+ // Errors/warnings
105+ bool hasWarnings() const {
106+ return warnings.size() != 0;
107+ }
108+ const wxArrayString& getWarnings() const {
109+ return warnings;
110+ }
111+ bool hasError() const {
112+ return error.size() != 0;
113+ }
114+ wxString getError() const {
115+ return error;
116+ }
117+
118+ // Mess with spawns
119+ bool addSpawn(Tile* spawn);
120+ void removeSpawn(Tile* tile);
121+ void removeSpawn(const Position& position) {
122+ removeSpawn(getTile(position));
123+ }
124+
125+ // Returns all possible spawns on the target tile
126+ SpawnList getSpawnList(Tile* t);
127+ SpawnList getSpawnList(const Position& position) {
128+ return getSpawnList(getTile(position));
129+ }
130+ SpawnList getSpawnList(int32_t x, int32_t y, int32_t z) {
131+ return getSpawnList(getTile(x, y, z));
132+ }
133+
134+ // Returns true if the map has been saved
135+ // ie. it knows which file it should be saved to
136+ bool hasFile() const;
137+ std::string getFilename() const {
138+ return filename;
139+ }
140+ std::string getName() const {
141+ return name;
142+ }
143+ void setName(const std::string& n) {
144+ name = n;
145+ }
146+
147+ // Get map data
148+ int getWidth() const {
149+ return width;
150+ }
151+ int getHeight() const {
152+ return height;
153+ }
154+ std::string getMapDescription() const {
155+ return description;
156+ }
157+ std::string getHouseFilename() const {
158+ return housefile;
159+ }
160+ std::string getSpawnFilename() const {
161+ return spawnfile;
162+ }
163+
164+ // Set some map data
165+ void setWidth(int new_width);
166+ void setHeight(int new_height);
167+ void setMapDescription(const std::string& new_description);
168+ void setHouseFilename(const std::string& new_housefile);
169+ void setSpawnFilename(const std::string& new_spawnfile);
170+
171+ void flagAsNamed() {
172+ unnamed = false;
173+ }
174+
175+ // Removes duplicate items from the map, optionally within specified ID ranges
176+ // Returns number of items removed
177+ uint32_t cleanDuplicateItems(
178+ const std::vector<std::pair<uint16_t, uint16_t>>& ranges,
179+ const PropertyFlags& flags
180+ );
181+
182+protected:
183+ // Loads a map
184+ bool open(const std::string identifier);
185+
186+protected:
187+ void removeSpawnInternal(Tile* tile);
188+
189+ wxArrayString warnings;
190+ wxString error;
191+
192+ std::string name; // The map name, NOT the same as filename
193+ std::string filename; // the maps filename
194+ std::string description; // The description of the map
195+
196+ MapVersion mapVersion;
197+
198+ // Map Width and Height - for info purposes
199+ uint16_t width, height;
200+
201+ std::string spawnfile; // The maps spawnfile
202+ std::string housefile; // The housefile
203+ std::string waypointfile; // The waypoints file (stores extended waypoint information such as id, preferred icon and matching town)
204+
205+public:
206+ Towns towns;
207+ Houses houses;
208+ Spawns spawns;
209+
210+protected:
211+ bool has_changed; // If the map has changed
212+ bool unnamed; // If the map has yet to receive a name
213+
214+ friend class IOMapOTBM;
215+ friend class IOMapOTMM;
216+ friend class Editor;
217+
218+public:
219+ Waypoints waypoints;
220+};
221+
222+template <typename ForeachType>
223+inline void foreach_ItemOnMap(Map& map, ForeachType& foreach, bool selectedTiles) {
224+ MapIterator tileiter = map.begin();
225+ MapIterator end = map.end();
226+ long long done = 0;
227+
228+ while (tileiter != end) {
229+ ++done;
230+ Tile* tile = (*tileiter)->get();
231+ if (selectedTiles && !tile->isSelected()) {
232+ ++tileiter;
233+ continue;
234+ }
235+
236+ if (tile->ground) {
237+ foreach (map, tile, tile->ground, done)
238+ ;
239+ }
240+
241+ std::queue<Container*> containers;
242+ for (ItemVector::iterator itemiter = tile->items.begin(); itemiter != tile->items.end(); ++itemiter) {
243+ Item* item = *itemiter;
244+ Container* container = dynamic_cast<Container*>(item);
245+ foreach (map, tile, item, done)
246+ ;
247+ if (container) {
248+ containers.push(container);
249+
250+ do {
251+ container = containers.front();
252+ ItemVector& v = container->getVector();
253+ for (ItemVector::iterator containeriter = v.begin(); containeriter != v.end(); ++containeriter) {
254+ Item* i = *containeriter;
255+ Container* c = dynamic_cast<Container*>(i);
256+ foreach (map, tile, i, done)
257+ ;
258+ if (c) {
259+ containers.push(c);
260+ }
261+ }
262+ containers.pop();
263+ } while (containers.size());
264+ }
265+ }
266+ ++tileiter;
267+ }
268+}
269+
270+template <typename ForeachType>
271+inline void foreach_TileOnMap(Map& map, ForeachType& foreach) {
272+ MapIterator tileiter = map.begin();
273+ MapIterator end = map.end();
274+ long long done = 0;
275+
276+ while (tileiter != end) {
277+ foreach (map, (*tileiter++)->get(), ++done)
278+ ;
279+ }
280+}
281+
282+template <typename RemoveIfType>
283+inline long long remove_if_TileOnMap(Map& map, RemoveIfType& remove_if) {
284+ MapIterator tileiter = map.begin();
285+ MapIterator end = map.end();
286+ long long done = 0;
287+ long long removed = 0;
288+ long long total = map.getTileCount();
289+
290+ while (tileiter != end) {
291+ Tile* tile = (*tileiter)->get();
292+ if (remove_if(map, tile, removed, done, total)) {
293+ map.setTile(tile->getPosition(), nullptr, true);
294+ ++removed;
295+ }
296+ ++tileiter;
297+ ++done;
298+ }
299+
300+ return removed;
301+}
302+
303+template <typename RemoveIfType>
304+inline int64_t RemoveItemOnMap(Map& map, RemoveIfType& condition, bool selectedOnly) {
305+ int64_t done = 0;
306+ int64_t removed = 0;
307+
308+ MapIterator it = map.begin();
309+ MapIterator end = map.end();
310+
311+ while (it != end) {
312+ ++done;
313+ Tile* tile = (*it)->get();
314+ if (selectedOnly && !tile->isSelected()) {
315+ ++it;
316+ continue;
317+ }
318+
319+ if (tile->ground) {
320+ if (condition(map, tile->ground, removed, done)) {
321+ delete tile->ground;
322+ tile->ground = nullptr;
323+ ++removed;
324+ }
325+ }
326+
327+ for (auto iit = tile->items.begin(); iit != tile->items.end();) {
328+ Item* item = *iit;
329+ if (condition(map, item, removed, done)) {
330+ iit = tile->items.erase(iit);
331+ delete item;
332+ ++removed;
333+ } else {
334+ ++iit;
335+ }
336+ }
337+ ++it;
338+ }
339+ return removed;
340+}
341+
342+#endif
A RD_Map_Editor/source/map_allocator.h +66-0 View file
@@ -0,0 +1,66 @@
1+//////////////////////////////////////////////////////////////////////
2+// This file is part of Remere's Map Editor
3+//////////////////////////////////////////////////////////////////////
4+// Remere's Map Editor is free software: you can redistribute it and/or modify
5+// it under the terms of the GNU General Public License as published by
6+// the Free Software Foundation, either version 3 of the License, or
7+// (at your option) any later version.
8+//
9+// Remere's Map Editor 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, see <http://www.gnu.org/licenses/>.
16+//////////////////////////////////////////////////////////////////////
17+
18+#ifndef RME_MAP_ALLOCATOR_H
19+#define RME_MAP_ALLOCATOR_H
20+
21+#include "tile.h"
22+#include "map_region.h"
23+
24+class BaseMap;
25+
26+class MapAllocator {
27+
28+public:
29+ MapAllocator() { }
30+ ~MapAllocator() { }
31+
32+ // shorthands for tiles
33+ Tile* operator()(TileLocation* location) {
34+ return allocateTile(location);
35+ }
36+ // free
37+ void operator()(Tile* t) {
38+ freeTile(t);
39+ }
40+
41+ //
42+ Tile* allocateTile(TileLocation* location) {
43+ return newd Tile(*location);
44+ }
45+ void freeTile(Tile* t) {
46+ delete t;
47+ }
48+
49+ //
50+ Floor* allocateFloor(int x, int y, int z) {
51+ return newd Floor(x, y, z);
52+ }
53+ void freeFloor(Floor* f) {
54+ delete f;
55+ }
56+
57+ //
58+ QTreeNode* allocateNode(BaseMap& map) {
59+ return newd QTreeNode(map);
60+ }
61+ void freeNode(QTreeNode* qt) {
62+ delete qt;
63+ }
64+};
65+
66+#endif
Top