Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "IUIScene_CreativeMenu.h"
|
||||
|
||||
#include "UI.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\MultiplayerLocalPlayer.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
|
||||
@@ -14,7 +13,7 @@
|
||||
#include "..\..\..\Minecraft.World\JavaMath.h"
|
||||
|
||||
// 4J JEV - Images for each tab.
|
||||
IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = nullptr;
|
||||
IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = NULL;
|
||||
|
||||
vector< shared_ptr<ItemInstance> > IUIScene_CreativeMenu::categoryGroups[eCreativeInventoryGroupsCount];
|
||||
|
||||
@@ -22,6 +21,7 @@ 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 == nullptr || enchantment->category == nullptr) continue;
|
||||
if (enchantment == NULL || enchantment->category == NULL) continue;
|
||||
list->push_back(Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, enchantment->getMaxLevel())));
|
||||
}
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if(app.DebugSettingsOn())
|
||||
{
|
||||
shared_ptr<ItemInstance> debugSword = std::make_shared<ItemInstance>(Item::sword_diamond_Id, 1, 0);
|
||||
shared_ptr<ItemInstance> debugSword = shared_ptr<ItemInstance>(new 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, nullptr, 1, debugDecorationsGroup);
|
||||
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, NULL, 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, nullptr, 1, debugMiscGroup);
|
||||
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, NULL, 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 /*= nullptr*/)
|
||||
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*/)
|
||||
: m_icon(icon), m_descriptionId(descriptionId), m_staticGroupsCount(staticGroupsCount), m_dynamicGroupsCount(dynamicGroupsCount), m_debugGroupsCount(debugGroupsCount)
|
||||
{
|
||||
|
||||
m_pages = 0;
|
||||
m_staticGroupsA = nullptr;
|
||||
m_staticGroupsA = NULL;
|
||||
|
||||
unsigned int dynamicItems = 0;
|
||||
m_staticItems = 0;
|
||||
@@ -786,7 +786,7 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta
|
||||
}
|
||||
}
|
||||
|
||||
m_debugGroupsA = nullptr;
|
||||
m_debugGroupsA = NULL;
|
||||
m_debugItems = 0;
|
||||
if(debugGroupsCount > 0)
|
||||
{
|
||||
@@ -798,8 +798,8 @@ IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int sta
|
||||
}
|
||||
}
|
||||
|
||||
m_dynamicGroupsA = nullptr;
|
||||
if(dynamicGroupsCount > 0 && dynamicGroups != nullptr)
|
||||
m_dynamicGroupsA = NULL;
|
||||
if(dynamicGroupsCount > 0 && dynamicGroups != NULL)
|
||||
{
|
||||
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 != nullptr) delete [] m_staticGroupsA;
|
||||
if(m_dynamicGroupsA != nullptr) delete [] m_dynamicGroupsA;
|
||||
if(m_debugGroupsA != nullptr) delete [] m_debugGroupsA;
|
||||
if(m_staticGroupsA != NULL) delete [] m_staticGroupsA;
|
||||
if(m_dynamicGroupsA != NULL) delete [] m_dynamicGroupsA;
|
||||
if(m_debugGroupsA != NULL) 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 != nullptr)
|
||||
if(m_dynamicGroupsCount > 0 && m_dynamicGroupsA != NULL)
|
||||
{
|
||||
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 = nullptr;
|
||||
Slot *slot = NULL;
|
||||
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 != nullptr)
|
||||
if(newItem != NULL)
|
||||
{
|
||||
m_menu->getSlot(i)->set(nullptr);
|
||||
// call this function to synchronize multiplayer item bar
|
||||
pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - static_cast<int>(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START);
|
||||
pMinecraft->localgameModes[iPad]->handleCreativeModeItemAdd(nullptr, i - (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() != nullptr)
|
||||
if (playerInventory->getCarried() != NULL)
|
||||
{
|
||||
if (buttonNum == 0)
|
||||
{
|
||||
@@ -1082,8 +1082,8 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction)
|
||||
// Fall through intentional
|
||||
case ACTION_MENU_RIGHT_SCROLL:
|
||||
{
|
||||
ECreativeInventoryTabs tab = static_cast<ECreativeInventoryTabs>(m_curTab + dir);
|
||||
if (tab < 0) tab = static_cast<ECreativeInventoryTabs>(eCreativeInventoryTab_COUNT - 1);
|
||||
ECreativeInventoryTabs tab = (ECreativeInventoryTabs)(m_curTab + dir);
|
||||
if (tab < 0) tab = (ECreativeInventoryTabs)(eCreativeInventoryTab_COUNT - 1);
|
||||
if (tab >= eCreativeInventoryTab_COUNT) tab = eCreativeInventoryTab_BuildingBlocks;
|
||||
switchTab(tab);
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
@@ -1143,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 != nullptr)
|
||||
if (clicked != NULL)
|
||||
{
|
||||
playerInventory->setCarried(ItemInstance::clone(clicked));
|
||||
carried = playerInventory->getCarried();
|
||||
@@ -1176,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 - static_cast<int>(m_menu->slots.size()) + 9 + InventoryMenu::USE_ROW_SLOT_START);
|
||||
pMinecraft->localgameModes[getPad()]->handleCreativeModeItemAdd(newItem, currentIndex - (int)m_menu->slots.size() + 9 + InventoryMenu::USE_ROW_SLOT_START);
|
||||
|
||||
if(m_bCarryingCreativeItem)
|
||||
{
|
||||
@@ -1224,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 != nullptr && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() ))
|
||||
if( slotItem != NULL && slotItem->sameItemWithTags(item) && (slotItem->GetCount() + item->GetCount() <= item->getMaxStackSize() ))
|
||||
{
|
||||
sameItemFound = true;
|
||||
slotX = i - TabSpec::MAX_SIZE;
|
||||
@@ -1237,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() == nullptr )
|
||||
if( m_menu->getSlot(i)->getItem() == NULL )
|
||||
{
|
||||
slotX = i - TabSpec::MAX_SIZE;
|
||||
emptySlotFound = true;
|
||||
@@ -1316,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(static_cast<unsigned int>(colors.size()));
|
||||
intArray colorArray(colors.size());
|
||||
for (int i = 0; i < colorArray.length; i++)
|
||||
{
|
||||
colorArray[i] = colors.at(i);
|
||||
@@ -1335,7 +1335,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis
|
||||
vector<int> colors;
|
||||
colors.push_back(DyePowderItem::COLOR_RGB[fadeColor]);
|
||||
|
||||
intArray colorArray(static_cast<unsigned int>(colors.size()));
|
||||
intArray colorArray(colors.size());
|
||||
for (int i = 0; i < colorArray.length; i++)
|
||||
{
|
||||
colorArray[i] = colors.at(i);
|
||||
@@ -1350,7 +1350,7 @@ void IUIScene_CreativeMenu::BuildFirework(vector<shared_ptr<ItemInstance> > *lis
|
||||
shared_ptr<ItemInstance> firework;
|
||||
|
||||
{
|
||||
firework = std::make_shared<ItemInstance>(Item::fireworks);
|
||||
firework = shared_ptr<ItemInstance>( new ItemInstance(Item::fireworks) );
|
||||
CompoundTag *itemTag = new CompoundTag();
|
||||
CompoundTag *fireTag = new CompoundTag(FireworksItem::TAG_FIREWORKS);
|
||||
ListTag<CompoundTag> *expTags = new ListTag<CompoundTag>(FireworksItem::TAG_EXPLOSIONS);
|
||||
@@ -1358,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, static_cast<byte>(sulphur));
|
||||
fireTag->putByte(FireworksItem::TAG_FLIGHT, (byte) sulphur);
|
||||
|
||||
itemTag->put(FireworksItem::TAG_FIREWORKS, fireTag);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user