From 40ce538aad9af8f7634c4ba7e9f12246fb23b31c Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Thu, 16 Mar 2017 10:34:54 +0100 Subject: [CSM] Add minimap API modifiers (#5399) * Rename Mapper (too generic) to Minimap * Add lua functions to get/set position, angle, mode for minimap * Client: rename m_mapper to m_minimap * Add minimap to core.ui namespace (core.ui.minimap) * Add various functions to manage minimap (show, hide, toggle_shape) * Cleanup trivial declaration in client --- src/script/lua_api/l_minimap.h | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/script/lua_api/l_minimap.h (limited to 'src/script/lua_api/l_minimap.h') diff --git a/src/script/lua_api/l_minimap.h b/src/script/lua_api/l_minimap.h new file mode 100644 index 000000000..d9bb8842c --- /dev/null +++ b/src/script/lua_api/l_minimap.h @@ -0,0 +1,64 @@ +/* +Minetest +Copyright (C) 2017 Loic Blot + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef L_MINIMAP_H_ +#define L_MINIMAP_H_ + +#include "l_base.h" + + +class Minimap; + +class LuaMinimap : public ModApiBase { +private: + + static const char className[]; + static const luaL_reg methods[]; + + // garbage collector + static int gc_object(lua_State *L); + + static int l_get_pos(lua_State *L); + static int l_set_pos(lua_State *L); + + static int l_get_angle(lua_State *L); + static int l_set_angle(lua_State *L); + + static int l_get_mode(lua_State *L); + static int l_set_mode(lua_State *L); + + static int l_show(lua_State *L); + static int l_hide(lua_State *L); + + static int l_toggle_shape(lua_State *L); + + Minimap *m_minimap; +public: + LuaMinimap(Minimap *m); + ~LuaMinimap() {} + + static void create(lua_State *L, Minimap *object); + + static LuaMinimap *checkobject(lua_State *L, int narg); + static Minimap* getobject(LuaMinimap *ref); + + static void Register(lua_State *L); +}; + +#endif // L_MINIMAP_H_ -- cgit v1.2.3 From 4af99b75cf3ae43c365a4c1e90e85f8ec764cf62 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Fri, 7 Apr 2017 23:22:00 +0200 Subject: Pass clang-format on 14 trivial header files fixes Also remove them from whitelist --- src/script/cpp_api/s_client.h | 4 +- src/script/cpp_api/s_player.h | 14 ++-- src/script/lua_api/l_areastore.h | 5 +- src/script/lua_api/l_metadata.h | 7 +- src/script/lua_api/l_minimap.h | 8 +-- src/script/lua_api/l_nodetimer.h | 7 +- src/script/lua_api/l_noise.h | 27 ++++---- src/script/lua_api/l_server.h | 4 +- src/script/lua_api/l_settings.h | 30 ++++----- src/threading/event.h | 10 +-- src/threading/semaphore.h | 14 ++-- src/tileanimation.h | 25 ++++--- src/touchscreengui.h | 115 +++++++++++++++++---------------- src/util/cpp11_container.h | 16 ++--- util/travis/clang-format-whitelist.txt | 14 ---- 15 files changed, 146 insertions(+), 154 deletions(-) (limited to 'src/script/lua_api/l_minimap.h') diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h index 2369efe3e..9afc66d61 100644 --- a/src/script/cpp_api/s_client.h +++ b/src/script/cpp_api/s_client.h @@ -22,8 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define S_CLIENT_H_ #include "cpp_api/s_base.h" -#include "util/string.h" #include "mapnode.h" +#include "util/string.h" #ifdef _CRT_MSVCP_CURRENT #include @@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class ClientEnvironment; -class ScriptApiClient: virtual public ScriptApiBase +class ScriptApiClient : virtual public ScriptApiBase { public: // Calls on_shutdown handlers diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h index 86ee1b024..9b4611f9e 100644 --- a/src/script/cpp_api/s_player.h +++ b/src/script/cpp_api/s_player.h @@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., struct ToolCapabilities; -class ScriptApiPlayer - : virtual public ScriptApiBase +class ScriptApiPlayer : virtual public ScriptApiBase { public: virtual ~ScriptApiPlayer(); @@ -36,17 +35,16 @@ public: void on_dieplayer(ServerActiveObject *player); bool on_respawnplayer(ServerActiveObject *player); bool on_prejoinplayer(const std::string &name, const std::string &ip, - std::string *reason); + std::string *reason); void on_joinplayer(ServerActiveObject *player); void on_leaveplayer(ServerActiveObject *player, bool timeout); void on_cheat(ServerActiveObject *player, const std::string &cheat_type); - bool on_punchplayer(ServerActiveObject *player, - ServerActiveObject *hitter, float time_from_last_punch, - const ToolCapabilities *toolcap, v3f dir, s16 damage); + bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter, + float time_from_last_punch, const ToolCapabilities *toolcap, + v3f dir, s16 damage); s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change); void on_playerReceiveFields(ServerActiveObject *player, - const std::string &formname, const StringMap &fields); + const std::string &formname, const StringMap &fields); }; - #endif /* S_PLAYER_H_ */ diff --git a/src/script/lua_api/l_areastore.h b/src/script/lua_api/l_areastore.h index 4bd94cebe..7dea08df4 100644 --- a/src/script/lua_api/l_areastore.h +++ b/src/script/lua_api/l_areastore.h @@ -22,12 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "lua_api/l_base.h" - class AreaStore; -class LuaAreaStore : public ModApiBase { +class LuaAreaStore : public ModApiBase +{ private: - static const char className[]; static const luaL_reg methods[]; diff --git a/src/script/lua_api/l_metadata.h b/src/script/lua_api/l_metadata.h index 561be6adf..be31d95ad 100644 --- a/src/script/lua_api/l_metadata.h +++ b/src/script/lua_api/l_metadata.h @@ -19,8 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef L_METADATA_H_ #define L_METADATA_H_ -#include "lua_api/l_base.h" #include "irrlichttypes_bloated.h" +#include "lua_api/l_base.h" class Metadata; @@ -28,14 +28,15 @@ class Metadata; NodeMetaRef */ -class MetaDataRef : public ModApiBase { +class MetaDataRef : public ModApiBase +{ public: virtual ~MetaDataRef() {} protected: static MetaDataRef *checkobject(lua_State *L, int narg); virtual void reportMetadataChange() {} - virtual Metadata* getmeta(bool auto_create) = 0; + virtual Metadata *getmeta(bool auto_create) = 0; virtual void clearMeta() = 0; virtual void handleToTable(lua_State *L, Metadata *meta); diff --git a/src/script/lua_api/l_minimap.h b/src/script/lua_api/l_minimap.h index d9bb8842c..9a299b4fd 100644 --- a/src/script/lua_api/l_minimap.h +++ b/src/script/lua_api/l_minimap.h @@ -22,12 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "l_base.h" - class Minimap; -class LuaMinimap : public ModApiBase { +class LuaMinimap : public ModApiBase +{ private: - static const char className[]; static const luaL_reg methods[]; @@ -49,6 +48,7 @@ private: static int l_toggle_shape(lua_State *L); Minimap *m_minimap; + public: LuaMinimap(Minimap *m); ~LuaMinimap() {} @@ -56,7 +56,7 @@ public: static void create(lua_State *L, Minimap *object); static LuaMinimap *checkobject(lua_State *L, int narg); - static Minimap* getobject(LuaMinimap *ref); + static Minimap *getobject(LuaMinimap *ref); static void Register(lua_State *L); }; diff --git a/src/script/lua_api/l_nodetimer.h b/src/script/lua_api/l_nodetimer.h index 9f8dd21c8..239112037 100644 --- a/src/script/lua_api/l_nodetimer.h +++ b/src/script/lua_api/l_nodetimer.h @@ -20,12 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef L_NODETIMER_H_ #define L_NODETIMER_H_ -#include "lua_api/l_base.h" #include "irr_v3d.h" +#include "lua_api/l_base.h" class ServerEnvironment; -class NodeTimerRef : public ModApiBase { +class NodeTimerRef : public ModApiBase +{ private: v3s16 m_p; ServerEnvironment *m_env; @@ -62,6 +63,4 @@ public: static void Register(lua_State *L); }; - - #endif /* L_NODETIMER_H_ */ diff --git a/src/script/lua_api/l_noise.h b/src/script/lua_api/l_noise.h index 40bfd1315..11ec348bf 100644 --- a/src/script/lua_api/l_noise.h +++ b/src/script/lua_api/l_noise.h @@ -20,14 +20,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef L_NOISE_H_ #define L_NOISE_H_ -#include "lua_api/l_base.h" #include "irr_v3d.h" +#include "lua_api/l_base.h" #include "noise.h" /* LuaPerlinNoise */ -class LuaPerlinNoise : public ModApiBase { +class LuaPerlinNoise : public ModApiBase +{ private: NoiseParams np; static const char className[]; @@ -57,7 +58,8 @@ public: /* LuaPerlinNoiseMap */ -class LuaPerlinNoiseMap : public ModApiBase { +class LuaPerlinNoiseMap : public ModApiBase +{ NoiseParams np; Noise *noise; bool m_is3d; @@ -95,7 +97,8 @@ public: /* LuaPseudoRandom */ -class LuaPseudoRandom : public ModApiBase { +class LuaPseudoRandom : public ModApiBase +{ private: PseudoRandom m_pseudo; @@ -111,8 +114,7 @@ private: static int l_next(lua_State *L); public: - LuaPseudoRandom(s32 seed) : - m_pseudo(seed) {} + LuaPseudoRandom(s32 seed) : m_pseudo(seed) {} // LuaPseudoRandom(seed) // Creates an LuaPseudoRandom and leaves it on top of stack @@ -126,7 +128,8 @@ public: /* LuaPcgRandom */ -class LuaPcgRandom : public ModApiBase { +class LuaPcgRandom : public ModApiBase +{ private: PcgRandom m_rnd; @@ -146,10 +149,8 @@ private: static int l_rand_normal_dist(lua_State *L); public: - LuaPcgRandom(u64 seed) : - m_rnd(seed) {} - LuaPcgRandom(u64 seed, u64 seq) : - m_rnd(seed, seq) {} + LuaPcgRandom(u64 seed) : m_rnd(seed) {} + LuaPcgRandom(u64 seed, u64 seq) : m_rnd(seed, seq) {} // LuaPcgRandom(seed) // Creates an LuaPcgRandom and leaves it on top of stack @@ -160,11 +161,11 @@ public: static void Register(lua_State *L); }; - /* LuaSecureRandom */ -class LuaSecureRandom : public ModApiBase { +class LuaSecureRandom : public ModApiBase +{ private: static const size_t RAND_BUF_SIZE = 2048; static const char className[]; diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h index 1ad46d440..ca5e7b80f 100644 --- a/src/script/lua_api/l_server.h +++ b/src/script/lua_api/l_server.h @@ -22,7 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "lua_api/l_base.h" -class ModApiServer : public ModApiBase { +class ModApiServer : public ModApiBase +{ private: // request_shutdown([message], [reconnect]) static int l_request_shutdown(lua_State *L); @@ -107,7 +108,6 @@ private: public: static void Initialize(lua_State *L, int top); - }; #endif /* L_SERVER_H_ */ diff --git a/src/script/lua_api/l_settings.h b/src/script/lua_api/l_settings.h index bca333e31..d5edd32ce 100644 --- a/src/script/lua_api/l_settings.h +++ b/src/script/lua_api/l_settings.h @@ -24,51 +24,51 @@ with this program; if not, write to the Free Software Foundation, Inc., class Settings; -class LuaSettings : public ModApiBase { +class LuaSettings : public ModApiBase +{ private: static const char className[]; static const luaL_reg methods[]; // garbage collector - static int gc_object(lua_State* L); + static int gc_object(lua_State *L); // get(self, key) -> value - static int l_get(lua_State* L); + static int l_get(lua_State *L); // get_bool(self, key) -> boolean - static int l_get_bool(lua_State* L); + static int l_get_bool(lua_State *L); // set(self, key, value) - static int l_set(lua_State* L); + static int l_set(lua_State *L); // remove(self, key) -> success - static int l_remove(lua_State* L); + static int l_remove(lua_State *L); // get_names(self) -> {key1, ...} - static int l_get_names(lua_State* L); + static int l_get_names(lua_State *L); // write(self) -> success - static int l_write(lua_State* L); + static int l_write(lua_State *L); // to_table(self) -> {[key1]=value1,...} - static int l_to_table(lua_State* L); + static int l_to_table(lua_State *L); bool m_write_allowed; - Settings* m_settings; + Settings *m_settings; std::string m_filename; public: - LuaSettings(const char* filename, bool write_allowed); + LuaSettings(const char *filename, bool write_allowed); ~LuaSettings(); // LuaSettings(filename) // Creates an LuaSettings and leaves it on top of stack - static int create_object(lua_State* L); + static int create_object(lua_State *L); - static LuaSettings* checkobject(lua_State* L, int narg); - - static void Register(lua_State* L); + static LuaSettings *checkobject(lua_State *L, int narg); + static void Register(lua_State *L); }; #endif diff --git a/src/threading/event.h b/src/threading/event.h index 26cb8997a..79a99ce1f 100644 --- a/src/threading/event.h +++ b/src/threading/event.h @@ -29,19 +29,19 @@ DEALINGS IN THE SOFTWARE. #include "threads.h" #if USE_CPP11_MUTEX - #include - #include "threading/mutex.h" - #include "threading/mutex_auto_lock.h" +#include +#include "threading/mutex.h" +#include "threading/mutex_auto_lock.h" #endif - /** A syncronization primitive that will wake up one waiting thread when signaled. * Calling @c signal() multiple times before a waiting thread has had a chance * to notice the signal will wake only one thread. Additionally, if no threads * are waiting on the event when it is signaled, the next call to @c wait() * will return (almost) immediately. */ -class Event { +class Event +{ public: Event(); #ifndef USE_CPP11_MUTEX diff --git a/src/threading/semaphore.h b/src/threading/semaphore.h index 822856396..8ff376666 100644 --- a/src/threading/semaphore.h +++ b/src/threading/semaphore.h @@ -21,21 +21,22 @@ with this program; if not, write to the Free Software Foundation, Inc., #define THREADING_SEMAPHORE_H #if defined(_WIN32) - #include +#include #elif defined(__MACH__) && defined(__APPLE__) - #include +#include #else - #include +#include #endif #include "util/basic_macros.h" -class Semaphore { +class Semaphore +{ public: - Semaphore(int val=0); + Semaphore(int val = 0); ~Semaphore(); - void post(unsigned int num=1); + void post(unsigned int num = 1); void wait(); bool wait(unsigned int time_ms); @@ -52,4 +53,3 @@ private: }; #endif - diff --git a/src/tileanimation.h b/src/tileanimation.h index eecd3eb96..9872e7917 100644 --- a/src/tileanimation.h +++ b/src/tileanimation.h @@ -20,36 +20,41 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef TILEANIMATION_HEADER #define TILEANIMATION_HEADER -#include "irrlichttypes_bloated.h" #include +#include "irrlichttypes_bloated.h" -enum TileAnimationType { +enum TileAnimationType +{ TAT_NONE = 0, TAT_VERTICAL_FRAMES = 1, TAT_SHEET_2D = 2, }; -struct TileAnimationParams { +struct TileAnimationParams +{ enum TileAnimationType type; - union { + union + { // struct { // } none; - struct { + struct + { int aspect_w; // width for aspect ratio int aspect_h; // height for aspect ratio float length; // seconds } vertical_frames; - struct { - int frames_w; // number of frames left-to-right - int frames_h; // number of frames top-to-bottom + struct + { + int frames_w; // number of frames left-to-right + int frames_h; // number of frames top-to-bottom float frame_length; // seconds } sheet_2d; }; void serialize(std::ostream &os, u16 protocol_version) const; void deSerialize(std::istream &is, u16 protocol_version); - void determineParams(v2u32 texture_size, int *frame_count, - int *frame_length_ms, v2u32 *frame_size) const; + void determineParams(v2u32 texture_size, int *frame_count, int *frame_length_ms, + v2u32 *frame_size) const; void getTextureModifer(std::ostream &os, v2u32 texture_size, int frame) const; v2f getTextureCoords(v2u32 texture_size, int frame) const; }; diff --git a/src/touchscreengui.h b/src/touchscreengui.h index 53fc6d683..88e068308 100644 --- a/src/touchscreengui.h +++ b/src/touchscreengui.h @@ -19,15 +19,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef TOUCHSCREENGUI_HEADER #define TOUCHSCREENGUI_HEADER -#include -#include #include +#include +#include -#include #include +#include -#include "game.h" #include "client/tile.h" +#include "game.h" using namespace irr; using namespace irr::core; @@ -68,32 +68,32 @@ typedef enum { #define SETTINGS_BAR_Y_OFFSET 6.5 #define RARE_CONTROLS_BAR_Y_OFFSET 4 -extern const char** touchgui_button_imagenames; +extern const char **touchgui_button_imagenames; -struct button_info { - float repeatcounter; - float repeatdelay; - irr::EKEY_CODE keycode; +struct button_info +{ + float repeatcounter; + float repeatdelay; + irr::EKEY_CODE keycode; std::vector ids; - IGUIButton* guibutton = NULL; - bool immediate_release; + IGUIButton *guibutton = NULL; + bool immediate_release; }; class AutoHideButtonBar { public: + AutoHideButtonBar(IrrlichtDevice *device, IEventReceiver *receiver); - AutoHideButtonBar( IrrlichtDevice *device, IEventReceiver* receiver ); - - void init(ISimpleTextureSource* tsrc, const char* starter_img, - int button_id, v2s32 UpperLeft, v2s32 LowerRight, - autohide_button_bar_dir dir, float timeout); + void init(ISimpleTextureSource *tsrc, const char *starter_img, int button_id, + v2s32 UpperLeft, v2s32 LowerRight, autohide_button_bar_dir dir, + float timeout); ~AutoHideButtonBar(); /* add button to be shown */ - void addButton(touch_gui_button_id id, const wchar_t* caption, - const char* btn_image); + void addButton(touch_gui_button_id id, const wchar_t *caption, + const char *btn_image); /* detect settings bar button events */ bool isButton(const SEvent &event); @@ -114,40 +114,41 @@ public: void show(); private: - ISimpleTextureSource* m_texturesource; - irr::video::IVideoDriver* m_driver; - IGUIEnvironment* m_guienv; - IEventReceiver* m_receiver; - v2u32 m_screensize; - button_info m_starter; - std::vector m_buttons; + ISimpleTextureSource *m_texturesource; + irr::video::IVideoDriver *m_driver; + IGUIEnvironment *m_guienv; + IEventReceiver *m_receiver; + v2u32 m_screensize; + button_info m_starter; + std::vector m_buttons; - v2s32 m_upper_left; - v2s32 m_lower_right; + v2s32 m_upper_left; + v2s32 m_lower_right; /* show settings bar */ - bool m_active; + bool m_active; - bool m_visible; + bool m_visible; /* settings bar timeout */ - float m_timeout; - float m_timeout_value; - bool m_initialized; - autohide_button_bar_dir m_dir; + float m_timeout; + float m_timeout_value; + bool m_initialized; + autohide_button_bar_dir m_dir; }; class TouchScreenGUI { public: - TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver); + TouchScreenGUI(IrrlichtDevice *device, IEventReceiver *receiver); ~TouchScreenGUI(); void translateEvent(const SEvent &event); - void init(ISimpleTextureSource* tsrc); + void init(ISimpleTextureSource *tsrc); - double getYawChange() { + double getYawChange() + { double res = m_camera_yaw_change; m_camera_yaw_change = 0; return res; @@ -166,28 +167,28 @@ public: void show(); private: - IrrlichtDevice* m_device; - IGUIEnvironment* m_guienv; - IEventReceiver* m_receiver; - ISimpleTextureSource* m_texturesource; - v2u32 m_screensize; - std::map > m_hud_rects; - std::map m_hud_ids; - bool m_visible; // is the gui visible + IrrlichtDevice *m_device; + IGUIEnvironment *m_guienv; + IEventReceiver *m_receiver; + ISimpleTextureSource *m_texturesource; + v2u32 m_screensize; + std::map> m_hud_rects; + std::map m_hud_ids; + bool m_visible; // is the gui visible /* value in degree */ - double m_camera_yaw_change; - double m_camera_pitch; + double m_camera_yaw_change; + double m_camera_pitch; - line3d m_shootline; + line3d m_shootline; - rect m_control_pad_rect; + rect m_control_pad_rect; - int m_move_id; - bool m_move_has_really_moved; - s32 m_move_downtime; - bool m_move_sent_as_mouse_event; - v2s32 m_move_downlocation; + int m_move_id; + bool m_move_has_really_moved; + s32 m_move_downtime; + bool m_move_sent_as_mouse_event; + v2s32 m_move_downlocation; button_info m_buttons[after_last_element_id]; @@ -206,9 +207,10 @@ private: float repeat_delay = BUTTON_REPEAT_DELAY); /* load texture */ - void loadButtonTexture(button_info* btn, const char* path, rect button_rect); + void loadButtonTexture(button_info *btn, const char *path, rect button_rect); - struct id_status{ + struct id_status + { int id; int X; int Y; @@ -236,7 +238,8 @@ private: int getGuiButtonSize(); /* doubleclick detection variables */ - struct key_event { + struct key_event + { unsigned int down_time; s32 x; s32 y; diff --git a/src/util/cpp11_container.h b/src/util/cpp11_container.h index 88317c9c4..0194385fc 100644 --- a/src/util/cpp11_container.h +++ b/src/util/cpp11_container.h @@ -29,15 +29,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif #ifdef USE_UNORDERED_CONTAINERS - #include - #include - #define UNORDERED_MAP std::unordered_map - #define UNORDERED_SET std::unordered_set +#include +#include +#define UNORDERED_MAP std::unordered_map +#define UNORDERED_SET std::unordered_set #else - #include - #include - #define UNORDERED_MAP std::map - #define UNORDERED_SET std::set +#include +#include +#define UNORDERED_MAP std::map +#define UNORDERED_SET std::set #endif #endif diff --git a/util/travis/clang-format-whitelist.txt b/util/travis/clang-format-whitelist.txt index fb3b21271..1f8c10ebb 100644 --- a/util/travis/clang-format-whitelist.txt +++ b/util/travis/clang-format-whitelist.txt @@ -248,7 +248,6 @@ src/script/cpp_api/s_async.h src/script/cpp_api/s_base.cpp src/script/cpp_api/s_base.h src/script/cpp_api/s_client.cpp -src/script/cpp_api/s_client.h src/script/cpp_api/s_entity.cpp src/script/cpp_api/s_entity.h src/script/cpp_api/s_env.cpp @@ -265,13 +264,11 @@ src/script/cpp_api/s_node.h src/script/cpp_api/s_nodemeta.cpp src/script/cpp_api/s_nodemeta.h src/script/cpp_api/s_player.cpp -src/script/cpp_api/s_player.h src/script/cpp_api/s_security.cpp src/script/cpp_api/s_security.h src/script/cpp_api/s_server.cpp src/script/cpp_api/s_server.h src/script/lua_api/l_areastore.cpp -src/script/lua_api/l_areastore.h src/script/lua_api/l_base.cpp src/script/lua_api/l_base.h src/script/lua_api/l_craft.cpp @@ -291,15 +288,11 @@ src/script/lua_api/l_mainmenu.cpp src/script/lua_api/l_mainmenu.h src/script/lua_api/l_mapgen.cpp src/script/lua_api/l_metadata.cpp -src/script/lua_api/l_metadata.h src/script/lua_api/l_minimap.cpp -src/script/lua_api/l_minimap.h src/script/lua_api/l_nodemeta.cpp src/script/lua_api/l_nodemeta.h src/script/lua_api/l_nodetimer.cpp -src/script/lua_api/l_nodetimer.h src/script/lua_api/l_noise.cpp -src/script/lua_api/l_noise.h src/script/lua_api/l_object.cpp src/script/lua_api/l_object.h src/script/lua_api/l_particles.cpp @@ -307,9 +300,7 @@ src/script/lua_api/l_particles.h src/script/lua_api/l_rollback.cpp src/script/lua_api/l_rollback.h src/script/lua_api/l_server.cpp -src/script/lua_api/l_server.h src/script/lua_api/l_settings.cpp -src/script/lua_api/l_settings.h src/script/lua_api/l_sound.cpp src/script/lua_api/l_storage.cpp src/script/lua_api/l_util.cpp @@ -347,21 +338,17 @@ src/terminal_chat_console.cpp src/terminal_chat_console.h src/threading/atomic.h src/threading/event.cpp -src/threading/event.h src/threading/mutex_auto_lock.h src/threading/mutex.cpp src/threading/mutex.h src/threading/semaphore.cpp -src/threading/semaphore.h src/threading/thread.cpp src/threading/thread.h src/threads.h src/tileanimation.cpp -src/tileanimation.h src/tool.cpp src/tool.h src/touchscreengui.cpp -src/touchscreengui.h src/treegen.cpp src/treegen.h src/unittest/test_areastore.cpp @@ -398,7 +385,6 @@ src/util/base64.cpp src/util/base64.h src/util/basic_macros.h src/util/container.h -src/util/cpp11_container.h src/util/directiontables.cpp src/util/directiontables.h src/util/enriched_string.cpp -- cgit v1.2.3 From 41c54830242269de073e4a0c10d1775dfdf6811d Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 8 Apr 2017 09:28:37 +0200 Subject: Replace luaL_reg with luaL_Reg as recent LuaJIT dropped the Lua 5.0 compat (#5541) We are bundling Lua5.1 which has same macro --- src/script/lua_api/l_areastore.cpp | 4 ++-- src/script/lua_api/l_areastore.h | 2 +- src/script/lua_api/l_inventory.cpp | 2 +- src/script/lua_api/l_inventory.h | 2 +- src/script/lua_api/l_item.cpp | 2 +- src/script/lua_api/l_item.h | 2 +- src/script/lua_api/l_itemstackmeta.cpp | 2 +- src/script/lua_api/l_itemstackmeta.h | 2 +- src/script/lua_api/l_minimap.cpp | 2 +- src/script/lua_api/l_minimap.h | 2 +- src/script/lua_api/l_nodemeta.cpp | 4 ++-- src/script/lua_api/l_nodemeta.h | 4 ++-- src/script/lua_api/l_nodetimer.cpp | 2 +- src/script/lua_api/l_nodetimer.h | 2 +- src/script/lua_api/l_noise.cpp | 10 +++++----- src/script/lua_api/l_noise.h | 10 +++++----- src/script/lua_api/l_object.cpp | 2 +- src/script/lua_api/l_object.h | 2 +- src/script/lua_api/l_settings.cpp | 2 +- src/script/lua_api/l_settings.h | 2 +- src/script/lua_api/l_storage.cpp | 2 +- src/script/lua_api/l_storage.h | 2 +- src/script/lua_api/l_vmanip.cpp | 2 +- src/script/lua_api/l_vmanip.h | 2 +- 24 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/script/lua_api/l_minimap.h') diff --git a/src/script/lua_api/l_areastore.cpp b/src/script/lua_api/l_areastore.cpp index 09a5c78f9..b81985a7f 100644 --- a/src/script/lua_api/l_areastore.cpp +++ b/src/script/lua_api/l_areastore.cpp @@ -74,7 +74,7 @@ static inline void push_areas(lua_State *L, const std::vector &areas, static int deserialization_helper(lua_State *L, AreaStore *as, std::istream &is) { - try { + try { as->deserialize(is); } catch (const SerializationError &e) { lua_pushboolean(L, false); @@ -380,7 +380,7 @@ void LuaAreaStore::Register(lua_State *L) } const char LuaAreaStore::className[] = "AreaStore"; -const luaL_reg LuaAreaStore::methods[] = { +const luaL_Reg LuaAreaStore::methods[] = { luamethod(LuaAreaStore, get_area), luamethod(LuaAreaStore, get_areas_for_pos), luamethod(LuaAreaStore, get_areas_in_area), diff --git a/src/script/lua_api/l_areastore.h b/src/script/lua_api/l_areastore.h index 7dea08df4..8292e7712 100644 --- a/src/script/lua_api/l_areastore.h +++ b/src/script/lua_api/l_areastore.h @@ -28,7 +28,7 @@ class LuaAreaStore : public ModApiBase { private: static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; static int gc_object(lua_State *L); diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index 9a4aa845d..f5e76a7b6 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -463,7 +463,7 @@ void InvRef::Register(lua_State *L) } const char InvRef::className[] = "InvRef"; -const luaL_reg InvRef::methods[] = { +const luaL_Reg InvRef::methods[] = { luamethod(InvRef, is_empty), luamethod(InvRef, get_size), luamethod(InvRef, set_size), diff --git a/src/script/lua_api/l_inventory.h b/src/script/lua_api/l_inventory.h index cc5333965..91d41c0d0 100644 --- a/src/script/lua_api/l_inventory.h +++ b/src/script/lua_api/l_inventory.h @@ -36,7 +36,7 @@ private: InventoryLocation m_loc; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; static InvRef *checkobject(lua_State *L, int narg); diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp index 7e6f457e1..19b5b0955 100644 --- a/src/script/lua_api/l_item.cpp +++ b/src/script/lua_api/l_item.cpp @@ -462,7 +462,7 @@ void LuaItemStack::Register(lua_State *L) } const char LuaItemStack::className[] = "ItemStack"; -const luaL_reg LuaItemStack::methods[] = { +const luaL_Reg LuaItemStack::methods[] = { luamethod(LuaItemStack, is_empty), luamethod(LuaItemStack, get_name), luamethod(LuaItemStack, set_name), diff --git a/src/script/lua_api/l_item.h b/src/script/lua_api/l_item.h index 1ba5d79e0..b4efaefc8 100644 --- a/src/script/lua_api/l_item.h +++ b/src/script/lua_api/l_item.h @@ -28,7 +28,7 @@ private: ItemStack m_stack; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // Exported functions diff --git a/src/script/lua_api/l_itemstackmeta.cpp b/src/script/lua_api/l_itemstackmeta.cpp index 304a7cdf3..efdd77b51 100644 --- a/src/script/lua_api/l_itemstackmeta.cpp +++ b/src/script/lua_api/l_itemstackmeta.cpp @@ -102,7 +102,7 @@ void ItemStackMetaRef::Register(lua_State *L) } const char ItemStackMetaRef::className[] = "ItemStackMetaRef"; -const luaL_reg ItemStackMetaRef::methods[] = { +const luaL_Reg ItemStackMetaRef::methods[] = { luamethod(MetaDataRef, get_string), luamethod(MetaDataRef, set_string), luamethod(MetaDataRef, get_int), diff --git a/src/script/lua_api/l_itemstackmeta.h b/src/script/lua_api/l_itemstackmeta.h index 6f9b2016c..4ef64a91e 100644 --- a/src/script/lua_api/l_itemstackmeta.h +++ b/src/script/lua_api/l_itemstackmeta.h @@ -31,7 +31,7 @@ private: ItemStack *istack; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; static ItemStackMetaRef *checkobject(lua_State *L, int narg); diff --git a/src/script/lua_api/l_minimap.cpp b/src/script/lua_api/l_minimap.cpp index 182894f4f..c68602909 100644 --- a/src/script/lua_api/l_minimap.cpp +++ b/src/script/lua_api/l_minimap.cpp @@ -201,7 +201,7 @@ void LuaMinimap::Register(lua_State *L) } const char LuaMinimap::className[] = "Minimap"; -const luaL_reg LuaMinimap::methods[] = { +const luaL_Reg LuaMinimap::methods[] = { luamethod(LuaMinimap, show), luamethod(LuaMinimap, hide), luamethod(LuaMinimap, get_pos), diff --git a/src/script/lua_api/l_minimap.h b/src/script/lua_api/l_minimap.h index 9a299b4fd..8be72b8e7 100644 --- a/src/script/lua_api/l_minimap.h +++ b/src/script/lua_api/l_minimap.h @@ -28,7 +28,7 @@ class LuaMinimap : public ModApiBase { private: static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // garbage collector static int gc_object(lua_State *L); diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp index 4368a8c50..55d11fc13 100644 --- a/src/script/lua_api/l_nodemeta.cpp +++ b/src/script/lua_api/l_nodemeta.cpp @@ -215,7 +215,7 @@ void NodeMetaRef::Register(lua_State *L) } -const luaL_reg NodeMetaRef::methodsServer[] = { +const luaL_Reg NodeMetaRef::methodsServer[] = { luamethod(MetaDataRef, get_string), luamethod(MetaDataRef, set_string), luamethod(MetaDataRef, get_int), @@ -237,7 +237,7 @@ void NodeMetaRef::RegisterClient(lua_State *L) } -const luaL_reg NodeMetaRef::methodsClient[] = { +const luaL_Reg NodeMetaRef::methodsClient[] = { luamethod(MetaDataRef, get_string), luamethod(MetaDataRef, get_int), luamethod(MetaDataRef, get_float), diff --git a/src/script/lua_api/l_nodemeta.h b/src/script/lua_api/l_nodemeta.h index 6d146416b..2ac028079 100644 --- a/src/script/lua_api/l_nodemeta.h +++ b/src/script/lua_api/l_nodemeta.h @@ -39,8 +39,8 @@ private: bool m_is_local; static const char className[]; - static const luaL_reg methodsServer[]; - static const luaL_reg methodsClient[]; + static const luaL_Reg methodsServer[]; + static const luaL_Reg methodsClient[]; static NodeMetaRef *checkobject(lua_State *L, int narg); diff --git a/src/script/lua_api/l_nodetimer.cpp b/src/script/lua_api/l_nodetimer.cpp index ed11cc58e..17b275c46 100644 --- a/src/script/lua_api/l_nodetimer.cpp +++ b/src/script/lua_api/l_nodetimer.cpp @@ -162,7 +162,7 @@ void NodeTimerRef::Register(lua_State *L) } const char NodeTimerRef::className[] = "NodeTimerRef"; -const luaL_reg NodeTimerRef::methods[] = { +const luaL_Reg NodeTimerRef::methods[] = { luamethod(NodeTimerRef, start), luamethod(NodeTimerRef, set), luamethod(NodeTimerRef, stop), diff --git a/src/script/lua_api/l_nodetimer.h b/src/script/lua_api/l_nodetimer.h index 239112037..ae362d8b3 100644 --- a/src/script/lua_api/l_nodetimer.h +++ b/src/script/lua_api/l_nodetimer.h @@ -32,7 +32,7 @@ private: ServerEnvironment *m_env; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; static int gc_object(lua_State *L); diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp index e0039371f..e3e76191f 100644 --- a/src/script/lua_api/l_noise.cpp +++ b/src/script/lua_api/l_noise.cpp @@ -135,7 +135,7 @@ void LuaPerlinNoise::Register(lua_State *L) const char LuaPerlinNoise::className[] = "PerlinNoise"; -const luaL_reg LuaPerlinNoise::methods[] = { +const luaL_Reg LuaPerlinNoise::methods[] = { luamethod(LuaPerlinNoise, get2d), luamethod(LuaPerlinNoise, get3d), {0,0} @@ -393,7 +393,7 @@ void LuaPerlinNoiseMap::Register(lua_State *L) const char LuaPerlinNoiseMap::className[] = "PerlinNoiseMap"; -const luaL_reg LuaPerlinNoiseMap::methods[] = { +const luaL_Reg LuaPerlinNoiseMap::methods[] = { luamethod(LuaPerlinNoiseMap, get2dMap), luamethod(LuaPerlinNoiseMap, get2dMap_flat), luamethod(LuaPerlinNoiseMap, calc2dMap), @@ -498,7 +498,7 @@ void LuaPseudoRandom::Register(lua_State *L) const char LuaPseudoRandom::className[] = "PseudoRandom"; -const luaL_reg LuaPseudoRandom::methods[] = { +const luaL_Reg LuaPseudoRandom::methods[] = { luamethod(LuaPseudoRandom, next), {0,0} }; @@ -597,7 +597,7 @@ void LuaPcgRandom::Register(lua_State *L) const char LuaPcgRandom::className[] = "PcgRandom"; -const luaL_reg LuaPcgRandom::methods[] = { +const luaL_Reg LuaPcgRandom::methods[] = { luamethod(LuaPcgRandom, next), luamethod(LuaPcgRandom, rand_normal_dist), {0,0} @@ -711,7 +711,7 @@ void LuaSecureRandom::Register(lua_State *L) } const char LuaSecureRandom::className[] = "SecureRandom"; -const luaL_reg LuaSecureRandom::methods[] = { +const luaL_Reg LuaSecureRandom::methods[] = { luamethod(LuaSecureRandom, next_bytes), {0,0} }; diff --git a/src/script/lua_api/l_noise.h b/src/script/lua_api/l_noise.h index 11ec348bf..f252b5ba2 100644 --- a/src/script/lua_api/l_noise.h +++ b/src/script/lua_api/l_noise.h @@ -32,7 +32,7 @@ class LuaPerlinNoise : public ModApiBase private: NoiseParams np; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // Exported functions @@ -64,7 +64,7 @@ class LuaPerlinNoiseMap : public ModApiBase Noise *noise; bool m_is3d; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // Exported functions @@ -103,7 +103,7 @@ private: PseudoRandom m_pseudo; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // Exported functions @@ -134,7 +134,7 @@ private: PcgRandom m_rnd; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // Exported functions @@ -169,7 +169,7 @@ class LuaSecureRandom : public ModApiBase private: static const size_t RAND_BUF_SIZE = 2048; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; u32 m_rand_idx; char m_rand_buf[RAND_BUF_SIZE]; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index d5681b809..f9d2754e7 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1823,7 +1823,7 @@ void ObjectRef::Register(lua_State *L) } const char ObjectRef::className[] = "ObjectRef"; -const luaL_reg ObjectRef::methods[] = { +const luaL_Reg ObjectRef::methods[] = { // ServerActiveObject luamethod(ObjectRef, remove), luamethod_aliased(ObjectRef, get_pos, getpos), diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 2c9aa559a..b6fc35bc2 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -37,7 +37,7 @@ private: ServerActiveObject *m_object; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; public: static ObjectRef *checkobject(lua_State *L, int narg); diff --git a/src/script/lua_api/l_settings.cpp b/src/script/lua_api/l_settings.cpp index d3fe03005..809f7d115 100644 --- a/src/script/lua_api/l_settings.cpp +++ b/src/script/lua_api/l_settings.cpp @@ -214,7 +214,7 @@ LuaSettings* LuaSettings::checkobject(lua_State* L, int narg) } const char LuaSettings::className[] = "Settings"; -const luaL_reg LuaSettings::methods[] = { +const luaL_Reg LuaSettings::methods[] = { luamethod(LuaSettings, get), luamethod(LuaSettings, get_bool), luamethod(LuaSettings, set), diff --git a/src/script/lua_api/l_settings.h b/src/script/lua_api/l_settings.h index d5edd32ce..b90f0a8f2 100644 --- a/src/script/lua_api/l_settings.h +++ b/src/script/lua_api/l_settings.h @@ -28,7 +28,7 @@ class LuaSettings : public ModApiBase { private: static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; // garbage collector static int gc_object(lua_State *L); diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp index 867ab9c8d..59906dda5 100644 --- a/src/script/lua_api/l_storage.cpp +++ b/src/script/lua_api/l_storage.cpp @@ -129,7 +129,7 @@ void StorageRef::clearMeta() } const char StorageRef::className[] = "StorageRef"; -const luaL_reg StorageRef::methods[] = { +const luaL_Reg StorageRef::methods[] = { luamethod(MetaDataRef, get_string), luamethod(MetaDataRef, set_string), luamethod(MetaDataRef, get_int), diff --git a/src/script/lua_api/l_storage.h b/src/script/lua_api/l_storage.h index e09b8b391..ec6f8d941 100644 --- a/src/script/lua_api/l_storage.h +++ b/src/script/lua_api/l_storage.h @@ -41,7 +41,7 @@ private: ModMetadata *m_object; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; virtual Metadata *getmeta(bool auto_create); virtual void clearMeta(); diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp index 5f129d2af..7316fb200 100644 --- a/src/script/lua_api/l_vmanip.cpp +++ b/src/script/lua_api/l_vmanip.cpp @@ -452,7 +452,7 @@ void LuaVoxelManip::Register(lua_State *L) } const char LuaVoxelManip::className[] = "VoxelManip"; -const luaL_reg LuaVoxelManip::methods[] = { +const luaL_Reg LuaVoxelManip::methods[] = { luamethod(LuaVoxelManip, read_from_map), luamethod(LuaVoxelManip, get_data), luamethod(LuaVoxelManip, set_data), diff --git a/src/script/lua_api/l_vmanip.h b/src/script/lua_api/l_vmanip.h index 65fc0d97a..b6a69f36a 100644 --- a/src/script/lua_api/l_vmanip.h +++ b/src/script/lua_api/l_vmanip.h @@ -38,7 +38,7 @@ private: bool is_mapgen_vm; static const char className[]; - static const luaL_reg methods[]; + static const luaL_Reg methods[]; static int gc_object(lua_State *L); -- cgit v1.2.3 From e80a83d1cb9d01273ddca1c075c25cd01c291ca7 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Fri, 14 Apr 2017 02:04:41 -0500 Subject: [CSM] Add function to set minimap shape (#5569) * [CSM] Add function to set minimap shape Also deprecates `toggle_shape`. * Oh fish, I messed that one up! * Fix Style * Sorry, I missed something I still had the `luamethod` call in there! * Add getters * Remove extra line * Remove useless variable Please review again @nerzhul . Thanks! * Satisfy nerzhul --- clientmods/preview/init.lua | 2 +- doc/client_lua_api.md | 3 ++- src/minimap.cpp | 22 ++++++++++++++++++++++ src/minimap.h | 7 +++++++ src/script/lua_api/l_minimap.cpp | 18 +++++++++++++++--- src/script/lua_api/l_minimap.h | 3 ++- 6 files changed, 49 insertions(+), 6 deletions(-) (limited to 'src/script/lua_api/l_minimap.h') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index df07f8c3f..4b31fa323 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -62,7 +62,7 @@ local function preview_minimap() minimap:set_mode(4) minimap:show() minimap:set_pos({x=5, y=50, z=5}) - minimap:toggle_shape() + minimap:set_shape(math.random(0, 1)) print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) .. " position => " .. dump(minimap:get_pos()) .. diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index 43a317a84..b2aeb3f25 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -779,7 +779,8 @@ An interface to manipulate minimap on client UI * `get_angle()`: returns the current minimap angle in degrees * `set_mode(mode)`: sets the minimap mode (0 to 6) * `get_mode()`: returns the current minimap mode -* `toggle_shape()`: toggles minimap shape to round or square. +* `set_shape(shape)`: Sets the minimap shape. (0 = square, 1 = round) +* `get_shape()`: Gets the minimap shape. (0 = square, 1 = round) ### LocalPlayer An interface to retrieve information about the player. The player is diff --git a/src/minimap.cpp b/src/minimap.cpp index a7f4822c9..500f49828 100644 --- a/src/minimap.cpp +++ b/src/minimap.cpp @@ -272,6 +272,28 @@ void Minimap::toggleMinimapShape() m_minimap_update_thread->deferUpdate(); } +void Minimap::setMinimapShape(MinimapShape shape) +{ + MutexAutoLock lock(m_mutex); + + if (shape == MINIMAP_SHAPE_SQUARE) + data->minimap_shape_round = false; + else if (shape == MINIMAP_SHAPE_ROUND) + data->minimap_shape_round = true; + + g_settings->setBool("minimap_shape_round", data->minimap_shape_round); + m_minimap_update_thread->deferUpdate(); +} + +MinimapShape Minimap::getMinimapShape() +{ + if (data->minimap_shape_round) { + return MINIMAP_SHAPE_ROUND; + } else { + return MINIMAP_SHAPE_SQUARE; + } +} + void Minimap::setMinimapMode(MinimapMode mode) { static const MinimapModeDef modedefs[MINIMAP_MODE_COUNT] = { diff --git a/src/minimap.h b/src/minimap.h index eb0ae1cf4..c50530335 100644 --- a/src/minimap.h +++ b/src/minimap.h @@ -45,6 +45,11 @@ enum MinimapMode { MINIMAP_MODE_COUNT, }; +enum MinimapShape { + MINIMAP_SHAPE_SQUARE, + MINIMAP_SHAPE_ROUND, +}; + struct MinimapModeDef { bool is_radar; u16 scan_height; @@ -128,6 +133,8 @@ public: void setMinimapMode(MinimapMode mode); MinimapMode getMinimapMode() const { return data->mode; } void toggleMinimapShape(); + void setMinimapShape(MinimapShape shape); + MinimapShape getMinimapShape(); video::ITexture *getMinimapTexture(); diff --git a/src/script/lua_api/l_minimap.cpp b/src/script/lua_api/l_minimap.cpp index c68602909..f32a07ce8 100644 --- a/src/script/lua_api/l_minimap.cpp +++ b/src/script/lua_api/l_minimap.cpp @@ -108,12 +108,23 @@ int LuaMinimap::l_set_mode(lua_State *L) return 1; } -int LuaMinimap::l_toggle_shape(lua_State *L) +int LuaMinimap::l_set_shape(lua_State *L) +{ + LuaMinimap *ref = checkobject(L, 1); + Minimap *m = getobject(ref); + if (!lua_isnumber(L, 2)) + return 0; + + m->setMinimapShape((MinimapShape)lua_tonumber(L, 2)); + return 0; +} + +int LuaMinimap::l_get_shape(lua_State *L) { LuaMinimap *ref = checkobject(L, 1); Minimap *m = getobject(ref); - m->toggleMinimapShape(); + lua_pushnumber(L, (int)m->getMinimapShape()); return 1; } @@ -210,6 +221,7 @@ const luaL_Reg LuaMinimap::methods[] = { luamethod(LuaMinimap, set_angle), luamethod(LuaMinimap, get_mode), luamethod(LuaMinimap, set_mode), - luamethod(LuaMinimap, toggle_shape), + luamethod(LuaMinimap, set_shape), + luamethod(LuaMinimap, get_shape), {0,0} }; diff --git a/src/script/lua_api/l_minimap.h b/src/script/lua_api/l_minimap.h index 8be72b8e7..ba702b0b1 100644 --- a/src/script/lua_api/l_minimap.h +++ b/src/script/lua_api/l_minimap.h @@ -45,7 +45,8 @@ private: static int l_show(lua_State *L); static int l_hide(lua_State *L); - static int l_toggle_shape(lua_State *L); + static int l_set_shape(lua_State *L); + static int l_get_shape(lua_State *L); Minimap *m_minimap; -- cgit v1.2.3