mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-22 18:36:06 +01:00
another crafting table backup point
This commit is contained in:
1 parent
350ada405f
commit
e010da4376
15 files changed
+1752
-852
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include "../../../Minecraft.World/net.minecraft.world.inventory.h"
|
||||
#include "../../../Minecraft.World/DyePowderItem.h"
|
||||
#include "../../../Minecraft.World/Tile.h"
|
||||
#include "../../../Minecraft.World/BannerPatternRecipe.h"
|
||||
#include "UIScene_CraftingMenu.h"
|
||||
#ifdef _WINDOWS64
|
||||
#include "../../Windows64/Iggy/gdraw/gdraw_d3d11.h"
|
||||
@@ -33,12 +34,14 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p
|
||||
initialiseMovie();
|
||||
|
||||
for(unsigned int i = 0; i < 9; ++i) m_labelIngredientsDesc[i].init(L"");
|
||||
m_labelDescription.init(L"");
|
||||
m_labelDescriptionText.init(L"");
|
||||
m_labelDescriptionTextTop.init(L"");
|
||||
m_labelGroupName.init(L"");
|
||||
m_labelSpinnerTitle.init(L"");
|
||||
m_labelItemName.init(L"");
|
||||
m_labelItemNameSmall.init(L"");
|
||||
m_labelInventory.init( app.GetString(IDS_INVENTORY) );
|
||||
m_labelPreview.init(L"Preview");
|
||||
m_labelIngredients.init(app.GetString(IDS_INGREDIENTS));
|
||||
|
||||
if(m_iContainerType==RECIPE_TYPE_2x2)
|
||||
@@ -62,20 +65,55 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p
|
||||
{
|
||||
int maxGroupVLimit = ((m_iContainerType == RECIPE_TYPE_2x2) ? m_iMaxGroupV2x2 : m_iMaxGroupV3x3);
|
||||
{
|
||||
m_vGroupIconCache[0].item = make_shared<ItemInstance>(Tile::workBench, 1);
|
||||
m_vGroupIconCache[0].show = (1 <= maxGroupVLimit);
|
||||
m_vGroupIconCache[0].VSlot.item = make_shared<ItemInstance>(Tile::workBench, 1);
|
||||
m_vGroupIconCache[0].VSlot.show = (1 <= maxGroupVLimit);
|
||||
}
|
||||
{
|
||||
m_vGroupIconCache[1].item = make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0);
|
||||
m_vGroupIconCache[1].show = (2 <= maxGroupVLimit);
|
||||
m_vGroupIconCache[1].VSlot.item = make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0);
|
||||
m_vGroupIconCache[1].VSlot.show = (2 <= maxGroupVLimit);
|
||||
|
||||
{
|
||||
m_vGroupIconCache[1].HSlots.push_back(SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0)));
|
||||
}
|
||||
|
||||
{
|
||||
SlotInfo slotInfo = SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0));
|
||||
BannerPatternRecipe::addBannerPattern(slotInfo.item, L"cr", DyePowderItem::BLACK);
|
||||
|
||||
m_vGroupIconCache[1].HSlots.push_back(slotInfo);
|
||||
}
|
||||
{
|
||||
SlotInfo slotInfo = SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0));
|
||||
BannerPatternRecipe::addBannerPattern(slotInfo.item, L"ld", DyePowderItem::BLACK);
|
||||
|
||||
m_vGroupIconCache[1].HSlots.push_back(slotInfo);
|
||||
}
|
||||
{
|
||||
SlotInfo slotInfo = SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0));
|
||||
BannerPatternRecipe::addBannerPattern(slotInfo.item, L"mc", DyePowderItem::BLACK);
|
||||
|
||||
m_vGroupIconCache[1].HSlots.push_back(slotInfo);
|
||||
}
|
||||
{
|
||||
SlotInfo slotInfo = SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0));
|
||||
BannerPatternRecipe::addBannerPattern(slotInfo.item, L"bo", DyePowderItem::BLACK);
|
||||
|
||||
m_vGroupIconCache[1].HSlots.push_back(slotInfo);
|
||||
}
|
||||
{
|
||||
SlotInfo slotInfo = SlotInfo(make_shared<ItemInstance>(Tile::standing_banner_Id, 1, 0));
|
||||
BannerPatternRecipe::addBannerPattern(slotInfo.item, L"cre", DyePowderItem::BLACK);
|
||||
|
||||
m_vGroupIconCache[1].HSlots.push_back(slotInfo);
|
||||
}
|
||||
}
|
||||
{
|
||||
m_vGroupIconCache[2].item = make_shared<ItemInstance>(Item::fireworks_Id, 1, 0);
|
||||
m_vGroupIconCache[2].show = (3 <= maxGroupVLimit);
|
||||
m_vGroupIconCache[2].VSlot.item = make_shared<ItemInstance>(Item::fireworks_Id, 1, 0);
|
||||
m_vGroupIconCache[2].VSlot.show = (3 <= maxGroupVLimit);
|
||||
}
|
||||
{
|
||||
m_vGroupIconCache[3].item = make_shared<ItemInstance>(Item::dye_Id, 1, DyePowderItem::CYAN);
|
||||
m_vGroupIconCache[3].show = (4 <= maxGroupVLimit);
|
||||
m_vGroupIconCache[3].VSlot.item = make_shared<ItemInstance>(Item::dye_Id, 1, DyePowderItem::CYAN);
|
||||
m_vGroupIconCache[3].VSlot.show = (4 <= maxGroupVLimit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +144,6 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p
|
||||
m_pGroupTabA=(_eGroupTab *)&m_GroupTabBkgMapping2x2A;
|
||||
|
||||
m_pGroupA[eGroupVType::eGroupVType_Workbench] = (Recipy::_eGroupType*)&m_GroupTypeMapping4GridA;
|
||||
m_pGroupA[eGroupVType::eGroupVType_Banner] = (Recipy::_eGroupType*)&m_GroupTypeBannerMapping4GridA;
|
||||
}
|
||||
m_iCraftablesMaxHSlotC = m_iMaxHSlot;
|
||||
|
||||
@@ -156,6 +193,7 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p
|
||||
m_Slot3_2.addSlot(CRAFTING_SLOT_EXTRA_START + 1);
|
||||
m_Slot3_3.addSlot(CRAFTING_SLOT_EXTRA_START + 2);
|
||||
|
||||
m_slotPreviewSlot.addSlot(CRAFTING_SLOT_EXTRA_START + 0);
|
||||
|
||||
// 3 Slot vertical scroll
|
||||
m_slotListCrafting3VSlots[0].addSlot(CRAFTING_V_SLOT_START + 0);
|
||||
@@ -266,20 +304,74 @@ UIControl* UIScene_CraftingMenu::GetMainPanel()
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sceneY) {
|
||||
void UIScene_CraftingMenu::handleCraftingGroupSwitch() {
|
||||
m_iCurrentSlotHIndex = 0;
|
||||
m_iCurrentSlotVIndex = 1;
|
||||
UpdateCraftingPanels();
|
||||
CheckRecipesAvailable();
|
||||
if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) {
|
||||
iVSlotIndexA[0] = 15; // White
|
||||
iVSlotIndexA[1] = 0; // Black (center)
|
||||
iVSlotIndexA[2] = 1; // Red
|
||||
} else {
|
||||
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
|
||||
iVSlotIndexA[1] = 0;
|
||||
iVSlotIndexA[2] = 1;
|
||||
}
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
UpdateVerticalSlots();
|
||||
UpdateHighlight();
|
||||
setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex]));
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::handleCraftingSlotClick(int iIndex) {
|
||||
if (iIndex == m_iCurrentSlotHIndex) {
|
||||
// Click on already-selected slot — craft the item
|
||||
|
||||
if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) {
|
||||
handleKeyDown(m_iPad, ACTION_MENU_Y, false);
|
||||
} else {
|
||||
handleKeyDown(m_iPad, ACTION_MENU_A, false);
|
||||
}
|
||||
} else {
|
||||
int iOldHSlot = m_iCurrentSlotHIndex;
|
||||
m_iCurrentSlotHIndex = iIndex;
|
||||
m_iCurrentSlotVIndex = 1;
|
||||
if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) {
|
||||
iVSlotIndexA[0] = 15; // White
|
||||
iVSlotIndexA[1] = 0; // Black (center)
|
||||
iVSlotIndexA[2] = 1; // Red
|
||||
} else {
|
||||
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
|
||||
iVSlotIndexA[1] = 0;
|
||||
iVSlotIndexA[2] = 1;
|
||||
}
|
||||
UpdateVerticalSlots();
|
||||
UpdateHighlight();
|
||||
//if (CanBeMadeA[iOldHSlot].iCount > 0) {
|
||||
setShowCraftHSlot(iOldHSlot, true);
|
||||
//}
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
}
|
||||
}
|
||||
|
||||
bool isClickInsideControl(F32 x, F32 y, UIControl& control) {
|
||||
F32 rectX = control.getXPos();
|
||||
F32 rectY = control.getYPos();
|
||||
|
||||
return x >= rectX && x < rectX + control.getWidth() && y >= rectY && y < rectY + control.getHeight();
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sceneY) {
|
||||
{
|
||||
int maxHorizontalTabs = (m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2;
|
||||
|
||||
F32 groupRowX1 = m_GroupH1.getXPos();
|
||||
F32 groupRowX2 = m_GroupH2.getXPos();
|
||||
F32 groupRowWidth = m_GroupH1.getWidth();
|
||||
F32 groupRowSpacing = groupRowX2 - (groupRowX1 + groupRowWidth);
|
||||
F32 groupRowX1 = m_GroupH[0].getXPos();
|
||||
F32 groupRowWidth = m_GroupH[0].getWidth();
|
||||
|
||||
F32 tabStep = groupRowWidth + groupRowSpacing;
|
||||
F32 rowX = groupRowX1;
|
||||
F32 rowY = m_GroupH1.getYPos();
|
||||
F32 rowHeight = m_GroupH1.getHeight();
|
||||
F32 tabStep = groupRowWidth + (m_GroupH[1].getXPos() - (groupRowX1 + groupRowWidth));
|
||||
F32 rowY = m_GroupH[0].getYPos();
|
||||
F32 rowHeight = m_GroupH[0].getHeight();
|
||||
|
||||
if (sceneY >= rowY && sceneY < rowY + rowHeight && sceneX >= groupRowX1 && tabStep > 0.0f) {
|
||||
F32 offsetX = sceneX - groupRowX1;
|
||||
@@ -289,20 +381,12 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc
|
||||
F32 tabOffset = offsetX - tabIndex * tabStep;
|
||||
|
||||
if (tabOffset < groupRowWidth) {
|
||||
m_iGroupHIndex = tabIndex;
|
||||
setHGroupHighlight(m_iGroupHIndex);
|
||||
m_iCurrentSlotHIndex = 0;
|
||||
m_iCurrentSlotVIndex = 1;
|
||||
UpdateCraftingPanels();
|
||||
CheckRecipesAvailable();
|
||||
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
|
||||
iVSlotIndexA[1] = 0;
|
||||
iVSlotIndexA[2] = 1;
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
UpdateVerticalSlots();
|
||||
UpdateHighlight();
|
||||
setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex]));
|
||||
if (iHSlotState[tabIndex]) {
|
||||
m_iGroupHIndex = tabIndex;
|
||||
setHGroupHighlight(m_iGroupHIndex);
|
||||
|
||||
handleCraftingGroupSwitch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -311,14 +395,12 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc
|
||||
{
|
||||
int maxVerticalTabs = (m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroupV3x3 : m_iMaxGroupV2x2;
|
||||
|
||||
F32 groupRowY1 = m_GroupV1.getYPos();
|
||||
F32 groupRowY2 = m_GroupV2.getYPos();
|
||||
F32 groupRowHeight = m_GroupV1.getHeight();
|
||||
F32 groupRowSpacing = groupRowY2 - (groupRowY1 + groupRowHeight);
|
||||
F32 groupRowY1 = m_GroupV[0].getYPos();
|
||||
F32 groupRowHeight = m_GroupV[0].getHeight();
|
||||
|
||||
F32 tabStep = groupRowHeight + groupRowSpacing;
|
||||
F32 rowX = m_GroupV1.getXPos();
|
||||
F32 rowWidth = m_GroupV1.getWidth();
|
||||
F32 tabStep = groupRowHeight + (m_GroupV[1].getYPos() - (groupRowY1 + groupRowHeight));
|
||||
F32 rowX = m_GroupV[0].getXPos();
|
||||
F32 rowWidth = m_GroupV[0].getWidth();
|
||||
|
||||
if (sceneY >= groupRowY1 && sceneX >= rowX && sceneX < rowX + rowWidth && tabStep > 0.0f) {
|
||||
F32 offsetY = sceneY - groupRowY1;
|
||||
@@ -328,58 +410,48 @@ void UIScene_CraftingMenu::handleLeftMouseClick(F32 x, F32 y, F32 sceneX, F32 sc
|
||||
F32 tabOffset = offsetY - tabIndex * tabStep;
|
||||
|
||||
if (tabOffset < groupRowHeight) {
|
||||
|
||||
m_iGroupHIndex = 0;
|
||||
m_iGroupVIndex = tabIndex;
|
||||
setVGroupHighlight(m_iGroupVIndex);
|
||||
m_iCurrentSlotHIndex = 0;
|
||||
m_iCurrentSlotVIndex = 1;
|
||||
UpdateCraftingPanels();
|
||||
CheckRecipesAvailable();
|
||||
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
|
||||
iVSlotIndexA[1] = 0;
|
||||
iVSlotIndexA[2] = 1;
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
UpdateVerticalSlots();
|
||||
UpdateHighlight();
|
||||
setGroupText(GetGroupNameText(m_pGroupA[m_iGroupVIndex][m_iGroupHIndex]));
|
||||
|
||||
handleCraftingGroupSwitch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_iGroupVIndex == eGroupVType::eGroupVType_Workbench) {
|
||||
bool showingSpecial3 = (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0);
|
||||
bool showingSpecial2 = false;
|
||||
bool showingNormalSlots = (!showingSpecial3 && !showingSpecial2);
|
||||
|
||||
if (showingSpecial3) {
|
||||
if (isClickInsideControl(sceneX, sceneY, m_Slot3_1)) {
|
||||
handleCraftingSlotClick(0);
|
||||
UpdateCraftingPanels();
|
||||
} else if (isClickInsideControl(sceneX, sceneY, m_Slot3_2)) {
|
||||
handleCraftingSlotClick(1);
|
||||
UpdateCraftingPanels();
|
||||
} else if (isClickInsideControl(sceneX, sceneY, m_Slot3_3)) {
|
||||
handleCraftingSlotClick(2);
|
||||
UpdateCraftingPanels();
|
||||
}
|
||||
} else if (showingSpecial2) {
|
||||
|
||||
} else if (showingNormalSlots) {
|
||||
if (m_hSlotBoundsValid && m_hSlotSpacing > 0) {
|
||||
F32 rowWidth = m_hSlotSpacing * m_iCraftablesMaxHSlotC;
|
||||
if (x >= m_hSlotX0 && x < m_hSlotX0 + rowWidth && y >= m_hSlotY0 && y < m_hSlotY1) {
|
||||
int iNewSlot = (int)((x - m_hSlotX0) / m_hSlotSpacing);
|
||||
if (iNewSlot >= 0 && iNewSlot < m_iCraftablesMaxHSlotC) {
|
||||
// Only interact with populated slots
|
||||
if (CanBeMadeA[iNewSlot].iCount != 0) {
|
||||
if (iNewSlot == m_iCurrentSlotHIndex)
|
||||
{
|
||||
// Click on already-selected slot — craft the item
|
||||
handleKeyDown(m_iPad, ACTION_MENU_A, false);
|
||||
} else {
|
||||
int iOldHSlot = m_iCurrentSlotHIndex;
|
||||
m_iCurrentSlotHIndex = iNewSlot;
|
||||
m_iCurrentSlotVIndex = 1;
|
||||
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
|
||||
iVSlotIndexA[1] = 0;
|
||||
iVSlotIndexA[2] = 1;
|
||||
UpdateVerticalSlots();
|
||||
UpdateHighlight();
|
||||
if (CanBeMadeA[iOldHSlot].iCount > 0) {
|
||||
setShowCraftHSlot(iOldHSlot, true);
|
||||
}
|
||||
ui.PlayUISFX(eSFX_Focus);
|
||||
}
|
||||
}
|
||||
//if (CanBeMadeA[iNewSlot].iCount != 0) {
|
||||
handleCraftingSlotClick(iNewSlot);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -416,6 +488,8 @@ void UIScene_CraftingMenu::handleReload()
|
||||
m_Slot3_2.addSlot(CRAFTING_SLOT_EXTRA_START + 1);
|
||||
m_Slot3_3.addSlot(CRAFTING_SLOT_EXTRA_START + 2);
|
||||
|
||||
m_slotPreviewSlot.addSlot(CRAFTING_SLOT_EXTRA_START + 0);
|
||||
|
||||
// 3 Slot vertical scroll
|
||||
m_slotListCrafting3VSlots[0].addSlot(CRAFTING_V_SLOT_START + 0);
|
||||
m_slotListCrafting3VSlots[1].addSlot(CRAFTING_V_SLOT_START + 1);
|
||||
@@ -452,7 +526,6 @@ void UIScene_CraftingMenu::handleReload()
|
||||
UpdateHighlight();
|
||||
|
||||
app.DebugPrintf(app.USER_SR,"Reloading tabs\n");
|
||||
setHGroupHighlight(m_iGroupHIndex);
|
||||
setVGroupHighlight(m_iGroupVIndex);
|
||||
UpdateCraftingPanels();
|
||||
}
|
||||
@@ -552,44 +625,30 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
|
||||
else if (slotId >= CRAFTING_SLOT_EXTRA_START && slotId < CRAFTING_SLOT_EXTRA_END) {
|
||||
int iIndex = (slotId - CRAFTING_SLOT_EXTRA_START);
|
||||
if (iIndex == 0) {
|
||||
if (m_hSlotsInfo[0].show) {
|
||||
item = m_hSlotsInfo[0].item;
|
||||
alpha = static_cast<float>(m_hSlotsInfo[0].alpha) / 31.0f;
|
||||
if (m_iGroupHIndex > 0) {
|
||||
item = m_bannerPreviewHolder;
|
||||
alpha = 1.0f;
|
||||
} else {
|
||||
if (m_craftingOutputSlotInfo.show)
|
||||
{
|
||||
item = m_craftingOutputSlotInfo.item;
|
||||
alpha = static_cast<float>(m_craftingOutputSlotInfo.alpha) / 31.0f;
|
||||
if (m_hSlotsInfo[0].show) {
|
||||
item = m_hSlotsInfo[0].item;
|
||||
alpha = static_cast<float>(m_hSlotsInfo[0].alpha) / 31.0f;
|
||||
} else {
|
||||
if (m_craftingOutputSlotInfo.show)
|
||||
{
|
||||
item = m_craftingOutputSlotInfo.item;
|
||||
alpha = static_cast<float>(m_hSlotsInfo[0].alpha) / 31.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (iIndex == 1) {
|
||||
if (CurrentInventoryBanners.size() > 0) {
|
||||
if (m_iCurrentSlotHIndex == 1) {
|
||||
item = CurrentInventoryBanners[m_iCurrentSlotVIndex-1];
|
||||
} else {
|
||||
item = CurrentInventoryBanners[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// Cache H slot SWF-space positions from the custom draw transform matrix
|
||||
if (iIndex == 0 || iIndex == 1)
|
||||
{
|
||||
F32 mat[16];
|
||||
gdraw_D3D11_CalculateCustomDraw_4J(region, mat);
|
||||
// Matrix to SWF coords (same formula as setupCustomDrawMatrices)
|
||||
F32 sw = (F32)getRenderWidth();
|
||||
F32 sh = (F32)getRenderHeight();
|
||||
F32 swfX = sw * (1.0f + mat[3]) / 2.0f;
|
||||
F32 swfY = sh * (1.0f - mat[7]) / 2.0f;
|
||||
if (iIndex == 0)
|
||||
{
|
||||
m_hSlotX0 = swfX;
|
||||
m_hSlotY0 = swfY;
|
||||
// Slot visual height from matrix scale and region height
|
||||
F32 slotH = sh * (-mat[5]) / 2.0f * region->y1;
|
||||
m_hSlotY1 = swfY + slotH;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hSlotSpacing = swfX - m_hSlotX0;
|
||||
m_hSlotBoundsValid = (m_hSlotSpacing > 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (slotId >= CRAFTING_INGREDIENTS_DESCRIPTION_START && slotId < (CRAFTING_INGREDIENTS_DESCRIPTION_START + 9))
|
||||
{
|
||||
@@ -609,13 +668,26 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
|
||||
}
|
||||
}
|
||||
} else if (swscanf(static_cast<wchar_t*>(region->name), L"TabV_%d", &iTabV) == 1) {
|
||||
SlotInfo& vGroupIconInfo = m_vGroupIconCache[iTabV - 1];
|
||||
if (vGroupIconInfo.show) {
|
||||
item = vGroupIconInfo.item;
|
||||
alpha = vGroupIconInfo.alpha;
|
||||
GroupIcons& vGroupIconInfo = m_vGroupIconCache[iTabV - 1];
|
||||
|
||||
if (vGroupIconInfo.VSlot.show) {
|
||||
item = vGroupIconInfo.VSlot.item;
|
||||
alpha = static_cast<float>(vGroupIconInfo.VSlot.alpha)/31.0f;
|
||||
}
|
||||
} else if (swscanf(static_cast<wchar_t*>(region->name), L"TabH_%d", &iTabH) == 1) {
|
||||
|
||||
GroupIcons& vGroupIconInfo = m_vGroupIconCache[m_iGroupVIndex];
|
||||
|
||||
if (m_selectedBannerEdit == nullptr) {
|
||||
if (vGroupIconInfo.HSlots.size() >= iTabH && iTabH == 1) {
|
||||
item = vGroupIconInfo.HSlots[iTabH - 1].item;
|
||||
}
|
||||
} else {
|
||||
if (vGroupIconInfo.HSlots.size() >= iTabH && iTabH != 1) {
|
||||
item = vGroupIconInfo.HSlots[iTabH - 1].item;
|
||||
}
|
||||
}
|
||||
|
||||
//alpha = static_cast<float>(vGroupIconInfo.HSlots[iTabH - 1].alpha)/31.0f;
|
||||
}
|
||||
|
||||
if(item != nullptr) {
|
||||
@@ -633,6 +705,11 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
}
|
||||
|
||||
int UIScene_CraftingMenu::getPad()
|
||||
{
|
||||
return m_iPad;
|
||||
@@ -654,19 +731,25 @@ void UIScene_CraftingMenu::handleInput(int iPad, int key, bool repeat, bool pres
|
||||
//app.DebugPrintf("UIScene_InventoryMenu handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE");
|
||||
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case ACTION_MENU_OTHER_STICK_UP:
|
||||
case ACTION_MENU_OTHER_STICK_DOWN:
|
||||
sendInputToMovie(key,repeat,pressed,released);
|
||||
break;
|
||||
default:
|
||||
if(pressed)
|
||||
//if (m_iGroupVIndex == eGroupVType_Banner && m_iCurrentSlotHIndex == 1) {
|
||||
|
||||
//} else {
|
||||
switch(key)
|
||||
{
|
||||
handled = handleKeyDown(m_iPad, key, repeat);
|
||||
}
|
||||
break;
|
||||
};
|
||||
case ACTION_MENU_OTHER_STICK_UP:
|
||||
case ACTION_MENU_OTHER_STICK_DOWN:
|
||||
sendInputToMovie(key,repeat,pressed,released);
|
||||
break;
|
||||
default:
|
||||
if(pressed)
|
||||
{
|
||||
handled = handleKeyDown(m_iPad, key, repeat);
|
||||
}
|
||||
break;
|
||||
};
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::hideAllHSlots()
|
||||
@@ -727,6 +810,9 @@ void UIScene_CraftingMenu::setCraftVSlotItem(int iPad, int iIndex, shared_ptr<It
|
||||
|
||||
void UIScene_CraftingMenu::setCraftingOutputSlotItem(int iPad, shared_ptr<ItemInstance> item)
|
||||
{
|
||||
if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0) {
|
||||
setDescriptionTextTop(item->getHoverName().c_str());
|
||||
}
|
||||
m_craftingOutputSlotInfo.item = item;
|
||||
m_craftingOutputSlotInfo.alpha = 31;
|
||||
m_craftingOutputSlotInfo.show = item != nullptr;
|
||||
@@ -797,6 +883,8 @@ void UIScene_CraftingMenu::setHGroupHighlight(int iIndex)
|
||||
|
||||
void UIScene_CraftingMenu::setVGroupHighlight(int iIndex) {
|
||||
setHGroupHighlight(m_iGroupHIndex);
|
||||
m_selectedBannerEdit = nullptr;
|
||||
m_bannerPreviewHolder = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -807,18 +895,23 @@ void UIScene_CraftingMenu::setGroupText(LPCWSTR text)
|
||||
|
||||
void UIScene_CraftingMenu::setDescriptionText(LPCWSTR text)
|
||||
{
|
||||
m_labelDescription.setLabel(text);
|
||||
m_labelDescriptionText.setLabel(text);
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::setDescriptionTextTop(LPCWSTR text)
|
||||
{
|
||||
m_labelDescriptionTextTop.setLabel(text);
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::setItemText(LPCWSTR text)
|
||||
{
|
||||
if (m_iContainerType == RECIPE_TYPE_2x2) {
|
||||
m_labelItemNameSmall.setLabel(text);
|
||||
m_labelItemName.setLabel(L"");
|
||||
} else {
|
||||
//if (m_iContainerType == RECIPE_TYPE_2x2) {
|
||||
// m_labelItemNameSmall.setLabel(text);
|
||||
// m_labelItemName.setLabel(L"");
|
||||
//} else {
|
||||
m_labelItemName.setLabel(text);
|
||||
m_labelItemNameSmall.setLabel(L"");
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::UpdateMultiPanel()
|
||||
@@ -853,13 +946,21 @@ void UIScene_CraftingMenu::updateHighlightAndScrollPositions()
|
||||
value[0].number = m_iCurrentSlotHIndex;
|
||||
|
||||
int selectorType = 0;
|
||||
if(CanBeMadeA[m_iCurrentSlotHIndex].iCount == 2)
|
||||
{
|
||||
selectorType = 1;
|
||||
}
|
||||
else if( CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2)
|
||||
{
|
||||
|
||||
if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex == 0 && m_iCurrentSlotHIndex == 1) {
|
||||
if (CurrentInventoryBanners.size() == 2) {
|
||||
selectorType = 1;
|
||||
} else if (CurrentInventoryBanners.size() > 2) {
|
||||
selectorType = 2;
|
||||
}
|
||||
} else if (m_iGroupVIndex == eGroupVType_Banner && m_iGroupHIndex > 0) {
|
||||
selectorType = 2;
|
||||
} else {
|
||||
if(CanBeMadeA[m_iCurrentSlotHIndex].iCount == 2) {
|
||||
selectorType = 1;
|
||||
} else if( CanBeMadeA[m_iCurrentSlotHIndex].iCount > 2) {
|
||||
selectorType = 2;
|
||||
}
|
||||
}
|
||||
|
||||
value[1].type = IGGY_DATATYPE_number;
|
||||
@@ -904,6 +1005,19 @@ void UIScene_CraftingMenu::HandleMessage(EUIMessage message, void *data)
|
||||
void UIScene_CraftingMenu::handleInventoryUpdated(LPVOID data)
|
||||
{
|
||||
HandleInventoryUpdated();
|
||||
|
||||
if (m_selectedBannerEdit != nullptr) {
|
||||
bool stillHasEditingBanner = false;
|
||||
for (unsigned int i = 0; i < CurrentInventoryBanners.size(); i++) {
|
||||
if (CurrentInventoryBanners[i] == nullptr) continue;
|
||||
if (CurrentInventoryBanners[i].get() == m_selectedBannerEdit.get()) {
|
||||
stillHasEditingBanner = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stillHasEditingBanner) setSelectedBannerEdit(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::updateVSlotPositions(int iSlots, int i)
|
||||
@@ -926,7 +1040,7 @@ void UIScene_CraftingMenu::SetCraftingMenu() {
|
||||
|
||||
int currentHGroups = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxGroupH3x3 : m_iMaxGroupH2x2);
|
||||
if (m_iGroupVIndex == eGroupVType_Banner) {
|
||||
currentHGroups = (m_iContainerType == RECIPE_TYPE_3x3 ? m_iMaxBannerGroupH3x3 : m_iMaxBannerGroupH2x2);
|
||||
currentHGroups = m_iMaxBannerGroupH3x3;
|
||||
}
|
||||
|
||||
value[0].type = IGGY_DATATYPE_number;
|
||||
@@ -940,27 +1054,83 @@ void UIScene_CraftingMenu::SetCraftingMenu() {
|
||||
|
||||
|
||||
void UIScene_CraftingMenu::UpdateCraftingPanels() {
|
||||
UpdateEnabledTabs();
|
||||
|
||||
if (m_iGroupVIndex == eGroupVType_Workbench) {
|
||||
m_iDisplayDescription = DISPLAY_INVENTORY;
|
||||
ShowSuperCraftingSlots(0);
|
||||
ShowDescriptionPanel(false);
|
||||
} else if (m_iGroupVIndex == eGroupVType_Banner) {
|
||||
ShowDescriptionPanel(m_iGroupHIndex == 0);
|
||||
|
||||
if (m_iGroupHIndex == 0) {
|
||||
ShowSuperCraftingSlots(3);
|
||||
m_iDisplayDescription = DISPLAY_INVENTORY;
|
||||
|
||||
if (m_iCurrentSlotHIndex == 0) {
|
||||
m_labelSpinnerTitle.setLabel(L"Create Banner");
|
||||
} else if (m_iCurrentSlotHIndex == 1) {
|
||||
m_labelSpinnerTitle.setLabel(L"Select Banner");
|
||||
}
|
||||
} else {
|
||||
ShowSuperCraftingSlots(0);
|
||||
m_iDisplayDescription = DISPLAY_PREVIEW;
|
||||
}
|
||||
|
||||
if (m_iCurrentSlotHIndex == 0) {
|
||||
m_labelSpinnerTitle.setLabel(L"Create Banner");
|
||||
} else if (m_iCurrentSlotHIndex == 1) {
|
||||
m_labelSpinnerTitle.setLabel(L"Select Banner");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetCraftingMenu();
|
||||
UpdateMultiPanel();
|
||||
updateHighlightAndScrollPositions();
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::UpdateEnabledTabs() {
|
||||
int maxHGroups = (m_iContainerType == RECIPE_TYPE_2x2) ? m_iMaxGroupH2x2 : m_iMaxGroupH3x3;
|
||||
for (int i = 0; i < maxHGroups; i++) {
|
||||
EnableTab(i, true);
|
||||
}
|
||||
|
||||
if (m_iGroupVIndex == eGroupVType_Banner) {
|
||||
if (m_selectedBannerEdit == nullptr) {
|
||||
for (int i = 1; i < maxHGroups; i++) {
|
||||
EnableTab(i, false);
|
||||
}
|
||||
} else {
|
||||
EnableTab(0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::EnableTab(int iIndex, bool enabled) {
|
||||
IggyDataValue result;
|
||||
IggyDataValue value[2];
|
||||
|
||||
value[0].type = IGGY_DATATYPE_number;
|
||||
value[0].number = iIndex;
|
||||
value[1].type = IGGY_DATATYPE_boolean;
|
||||
value[1].boolval = enabled;
|
||||
IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcEnableTab, 2, value);
|
||||
|
||||
iHSlotState[iIndex] = enabled;
|
||||
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::ShowDescriptionPanel(bool show) {
|
||||
m_controlDescriptionPanel.setVisible(show);
|
||||
m_labelDescriptionTextTop.setVisible(show);
|
||||
}
|
||||
|
||||
void UIScene_CraftingMenu::setSelectedBannerEdit(shared_ptr<ItemInstance> banner) {
|
||||
m_selectedBannerEdit = banner;
|
||||
|
||||
if (m_selectedBannerEdit == nullptr) {
|
||||
m_iGroupHIndex = 0;
|
||||
m_bannerPreviewHolder = nullptr;
|
||||
} else {
|
||||
m_iGroupHIndex = 1;
|
||||
m_bannerPreviewHolder = ItemInstance::clone(m_selectedBannerEdit);
|
||||
}
|
||||
setHGroupHighlight(m_iGroupHIndex);
|
||||
handleCraftingGroupSwitch();
|
||||
}
|
||||
Reference in new issue
Block a user