diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/minimap.cpp | 22 | ||||
-rw-r--r-- | src/minimap.h | 7 | ||||
-rw-r--r-- | src/script/lua_api/l_minimap.cpp | 18 | ||||
-rw-r--r-- | src/script/lua_api/l_minimap.h | 3 |
4 files changed, 46 insertions, 4 deletions
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; |