fix(jui): make creative screen correctly override menu clicked()

(also made rendertooltip names in AbstractContainerScreen match so my editor stops complaining)
This commit is contained in:
Sally Knight 2026-03-29 20:39:49 +03:00 committed by Tropical
parent cd6959b989
commit ca276943f2
4 changed files with 20 additions and 20 deletions

View file

@ -116,7 +116,7 @@ void AbstractContainerScreen::render(int xm, int ym, float a) {
// places) // places)
void AbstractContainerScreen::renderTooltipInternal( void AbstractContainerScreen::renderTooltipInternal(
const std::vector<std::wstring>& cleanedLines, const std::vector<std::wstring>& cleanedLines,
const std::vector<int>& lineColors, int mouseX, int mouseY) { const std::vector<int>& lineColors, int xm, int ym) {
if (cleanedLines.empty()) return; if (cleanedLines.empty()) return;
int tooltipWidth = 0; int tooltipWidth = 0;
@ -125,8 +125,8 @@ void AbstractContainerScreen::renderTooltipInternal(
if (lineWidth > tooltipWidth) tooltipWidth = lineWidth; if (lineWidth > tooltipWidth) tooltipWidth = lineWidth;
} }
int tooltipX = mouseX + 12; int tooltipX = xm + 12;
int tooltipY = mouseY - 12; int tooltipY = ym - 12;
int tooltipHeight = 8; int tooltipHeight = 8;
if (cleanedLines.size() > 1) { if (cleanedLines.size() > 1) {
@ -175,7 +175,7 @@ void AbstractContainerScreen::renderTooltipInternal(
} }
void AbstractContainerScreen::renderTooltip(std::shared_ptr<ItemInstance> item, void AbstractContainerScreen::renderTooltip(std::shared_ptr<ItemInstance> item,
int mouseX, int mouseY) { int xm, int ym) {
if (item == nullptr) return; if (item == nullptr) return;
std::vector<std::wstring> elementName; std::vector<std::wstring> elementName;
@ -240,12 +240,12 @@ void AbstractContainerScreen::renderTooltip(std::shared_ptr<ItemInstance> item,
lineColors[0] = app.GetHTMLColour(item->getRarity()->color); lineColors[0] = app.GetHTMLColour(item->getRarity()->color);
} }
renderTooltipInternal(cleanedLines, lineColors, mouseX, mouseY); renderTooltipInternal(cleanedLines, lineColors, xm, ym);
} }
} }
void AbstractContainerScreen::renderTooltip( void AbstractContainerScreen::renderTooltip(
const std::vector<std::wstring>& lines, int mouseX, int mouseY) { const std::vector<std::wstring>& lines, int xm, int ym) {
if (lines.empty()) return; if (lines.empty()) return;
std::vector<std::wstring> cleanedLines = lines; std::vector<std::wstring> cleanedLines = lines;
@ -260,12 +260,12 @@ void AbstractContainerScreen::renderTooltip(
} }
} }
renderTooltipInternal(cleanedLines, lineColors, mouseX, mouseY); renderTooltipInternal(cleanedLines, lineColors, xm, ym);
} }
void AbstractContainerScreen::renderTooltip(const std::wstring& line, void AbstractContainerScreen::renderTooltip(const std::wstring& line, int xm,
int mouseX, int mouseY) { int ym) {
renderTooltip(std::vector<std::wstring>{line}, mouseX, mouseY); renderTooltip(std::vector<std::wstring>{line}, xm, ym);
} }
void AbstractContainerScreen::renderLabels() {} void AbstractContainerScreen::renderLabels() {}

View file

@ -36,9 +36,9 @@ protected:
// used in other places // used in other places
virtual void renderTooltipInternal( virtual void renderTooltipInternal(
const std::vector<std::wstring>& cleanedLines, const std::vector<std::wstring>& cleanedLines,
const std::vector<int>& lineColors, int mouseX, int mouseY); const std::vector<int>& lineColors, int xm, int ym);
virtual void renderTooltip(std::shared_ptr<ItemInstance> item, int x, virtual void renderTooltip(std::shared_ptr<ItemInstance> item, int xm,
int y); int ym);
private: private:
virtual void renderSlot(Slot* slot); virtual void renderSlot(Slot* slot);
@ -55,7 +55,7 @@ public:
virtual void tick() override; virtual void tick() override;
// 4jcraft: 1.6.x era overloads // 4jcraft: 1.6.x era overloads
virtual void renderTooltip(const std::vector<std::wstring>& lines, int x, virtual void renderTooltip(const std::vector<std::wstring>& lines, int xm,
int y); int ym);
virtual void renderTooltip(const std::wstring& line, int x, int y); virtual void renderTooltip(const std::wstring& line, int xm, int ym);
}; };

View file

@ -90,8 +90,8 @@ bool CreativeInventoryScreen::ContainerCreative::stillValid(
std::shared_ptr<ItemInstance> std::shared_ptr<ItemInstance>
CreativeInventoryScreen::ContainerCreative::clicked( CreativeInventoryScreen::ContainerCreative::clicked(
int slotIndex, int buttonNum, int clickType, int slotIndex, int buttonNum, int clickType, std::shared_ptr<Player> player,
std::shared_ptr<Player> player) { bool looped) {
std::shared_ptr<Inventory> inventory = player->inventory; std::shared_ptr<Inventory> inventory = player->inventory;
std::shared_ptr<ItemInstance> carried = inventory->getCarried(); std::shared_ptr<ItemInstance> carried = inventory->getCarried();

View file

@ -51,10 +51,10 @@ public:
std::vector<std::shared_ptr<ItemInstance>> itemList; std::vector<std::shared_ptr<ItemInstance>> itemList;
ContainerCreative(std::shared_ptr<Player> player); ContainerCreative(std::shared_ptr<Player> player);
virtual bool stillValid(std::shared_ptr<Player> player); virtual bool stillValid(std::shared_ptr<Player> player) override;
virtual std::shared_ptr<ItemInstance> clicked( virtual std::shared_ptr<ItemInstance> clicked(
int slotIndex, int buttonNum, int clickType, int slotIndex, int buttonNum, int clickType,
std::shared_ptr<Player> player); std::shared_ptr<Player> player, bool looped = false) override;
void scrollTo(float pos); void scrollTo(float pos);
bool canScroll(); bool canScroll();
}; };