├── README.md ├── source ├── mkpch.cpp ├── script.cpp ├── json │ ├── json_spirit_value.cpp │ ├── json_spirit.h │ ├── json_spirit_error_position.h │ ├── json_spirit_utils.h │ ├── json_spirit_writer.h │ ├── json_spirit_stream_reader.h │ ├── json_spirit_writer.cpp │ └── json_spirit_reader.h ├── dat_debug_view.h ├── json.h ├── extension_window.h ├── map_allocator.h ├── raw_brush.h ├── live_packets.h ├── spawn_brush.h ├── extension.h ├── rme_forward_declarations.h ├── dcbutton.h ├── creature_brush.h ├── waypoint_brush.cpp ├── mt_rand.h ├── templatemap76-74.cpp ├── materials.h ├── house_brush.h ├── house_exit_brush.cpp ├── spawn_brush.cpp ├── pugicast.h ├── live_action.h ├── waypoint_brush.h ├── house_exit_brush.h ├── container_properties_window.h ├── net_connection.h ├── outfit.h ├── live_tab.h ├── table_brush.h ├── about_window.h ├── templates.h ├── result_window.h ├── browse_tile_window.h ├── iomap.cpp ├── properties_window.h ├── carpet_brush.h ├── threads.h ├── minimap_window.h ├── live_server.h ├── copybuffer.h ├── process_com.h ├── old_properties_window.h ├── spawn.cpp ├── extension.cpp ├── positionctrl.h ├── updater.h ├── live_peer.h ├── waypoints.h ├── eraser_brush.cpp ├── creature_brush.cpp ├── numbertextctrl.h ├── map_tab.h ├── rme_net.h ├── iomap.h ├── map_tab.cpp ├── live_client.h ├── raw_brush.cpp ├── town.cpp ├── rme-install ├── waypoints.cpp ├── wall_brush.h ├── editor_tabs.h ├── creature.cpp ├── creature.h ├── process_com.cpp ├── con_vector.h ├── house_brush.cpp ├── spawn.h ├── palette_waypoints.h ├── live_socket.h ├── updater.cpp ├── ground_brush.h ├── pngfiles.h ├── iomap_otmm.h ├── town.h ├── tileset.h ├── brush_enums.h ├── creatures.h ├── ext │ └── pugiconfig.hpp ├── dat_debug_view.cpp ├── complexitem.cpp ├── net_connection.cpp ├── selection.h ├── palette_creature.h ├── house.h ├── doodad_brush.h ├── positionctrl.cpp ├── live_action.cpp ├── mt_rand.cpp ├── application.h ├── palette_window.h ├── common.h ├── find_item_window.h └── numbertextctrl.cpp ├── .gitattributes ├── brushes ├── eraser.png ├── no_pvp.png ├── gem_edit.png ├── gem_move.png ├── no_logout.png ├── pvp_zone.png ├── circular_1.png ├── circular_2.png ├── circular_3.png ├── circular_4.png ├── circular_5.png ├── circular_6.png ├── circular_7.png ├── door_locked.png ├── door_magic.png ├── door_normal.png ├── door_quest.png ├── eraser_small.png ├── no_pvp_small.png ├── window_hatch.png ├── icon │ ├── rme_icon.ico │ └── rme_icon.png ├── pvp_zone_small.png ├── rectangular_1.png ├── rectangular_2.png ├── rectangular_3.png ├── rectangular_4.png ├── rectangular_5.png ├── rectangular_6.png ├── rectangular_7.png ├── window_normal.png ├── circular_1_small.png ├── circular_2_small.png ├── circular_3_small.png ├── circular_4_small.png ├── circular_5_small.png ├── circular_6_small.png ├── circular_7_small.png ├── door_locked_small.png ├── door_magic_small.png ├── door_normal_small.png ├── door_quest_small.png ├── no_logout_small.png ├── optional_border.png ├── protection_zone.png ├── rectangular_1_small.png ├── rectangular_2_small.png ├── rectangular_3_small.png ├── rectangular_4_small.png ├── rectangular_5_small.png ├── rectangular_6_small.png ├── rectangular_7_small.png ├── window_hatch_small.png ├── window_normal_small.png ├── optional_border_small.png └── protection_zone_small.png └── data ├── 770 └── materials.xml └── clients.xml /README.md: -------------------------------------------------------------------------------- 1 | # Map Editor 2 | -------------------------------------------------------------------------------- /source/mkpch.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /brushes/eraser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/eraser.png -------------------------------------------------------------------------------- /brushes/no_pvp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/no_pvp.png -------------------------------------------------------------------------------- /source/script.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/source/script.cpp -------------------------------------------------------------------------------- /brushes/gem_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/gem_edit.png -------------------------------------------------------------------------------- /brushes/gem_move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/gem_move.png -------------------------------------------------------------------------------- /brushes/no_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/no_logout.png -------------------------------------------------------------------------------- /brushes/pvp_zone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/pvp_zone.png -------------------------------------------------------------------------------- /brushes/circular_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_1.png -------------------------------------------------------------------------------- /brushes/circular_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_2.png -------------------------------------------------------------------------------- /brushes/circular_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_3.png -------------------------------------------------------------------------------- /brushes/circular_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_4.png -------------------------------------------------------------------------------- /brushes/circular_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_5.png -------------------------------------------------------------------------------- /brushes/circular_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_6.png -------------------------------------------------------------------------------- /brushes/circular_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_7.png -------------------------------------------------------------------------------- /brushes/door_locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_locked.png -------------------------------------------------------------------------------- /brushes/door_magic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_magic.png -------------------------------------------------------------------------------- /brushes/door_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_normal.png -------------------------------------------------------------------------------- /brushes/door_quest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_quest.png -------------------------------------------------------------------------------- /brushes/eraser_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/eraser_small.png -------------------------------------------------------------------------------- /brushes/no_pvp_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/no_pvp_small.png -------------------------------------------------------------------------------- /brushes/window_hatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/window_hatch.png -------------------------------------------------------------------------------- /brushes/icon/rme_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/icon/rme_icon.ico -------------------------------------------------------------------------------- /brushes/icon/rme_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/icon/rme_icon.png -------------------------------------------------------------------------------- /brushes/pvp_zone_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/pvp_zone_small.png -------------------------------------------------------------------------------- /brushes/rectangular_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_1.png -------------------------------------------------------------------------------- /brushes/rectangular_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_2.png -------------------------------------------------------------------------------- /brushes/rectangular_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_3.png -------------------------------------------------------------------------------- /brushes/rectangular_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_4.png -------------------------------------------------------------------------------- /brushes/rectangular_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_5.png -------------------------------------------------------------------------------- /brushes/rectangular_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_6.png -------------------------------------------------------------------------------- /brushes/rectangular_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_7.png -------------------------------------------------------------------------------- /brushes/window_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/window_normal.png -------------------------------------------------------------------------------- /brushes/circular_1_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_1_small.png -------------------------------------------------------------------------------- /brushes/circular_2_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_2_small.png -------------------------------------------------------------------------------- /brushes/circular_3_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_3_small.png -------------------------------------------------------------------------------- /brushes/circular_4_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_4_small.png -------------------------------------------------------------------------------- /brushes/circular_5_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_5_small.png -------------------------------------------------------------------------------- /brushes/circular_6_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_6_small.png -------------------------------------------------------------------------------- /brushes/circular_7_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/circular_7_small.png -------------------------------------------------------------------------------- /brushes/door_locked_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_locked_small.png -------------------------------------------------------------------------------- /brushes/door_magic_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_magic_small.png -------------------------------------------------------------------------------- /brushes/door_normal_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_normal_small.png -------------------------------------------------------------------------------- /brushes/door_quest_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/door_quest_small.png -------------------------------------------------------------------------------- /brushes/no_logout_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/no_logout_small.png -------------------------------------------------------------------------------- /brushes/optional_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/optional_border.png -------------------------------------------------------------------------------- /brushes/protection_zone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/protection_zone.png -------------------------------------------------------------------------------- /brushes/rectangular_1_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_1_small.png -------------------------------------------------------------------------------- /brushes/rectangular_2_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_2_small.png -------------------------------------------------------------------------------- /brushes/rectangular_3_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_3_small.png -------------------------------------------------------------------------------- /brushes/rectangular_4_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_4_small.png -------------------------------------------------------------------------------- /brushes/rectangular_5_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_5_small.png -------------------------------------------------------------------------------- /brushes/rectangular_6_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_6_small.png -------------------------------------------------------------------------------- /brushes/rectangular_7_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/rectangular_7_small.png -------------------------------------------------------------------------------- /brushes/window_hatch_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/window_hatch_small.png -------------------------------------------------------------------------------- /brushes/window_normal_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/window_normal_small.png -------------------------------------------------------------------------------- /brushes/optional_border_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/optional_border_small.png -------------------------------------------------------------------------------- /brushes/protection_zone_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ezzz-dev/Map-Editor/HEAD/brushes/protection_zone_small.png -------------------------------------------------------------------------------- /source/json/json_spirit_value.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 John W Wilkinson 2 | 3 | This source code can be used for any purpose as long as 4 | this comment is retained. */ 5 | 6 | // json spirit version 2.00 7 | 8 | #include "json_spirit_value.h" 9 | -------------------------------------------------------------------------------- /data/clients.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /source/dat_debug_view.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef RME_DAT_DEBUG_VIEW_H_ 3 | #define RME_DAT_DEBUG_VIEW_H_ 4 | 5 | class DatDebugViewListBox; 6 | 7 | class DatDebugView : wxPanel 8 | { 9 | public: 10 | DatDebugView(wxWindow* parent); 11 | ~DatDebugView(); 12 | 13 | void OnTextChange(wxCommandEvent&); 14 | void OnClickList(wxCommandEvent&); 15 | 16 | protected: 17 | 18 | DatDebugViewListBox* item_list; 19 | wxTextCtrl* search_field; 20 | 21 | DECLARE_EVENT_TABLE() 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /source/json/json_spirit.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT 2 | #define JSON_SPIRIT 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include "json_spirit_reader.h" 15 | #include "json_spirit_writer.h" 16 | #include "json_spirit_utils.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /source/json.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // $URL: https://rme.svn.sourceforge.net/svnroot/rme/trunk/source/common.h $ 5 | // $Id: common.h 264 2009-10-05 06:36:21Z remere $ 6 | 7 | #ifndef RME_JSON_H_ 8 | #define RME_JSON_H_ 9 | 10 | #include "json/json_spirit.h" 11 | 12 | namespace json { 13 | using namespace json_spirit; 14 | } 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /data/770/materials.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /source/extension_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_EXTENSION_WINDOW_H 6 | #define RME_EXTENSION_WINDOW_H 7 | 8 | class MaterialsExtension; 9 | 10 | class ExtensionsDialog : public wxDialog 11 | { 12 | public: 13 | ExtensionsDialog(wxWindow* parent); 14 | virtual ~ExtensionsDialog(); 15 | 16 | void OnClickOK(wxCommandEvent& evt); 17 | void OnClickOpenFolder(wxCommandEvent& evt); 18 | void OnClickLink(wxHtmlLinkEvent& evt); 19 | 20 | DECLARE_EVENT_TABLE(); 21 | 22 | private: 23 | wxString HTML() const; 24 | wxString HTMLForExtension(MaterialsExtension* me) const; 25 | }; 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /source/map_allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_MAP_ALLOCATOR_H 2 | #define RME_MAP_ALLOCATOR_H 3 | 4 | #include "tile.h" 5 | #include "map_region.h" 6 | 7 | class BaseMap; 8 | 9 | class MapAllocator 10 | { 11 | 12 | public: 13 | MapAllocator() {} 14 | ~MapAllocator() {} 15 | 16 | // shorthands for tiles 17 | Tile* operator()(TileLocation* location) { 18 | return allocateTile(location); 19 | } 20 | // free 21 | void operator()(Tile* t) { 22 | freeTile(t); 23 | } 24 | 25 | // 26 | Tile* allocateTile(TileLocation* location) { 27 | return newd Tile(*location); 28 | } 29 | void freeTile(Tile* t) { 30 | delete t; 31 | } 32 | 33 | // 34 | Floor* allocateFloor(int x, int y, int z) { 35 | return newd Floor(x, y, z); 36 | } 37 | void freeFloor(Floor* f) { 38 | delete f; 39 | } 40 | 41 | // 42 | QTreeNode* allocateNode(BaseMap& map) { 43 | return newd QTreeNode(map); 44 | } 45 | void freeNode(QTreeNode* qt) { 46 | delete qt; 47 | } 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /source/raw_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_RAW_BRUSH_H 2 | #define RME_RAW_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // RAWBrush, draw items like SimOne's editor 8 | 9 | class RAWBrush : public Brush { 10 | public: 11 | RAWBrush(uint16_t itemid); // Create a RAWBrush of the specified type 12 | virtual ~RAWBrush(); 13 | 14 | bool isRaw() const { return true; } 15 | RAWBrush* asRaw() { return static_cast(this); } 16 | 17 | virtual bool canDraw(BaseMap* map, const Position& position) const {return true;} 18 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 19 | virtual void undraw(BaseMap* map, Tile* tile); 20 | 21 | virtual bool canDrag() const {return true;} 22 | virtual int getLookID() const; 23 | virtual std::string getName() const; 24 | ItemType* getItemType() const {return itemtype;} 25 | uint16_t getItemID() const; 26 | protected: 27 | ItemType* itemtype; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /source/live_packets.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef LIVE_PACKETS_H 6 | #define LIVE_PACKETS_H 7 | 8 | 9 | enum LivePacketType 10 | { 11 | PACKET_HELLO_FROM_CLIENT = 0x10, 12 | PACKET_READY_CLIENT = 0x11, 13 | 14 | PACKET_REQUEST_NODES = 0x20, 15 | PACKET_CHANGE_LIST = 0x21, 16 | PACKET_ADD_HOUSE = 0x23, 17 | PACKET_EDIT_HOUSE = 0x24, 18 | PACKET_REMOVE_HOUSE = 0x25, 19 | 20 | PACKET_CLIENT_TALK = 0x30, 21 | PACKET_CLIENT_UPDATE_CURSOR = 0x31, 22 | 23 | PACKET_HELLO_FROM_SERVER = 0x80, 24 | PACKET_KICK = 0x81, 25 | PACKET_ACCEPTED_CLIENT = 0x82, 26 | PACKET_CHANGE_CLIENT_VERSION = 0x83, 27 | PACKET_SERVER_TALK = 0x84, 28 | 29 | PACKET_NODE = 0x90, 30 | PACKET_CURSOR_UPDATE = 0x91, 31 | PACKET_START_OPERATION = 0x92, 32 | PACKET_UPDATE_OPERATION = 0x93, 33 | PACKET_CHAT_MESSAGE = 0x94, 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /source/spawn_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_SPAWN_BRUSH_H 2 | #define RME_SPAWN_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // SpawnBrush, place spawns 8 | 9 | class SpawnBrush : public Brush { 10 | public: 11 | SpawnBrush(); // Create a RAWBrush of the specified type 12 | virtual ~SpawnBrush(); 13 | 14 | bool isSpawn() const { return true; } 15 | SpawnBrush* asSpawn() { return static_cast(this); } 16 | 17 | virtual bool canDraw(BaseMap* map, const Position& position) const; 18 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); // parameter is brush size 19 | virtual void undraw(BaseMap* map, Tile* tile); 20 | 21 | virtual int getLookID() const; // We don't have a look, sorry! 22 | virtual std::string getName() const; 23 | virtual bool canDrag() const {return true;} 24 | virtual bool canSmear() const {return false;} 25 | virtual bool oneSizeFitsAll() const {return true;} 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /source/extension.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_EXTENSION_H_ 6 | #define RME_EXTENSION_H_ 7 | 8 | #include "tileset.h" 9 | #include "client_version.h" 10 | 11 | class MaterialsExtension 12 | { 13 | public: 14 | MaterialsExtension(std::string name, std::string author, std::string description); 15 | ~MaterialsExtension(); 16 | 17 | void addVersion(const std::string& versionString); 18 | bool isForVersion(uint16_t versionId); 19 | std::string getVersionString(); 20 | 21 | std::string name; 22 | std::string url; 23 | std::string author; 24 | std::string author_url; 25 | std::string description; 26 | bool for_all_versions; 27 | ClientVersionList version_list; 28 | private: 29 | MaterialsExtension(const MaterialsExtension&); 30 | MaterialsExtension& operator=(const MaterialsExtension&); 31 | }; 32 | 33 | typedef std::vector MaterialsExtensionList; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /source/rme_forward_declarations.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_FORWARD_H 6 | #define RME_FORWARD_H 7 | 8 | class Map; 9 | class Tile; 10 | class TileLocation; 11 | class Item; 12 | class container; 13 | class Spawn; 14 | struct Outfit; 15 | class House; 16 | class Creature; 17 | class BaseMap; 18 | class Waypoint; 19 | class Waypoints; 20 | class Tileset; 21 | class Town; 22 | class Position; 23 | class Editor; 24 | class GUI; 25 | class Selection; 26 | class CopyBuffer; 27 | class ItemType; 28 | class Creatures; 29 | class ItemDatabase; 30 | class QTreeNode; 31 | class Floor; 32 | class Action; 33 | 34 | class Brush; 35 | 36 | #include 37 | 38 | typedef std::vector HouseExitList; 39 | typedef std::vector TileVector; 40 | typedef std::unordered_set TileSet; 41 | typedef std::vector ItemVector; 42 | typedef std::vector BrushVector; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /source/dcbutton.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_DC_BUTTON_H 6 | #define RME_DC_BUTTON_H 7 | 8 | class Sprite; 9 | class GameSprite; 10 | class EditorSprite; 11 | 12 | enum { 13 | DC_BTN_NORMAL, 14 | DC_BTN_TOGGLE, 15 | }; 16 | 17 | enum RenderSize { 18 | RENDER_SIZE_16x16, 19 | RENDER_SIZE_32x32, 20 | RENDER_SIZE_64x64, 21 | }; 22 | 23 | class DCButton : public wxPanel 24 | { 25 | public: 26 | DCButton(); 27 | DCButton(wxWindow* parent, wxWindowID id, wxPoint pos, int type, RenderSize sz, int sprite_id); 28 | virtual ~DCButton(); 29 | 30 | void SetValue(bool val); 31 | bool GetValue() const; 32 | 33 | void SetSprite(int id); 34 | 35 | void OnPaint(wxPaintEvent&); 36 | void OnClick(wxMouseEvent&); 37 | protected: 38 | void SetOverlay(Sprite* espr); 39 | 40 | int type; 41 | bool state; // pressed/unpressed 42 | RenderSize size; 43 | Sprite* sprite; 44 | Sprite* overlay; 45 | 46 | DECLARE_DYNAMIC_CLASS(DCButton) 47 | DECLARE_EVENT_TABLE() 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /source/creature_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_CREATURE_BRUSH_H 2 | #define RME_CREATURE_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // CreatureBrush, place creatures 8 | 9 | class CreatureBrush : public Brush 10 | { 11 | public: 12 | CreatureBrush(CreatureType* type); // Create a RAWBrush of the specified type 13 | virtual ~CreatureBrush(); 14 | 15 | bool isCreature() const { return true; } 16 | CreatureBrush* asCreature() { return static_cast(this); } 17 | 18 | virtual bool canDraw(BaseMap* map, const Position& position) const; 19 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 20 | virtual void undraw(BaseMap* map, Tile* tile); 21 | 22 | CreatureType* getType() const {return creature_type;} 23 | 24 | virtual int getLookID() const; // We don't have a look type, this will always return 0 25 | virtual std::string getName() const; 26 | virtual bool canDrag() const {return false;} 27 | virtual bool canSmear() const {return true;} 28 | virtual bool oneSizeFitsAll() const {return true;} 29 | protected: 30 | CreatureType* creature_type; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /source/waypoint_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "waypoint_brush.h" 8 | #include "waypoints.h" 9 | #include "basemap.h" 10 | 11 | //============================================================================= 12 | // Waypoint Brush 13 | 14 | WaypointBrush::WaypointBrush() : 15 | Brush() 16 | { 17 | //// 18 | } 19 | 20 | WaypointBrush::~WaypointBrush() 21 | { 22 | //// 23 | } 24 | 25 | void WaypointBrush::setWaypoint(Waypoint* wp) 26 | { 27 | if(wp) { 28 | waypoint_name = wp->name; 29 | } else { 30 | waypoint_name = ""; 31 | } 32 | } 33 | 34 | std::string WaypointBrush::getWaypoint() const 35 | { 36 | return waypoint_name; 37 | } 38 | 39 | bool WaypointBrush::canDraw(BaseMap* map, const Position& position) const 40 | { 41 | return map->getTile(position) != nullptr; 42 | } 43 | 44 | void WaypointBrush::undraw(BaseMap* map, Tile* tile) 45 | { 46 | // Never called 47 | ASSERT(false); 48 | } 49 | 50 | void WaypointBrush::draw(BaseMap* map, Tile* tile, void* parameter) 51 | { 52 | // Never called 53 | ASSERT(false); 54 | } 55 | -------------------------------------------------------------------------------- /source/mt_rand.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/mt_rand.h $ 18 | // $Id: mt_rand.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_MT_RAND_H_ 21 | #define RME_MT_RAND_H_ 22 | 23 | void mt_seed(unsigned long s); 24 | unsigned long mt_randi(); 25 | double mt_randd(); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /source/templatemap76-74.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/templatemap76-74.hpp $ 18 | // $Id: templatemap76-74.hpp 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #include "main.h" 21 | 22 | 23 | #include "templates.h" 24 | 25 | ConversionMap getReplacementMapFrom760To740() { 26 | ConversionMap replacement_map; 27 | return replacement_map; 28 | } 29 | -------------------------------------------------------------------------------- /source/materials.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_MATERIALS_H_ 6 | #define RME_MATERIALS_H_ 7 | 8 | #include "extension.h" 9 | 10 | class Materials { 11 | public: 12 | Materials(); 13 | ~Materials(); 14 | 15 | void clear(); 16 | 17 | const MaterialsExtensionList& getExtensions(); 18 | MaterialsExtensionList getExtensionsByVersion(uint16_t version_id); 19 | 20 | TilesetContainer tilesets; 21 | 22 | bool loadMaterials(const FileName& identifier, wxString& error, wxArrayString& warnings); 23 | bool loadExtensions(FileName identifier, wxString& error, wxArrayString& warnings); 24 | void createOtherTileset(); 25 | 26 | bool isInTileset(Item* item, std::string tileset) const; 27 | bool isInTileset(Brush* brush, std::string tileset) const; 28 | 29 | protected: 30 | bool unserializeMaterials(const FileName& filename, pugi::xml_node node, wxString& error, wxArrayString& warnings); 31 | bool unserializeTileset(pugi::xml_node node, wxArrayString& warnings); 32 | 33 | MaterialsExtensionList extensions; 34 | 35 | private: 36 | Materials(const Materials&); 37 | Materials& operator=(const Materials&); 38 | }; 39 | 40 | extern Materials g_materials; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /source/house_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_HOUSE_BRUSH_H 2 | #define RME_HOUSE_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // HouseBrush, draw house tiles 8 | // This brush is created on demand and NOT loaded, as such, the load() method is empty 9 | // Should be deleted by the owning palette 10 | 11 | // Forward declaration 12 | class HouseBrush : public Brush { 13 | public: 14 | HouseBrush(); 15 | virtual ~HouseBrush(); 16 | 17 | bool isHouse() const { return true; } 18 | HouseBrush* asHouse() { return static_cast(this); } 19 | 20 | // Not used 21 | virtual bool load(pugi::xml_node node, wxArrayString& warnings) {return true;} 22 | 23 | // You can always draw house tiles! 24 | virtual bool canDraw(BaseMap* map, const Position& position) const {return true;} 25 | // Draw the shit! 26 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 27 | // Undraw the shit! 28 | virtual void undraw(BaseMap* map, Tile* tile); 29 | 30 | virtual bool canDrag() const {return true;} 31 | 32 | void setHouse(House* house); 33 | 34 | uint32_t getHouseID() const; 35 | virtual int getLookID() const {return 0;} // We don't have a graphic 36 | virtual std::string getName() const {return "House Brush";} 37 | protected: 38 | House* draw_house; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /source/house_exit_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "house_exit_brush.h" 8 | #include "house.h" 9 | #include "basemap.h" 10 | 11 | //============================================================================= 12 | // House Exit Brush 13 | 14 | HouseExitBrush::HouseExitBrush() : 15 | Brush(), 16 | draw_house(0) 17 | { 18 | //// 19 | } 20 | 21 | HouseExitBrush::~HouseExitBrush() 22 | { 23 | //// 24 | } 25 | 26 | void HouseExitBrush::setHouse(House* house) 27 | { 28 | draw_house = house->id; 29 | } 30 | 31 | uint32_t HouseExitBrush::getHouseID() const 32 | { 33 | return draw_house; 34 | } 35 | 36 | 37 | bool HouseExitBrush::canDraw(BaseMap* map, const Position& position) const 38 | { 39 | Tile* tile = map->getTile(position); 40 | if(!tile || !tile->hasGround()) { 41 | return false; 42 | } 43 | if(tile->isHouseTile() || tile->isBlocking()) { 44 | return false; 45 | } 46 | return true; 47 | } 48 | 49 | void HouseExitBrush::undraw(BaseMap* map, Tile* tile) 50 | { 51 | // Never called 52 | ASSERT(false); 53 | } 54 | 55 | void HouseExitBrush::draw(BaseMap* map, Tile* tile, void* parameter) 56 | { 57 | // Never called 58 | ASSERT(false); 59 | } 60 | -------------------------------------------------------------------------------- /source/spawn_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "spawn_brush.h" 8 | #include "basemap.h" 9 | #include "spawn.h" 10 | 11 | //============================================================================= 12 | // Spawn brush 13 | 14 | SpawnBrush::SpawnBrush() : 15 | Brush() 16 | { 17 | //// 18 | } 19 | 20 | SpawnBrush::~SpawnBrush() 21 | { 22 | //// 23 | } 24 | 25 | int SpawnBrush::getLookID() const 26 | { 27 | return 0; 28 | } 29 | 30 | std::string SpawnBrush::getName() const 31 | { 32 | return "Spawn Brush"; 33 | } 34 | 35 | bool SpawnBrush::canDraw(BaseMap* map, const Position& position) const 36 | { 37 | Tile* tile = map->getTile(position); 38 | if(tile) { 39 | if(tile->spawn) { 40 | return false; 41 | } 42 | } 43 | return true; 44 | } 45 | 46 | void SpawnBrush::undraw(BaseMap* map, Tile* tile) 47 | { 48 | delete tile->spawn; 49 | tile->spawn = nullptr; 50 | } 51 | 52 | void SpawnBrush::draw(BaseMap* map, Tile* tile, void* parameter) 53 | { 54 | ASSERT(tile); 55 | ASSERT(parameter); // Should contain an int which is the size of the newd spawn 56 | if(tile->spawn == nullptr) { 57 | tile->spawn = newd Spawn(max(1, *(int*)parameter)); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /source/pugicast.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The Forgotten Server - a free and open-source MMORPG server emulator 3 | * Copyright (C) 2013 Mark Samman 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #ifndef FS_PUGICAST_H_07810DF7954D411EB14A16C3ED2A7548 21 | #define FS_PUGICAST_H_07810DF7954D411EB14A16C3ED2A7548 22 | 23 | #include 24 | 25 | namespace pugi { 26 | template 27 | T cast(const pugi::char_t* str) 28 | { 29 | T value; 30 | try { 31 | value = boost::lexical_cast(str); 32 | } catch (boost::bad_lexical_cast&) { 33 | value = T(); 34 | } 35 | return value; 36 | } 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /source/live_action.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef _RME_NETWORK_ACTION_H_ 6 | #define _RME_NETWORK_ACTION_H_ 7 | 8 | #include "action.h" 9 | 10 | class NetworkedActionQueue; 11 | 12 | class NetworkedAction : public Action { 13 | protected: 14 | NetworkedAction(Editor& editor, ActionIdentifier ident); 15 | ~NetworkedAction(); 16 | public: 17 | uint32_t owner; 18 | 19 | friend class NetworkedActionQueue; 20 | }; 21 | 22 | class NetworkedBatchAction : public BatchAction { 23 | NetworkedActionQueue& queue; 24 | protected: 25 | NetworkedBatchAction(Editor& editor, NetworkedActionQueue& queue, ActionIdentifier ident); 26 | ~NetworkedBatchAction(); 27 | 28 | public: 29 | void addAndCommitAction(Action* action); 30 | 31 | protected: 32 | void commit(); 33 | void undo(); 34 | void redo(); 35 | 36 | friend class NetworkedActionQueue; 37 | }; 38 | 39 | class NetworkedActionQueue : public ActionQueue { 40 | public: 41 | NetworkedActionQueue(Editor& editor); 42 | ~NetworkedActionQueue(); 43 | 44 | Action* createAction(ActionIdentifier ident); 45 | BatchAction* createBatch(ActionIdentifier ident); 46 | 47 | protected: 48 | void broadcast(DirtyList& dirty_list); 49 | 50 | friend class NetworkedBatchAction; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /source/waypoint_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_WAYPOINT_BRUSH_H 2 | #define RME_WAYPOINT_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // WaypointBrush, draws waypoints simply 8 | // This doesn't actually draw anything, and the draw/undraw functions will ASSERT if 9 | // you try to call them, so I strongly advice against it 10 | 11 | class WaypointBrush : public Brush { 12 | public: 13 | WaypointBrush(); 14 | virtual ~WaypointBrush(); 15 | 16 | bool isWaypoint() const { return true; } 17 | WaypointBrush* asWaypoint() { return static_cast(this); } 18 | 19 | // Not used 20 | virtual bool load(pugi::xml_node node, wxArrayString& warnings) {return true;} 21 | 22 | virtual bool canDraw(BaseMap* map, const Position& position) const; 23 | // Will ASSERT 24 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 25 | virtual void undraw(BaseMap* map, Tile* tile); 26 | 27 | virtual bool canDrag() const {return false;} 28 | virtual bool canSmear() const {return false;} 29 | virtual bool oneSizeFitsAll() const {return true;} 30 | 31 | std::string getWaypoint() const; 32 | void setWaypoint(Waypoint* wp); 33 | virtual int getLookID() const {return 0;} // We don't have a graphic 34 | virtual std::string getName() const {return "Waypoint Brush";} 35 | protected: 36 | std::string waypoint_name; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /source/house_exit_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_HOUSE_EXIT_BRUSH_H 2 | #define RME_HOUSE_EXIT_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // HouseExitBrush, draw house exit tiles 8 | // This doesn't actually draw anything, and the draw/undraw functions will ASSERT if 9 | // you try to call them, so I strongly advice against it 10 | 11 | class HouseExitBrush : public Brush { 12 | public: 13 | HouseExitBrush(); 14 | virtual ~HouseExitBrush(); 15 | 16 | bool isHouseExit() const { return true; } 17 | HouseExitBrush* asHouseExit() { return static_cast(this); } 18 | 19 | // Not used 20 | virtual bool load(pugi::xml_node node, wxArrayString& warnings) {return true;} 21 | 22 | virtual bool canDraw(BaseMap* map, const Position& position) const; 23 | // Will ASSERT 24 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 25 | virtual void undraw(BaseMap* map, Tile* tile); 26 | 27 | virtual bool canDrag() const {return false;} 28 | virtual bool canSmear() const {return false;} 29 | virtual bool oneSizeFitsAll() const {return true;} 30 | 31 | void setHouse(House* house); 32 | 33 | uint32_t getHouseID() const; 34 | virtual int getLookID() const {return 0;} // We don't have a graphic 35 | virtual std::string getName() const {return "House Exit Brush";} // We don't have a name 36 | protected: 37 | uint32_t draw_house; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /source/container_properties_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef _RME_CONTAINER_PROPS_H_ 6 | #define _RME_CONTAINER_PROPS_H_ 7 | 8 | #include "common_windows.h" 9 | 10 | class Container; 11 | class ContainerItemButton; 12 | 13 | // Right-click popup menu 14 | class ContainerItemPopupMenu : public wxMenu { 15 | public: 16 | ContainerItemPopupMenu(); 17 | virtual ~ContainerItemPopupMenu(); 18 | 19 | void Update(ContainerItemButton* what); 20 | }; 21 | 22 | // Container Item Button 23 | class ContainerItemButton : public ItemButton 24 | { 25 | DECLARE_EVENT_TABLE() 26 | public: 27 | ContainerItemButton(wxWindow* parent, bool large, int index, const Map* map, Item* item); 28 | ~ContainerItemButton(); 29 | 30 | void OnMouseDoubleLeftClick(wxMouseEvent& event); 31 | void OnMouseRightRelease(wxMouseEvent& event); 32 | 33 | void OnAddItem(wxCommandEvent& event); 34 | void OnEditItem(wxCommandEvent& event); 35 | void OnRemoveItem(wxCommandEvent& event); 36 | 37 | ObjectPropertiesWindowBase* getParentContainerWindow(); 38 | Container* getParentContainer(); 39 | 40 | void setItem(Item* item); 41 | 42 | private: 43 | static std::unique_ptr popup_menu; 44 | 45 | const Map* edit_map; 46 | Item* edit_item; 47 | 48 | size_t index; 49 | 50 | friend class ContainerItemPopupMenu; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /source/net_connection.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _RME_NET_CONNECTION_H_ 3 | #define _RME_NET_CONNECTION_H_ 4 | 5 | #include "position.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct NetworkMessage 14 | { 15 | NetworkMessage(); 16 | 17 | void clear(); 18 | void expand(const size_t length); 19 | 20 | // 21 | template T read() 22 | { 23 | T& value = *reinterpret_cast(&buffer[position]); 24 | position += sizeof(T); 25 | return value; 26 | } 27 | 28 | template void write(const T& value) 29 | { 30 | expand(sizeof(T)); 31 | memcpy(&buffer[position], &value, sizeof(T)); 32 | position += sizeof(T); 33 | } 34 | 35 | // 36 | std::vector buffer; 37 | size_t position; 38 | size_t size; 39 | }; 40 | 41 | template<> std::string NetworkMessage::read(); 42 | template<> Position NetworkMessage::read(); 43 | template<> void NetworkMessage::write(const std::string& value); 44 | template<> void NetworkMessage::write(const Position& value); 45 | 46 | class NetworkConnection 47 | { 48 | private: 49 | NetworkConnection(); 50 | NetworkConnection(const NetworkConnection& copy) = delete; 51 | 52 | public: 53 | ~NetworkConnection(); 54 | 55 | static NetworkConnection& getInstance(); 56 | 57 | bool start(); 58 | void stop(); 59 | 60 | boost::asio::io_service& get_service(); 61 | 62 | private: 63 | boost::asio::io_service* service; 64 | std::thread thread; 65 | bool stopped; 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /source/outfit.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/outfit.h $ 18 | // $Id: outfit.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_OUTFIT_H_ 21 | #define RME_OUTFIT_H_ 22 | 23 | struct Outfit { 24 | Outfit() : lookType(0), lookItem(0), lookAddon(0), lookHead(0), lookBody(0), lookLegs(0), lookFeet(0) {} 25 | ~Outfit() {} 26 | int lookType; 27 | int lookItem; 28 | int lookAddon; 29 | int lookHead; 30 | int lookBody; 31 | int lookLegs; 32 | int lookFeet; 33 | 34 | uint32_t getColorHash() const { 35 | return lookHead << 24 | lookBody << 16 | lookLegs << 8 | lookFeet; 36 | } 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /source/live_tab.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef _RME_LIVE_TAB_H_ 7 | #define _RME_LIVE_TAB_H_ 8 | 9 | #include "main.h" 10 | 11 | #include "editor_tabs.h" 12 | #include "application.h" 13 | #include "live_server.h" 14 | 15 | class wxGrid; 16 | 17 | class MapTabbook; 18 | class LiveSocket; 19 | class LiveServer; 20 | 21 | class LiveLogTab : public EditorTab, public wxPanel { 22 | public: 23 | LiveLogTab(MapTabbook* aui, LiveSocket* socket); 24 | ~LiveLogTab(); 25 | 26 | void Message(const wxString& str); 27 | void Chat(const wxString& speaker, const wxString& str); 28 | 29 | virtual wxWindow* GetWindow() const {return (wxPanel*)this;} 30 | virtual wxString GetTitle() const; 31 | 32 | bool IsConnected() const {return socket != nullptr;} 33 | void Disconnect(); 34 | 35 | LiveSocket* GetSocket() {return socket;} 36 | 37 | void UpdateClientList(const std::unordered_map& updatedClients); 38 | 39 | void OnSelectChatbox(wxFocusEvent& evt); 40 | void OnDeselectChatbox(wxFocusEvent& evt); 41 | 42 | void OnChat(wxCommandEvent& evt); 43 | void OnResizeChat(wxSizeEvent& evt); 44 | void OnResizeClientList(wxSizeEvent& evt); 45 | 46 | protected: 47 | MapTabbook* aui; 48 | LiveSocket* socket; 49 | wxGrid* log; 50 | wxTextCtrl* input; 51 | wxGrid* user_list; 52 | 53 | std::unordered_map clients; 54 | 55 | DECLARE_EVENT_TABLE(); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /source/table_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_TABLE_BRUSH_H 2 | #define RME_TABLE_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // Tablebrush, for tables, and some things that behave like tables 8 | // and with tables I really mean counters. 9 | 10 | class TableBrush : public Brush 11 | { 12 | public: 13 | static void init(); 14 | 15 | TableBrush(); 16 | virtual ~TableBrush(); 17 | 18 | bool isTable() const { return true; } 19 | TableBrush* asTable() { return static_cast(this); } 20 | 21 | virtual bool load(pugi::xml_node node, wxArrayString& warnings); 22 | 23 | virtual bool canDraw(BaseMap* map, const Position& position) const; 24 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 25 | virtual void undraw(BaseMap* map, Tile* tile); 26 | 27 | static void doTables(BaseMap* map, Tile* tile); 28 | 29 | virtual int getLookID() const { return look_id; } 30 | 31 | virtual std::string getName() const { return name; } 32 | virtual void setName(const std::string& newName) { name = newName; } 33 | 34 | virtual bool needBorders() const {return true;} 35 | protected: 36 | struct TableType 37 | { 38 | TableType() : chance(0), item_id(0) {} 39 | int chance; 40 | uint16_t item_id; 41 | }; 42 | 43 | struct TableNode 44 | { 45 | TableNode() : total_chance(0) {} 46 | int total_chance; 47 | std::vector items; 48 | }; 49 | 50 | std::string name; 51 | uint16_t look_id; 52 | TableNode table_items[7]; 53 | 54 | static uint32_t table_types[256]; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /source/about_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/about_window.h $ 18 | // $Id: about_window.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_ABOUT_WINDOW_H_ 21 | #define RME_ABOUT_WINDOW_H_ 22 | 23 | #include "main.h" 24 | 25 | class GamePanel; 26 | 27 | class AboutWindow : public wxDialog { 28 | public: 29 | AboutWindow(wxWindow* parent); 30 | ~AboutWindow(); 31 | 32 | void OnClickOK(wxCommandEvent&); 33 | void OnClickLicense(wxCommandEvent&); 34 | 35 | void OnTetris(wxCommandEvent&); 36 | void OnSnake(wxCommandEvent&); 37 | private: 38 | wxSizer* topsizer; 39 | GamePanel* game_panel; 40 | 41 | DECLARE_EVENT_TABLE() 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /source/templates.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/templates.h $ 18 | // $Id: templates.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_MAP_TEMPLATES_H_ 21 | #define RME_MAP_TEMPLATES_H_ 22 | 23 | #include "common.h" 24 | 25 | struct ConversionMap { 26 | // Many to Many 27 | typedef std::map, std::vector > MTM; 28 | // Single to Many 29 | typedef std::map > STM; 30 | 31 | MTM mtm; 32 | STM stm; 33 | }; 34 | 35 | ConversionMap getReplacementMapFrom800To810(); 36 | ConversionMap getReplacementMapFrom760To740(); 37 | ConversionMap getReplacementMapFrom854To854(); 38 | ConversionMap getReplacementMapClassic(); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /source/result_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/result_window.h $ 18 | // $Id: result_window.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_RESULT_WINDOW_H_ 21 | #define RME_RESULT_WINDOW_H_ 22 | 23 | #include "main.h" 24 | 25 | class SearchResultWindow : public wxPanel 26 | { 27 | public: 28 | SearchResultWindow(wxWindow* parent); 29 | virtual ~SearchResultWindow(); 30 | 31 | void Clear(); 32 | void AddPosition(wxString description, Position pos); 33 | 34 | void OnClickResult(wxCommandEvent&); 35 | void OnClickExport(wxCommandEvent&); 36 | void OnClickClear(wxCommandEvent&); 37 | 38 | protected: 39 | wxListBox* result_list; 40 | 41 | DECLARE_EVENT_TABLE() 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /source/browse_tile_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef RME_BROWSE_TILE_WINDOW_H_ 19 | #define RME_BROWSE_TILE_WINDOW_H_ 20 | 21 | #include "main.h" 22 | #include "map.h" 23 | #include "tile.h" 24 | 25 | class BrowseTileListBox; 26 | 27 | class BrowseTileWindow : public wxDialog 28 | { 29 | public: 30 | BrowseTileWindow(wxWindow* parent, Tile* tile, wxPoint position = wxDefaultPosition); 31 | ~BrowseTileWindow(); 32 | 33 | void OnClickDelete(wxCommandEvent&); 34 | void OnClickSelectRaw(wxCommandEvent&); 35 | void OnClickOK(wxCommandEvent&); 36 | void OnClickCancel(wxCommandEvent&); 37 | 38 | protected: 39 | BrowseTileListBox* item_list; 40 | wxStaticText* item_count_txt; 41 | 42 | DECLARE_EVENT_TABLE(); 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /source/iomap.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/iomap.hpp $ 18 | // $Id: iomap.hpp 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #include "main.h" 21 | #include "gui.h" 22 | 23 | void IOMap::error(const wxString format, ...) 24 | { 25 | va_list argp; 26 | va_start(argp, format); 27 | errorstr.PrintfV(format, argp); 28 | va_end(argp); 29 | }; 30 | 31 | void IOMap::warning(const wxString format, ...) 32 | { 33 | wxString s; 34 | va_list argp; 35 | va_start(argp, format); 36 | s.PrintfV(format, argp); 37 | va_end(argp); 38 | warnings.push_back(s); 39 | }; 40 | 41 | bool IOMap::queryUser(const wxString& title, const wxString& text) 42 | { 43 | return g_gui.PopupDialog(title, text, wxYES | wxNO) == wxID_YES; 44 | } 45 | -------------------------------------------------------------------------------- /source/properties_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_PROPERTIES_WINDOW_H_ 6 | #define RME_PROPERTIES_WINDOW_H_ 7 | 8 | #include "main.h" 9 | 10 | #include "common_windows.h" 11 | 12 | class ContainerItemButton; 13 | class ContainerItemPopupMenu; 14 | class ItemAttribute; 15 | 16 | class PropertiesWindow : public ObjectPropertiesWindowBase 17 | { 18 | public: 19 | PropertiesWindow(wxWindow* parent, const Map* map, const Tile* tile, Item* item, wxPoint position = wxDefaultPosition); 20 | ~PropertiesWindow(); 21 | 22 | void OnClickOK(wxCommandEvent&); 23 | void OnClickCancel(wxCommandEvent&); 24 | void OnClickAddAttribute(wxCommandEvent&); 25 | void OnClickRemoveAttribute(wxCommandEvent&); 26 | 27 | void OnResize(wxSizeEvent&); 28 | void OnNotebookPageChanged(wxNotebookEvent&); 29 | void OnGridValueChanged(wxGridEvent&); 30 | 31 | void Update(); 32 | 33 | protected: 34 | // Simple pane 35 | wxWindow* createGeneralPanel(wxWindow* parent); 36 | void saveGeneralPanel(); 37 | 38 | // Container pane 39 | std::vector container_items; 40 | wxWindow* createContainerPanel(wxWindow* parent); 41 | void saveContainerPanel(); 42 | 43 | // Advanced pane 44 | wxGrid* attributesGrid; 45 | wxWindow* createAttributesPanel(wxWindow *parent); 46 | void saveAttributesPanel(); 47 | void SetGridValue(wxGrid* grid, int rowIndex, std::string name, const ItemAttribute& attr); 48 | 49 | protected: 50 | wxNotebook* notebook; 51 | wxWindow* currentPanel; 52 | 53 | DECLARE_EVENT_TABLE() 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /source/carpet_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_CARPET_BRUSH_H 2 | #define RME_CARPET_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // Carpetbrush, for tables, and some things that behave like tables 8 | // and with tables I really mean counters. 9 | 10 | class CarpetBrush : public Brush 11 | { 12 | public: 13 | static void init(); 14 | 15 | CarpetBrush(); 16 | virtual ~CarpetBrush(); 17 | 18 | bool isCarpet() const { return true; } 19 | CarpetBrush* asCarpet() { return static_cast(this); } 20 | 21 | virtual bool load(pugi::xml_node node, wxArrayString& warnings); 22 | 23 | virtual bool canDraw(BaseMap* map, const Position& position) const; 24 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 25 | virtual void undraw(BaseMap* map, Tile* tile); 26 | 27 | static void doCarpets(BaseMap* map, Tile* tile); 28 | 29 | virtual bool canDrag() const { return true; } 30 | virtual bool needBorders() const { return true; } 31 | 32 | virtual int getLookID() const { return look_id; } 33 | 34 | virtual std::string getName() const { return name; } 35 | virtual void setName(const std::string& newName) { name = newName; } 36 | 37 | protected: 38 | uint16_t getRandomCarpet(BorderType alignment); 39 | 40 | struct CarpetType { 41 | int32_t chance; 42 | uint16_t id; 43 | }; 44 | 45 | struct CarpetNode { 46 | std::vector items; 47 | int32_t total_chance; 48 | 49 | CarpetNode() : 50 | items(), total_chance(0) {} 51 | }; 52 | 53 | CarpetNode carpet_items[14]; 54 | std::string name; 55 | uint16_t look_id; 56 | 57 | static uint32_t carpet_types[256]; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /source/threads.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/threads.h $ 18 | // $Id: threads.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_THREAD_H_ 21 | #define RME_THREAD_H_ 22 | 23 | #include "main.h" 24 | 25 | class Thread : public wxThread { 26 | public: 27 | Thread(wxThreadKind); 28 | 29 | void Execute(); // Calls "Create" and then "Run" 30 | }; 31 | 32 | class JoinableThread : public Thread { 33 | public: 34 | JoinableThread() : Thread(wxTHREAD_JOINABLE) {} 35 | }; 36 | 37 | class DetachedThread : public Thread { 38 | public: 39 | DetachedThread() : Thread(wxTHREAD_DETACHED) {} 40 | }; 41 | 42 | inline Thread::Thread(wxThreadKind kind) : wxThread(kind) {} 43 | 44 | inline void Thread::Execute() { 45 | Create(); 46 | Run(); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /source/minimap_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/minimap_window.h $ 18 | // $Id: minimap_window.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_MINIMAP_WINDOW_H_ 21 | #define RME_MINIMAP_WINDOW_H_ 22 | 23 | class MinimapWindow : public wxPanel { 24 | public: 25 | MinimapWindow(wxWindow* parent); 26 | virtual ~MinimapWindow(); 27 | 28 | void OnPaint(wxPaintEvent&); 29 | void OnEraseBackground(wxEraseEvent&) {} 30 | void OnMouseClick(wxMouseEvent&); 31 | void OnSize(wxSizeEvent&); 32 | void OnClose(wxCloseEvent&); 33 | 34 | void DelayedUpdate(); 35 | void OnDelayedUpdate(wxTimerEvent& event); 36 | void OnKey(wxKeyEvent& event); 37 | protected: 38 | wxPen* pens[256]; 39 | wxTimer update_timer; 40 | int last_start_x; 41 | int last_start_y; 42 | 43 | DECLARE_EVENT_TABLE() 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /source/json/json_spirit_error_position.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_ERROR_POSITION 2 | #define JSON_SPIRIT_ERROR_POSITION 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include 14 | 15 | namespace json_spirit 16 | { 17 | // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. 18 | // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" 19 | // functions that return a bool. 20 | // 21 | struct Error_position : std::runtime_error 22 | { 23 | Error_position(); 24 | Error_position( unsigned int line, unsigned int column, const std::string& reason ); 25 | bool operator==( const Error_position& lhs ) const; 26 | unsigned int line_; 27 | unsigned int column_; 28 | std::string reason_; 29 | }; 30 | 31 | inline Error_position::Error_position() 32 | : std::runtime_error("Error_position") 33 | , line_( 0 ) 34 | , column_( 0 ) 35 | { 36 | } 37 | 38 | inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) 39 | : std::runtime_error("Error_position") 40 | , line_( line ) 41 | , column_( column ) 42 | , reason_( reason ) 43 | { 44 | } 45 | 46 | inline bool Error_position::operator==( const Error_position& lhs ) const 47 | { 48 | if( this == &lhs ) return true; 49 | 50 | return ( reason_ == lhs.reason_ ) && 51 | ( line_ == lhs.line_ ) && 52 | ( column_ == lhs.column_ ); 53 | } 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /source/json/json_spirit_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_UTILS 2 | #define JSON_SPIRIT_UTILS 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include 15 | 16 | namespace json_spirit 17 | { 18 | template< class Obj_t, class Map_t > 19 | void obj_to_map( const Obj_t& obj, Map_t& mp_obj ) 20 | { 21 | mp_obj.clear(); 22 | 23 | for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i ) 24 | { 25 | mp_obj[ i->name_ ] = i->value_; 26 | } 27 | } 28 | 29 | template< class Obj_t, class Map_t > 30 | void map_to_obj( const Map_t& mp_obj, Obj_t& obj ) 31 | { 32 | obj.clear(); 33 | 34 | for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i ) 35 | { 36 | obj.push_back( typename Obj_t::value_type( i->first, i->second ) ); 37 | } 38 | } 39 | 40 | typedef std::map< std::string, Value > Mapped_obj; 41 | 42 | #ifndef BOOST_NO_STD_WSTRING 43 | typedef std::map< std::wstring, wValue > wMapped_obj; 44 | #endif 45 | 46 | template< class Object_type, class String_type > 47 | const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name ) 48 | { 49 | for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i ) 50 | { 51 | if( i->name_ == name ) 52 | { 53 | return i->value_; 54 | } 55 | } 56 | 57 | return Object_type::value_type::Value_type::null; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /source/json/json_spirit_writer.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_WRITER 2 | #define JSON_SPIRIT_WRITER 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include 15 | 16 | namespace json_spirit 17 | { 18 | // functions to convert JSON Values to text, 19 | // the "formatted" versions add whitespace to format the output nicely 20 | 21 | void write ( const Value& value, std::ostream& os ); 22 | void write_formatted( const Value& value, std::ostream& os ); 23 | std::string write ( const Value& value ); 24 | std::string write_formatted( const Value& value ); 25 | 26 | #ifndef BOOST_NO_STD_WSTRING 27 | 28 | void write ( const wValue& value, std::wostream& os ); 29 | void write_formatted( const wValue& value, std::wostream& os ); 30 | std::wstring write ( const wValue& value ); 31 | std::wstring write_formatted( const wValue& value ); 32 | 33 | #endif 34 | 35 | void write ( const mValue& value, std::ostream& os ); 36 | void write_formatted( const mValue& value, std::ostream& os ); 37 | std::string write ( const mValue& value ); 38 | std::string write_formatted( const mValue& value ); 39 | 40 | #ifndef BOOST_NO_STD_WSTRING 41 | 42 | void write ( const wmValue& value, std::wostream& os ); 43 | void write_formatted( const wmValue& value, std::wostream& os ); 44 | std::wstring write ( const wmValue& value ); 45 | std::wstring write_formatted( const wmValue& value ); 46 | 47 | #endif 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /source/live_server.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef _RME_LIVE_SERVER_H_ 7 | #define _RME_LIVE_SERVER_H_ 8 | 9 | #include "live_socket.h" 10 | #include "net_connection.h" 11 | #include "action.h" 12 | 13 | class LivePeer; 14 | class LiveLogTab; 15 | class QTreeNode; 16 | 17 | class LiveServer : public LiveSocket 18 | { 19 | public: 20 | LiveServer(Editor& editor); 21 | ~LiveServer(); 22 | 23 | // 24 | bool bind(); 25 | void close(); 26 | 27 | void acceptClient(); 28 | void removeClient(uint32_t id); 29 | 30 | // 31 | void receiveHeader() {} 32 | void receive(uint32_t packetSize) {} 33 | void send(NetworkMessage& message) {} 34 | 35 | // 36 | void updateCursor(const Position& position); 37 | void updateClientList() const; 38 | 39 | // 40 | LiveLogTab* createLogWindow(wxWindow* parent); 41 | 42 | // 43 | uint16_t getPort() const; 44 | bool setPort(int32_t newPort); 45 | 46 | Editor* getEditor() const { 47 | return editor; 48 | } 49 | 50 | uint32_t getFreeClientId(); 51 | std::string getHostName() const; 52 | 53 | // 54 | void broadcastNodes(DirtyList& dirtyList); 55 | void broadcastChat(const wxString& speaker, const wxString& chatMessage); 56 | void broadcastCursor(const LiveCursor& cursor); 57 | 58 | void startOperation(const wxString& operationMessage); 59 | void updateOperation(int32_t percent); 60 | 61 | protected: 62 | std::unordered_map clients; 63 | 64 | std::shared_ptr acceptor; 65 | std::shared_ptr socket; 66 | 67 | Editor* editor; 68 | 69 | uint32_t clientIds; 70 | uint16_t port; 71 | 72 | bool stopped; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /source/copybuffer.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/copybuffer.h $ 18 | // $Id: copybuffer.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_COPYBUFFER_H_ 21 | #define RME_COPYBUFFER_H_ 22 | 23 | #include 24 | 25 | #include "position.h" 26 | #include "basemap.h" 27 | 28 | class Editor; 29 | 30 | class CopyBuffer 31 | { 32 | public: 33 | CopyBuffer(); 34 | virtual ~CopyBuffer(); 35 | 36 | // In-editor implantation 37 | void copy(Editor& editor, int floor); 38 | void cut(Editor& editor, int floor); 39 | void paste(Editor& editor, const Position& toPosition); 40 | bool canPaste() const; 41 | // Returns the upper-left corner of the copybuffer 42 | Position getPosition() const; 43 | 44 | // Clears the copybuffer (eg. resets it) 45 | void clear(); 46 | 47 | size_t GetTileCount(); 48 | 49 | BaseMap& getBufferMap(); 50 | private: 51 | Position copyPos; 52 | BaseMap* tiles; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/process_com.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/process_com.h $ 18 | // $Id: process_com.h 310 2010-02-26 18:03:48Z admin $ 19 | 20 | 21 | #ifdef _USE_PROCESS_COM 22 | 23 | #ifndef RME_PROCESS_COMMUNICATION_H_ 24 | #define RME_PROCESS_COMMUNICATION_H_ 25 | 26 | #include "wx/ipc.h" 27 | 28 | class RMEProcessConnection : public wxConnection { 29 | public: 30 | RMEProcessConnection(); 31 | ~RMEProcessConnection(); 32 | 33 | bool OnExec(const wxString& topic, const wxString& fileName); 34 | }; 35 | 36 | class RMEProcessServer : public wxServer { 37 | public: 38 | RMEProcessServer(); 39 | ~RMEProcessServer(); 40 | 41 | wxConnectionBase* OnAcceptConnection(const wxString& topic); 42 | }; 43 | 44 | class RMEProcessClient : public wxClient { 45 | wxConnectionBase* proc; 46 | public: 47 | RMEProcessClient(); 48 | ~RMEProcessClient(); 49 | 50 | wxConnectionBase* OnMakeConnection(); 51 | }; 52 | 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/old_properties_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_OLD_PROPERTIES_WINDOW_H_ 6 | #define RME_OLD_PROPERTIES_WINDOW_H_ 7 | 8 | #include "main.h" 9 | 10 | #include "common_windows.h" 11 | 12 | class ContainerItemButton; 13 | class ContainerItemPopupMenu; 14 | 15 | class OldPropertiesWindow : public ObjectPropertiesWindowBase 16 | { 17 | public: 18 | OldPropertiesWindow(wxWindow* parent, const Map* map, const Tile* tile, Item* item, wxPoint = wxDefaultPosition); 19 | OldPropertiesWindow(wxWindow* parent, const Map* map, const Tile* tile, Creature* creature, wxPoint = wxDefaultPosition); 20 | OldPropertiesWindow(wxWindow* parent, const Map* map, const Tile* tile, Spawn* spawn, wxPoint = wxDefaultPosition); 21 | virtual ~OldPropertiesWindow(); 22 | 23 | void OnFocusChange(wxFocusEvent&); 24 | 25 | void OnClickOK(wxCommandEvent&); 26 | void OnClickCancel(wxCommandEvent&); 27 | 28 | void Update(); 29 | 30 | protected: 31 | 32 | protected: 33 | wxSpinCtrl* keynumber_field; 34 | wxSpinCtrl* doorlevel_field; 35 | wxSpinCtrl* keyholenumber_field; 36 | wxSpinCtrl* doorquestnumber_field; 37 | wxSpinCtrl* doorquestvalue_field; 38 | wxSpinCtrl* chestquestnumber_field; 39 | 40 | wxSpinCtrl* count_field; 41 | wxChoice* direction_field; 42 | wxSpinCtrl* action_id_field; 43 | wxSpinCtrl* unique_id_field; 44 | wxSpinCtrl* door_id_field; 45 | wxChoice* depot_id_field; 46 | wxSpinCtrl* x_field; 47 | wxSpinCtrl* y_field; 48 | wxSpinCtrl* z_field; 49 | wxChoice* splash_type_field; 50 | wxTextCtrl* text_field; 51 | wxTextCtrl* description_field; 52 | std::vector container_items; 53 | 54 | friend class ContainerItemButton; 55 | friend class ContainerItemPopupMenu; 56 | 57 | DECLARE_EVENT_TABLE(); 58 | }; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /source/spawn.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/spawn.hpp $ 18 | // $Id: spawn.hpp 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #include "main.h" 21 | 22 | #include "tile.h" 23 | #include "spawn.h" 24 | 25 | Spawns::Spawns() 26 | { 27 | //// 28 | } 29 | 30 | Spawns::~Spawns() 31 | { 32 | //// 33 | } 34 | 35 | void Spawns::addSpawn(Tile* tile) 36 | { 37 | ASSERT(tile->spawn); 38 | 39 | auto it = spawns.insert(tile->getPosition()); 40 | ASSERT(it.second); 41 | } 42 | 43 | void Spawns::removeSpawn(Tile* tile) { 44 | ASSERT(tile->spawn); 45 | spawns.erase(tile->getPosition()); 46 | #if 0 47 | SpawnPositionList::iterator iter = begin(); 48 | while(iter != end()) { 49 | if(*iter == tile->getPosition()) { 50 | spawns.erase(iter); 51 | return; 52 | } 53 | ++iter; 54 | } 55 | ASSERT(false); 56 | #endif 57 | } 58 | 59 | std::ostream& operator<<(std::ostream& os, const Spawn& spawn) { 60 | os << &spawn << ":: -> " << spawn.getSize() << std::endl; 61 | return os; 62 | } 63 | -------------------------------------------------------------------------------- /source/extension.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "extension.h" 8 | 9 | MaterialsExtension::MaterialsExtension(std::string name, std::string author, std::string description) : 10 | name(name), 11 | author(author), 12 | description(description), 13 | for_all_versions(false) 14 | { 15 | //// 16 | } 17 | 18 | MaterialsExtension::~MaterialsExtension() 19 | { 20 | //// 21 | } 22 | 23 | void MaterialsExtension::addVersion(const std::string& versionString) 24 | { 25 | if(versionString == "all") { 26 | for_all_versions = true; 27 | } else { 28 | ClientVersion* client = ClientVersion::get(versionString); 29 | if(client) { 30 | ClientVersionList supported_versions = ClientVersion::getAllVersionsSupportedForClientVersion(client); 31 | version_list.insert(version_list.end(), supported_versions.begin(), supported_versions.end()); 32 | } 33 | } 34 | } 35 | 36 | bool MaterialsExtension::isForVersion(uint16_t versionId) 37 | { 38 | if(for_all_versions) { 39 | return true; 40 | } 41 | 42 | for(ClientVersion* version : version_list) { 43 | if(version->getID() == versionId) { 44 | return true; 45 | } 46 | } 47 | return false; 48 | } 49 | 50 | std::string MaterialsExtension::getVersionString() 51 | { 52 | if(for_all_versions) { 53 | return "All"; 54 | } 55 | 56 | std::string versions; 57 | std::string last; 58 | for(ClientVersion* version : version_list) { 59 | if(!last.empty()) { 60 | if(!versions.empty()) { 61 | versions += ", " + last; 62 | } else { 63 | versions = last; 64 | } 65 | } 66 | last = version->getName(); 67 | } 68 | 69 | if(!last.empty()) { 70 | if(!versions.empty()) { 71 | versions += " and " + last; 72 | } else { 73 | versions = last; 74 | } 75 | } else { 76 | return "None"; 77 | } 78 | return versions; 79 | } 80 | -------------------------------------------------------------------------------- /source/positionctrl.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef _RME_POSITION_CTRL_H_ 19 | #define _RME_POSITION_CTRL_H_ 20 | 21 | #include "numbertextctrl.h" 22 | 23 | class PositionCtrl : public wxStaticBoxSizer 24 | { 25 | public: 26 | PositionCtrl(wxWindow* parent, const wxString& label, int x, int y, int z, 27 | int maxx = MAP_MAX_WIDTH, int maxy = MAP_MAX_HEIGHT, int maxz = MAP_MAX_LAYER); 28 | ~PositionCtrl(); 29 | 30 | long GetX() const { return x_field->GetIntValue(); } 31 | long GetY() const { return y_field->GetIntValue(); } 32 | long GetZ() const { return z_field->GetIntValue(); } 33 | Position GetPosition() const; 34 | 35 | void SetX(long value) { x_field->SetIntValue(value); } 36 | void SetY(long value) { y_field->SetIntValue(value); } 37 | void SetZ(long value) { z_field->SetIntValue(value); } 38 | void SetPosition(Position pos); 39 | 40 | bool Enable(bool enable = true); 41 | 42 | void OnClipboardText(wxClipboardTextEvent&); 43 | 44 | protected: 45 | NumberTextCtrl* x_field; 46 | NumberTextCtrl* y_field; 47 | NumberTextCtrl* z_field; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /source/json/json_spirit_stream_reader.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_READ_STREAM 2 | #define JSON_SPIRIT_READ_STREAM 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_reader_template.h" 14 | 15 | namespace json_spirit 16 | { 17 | // these classes allows you to read multiple top level contiguous values from a stream, 18 | // the normal stream read functions have a bug that prevent multiple top level values 19 | // from being read unless they are separated by spaces 20 | 21 | template< class Istream_type, class Value_type > 22 | class Stream_reader 23 | { 24 | public: 25 | 26 | Stream_reader( Istream_type& is ) 27 | : iters_( is ) 28 | { 29 | } 30 | 31 | bool read_next( Value_type& value ) 32 | { 33 | return read_range( iters_.begin_, iters_.end_, value ); 34 | } 35 | 36 | private: 37 | 38 | typedef Multi_pass_iters< Istream_type > Mp_iters; 39 | 40 | Mp_iters iters_; 41 | }; 42 | 43 | template< class Istream_type, class Value_type > 44 | class Stream_reader_thrower 45 | { 46 | public: 47 | 48 | Stream_reader_thrower( Istream_type& is ) 49 | : iters_( is ) 50 | , posn_begin_( iters_.begin_, iters_.end_ ) 51 | , posn_end_( iters_.end_, iters_.end_ ) 52 | { 53 | } 54 | 55 | void read_next( Value_type& value ) 56 | { 57 | posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value ); 58 | } 59 | 60 | private: 61 | 62 | typedef Multi_pass_iters< Istream_type > Mp_iters; 63 | typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t; 64 | 65 | Mp_iters iters_; 66 | Posn_iter_t posn_begin_, posn_end_; 67 | }; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /source/updater.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/updater.h $ 18 | // $Id: updater.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifdef _USE_UPDATER_ 21 | 22 | #ifndef RME_UPDATER_H_ 23 | #define RME_UPDATER_H_ 24 | 25 | #include "threads.h" 26 | 27 | extern const wxEventType EVT_UPDATE_CHECK_FINISHED; 28 | 29 | #define EVT_ON_UPDATE_CHECK_FINISHED(id, fn) \ 30 | DECLARE_EVENT_TABLE_ENTRY( \ 31 | EVT_UPDATE_CHECK_FINISHED, id, wxID_ANY, \ 32 | (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \ 33 | (wxObject *) nullptr \ 34 | ), 35 | 36 | 37 | class wxURL; 38 | 39 | class UpdateConnectionThread : public DetachedThread { 40 | public: 41 | UpdateConnectionThread(wxEvtHandler* receiver, wxURL* url); 42 | virtual ~UpdateConnectionThread(); 43 | protected: 44 | virtual ExitCode Entry(); 45 | wxEvtHandler* receiver; 46 | wxURL* url; 47 | }; 48 | 49 | class UpdateChecker { 50 | public: 51 | UpdateChecker(); 52 | ~UpdateChecker(); 53 | 54 | void connect(wxEvtHandler* receiver); 55 | }; 56 | 57 | #endif 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /source/live_peer.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef _RME_LIVE_PEER_H_ 6 | #define _RME_LIVE_PEER_H_ 7 | 8 | #include "live_socket.h" 9 | #include "net_connection.h" 10 | 11 | class LiveServer; 12 | class LivePeer : public LiveSocket 13 | { 14 | public: 15 | LivePeer(LiveServer* server, boost::asio::ip::tcp::socket socket); 16 | ~LivePeer(); 17 | 18 | void close(); 19 | bool handleError(const boost::system::error_code& error); 20 | 21 | // 22 | uint32_t getId() const { return id; } 23 | uint32_t getClientId() const { return clientId; } 24 | 25 | std::string getHostName() const; 26 | 27 | wxColor getUsedColor() const { return color; } 28 | void setUsedColor(const wxColor& newColor) { color = newColor; } 29 | 30 | // 31 | void receiveHeader(); 32 | void receive(uint32_t packetSize); 33 | void send(NetworkMessage& message); 34 | 35 | // 36 | void updateCursor(const Position& position) {} 37 | 38 | protected: 39 | void parseLoginPacket(NetworkMessage message); 40 | void parseEditorPacket(NetworkMessage message); 41 | 42 | // login packets 43 | void parseHello(NetworkMessage& message); 44 | void parseReady(NetworkMessage& message); 45 | 46 | // editor packets 47 | void parseNodeRequest(NetworkMessage& message); 48 | void parseReceiveChanges(NetworkMessage& message); 49 | void parseAddHouse(NetworkMessage& message); 50 | void parseEditHouse(NetworkMessage& message); 51 | void parseRemoveHouse(NetworkMessage& message); 52 | void parseCursorUpdate(NetworkMessage& message); 53 | void parseChatMessage(NetworkMessage& message); 54 | 55 | // 56 | NetworkMessage readMessage; 57 | 58 | LiveServer* server; 59 | boost::asio::ip::tcp::socket socket; 60 | 61 | wxColor color; 62 | 63 | uint32_t id; 64 | uint32_t clientId; 65 | 66 | bool connected; 67 | 68 | friend class LiveLogTab; 69 | friend class LiveServer; 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /source/waypoints.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/waypoints.h $ 18 | // $Id: waypoints.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_WAYPOINTS_H_ 21 | #define RME_WAYPOINTS_H_ 22 | 23 | #include "position.h" 24 | 25 | class Waypoint { 26 | public: 27 | std::string name; 28 | Position pos; 29 | }; 30 | 31 | typedef std::map WaypointMap; 32 | 33 | class Waypoints { 34 | Map& map; 35 | public: 36 | Waypoints(Map& map) : map(map) {} 37 | ~Waypoints() { 38 | for(WaypointMap::iterator iter = waypoints.begin(); iter != waypoints.end(); ++iter) 39 | delete iter->second; 40 | } 41 | 42 | void addWaypoint(Waypoint* wp); 43 | Waypoint* getWaypoint(std::string name); 44 | Waypoint* getWaypoint(TileLocation* location); 45 | void removeWaypoint(std::string name); 46 | 47 | WaypointMap waypoints; 48 | 49 | WaypointMap::iterator begin() {return waypoints.begin();} 50 | WaypointMap::const_iterator begin() const {return waypoints.begin();} 51 | WaypointMap::iterator end() {return waypoints.end();} 52 | WaypointMap::const_iterator end() const {return waypoints.end();} 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/eraser_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "brush.h" 8 | #include "sprites.h" 9 | #include "basemap.h" 10 | #include "settings.h" 11 | 12 | //============================================================================= 13 | // Eraser brush 14 | 15 | EraserBrush::EraserBrush() 16 | { 17 | //// 18 | } 19 | 20 | EraserBrush::~EraserBrush() 21 | { 22 | //// 23 | } 24 | 25 | std::string EraserBrush::getName() const 26 | { 27 | return "Eraser"; 28 | } 29 | 30 | int EraserBrush::getLookID() const 31 | { 32 | return EDITOR_SPRITE_ERASER; 33 | } 34 | 35 | bool EraserBrush::canDraw(BaseMap* map, const Position& position) const 36 | { 37 | return true; 38 | } 39 | 40 | void EraserBrush::undraw(BaseMap* map, Tile* tile) 41 | { 42 | for(ItemVector::iterator item_iter = tile->items.begin(); item_iter != tile->items.end();) { 43 | Item* item = *item_iter; 44 | if(item->isComplex() && g_settings.getInteger(Config::ERASER_LEAVE_UNIQUE)) { 45 | ++item_iter; 46 | } else { 47 | delete item; 48 | item_iter = tile->items.erase(item_iter); 49 | } 50 | } 51 | if(tile->ground) { 52 | if(g_settings.getInteger(Config::ERASER_LEAVE_UNIQUE)) { 53 | if(!tile->ground->isComplex()) { 54 | delete tile->ground; 55 | tile->ground = nullptr; 56 | } 57 | } else { 58 | delete tile->ground; 59 | tile->ground = nullptr; 60 | } 61 | } 62 | } 63 | 64 | void EraserBrush::draw(BaseMap* map, Tile* tile, void* parameter) 65 | { 66 | // Draw is undraw, undraw is super-undraw! 67 | for(ItemVector::iterator item_iter = tile->items.begin(); item_iter != tile->items.end();) { 68 | Item* item = *item_iter; 69 | if((item->isComplex() || item->isBorder()) && g_settings.getInteger(Config::ERASER_LEAVE_UNIQUE)) { 70 | ++item_iter; 71 | //} else if(item->getDoodadBrush()) { 72 | //++item_iter; 73 | } else { 74 | delete item; 75 | item_iter = tile->items.erase(item_iter); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /source/creature_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "creature_brush.h" 8 | #include "settings.h" 9 | #include "tile.h" 10 | #include "creature.h" 11 | #include "basemap.h" 12 | #include "spawn.h" 13 | 14 | //============================================================================= 15 | // Creature brush 16 | 17 | CreatureBrush::CreatureBrush(CreatureType* type) : 18 | Brush(), 19 | creature_type(type) 20 | { 21 | ASSERT(type->brush == nullptr); 22 | type->brush = this; 23 | } 24 | 25 | CreatureBrush::~CreatureBrush() 26 | { 27 | //// 28 | } 29 | 30 | int CreatureBrush::getLookID() const 31 | { 32 | return 0; 33 | } 34 | 35 | std::string CreatureBrush::getName() const 36 | { 37 | if(creature_type) 38 | return creature_type->name; 39 | return "Creature Brush"; 40 | } 41 | 42 | bool CreatureBrush::canDraw(BaseMap* map, const Position& position) const 43 | { 44 | Tile* tile = map->getTile(position); 45 | if(creature_type && tile && !tile->isBlocking()) { 46 | if(tile->getLocation()->getSpawnCount() != 0 || g_settings.getInteger(Config::AUTO_CREATE_SPAWN)) { 47 | if(tile->isPZ()) { 48 | if(creature_type->isNpc) { 49 | return true; 50 | } 51 | } else { 52 | return true; 53 | } 54 | } 55 | } 56 | return false; 57 | } 58 | 59 | void CreatureBrush::undraw(BaseMap* map, Tile* tile) 60 | { 61 | delete tile->creature; 62 | tile->creature = nullptr; 63 | } 64 | 65 | void CreatureBrush::draw(BaseMap* map, Tile* tile, void* parameter) 66 | { 67 | ASSERT(tile); 68 | ASSERT(parameter); 69 | if(canDraw(map, tile->getPosition())) { 70 | undraw(map, tile); 71 | if(creature_type) { 72 | if(tile->spawn == nullptr && tile->getLocation()->getSpawnCount() == 0) { 73 | // manually place spawn on location 74 | tile->spawn = newd Spawn(1); 75 | } 76 | tile->creature = newd Creature(creature_type); 77 | tile->creature->setSpawnTime(*(int*)parameter); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /source/numbertextctrl.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/numbertextctrl.h $ 18 | // $Id: numbertextctrl.h 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #ifndef _RME_NUMBER_TEXT_CTRL_H_ 21 | #define _RME_NUMBER_TEXT_CTRL_H_ 22 | 23 | // Text ctrl that only allows number input 24 | class NumberTextCtrl : public wxTextCtrl 25 | { 26 | public: 27 | NumberTextCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, 28 | long value = 0, long minvalue = 0, long maxvalue = 100, 29 | const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, 30 | long style = 0, const wxString& name = wxTextCtrlNameStr); 31 | NumberTextCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, 32 | long value = 0, long minvalue = 0, long maxvalue = 100, 33 | long style = 0, const wxString& name = wxTextCtrlNameStr, 34 | const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize); 35 | ~NumberTextCtrl(); 36 | 37 | void OnKillFocus(wxFocusEvent&); 38 | void OnTextEnter(wxCommandEvent&); 39 | 40 | long GetIntValue(); 41 | void SetIntValue(long v); 42 | 43 | protected: 44 | void CheckRange(); 45 | 46 | long minval, maxval, lastval; 47 | DECLARE_EVENT_TABLE(); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /source/map_tab.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/map_tab.h $ 18 | // $Id: map_tab.h 310 2010-02-26 18:03:48Z admin $ 19 | 20 | #ifndef RME_MAP_TAB_H_ 21 | #define RME_MAP_TAB_H_ 22 | 23 | #include "editor_tabs.h" 24 | #include "application.h" 25 | #include "map_window.h" 26 | 27 | class MapTab : public EditorTab, public MapWindow { 28 | public: 29 | MapTab(MapTabbook* aui, Editor* editor); 30 | // Constructs a newd window, but it uses the same internal editor as 'other' 31 | // AND the same parent, aui_notebook etc. 32 | MapTab(const MapTab* other); 33 | ~MapTab(); 34 | 35 | bool IsUniqueReference() const; 36 | bool HasSameReference(MapTab* other) const; 37 | 38 | // Properties 39 | MapWindow* GetView() const; 40 | MapCanvas* GetCanvas() const; 41 | wxWindow* GetWindow() const; 42 | wxString GetTitle() const; 43 | Editor* GetEditor() const; 44 | Map* GetMap() const; 45 | 46 | // Event handlers 47 | void OnSwitchEditorMode(EditorMode mode); 48 | 49 | protected: 50 | struct InternalReference { 51 | Editor* editor; 52 | int owner_count; 53 | }; 54 | MapTabbook* aui; 55 | InternalReference* iref; 56 | }; 57 | 58 | inline bool MapTab::HasSameReference(MapTab* other) const { 59 | return other->iref == iref; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /source/rme_net.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if 0 6 | 7 | #ifndef _RME_NET_H_ 8 | #define _RME_NET_H_ 9 | 10 | #include "net_connection.h" 11 | 12 | class RMENet : public wxEvtHandler, public NetSocket 13 | { 14 | ~RMENet(); 15 | public: 16 | RMENet(wxEvtHandler* event_dump); 17 | 18 | bool Connect(); 19 | void Close(); 20 | void Log(wxString message) {} 21 | 22 | void HandleEvent(wxSocketEvent& evt); 23 | 24 | bool CanHostLive() {return can_host;} 25 | 26 | protected: 27 | void OnParsePacket(NetworkMessage* nmsg); 28 | 29 | void OnReceiveWelcome(NetworkMessage* nmsg); 30 | void OnReceiveDisconnect(NetworkMessage* nmsg); 31 | void OnReceivePing(NetworkMessage* nmsg); 32 | 33 | wxSocketClient* socket; 34 | NetworkConnection* connection; 35 | bool can_host; 36 | 37 | wxEvtHandler* event_dump; 38 | }; 39 | 40 | //============================================================================= 41 | // Events 42 | 43 | extern const wxEventType EVT_RMENET_CONNECTION_ESTABLISHED; 44 | 45 | #define EVT_RMENET_CONNECTION_ESTABLISHED(id, fn) \ 46 | DECLARE_EVENT_TABLE_ENTRY( \ 47 | EVT_RMENET_CONNECTION_ESTABLISHED, id, wxID_ANY, \ 48 | (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \ 49 | (wxObject *) nullptr \ 50 | ), 51 | 52 | extern const wxEventType EVT_RMENET_CONNECTION_LOST; 53 | 54 | #define EVT_RMENET_CONNECTION_LOST(id, fn) \ 55 | DECLARE_EVENT_TABLE_ENTRY( \ 56 | EVT_RMENET_CONNECTION_LOST, id, wxID_ANY, \ 57 | (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \ 58 | (wxObject *) nullptr \ 59 | ), 60 | 61 | extern const wxEventType EVT_RMENET_SHOW_SERVLIST; 62 | 63 | #define EVT_RMENET_SHOW_SERVLIST(id, fn) \ 64 | DECLARE_EVENT_TABLE_ENTRY( \ 65 | EVT_RMENET_SHOW_SERVLIST, id, wxID_ANY, \ 66 | (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \ 67 | (wxObject *) nullptr \ 68 | ), 69 | 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /source/iomap.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/iomap.h $ 18 | // $Id: iomap.h 306 2010-02-24 10:38:25Z admin $ 19 | 20 | #ifndef RME_MAP_IO_H_ 21 | #define RME_MAP_IO_H_ 22 | 23 | #include "client_version.h" 24 | 25 | enum ImportType 26 | { 27 | IMPORT_DONT, 28 | IMPORT_MERGE, 29 | IMPORT_SMART_MERGE, 30 | IMPORT_INSERT, 31 | }; 32 | 33 | class Map; 34 | 35 | class IOMap 36 | { 37 | protected: 38 | wxArrayString warnings; 39 | wxString errorstr; 40 | 41 | bool queryUser(const wxString& title, const wxString& format); 42 | void warning(const wxString format, ...); 43 | void error(const wxString format, ...); 44 | public: 45 | IOMap() { 46 | version.otbm = MAP_OTBM_1; 47 | version.client = CLIENT_VERSION_NONE; 48 | } 49 | virtual ~IOMap() {} 50 | 51 | MapVersion version; 52 | 53 | wxArrayString& getWarnings() {return warnings;} 54 | wxString& getError() {return errorstr;} 55 | 56 | virtual bool loadMap(Map& map, const FileName& identifier) = 0; 57 | virtual bool saveMap(Map& map, const FileName& identifier) = 0; 58 | }; 59 | 60 | 61 | class VirtualIOMap : public IOMap { 62 | public: 63 | VirtualIOMap(MapVersion v) { 64 | version = v; 65 | } 66 | 67 | virtual bool loadMap(Map& map, const FileName& identifier) {return false;} 68 | virtual bool saveMap(Map& map, const FileName& identifier) {return false;} 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /source/map_tab.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/map_tab.hpp $ 5 | // $Id: map_tab.hpp 310 2010-02-26 18:03:48Z admin $ 6 | 7 | #include "main.h" 8 | 9 | #include "gui.h" 10 | #include "editor.h" 11 | #include "map.h" 12 | #include "sprites.h" 13 | #include "map_tab.h" 14 | #include "editor_tabs.h" 15 | #include "map_display.h" 16 | 17 | MapTab::MapTab(MapTabbook* aui, Editor* editor) : 18 | EditorTab(), 19 | MapWindow(aui, *editor), 20 | aui(aui) 21 | { 22 | iref = newd InternalReference; 23 | iref->editor = editor; 24 | iref->owner_count = 1; 25 | 26 | aui->AddTab(this, true); 27 | FitToMap(); 28 | } 29 | 30 | MapTab::MapTab(const MapTab* other) : 31 | EditorTab(), 32 | MapWindow(other->aui, *other->iref->editor), 33 | aui(other->aui), 34 | iref(other->iref) 35 | { 36 | iref->owner_count++; 37 | aui->AddTab(this, true); 38 | FitToMap(); 39 | int x, y; 40 | other->GetCanvas()->GetScreenCenter(&x, &y); 41 | SetScreenCenterPosition(Position(x, y, other->GetCanvas()->GetFloor())); 42 | } 43 | 44 | MapTab::~MapTab() 45 | { 46 | iref->owner_count--; 47 | if(iref->owner_count <= 0) { 48 | delete iref->editor; 49 | delete iref; 50 | } 51 | } 52 | 53 | bool MapTab::IsUniqueReference() const 54 | { 55 | return iref->owner_count == 1; 56 | } 57 | 58 | wxWindow* MapTab::GetWindow() const 59 | { 60 | return const_cast(this); 61 | } 62 | 63 | MapCanvas* MapTab::GetCanvas() const 64 | { 65 | return canvas; 66 | } 67 | 68 | MapWindow* MapTab::GetView() const 69 | { 70 | return const_cast((const MapWindow*)this); 71 | } 72 | 73 | wxString MapTab::GetTitle() const 74 | { 75 | wxString ss; 76 | ss << wxstr(iref->editor->map.getName()) << (iref->editor->map.hasChanged()? "*": ""); 77 | return ss; 78 | } 79 | 80 | Editor* MapTab::GetEditor() const 81 | { 82 | return &editor; 83 | } 84 | 85 | Map* MapTab::GetMap() const 86 | { 87 | return &editor.map; 88 | } 89 | 90 | void MapTab::OnSwitchEditorMode(EditorMode mode) 91 | { 92 | gem->SetSprite(mode == DRAWING_MODE? EDITOR_SPRITE_DRAWING_GEM : EDITOR_SPRITE_SELECTION_GEM); 93 | if(mode == SELECTION_MODE) 94 | canvas->EnterSelectionMode(); 95 | else 96 | canvas->EnterDrawingMode(); 97 | } 98 | -------------------------------------------------------------------------------- /source/live_client.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef _RME_LIVE_CLIENT_H_ 6 | #define _RME_LIVE_CLIENT_H_ 7 | 8 | #include "live_socket.h" 9 | #include "net_connection.h" 10 | 11 | #include 12 | 13 | class DirtyList; 14 | class MapTab; 15 | 16 | class LiveClient : public LiveSocket 17 | { 18 | public: 19 | LiveClient(); 20 | ~LiveClient(); 21 | 22 | // 23 | bool connect(const std::string& address, uint16_t port); 24 | void tryConnect(boost::asio::ip::tcp::resolver::iterator endpoint); 25 | 26 | void close(); 27 | bool handleError(const boost::system::error_code& error); 28 | 29 | // 30 | std::string getHostName() const; 31 | 32 | // 33 | void receiveHeader(); 34 | void receive(uint32_t packetSize); 35 | void send(NetworkMessage& message); 36 | 37 | // 38 | void updateCursor(const Position& position); 39 | 40 | LiveLogTab* createLogWindow(wxWindow* parent); 41 | MapTab* createEditorWindow(); 42 | 43 | // send packets 44 | void sendHello(); 45 | void sendNodeRequests(); 46 | void sendChanges(DirtyList& dirtyList); 47 | void sendChat(const wxString& chatMessage); 48 | void sendReady(); 49 | 50 | // Flags a node as queried and stores it, need to call SendNodeRequest to send it to server 51 | void queryNode(int32_t ndx, int32_t ndy, bool underground); 52 | 53 | protected: 54 | void parsePacket(NetworkMessage message); 55 | 56 | // parse packets 57 | void parseHello(NetworkMessage& message); 58 | void parseKick(NetworkMessage& message); 59 | void parseClientAccepted(NetworkMessage& message); 60 | void parseChangeClientVersion(NetworkMessage& message); 61 | void parseServerTalk(NetworkMessage& message); 62 | void parseNode(NetworkMessage& message); 63 | void parseCursorUpdate(NetworkMessage& message); 64 | void parseStartOperation(NetworkMessage& message); 65 | void parseUpdateOperation(NetworkMessage& message); 66 | 67 | // 68 | NetworkMessage readMessage; 69 | 70 | std::set queryNodeList; 71 | wxString currentOperation; 72 | 73 | std::shared_ptr resolver; 74 | std::shared_ptr socket; 75 | 76 | Editor* editor; 77 | 78 | bool stopped; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /source/raw_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "raw_brush.h" 8 | #include "settings.h" 9 | #include "items.h" 10 | #include "basemap.h" 11 | 12 | //============================================================================= 13 | // RAW brush 14 | 15 | RAWBrush::RAWBrush(uint16_t itemid) : 16 | Brush() 17 | { 18 | ItemType& it = g_items[itemid]; 19 | if(it.id == 0) 20 | itemtype = nullptr; 21 | else 22 | itemtype = ⁢ 23 | } 24 | 25 | RAWBrush::~RAWBrush() 26 | { 27 | //// 28 | } 29 | 30 | int RAWBrush::getLookID() const 31 | { 32 | if(itemtype) 33 | return itemtype->clientID; 34 | return 0; 35 | } 36 | 37 | uint16_t RAWBrush::getItemID() const 38 | { 39 | return itemtype->id; 40 | } 41 | 42 | std::string RAWBrush::getName() const 43 | { 44 | if(!itemtype) 45 | return "RAWBrush"; 46 | 47 | if(itemtype->hookSouth) 48 | return i2s(itemtype->id) + " - " + itemtype->name + " (Hook South)"; 49 | else if(itemtype->hookEast) 50 | return i2s(itemtype->id) + " - " + itemtype->name + " (Hook East)"; 51 | 52 | return i2s(itemtype->id) + " - " + itemtype->name + itemtype->editorsuffix; 53 | } 54 | 55 | void RAWBrush::undraw(BaseMap* map, Tile* tile) 56 | { 57 | if(tile->ground && tile->ground->getID() == itemtype->id) { 58 | delete tile->ground; 59 | tile->ground = nullptr; 60 | } 61 | for(ItemVector::iterator iter = tile->items.begin(); iter != tile->items.end();) { 62 | Item* item = *iter; 63 | if(item->getID() == itemtype->id) { 64 | delete item; 65 | iter = tile->items.erase(iter); 66 | } else { 67 | ++iter; 68 | } 69 | } 70 | } 71 | 72 | void RAWBrush::draw(BaseMap* map, Tile* tile, void* parameter) 73 | { 74 | if(!itemtype) return; 75 | 76 | bool b = parameter? *reinterpret_cast(parameter) : false; 77 | if((g_settings.getInteger(Config::RAW_LIKE_SIMONE) && !b) && itemtype->alwaysOnBottom && itemtype->alwaysOnTopOrder == 2) { 78 | for(ItemVector::iterator iter = tile->items.begin(); iter != tile->items.end();) { 79 | Item* item = *iter; 80 | if(item->getTopOrder() == itemtype->alwaysOnTopOrder) { 81 | delete item; 82 | iter = tile->items.erase(iter); 83 | } 84 | else 85 | ++iter; 86 | } 87 | } 88 | tile->addItem(Item::Create(itemtype->id)); 89 | } 90 | -------------------------------------------------------------------------------- /source/town.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/town.hpp $ 18 | // $Id: town.hpp 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #include "main.h" 21 | 22 | #include "town.h" 23 | 24 | #include "map.h" 25 | #include "tile.h" 26 | 27 | Towns::Towns() 28 | { 29 | //// 30 | } 31 | 32 | Towns::~Towns() 33 | { 34 | clear(); 35 | } 36 | 37 | void Towns::clear() 38 | { 39 | TownMap::const_iterator it = begin(); 40 | while(it != end()) { 41 | delete it->second; 42 | ++it; 43 | } 44 | towns.clear(); 45 | } 46 | 47 | bool Towns::addTown(Town* town) 48 | { 49 | TownMap::iterator it = find(town->getID()); 50 | if(it != end()) { 51 | return false; 52 | } 53 | towns[town->getID()] = town; 54 | return true; 55 | } 56 | 57 | uint32_t Towns::getEmptyID() 58 | { 59 | uint32_t empty = 0; 60 | for(TownMap::iterator it = begin(); it != end(); ++it) { 61 | if(it->second->getID() > empty) { 62 | empty = it->second->getID(); 63 | } 64 | } 65 | return empty + 1; 66 | } 67 | 68 | Town* Towns::getTown(std::string& name) 69 | { 70 | for(TownMap::iterator it = begin(); it != end(); ++it) { 71 | if(it->second->getName() == name) { 72 | return it->second; 73 | } 74 | } 75 | return nullptr; 76 | } 77 | 78 | Town* Towns::getTown(uint32_t id) 79 | { 80 | TownMap::iterator it = find(id); 81 | if(it != end()) { 82 | return it->second; 83 | } 84 | return nullptr; 85 | } 86 | 87 | void Town::setTemplePosition(const Position& pos) 88 | { 89 | templepos = pos; 90 | } 91 | -------------------------------------------------------------------------------- /source/rme-install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "------------------------------------------------------------------------------" 4 | echo "Remere's Map Editor installation script" 5 | echo -n "Checking for root privilegies... " 6 | 7 | if [ "$(id -u)" != "0" ]; then 8 | echo "FAILED" 9 | echo "This script must be run as root" 1>&2 10 | exit 1 11 | else 12 | echo "Done" 13 | fi 14 | 15 | echo -n "Adding tt-solutions repository... " 16 | grep "apt.tt-solutions.com" /etc/apt/sources.list > /dev/null 17 | if [ "$?" != "0" ]; then 18 | echo "" >> /etc/apt/sources.list 19 | echo "# tt-solutions repository, added by Remere's Map Editor installation script." >> /etc/apt/sources.list 20 | echo "deb http://apt.tt-solutions.com/ubuntu/ dapper main" >> /etc/apt/sources.list 21 | echo "Done" 22 | else 23 | echo "Already done" 24 | fi 25 | 26 | echo "Installing required packages" 27 | 28 | echo -n "Installing libwxgtk2.8-0... " 29 | apt-get -y install libwxgtk2.8-0 > /dev/null 30 | if [ "$?" != "0" ]; then 31 | echo "FAILED" 32 | echo "You must do a manual install of the required packages" 33 | else 34 | echo "Done" 35 | fi 36 | 37 | echo -n "Installing libboost1.40-all-dev... " 38 | apt-get -y install libboost1.40-all-dev > /dev/null 39 | if [ "$?" != "0" ]; then 40 | echo "FAILED" 41 | echo "You must do a manual install of the required packages" 42 | else 43 | echo "Done" 44 | fi 45 | 46 | echo -n "Installing libxml2... " 47 | apt-get -y install libxml2 > /dev/null 48 | if [ "$?" != "0" ]; then 49 | echo "FAILED" 50 | echo "You must do a manual install of the required packages" 51 | else 52 | echo "Done" 53 | fi 54 | 55 | echo -n "Installing libglu1-mesa... " 56 | apt-get -y install libglu1-mesa > /dev/null 57 | if [ "$?" != "0" ]; then 58 | echo "FAILED" 59 | echo "You must do a manual install of the required packages" 60 | else 61 | echo "Done" 62 | fi 63 | 64 | echo -n "Installing libgl1-mesa-glx... " 65 | apt-get -y install libgl1-mesa-glx > /dev/null 66 | if [ "$?" != "0" ]; then 67 | echo "FAILED" 68 | echo "You must do a manual install of the required packages" 69 | else 70 | echo "Done" 71 | fi 72 | 73 | echo -n "Do you want to update all packages, editor may not run with not-updated runtime libraries. [y/n] " 74 | read pr 75 | if [ "$pr" == "y" ]; then 76 | echo "Running apt-get update..." 77 | apt-get update 78 | fi 79 | 80 | echo "Installation complete, run ./rme to launch the editor" 81 | read -p "Press any key to exit... " 82 | 83 | -------------------------------------------------------------------------------- /source/waypoints.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/waypoints.hpp $ 18 | // $Id: waypoints.hpp 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #include "main.h" 21 | 22 | #include "waypoints.h" 23 | #include "map.h" 24 | 25 | void Waypoints::addWaypoint(Waypoint* wp) 26 | { 27 | removeWaypoint(wp->name); 28 | if(wp->pos != Position()) { 29 | Tile* t = map.getTile(wp->pos); 30 | if(!t) 31 | map.setTile(wp->pos, t = map.allocator(map.createTileL(wp->pos))); 32 | t->getLocation()->increaseWaypointCount(); 33 | } 34 | waypoints.insert(std::make_pair(as_lower_str(wp->name), wp)); 35 | } 36 | 37 | Waypoint* Waypoints::getWaypoint(std::string name) 38 | { 39 | to_lower_str(name); 40 | WaypointMap::iterator iter = waypoints.find(name); 41 | if(iter == waypoints.end()) 42 | return nullptr; 43 | return iter->second; 44 | } 45 | 46 | Waypoint* Waypoints::getWaypoint(TileLocation* location) 47 | { 48 | if(!location) 49 | return nullptr; 50 | // TODO find waypoint by position hash. 51 | for(WaypointMap::iterator it = waypoints.begin(); it != waypoints.end(); it++) { 52 | Waypoint* waypoint = it->second; 53 | if(waypoint && waypoint->pos == location->position) 54 | return waypoint; 55 | } 56 | return nullptr; 57 | } 58 | 59 | void Waypoints::removeWaypoint(std::string name) 60 | { 61 | to_lower_str(name); 62 | WaypointMap::iterator iter = waypoints.find(name); 63 | if(iter == waypoints.end()) 64 | return; 65 | delete iter->second; 66 | waypoints.erase(iter); 67 | } 68 | -------------------------------------------------------------------------------- /source/wall_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_WALL_BRUSH_H 2 | #define RME_WALL_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // Wallbrush, for drawing walls 8 | 9 | class WallBrush : public TerrainBrush { 10 | public: 11 | static void init(); 12 | 13 | WallBrush(); 14 | virtual ~WallBrush(); 15 | 16 | bool isWall() const { return true; } 17 | WallBrush* asWall() { return static_cast(this); } 18 | 19 | virtual bool load(pugi::xml_node node, wxArrayString& warnings); 20 | 21 | virtual bool canDraw(BaseMap* map, const Position& position) const {return true;} 22 | 23 | // Draw to the target tile 24 | // Note that this actually only puts the first WALL_NORMAL item on the tile. 25 | // It's up to the doWalls function to change it to the correct alignment 26 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 27 | virtual void undraw(BaseMap* map, Tile* tile); 28 | // Creates walls on the target tile (does not depend on brush in any way) 29 | static void doWalls(BaseMap* map, Tile* tile); 30 | 31 | // If the specified wall item is part of this wall 32 | bool hasWall(Item* item); 33 | ::DoorType getDoorTypeFromID(uint16_t id); 34 | 35 | virtual bool canSmear() const {return false;} 36 | virtual bool canDrag() const {return true;} 37 | protected: 38 | struct WallType { 39 | int chance; 40 | uint16_t id; 41 | }; 42 | struct WallNode { 43 | WallNode() : total_chance(0) {} 44 | int total_chance; 45 | std::vector items; 46 | }; 47 | struct DoorType { 48 | ::DoorType type; 49 | uint16_t id; 50 | }; 51 | WallNode wall_items[17]; 52 | std::vector door_items[17]; 53 | 54 | WallBrush* redirect_to; 55 | 56 | friend class DoorBrush; 57 | public: 58 | static uint32_t full_border_types[16]; 59 | static uint32_t half_border_types[16]; 60 | }; 61 | 62 | //============================================================================= 63 | // Wall decoration brush, for drawing decoration on walls 64 | 65 | class WallDecorationBrush : public WallBrush { 66 | public: 67 | WallDecorationBrush(); 68 | virtual ~WallDecorationBrush(); 69 | 70 | bool isWallDecoration() const { return true; } 71 | WallDecorationBrush* asWallDecoration() { return static_cast(this); } 72 | 73 | // We use the exact same loading algorithm as normal walls 74 | 75 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /source/json/json_spirit_writer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright John W. Wilkinson 2007 - 2009. 2 | // Distributed under the MIT License, see accompanying file LICENSE.txt 3 | 4 | // json spirit version 4.03 5 | 6 | #include "json_spirit_writer.h" 7 | #include "json_spirit_writer_template.h" 8 | 9 | void json_spirit::write( const Value& value, std::ostream& os ) 10 | { 11 | write_stream( value, os, false ); 12 | } 13 | 14 | void json_spirit::write_formatted( const Value& value, std::ostream& os ) 15 | { 16 | write_stream( value, os, true ); 17 | } 18 | 19 | std::string json_spirit::write( const Value& value ) 20 | { 21 | return write_string( value, false ); 22 | } 23 | 24 | std::string json_spirit::write_formatted( const Value& value ) 25 | { 26 | return write_string( value, true ); 27 | } 28 | 29 | #ifndef BOOST_NO_STD_WSTRING 30 | 31 | void json_spirit::write( const wValue& value, std::wostream& os ) 32 | { 33 | write_stream( value, os, false ); 34 | } 35 | 36 | void json_spirit::write_formatted( const wValue& value, std::wostream& os ) 37 | { 38 | write_stream( value, os, true ); 39 | } 40 | 41 | std::wstring json_spirit::write( const wValue& value ) 42 | { 43 | return write_string( value, false ); 44 | } 45 | 46 | std::wstring json_spirit::write_formatted( const wValue& value ) 47 | { 48 | return write_string( value, true ); 49 | } 50 | 51 | #endif 52 | 53 | void json_spirit::write( const mValue& value, std::ostream& os ) 54 | { 55 | write_stream( value, os, false ); 56 | } 57 | 58 | void json_spirit::write_formatted( const mValue& value, std::ostream& os ) 59 | { 60 | write_stream( value, os, true ); 61 | } 62 | 63 | std::string json_spirit::write( const mValue& value ) 64 | { 65 | return write_string( value, false ); 66 | } 67 | 68 | std::string json_spirit::write_formatted( const mValue& value ) 69 | { 70 | return write_string( value, true ); 71 | } 72 | 73 | #ifndef BOOST_NO_STD_WSTRING 74 | 75 | void json_spirit::write( const wmValue& value, std::wostream& os ) 76 | { 77 | write_stream( value, os, false ); 78 | } 79 | 80 | void json_spirit::write_formatted( const wmValue& value, std::wostream& os ) 81 | { 82 | write_stream( value, os, true ); 83 | } 84 | 85 | std::wstring json_spirit::write( const wmValue& value ) 86 | { 87 | return write_string( value, false ); 88 | } 89 | 90 | std::wstring json_spirit::write_formatted( const wmValue& value ) 91 | { 92 | return write_string( value, true ); 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /source/editor_tabs.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/editor_tabs.h $ 18 | // $Id: editor_tabs.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_EDITOR_TABS_H_ 21 | #define RME_EDITOR_TABS_H_ 22 | 23 | #include "gui_ids.h" 24 | 25 | class EditorTab; 26 | 27 | class MapTabbook : public wxPanel 28 | { 29 | public: 30 | MapTabbook(wxWindow* parent, wxWindowID id); 31 | ~MapTabbook(); 32 | 33 | // Wrapper functions 34 | void AddTab(EditorTab* tab, bool select); 35 | void SetTabLabel(int idx, wxString label); 36 | void SetFocusedTab(int idx); 37 | void DeleteTab(int idx); 38 | int GetTabCount(); 39 | int GetTabIndex(wxWindow* tab); 40 | int GetSelection(); 41 | void CycleTab(bool forward = true); 42 | wxWindow* GetCurrentPage(); 43 | EditorTab* GetCurrentTab(); 44 | EditorTab* GetTab(int idx); 45 | 46 | // Events 47 | void OnAllowNotebookDND(wxAuiNotebookEvent& evt); 48 | void OnNotebookPageClose(wxAuiNotebookEvent& evt); 49 | void OnNotebookPageChanged(wxAuiNotebookEvent& evt); 50 | void OnSwitchEditorMode(EditorMode mode); 51 | 52 | protected: 53 | EditorTab* GetInternalTab(int idx); 54 | wxAuiNotebook* notebook; 55 | std::map conv; 56 | 57 | DECLARE_EVENT_TABLE(); 58 | }; 59 | 60 | class EditorTab 61 | { 62 | public: 63 | EditorTab(); 64 | virtual ~EditorTab(); 65 | 66 | // Properties 67 | virtual wxWindow* GetWindow() const = 0; 68 | virtual wxString GetTitle() const = 0; 69 | 70 | // 71 | virtual void OnSwitchEditorMode(EditorMode mode) {} 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /source/creature.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/creature.hpp $ 18 | // $Id: creature.hpp 310 2010-02-26 18:03:48Z admin $ 19 | 20 | #include "main.h" 21 | 22 | #include "creature.h" 23 | 24 | Creature::Creature(CreatureType* ctype) : direction(NORTH), spawntime(0), saved(false), selected(false) 25 | { 26 | if(ctype) 27 | type_name = ctype->name; 28 | } 29 | 30 | Creature::Creature(std::string ctype_name) : type_name(ctype_name), direction(NORTH), spawntime(0), saved(false), selected(false) 31 | { 32 | //// 33 | } 34 | 35 | Creature::~Creature() 36 | { 37 | //// 38 | } 39 | 40 | std::string Creature::DirID2Name(uint16_t id) { 41 | switch (id) { 42 | case NORTH: return "North"; 43 | case EAST: return "East"; 44 | case SOUTH: return "South"; 45 | case WEST: return "West"; 46 | default: return "Unknown"; 47 | } 48 | } 49 | 50 | uint16_t Creature::DirName2ID(std::string dir) 51 | { 52 | to_lower_str(dir); 53 | if(dir == "north") return NORTH; 54 | if(dir == "east") return EAST; 55 | if(dir == "south") return SOUTH; 56 | if(dir == "west") return WEST; 57 | return SOUTH; 58 | } 59 | 60 | Creature* Creature::deepCopy() const 61 | { 62 | Creature* copy = newd Creature(type_name); 63 | copy->spawntime = spawntime; 64 | copy->direction = direction; 65 | copy->selected = selected; 66 | copy->saved = saved; 67 | return copy; 68 | } 69 | 70 | const Outfit& Creature::getLookType() const 71 | { 72 | CreatureType* type = g_creatures[type_name]; 73 | if(type) 74 | return type->outfit; 75 | static const Outfit otfi; // Empty outfit 76 | return otfi; 77 | } 78 | -------------------------------------------------------------------------------- /source/creature.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef RME_CREATURE_H_ 7 | #define RME_CREATURE_H_ 8 | 9 | #include "creatures.h" 10 | 11 | enum Direction 12 | { 13 | NORTH = 0, 14 | EAST = 1, 15 | SOUTH = 2, 16 | WEST = 3, 17 | 18 | DIRECTION_FIRST = NORTH, 19 | DIRECTION_LAST = WEST 20 | }; 21 | 22 | IMPLEMENT_INCREMENT_OP(Direction) 23 | 24 | class Creature { 25 | public: 26 | Creature(CreatureType* ctype); 27 | Creature(std::string type_name); 28 | ~Creature(); 29 | 30 | // Static conversions 31 | static std::string DirID2Name(uint16_t id); 32 | static uint16_t DirName2ID(std::string id); 33 | 34 | Creature* deepCopy() const; 35 | 36 | const Outfit& getLookType() const; 37 | 38 | bool isSaved(); 39 | void save(); 40 | void reset(); 41 | 42 | bool isSelected() const {return selected;} 43 | void deselect() {selected = false;} 44 | void select() {selected = true;} 45 | 46 | bool isNpc() const; 47 | 48 | std::string getName() const; 49 | CreatureBrush* getBrush() const; 50 | 51 | int getSpawnTime() const {return spawntime;} 52 | void setSpawnTime(int spawntime) {this->spawntime = spawntime;} 53 | 54 | Direction getDirection() const { return direction; } 55 | void setDirection(Direction direction) { this->direction = direction; } 56 | 57 | protected: 58 | std::string type_name; 59 | Direction direction; 60 | int spawntime; 61 | bool saved; 62 | bool selected; 63 | }; 64 | 65 | inline void Creature::save() { 66 | saved = true; 67 | } 68 | 69 | inline void Creature::reset() { 70 | saved = false; 71 | } 72 | 73 | inline bool Creature::isSaved() { 74 | return saved; 75 | } 76 | 77 | inline bool Creature::isNpc() const { 78 | CreatureType* type = g_creatures[type_name]; 79 | if(type) { 80 | return type->isNpc; 81 | } 82 | return false; 83 | } 84 | 85 | inline std::string Creature::getName() const { 86 | CreatureType* type = g_creatures[type_name]; 87 | if(type) { 88 | return type->name; 89 | } 90 | return ""; 91 | } 92 | inline CreatureBrush* Creature::getBrush() const { 93 | CreatureType* type = g_creatures[type_name]; 94 | if(type) { 95 | return type->brush; 96 | } 97 | return nullptr; 98 | } 99 | 100 | typedef std::vector CreatureVector; 101 | typedef std::list CreatureList; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /source/process_com.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/process_com.hpp $ 18 | // $Id: process_com.hpp 310 2010-02-26 18:03:48Z admin $ 19 | 20 | #include "main.h" 21 | 22 | #ifdef _USE_PROCESS_COM 23 | 24 | #include "gui.h" 25 | #include "process_com.h" 26 | 27 | 28 | //Server 29 | 30 | RMEProcessServer::RMEProcessServer() 31 | { 32 | //// 33 | } 34 | 35 | RMEProcessServer::~RMEProcessServer() 36 | { 37 | //// 38 | } 39 | 40 | wxConnectionBase* RMEProcessServer::OnAcceptConnection(const wxString& topic) 41 | { 42 | if(topic.Lower() == "rme_talk") { 43 | g_gui.root->Iconize(false); //Show application if minimized 44 | g_gui.root->Raise(); //Request the window manager to raise this application to the top of Z-order 45 | return newd RMEProcessConnection(); 46 | } 47 | return nullptr; 48 | } 49 | 50 | 51 | //Client 52 | 53 | RMEProcessClient::RMEProcessClient() : proc(nullptr) 54 | { 55 | //// 56 | } 57 | 58 | RMEProcessClient::~RMEProcessClient() 59 | { 60 | delete proc; 61 | } 62 | 63 | wxConnectionBase* RMEProcessClient::OnMakeConnection() 64 | { 65 | return proc = newd RMEProcessConnection(); 66 | } 67 | 68 | 69 | //Connection 70 | 71 | RMEProcessConnection::RMEProcessConnection() : wxConnection() 72 | { 73 | //// 74 | } 75 | 76 | RMEProcessConnection::~RMEProcessConnection() 77 | { 78 | //// 79 | } 80 | 81 | bool RMEProcessConnection::OnExec(const wxString& topic, const wxString& fileName) 82 | { 83 | if(topic.Lower() == "rme_talk" && fileName != wxEmptyString) { 84 | g_gui.LoadMap(FileName(fileName)); 85 | return true; 86 | } 87 | return false; 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /source/con_vector.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/con_vector.h $ 18 | // $Id: con_vector.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_CON_VECTOR_H_ 21 | #define RME_CON_VECTOR_H_ 22 | 23 | #define REALLOC_INCREASE 600 24 | 25 | template // This only really works with pointers.. hrhr "T" might be abit misleading.. :o 26 | class contigous_vector { 27 | T __pointer_check(T t) {return *t;} // If this fails, you have tried using this class with a non-pointer type, DONT 28 | public: 29 | contigous_vector(size_t start_size = 7) { 30 | start = reinterpret_cast(malloc(sizeof(T) * start_size)); 31 | memset(start, 0, sizeof(T) * start_size); 32 | sz = start_size; 33 | } 34 | ~contigous_vector() { 35 | free(start); 36 | } 37 | 38 | void resize(size_t new_size) { 39 | size_t old_size = sz; 40 | start = reinterpret_cast(realloc(start, sizeof(T) * new_size)); 41 | memset(start + old_size, 0, sizeof(T) * (new_size - old_size)); 42 | sz = new_size; 43 | } 44 | size_t size() { 45 | return sz; 46 | } 47 | 48 | T& locate(size_t index) { 49 | // Masterly inefficient! 50 | while(index >= sz) { 51 | resize(sz+REALLOC_INCREASE); 52 | } 53 | return start[index]; 54 | } 55 | 56 | T at(size_t index) const { 57 | if(index >= sz) { 58 | return nullptr; 59 | } 60 | return start[index]; 61 | } 62 | 63 | void set(size_t index, T value) { 64 | locate(index) = value; 65 | } 66 | 67 | T operator[](size_t index) {return at(index);} 68 | const T operator[](size_t index) const {return at(index);} 69 | private: 70 | T* start; 71 | size_t sz; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /source/json/json_spirit_reader.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_READER 2 | #define JSON_SPIRIT_READER 3 | 4 | // Copyright John W. Wilkinson 2007 - 2009. 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.03 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include "json_spirit_error_position.h" 15 | #include 16 | 17 | namespace json_spirit 18 | { 19 | // functions to reads a JSON values 20 | 21 | bool read( const std::string& s, Value& value ); 22 | bool read( std::istream& is, Value& value ); 23 | bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); 24 | 25 | void read_or_throw( const std::string& s, Value& value ); 26 | void read_or_throw( std::istream& is, Value& value ); 27 | void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); 28 | 29 | #ifndef BOOST_NO_STD_WSTRING 30 | 31 | bool read( const std::wstring& s, wValue& value ); 32 | bool read( std::wistream& is, wValue& value ); 33 | bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); 34 | 35 | void read_or_throw( const std::wstring& s, wValue& value ); 36 | void read_or_throw( std::wistream& is, wValue& value ); 37 | void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); 38 | 39 | #endif 40 | 41 | bool read( const std::string& s, mValue& value ); 42 | bool read( std::istream& is, mValue& value ); 43 | bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); 44 | 45 | void read_or_throw( const std::string& s, mValue& value ); 46 | void read_or_throw( std::istream& is, mValue& value ); 47 | void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); 48 | 49 | #ifndef BOOST_NO_STD_WSTRING 50 | 51 | bool read( const std::wstring& s, wmValue& value ); 52 | bool read( std::wistream& is, wmValue& value ); 53 | bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); 54 | 55 | void read_or_throw( const std::wstring& s, wmValue& value ); 56 | void read_or_throw( std::wistream& is, wmValue& value ); 57 | void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); 58 | 59 | #endif 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /source/house_brush.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "house_brush.h" 8 | #include "house.h" 9 | #include "map.h" 10 | #include "complexitem.h" 11 | 12 | //============================================================================= 13 | // House Brush 14 | 15 | HouseBrush::HouseBrush() : 16 | Brush(), 17 | draw_house(nullptr) 18 | { 19 | //// 20 | } 21 | 22 | HouseBrush::~HouseBrush() 23 | { 24 | //// 25 | } 26 | 27 | void HouseBrush::setHouse(House* house) 28 | { 29 | draw_house = house; 30 | } 31 | 32 | uint32_t HouseBrush::getHouseID() const 33 | { 34 | if(draw_house) 35 | return draw_house->id; 36 | return 0; 37 | } 38 | 39 | void HouseBrush::undraw(BaseMap* map, Tile* tile) 40 | { 41 | if(tile->isHouseTile()) { 42 | tile->setPZ(false); 43 | } 44 | tile->setHouse(nullptr); 45 | if(g_settings.getInteger(Config::AUTO_ASSIGN_DOORID)) { 46 | // Is there a door? If so, remove any door id it has 47 | for(ItemVector::iterator it = tile->items.begin(); 48 | it != tile->items.end(); 49 | ++it) 50 | { 51 | if(Door* door = dynamic_cast(*it)) { 52 | door->setDoorID(0); 53 | } 54 | } 55 | } 56 | } 57 | 58 | void HouseBrush::draw(BaseMap* map, Tile* tile, void* parameter) 59 | { 60 | ASSERT(draw_house); 61 | uint32_t old_house_id = tile->getHouseID(); 62 | tile->setHouse(draw_house); 63 | tile->setPZ(true); 64 | if(g_settings.getInteger(Config::HOUSE_BRUSH_REMOVE_ITEMS)) { 65 | // Remove loose items 66 | for(ItemVector::iterator it = tile->items.begin(); 67 | it != tile->items.end(); 68 | /*..*/) 69 | { 70 | Item* item = *it; 71 | if(item->isNotMoveable() == 0) { 72 | delete item; 73 | it = tile->items.erase(it); 74 | } else { 75 | ++it; 76 | } 77 | } 78 | } 79 | if(g_settings.getInteger(Config::AUTO_ASSIGN_DOORID)) { 80 | // Is there a door? If so, find an empty ID and assign it (if the door doesn't already have an id. 81 | for(ItemVector::iterator it = tile->items.begin(); 82 | it != tile->items.end(); 83 | ++it) 84 | { 85 | if(Door* door = dynamic_cast(*it)) { 86 | if(door->getDoorID() == 0 || old_house_id != 0) { 87 | Map* real_map = dynamic_cast(map); 88 | if(real_map) { 89 | door->setDoorID(draw_house->getEmptyDoorID()); 90 | } 91 | } 92 | } 93 | } 94 | } 95 | // The tile will automagically be added to the house via the Action functions 96 | //draw_house->addTile(tile); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /source/spawn.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/spawn.h $ 18 | // $Id: spawn.h 310 2010-02-26 18:03:48Z admin $ 19 | 20 | #ifndef RME_SPAWN_H_ 21 | #define RME_SPAWN_H_ 22 | 23 | class Tile; 24 | 25 | class Spawn { 26 | public: 27 | Spawn(int size = 3) : size(0), selected(false) {setSize(size);} 28 | ~Spawn() {} 29 | 30 | Spawn* deepCopy() { 31 | Spawn* copy = newd Spawn(size); 32 | copy->selected = selected; 33 | return copy; 34 | } 35 | 36 | bool isSelected() const {return selected;} 37 | void select() {selected = true;} 38 | void deselect() {selected = false;} 39 | 40 | // Does not compare selection! 41 | bool operator==(const Spawn& other) {return size == other.size;} 42 | bool operator!=(const Spawn& other) {return size != other.size;} 43 | 44 | void setSize(int newsize) { 45 | ASSERT(size < 100); 46 | size = newsize; 47 | } 48 | int getSize() const {return size;} 49 | protected: 50 | int size; 51 | bool selected; 52 | }; 53 | 54 | typedef std::set SpawnPositionList; 55 | typedef std::list SpawnList; 56 | 57 | class Spawns { 58 | public: 59 | Spawns(); 60 | ~Spawns(); 61 | 62 | void addSpawn(Tile* tile); 63 | void removeSpawn(Tile* tile); 64 | 65 | SpawnPositionList::iterator begin() {return spawns.begin();} 66 | SpawnPositionList::const_iterator begin() const {return spawns.begin();} 67 | SpawnPositionList::iterator end() {return spawns.end();} 68 | SpawnPositionList::const_iterator end() const {return spawns.end();} 69 | void erase(SpawnPositionList::iterator iter) {spawns.erase(iter);} 70 | SpawnPositionList::iterator find(Position& pos) {return spawns.find(pos);} 71 | private: 72 | SpawnPositionList spawns; 73 | }; 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /source/palette_waypoints.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/palette_waypoints.h $ 18 | // $Id: palette_waypoints.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_PALETTE_WAYPOINTS_H_ 21 | #define RME_PALETTE_WAYPOINTS_H_ 22 | 23 | #include 24 | 25 | #include "waypoints.h" 26 | #include "palette_common.h" 27 | 28 | class WaypointPalettePanel : public PalettePanel { 29 | public: 30 | WaypointPalettePanel(wxWindow* parent, wxWindowID id = wxID_ANY); 31 | ~WaypointPalettePanel(); 32 | 33 | wxString GetName() const; 34 | PaletteType GetType() const; 35 | 36 | // Select the first brush 37 | void SelectFirstBrush(); 38 | // Returns the currently selected brush (first brush if panel is not loaded) 39 | Brush* GetSelectedBrush() const; 40 | // Returns the currently selected brush size 41 | int GetSelectedBrushSize() const; 42 | // Select the brush in the parameter, this only changes the look of the panel 43 | bool SelectBrush(const Brush* whatbrush); 44 | 45 | // Called sometimes? 46 | void OnUpdate(); 47 | // Called when this page is about to be displayed 48 | void OnSwitchIn(); 49 | // Called when this page is hidden 50 | void OnSwitchOut(); 51 | public: 52 | // wxWidgets event handling 53 | void OnClickWaypoint(wxListEvent& event); 54 | void OnBeginEditWaypointLabel(wxListEvent& event); 55 | void OnEditWaypointLabel(wxListEvent& event); 56 | void OnClickAddWaypoint(wxCommandEvent& event); 57 | void OnClickRemoveWaypoint(wxCommandEvent& event); 58 | 59 | void SetMap(Map* map); 60 | protected: 61 | Map* map; 62 | wxListCtrl* waypoint_list; 63 | wxButton* add_waypoint_button; 64 | wxButton* remove_waypoint_button; 65 | 66 | DECLARE_EVENT_TABLE() 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /source/live_socket.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef _RME_LIVE_SOCKET_H_ 6 | #define _RME_LIVE_SOCKET_H_ 7 | 8 | #include "position.h" 9 | #include "net_connection.h" 10 | #include "live_packets.h" 11 | #include "filehandle.h" 12 | #include "iomap.h" 13 | 14 | #include 15 | #include 16 | 17 | class LiveLogTab; 18 | class Action; 19 | 20 | struct LiveCursor 21 | { 22 | uint32_t id; 23 | wxColor color; 24 | Position pos; 25 | }; 26 | 27 | class LiveSocket 28 | { 29 | public: 30 | LiveSocket(); 31 | virtual ~LiveSocket(); 32 | 33 | // 34 | wxString getName() const; 35 | bool setName(const wxString& newName); 36 | 37 | wxString getPassword() const; 38 | bool setPassword(const wxString& newPassword); 39 | 40 | wxString getLastError() const; 41 | void setLastError(const wxString& error); 42 | 43 | std::string getHostName() const; 44 | std::vector getCursorList() const; 45 | 46 | // 47 | void logMessage(const wxString& message); 48 | 49 | // 50 | virtual void receiveHeader() = 0; 51 | virtual void receive(uint32_t packetSize) = 0; 52 | virtual void send(NetworkMessage& message) = 0; 53 | 54 | // 55 | virtual void updateCursor(const Position& position) = 0; 56 | 57 | protected: 58 | // receive / send methods 59 | void receiveNode(NetworkMessage& message, Editor& editor, Action* action, int32_t ndx, int32_t ndy, bool underground); 60 | void sendNode(uint32_t clientId, QTreeNode* node, int32_t ndx, int32_t ndy, uint32_t floorMask); 61 | 62 | void receiveFloor(NetworkMessage& message, Editor& editor, Action* action, int32_t ndx, int32_t ndy, int32_t z, QTreeNode* node, Floor* floor); 63 | void sendFloor(NetworkMessage& message, Floor* floor); 64 | 65 | void receiveTile(BinaryNode* node, Editor& editor, Action* action, const Position* position); 66 | void sendTile(MemoryNodeFileWriteHandle& writer, Tile* tile, const Position* position); 67 | 68 | // read / write types 69 | Tile* readTile(BinaryNode* node, Editor& editor, const Position* position); 70 | 71 | LiveCursor readCursor(NetworkMessage& message); 72 | void writeCursor(NetworkMessage& message, const LiveCursor& cursor); 73 | 74 | // 75 | std::unordered_map cursors; 76 | 77 | MemoryNodeFileReadHandle mapReader; 78 | MemoryNodeFileWriteHandle mapWriter; 79 | VirtualIOMap mapVersion; 80 | 81 | LiveLogTab* log; 82 | 83 | wxString name; 84 | wxString password; 85 | wxString lastError; 86 | 87 | friend class LiveLogTab; 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /source/updater.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/updater.hpp $ 18 | // $Id: updater.hpp 310 2010-02-26 18:03:48Z admin $ 19 | 20 | #include "main.h" 21 | 22 | #ifdef _USE_UPDATER_ 23 | 24 | #include 25 | 26 | #include "json.h" 27 | 28 | #include "updater.h" 29 | 30 | const wxEventType EVT_UPDATE_CHECK_FINISHED = wxNewEventType(); 31 | 32 | UpdateChecker::UpdateChecker() 33 | { 34 | //// 35 | } 36 | 37 | UpdateChecker::~UpdateChecker() 38 | { 39 | //// 40 | } 41 | 42 | void UpdateChecker::connect(wxEvtHandler* receiver) 43 | { 44 | wxString address = "http://www.remeresmapeditor.com/update.php"; 45 | address << "?os=" << 46 | #ifdef __WINDOWS__ 47 | "windows"; 48 | #elif __LINUX__ 49 | "linux"; 50 | #else 51 | "unknown"; 52 | #endif 53 | address << "&verid=" << __RME_VERSION_ID__; 54 | #ifdef __EXPERIMENTAL__ 55 | address << "&beta"; 56 | #endif 57 | wxURL* url = newd wxURL(address); 58 | UpdateConnectionThread* connection = newd UpdateConnectionThread(receiver, url); 59 | connection->Execute(); 60 | } 61 | 62 | UpdateConnectionThread::UpdateConnectionThread(wxEvtHandler* receiver, wxURL* url) : 63 | receiver(receiver), 64 | url(url) 65 | { 66 | //// 67 | } 68 | 69 | UpdateConnectionThread::~UpdateConnectionThread() 70 | { 71 | //// 72 | } 73 | 74 | wxThread::ExitCode UpdateConnectionThread::Entry() 75 | { 76 | wxInputStream* input = url->GetInputStream(); 77 | if(!input) { 78 | delete input; 79 | delete url; 80 | return 0; 81 | } 82 | 83 | std::string data; 84 | while(!input->Eof()) { 85 | data += input->GetC(); 86 | } 87 | 88 | delete input; 89 | delete url; 90 | wxCommandEvent event(EVT_UPDATE_CHECK_FINISHED); 91 | event.SetClientData(newd std::string(data)); 92 | if(receiver) receiver->AddPendingEvent(event); 93 | return 0; 94 | } 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /source/ground_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_GROUND_BRUSH_H 2 | #define RME_GROUND_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | 8 | class GroundBrush : public TerrainBrush { 9 | protected: 10 | struct BorderBlock; 11 | public: 12 | static void init(); 13 | 14 | GroundBrush(); 15 | virtual ~GroundBrush(); 16 | 17 | bool isGround() const { return true; } 18 | GroundBrush* asGround() { return static_cast(this); } 19 | 20 | virtual bool load(pugi::xml_node node, wxArrayString& warnings); 21 | 22 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 23 | virtual void undraw(BaseMap* map, Tile* tile); 24 | static void doBorders(BaseMap* map, Tile* tile); 25 | static const BorderBlock* getBrushTo(GroundBrush* first, GroundBrush* second); 26 | 27 | virtual int32_t getZ() const {return z_order;} 28 | bool useSoloOptionalBorder() const {return use_only_optional;} 29 | bool isReRandomizable() const {return randomize;} 30 | 31 | bool hasOuterZilchBorder() const {return has_zilch_outer_border || optional_border;} 32 | bool hasInnerZilchBorder() const {return has_zilch_inner_border;} 33 | bool hasOuterBorder() const {return has_outer_border || optional_border;} 34 | bool hasInnerBorder() const {return has_inner_border;} 35 | bool hasOptionalBorder() const {return optional_border != nullptr;} 36 | protected: // Members 37 | int32_t z_order; 38 | bool has_zilch_outer_border; 39 | bool has_zilch_inner_border; 40 | bool has_outer_border; 41 | bool has_inner_border; 42 | AutoBorder* optional_border; 43 | bool use_only_optional; // If this is true, there will be no normal border under the gravel 44 | bool randomize; 45 | 46 | struct SpecificCaseBlock { 47 | SpecificCaseBlock() : match_group(0), group_match_alignment(BORDER_NONE), to_replace_id(0), with_id(0), delete_all(false) {} 48 | std::vector items_to_match; 49 | uint32_t match_group; 50 | BorderType group_match_alignment; 51 | uint16_t to_replace_id; 52 | uint16_t with_id; 53 | bool delete_all; 54 | }; 55 | 56 | struct BorderBlock { 57 | bool outer; 58 | bool super; 59 | uint32_t to; 60 | 61 | AutoBorder* autoborder; 62 | std::vector specific_cases; 63 | }; 64 | 65 | struct ItemChanceBlock { 66 | int chance; 67 | uint16_t id; 68 | }; 69 | 70 | struct BorderCluster { 71 | uint32_t alignment; 72 | int32_t z; 73 | const AutoBorder* border; 74 | 75 | bool operator<(const BorderCluster& other) const { 76 | return other.z > z; 77 | } 78 | }; 79 | 80 | std::vector borders; 81 | std::vector border_items; 82 | int total_chance; 83 | public: // Static global members 84 | static uint32_t border_types[256]; 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /source/pngfiles.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_PNG_HEADER_FILE_H_ 2 | #define RME_PNG_HEADER_FILE_H_ 3 | 4 | extern unsigned char circular_1_png[453]; 5 | extern unsigned char circular_1_small_png[253]; 6 | extern unsigned char circular_2_png[643]; 7 | extern unsigned char circular_2_small_png[318]; 8 | extern unsigned char circular_3_png[796]; 9 | extern unsigned char circular_3_small_png[398]; 10 | extern unsigned char circular_4_png[1076]; 11 | extern unsigned char circular_4_small_png[501]; 12 | extern unsigned char circular_5_png[1230]; 13 | extern unsigned char circular_5_small_png[600]; 14 | extern unsigned char circular_6_png[1467]; 15 | extern unsigned char circular_6_small_png[678]; 16 | extern unsigned char circular_7_png[1563]; 17 | extern unsigned char circular_7_small_png[740]; 18 | extern unsigned char door_locked_png[752]; 19 | extern unsigned char door_locked_small_png[552]; 20 | extern unsigned char door_magic_png[761]; 21 | extern unsigned char door_magic_small_png[552]; 22 | extern unsigned char door_normal_png[748]; 23 | extern unsigned char door_normal_small_png[552]; 24 | extern unsigned char door_quest_png[764]; 25 | extern unsigned char door_quest_small_png[552]; 26 | extern unsigned char eraser_png[878]; 27 | extern unsigned char eraser_small_png[667]; 28 | extern unsigned char gem_edit_png[697]; 29 | extern unsigned char gem_move_png[662]; 30 | extern unsigned char no_logout_png[782]; 31 | extern unsigned char no_logout_small_png[670]; 32 | extern unsigned char no_pvp_png[726]; 33 | extern unsigned char no_pvp_small_png[630]; 34 | extern unsigned char optional_border_png[768]; 35 | extern unsigned char optional_border_small_png[544]; 36 | extern unsigned char protection_zone_png[961]; 37 | extern unsigned char protection_zone_small_png[687]; 38 | extern unsigned char pvp_zone_png[677]; 39 | extern unsigned char pvp_zone_small_png[620]; 40 | extern unsigned char rectangular_1_png[353]; 41 | extern unsigned char rectangular_1_small_png[250]; 42 | extern unsigned char rectangular_2_png[393]; 43 | extern unsigned char rectangular_2_small_png[248]; 44 | extern unsigned char rectangular_3_png[424]; 45 | extern unsigned char rectangular_3_small_png[276]; 46 | extern unsigned char rectangular_4_png[483]; 47 | extern unsigned char rectangular_4_small_png[333]; 48 | extern unsigned char rectangular_5_png[535]; 49 | extern unsigned char rectangular_5_small_png[375]; 50 | extern unsigned char rectangular_6_png[600]; 51 | extern unsigned char rectangular_6_small_png[431]; 52 | extern unsigned char rectangular_7_png[697]; 53 | extern unsigned char rectangular_7_small_png[429]; 54 | extern unsigned char window_hatch_png[910]; 55 | extern unsigned char window_hatch_small_png[641]; 56 | extern unsigned char window_normal_png[947]; 57 | extern unsigned char window_normal_small_png[641]; 58 | #endif //_RME_PNG_HEADER_FILE_H_ 59 | -------------------------------------------------------------------------------- /source/iomap_otmm.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/iomap_otmm.h $ 18 | // $Id: iomap_otmm.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_OTMM_IOMAP_H_ 21 | #define RME_OTMM_IOMAP_H_ 22 | 23 | #include "iomap.h" 24 | 25 | #pragma pack(1) 26 | 27 | enum OTMM_VERSION { 28 | OTMM_VERSION_1, 29 | }; 30 | 31 | enum OTMM_TileAttributes { 32 | OTMM_ATTR_TILE_FLAGS = 1, 33 | }; 34 | 35 | enum OTMM_ItemAttribute { 36 | OTMM_ATTR_DESCRIPTION = 1, 37 | OTMM_ATTR_ACTION_ID = 2, 38 | OTMM_ATTR_UNIQUE_ID = 3, 39 | OTMM_ATTR_TEXT = 4, 40 | OTMM_ATTR_DESC = 5, 41 | OTMM_ATTR_TELE_DEST = 6, 42 | OTMM_ATTR_ITEM = 7, 43 | OTMM_ATTR_SUBTYPE = 8, 44 | OTMM_ATTR_DEPOT_ID = 9, 45 | OTMM_ATTR_DOOR_ID = 10, 46 | OTMM_ATTR_DURATION = 11, 47 | }; 48 | 49 | enum OTMM_NodeTypes { 50 | OTMM_ROOT = 1, 51 | OTMM_MAP_DATA = 2, 52 | OTMM_TILE_DATA = 3, 53 | OTMM_TILE = 4, 54 | OTMM_HOUSETILE = 5, 55 | OTMM_ITEM = 6, 56 | OTMM_SPAWN_DATA = 7, 57 | OTMM_SPAWN_AREA = 8, 58 | OTMM_MONSTER = 9, 59 | OTMM_NPC = 10, 60 | OTMM_TOWN_DATA = 11, 61 | OTMM_TOWN = 12, 62 | OTMM_HOUSE_DATA = 13, 63 | OTMM_HOUSE = 14, 64 | OTMM_DESCRIPTION = 15, 65 | OTMM_EDITOR = 16, 66 | }; 67 | 68 | #pragma pack() 69 | 70 | class NodeFileReadHandle; 71 | class NodeFileWriteHandle; 72 | 73 | class IOMapOTMM : public IOMap { 74 | public: 75 | IOMapOTMM(); 76 | ~IOMapOTMM(); 77 | 78 | virtual MapVersion getVersionInfo(const FileName& identifier); 79 | 80 | virtual bool loadMap(Map& map, NodeFileReadHandle& handle, const FileName& identifier, bool showdialog); 81 | virtual bool loadMap(Map& map, const FileName& identifier, bool showdialog); 82 | 83 | virtual bool saveMap(Map& map, NodeFileWriteHandle& handle, const FileName& identifier, bool showdialog); 84 | virtual bool saveMap(Map& map, const FileName& identifier, bool showdialog); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /source/town.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/town.h $ 18 | // $Id: town.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_TOWN_H_ 21 | #define RME_TOWN_H_ 22 | 23 | #include "position.h" 24 | 25 | class Town 26 | { 27 | public: 28 | Town(uint32_t _id) : id(_id), name("") {} 29 | Town(const Town& copy) : id(copy.id), name(copy.name), templepos(copy.templepos) {} 30 | ~Town() {} 31 | 32 | const std::string& getName() const { return name; } 33 | void setName(const std::string& newName) { name = newName; } 34 | 35 | const Position& getTemplePosition() const {return templepos;} 36 | void setTemplePosition(const Position& _pos); 37 | 38 | uint32_t getID() const {return id;} 39 | void setID(uint32_t _id) {id = _id;} 40 | private: 41 | uint32_t id; 42 | std::string name; 43 | Position templepos; 44 | }; 45 | 46 | typedef std::map TownMap; 47 | 48 | class Towns 49 | { 50 | public: 51 | Towns(); 52 | ~Towns(); 53 | 54 | // Clears the townmap 55 | void clear(); 56 | 57 | uint32_t count() const {return towns.size();} 58 | 59 | bool addTown(Town* town); 60 | uint32_t getEmptyID(); 61 | 62 | Town* getTown(std::string& townname); 63 | Town* getTown(uint32_t _townid); 64 | 65 | TownMap::const_iterator begin() const{return towns.begin();} 66 | TownMap::const_iterator end() const{return towns.end();} 67 | TownMap::const_iterator find(uint32_t id) const {return towns.find(id);} 68 | TownMap::iterator begin() {return towns.begin();} 69 | TownMap::iterator end() {return towns.end();} 70 | TownMap::iterator find(uint32_t id) {return towns.find(id);} 71 | #ifdef __VISUALC__ // C++0x compliance to some degree :) 72 | TownMap::iterator erase(TownMap::iterator iter) {return towns.erase(iter);} 73 | #else 74 | void erase(TownMap::iterator iter) {towns.erase(iter);} 75 | #endif 76 | 77 | private: 78 | TownMap towns; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /source/tileset.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/tileset.h $ 18 | // $Id: tileset.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_TILESET_H_ 21 | #define RME_TILESET_H_ 22 | 23 | class Brushes; 24 | 25 | enum TilesetCategoryType { 26 | TILESET_UNKNOWN, 27 | TILESET_TERRAIN, 28 | TILESET_CREATURE, 29 | TILESET_DOODAD, 30 | TILESET_ITEM, 31 | TILESET_RAW, 32 | TILESET_HOUSE, 33 | TILESET_WAYPOINT, 34 | }; 35 | 36 | class TilesetCategory { 37 | public: 38 | TilesetCategory(Tileset& parent, TilesetCategoryType type); 39 | ~TilesetCategory(); 40 | 41 | bool isTrivial() const; 42 | TilesetCategoryType getType() const {return type;} 43 | size_t size() const {return brushlist.size();} 44 | 45 | void loadBrush(pugi::xml_node node, wxArrayString& warnings); 46 | void clear(); 47 | 48 | bool containsBrush(Brush* brush) const; 49 | 50 | protected: 51 | TilesetCategoryType type; 52 | public: 53 | std::vector brushlist; 54 | Tileset& tileset; 55 | 56 | private: 57 | TilesetCategory(const TilesetCategory&); 58 | TilesetCategory operator=(const TilesetCategory&); 59 | }; 60 | 61 | typedef std::vector TilesetCategoryArray; 62 | 63 | class Tileset { 64 | public: 65 | Tileset(Brushes& brushes, const std::string& name); 66 | ~Tileset(); 67 | 68 | TilesetCategory* getCategory(TilesetCategoryType type); 69 | const TilesetCategory* getCategory(TilesetCategoryType type) const; 70 | 71 | void loadCategory(pugi::xml_node node, wxArrayString& warnings); 72 | void clear(); 73 | 74 | bool containsBrush(Brush* brush) const; 75 | 76 | public: 77 | std::string name; 78 | TilesetCategoryArray categories; 79 | 80 | protected: 81 | Brushes& brushes; 82 | 83 | protected: 84 | Tileset(const Tileset&); 85 | Tileset operator=(const Tileset&); 86 | 87 | friend class TilesetCategory; 88 | }; 89 | 90 | typedef std::map TilesetContainer; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /source/brush_enums.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/brush_enums.h $ 18 | // $Id: brush_enums.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_BRUSH_ENUMS_H_ 21 | #define RME_BRUSH_ENUMS_H_ 22 | 23 | enum BorderType { 24 | // Border types (also used for carpets) 25 | BORDER_NONE = 0, 26 | NORTH_HORIZONTAL = 1, 27 | EAST_HORIZONTAL = 2, 28 | SOUTH_HORIZONTAL = 3, 29 | WEST_HORIZONTAL = 4, 30 | NORTHWEST_CORNER = 5, 31 | NORTHEAST_CORNER = 6, 32 | SOUTHWEST_CORNER = 7, 33 | SOUTHEAST_CORNER = 8, 34 | NORTHWEST_DIAGONAL = 9, 35 | NORTHEAST_DIAGONAL = 10, 36 | SOUTHEAST_DIAGONAL = 11, 37 | SOUTHWEST_DIAGONAL = 12, 38 | // Additional carpet type 39 | CARPET_CENTER = 13, 40 | // Wall types 41 | WALL_POLE = 0, 42 | WALL_SOUTH_END = 1, 43 | WALL_EAST_END = 2, 44 | WALL_NORTHWEST_DIAGONAL = 3, 45 | WALL_WEST_END = 4, 46 | WALL_NORTHEAST_DIAGONAL = 5, 47 | WALL_HORIZONTAL = 6, 48 | WALL_SOUTH_T = 7, 49 | WALL_NORTH_END = 8, 50 | WALL_VERTICAL = 9, 51 | WALL_SOUTHWEST_DIAGONAL = 10, 52 | WALL_EAST_T = 11, 53 | WALL_SOUTHEAST_DIAGONAL = 12, 54 | WALL_WEST_T = 13, 55 | WALL_NORTH_T = 14, 56 | WALL_INTERSECTION = 15, 57 | WALL_UNTOUCHABLE = 16, 58 | // Table types 59 | TABLE_NORTH_END = 0, 60 | TABLE_SOUTH_END = 1, 61 | TABLE_EAST_END = 2, 62 | TABLE_WEST_END = 3, 63 | TABLE_HORIZONTAL = 4, 64 | TABLE_VERTICAL = 5, 65 | TABLE_ALONE = 6, 66 | }; 67 | 68 | enum TileAlignement { 69 | TILE_NORTHWEST =1, 70 | TILE_NORTH = 2, 71 | TILE_NORTHEAST = 4, 72 | TILE_WEST = 8, 73 | TILE_EAST = 16, 74 | TILE_SOUTHWEST = 32, 75 | TILE_SOUTH = 64, 76 | TILE_SOUTHEAST = 128, 77 | WALLTILE_NORTH = 1, 78 | WALLTILE_WEST = 2, 79 | WALLTILE_EAST = 4, 80 | WALLTILE_SOUTH = 8, 81 | }; 82 | 83 | enum DoorType { 84 | WALL_UNDEFINED, 85 | WALL_ARCHWAY, 86 | WALL_DOOR_NORMAL, 87 | WALL_DOOR_LOCKED, 88 | WALL_DOOR_QUEST, 89 | WALL_DOOR_MAGIC, 90 | WALL_WINDOW, 91 | WALL_HATCH_WINDOW, 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /source/creatures.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/creatures.h $ 18 | // $Id: creatures.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_CREATURES_H_ 21 | #define RME_CREATURES_H_ 22 | 23 | #include "outfit.h" 24 | 25 | #include 26 | #include 27 | 28 | class CreatureType; 29 | class CreatureBrush; 30 | 31 | typedef std::map CreatureMap; 32 | 33 | class CreatureDatabase 34 | { 35 | protected: 36 | CreatureMap creature_map; 37 | 38 | public: 39 | typedef CreatureMap::iterator iterator; 40 | typedef CreatureMap::const_iterator const_iterator; 41 | 42 | CreatureDatabase(); 43 | ~CreatureDatabase(); 44 | 45 | void clear(); 46 | 47 | CreatureType* operator[](const std::string& name); 48 | CreatureType* addMissingCreatureType(const std::string& name, bool isNpc); 49 | CreatureType* addCreatureType(const std::string& name, bool isNpc, const Outfit& outfit); 50 | 51 | bool hasMissing() const; 52 | iterator begin() {return creature_map.begin();} 53 | iterator end() {return creature_map.end();} 54 | 55 | bool loadFromXML(const FileName& filename, bool standard, wxString& error, wxArrayString& warnings); 56 | bool importXMLFromOT(const FileName& filename, wxString& error, wxArrayString& warnings); 57 | 58 | bool saveToXML(const FileName& filename); 59 | }; 60 | 61 | class CreatureType { 62 | public: 63 | CreatureType(); 64 | CreatureType(const CreatureType& ct); 65 | CreatureType& operator=(const CreatureType& ct); 66 | ~CreatureType(); 67 | 68 | bool isNpc; 69 | bool missing; 70 | bool in_other_tileset; 71 | bool standard; 72 | std::string name; 73 | Outfit outfit; 74 | CreatureBrush* brush; 75 | 76 | static CreatureType* loadFromXML(pugi::xml_node node, wxArrayString& warnings); 77 | static CreatureType* loadFromOTXML(const FileName& filename, pugi::xml_document& node, wxArrayString& warnings); 78 | }; 79 | 80 | extern CreatureDatabase g_creatures; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /source/ext/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.2 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2012, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at http://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | // #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to disable XPath 21 | #define PUGIXML_NO_XPATH 22 | 23 | // Uncomment this to disable STL 24 | // #define PUGIXML_NO_STL 25 | 26 | // Uncomment this to disable exceptions 27 | // #define PUGIXML_NO_EXCEPTIONS 28 | 29 | // Set this to control attributes for public classes/functions, i.e.: 30 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 31 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 32 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 33 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 34 | 35 | // Uncomment this to switch to header-only version 36 | #define PUGIXML_HEADER_ONLY 37 | #include "pugixml.cpp" 38 | 39 | // Tune these constants to adjust memory-related behavior 40 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 41 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 42 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 43 | 44 | #endif 45 | 46 | /** 47 | * Copyright (c) 2006-2012 Arseny Kapoulkine 48 | * 49 | * Permission is hereby granted, free of charge, to any person 50 | * obtaining a copy of this software and associated documentation 51 | * files (the "Software"), to deal in the Software without 52 | * restriction, including without limitation the rights to use, 53 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 54 | * copies of the Software, and to permit persons to whom the 55 | * Software is furnished to do so, subject to the following 56 | * conditions: 57 | * 58 | * The above copyright notice and this permission notice shall be 59 | * included in all copies or substantial portions of the Software. 60 | * 61 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 62 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 63 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 64 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 65 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 66 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 67 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 68 | * OTHER DEALINGS IN THE SOFTWARE. 69 | */ 70 | -------------------------------------------------------------------------------- /source/dat_debug_view.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | #include "dat_debug_view.h" 4 | 5 | #include "graphics.h" 6 | #include "gui.h" 7 | 8 | // ============================================================================ 9 | // 10 | 11 | class DatDebugViewListBox : public wxVListBox 12 | { 13 | public: 14 | DatDebugViewListBox(wxWindow* parent, wxWindowID id); 15 | ~DatDebugViewListBox(); 16 | 17 | void OnDrawItem(wxDC& dc, const wxRect& rect, size_t index) const; 18 | wxCoord OnMeasureItem(size_t index) const; 19 | 20 | protected: 21 | typedef std::map SpriteMap; 22 | SpriteMap sprites; 23 | }; 24 | 25 | DatDebugViewListBox::DatDebugViewListBox(wxWindow* parent, wxWindowID id) : 26 | wxVListBox(parent, id, wxDefaultPosition, wxDefaultSize, wxLB_SINGLE) 27 | { 28 | int n = 0; 29 | for(int id = 0; id < g_gui.gfx.getItemSpriteMaxID(); ++id) { 30 | Sprite* spr = g_gui.gfx.getSprite(id); 31 | if(spr) { 32 | sprites[n] = spr; 33 | ++n; 34 | } 35 | } 36 | SetItemCount(n); 37 | } 38 | 39 | DatDebugViewListBox::~DatDebugViewListBox() 40 | { 41 | //// 42 | } 43 | 44 | void DatDebugViewListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const 45 | { 46 | SpriteMap::const_iterator spr_iter = sprites.find(int(n)); 47 | if(spr_iter != sprites.end()) 48 | spr_iter->second->DrawTo(&dc, SPRITE_SIZE_32x32, rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()); 49 | 50 | if(IsSelected(n)) { 51 | if(HasFocus()) 52 | dc.SetTextForeground(wxColor(0xFF, 0xFF, 0xFF)); 53 | else 54 | dc.SetTextForeground(wxColor(0x00, 0x00, 0xFF)); 55 | } else { 56 | dc.SetTextForeground(wxColor(0x00, 0x00, 0x00)); 57 | } 58 | 59 | dc.DrawText(wxString() << n, rect.GetX() + 40, rect.GetY() + 6); 60 | } 61 | 62 | wxCoord DatDebugViewListBox::OnMeasureItem(size_t n) const 63 | { 64 | return 32; 65 | } 66 | 67 | // ============================================================================ 68 | // 69 | 70 | BEGIN_EVENT_TABLE(DatDebugView, wxPanel) 71 | EVT_TEXT(wxID_ANY, DatDebugView::OnTextChange) 72 | EVT_LISTBOX_DCLICK(wxID_ANY, DatDebugView::OnClickList) 73 | END_EVENT_TABLE() 74 | 75 | DatDebugView::DatDebugView(wxWindow* parent) : wxPanel(parent) 76 | { 77 | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); 78 | 79 | search_field = newd wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize); 80 | search_field->SetFocus(); 81 | sizer->Add(search_field, 0, wxEXPAND, 2); 82 | 83 | item_list = newd DatDebugViewListBox(this, wxID_ANY); 84 | item_list->SetMinSize(wxSize(470, 400)); 85 | sizer->Add(item_list, 1, wxEXPAND | wxALL, 2); 86 | 87 | SetSizerAndFit(sizer); 88 | Centre(wxBOTH); 89 | } 90 | 91 | DatDebugView::~DatDebugView() 92 | { 93 | //// 94 | } 95 | 96 | void DatDebugView::OnTextChange(wxCommandEvent& evt) 97 | { 98 | //// 99 | } 100 | 101 | void DatDebugView::OnClickList(wxCommandEvent& evt) 102 | { 103 | //// 104 | } 105 | 106 | -------------------------------------------------------------------------------- /source/complexitem.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/complexitem.hpp $ 18 | // $Id: complexitem.hpp 264 2009-10-05 06:36:21Z remere $ 19 | 20 | #include "main.h" 21 | 22 | #include "complexitem.h" 23 | 24 | #include "iomap.h" 25 | 26 | // Container 27 | Container::Container(const uint16_t type) : Item(type, 0) 28 | { 29 | //// 30 | } 31 | 32 | Container::~Container() 33 | { 34 | for(Item* item : contents) { 35 | delete item; 36 | } 37 | } 38 | 39 | Item* Container::deepCopy() const 40 | { 41 | Item* copy = Item::deepCopy(); 42 | Container* copyContainer = dynamic_cast(copy); 43 | if(copyContainer) { 44 | for(Item* item : contents) { 45 | copyContainer->contents.push_back(item->deepCopy()); 46 | } 47 | } 48 | return copy; 49 | } 50 | 51 | Item* Container::getItem(size_t index) const 52 | { 53 | if(index < contents.size()) { 54 | return contents[index]; 55 | } 56 | return nullptr; 57 | } 58 | 59 | double Container::getWeight() 60 | { 61 | return g_items[id].weight; 62 | } 63 | 64 | // Teleport 65 | Teleport::Teleport(const uint16_t type) : Item(type, 0), 66 | destination(0, 0, 0) 67 | { 68 | //// 69 | } 70 | 71 | Item* Teleport::deepCopy() const 72 | { 73 | Teleport* copy = static_cast(Item::deepCopy()); 74 | copy->destination = destination; 75 | return copy; 76 | } 77 | 78 | // Door 79 | Door::Door(const uint16_t type) : Item(type, 0), 80 | doorId(0) 81 | { 82 | //// 83 | } 84 | 85 | Item* Door::deepCopy() const 86 | { 87 | Door* copy = static_cast(Item::deepCopy()); 88 | copy->doorId = doorId; 89 | return copy; 90 | } 91 | 92 | // Depot 93 | Depot::Depot(const uint16_t type) : Item(type, 0), 94 | depotId(0) 95 | { 96 | //// 97 | } 98 | 99 | Item* Depot::deepCopy() const 100 | { 101 | Item* copy = Item::deepCopy(); 102 | Depot* copy_depot = dynamic_cast(copy); 103 | if(copy_depot) { 104 | copy_depot->depotId = depotId; 105 | } 106 | return copy; 107 | } 108 | -------------------------------------------------------------------------------- /source/net_connection.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | #include "net_connection.h" 7 | 8 | NetworkMessage::NetworkMessage() 9 | { 10 | clear(); 11 | } 12 | 13 | void NetworkMessage::clear() 14 | { 15 | buffer.resize(4); 16 | position = 4; 17 | size = 0; 18 | } 19 | 20 | void NetworkMessage::expand(const size_t length) 21 | { 22 | if(position + length >= buffer.size()) { 23 | buffer.resize(position + length + 1); 24 | } 25 | size += length; 26 | } 27 | 28 | template<> std::string NetworkMessage::read() 29 | { 30 | const uint16_t length = read(); 31 | char* strBuffer = reinterpret_cast(&buffer[position]); 32 | position += length; 33 | return std::string(strBuffer, length); 34 | } 35 | 36 | template<> Position NetworkMessage::read() 37 | { 38 | Position position; 39 | position.x = read(); 40 | position.y = read(); 41 | position.z = read(); 42 | return position; 43 | } 44 | 45 | template<> void NetworkMessage::write(const std::string& value) 46 | { 47 | const size_t length = value.length(); 48 | write(length); 49 | 50 | expand(length); 51 | memcpy(&buffer[position], &value[0], length); 52 | position += length; 53 | } 54 | 55 | template<> void NetworkMessage::write(const Position& value) 56 | { 57 | write(value.x); 58 | write(value.y); 59 | write(value.z); 60 | } 61 | 62 | // NetworkConnection 63 | NetworkConnection::NetworkConnection() : 64 | service(nullptr), thread(), stopped(false) 65 | { 66 | // 67 | } 68 | 69 | NetworkConnection::~NetworkConnection() 70 | { 71 | stop(); 72 | } 73 | 74 | NetworkConnection& NetworkConnection::getInstance() 75 | { 76 | static NetworkConnection connection; 77 | return connection; 78 | } 79 | 80 | bool NetworkConnection::start() 81 | { 82 | if(thread.joinable()) { 83 | if(stopped) { 84 | return false; 85 | } 86 | return true; 87 | } 88 | 89 | stopped = false; 90 | if(!service) { 91 | service = new boost::asio::io_service; 92 | } 93 | 94 | thread = std::thread([this]() -> void { 95 | boost::asio::io_service& serviceRef = *service; 96 | try { 97 | while(!stopped) { 98 | serviceRef.run_one(); 99 | serviceRef.reset(); 100 | } 101 | } catch (std::exception& e) { 102 | std::cout << e.what() << std::endl; 103 | } 104 | }); 105 | return true; 106 | } 107 | 108 | void NetworkConnection::stop() 109 | { 110 | if(!service) { 111 | return; 112 | } 113 | 114 | service->stop(); 115 | stopped = true; 116 | thread.join(); 117 | 118 | delete service; 119 | service = nullptr; 120 | } 121 | 122 | boost::asio::io_service& NetworkConnection::get_service() 123 | { 124 | return *service; 125 | } 126 | -------------------------------------------------------------------------------- /source/selection.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_SELECTION_H 6 | #define RME_SELECTION_H 7 | 8 | #include "position.h" 9 | 10 | class Action; 11 | class Editor; 12 | class BatchAction; 13 | 14 | class SelectionThread; 15 | 16 | class Selection 17 | { 18 | public: 19 | Selection(Editor& editor); 20 | ~Selection(); 21 | 22 | // Selects the items on the tile/tiles 23 | // Won't work outside a selection session 24 | void add(Tile* tile, Item* item); 25 | void add(Tile* tile, Spawn* spawn); 26 | void add(Tile* tile, Creature* creature); 27 | void add(Tile* tile); 28 | void remove(Tile* tile, Item* item); 29 | void remove(Tile* tile, Spawn* spawn); 30 | void remove(Tile* tile, Creature* creature); 31 | void remove(Tile* tile); 32 | 33 | // The tile will be added to the list of selected tiles, however, the items on the tile won't be selected 34 | void addInternal(Tile* tile); 35 | void removeInternal(Tile* tile); 36 | 37 | // Clears the selection completely 38 | void clear(); 39 | 40 | // Returns true when inside a session 41 | bool isBusy() {return busy;} 42 | 43 | // 44 | Position minPosition() const; 45 | Position maxPosition() const; 46 | 47 | // This manages a "selection session" 48 | // Internal session doesn't store the result (eg. no undo) 49 | // Subthread means the session doesn't create a complete 50 | // action, just part of one to be merged with the main thread 51 | // later. 52 | enum SessionFlags { 53 | NONE, 54 | INTERNAL = 1, 55 | SUBTHREAD = 2, 56 | }; 57 | 58 | void start(SessionFlags flags = NONE); 59 | void commit(); 60 | void finish(SessionFlags flags = NONE); 61 | 62 | // Joins the selection instance in this thread with this instance 63 | // This deletes the thread 64 | void join(SelectionThread* thread); 65 | 66 | size_t size() {return tiles.size();} 67 | size_t size() const {return tiles.size();} 68 | void updateSelectionCount(); 69 | TileSet::iterator begin() {return tiles.begin();} 70 | TileSet::iterator end() {return tiles.end();} 71 | TileSet& getTiles() {return tiles; } 72 | Tile* getSelectedTile() {ASSERT(size() == 1); return *tiles.begin();} 73 | 74 | private: 75 | bool busy; 76 | Editor& editor; 77 | BatchAction* session; 78 | Action* subsession; 79 | 80 | TileSet tiles; 81 | 82 | friend class SelectionThread; 83 | }; 84 | 85 | class SelectionThread : public wxThread { 86 | public: 87 | SelectionThread(Editor& editor, Position start, Position end); 88 | virtual ~SelectionThread(); 89 | 90 | void Execute(); // Calls "Create" and then "Run" 91 | protected: 92 | virtual ExitCode Entry(); 93 | Editor& editor; 94 | Position start, end; 95 | Selection selection; 96 | Action* result; 97 | 98 | friend class Selection; 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /source/palette_creature.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/palette_creature.h $ 18 | // $Id: palette_creature.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | 21 | #ifndef RME_TILESET_CREATURE_H_ 22 | #define RME_TILESET_CREATURE_H_ 23 | 24 | #include "palette_common.h" 25 | 26 | class CreaturePalettePanel : public PalettePanel { 27 | public: 28 | CreaturePalettePanel(wxWindow* parent, wxWindowID id = wxID_ANY); 29 | virtual ~CreaturePalettePanel(); 30 | 31 | PaletteType GetType() const; 32 | 33 | // Select the first brush 34 | void SelectFirstBrush(); 35 | // Returns the currently selected brush (first brush if panel is not loaded) 36 | Brush* GetSelectedBrush() const; 37 | // Returns the currently selected brush size 38 | int GetSelectedBrushSize() const; 39 | // Select the brush in the parameter, this only changes the look of the panel 40 | bool SelectBrush(const Brush* whatbrush); 41 | 42 | // Updates the palette window to use the current brush size 43 | void OnUpdateBrushSize(BrushShape shape, int size); 44 | // Called when this page is displayed 45 | void OnSwitchIn(); 46 | // Called sometimes? 47 | void OnUpdate(); 48 | 49 | protected: 50 | void SelectTileset(size_t index); 51 | void SelectCreature(size_t index); 52 | void SelectCreature(std::string name); 53 | public: 54 | // Event handling 55 | void OnChangeSpawnTime(wxSpinEvent& event); 56 | void OnChangeSpawnSize(wxSpinEvent& event); 57 | 58 | void OnTilesetChange(wxCommandEvent& event); 59 | void OnListBoxChange(wxCommandEvent& event); 60 | void OnClickCreatureBrushButton(wxCommandEvent& event); 61 | void OnClickSpawnBrushButton(wxCommandEvent& event); 62 | protected: 63 | void SelectCreatureBrush(); 64 | void SelectSpawnBrush(); 65 | 66 | wxChoice* tileset_choice; 67 | SortableListBox* creature_list; 68 | wxToggleButton* creature_brush_button; 69 | wxToggleButton* spawn_brush_button; 70 | wxSpinCtrl* creature_spawntime_spin; 71 | wxSpinCtrl* spawn_size_spin; 72 | 73 | bool handling_event; 74 | 75 | DECLARE_EVENT_TABLE(); 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /source/house.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/house.h $ 18 | // $Id: house.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_HOUSE_H_ 21 | #define RME_HOUSE_H_ 22 | 23 | #include "position.h" 24 | 25 | class Map; 26 | class Tile; 27 | class Door; 28 | 29 | class Houses; 30 | 31 | class House { 32 | public: 33 | House(Map& map); 34 | ~House(); 35 | 36 | void clean(); 37 | void addTile(Tile* tile); 38 | void removeTile(Tile* tile); 39 | size_t size() const; 40 | std::string getDescription(); 41 | 42 | uint32_t id; 43 | int rent; 44 | //HouseDoorList doorList; 45 | std::string name; 46 | uint32_t townid; 47 | bool guildhall; 48 | 49 | void setExit(const Position& pos); 50 | void setExit(Map* map, const Position& pos); 51 | Position getExit() const {return exit;} 52 | uint8_t getEmptyDoorID() const; 53 | Position getDoorPositionByID(uint8_t id) const; 54 | protected: 55 | Map* map; 56 | PositionList tiles; 57 | Position exit; 58 | 59 | friend class Houses; 60 | }; 61 | 62 | typedef std::map HouseMap; 63 | 64 | class Houses { 65 | public: 66 | Houses(Map& map); 67 | ~Houses(); 68 | 69 | uint32_t count() const {return houses.size();} 70 | 71 | HouseMap::iterator begin() {return houses.begin();} 72 | HouseMap::iterator end() {return houses.end();} 73 | HouseMap::const_iterator begin() const {return houses.begin();} 74 | HouseMap::const_iterator end() const {return houses.end();} 75 | #ifdef __VISUALC__ // C++0x compliance to some degree :) 76 | HouseMap::iterator erase(HouseMap::iterator iter) {return houses.erase(iter);} 77 | #else 78 | void erase(HouseMap::iterator iter) {houses.erase(iter);} 79 | #endif 80 | HouseMap::iterator find(uint32_t val) {return houses.find(val);} 81 | 82 | void removeHouse(House* house_to_remove); 83 | void addHouse(House* new_house); 84 | House* getHouse(uint32_t houseid); 85 | const House* getHouse(uint32_t houseid) const; 86 | uint32_t getEmptyID(); 87 | protected: 88 | Map& map; 89 | uint32_t max_house_id; 90 | HouseMap houses; 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /source/doodad_brush.h: -------------------------------------------------------------------------------- 1 | #ifndef RME_DOODAD_BRUSH_H 2 | #define RME_DOODAD_BRUSH_H 3 | 4 | #include "brush.h" 5 | 6 | //============================================================================= 7 | // Doodadbrush, add doodads! 8 | 9 | typedef std::vector > CompositeTileList; 10 | 11 | class DoodadBrush : public Brush { 12 | public: 13 | DoodadBrush(); 14 | virtual ~DoodadBrush(); 15 | 16 | bool isDoodad() const { return true; } 17 | DoodadBrush* asDoodad() { return static_cast(this); } 18 | 19 | protected: 20 | struct AlternativeBlock; 21 | public: 22 | 23 | bool loadAlternative(pugi::xml_node node, wxArrayString& warnings, AlternativeBlock* which = nullptr); 24 | virtual bool load(pugi::xml_node node, wxArrayString& warnings); 25 | 26 | virtual bool canDraw(BaseMap* map, const Position& position) const {return true;} 27 | virtual void draw(BaseMap* map, Tile* tile, void* parameter); 28 | const CompositeTileList& getComposite(int variation) const; 29 | virtual void undraw(BaseMap* map, Tile* tile); 30 | 31 | bool isEmpty(int variation) const; 32 | 33 | int getThickness() const {return thickness;} 34 | int getThicknessCeiling() const {return thickness_ceiling;} 35 | 36 | int getCompositeChance(int variation) const; 37 | int getSingleChance(int variation) const; 38 | int getTotalChance(int variation) const; 39 | 40 | bool hasSingleObjects(int variation) const; 41 | bool hasCompositeObjects(int variation) const; 42 | 43 | bool placeOnBlocking() const {return on_blocking;} 44 | bool placeOnDuplicate() const {return on_duplicate;} 45 | bool doNewBorders() const {return do_new_borders;} 46 | bool ownsItem(Item* item) const; 47 | 48 | virtual bool canSmear() const {return draggable;} 49 | virtual bool canDrag() const {return false;} 50 | virtual bool oneSizeFitsAll() const {return one_size;} 51 | virtual int getLookID() const {return look_id;} 52 | virtual int getMaxVariation() const {return alternatives.size();} 53 | virtual std::string getName() const {return name;} 54 | virtual void setName(const std::string& newName) { name = newName; } 55 | 56 | protected: 57 | std::string name; 58 | uint16_t look_id; 59 | 60 | int thickness; 61 | int thickness_ceiling; 62 | 63 | bool draggable; 64 | bool on_blocking; 65 | bool one_size; 66 | bool do_new_borders; 67 | bool on_duplicate; 68 | uint16_t clear_mapflags; 69 | uint16_t clear_statflags; 70 | 71 | struct SingleBlock { 72 | int chance; 73 | Item* item; 74 | }; 75 | 76 | struct CompositeBlock { 77 | int chance; 78 | CompositeTileList items; 79 | }; 80 | 81 | struct AlternativeBlock { 82 | AlternativeBlock(); 83 | ~AlternativeBlock(); 84 | bool ownsItem(uint16_t id) const; 85 | std::vector single_items; 86 | std::vector composite_items; 87 | 88 | int composite_chance; // Total chance of a composite 89 | int single_chance; // Total chance of a single object 90 | }; 91 | 92 | std::vector alternatives; 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /source/positionctrl.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #include "main.h" 19 | #include "positionctrl.h" 20 | #include "numbertextctrl.h" 21 | #include "position.h" 22 | 23 | PositionCtrl::PositionCtrl(wxWindow* parent, const wxString& label, int x, int y, int z, 24 | int maxx /*= MAP_MAX_WIDTH*/, int maxy /*= MAP_MAX_HEIGHT*/, int maxz /*= MAP_MAX_LAYER*/) : 25 | wxStaticBoxSizer(wxHORIZONTAL, parent, label) 26 | { 27 | x_field = newd NumberTextCtrl(parent, wxID_ANY, x, 0, maxx, wxTE_PROCESS_ENTER, "X", wxDefaultPosition, wxSize(60, 20)); 28 | x_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this); 29 | Add(x_field, 2, wxEXPAND | wxLEFT | wxBOTTOM, 5); 30 | 31 | y_field = newd NumberTextCtrl(parent, wxID_ANY, y, 0, maxy, wxTE_PROCESS_ENTER, "Y", wxDefaultPosition, wxSize(60, 20)); 32 | y_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this); 33 | Add(y_field, 2, wxEXPAND | wxLEFT | wxBOTTOM, 5); 34 | 35 | z_field = newd NumberTextCtrl(parent, wxID_ANY, z, 0, maxz, wxTE_PROCESS_ENTER, "Z", wxDefaultPosition, wxSize(35, 20)); 36 | z_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this); 37 | Add(z_field, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); 38 | } 39 | 40 | PositionCtrl::~PositionCtrl() 41 | { 42 | //// 43 | } 44 | 45 | Position PositionCtrl::GetPosition() const 46 | { 47 | Position pos; 48 | pos.x = x_field->GetIntValue(); 49 | pos.y = y_field->GetIntValue(); 50 | pos.z = z_field->GetIntValue(); 51 | return pos; 52 | } 53 | 54 | void PositionCtrl::SetPosition(Position pos) 55 | { 56 | x_field->SetIntValue(pos.x); 57 | y_field->SetIntValue(pos.y); 58 | z_field->SetIntValue(pos.z); 59 | } 60 | 61 | bool PositionCtrl::Enable(bool enable) 62 | { 63 | return (x_field->Enable(enable) && y_field->Enable(enable) && z_field->Enable(enable)); 64 | } 65 | 66 | void PositionCtrl::OnClipboardText(wxClipboardTextEvent& evt) 67 | { 68 | Position position; 69 | if(posFromClipboard(position.x, position.y, position.z)) { 70 | x_field->SetIntValue(position.x); 71 | y_field->SetIntValue(position.y); 72 | z_field->SetIntValue(position.z); 73 | } else { 74 | evt.Skip(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /source/live_action.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "main.h" 6 | 7 | #include "live_action.h" 8 | #include "editor.h" 9 | 10 | NetworkedAction::NetworkedAction(Editor& editor, ActionIdentifier ident) : 11 | Action(editor, ident), 12 | owner(0) 13 | { 14 | ; 15 | } 16 | 17 | NetworkedAction::~NetworkedAction() 18 | { 19 | ; 20 | } 21 | 22 | NetworkedBatchAction::NetworkedBatchAction(Editor& editor, NetworkedActionQueue& queue, ActionIdentifier ident) : 23 | BatchAction(editor, ident), 24 | queue(queue) 25 | { 26 | ; 27 | } 28 | 29 | NetworkedBatchAction::~NetworkedBatchAction() 30 | { 31 | ; 32 | } 33 | 34 | void NetworkedBatchAction::addAndCommitAction(Action* action) 35 | { 36 | // If empty, do nothing. 37 | if(action->size() == 0) { 38 | delete action; 39 | return; 40 | } 41 | 42 | // Track changed nodes... 43 | DirtyList dirty_list; 44 | NetworkedAction* netact = dynamic_cast(action); 45 | if(netact) 46 | dirty_list.owner = netact->owner; 47 | 48 | // Add it! 49 | action->commit(type != ACTION_SELECT? &dirty_list : nullptr); 50 | batch.push_back(action); 51 | timestamp = time(nullptr); 52 | 53 | // Broadcast changes! 54 | queue.broadcast(dirty_list); 55 | } 56 | 57 | void NetworkedBatchAction::commit() 58 | { 59 | // Track changed nodes... 60 | DirtyList dirty_list; 61 | 62 | for(ActionVector::iterator it = batch.begin(); it != batch.end(); ++it) { 63 | NetworkedAction* action = static_cast(*it); 64 | if(!action->isCommited()) { 65 | action->commit(type != ACTION_SELECT? &dirty_list : nullptr); 66 | if(action->owner != 0) 67 | dirty_list.owner = action->owner; 68 | } 69 | } 70 | // Broadcast changes! 71 | queue.broadcast(dirty_list); 72 | } 73 | 74 | void NetworkedBatchAction::undo() 75 | { 76 | // Track changed nodes... 77 | DirtyList dirty_list; 78 | 79 | for(ActionVector::reverse_iterator it = batch.rbegin(); it != batch.rend(); ++it) { 80 | (*it)->undo(type != ACTION_SELECT? &dirty_list : nullptr); 81 | } 82 | // Broadcast changes! 83 | queue.broadcast(dirty_list); 84 | } 85 | 86 | void NetworkedBatchAction::redo() 87 | { 88 | commit(); 89 | } 90 | 91 | 92 | //=================== 93 | // Action queue 94 | 95 | NetworkedActionQueue::NetworkedActionQueue(Editor& editor) : ActionQueue(editor) 96 | { 97 | } 98 | 99 | NetworkedActionQueue::~NetworkedActionQueue() 100 | { 101 | } 102 | 103 | Action* NetworkedActionQueue::createAction(ActionIdentifier ident) 104 | { 105 | return newd NetworkedAction(editor, ident); 106 | } 107 | 108 | BatchAction* NetworkedActionQueue::createBatch(ActionIdentifier ident) 109 | { 110 | return newd NetworkedBatchAction(editor, *this, ident); 111 | } 112 | 113 | void NetworkedActionQueue::broadcast(DirtyList& dirty_list) 114 | { 115 | editor.BroadcastNodes(dirty_list); 116 | } 117 | -------------------------------------------------------------------------------- /source/mt_rand.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/mt_rand.hpp $ 5 | // $Id: mt_rand.hpp 293 2010-02-16 02:29:50Z admin $ 6 | 7 | #include "main.h" 8 | 9 | static inline unsigned long int mt_get (void *vstate); 10 | static double mt_get_double (void *vstate); 11 | static void mt_set (void *state, unsigned long int s); 12 | 13 | #define N 624 /* Period parameters */ 14 | #define M 397 15 | 16 | /* most significant w-r bits */ 17 | static const unsigned long UPPER_MASK = 0x80000000UL; 18 | 19 | /* least significant r bits */ 20 | static const unsigned long LOWER_MASK = 0x7fffffffUL; 21 | 22 | typedef struct 23 | { 24 | unsigned long mt[N]; 25 | int mti; 26 | } 27 | mt_state_t; 28 | 29 | static inline unsigned long 30 | mt_get (void *vstate) 31 | { 32 | mt_state_t *state = (mt_state_t *) vstate; 33 | 34 | unsigned long k ; 35 | unsigned long int *const mt = state->mt; 36 | 37 | #define MAGIC(y) (((y)&0x1) ? 0x9908b0dfUL : 0) 38 | 39 | if(state->mti >= N) 40 | { /* generate N words at one time */ 41 | int kk; 42 | 43 | for(kk = 0; kk < N - M; kk++) 44 | { 45 | unsigned long y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); 46 | mt[kk] = mt[kk + M] ^ (y >> 1) ^ MAGIC(y); 47 | } 48 | for(; kk < N - 1; kk++) 49 | { 50 | unsigned long y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); 51 | mt[kk] = mt[kk + (M - N)] ^ (y >> 1) ^ MAGIC(y); 52 | } 53 | 54 | { 55 | unsigned long y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); 56 | mt[N - 1] = mt[M - 1] ^ (y >> 1) ^ MAGIC(y); 57 | } 58 | 59 | state->mti = 0; 60 | } 61 | 62 | /* Tempering */ 63 | 64 | k = mt[state->mti]; 65 | k ^= (k >> 11); 66 | k ^= (k << 7) & 0x9d2c5680UL; 67 | k ^= (k << 15) & 0xefc60000UL; 68 | k ^= (k >> 18); 69 | 70 | state->mti++; 71 | 72 | return k; 73 | } 74 | 75 | static double 76 | mt_get_double (void * vstate) 77 | { 78 | return mt_get (vstate) / 4294967296.0 ; 79 | } 80 | 81 | static void 82 | mt_set (void *vstate, unsigned long int s) 83 | { 84 | mt_state_t *state = (mt_state_t *) vstate; 85 | int i; 86 | 87 | if(s == 0) 88 | s = 4357; /* the default seed is 4357 */ 89 | 90 | state->mt[0]= s & 0xffffffffUL; 91 | 92 | for(i = 1; i < N; i++) 93 | { 94 | /* See Knuth's "Art of Computer Programming" Vol. 2, 3rd 95 | Ed. p.106 for multiplier. */ 96 | 97 | state->mt[i] = 98 | (1812433253UL * (state->mt[i-1] ^ (state->mt[i-1] >> 30)) + i); 99 | 100 | state->mt[i] &= 0xffffffffUL; 101 | } 102 | 103 | state->mti = i; 104 | } 105 | 106 | static mt_state_t mt_state; 107 | 108 | void mt_seed(unsigned long s) { 109 | mt_set(&mt_state, s); 110 | } 111 | 112 | unsigned long mt_randi() { 113 | return mt_get(&mt_state); 114 | } 115 | 116 | double mt_randd() { 117 | return mt_get_double(&mt_state); 118 | } 119 | -------------------------------------------------------------------------------- /source/application.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/application.h $ 18 | // $Id: application.h 298 2010-02-23 17:09:13Z admin $ 19 | 20 | #ifndef RME_APPLICATION_H_ 21 | #define RME_APPLICATION_H_ 22 | 23 | #include "gui.h" 24 | #include "action.h" 25 | #include "settings.h" 26 | 27 | #include "process_com.h" 28 | #include "map_display.h" 29 | 30 | class Item; 31 | class Creature; 32 | 33 | class MainFrame; 34 | class MapWindow; 35 | class wxEventLoopBase; 36 | class wxSingleInstanceChecker; 37 | 38 | class Application : public wxApp 39 | { 40 | public: 41 | ~Application(); 42 | virtual bool OnInit(); 43 | virtual void OnEventLoopEnter(wxEventLoopBase* loop); 44 | virtual void MacOpenFiles(const wxArrayString& fileNames); 45 | virtual int OnExit(); 46 | void Unload(); 47 | 48 | private: 49 | bool m_startup; 50 | wxString m_fileToOpen; 51 | 52 | void FixVersionDiscrapencies(); 53 | bool ParseCommandLineMap(wxString& fileName); 54 | 55 | virtual void OnFatalException(); 56 | 57 | #ifdef _USE_PROCESS_COM 58 | RMEProcessServer* m_proc_server; 59 | wxSingleInstanceChecker* m_single_instance_checker; 60 | #endif 61 | 62 | }; 63 | 64 | class MainMenuBar; 65 | 66 | class MainFrame : public wxFrame 67 | { 68 | public: 69 | MainFrame(const wxString& title, 70 | const wxPoint& pos, const wxSize& size); 71 | ~MainFrame(); 72 | 73 | void UpdateMenubar(); 74 | bool DoQueryClose(); 75 | bool DoQuerySave(bool doclose = true); 76 | bool DoQueryImportCreatures(); 77 | bool LoadMap(FileName name); 78 | 79 | void AddRecentFile(const FileName& file); 80 | void LoadRecentFiles(); 81 | void SaveRecentFiles(); 82 | 83 | void OnUpdateMenus(wxCommandEvent& event); 84 | void UpdateFloorMenu(); 85 | void OnIdle(wxIdleEvent& event); 86 | void OnExit(wxCloseEvent& event); 87 | 88 | #ifdef _USE_UPDATER_ 89 | void OnUpdateReceived(wxCommandEvent& event); 90 | #endif 91 | 92 | #ifdef __WINDOWS__ 93 | virtual bool MSWTranslateMessage(WXMSG *msg); 94 | #endif 95 | 96 | void PrepareDC(wxDC& dc); 97 | protected: 98 | MainMenuBar* menu_bar; 99 | 100 | friend class Application; 101 | friend class GUI; 102 | 103 | DECLARE_EVENT_TABLE() 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /source/palette_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef RME_PALETTE_H_ 6 | #define RME_PALETTE_H_ 7 | 8 | #include "palette_common.h" 9 | 10 | class BrushPalettePanel; 11 | class CreaturePalettePanel; 12 | class HousePalettePanel; 13 | class WaypointPalettePanel; 14 | 15 | class PaletteWindow : public wxPanel { 16 | public: 17 | PaletteWindow(wxWindow* parent, const TilesetContainer& tilesets); 18 | ~PaletteWindow(); 19 | 20 | // Interface 21 | // Reloads layout g_settings from g_settings (and using map) 22 | void ReloadSettings(Map* from); 23 | // Flushes all pages and forces them to be reloaded from the palette data again 24 | void InvalidateContents(); 25 | // (Re)Loads all currently displayed data, called from InvalidateContents implicitly 26 | void LoadCurrentContents(); 27 | // Goes to the selected page and selects any brush there 28 | void SelectPage(PaletteType palette); 29 | // The currently selected brush in this palette 30 | Brush* GetSelectedBrush() const; 31 | // The currently selected brush size in this palette 32 | int GetSelectedBrushSize() const; 33 | // The currently selected page (terrain, doodad...) 34 | PaletteType GetSelectedPage() const; 35 | 36 | // Custom Event handlers (something has changed?) 37 | // Finds the brush pointed to by whatbrush and selects it as the current brush (also changes page) 38 | // Returns if the brush was found in this palette 39 | virtual bool OnSelectBrush(const Brush* whatbrush, PaletteType primary = TILESET_UNKNOWN); 40 | // Updates the palette window to use the current brush size 41 | virtual void OnUpdateBrushSize(BrushShape shape, int size); 42 | // Updates the content of the palette (eg. houses, creatures) 43 | virtual void OnUpdate(Map* map); 44 | 45 | // wxWidgets Event Handlers 46 | void OnSwitchingPage(wxChoicebookEvent& event); 47 | void OnPageChanged(wxChoicebookEvent& event); 48 | // Forward key events to the parent window (The Map Window) 49 | void OnKey(wxKeyEvent& event); 50 | void OnClose(wxCloseEvent&); 51 | protected: 52 | static PalettePanel* CreateTerrainPalette(wxWindow* parent, const TilesetContainer& tilesets); 53 | static PalettePanel* CreateDoodadPalette(wxWindow* parent, const TilesetContainer& tilesets); 54 | static PalettePanel* CreateItemPalette(wxWindow* parent, const TilesetContainer& tilesets); 55 | static PalettePanel* CreateCreaturePalette(wxWindow* parent, const TilesetContainer& tilesets); 56 | static PalettePanel* CreateHousePalette(wxWindow* parent, const TilesetContainer& tilesets); 57 | static PalettePanel* CreateWaypointPalette(wxWindow* parent, const TilesetContainer& tilesets); 58 | static PalettePanel* CreateRAWPalette(wxWindow* parent, const TilesetContainer& tilesets); 59 | 60 | wxChoicebook* choicebook; 61 | 62 | BrushPalettePanel* terrain_palette; 63 | BrushPalettePanel* doodad_palette; 64 | BrushPalettePanel* item_palette; 65 | CreaturePalettePanel* creature_palette; 66 | HousePalettePanel* house_palette; 67 | WaypointPalettePanel* waypoint_palette; 68 | BrushPalettePanel* raw_palette; 69 | 70 | DECLARE_EVENT_TABLE() 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /source/common.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/common.h $ 5 | // $Id: common.h 298 2010-02-23 17:09:13Z admin $ 6 | 7 | #ifndef RME_COMMONS_H_ 8 | #define RME_COMMONS_H_ 9 | 10 | #include "main.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "mt_rand.h" 18 | 19 | // 20 | inline bool testFlags(size_t flags, size_t test) { 21 | return (flags & test) != 0; 22 | } 23 | 24 | int32_t uniform_random(int32_t minNumber, int32_t maxNumber); 25 | int32_t uniform_random(int32_t maxNumber); 26 | 27 | // Function-like convertions between float, int and doubles 28 | std::string i2s(int i); 29 | std::string f2s(double i); 30 | int s2i(std::string s); 31 | double s2f(std::string s); 32 | wxString i2ws(int i); 33 | wxString f2ws(double i); 34 | int ws2i(wxString s); 35 | double ws2f(wxString s); 36 | double frand(); 37 | 38 | // replaces all instances of sought in str with replacement 39 | void replaceString(std::string& str, const std::string sought, const std::string replacement); 40 | // Removes all characters in t from source (from either start or beginning of the string) 41 | void trim_right(std::string& source, const std::string& t); 42 | void trim_left(std::string& source, const std::string& t); 43 | // Converts the argument to lower/uppercase 44 | void to_lower_str(std::string& source); 45 | void to_upper_str(std::string& source); 46 | std::string as_lower_str(const std::string& other); 47 | std::string as_upper_str(const std::string& other); 48 | 49 | // isFalseString returns true if the string is either "0", "false", "no", "not" or blank 50 | // isTrueString returns the opposite value of isFalseString 51 | bool isFalseString(std::string& str); 52 | bool isTrueString(std::string& str); 53 | 54 | // Generates a random number between low and high using the mersenne twister 55 | int random(int high); 56 | int random(int low, int high); 57 | 58 | // Unicode conversions 59 | std::wstring string2wstring(const std::string& utf8string); 60 | std::string wstring2string(const std::wstring& widestring); 61 | 62 | // Gets position values from ClipBoard 63 | bool posFromClipboard(int& x, int& y, int& z); 64 | 65 | // Returns 'yes' if the defined value is true or 'no' if it is false. 66 | wxString b2yn(bool v); 67 | 68 | // Standard math functions 69 | template 70 | inline T abs(T t) { 71 | return (t < 0? -t : t); 72 | } 73 | 74 | template 75 | inline T min(T t, U u) { 76 | return (t < u? t : u); 77 | } 78 | 79 | template 80 | T max(T t, U u) { 81 | return (t > u? t : u); 82 | } 83 | 84 | template 85 | inline T min(T t, U u, V v) { 86 | int min = t; 87 | if ( u < min ) min = u; 88 | if ( v < min ) min = v; 89 | return min; 90 | } 91 | 92 | template 93 | inline T max(T t, U u, V v) { 94 | int max = t; 95 | if ( u > max ) max = u; 96 | if ( v > max ) max = v; 97 | return max; 98 | } 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /source/find_item_window.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef RME_FIND_ITEM_WINDOW_H_ 19 | #define RME_FIND_ITEM_WINDOW_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class FindDialogListBox; 31 | 32 | class FindItemDialog : public wxDialog 33 | { 34 | public: 35 | enum SearchMode { 36 | ServerIDs = 0, 37 | ClientIDs, 38 | Names, 39 | Types, 40 | Properties, 41 | }; 42 | 43 | enum SearchItemType { 44 | Depot, 45 | Mailbox, 46 | TrashHolder, 47 | Container, 48 | Door, 49 | MagicField, 50 | Teleport, 51 | Bed, 52 | Key 53 | }; 54 | 55 | FindItemDialog(wxWindow* parent, const wxString& title, bool onlyPickupables = false); 56 | ~FindItemDialog(); 57 | 58 | Brush* getResult() const { return result_brush; } 59 | uint16_t getResultID() const { return result_id; } 60 | 61 | SearchMode getSearchMode() const; 62 | void setSearchMode(SearchMode mode); 63 | 64 | private: 65 | void EnableProperties(bool enable); 66 | void RefreshContentsInternal(); 67 | 68 | void OnOptionChange(wxCommandEvent& event); 69 | void OnServerIdChange(wxCommandEvent& event); 70 | void OnClientIdChange(wxCommandEvent& event); 71 | void OnText(wxCommandEvent& event); 72 | void OnTypeChange(wxCommandEvent& event); 73 | void OnPropertyChange(wxCommandEvent& event); 74 | void OnClickOK(wxCommandEvent& event); 75 | void OnClickCancel(wxCommandEvent& event); 76 | 77 | wxRadioBox* options_radio_box; 78 | 79 | wxRadioBox* types_radio_box; 80 | 81 | wxSpinCtrl* server_id_spin; 82 | wxSpinCtrl* client_id_spin; 83 | wxTextCtrl* name_text_input; 84 | wxCheckBox* unpassable; 85 | wxCheckBox* unmovable; 86 | wxCheckBox* block_missiles; 87 | wxCheckBox* block_pathfinder; 88 | wxCheckBox* readable; 89 | wxCheckBox* writeable; 90 | wxCheckBox* pickupable; 91 | wxCheckBox* stackable; 92 | wxCheckBox* rotatable; 93 | wxCheckBox* hangable; 94 | wxCheckBox* hook_east; 95 | wxCheckBox* hook_south; 96 | wxCheckBox* has_elevation; 97 | wxCheckBox* ignore_look; 98 | wxCheckBox* floor_change; 99 | 100 | FindDialogListBox* items_list; 101 | wxStdDialogButtonSizer* buttons_box_sizer; 102 | wxButton* ok_button; 103 | wxButton* cancel_button; 104 | Brush* result_brush; 105 | uint16_t result_id; 106 | 107 | DECLARE_EVENT_TABLE() 108 | }; 109 | 110 | #endif // RME_FIND_ITEM_WINDOW_H_ 111 | -------------------------------------------------------------------------------- /source/numbertextctrl.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // This file is part of Remere's Map Editor 3 | ////////////////////////////////////////////////////////////////////// 4 | // This program 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 | // 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, see . 16 | ////////////////////////////////////////////////////////////////////// 17 | // $URL: http://svn.rebarp.se/svn/RME/trunk/source/numbertextctrl.hpp $ 18 | // $Id: numbertextctrl.hpp 280 2010-02-14 23:46:31Z admin $ 19 | 20 | #include "main.h" 21 | #include "numbertextctrl.h" 22 | 23 | BEGIN_EVENT_TABLE(NumberTextCtrl, wxTextCtrl) 24 | EVT_KILL_FOCUS(NumberTextCtrl::OnKillFocus) 25 | EVT_TEXT_ENTER(wxID_ANY, NumberTextCtrl::OnTextEnter) 26 | END_EVENT_TABLE() 27 | 28 | NumberTextCtrl::NumberTextCtrl(wxWindow* parent, wxWindowID id, 29 | long value, long minvalue, long maxvalue, 30 | const wxPoint& pos, const wxSize& sz, 31 | long style, const wxString& name) : 32 | wxTextCtrl(parent, id, (wxString() << value), pos, sz, style, wxTextValidator(wxFILTER_NUMERIC), name), 33 | minval(minvalue), maxval(maxvalue), lastval(value) 34 | { 35 | //// 36 | } 37 | 38 | NumberTextCtrl::NumberTextCtrl(wxWindow* parent, wxWindowID id, 39 | long value, long minvalue, long maxvalue, 40 | long style, const wxString& name, 41 | const wxPoint& pos, const wxSize& sz) : 42 | wxTextCtrl(parent, id, (wxString() << value), pos, sz, style, wxTextValidator(wxFILTER_NUMERIC), name), 43 | minval(minvalue), maxval(maxvalue), lastval(value) 44 | { 45 | //// 46 | } 47 | 48 | NumberTextCtrl::~NumberTextCtrl() 49 | { 50 | //// 51 | } 52 | 53 | void NumberTextCtrl::OnKillFocus(wxFocusEvent& evt) 54 | { 55 | CheckRange(); 56 | evt.Skip(); 57 | } 58 | 59 | void NumberTextCtrl::OnTextEnter(wxCommandEvent& evt) 60 | { 61 | CheckRange(); 62 | } 63 | 64 | void NumberTextCtrl::SetIntValue(long v) 65 | { 66 | wxString sv; 67 | sv << v; 68 | // Will generate events 69 | SetValue(sv); 70 | } 71 | 72 | long NumberTextCtrl::GetIntValue() 73 | { 74 | long l; 75 | if(GetValue().ToLong(&l)) 76 | return l; 77 | return 0; 78 | } 79 | 80 | void NumberTextCtrl::CheckRange() 81 | { 82 | wxString text = GetValue(); 83 | wxString ntext; 84 | 85 | for(size_t s = 0; s < text.size(); ++s) { 86 | if(text[s] >= '0' && text[s] <= '9') 87 | ntext.Append(text[s]); 88 | } 89 | 90 | // Check that value is in range 91 | long v; 92 | if(ntext.size() != 0 && ntext.ToLong(&v)) { 93 | if(v < minval) 94 | v = minval; 95 | else if(v > maxval) 96 | v = maxval; 97 | 98 | ntext.clear(); 99 | ntext << v; 100 | lastval = v; 101 | } else { 102 | ntext.clear(); 103 | ntext << lastval; 104 | } 105 | 106 | // Check if there was any change 107 | if(ntext != text) { 108 | // ChangeValue doesn't generate events 109 | ChangeValue(ntext); 110 | } 111 | } 112 | 113 | --------------------------------------------------------------------------------