mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-03-25 14:21:55 +02:00
add advanced tooltips, F3+H combo, and handle settings (#1389)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
|
||||
#include "..\..\MultiplayerLocalPlayer.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\Options.h"
|
||||
|
||||
#ifdef __ORBIS__
|
||||
#include <pad.h>
|
||||
@@ -1677,7 +1678,13 @@ vector<HtmlString> *IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slo
|
||||
{
|
||||
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
|
||||
if (lines->size() > 0)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\Options.h"
|
||||
#include "..\..\MultiPlayerLocalPlayer.h"
|
||||
#include "..\..\ClientConnection.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> *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
|
||||
if (lines->size() > 0)
|
||||
|
||||
@@ -170,6 +170,7 @@ void Options::init()
|
||||
particles = 0;
|
||||
fov = 0;
|
||||
gamma = 0;
|
||||
advancedTooltips = false;
|
||||
}
|
||||
|
||||
Options::Options(Minecraft *minecraft, File workingDirectory)
|
||||
@@ -451,6 +452,7 @@ void Options::load()
|
||||
if (cmds[0] == L"fancyGraphics") fancyGraphics = 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"advancedTooltips") advancedTooltips = cmds[1]==L"false";
|
||||
if (cmds[0] == L"skin") skin = cmds[1];
|
||||
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
|
||||
|
||||
@@ -508,6 +510,7 @@ void Options::save()
|
||||
dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(ambientOcclusion ? L"ao:true" : L"ao:false");
|
||||
dos.writeChars(renderClouds ? L"clouds:true" : L"clouds:false");
|
||||
dos.writeChars(advancedTooltips ? L"advancedTooltips:true" : L"advancedTooltips:false");
|
||||
dos.writeChars(L"skin:" + skin);
|
||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
int particles; // 0 is all, 1 is decreased and 2 is minimal
|
||||
float fov;
|
||||
float gamma;
|
||||
bool advancedTooltips;
|
||||
|
||||
void init(); // 4J added
|
||||
Options(Minecraft *minecraft, File workingDirectory);
|
||||
|
||||
@@ -234,6 +234,13 @@ bool KeyboardMouseInput::IsKeyReleased(int vkCode) const
|
||||
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
|
||||
{
|
||||
if (button >= 0 && button < MAX_MOUSE_BUTTONS)
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
bool IsKeyPressed(int vkCode) const;
|
||||
bool IsKeyReleased(int vkCode) const;
|
||||
|
||||
int GetPressedKey() const;
|
||||
|
||||
bool IsMouseButtonDown(int button) const;
|
||||
bool IsMouseButtonPressed(int button) const;
|
||||
bool IsMouseButtonReleased(int button) const;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
//#include "NetworkManager.h"
|
||||
#include "..\..\Minecraft.Client\Tesselator.h"
|
||||
#include "..\..\Minecraft.Client\Options.h"
|
||||
#include "..\Gui.h"
|
||||
#include "Sentient\SentientManager.h"
|
||||
#include "..\..\Minecraft.World\IntCache.h"
|
||||
#include "..\Textures.h"
|
||||
@@ -107,6 +108,7 @@ int g_iScreenHeight = 1080;
|
||||
// always matches the current window, even after a resize.
|
||||
int g_rScreenWidth = 1920;
|
||||
int g_rScreenHeight = 1080;
|
||||
static bool f3ComboUsed = false;
|
||||
|
||||
float g_iAspectRatio = static_cast<float>(g_iScreenWidth) / g_iScreenHeight;
|
||||
static bool g_bResizeReady = false;
|
||||
@@ -1774,16 +1776,36 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
// advanced tooltips
|
||||
case 'H':
|
||||
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
|
||||
// F6 Open debug console
|
||||
|
||||
@@ -562,34 +562,27 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
|
||||
title.italics = true;
|
||||
}
|
||||
|
||||
// 4J: This is for showing aux values, not useful in console version
|
||||
/*
|
||||
if (advanced)
|
||||
{
|
||||
wstring suffix = L"";
|
||||
|
||||
if (title.length() > 0)
|
||||
if (title.text.length() > 0)
|
||||
{
|
||||
title += L" (";
|
||||
title.text += L" (";
|
||||
suffix = L")";
|
||||
}
|
||||
|
||||
wchar_t buf[64];
|
||||
if (isStackedByData())
|
||||
{
|
||||
title += String.format("#%04d/%d%s", id, auxValue, suffix);
|
||||
}
|
||||
swprintf_s(buf, 64, L"#%04d/%d%s", id, auxValue, suffix.c_str());
|
||||
else
|
||||
{
|
||||
title += String.format("#%04d%s", id, suffix);
|
||||
}
|
||||
swprintf_s(buf, 64, L"#%04d%s", id, suffix.c_str());
|
||||
title.text += buf;
|
||||
}
|
||||
else if (!hasCustomHoverName() && id == Item::map_Id)
|
||||
*/
|
||||
|
||||
/*if (!hasCustomHoverName() && id == Item::map_Id)
|
||||
{
|
||||
title.text += L" #" + std::to_wstring(auxValue);
|
||||
}*/
|
||||
}
|
||||
|
||||
lines->push_back(title);
|
||||
|
||||
@@ -673,7 +666,7 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user