add advanced tooltips, F3+H combo, and handle settings (#1389)

This commit is contained in:
Sylvessa
2026-03-23 17:54:46 -05:00
committed by GitHub
parent 77433dbd86
commit 127465b0eb
8 changed files with 68 additions and 26 deletions

View File

@@ -9,6 +9,7 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" #include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\..\MultiplayerLocalPlayer.h" #include "..\..\MultiplayerLocalPlayer.h"
#include "..\..\Minecraft.h" #include "..\..\Minecraft.h"
#include "..\..\Options.h"
#ifdef __ORBIS__ #ifdef __ORBIS__
#include <pad.h> #include <pad.h>
@@ -1677,7 +1678,13 @@ vector<HtmlString> *IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slo
{ {
if(slot == nullptr) return nullptr; if(slot == nullptr) return nullptr;
vector<HtmlString> *lines = slot->getItem()->getHoverText(nullptr, false); bool advanced = false;
if (const Minecraft* pMinecraft = Minecraft::GetInstance())
{
if (pMinecraft->options)
advanced = pMinecraft->options->advancedTooltips;
}
vector<HtmlString> *lines = slot->getItem()->getHoverText(nullptr, advanced);
// Add rarity to first line // Add rarity to first line
if (lines->size() > 0) if (lines->size() > 0)

View File

@@ -4,6 +4,7 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h" #include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h" #include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
#include "..\..\Minecraft.h" #include "..\..\Minecraft.h"
#include "..\..\Options.h"
#include "..\..\MultiPlayerLocalPlayer.h" #include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\ClientConnection.h" #include "..\..\ClientConnection.h"
#include "IUIScene_TradingMenu.h" #include "IUIScene_TradingMenu.h"
@@ -368,7 +369,13 @@ void IUIScene_TradingMenu::setTradeItem(int index, shared_ptr<ItemInstance> item
vector<HtmlString> *IUIScene_TradingMenu::GetItemDescription(shared_ptr<ItemInstance> item) vector<HtmlString> *IUIScene_TradingMenu::GetItemDescription(shared_ptr<ItemInstance> item)
{ {
vector<HtmlString> *lines = item->getHoverText(nullptr, false); bool advanced = false;
if (const Minecraft* pMinecraft = Minecraft::GetInstance())
{
if (pMinecraft->options)
advanced = pMinecraft->options->advancedTooltips;
}
vector<HtmlString> *lines = item->getHoverText(nullptr, advanced);
// Add rarity to first line // Add rarity to first line
if (lines->size() > 0) if (lines->size() > 0)

View File

@@ -170,6 +170,7 @@ void Options::init()
particles = 0; particles = 0;
fov = 0; fov = 0;
gamma = 0; gamma = 0;
advancedTooltips = false;
} }
Options::Options(Minecraft *minecraft, File workingDirectory) Options::Options(Minecraft *minecraft, File workingDirectory)
@@ -451,8 +452,9 @@ void Options::load()
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1]==L"true"; if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1]==L"true";
if (cmds[0] == L"ao") ambientOcclusion = cmds[1]==L"true"; if (cmds[0] == L"ao") ambientOcclusion = cmds[1]==L"true";
if (cmds[0] == L"clouds") renderClouds = cmds[1]==L"true"; if (cmds[0] == L"clouds") renderClouds = cmds[1]==L"true";
if (cmds[0] == L"skin") skin = cmds[1]; if (cmds[0] == L"advancedTooltips") advancedTooltips = cmds[1]==L"false";
if (cmds[0] == L"lastServer") lastMpIp = cmds[1]; if (cmds[0] == L"skin") skin = cmds[1];
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
for (int i = 0; i < keyMappings_length; i++) for (int i = 0; i < keyMappings_length; i++)
{ {
@@ -508,7 +510,8 @@ void Options::save()
dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false")); dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false"));
dos.writeChars(ambientOcclusion ? L"ao:true" : L"ao:false"); dos.writeChars(ambientOcclusion ? L"ao:true" : L"ao:false");
dos.writeChars(renderClouds ? L"clouds:true" : L"clouds:false"); dos.writeChars(renderClouds ? L"clouds:true" : L"clouds:false");
dos.writeChars(L"skin:" + skin); dos.writeChars(advancedTooltips ? L"advancedTooltips:true" : L"advancedTooltips:false");
dos.writeChars(L"skin:" + skin);
dos.writeChars(L"lastServer:" + lastMpIp); dos.writeChars(L"lastServer:" + lastMpIp);
for (int i = 0; i < keyMappings_length; i++) for (int i = 0; i < keyMappings_length; i++)

View File

@@ -110,6 +110,7 @@ public:
int particles; // 0 is all, 1 is decreased and 2 is minimal int particles; // 0 is all, 1 is decreased and 2 is minimal
float fov; float fov;
float gamma; float gamma;
bool advancedTooltips;
void init(); // 4J added void init(); // 4J added
Options(Minecraft *minecraft, File workingDirectory); Options(Minecraft *minecraft, File workingDirectory);

View File

@@ -234,6 +234,13 @@ bool KeyboardMouseInput::IsKeyReleased(int vkCode) const
return false; return false;
} }
int KeyboardMouseInput::GetPressedKey() const
{
for (int i = 0; i < MAX_KEYS; ++i)
if (m_keyPressed[i]) return i;
return 0;
}
bool KeyboardMouseInput::IsMouseButtonDown(int button) const bool KeyboardMouseInput::IsMouseButtonDown(int button) const
{ {
if (button >= 0 && button < MAX_MOUSE_BUTTONS) if (button >= 0 && button < MAX_MOUSE_BUTTONS)

View File

@@ -56,6 +56,8 @@ public:
bool IsKeyPressed(int vkCode) const; bool IsKeyPressed(int vkCode) const;
bool IsKeyReleased(int vkCode) const; bool IsKeyReleased(int vkCode) const;
int GetPressedKey() const;
bool IsMouseButtonDown(int button) const; bool IsMouseButtonDown(int button) const;
bool IsMouseButtonPressed(int button) const; bool IsMouseButtonPressed(int button) const;
bool IsMouseButtonReleased(int button) const; bool IsMouseButtonReleased(int button) const;

View File

@@ -36,6 +36,7 @@
//#include "NetworkManager.h" //#include "NetworkManager.h"
#include "..\..\Minecraft.Client\Tesselator.h" #include "..\..\Minecraft.Client\Tesselator.h"
#include "..\..\Minecraft.Client\Options.h" #include "..\..\Minecraft.Client\Options.h"
#include "..\Gui.h"
#include "Sentient\SentientManager.h" #include "Sentient\SentientManager.h"
#include "..\..\Minecraft.World\IntCache.h" #include "..\..\Minecraft.World\IntCache.h"
#include "..\Textures.h" #include "..\Textures.h"
@@ -107,6 +108,7 @@ int g_iScreenHeight = 1080;
// always matches the current window, even after a resize. // always matches the current window, even after a resize.
int g_rScreenWidth = 1920; int g_rScreenWidth = 1920;
int g_rScreenHeight = 1080; int g_rScreenHeight = 1080;
static bool f3ComboUsed = false;
float g_iAspectRatio = static_cast<float>(g_iScreenWidth) / g_iScreenHeight; float g_iAspectRatio = static_cast<float>(g_iScreenWidth) / g_iScreenHeight;
static bool g_bResizeReady = false; static bool g_bResizeReady = false;
@@ -1774,17 +1776,37 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
} }
// F3 toggles onscreen debug info // F3 toggles onscreen debug info
if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DEBUG_INFO)) if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DEBUG_INFO)) f3ComboUsed = false;
// f3 combo
if (g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_DEBUG_INFO))
{ {
if (const Minecraft* pMinecraft = Minecraft::GetInstance()) switch (g_KBMInput.GetPressedKey())
{ {
if (pMinecraft->options) // advanced tooltips
{ case 'H':
pMinecraft->options->renderDebug = !pMinecraft->options->renderDebug; if (pMinecraft->options && app.GetGameStarted())
} {
pMinecraft->options->advancedTooltips = !pMinecraft->options->advancedTooltips;
pMinecraft->options->save();
const wstring msg = wstring(L"Advanced tooltips: ") + (pMinecraft->options->advancedTooltips ? L"shown" : L"hidden");
const int primaryPad = ProfileManager.GetPrimaryPad();
if (pMinecraft->gui) pMinecraft->gui->addMessage(msg, primaryPad);
f3ComboUsed = true;
}
break;
} }
} }
// no combo
if (g_KBMInput.IsKeyReleased(KeyboardMouseInput::KEY_DEBUG_INFO) && !f3ComboUsed)
if (pMinecraft->options)
pMinecraft->options->renderDebug = !pMinecraft->options->renderDebug;
#ifdef _DEBUG_MENUS_ENABLED #ifdef _DEBUG_MENUS_ENABLED
// F6 Open debug console // F6 Open debug console
if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DEBUG_CONSOLE)) if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DEBUG_CONSOLE))

View File

@@ -562,34 +562,27 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
title.italics = true; title.italics = true;
} }
// 4J: This is for showing aux values, not useful in console version
/*
if (advanced) if (advanced)
{ {
wstring suffix = L""; wstring suffix = L"";
if (title.length() > 0) if (title.text.length() > 0)
{ {
title += L" ("; title.text += L" (";
suffix = L")"; suffix = L")";
} }
wchar_t buf[64];
if (isStackedByData()) if (isStackedByData())
{ swprintf_s(buf, 64, L"#%04d/%d%s", id, auxValue, suffix.c_str());
title += String.format("#%04d/%d%s", id, auxValue, suffix);
}
else else
{ swprintf_s(buf, 64, L"#%04d%s", id, suffix.c_str());
title += String.format("#%04d%s", id, suffix); title.text += buf;
}
} }
else if (!hasCustomHoverName() && id == Item::map_Id) else if (!hasCustomHoverName() && id == Item::map_Id)
*/
/*if (!hasCustomHoverName() && id == Item::map_Id)
{ {
title.text += L" #" + std::to_wstring(auxValue); title.text += L" #" + std::to_wstring(auxValue);
}*/ }
lines->push_back(title); lines->push_back(title);
@@ -673,7 +666,7 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
{ {
if (isDamaged()) if (isDamaged())
{ {
wstring damageStr = L"Durability: LOCALISE " + std::to_wstring((getMaxDamage()) - getDamageValue()) + L" / " + std::to_wstring(getMaxDamage()); wstring damageStr = L"Durability: " + std::to_wstring((getMaxDamage()) - getDamageValue()) + L" / " + std::to_wstring(getMaxDamage());
lines->push_back(HtmlString(damageStr)); lines->push_back(HtmlString(damageStr));
} }
} }