Only show HUD co-ordinates when minimap is showing or debug mode is on (#93)
This commit is contained in:
parent
bfd46c88c8
commit
caa7ae51bb
@ -2297,7 +2297,7 @@ void Game::toggleMinimap(bool shift_pressed)
|
|||||||
u32 hud_flags = client->getEnv().getLocalPlayer()->hud_flags;
|
u32 hud_flags = client->getEnv().getLocalPlayer()->hud_flags;
|
||||||
|
|
||||||
if (!(hud_flags & HUD_FLAG_MINIMAP_VISIBLE)) {
|
if (!(hud_flags & HUD_FLAG_MINIMAP_VISIBLE)) {
|
||||||
m_game_ui->m_flags.show_minimap = false;
|
m_game_ui->showMinimap(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If radar is disabled, try to find a non radar mode or fall back to 0
|
// If radar is disabled, try to find a non radar mode or fall back to 0
|
||||||
@ -2306,8 +2306,7 @@ void Game::toggleMinimap(bool shift_pressed)
|
|||||||
mapper->getModeDef().type == MINIMAP_TYPE_RADAR)
|
mapper->getModeDef().type == MINIMAP_TYPE_RADAR)
|
||||||
mapper->nextMode();
|
mapper->nextMode();
|
||||||
|
|
||||||
m_game_ui->m_flags.show_minimap = mapper->getModeDef().type !=
|
m_game_ui->showMinimap(mapper->getModeDef().type != MINIMAP_TYPE_OFF);
|
||||||
MINIMAP_TYPE_OFF;
|
|
||||||
}
|
}
|
||||||
// <--
|
// <--
|
||||||
// End of 'not so satifying code'
|
// End of 'not so satifying code'
|
||||||
@ -2357,6 +2356,9 @@ void Game::toggleDebug()
|
|||||||
m_game_ui->showTranslatedStatusText("Debug info and profiler graph hidden");
|
m_game_ui->showTranslatedStatusText("Debug info and profiler graph hidden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the chat text as it may need changing because of rounded screens
|
||||||
|
m_game_ui->m_chat_text_needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,20 +124,20 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
|||||||
<< (draw_control->range_all ? "All" : itos(draw_control->wanted_range))
|
<< (draw_control->range_all ? "All" : itos(draw_control->wanted_range))
|
||||||
<< std::setprecision(2)
|
<< std::setprecision(2)
|
||||||
<< " | RTT: " << (client->getRTT() * 1000.0f) << "ms";
|
<< " | RTT: " << (client->getRTT() * 1000.0f) << "ms";
|
||||||
} else {
|
} else if (m_flags.show_minimap) {
|
||||||
os << std::setprecision(1) << std::fixed
|
os << std::setprecision(1) << std::fixed
|
||||||
<< "X: " << (player_position.X / BS)
|
<< "X: " << (player_position.X / BS)
|
||||||
<< ", Y: " << (player_position.Y / BS)
|
<< ", Y: " << (player_position.Y / BS)
|
||||||
<< ", Z: " << (player_position.Z / BS);
|
<< ", Z: " << (player_position.Z / BS);
|
||||||
}
|
}
|
||||||
m_guitext->setText(utf8_to_wide(os.str()).c_str());
|
m_guitext->setText(utf8_to_wide(os.str()).c_str());
|
||||||
|
|
||||||
m_guitext->setRelativePosition(core::rect<s32>(
|
m_guitext->setRelativePosition(core::rect<s32>(
|
||||||
5 + client->getRoundScreen(), 5,
|
5 + client->getRoundScreen(), 5,
|
||||||
screensize.X, 5 + g_fontengine->getTextHeight()));
|
screensize.X, 5 + g_fontengine->getTextHeight()));
|
||||||
|
|
||||||
// Finally set the guitext visible depending on the flag
|
// Finally set the guitext visible depending on the flag
|
||||||
m_guitext->setVisible(m_flags.show_hud);
|
m_guitext->setVisible(m_flags.show_hud && (m_flags.show_debug || m_flags.show_minimap));
|
||||||
|
|
||||||
if (m_flags.show_debug) {
|
if (m_flags.show_debug) {
|
||||||
std::ostringstream os(std::ios_base::binary);
|
std::ostringstream os(std::ios_base::binary);
|
||||||
@ -209,6 +209,30 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
|||||||
m_guitext_status->enableOverrideColor(true);
|
m_guitext_status->enableOverrideColor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update chat text
|
||||||
|
if (m_chat_text_needs_update) {
|
||||||
|
m_chat_text_needs_update = false;
|
||||||
|
if ((!m_flags.show_hud || (!m_flags.show_debug && !m_flags.show_minimap)) &&
|
||||||
|
client->getRoundScreen() > 0) {
|
||||||
|
// Cache the space count
|
||||||
|
if (!m_space_count) {
|
||||||
|
// Use spaces to shift the text
|
||||||
|
const u32 spwidth = g_fontengine->getFont()->getDimension(L" ").Width;
|
||||||
|
// Divide and round up
|
||||||
|
m_space_count = (client->getRoundScreen() + spwidth - 1) / spwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnrichedString padded_chat_text;
|
||||||
|
for (int i = 0; i < m_space_count; i++)
|
||||||
|
padded_chat_text.addCharNoColor(L' ');
|
||||||
|
|
||||||
|
padded_chat_text += m_chat_text;
|
||||||
|
setStaticText(m_guitext_chat, padded_chat_text);
|
||||||
|
} else {
|
||||||
|
setStaticText(m_guitext_chat, m_chat_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hide chat when console is visible
|
// Hide chat when console is visible
|
||||||
m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible());
|
m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible());
|
||||||
}
|
}
|
||||||
@ -221,6 +245,7 @@ void GameUI::initFlags()
|
|||||||
|
|
||||||
void GameUI::showMinimap(bool show)
|
void GameUI::showMinimap(bool show)
|
||||||
{
|
{
|
||||||
|
m_chat_text_needs_update = m_chat_text_needs_update || show != m_flags.show_minimap;
|
||||||
m_flags.show_minimap = show;
|
m_flags.show_minimap = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,18 +258,22 @@ void GameUI::showTranslatedStatusText(const char *str)
|
|||||||
|
|
||||||
void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
|
void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
|
||||||
{
|
{
|
||||||
setStaticText(m_guitext_chat, chat_text);
|
m_chat_text = chat_text;
|
||||||
|
m_chat_text_needs_update = true;
|
||||||
m_recent_chat_count = recent_chat_count;
|
m_recent_chat_count = recent_chat_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameUI::updateChatSize()
|
void GameUI::updateChatSize()
|
||||||
{
|
{
|
||||||
// Update gui element size and position
|
// Update gui element size and position
|
||||||
s32 chat_y = 5 + g_fontengine->getLineHeight();;
|
s32 chat_y = 5;
|
||||||
|
|
||||||
if (m_flags.show_debug)
|
if (m_flags.show_hud) {
|
||||||
chat_y += g_fontengine->getLineHeight();
|
if (m_flags.show_debug)
|
||||||
|
chat_y += g_fontengine->getLineHeight() * 2;
|
||||||
|
else if (m_flags.show_minimap)
|
||||||
|
chat_y += g_fontengine->getLineHeight();
|
||||||
|
}
|
||||||
|
|
||||||
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
||||||
|
|
||||||
@ -302,6 +331,7 @@ void GameUI::toggleHud()
|
|||||||
showTranslatedStatusText("HUD shown");
|
showTranslatedStatusText("HUD shown");
|
||||||
else
|
else
|
||||||
showTranslatedStatusText("HUD hidden");
|
showTranslatedStatusText("HUD hidden");
|
||||||
|
m_chat_text_needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameUI::toggleProfiler()
|
void GameUI::toggleProfiler()
|
||||||
|
@ -121,6 +121,9 @@ private:
|
|||||||
video::SColor m_statustext_initial_color;
|
video::SColor m_statustext_initial_color;
|
||||||
|
|
||||||
gui::IGUIStaticText *m_guitext_chat = nullptr; // Chat text
|
gui::IGUIStaticText *m_guitext_chat = nullptr; // Chat text
|
||||||
|
EnrichedString m_chat_text;
|
||||||
|
bool m_chat_text_needs_update = false;
|
||||||
|
int m_space_count = 0;
|
||||||
u32 m_recent_chat_count = 0;
|
u32 m_recent_chat_count = 0;
|
||||||
core::rect<s32> m_current_chat_size{0, 0, 0, 0};
|
core::rect<s32> m_current_chat_size{0, 0, 0, 0};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user