diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 0d3f7dac..a0c0ebdd 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "IUIScene_CreativeMenu.h" +#include "UI.h" #include "..\..\Minecraft.h" #include "..\..\MultiplayerLocalPlayer.h" #include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" @@ -13,7 +14,7 @@ #include "..\..\..\Minecraft.World\JavaMath.h" // 4J JEV - Images for each tab. -IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = NULL; +IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = nullptr; vector< shared_ptr<ItemInstance> > IUIScene_CreativeMenu::categoryGroups[eCreativeInventoryGroupsCount]; @@ -21,7 +22,6 @@ vector< shared_ptr<ItemInstance> > IUIScene_CreativeMenu::categoryGroups[eCreati #define ITEM_AUX(id, aux) list->push_back( shared_ptr<ItemInstance>(new ItemInstance(id, 1, aux)) ); #define DEF(index) list = &categoryGroups[index]; - void IUIScene_CreativeMenu::staticCtor() { vector< shared_ptr<ItemInstance> > *list; @@ -488,14 +488,14 @@ void IUIScene_CreativeMenu::staticCtor() for(unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { Enchantment *enchantment = Enchantment::enchantments[i]; - if (enchantment == NULL || enchantment->category == NULL) continue; + if (enchantment == nullptr || enchantment->category == nullptr) continue; list->push_back(Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, enchantment->getMaxLevel()))); } #ifndef _CONTENT_PACKAGE if(app.DebugSettingsOn()) { - shared_ptr<ItemInstance> debugSword = shared_ptr<ItemInstance>(new ItemInstance(Item::sword_diamond_Id, 1, 0)); + shared_ptr<ItemInstance> debugSword = std::make_shared<ItemInstance>(Item::sword_diamond_Id, 1, 0); debugSword->enchant( Enchantment::damageBonus, 50 ); debugSword->setHoverName(L"Sword of Debug"); list->push_back(debugSword); @@ -673,7 +673,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; ECreative_Inventory_Groups debugDecorationsGroup[] = {eCreativeInventory_ArtToolsDecorations}; - specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, NULL, 1, debugDecorationsGroup); + specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup); #else ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup); @@ -707,7 +707,7 @@ void IUIScene_CreativeMenu::staticCtor() #ifndef _CONTENT_PACKAGE ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; ECreative_Inventory_Groups debugMiscGroup[] = {eCreativeInventory_ArtToolsMisc}; - specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL, 1, debugMiscGroup); + specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup); #else ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup); @@ -766,12 +766,12 @@ void IUIScene_CreativeMenu::ScrollBar(UIVec2D pointerPos) // 4J JEV - Tab Spec Struct -IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups, int debugGroupsCount /*= 0*/, ECreative_Inventory_Groups *debugGroups /*= NULL*/) +IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups, int debugGroupsCount /*= 0*/, ECreative_Inventory_Groups *debugGroups /*= nullptr*/) : m_icon(icon), m_descriptionId(descriptionId), m_staticGroupsCount(staticGroupsCount), m_dynamicGroupsCount(dynamicGroupsCount), m_debugGroupsCount(debugGroupsCount) { m_pages = 0; - m_staticGroupsA = NULL; + m_staticGroupsA = nullptr; unsigned int dynamicItems = 0; m_staticItems = 0; @@ -786,7 +786,7 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta } } - m_debugGroupsA = NULL; + m_debugGroupsA = nullptr; m_debugItems = 0; if(debugGroupsCount > 0) { @@ -798,8 +798,8 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta } } - m_dynamicGroupsA = NULL; - if(dynamicGroupsCount > 0 && dynamicGroups != NULL) + m_dynamicGroupsA = nullptr; + if(dynamicGroupsCount > 0 && dynamicGroups != nullptr) { m_dynamicGroupsA = new ECreative_Inventory_Groups[dynamicGroupsCount]; for(int i = 0; i < dynamicGroupsCount; ++i) @@ -816,9 +816,9 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta IUIScene_CreativeMenu::TabSpec::~TabSpec() { - if(m_staticGroupsA != NULL) delete [] m_staticGroupsA; - if(m_dynamicGroupsA != NULL) delete [] m_dynamicGroupsA; - if(m_debugGroupsA != NULL) delete [] m_debugGroupsA; + if(m_staticGroupsA != nullptr) delete [] m_staticGroupsA; + if(m_dynamicGroupsA != nullptr) delete [] m_dynamicGroupsA; + if(m_debugGroupsA != nullptr) delete [] m_debugGroupsA; } void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, int dynamicIndex, unsigned int page) @@ -826,7 +826,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i int lastSlotIndex = 0; // Fill the dynamic group - if(m_dynamicGroupsCount > 0 && m_dynamicGroupsA != NULL) + if(m_dynamicGroupsCount > 0 && m_dynamicGroupsA != nullptr) { for (auto it = categoryGroups[m_dynamicGroupsA[dynamicIndex]].rbegin(); it != categoryGroups[m_dynamicGroupsA[dynamicIndex]].rend() && lastSlotIndex < MAX_SIZE; ++it) { @@ -957,7 +957,7 @@ IUIScene_CreativeMenu::ItemPickerMenu::ItemPickerMenu( shared_ptr<SimpleContaine //int startLength = slots->size(); - Slot *slot = NULL; + Slot *slot = nullptr; for (int i = 0; i < TabSpec::MAX_SIZE; i++) { // 4J JEV - These values get set by addSlot anyway. @@ -1036,11 +1036,11 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, BOOL qu { shared_ptr<ItemInstance> newItem = m_menu->getSlot(i)->getItem(); - if(newItem != NULL) + if(newItem != nullptr) { m_menu->getSlot(i)->set(nullptr); // call this function to synchronize multiplayer item bar - pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); + pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - static_cast<int>(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START); } } return true; @@ -1054,7 +1054,7 @@ void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, BOOL q Minecraft *pMinecraft = Minecraft::GetInstance(); shared_ptr<Inventory> playerInventory = pMinecraft->localplayers[iPad]->inventory; - if (playerInventory->getCarried() != NULL) + if (playerInventory->getCarried() != nullptr) { if (buttonNum == 0) { @@ -1082,8 +1082,8 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) // Fall through intentional case ACTION_MENU_RIGHT_SCROLL: { - ECreativeInventoryTabs tab = (ECreativeInventoryTabs)(m_curTab + dir); - if (tab < 0) tab = (ECreativeInventoryTabs)(eCreativeInventoryTab_COUNT - 1); + ECreativeInventoryTabs tab = static_cast<ECreativeInventoryTabs>(m_curTab + dir); + if (tab < 0) tab = static_cast<ECreativeInventoryTabs>(eCreativeInventoryTab_COUNT - 1); if (tab >= eCreativeInventoryTab_COUNT) tab = eCreativeInventoryTab_BuildingBlocks; switchTab(tab); ui.PlayUISFX(eSFX_Focus); @@ -1099,13 +1099,7 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) break; case ACTION_MENU_OTHER_STICK_DOWN: { - int pageStep = TabSpec::rows; -#ifdef _WINDOWS64 - if (g_KBMInput.WasMouseWheelConsumed()) - { - pageStep = 1; - } -#endif + int pageStep = 1; m_tabPage[m_curTab] += pageStep; if(m_tabPage[m_curTab] >= specs[m_curTab]->getPageCount()) { @@ -1119,13 +1113,7 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) break; case ACTION_MENU_OTHER_STICK_UP: { - int pageStep = TabSpec::rows; -#ifdef _WINDOWS64 - if (g_KBMInput.WasMouseWheelConsumed()) - { - pageStep = 1; - } -#endif + int pageStep = 1; m_tabPage[m_curTab] -= pageStep; if(m_tabPage[m_curTab] < 0) { @@ -1155,7 +1143,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu shared_ptr<Inventory> playerInventory = pMinecraft->localplayers[getPad()]->inventory; shared_ptr<ItemInstance> carried = playerInventory->getCarried(); shared_ptr<ItemInstance> clicked = m_menu->getSlot(currentIndex)->getItem(); - if (clicked != NULL) + if (clicked != nullptr) { playerInventory->setCarried(ItemInstance::clone(clicked)); carried = playerInventory->getCarried(); @@ -1188,7 +1176,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu m_menu->clicked(currentIndex, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, pMinecraft->localplayers[getPad()]); shared_ptr<ItemInstance> newItem = m_menu->getSlot(currentIndex)->getItem(); // call this function to synchronize multiplayer item bar - pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd(newItem, currentIndex - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START); + pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd(newItem, currentIndex - static_cast<int>(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START); if(m_bCarryingCreativeItem) { @@ -1236,7 +1224,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot(shared_ptr<ItemInstance> item, for(unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { shared_ptr<ItemInstance> slotItem = m_menu->getSlot(i)->getItem(); - if( slotItem != NULL && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() )) + if( slotItem != nullptr && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() )) { sameItemFound = true; slotX = i - TabSpec::MAX_SIZE; @@ -1249,7 +1237,7 @@ bool IUIScene_CreativeMenu::getEmptyInventorySlot(shared_ptr<ItemInstance> item, // Find an empty slot for(unsigned int i = TabSpec::MAX_SIZE; i < TabSpec::MAX_SIZE + 9; ++i) { - if( m_menu->getSlot(i)->getItem() == NULL ) + if( m_menu->getSlot(i)->getItem() == nullptr ) { slotX = i - TabSpec::MAX_SIZE; emptySlotFound = true; @@ -1328,7 +1316,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis // diamonds give trails if (trail) expTag->putBoolean(FireworksItem::TAG_E_TRAIL, true); - intArray colorArray(colors.size()); + intArray colorArray(static_cast<unsigned int>(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); @@ -1347,7 +1335,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis vector<int> colors; colors.push_back(DyePowderItem::COLOR_RGB[fadeColor]); - intArray colorArray(colors.size()); + intArray colorArray(static_cast<unsigned int>(colors.size())); for (int i = 0; i < colorArray.length; i++) { colorArray[i] = colors.at(i); @@ -1362,7 +1350,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis shared_ptr<ItemInstance> firework; { - firework = shared_ptr<ItemInstance>( new ItemInstance(Item::fireworks) ); + firework = std::make_shared<ItemInstance>(Item::fireworks); CompoundTag *itemTag = new CompoundTag(); CompoundTag *fireTag = new CompoundTag(FireworksItem::TAG_FIREWORKS); ListTag<CompoundTag> *expTags = new ListTag<CompoundTag>(FireworksItem::TAG_EXPLOSIONS); @@ -1370,7 +1358,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis expTags->add(expTag); fireTag->put(FireworksItem::TAG_EXPLOSIONS, expTags); - fireTag->putByte(FireworksItem::TAG_FLIGHT, (byte) sulphur); + fireTag->putByte(FireworksItem::TAG_FLIGHT, static_cast<byte>(sulphur)); itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag); |
