aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua_api.txt7
-rw-r--r--src/game.cpp3
-rw-r--r--src/hud.h13
-rw-r--r--src/network/clientpackethandler.cpp9
-rw-r--r--src/player.cpp3
-rw-r--r--src/script/lua_api/l_object.cpp15
6 files changed, 33 insertions, 17 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 3c87c2e2f..37c754c9d 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -3310,13 +3310,16 @@ This is basically a reference to a C++ `ServerActiveObject`
* element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
* `hud_get(id)`: gets the HUD element definition structure of the specified ID
* `hud_set_flags(flags)`: sets specified HUD flags to `true`/`false`
- * `flags`: (is visible) `hotbar`, `healthbar`, `crosshair`, `wielditem`, `minimap`
+ * `flags`: (is visible) `hotbar`, `healthbar`, `crosshair`, `wielditem`, `breathbar`,
+ `minimap`, `minimap_radar`
* pass a table containing a `true`/`false` value of each flag to be set or unset
* if a flag equals `nil`, the flag is not modified
* note that setting `minimap` modifies the client's permission to view the minimap -
* the client may locally elect to not view the minimap
+ * minimap `radar` is only usable when `minimap` is true
* `hud_get_flags()`: returns a table containing status of hud flags
- * returns `{ hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true, minimap=true }`
+ * returns `{hotbar=true, healthbar=true, crosshair=true, wielditem=true,
+ breathbar=true, minimap=true, minimap_radar=true}`
* `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
* `count`: number of items, must be between `1` and `23`
* `hud_get_hotbar_itemcount`: returns number of visible items
diff --git a/src/game.cpp b/src/game.cpp
index fad902d03..0f8227749 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2818,6 +2818,9 @@ void Game::toggleMinimap(bool shift_pressed)
if (hud_flags & HUD_FLAG_MINIMAP_VISIBLE) {
mode = mapper->getMinimapMode();
mode = (MinimapMode)((int)mode + 1);
+ // If radar is disabled and in, or switching to, radar mode
+ if (!(hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE) && mode > 3)
+ mode = MINIMAP_MODE_OFF;
}
flags.show_minimap = true;
diff --git a/src/hud.h b/src/hud.h
index 363909b0b..3084478b1 100644
--- a/src/hud.h
+++ b/src/hud.h
@@ -34,12 +34,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Note that these visibility flags do not determine if the hud items are
// actually drawn, but rather, whether to draw the item should the rest
// of the game state permit it.
-#define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
-#define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
-#define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)
-#define HUD_FLAG_WIELDITEM_VISIBLE (1 << 3)
-#define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4)
-#define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
+#define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
+#define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
+#define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)
+#define HUD_FLAG_WIELDITEM_VISIBLE (1 << 3)
+#define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4)
+#define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
+#define HUD_FLAG_MINIMAP_RADAR_VISIBLE (1 << 6)
#define HUD_PARAM_HOTBAR_ITEMCOUNT 1
#define HUD_PARAM_HOTBAR_IMAGE 2
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 1d5a28277..86bb88f61 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -1183,18 +1183,23 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
assert(player != NULL);
bool was_minimap_visible = player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE;
+ bool was_minimap_radar_visible = player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE;
player->hud_flags &= ~mask;
player->hud_flags |= flags;
m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
+ bool m_minimap_radar_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE);
// Hide minimap if it has been disabled by the server
- if (m_minimap && m_minimap_disabled_by_server && was_minimap_visible) {
+ if (m_minimap && m_minimap_disabled_by_server && was_minimap_visible)
// defers a minimap update, therefore only call it if really
// needed, by checking that minimap was visible before
m_minimap->setMinimapMode(MINIMAP_MODE_OFF);
- }
+
+ // Switch to surface mode if radar disabled by server
+ if (m_minimap && m_minimap_radar_disabled_by_server && was_minimap_radar_visible)
+ m_minimap->setMinimapMode(MINIMAP_MODE_SURFACEx1);
}
void Client::handleCommand_HudSetParam(NetworkPacket* pkt)
diff --git a/src/player.cpp b/src/player.cpp
index 53e173498..1ff953253 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -70,7 +70,8 @@ Player::Player(const char *name, IItemDefManager *idef):
hud_flags =
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
- HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE;
+ HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
+ HUD_FLAG_MINIMAP_RADAR_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
}
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index a65a5e88f..46ac61f27 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -60,12 +60,13 @@ struct EnumString es_HudElementStat[] =
struct EnumString es_HudBuiltinElement[] =
{
- {HUD_FLAG_HOTBAR_VISIBLE, "hotbar"},
- {HUD_FLAG_HEALTHBAR_VISIBLE, "healthbar"},
- {HUD_FLAG_CROSSHAIR_VISIBLE, "crosshair"},
- {HUD_FLAG_WIELDITEM_VISIBLE, "wielditem"},
- {HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"},
- {HUD_FLAG_MINIMAP_VISIBLE, "minimap"},
+ {HUD_FLAG_HOTBAR_VISIBLE, "hotbar"},
+ {HUD_FLAG_HEALTHBAR_VISIBLE, "healthbar"},
+ {HUD_FLAG_CROSSHAIR_VISIBLE, "crosshair"},
+ {HUD_FLAG_WIELDITEM_VISIBLE, "wielditem"},
+ {HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"},
+ {HUD_FLAG_MINIMAP_VISIBLE, "minimap"},
+ {HUD_FLAG_MINIMAP_RADAR_VISIBLE, "minimap_radar"},
{0, NULL},
};
@@ -1569,6 +1570,8 @@ int ObjectRef::l_hud_get_flags(lua_State *L)
lua_setfield(L, -2, "breathbar");
lua_pushboolean(L, player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
lua_setfield(L, -2, "minimap");
+ lua_pushboolean(L, player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE);
+ lua_setfield(L, -2, "minimap_radar");
return 1;
}