mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
fix: slotId parsing in enchantment menu
This commit is contained in:
parent
ca533de1c3
commit
74252cc8d2
|
|
@ -1235,7 +1235,7 @@ std::size_t UIScene::GetCallbackUniqueId() {
|
||||||
bool UIScene::isReadyToDelete() { return true; }
|
bool UIScene::isReadyToDelete() { return true; }
|
||||||
|
|
||||||
int UIScene::parseSlotId(const char16_t* s) {
|
int UIScene::parseSlotId(const char16_t* s) {
|
||||||
if (s == nullptr ||
|
if (s == nullptr || std::char_traits<char16_t>::length(s) <= 5 ||
|
||||||
std::char_traits<char16_t>::compare(s, u"slot_", 5) != 0) {
|
std::char_traits<char16_t>::compare(s, u"slot_", 5) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#include "../../Minecraft.Client/Minecraft.h"
|
#include "../../Minecraft.Client/Minecraft.h"
|
||||||
#include "UIScene_EnchantingMenu.h"
|
#include "UIScene_EnchantingMenu.h"
|
||||||
|
|
||||||
|
#include <print>
|
||||||
|
|
||||||
UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void* _initData,
|
UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void* _initData,
|
||||||
UILayer* parentLayer)
|
UILayer* parentLayer)
|
||||||
: UIScene_AbstractContainerMenu(iPad, parentLayer) {
|
: UIScene_AbstractContainerMenu(iPad, parentLayer) {
|
||||||
|
|
@ -253,13 +255,30 @@ void UIScene_EnchantingMenu::customDraw(IggyCustomDrawCallbackRegion* region) {
|
||||||
// Finish GDraw and anything else that needs to be finalised
|
// Finish GDraw and anything else that needs to be finalised
|
||||||
ui.endCustomDraw(region);
|
ui.endCustomDraw(region);
|
||||||
} else {
|
} else {
|
||||||
int slotId = parseSlotId(region->name);
|
int slotId = -1;
|
||||||
|
if (region->name != nullptr &&
|
||||||
|
std::char_traits<char16_t>::length(region->name) > 11 &&
|
||||||
|
std::char_traits<char16_t>::compare(region->name, u"slot_Button", 11) ==
|
||||||
|
0) {
|
||||||
|
int i = 11;
|
||||||
|
slotId = 0;
|
||||||
|
|
||||||
|
while (region->name[i] >= u'0' && region->name[i] <= u'9') {
|
||||||
|
slotId = slotId * 10 + (region->name[i] - u'0');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (slotId >= 0) {
|
if (slotId >= 0) {
|
||||||
// Setup GDraw, normal game render states and matrices
|
// Setup GDraw, normal game render states and matrices
|
||||||
CustomDrawData* customDrawRegion = ui.setupCustomDraw(this, region);
|
CustomDrawData* customDrawRegion = ui.setupCustomDraw(this, region);
|
||||||
delete customDrawRegion;
|
delete customDrawRegion;
|
||||||
|
|
||||||
m_enchantButton[slotId - 1].render(region);
|
const char* namews = wstringtofilename(u16string_to_wstring(region->name));
|
||||||
|
|
||||||
|
std::println("render slot {} {}", namews, slotId);
|
||||||
|
|
||||||
|
m_enchantButton[slotId].render(region);
|
||||||
|
|
||||||
// Finish GDraw and anything else that needs to be finalised
|
// Finish GDraw and anything else that needs to be finalised
|
||||||
ui.endCustomDraw(region);
|
ui.endCustomDraw(region);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue