Initial commit

This commit is contained in:
Stillkill committed 2026-03-08 15:20:20 -05:00
commit 2dfcaaa842
5375 files changed
+978475

No files matched your search

@@ -0,0 +1,77 @@
#pragma once
#include "UIEnums.h"
// 4J Stu - An interface class that defines all the public functions that we use within the game code. This allows us to build the Xbox 360 version without
// using the base UIController class used by the other platforms
class IUIController
{
public:
virtual void tick() = 0;
virtual void render() = 0;
virtual void StartReloadSkinThread() = 0;
virtual bool IsReloadingSkin() = 0;
virtual void CleanUpSkinReload() = 0;
virtual bool NavigateToScene(int iPad, EUIScene scene, void *initData = NULL, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD) = 0;
virtual bool NavigateBack(int iPad, bool forceUsePad = false, EUIScene eScene = eUIScene_COUNT, EUILayer eLayer = eUILayer_COUNT) = 0;
virtual void CloseUIScenes(int iPad, bool forceIPad = false) = 0;
virtual void CloseAllPlayersScenes() = 0;
virtual bool IsPauseMenuDisplayed(int iPad) = 0;
virtual bool IsContainerMenuDisplayed(int iPad) = 0;
virtual bool IsIgnorePlayerJoinMenuDisplayed(int iPad) = 0;
virtual bool IsIgnoreAutosaveMenuDisplayed(int iPad) = 0;
virtual void SetIgnoreAutosaveMenuDisplayed(int iPad, bool displayed) = 0;
virtual bool IsSceneInStack(int iPad, EUIScene eScene) = 0;
virtual bool GetMenuDisplayed(int iPad) = 0;
virtual void CheckMenuDisplayed() = 0;
virtual void SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ) = 0;
virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal ) = 0;
virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) = 0;
virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, int iRS=-1, int iBack=-1, bool forceUpdate = false) = 0;
virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ) = 0;
virtual void RefreshTooltips(unsigned int iPad) = 0;
virtual void PlayUISFX(ESoundEffect eSound) = 0;
virtual void ShowUIDebugConsole(bool show) {}
virtual void ShowUIDebugMarketingGuide(bool show) {}
virtual void DisplayGamertag(unsigned int iPad, bool show) = 0;
virtual void SetSelectedItem(unsigned int iPad, const wstring &name) = 0;
virtual void UpdateSelectedItemPos(unsigned int iPad) = 0;
virtual void HandleDLCMountingComplete() = 0;
virtual void HandleDLCInstalled(int iPad) = 0;
#ifdef _XBOX_ONE
virtual void HandleDLCLicenseChange() = 0;
#endif
virtual void HandleTMSDLCFileRetrieved(int iPad) = 0;
virtual void HandleTMSBanFileRetrieved(int iPad) = 0;
virtual void HandleInventoryUpdated(int iPad) = 0;
virtual void HandleGameTick() = 0;
virtual void SetTutorialDescription(int iPad, TutorialPopupInfo *info) = 0;
virtual void SetTutorialVisible(int iPad, bool visible) = 0;
virtual bool IsTutorialVisible(int iPad) = 0;
virtual void UpdatePlayerBasePositions() = 0;
virtual void SetEmptyQuadrantLogo(int iSection) = 0;
virtual void HideAllGameUIElements() = 0;
virtual void ShowOtherPlayersBaseScene(unsigned int iPad, bool show) = 0;
virtual void ShowTrialTimer(bool show) = 0;
virtual void SetTrialTimerLimitSecs(unsigned int uiSeconds) = 0;
virtual void UpdateTrialTimer(unsigned int iPad) = 0;
virtual void ReduceTrialTimerValue() = 0;
virtual void ShowAutosaveCountdownTimer(bool show) = 0;
virtual void UpdateAutosaveCountdownTimer(unsigned int uiSeconds) = 0;
virtual void ShowSavingMessage(unsigned int iPad, C4JStorage::ESavingMessage eVal) = 0;
virtual bool PressStartPlaying(unsigned int iPad) = 0;
virtual void ShowPressStart(unsigned int iPad) = 0;
virtual void SetWinUserIndex(unsigned int iPad) = 0;
};
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,267 @@
#pragma once
// Uncomment to enable tap input detection to jump 1 slot. Doesn't work particularly well yet, and I feel the system does not need it.
// Would probably be required if we decide to slow down the pointer movement.
// 4J Stu - There was a request to be able to navigate the scenes with the dpad, so I have used much of the TAP_DETECTION
// code as it worked well for that situation. This #define should still stop the same things happening when using the
// stick though when not defined
#define TAP_DETECTION
// Uncomment to enable acceleration on pointer input.
//#define USE_POINTER_ACCEL
#define POINTER_INPUT_TIMER_ID (0) // Arbitrary timer ID.
#define POINTER_SPEED_FACTOR (13.0f) // Speed of pointer.
//#define POINTER_PANEL_OVER_REACH (42.0f) // Amount beyond edge of panel which pointer can go over to drop items. - comes from the pointer size in the scene
#define MAX_INPUT_TICKS_FOR_SCALING (7)
#define MAX_INPUT_TICKS_FOR_TAPPING (15)
class AbstractContainerMenu;
class Slot;
class IUIScene_AbstractContainerMenu
{
protected:
// Sections of this scene containing items selectable by the pointer.
// 4J Stu - Always make the Using section the first one
enum ESceneSection
{
eSectionNone = -1,
eSectionContainerUsing = 0,
eSectionContainerInventory,
eSectionContainerChest,
eSectionContainerMax,
eSectionFurnaceUsing,
eSectionFurnaceInventory,
eSectionFurnaceIngredient,
eSectionFurnaceFuel,
eSectionFurnaceResult,
eSectionFurnaceMax,
eSectionInventoryUsing,
eSectionInventoryInventory,
eSectionInventoryArmor,
eSectionInventoryMax,
eSectionTrapUsing,
eSectionTrapInventory,
eSectionTrapTrap,
eSectionTrapMax,
eSectionInventoryCreativeUsing,
eSectionInventoryCreativeSelector,
eSectionInventoryCreativeTab_0,
eSectionInventoryCreativeTab_1,
eSectionInventoryCreativeTab_2,
eSectionInventoryCreativeTab_3,
eSectionInventoryCreativeTab_4,
eSectionInventoryCreativeTab_5,
eSectionInventoryCreativeTab_6,
eSectionInventoryCreativeTab_7,
eSectionInventoryCreativeSlider,
eSectionInventoryCreativeMax,
eSectionEnchantUsing,
eSectionEnchantInventory,
eSectionEnchantSlot,
eSectionEnchantButton1,
eSectionEnchantButton2,
eSectionEnchantButton3,
eSectionEnchantMax,
eSectionBrewingUsing,
eSectionBrewingInventory,
eSectionBrewingBottle1,
eSectionBrewingBottle2,
eSectionBrewingBottle3,
eSectionBrewingIngredient,
eSectionBrewingMax,
eSectionAnvilUsing,
eSectionAnvilInventory,
eSectionAnvilItem1,
eSectionAnvilItem2,
eSectionAnvilResult,
eSectionAnvilName,
eSectionAnvilMax,
eSectionBeaconUsing,
eSectionBeaconInventory,
eSectionBeaconItem,
eSectionBeaconPrimaryTierOneOne,
eSectionBeaconPrimaryTierOneTwo,
eSectionBeaconPrimaryTierTwoOne,
eSectionBeaconPrimaryTierTwoTwo,
eSectionBeaconPrimaryTierThree,
eSectionBeaconSecondaryOne,
eSectionBeaconSecondaryTwo,
eSectionBeaconConfirm,
eSectionBeaconMax,
eSectionHopperUsing,
eSectionHopperInventory,
eSectionHopperContents,
eSectionHopperMax,
eSectionHorseUsing,
eSectionHorseInventory,
eSectionHorseChest,
eSectionHorseArmor,
eSectionHorseSaddle,
eSectionHorseMax,
eSectionFireworksUsing,
eSectionFireworksInventory,
eSectionFireworksResult,
eSectionFireworksIngredients,
eSectionFireworksMax,
};
AbstractContainerMenu* m_menu;
bool m_autoDeleteMenu;
eTutorial_State m_previousTutorialState;
UIVec2D m_pointerPos;
// Offset from pointer image top left to centre (we use the centre as the actual pointer).
float m_fPointerImageOffsetX;
float m_fPointerImageOffsetY;
// Min and max extents for the pointer.
float m_fPointerMinX;
float m_fPointerMaxX;
float m_fPointerMinY;
float m_fPointerMaxY;
// Min and max extents of the panel.
float m_fPanelMinX;
float m_fPanelMaxX;
float m_fPanelMinY;
float m_fPanelMaxY;
int m_iConsectiveInputTicks;
// Used for detecting quick "taps" in a direction, should jump cursor to next slot.
enum ETapState
{
eTapStateNoInput = 0,
eTapStateUp,
eTapStateDown,
eTapStateLeft,
eTapStateRight,
eTapStateJump,
eTapNone
};
ETapState m_eCurrTapState;
ESceneSection m_eCurrSection;
int m_iCurrSlotX;
int m_iCurrSlotY;
#ifdef __ORBIS__
bool m_bFirstTouchStored[XUSER_MAX_COUNT]; // monitor the first position of a touch, so we can use relative distances of movement
UIVec2D m_oldvPointerPos;
UIVec2D m_oldvTouchPos;
// store the multipliers to map the UI window to the touchpad window
float m_fTouchPadMulX;
float m_fTouchPadMulY;
float m_fTouchPadDeadZoneX; // usese the multipliers
float m_fTouchPadDeadZoneY;
#endif
// ENum indexes of the first section for this scene, and 1+the last section
ESceneSection m_eFirstSection, m_eMaxSection;
// 4J - WESTY - Added for pointer prototype.
// Current tooltip settings.
EToolTipItem m_aeToolTipSettings[ eToolTipNumButtons ];
// 4J - WESTY - Added for pointer prototype.
// Indicates if pointer is outside UI window (used to drop items).
bool m_bPointerOutsideMenu;
Slot *m_lastPointerLabelSlot;
bool m_bSplitscreen;
bool m_bNavigateBack; // should we exit the xuiscenes or just navigate back on exit?
virtual bool IsSectionSlotList( ESceneSection eSection ) { return eSection != eSectionNone; }
virtual bool CanHaveFocus( ESceneSection eSection ) { return true; }
virtual bool IsVisible( ESceneSection eSection ) { return true; }
int GetSectionDimensions( ESceneSection eSection, int* piNumColumns, int* piNumRows );
virtual int getSectionColumns(ESceneSection eSection) = 0;
virtual int getSectionRows(ESceneSection eSection) = 0;
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY ) = 0;
virtual void GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) = 0;
virtual void GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) = 0;
void updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int *piTargetX, int *piTargetY, int xOffset = 0, int yOffset = 0 );
#ifdef TAP_DETECTION
ETapState GetTapInputType( float fInputX, float fInputY );
#endif
// Current tooltip settings.
void SetToolTip( EToolTipButton eButton, EToolTipItem eItem );
void UpdateTooltips();
// 4J - WESTY - Added for pointer prototype.
void SetPointerOutsideMenu( bool bOutside ) { m_bPointerOutsideMenu = bOutside; }
void Initialize(int m_iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack=FALSE);
virtual void PlatformInitialize(int iPad, int startIndex) = 0;
virtual void InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex = 0) = 0;
void onMouseTick();
bool handleKeyDown(int iPad, int iAction, bool bRepeat);
virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld);
virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld);
virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey);
virtual void handleAdditionalKeyPress(int iAction);
virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld);
virtual void handleSectionClick(ESceneSection eSection) = 0;
void slotClicked(int slotId, int buttonNum, bool quickKey);
int getCurrentIndex(ESceneSection eSection);
virtual int getSectionStartOffset(ESceneSection eSection) = 0;
virtual bool doesSectionTreeHaveFocus(ESceneSection eSection) = 0;
virtual void setSectionFocus(ESceneSection eSection, int iPad) = 0;
virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y) = 0;
virtual void setFocusToPointer(int iPad) = 0;
virtual void SetPointerText(vector<HtmlString> *description, bool newSlot) = 0;
virtual vector<HtmlString> *GetSectionHoverText(ESceneSection eSection);
virtual shared_ptr<ItemInstance> getSlotItem(ESceneSection eSection, int iSlot) = 0;
virtual Slot *getSlot(ESceneSection eSection, int iSlot) = 0;
virtual bool isSlotEmpty(ESceneSection eSection, int iSlot) = 0;
virtual void adjustPointerForSafeZone() = 0;
virtual bool overrideTooltips(
ESceneSection sectionUnderPointer,
shared_ptr<ItemInstance> itemUnderPointer,
bool bIsItemCarried,
bool bSlotHasItem,
bool bCarriedIsSameAsSlot,
int iSlotStackSizeRemaining,
EToolTipItem &buttonA,
EToolTipItem &buttonX,
EToolTipItem &buttonY,
EToolTipItem &buttonRT,
EToolTipItem &buttonBack
) { return false; }
private:
bool IsSameItemAs(shared_ptr<ItemInstance> itemA, shared_ptr<ItemInstance> itemB);
int GetEmptyStackSpace(Slot *slot);
vector<HtmlString> *GetItemDescription(Slot *slot);
protected:
IUIScene_AbstractContainerMenu();
virtual ~IUIScene_AbstractContainerMenu();
public:
virtual int getPad() = 0;
};
@@ -0,0 +1,272 @@
#include "stdafx.h"
#include "IUIScene_AnvilMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\InputOutputStream.h"
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\ClientConnection.h"
IUIScene_AnvilMenu::IUIScene_AnvilMenu()
{
m_inventory = nullptr;
m_repairMenu = NULL;
m_itemName = L"";
}
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_AnvilMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionAnvilItem1:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionAnvilName;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionAnvilInventory;
xOffset = ANVIL_SCENE_ITEM1_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionAnvilResult;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionAnvilItem2;
}
break;
case eSectionAnvilItem2:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionAnvilName;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionAnvilInventory;
xOffset = ANVIL_SCENE_ITEM2_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionAnvilItem1;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionAnvilResult;
}
break;
case eSectionAnvilResult:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionAnvilName;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionAnvilInventory;
xOffset = ANVIL_SCENE_RESULT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionAnvilItem2;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionAnvilItem1;
}
break;
case eSectionAnvilName:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionAnvilUsing;
xOffset = ANVIL_SCENE_ITEM2_SLOT_UP_OFFSET;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionAnvilItem2;
}
break;
case eSectionAnvilInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionAnvilUsing;
}
else if(eTapDirection == eTapStateUp)
{
if( *piTargetX <= ANVIL_SCENE_ITEM1_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilItem1;
}
else if( *piTargetX <= ANVIL_SCENE_ITEM2_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilItem2;
}
else if( *piTargetX >= ANVIL_SCENE_RESULT_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilResult;
}
}
break;
case eSectionAnvilUsing:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionAnvilInventory;
}
else if(eTapDirection == eTapStateDown)
{
if( *piTargetX <= ANVIL_SCENE_ITEM1_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilItem1;
}
else if( *piTargetX <= ANVIL_SCENE_ITEM2_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilName;
}
else if( *piTargetX >= ANVIL_SCENE_RESULT_SLOT_UP_OFFSET)
{
newSection = eSectionAnvilName;
}
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_AnvilMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionAnvilItem1:
offset = MerchantMenu::PAYMENT1_SLOT;
break;
case eSectionAnvilItem2:
offset = MerchantMenu::PAYMENT2_SLOT;
break;
case eSectionAnvilResult:
offset = MerchantMenu::RESULT_SLOT;
break;
case eSectionAnvilInventory:
offset = MerchantMenu::INV_SLOT_START;
break;
case eSectionAnvilUsing:
offset = MerchantMenu::USE_ROW_SLOT_START;
break;
default:
assert( false );
break;
}
return offset;
}
void IUIScene_AnvilMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey)
{
switch(eSection)
{
case eSectionAnvilName:
handleEditNamePressed();
break;
};
}
bool IUIScene_AnvilMenu::IsSectionSlotList( ESceneSection eSection )
{
switch( eSection )
{
case eSectionAnvilUsing:
case eSectionAnvilInventory:
case eSectionAnvilItem1:
case eSectionAnvilItem2:
case eSectionAnvilResult:
return true;
}
return false;
}
void IUIScene_AnvilMenu::handleTick()
{
Minecraft *pMinecraft = Minecraft::GetInstance();
bool canAfford = true;
wstring m_costString = L"";
if(m_repairMenu->cost > 0)
{
if(m_repairMenu->cost >= 40 && !pMinecraft->localplayers[getPad()]->abilities.instabuild)
{
m_costString = app.GetString(IDS_REPAIR_EXPENSIVE);
canAfford = false;
}
else if(!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->hasItem())
{
// Do nothing
}
else
{
LPCWSTR costString = app.GetString(IDS_REPAIR_COST);
wchar_t temp[256];
swprintf(temp, 256, costString, m_repairMenu->cost);
m_costString = temp;
if(!m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->mayPickup(dynamic_pointer_cast<Player>(m_inventory->player->shared_from_this())))
{
canAfford = false;
}
}
}
setCostLabel(m_costString, canAfford);
bool crossVisible = (m_repairMenu->getSlot(AnvilMenu::INPUT_SLOT)->hasItem() || m_repairMenu->getSlot(AnvilMenu::ADDITIONAL_SLOT)->hasItem()) && !m_repairMenu->getSlot(AnvilMenu::RESULT_SLOT)->hasItem();
showCross(crossVisible);
}
void IUIScene_AnvilMenu::updateItemName()
{
Slot *slot = m_repairMenu->getSlot(AnvilMenu::INPUT_SLOT);
if (slot != NULL && slot->hasItem())
{
if (!slot->getItem()->hasCustomHoverName() && m_itemName.compare(slot->getItem()->getHoverName())==0)
{
m_itemName = L"";
}
}
m_repairMenu->setItemName(m_itemName);
// Convert to byteArray
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
dos.writeUTF(m_itemName);
Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr<CustomPayloadPacket>(new CustomPayloadPacket(CustomPayloadPacket::SET_ITEM_NAME_PACKET, baos.toByteArray())));
}
void IUIScene_AnvilMenu::refreshContainer(AbstractContainerMenu *container, vector<shared_ptr<ItemInstance> > *items)
{
slotChanged(container, AnvilMenu::INPUT_SLOT, container->getSlot(0)->getItem());
}
void IUIScene_AnvilMenu::slotChanged(AbstractContainerMenu *container, int slotIndex, shared_ptr<ItemInstance> item)
{
if (slotIndex == AnvilMenu::INPUT_SLOT)
{
m_itemName = item == NULL ? L"" : item->getHoverName();
setEditNameValue(m_itemName);
setEditNameEditable(item != NULL);
if (item != NULL)
{
updateItemName();
}
}
}
void IUIScene_AnvilMenu::setContainerData(AbstractContainerMenu *container, int id, int value)
{
}
@@ -0,0 +1,45 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.ContainerListener.h"
// The 0-indexed slot in the inventory list that lines up with the result slot
#define ANVIL_SCENE_RESULT_SLOT_UP_OFFSET 5
#define ANVIL_SCENE_RESULT_SLOT_DOWN_OFFSET 5
#define ANVIL_SCENE_ITEM1_SLOT_UP_OFFSET 3
#define ANVIL_SCENE_ITEM1_SLOT_DOWN_OFFSET 3
#define ANVIL_SCENE_ITEM2_SLOT_UP_OFFSET 4
#define ANVIL_SCENE_ITEM2_SLOT_DOWN_OFFSET 4
class Inventory;
class AnvilMenu;
class IUIScene_AnvilMenu : public virtual IUIScene_AbstractContainerMenu, public net_minecraft_world_inventory::ContainerListener
{
protected:
shared_ptr<Inventory> m_inventory;
AnvilMenu *m_repairMenu;
wstring m_itemName;
protected:
IUIScene_AnvilMenu();
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey);
bool IsSectionSlotList( ESceneSection eSection );
void handleTick();
// Anvil only
virtual void handleEditNamePressed() = 0;
virtual void setEditNameValue(const wstring &name) = 0;
virtual void setEditNameEditable(bool enabled) = 0;
virtual void setCostLabel(const wstring &label, bool canAfford) = 0;
virtual void showCross(bool show) = 0;
void updateItemName();
// ContainerListenr
void refreshContainer(AbstractContainerMenu *container, vector<shared_ptr<ItemInstance> > *items);
void slotChanged(AbstractContainerMenu *container, int slotIndex, shared_ptr<ItemInstance> item);
void setContainerData(AbstractContainerMenu *container, int id, int value);
};
@@ -0,0 +1,410 @@
#include "stdafx.h"
#include "..\Minecraft.World\CustomPayloadPacket.h"
#include "..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\Minecraft.World\net.minecraft.world.effect.h"
#include "..\Minecraft.World\HtmlString.h"
#include "IUIScene_BeaconMenu.h"
#include "Minecraft.h"
#include "MultiPlayerLocalPlayer.h"
#include "ClientConnection.h"
IUIScene_BeaconMenu::IUIScene_BeaconMenu()
{
m_beacon = nullptr;
m_initPowerButtons = true;
}
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_BeaconMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionBeaconInventory:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconUsing;
else if(eTapDirection == eTapStateUp)
{
if( *piTargetX < 4 )
{
newSection = eSectionBeaconPrimaryTierThree;
}
else if ( *piTargetX < 7)
{
newSection = eSectionBeaconItem;
}
else
{
newSection = eSectionBeaconConfirm;
}
}
break;
case eSectionBeaconUsing:
if(eTapDirection == eTapStateDown)
{
if( *piTargetX < 2)
{
newSection = eSectionBeaconPrimaryTierOneOne;
}
else if( *piTargetX < 5)
{
newSection = eSectionBeaconPrimaryTierOneTwo;
}
else if( *piTargetX > 8 && GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0)
{
newSection = eSectionBeaconSecondaryTwo;
}
else
{
newSection = eSectionBeaconSecondaryOne;
}
}
else if(eTapDirection == eTapStateUp) newSection = eSectionBeaconInventory;
break;
case eSectionBeaconItem:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionBeaconInventory;
xOffset = -5;
}
else if(eTapDirection == eTapStateUp) newSection = eSectionBeaconSecondaryOne;
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconConfirm;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconConfirm;
break;
case eSectionBeaconPrimaryTierOneOne:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconPrimaryTierTwoOne;
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionBeaconUsing;
xOffset = -1;
}
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconPrimaryTierOneTwo;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconPrimaryTierOneTwo;
break;
case eSectionBeaconPrimaryTierOneTwo:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconPrimaryTierTwoTwo;
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionBeaconUsing;
xOffset = -3;
}
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconPrimaryTierOneOne;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconPrimaryTierOneOne;
break;
case eSectionBeaconPrimaryTierTwoOne:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconPrimaryTierThree;
else if(eTapDirection == eTapStateUp) newSection = eSectionBeaconPrimaryTierOneOne;
else if(eTapDirection == eTapStateLeft)
{
if(GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0)
{
newSection = eSectionBeaconSecondaryTwo;
}
else
{
newSection = eSectionBeaconSecondaryOne;
}
}
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconPrimaryTierTwoTwo;
break;
case eSectionBeaconPrimaryTierTwoTwo:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconPrimaryTierThree;
else if(eTapDirection == eTapStateUp) newSection = eSectionBeaconPrimaryTierOneTwo;
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconPrimaryTierTwoOne;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconSecondaryOne;
break;
case eSectionBeaconPrimaryTierThree:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionBeaconInventory;
xOffset = -3;
}
else if(eTapDirection == eTapStateUp) newSection = eSectionBeaconPrimaryTierTwoOne;
break;
case eSectionBeaconSecondaryOne:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconItem;
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionBeaconUsing;
xOffset = -7;
}
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconPrimaryTierTwoTwo;
else if(eTapDirection == eTapStateRight)
{
if(GetPowerButtonId(eSectionBeaconSecondaryTwo) > 0)
{
newSection = eSectionBeaconSecondaryTwo;
}
else
{
newSection = eSectionBeaconPrimaryTierTwoOne;
}
}
break;
case eSectionBeaconSecondaryTwo:
if(eTapDirection == eTapStateDown) newSection = eSectionBeaconItem;
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionBeaconUsing;
xOffset = -8;
}
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconSecondaryOne;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconPrimaryTierTwoOne;
break;
case eSectionBeaconConfirm:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionBeaconInventory;
xOffset = -8;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionBeaconSecondaryOne;
}
else if(eTapDirection == eTapStateLeft) newSection = eSectionBeaconItem;
else if(eTapDirection == eTapStateRight) newSection = eSectionBeaconItem;
break;
default:
assert(false);
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_BeaconMenu::getSectionStartOffset(IUIScene_AbstractContainerMenu::ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionBeaconItem:
offset = BeaconMenu::PAYMENT_SLOT;
break;
case eSectionBeaconInventory:
offset = BeaconMenu::INV_SLOT_START;
break;
case eSectionBeaconUsing:
offset = BeaconMenu::USE_ROW_SLOT_START;
break;
default:
assert( false );
break;
}
return offset;
}
bool IUIScene_BeaconMenu::IsSectionSlotList( ESceneSection eSection )
{
switch( eSection )
{
case eSectionBeaconItem:
case eSectionBeaconInventory:
case eSectionBeaconUsing:
return true;
}
return false;
}
void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey)
{
switch(eSection)
{
case eSectionBeaconConfirm:
{
if( (m_beacon->getItem(0) == NULL) || (m_beacon->getPrimaryPower() <= 0) ) return;
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
dos.writeInt(m_beacon->getPrimaryPower());
dos.writeInt(m_beacon->getSecondaryPower());
Minecraft::GetInstance()->localplayers[getPad()]->connection->send(shared_ptr<CustomPayloadPacket>(new CustomPayloadPacket(CustomPayloadPacket::SET_BEACON_PACKET, baos.toByteArray())));
if (m_beacon->getPrimaryPower() > 0)
{
int effectId = m_beacon->getPrimaryPower();
bool active = true;
bool selected = false;
int tier = 3;
if (tier >= m_beacon->getLevels())
{
active = false;
}
else if (effectId == m_beacon->getSecondaryPower())
{
selected = true;
}
AddPowerButton(GetId(tier, m_beacon->getPrimaryPower()), MobEffect::effects[m_beacon->getPrimaryPower()]->getIcon(), tier, 1, active, selected);
}
}
break;
case eSectionBeaconPrimaryTierOneOne:
case eSectionBeaconPrimaryTierOneTwo:
case eSectionBeaconPrimaryTierTwoOne:
case eSectionBeaconPrimaryTierTwoTwo:
case eSectionBeaconPrimaryTierThree:
case eSectionBeaconSecondaryOne:
case eSectionBeaconSecondaryTwo:
if(IsPowerButtonSelected(eSection))
{
return;
}
int id = GetPowerButtonId(eSection);
int effectId = (id & 0xff);
int tier = (id >> 8);
if (tier < 3)
{
m_beacon->setPrimaryPower(effectId);
}
else
{
m_beacon->setSecondaryPower(effectId);
}
SetPowerButtonSelected(eSection);
break;
};
}
void IUIScene_BeaconMenu::handleTick()
{
if (m_initPowerButtons && m_beacon->getLevels() >= 0)
{
m_initPowerButtons = false;
for (int tier = 0; tier <= 2; tier++)
{
int count = BeaconTileEntity::BEACON_EFFECTS_EFFECTS;//BEACON_EFFECTS[tier].length;
int totalWidth = count * 22 + (count - 1) * 2;
for (int c = 0; c < count; c++)
{
if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue;
int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id;
int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon();
bool active = true;
bool selected = false;
if (tier >= m_beacon->getLevels())
{
active = false;
}
else if (effectId == m_beacon->getPrimaryPower())
{
selected = true;
}
AddPowerButton(GetId(tier, effectId), icon, tier, c, active, selected);
}
}
{
int tier = 3;
int count = BeaconTileEntity::BEACON_EFFECTS_EFFECTS + 1;//BEACON_EFFECTS[tier].length + 1;
int totalWidth = count * 22 + (count - 1) * 2;
for (int c = 0; c < count - 1; c++)
{
if(BeaconTileEntity::BEACON_EFFECTS[tier][c] == NULL) continue;
int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id;
int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon();
bool active = true;
bool selected = false;
if (tier >= m_beacon->getLevels())
{
active = false;
}
else if (effectId == m_beacon->getSecondaryPower())
{
selected = true;
}
AddPowerButton(GetId(tier, effectId), icon, tier, c, active, selected);
}
if (m_beacon->getPrimaryPower() > 0)
{
int effectId = m_beacon->getPrimaryPower();
bool active = true;
bool selected = false;
if (tier >= m_beacon->getLevels())
{
active = false;
}
else if (effectId == m_beacon->getSecondaryPower())
{
selected = true;
}
AddPowerButton(GetId(tier, m_beacon->getPrimaryPower()), MobEffect::effects[m_beacon->getPrimaryPower()]->getIcon(), tier, 1, active, selected);
}
}
}
SetConfirmButtonEnabled( (m_beacon->getItem(0) != NULL) && (m_beacon->getPrimaryPower() > 0) );
}
int IUIScene_BeaconMenu::GetId(int tier, int effectId)
{
return (tier << 8) | effectId;
}
vector<HtmlString> *IUIScene_BeaconMenu::GetSectionHoverText(ESceneSection eSection)
{
vector<HtmlString> *desc = NULL;
switch(eSection)
{
case eSectionBeaconSecondaryTwo:
if(GetPowerButtonId(eSectionBeaconSecondaryTwo) == 0)
{
// This isn't visible
break;
}
// Fall through otherwise
case eSectionBeaconPrimaryTierOneOne:
case eSectionBeaconPrimaryTierOneTwo:
case eSectionBeaconPrimaryTierTwoOne:
case eSectionBeaconPrimaryTierTwoTwo:
case eSectionBeaconPrimaryTierThree:
case eSectionBeaconSecondaryOne:
{
int id = GetPowerButtonId(eSection);
int effectId = (id & 0xff);
desc = new vector<HtmlString>();
HtmlString string( app.GetString(MobEffect::effects[effectId]->getDescriptionId()), eHTMLColor_White );
desc->push_back( string );
}
break;
}
return desc;
}
bool IUIScene_BeaconMenu::IsVisible( ESceneSection eSection )
{
switch( eSection )
{
case eSectionBeaconSecondaryTwo:
if(GetPowerButtonId(eSectionBeaconSecondaryTwo) == 0)
{
// This isn't visible
return false;
}
}
return true;
}
@@ -0,0 +1,31 @@
#pragma once
#include "Common\UI\IUIScene_AbstractContainerMenu.h"
class BeaconTileEntity;
class IUIScene_BeaconMenu : public virtual IUIScene_AbstractContainerMenu
{
public:
IUIScene_BeaconMenu();
virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY);
int getSectionStartOffset(ESceneSection eSection);
virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey);
virtual bool IsSectionSlotList( ESceneSection eSection );
virtual vector<HtmlString> *GetSectionHoverText(ESceneSection eSection);
bool IsVisible( ESceneSection eSection );
protected:
void handleTick();
int GetId(int tier, int effectId);
virtual void SetConfirmButtonEnabled(bool enabled) = 0;
virtual void AddPowerButton(int id, int icon, int tier, int count, bool active, bool selected) = 0;
virtual int GetPowerButtonId(ESceneSection eSection) = 0;
virtual bool IsPowerButtonSelected(ESceneSection eSection) = 0;
virtual void SetPowerButtonSelected(ESceneSection eSection) = 0;
shared_ptr<BeaconTileEntity> m_beacon;
bool m_initPowerButtons;
};
@@ -0,0 +1,151 @@
#include "stdafx.h"
#include "IUIScene_BrewingMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_BrewingMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionBrewingBottle1:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionBrewingIngredient;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingInventory;
xOffset = BREWING_SCENE_BOTTLE1_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionBrewingBottle3;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionBrewingBottle2;
}
break;
case eSectionBrewingBottle2:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionBrewingIngredient;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingInventory;
xOffset = BREWING_SCENE_BOTTLE2_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionBrewingBottle1;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionBrewingBottle3;
}
break;
case eSectionBrewingBottle3:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionBrewingIngredient;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingInventory;
xOffset = BREWING_SCENE_BOTTLE3_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionBrewingBottle2;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionBrewingBottle1;
}
break;
case eSectionBrewingIngredient:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionBrewingUsing;
xOffset = BREWING_SCENE_INGREDIENT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingBottle2;
}
break;
case eSectionBrewingInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingUsing;
}
else if(eTapDirection == eTapStateUp)
{
if( *piTargetX <= BREWING_SCENE_BOTTLE1_SLOT_UP_OFFSET)
{
newSection = eSectionBrewingBottle1;
}
else if( *piTargetX <= BREWING_SCENE_BOTTLE2_SLOT_UP_OFFSET)
{
newSection = eSectionBrewingBottle2;
}
else if( *piTargetX >= BREWING_SCENE_BOTTLE3_SLOT_UP_OFFSET)
{
newSection = eSectionBrewingBottle3;
}
}
break;
case eSectionBrewingUsing:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionBrewingInventory;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionBrewingIngredient;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_BrewingMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionBrewingBottle1:
offset = BrewingStandMenu::BOTTLE_SLOT_START;
break;
case eSectionBrewingBottle2:
offset = BrewingStandMenu::BOTTLE_SLOT_START + 1;
break;
case eSectionBrewingBottle3:
offset = BrewingStandMenu::BOTTLE_SLOT_START + 2;
break;
case eSectionBrewingIngredient:
offset = BrewingStandMenu::INGREDIENT_SLOT;
break;
case eSectionBrewingInventory:
offset = BrewingStandMenu::INV_SLOT_START;
break;
case eSectionBrewingUsing:
offset = BrewingStandMenu::INV_SLOT_START + 27;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,19 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
// The 0-indexed slot in the inventory list that lines up with the result slot
#define BREWING_SCENE_INGREDIENT_SLOT_UP_OFFSET 5
#define BREWING_SCENE_INGREDIENT_SLOT_DOWN_OFFSET 5
#define BREWING_SCENE_BOTTLE1_SLOT_UP_OFFSET 3
#define BREWING_SCENE_BOTTLE1_SLOT_DOWN_OFFSET 3
#define BREWING_SCENE_BOTTLE2_SLOT_UP_OFFSET 4
#define BREWING_SCENE_BOTTLE2_SLOT_DOWN_OFFSET 4
#define BREWING_SCENE_BOTTLE3_SLOT_UP_OFFSET 5
#define BREWING_SCENE_BOTTLE3_SLOT_DOWN_OFFSET 5
class IUIScene_BrewingMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
@@ -0,0 +1,25 @@
#include "stdafx.h"
#include "../../../Minecraft.World/CustomPayloadPacket.h"
#include "MultiPlayerLocalPlayer.h"
#include "ClientConnection.h"
#include "IUIScene_CommandBlockMenu.h"
void IUIScene_CommandBlockMenu::Initialise(CommandBlockEntity *commandBlock)
{
m_commandBlock = commandBlock;
SetCommand(m_commandBlock->getCommand());
}
void IUIScene_CommandBlockMenu::ConfirmButtonClicked()
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
dos.writeInt(m_commandBlock->x);
dos.writeInt(m_commandBlock->y);
dos.writeInt(m_commandBlock->z);
dos.writeUTF(GetCommand());
Minecraft::GetInstance()->localplayers[GetPad()]->connection->send(shared_ptr<CustomPayloadPacket>(new CustomPayloadPacket(CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET, baos.toByteArray())));
}
@@ -0,0 +1,18 @@
#pragma once
#include "../Minecraft.World/net.minecraft.world.level.tile.entity.h"
class IUIScene_CommandBlockMenu
{
public:
void Initialise(CommandBlockEntity *commandBlock);
protected:
void ConfirmButtonClicked();
virtual wstring GetCommand();
virtual void SetCommand(wstring command);
virtual int GetPad();
private:
CommandBlockEntity *m_commandBlock;
};
@@ -0,0 +1,71 @@
#include "stdafx.h"
#include "IUIScene_ContainerMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_ContainerMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
// Find the new section if there is one
switch( eSection )
{
case eSectionContainerChest:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionContainerInventory;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionContainerUsing;
}
break;
case eSectionContainerInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionContainerUsing;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionContainerChest;
}
break;
case eSectionContainerUsing:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionContainerChest;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionContainerInventory;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, 0);
return newSection;
}
int IUIScene_ContainerMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionContainerChest:
offset = 0;
break;
case eSectionContainerInventory:
offset = m_menu->getSize() - (27+9);
break;
case eSectionContainerUsing:
offset = m_menu->getSize() - 9;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,10 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
class IUIScene_ContainerMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,120 @@
#pragma once
#include "..\..\..\Minecraft.World\Recipy.h"
#include "..\..\..\Minecraft.World\Item.h"
class LocalPlayer;
// 4J Stu - Crafting menu code that's shared across Iggy and XUI
class IUIScene_CraftingMenu
{
protected:
#define DISPLAY_INVENTORY 0
#define DISPLAY_DESCRIPTION 1
#define DISPLAY_INGREDIENTS 2
#define DISPLAY_MAX 3
enum _eGroupTab
{
eGroupTab_Left,
eGroupTab_Middle,
eGroupTab_Right
};
static const int m_iMaxHSlotC = 12;
static const int m_iMaxHCraftingSlotC = 10;
static const int m_iMaxVSlotC = 17;
static const int m_iMaxDisplayedVSlotC = 3;
static const int m_iIngredients3x3SlotC = 9;
static const int m_iIngredients2x2SlotC = 4;
static const int m_iMaxHSlot3x3C = 12;
static const int m_iMaxHSlot2x2C = 10;
static const int m_iMaxGroup3x3 = 7;
static const int m_iMaxGroup2x2 = 6;
static int m_iBaseTypeMapA[Item::eBaseItemType_MAXTYPES];
typedef struct
{
int iCount;
int iItemBaseType;
int iRecipeA[m_iMaxVSlotC]; // tiers of item that can be made
}
CANBEMADE;
CANBEMADE CanBeMadeA[m_iMaxHSlotC];
int m_iCurrentSlotHIndex;
int m_iCurrentSlotVIndex;
int m_iRecipeC;
int m_iContainerType; // 2x2 or 3x3
shared_ptr<LocalPlayer> m_pPlayer;
int m_iGroupIndex;
int iVSlotIndexA[3]; // index of the v slots currently displayed
static LPCWSTR m_GroupIconNameA[m_iMaxGroup3x3];
static Recipy::_eGroupType m_GroupTypeMapping4GridA[m_iMaxGroup2x2];
static Recipy::_eGroupType m_GroupTypeMapping9GridA[m_iMaxGroup3x3];
Recipy::_eGroupType *m_pGroupA;
static LPCWSTR m_GroupTabNameA[3];
static _eGroupTab m_GroupTabBkgMapping2x2A[m_iMaxGroup2x2];
static _eGroupTab m_GroupTabBkgMapping3x3A[m_iMaxGroup3x3];
_eGroupTab *m_pGroupTabA;
int m_iCraftablesMaxHSlotC;
int m_iIngredientsMaxSlotC;
int m_iDisplayDescription;
int m_iIngredientsC;
bool m_bIgnoreKeyPresses;
bool m_bSplitscreen;
eTutorial_State m_previousTutorialState;
bool handleKeyDown(int iPad, int iAction, bool bRepeat);
public:
IUIScene_CraftingMenu();
protected:
LPCWSTR GetGroupNameText(int iGroupType);
void CheckRecipesAvailable();
void UpdateHighlight();
void UpdateVerticalSlots();
void DisplayIngredients();
void UpdateTooltips();
void UpdateDescriptionText(bool);
void HandleInventoryUpdated();
public:
Recipy::_eGroupType getCurrentGroup() { return m_pGroupA[m_iGroupIndex]; }
bool isItemSelected(int itemId);
protected:
virtual int getPad() = 0;
virtual void hideAllHSlots() = 0;
virtual void hideAllVSlots() = 0;
virtual void hideAllIngredientsSlots() = 0;
virtual void setCraftHSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha) = 0;
virtual void setCraftVSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha) = 0;
virtual void setCraftingOutputSlotItem(int iPad, shared_ptr<ItemInstance> item) = 0;
virtual void setCraftingOutputSlotRedBox(bool show) = 0;
virtual void setIngredientSlotItem(int iPad, int index, shared_ptr<ItemInstance> item) = 0;
virtual void setIngredientSlotRedBox(int index, bool show) = 0;
virtual void setIngredientDescriptionItem(int iPad, int index, shared_ptr<ItemInstance> item) = 0;
virtual void setIngredientDescriptionRedBox(int index, bool show) = 0;
virtual void setIngredientDescriptionText(int index, LPCWSTR text) = 0;
virtual void setShowCraftHSlot(int iIndex, bool show) = 0;
virtual void showTabHighlight(int iIndex, bool show) = 0;
virtual void setGroupText(LPCWSTR text) = 0;
virtual void setDescriptionText(LPCWSTR text) = 0;
virtual void setItemText(LPCWSTR text) = 0;
virtual void scrollDescriptionUp() = 0;
virtual void scrollDescriptionDown() = 0;
virtual void updateHighlightAndScrollPositions() = 0;
virtual void updateVSlotPositions(int iSlots, int i) = 0;
virtual void UpdateMultiPanel() = 0;
};
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,141 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
#include "..\..\..\Minecraft.World\AbstractContainerMenu.h"
// 4J Stu - This class is for code that is common between XUI and Iggy
class SimpleContainer;
class IUIScene_CreativeMenu : public virtual IUIScene_AbstractContainerMenu
{
public:
// 4J Stu - These map directly to the tabs seenon the screen
enum ECreativeInventoryTabs
{
eCreativeInventoryTab_BuildingBlocks = 0,
eCreativeInventoryTab_Decorations,
eCreativeInventoryTab_RedstoneAndTransport,
eCreativeInventoryTab_Materials,
eCreativeInventoryTab_Food,
eCreativeInventoryTab_ToolsWeaponsArmor,
eCreativeInventoryTab_Brewing,
eCreativeInventoryTab_Misc,
eCreativeInventoryTab_COUNT,
};
// 4J Stu - These are logical groupings of items, and be be combined for tabs on-screen
enum ECreative_Inventory_Groups
{
eCreativeInventory_BuildingBlocks,
eCreativeInventory_Decoration,
eCreativeInventory_Redstone,
eCreativeInventory_Transport,
eCreativeInventory_Materials,
eCreativeInventory_Food,
eCreativeInventory_ToolsArmourWeapons,
eCreativeInventory_Brewing,
eCreativeInventory_Potions_Basic,
eCreativeInventory_Potions_Level2,
eCreativeInventory_Potions_Extended,
eCreativeInventory_Potions_Level2_Extended,
eCreativeInventory_Misc,
eCreativeInventory_ArtToolsDecorations,
eCreativeInventory_ArtToolsMisc,
eCreativeInventoryGroupsCount
};
// 4J JEV - Keeping all the tab specifications in one place.
struct TabSpec
{
public:
// 4J JEV - Layout
static const int rows = 5;
static const int columns = 10;
static const int MAX_SIZE = rows * columns;
// 4J JEV - Images
const LPCWSTR m_icon;
const int m_descriptionId;
const int m_staticGroupsCount;
ECreative_Inventory_Groups *m_staticGroupsA;
const int m_dynamicGroupsCount;
ECreative_Inventory_Groups *m_dynamicGroupsA;
const int m_debugGroupsCount;
ECreative_Inventory_Groups *m_debugGroupsA;
private:
unsigned int m_pages;
unsigned int m_staticPerPage;
unsigned int m_staticItems;
unsigned int m_debugItems;
public:
TabSpec( LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount = 0, ECreative_Inventory_Groups *dynamicGroups = NULL, int debugGroupsCount = 0, ECreative_Inventory_Groups *debugGroups = NULL );
~TabSpec();
void populateMenu(AbstractContainerMenu *menu, int dynamicIndex, unsigned int page);
unsigned int getPageCount();
};
class ItemPickerMenu : public AbstractContainerMenu
{
protected:
shared_ptr<SimpleContainer> creativeContainer;
shared_ptr<Inventory> inventory;
public:
ItemPickerMenu( shared_ptr<SimpleContainer> creativeContainer, shared_ptr<Inventory> inventory );
virtual bool stillValid(shared_ptr<Player> player);
bool isOverrideResultClick(int slotNum, int buttonNum);
protected:
// 4J Stu - Brought forward from 1.2 to fix infinite recursion bug in creative
virtual void loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player) { } // do nothing
} *itemPickerMenu;
protected:
static vector< shared_ptr<ItemInstance> > categoryGroups[eCreativeInventoryGroupsCount];
// 4J JEV - Tabs
static TabSpec **specs;
bool m_bCarryingCreativeItem;
int m_creativeSlotX, m_creativeSlotY, m_inventorySlotX, m_inventorySlotY;
public:
static void staticCtor();
IUIScene_CreativeMenu();
protected:
ECreativeInventoryTabs m_curTab;
int m_tabDynamicPos[eCreativeInventoryTab_COUNT];
int m_tabPage[eCreativeInventoryTab_COUNT];
void switchTab(ECreativeInventoryTabs tab);
void ScrollBar(UIVec2D pointerPos);
virtual void updateTabHighlightAndText(ECreativeInventoryTabs tab) = 0;
virtual void updateScrollCurrentPage(int currentPage, int pageCount) = 0;
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld);
virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld);
virtual void handleAdditionalKeyPress(int iAction);
virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld);
bool getEmptyInventorySlot(shared_ptr<ItemInstance> item, int &slotX);
int getSectionStartOffset(ESceneSection eSection);
virtual bool IsSectionSlotList( ESceneSection eSection );
virtual bool CanHaveFocus( ESceneSection eSection );
virtual bool overrideTooltips(
ESceneSection sectionUnderPointer,
shared_ptr<ItemInstance> itemUnderPointer,
bool bIsItemCarried,
bool bSlotHasItem,
bool bCarriedIsSameAsSlot,
int iSlotStackSizeRemaining,
EToolTipItem &buttonA,
EToolTipItem &buttonX,
EToolTipItem &buttonY,
EToolTipItem &buttonRT,
EToolTipItem &buttonBack
);
static void BuildFirework(vector<shared_ptr<ItemInstance> > *list, byte type, int color, int sulphur, bool flicker, bool trail, int fadeColor = -1);
};
@@ -0,0 +1,77 @@
#include "stdafx.h"
#include "IUIScene_DispenserMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_DispenserMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionTrapTrap:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionTrapInventory;
xOffset = -TRAP_SCENE_TRAP_SLOT_OFFSET;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionTrapUsing;
xOffset = -TRAP_SCENE_TRAP_SLOT_OFFSET;
}
break;
case eSectionTrapInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionTrapUsing;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionTrapTrap;
xOffset = TRAP_SCENE_TRAP_SLOT_OFFSET;
}
break;
case eSectionTrapUsing:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionTrapTrap;
xOffset = TRAP_SCENE_TRAP_SLOT_OFFSET;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionTrapInventory;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_DispenserMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionTrapTrap:
offset = 0;
break;
case eSectionTrapInventory:
offset = 9;
break;
case eSectionTrapUsing:
offset = 9 + 27;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,12 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
// The 0-indexed slot in the inventory list that lines up with the result slot
#define TRAP_SCENE_TRAP_SLOT_OFFSET 3
class IUIScene_DispenserMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
@@ -0,0 +1,185 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "IUIScene_EnchantingMenu.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_EnchantingMenu::GetSectionAndSlotInDirection( IUIScene_AbstractContainerMenu::ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
IUIScene_AbstractContainerMenu::ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionEnchantInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionEnchantUsing;
}
else if(eTapDirection == eTapStateUp)
{
if( *piTargetX >= ENCHANT_SCENE_ENCHANT_BUTTONS_UP_OFFSET)
{
newSection = eSectionEnchantButton3;
}
else
{
newSection = eSectionEnchantSlot;
}
}
break;
case eSectionEnchantUsing:
if(eTapDirection == eTapStateDown)
{
if( *piTargetX >= ENCHANT_SCENE_ENCHANT_BUTTONS_UP_OFFSET)
{
newSection = eSectionEnchantButton1;
}
else
{
newSection = eSectionEnchantSlot;
}
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionEnchantInventory;
}
break;
case eSectionEnchantSlot:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionEnchantInventory;
xOffset = ENCHANT_SCENE_INGREDIENT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionEnchantUsing;
xOffset = ENCHANT_SCENE_INGREDIENT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
{
newSection = eSectionEnchantButton1;
}
break;
case eSectionEnchantButton1:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionEnchantButton2;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionEnchantUsing;
xOffset = ENCHANT_SCENE_ENCHANT_BUTTONS_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
{
newSection = eSectionEnchantSlot;
}
break;
case eSectionEnchantButton2:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionEnchantButton3;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionEnchantButton1;
}
else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
{
newSection = eSectionEnchantSlot;
}
break;
case eSectionEnchantButton3:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionEnchantInventory;
xOffset = ENCHANT_SCENE_ENCHANT_BUTTONS_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionEnchantButton2;
}
else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
{
newSection = eSectionEnchantSlot;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
void IUIScene_EnchantingMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey)
{
int index = -1;
// Old xui code
#if 0
HXUIOBJ hFocusObject = GetFocus(iPad);
if(hFocusObject == m_enchant1->m_hObj) index = 0;
else if(hFocusObject == m_enchant2->m_hObj) index = 1;
else if(hFocusObject == m_enchant3->m_hObj) index = 2;
#endif
switch(eSection)
{
case eSectionEnchantButton1:
index = 0;
break;
case eSectionEnchantButton2:
index = 1;
break;
case eSectionEnchantButton3:
index = 2;
break;
};
Minecraft *pMinecraft = Minecraft::GetInstance();
if (index >= 0 && m_menu->clickMenuButton(dynamic_pointer_cast<Player>(pMinecraft->localplayers[iPad]), index))
{
pMinecraft->localgameModes[iPad]->handleInventoryButtonClick(m_menu->containerId, index);
}
}
int IUIScene_EnchantingMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionEnchantSlot:
offset = 0;
break;
case eSectionEnchantInventory:
offset = 1;
break;
case eSectionEnchantUsing:
offset = 1 + 27;
break;
default:
assert( false );
break;
};
return offset;
}
bool IUIScene_EnchantingMenu::IsSectionSlotList( ESceneSection eSection )
{
switch( eSection )
{
case eSectionEnchantInventory:
case eSectionEnchantUsing:
case eSectionEnchantSlot:
return true;
}
return false;
}
EnchantmentMenu *IUIScene_EnchantingMenu::getMenu()
{
return (EnchantmentMenu *)m_menu;
}
@@ -0,0 +1,23 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
// The 0-indexed slot in the inventory list that lines up with the result slot
#define ENCHANT_SCENE_ENCHANT_BUTTONS_UP_OFFSET 3
#define ENCHANT_SCENE_ENCHANT_BUTTONS_DOWN_OFFSET -7
#define ENCHANT_SCENE_INGREDIENT_SLOT_UP_OFFSET 0
#define ENCHANT_SCENE_INGREDIENT_SLOT_DOWN_OFFSET 0
class EnchantmentMenu;
class IUIScene_EnchantingMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey);
int getSectionStartOffset(ESceneSection eSection);
virtual bool IsSectionSlotList( ESceneSection eSection );
public:
EnchantmentMenu *getMenu();
};
@@ -0,0 +1,129 @@
#include "stdafx.h"
#include "IUIScene_FireworksMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_FireworksMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
int yOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionFireworksIngredients:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionFireworksInventory;
xOffset = -1;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionFireworksUsing;
xOffset = -1;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionFireworksResult;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionFireworksResult;
}
break;
case eSectionFireworksResult:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionFireworksInventory;
xOffset = -7;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionFireworksUsing;
xOffset = -7;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionFireworksIngredients;
yOffset = -1;
*piTargetX = getSectionColumns(eSectionFireworksIngredients);
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionFireworksIngredients;
yOffset = -1;
*piTargetX = 0;
}
break;
case eSectionFireworksInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionFireworksUsing;
}
else if(eTapDirection == eTapStateUp)
{
if(*piTargetX < 6)
{
newSection = eSectionFireworksIngredients;
xOffset = 1;
}
else
{
newSection = eSectionFireworksResult;
}
}
break;
case eSectionFireworksUsing:
if(eTapDirection == eTapStateDown)
{
if(*piTargetX < 6)
{
newSection = eSectionFireworksIngredients;
xOffset = 1;
}
else
{
newSection = eSectionFireworksResult;
}
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionFireworksInventory;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset, yOffset);
return newSection;
}
int IUIScene_FireworksMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionFireworksIngredients:
offset = FireworksMenu::CRAFT_SLOT_START;
break;
case eSectionFireworksResult:
offset = FireworksMenu::RESULT_SLOT;
break;
case eSectionFireworksInventory:
offset = FireworksMenu::INV_SLOT_START;
break;
case eSectionFireworksUsing:
offset = FireworksMenu::INV_SLOT_START + 27;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,9 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
class IUIScene_FireworksMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
@@ -0,0 +1,141 @@
#include "stdafx.h"
#include "IUIScene_FurnaceMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_FurnaceMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionFurnaceResult:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionFurnaceUsing;
xOffset = FURNACE_SCENE_RESULT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionFurnaceInventory;
xOffset = FURNACE_SCENE_RESULT_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionFurnaceIngredient;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionFurnaceIngredient;
}
break;
case eSectionFurnaceIngredient:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionFurnaceUsing;
xOffset = FURNACE_SCENE_FUEL_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateDown)
{
newSection = eSectionFurnaceFuel;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionFurnaceResult;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionFurnaceResult;
}
break;
case eSectionFurnaceFuel:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionFurnaceInventory;
xOffset = FURNACE_SCENE_FUEL_SLOT_DOWN_OFFSET;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionFurnaceIngredient;
}
else if(eTapDirection == eTapStateLeft)
{
newSection = eSectionFurnaceResult;
}
else if(eTapDirection == eTapStateRight)
{
newSection = eSectionFurnaceResult;
}
break;
case eSectionFurnaceInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionFurnaceUsing;
}
else if(eTapDirection == eTapStateUp)
{
if( *piTargetX >= FURNACE_SCENE_RESULT_SLOT_UP_OFFSET)
{
newSection = eSectionFurnaceResult;
}
else
{
newSection = eSectionFurnaceFuel;
}
}
break;
case eSectionFurnaceUsing:
if(eTapDirection == eTapStateUp)
{
newSection = eSectionFurnaceInventory;
}
else if(eTapDirection == eTapStateDown)
{
if( *piTargetX >= FURNACE_SCENE_RESULT_SLOT_UP_OFFSET)
{
newSection = eSectionFurnaceResult;
}
else
{
newSection = eSectionFurnaceIngredient;
}
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_FurnaceMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionFurnaceResult:
offset = FurnaceMenu::RESULT_SLOT;
break;
case eSectionFurnaceFuel:
offset = FurnaceMenu::FUEL_SLOT;
break;
case eSectionFurnaceIngredient:
offset = FurnaceMenu::INGREDIENT_SLOT;
break;
case eSectionFurnaceInventory:
offset = FurnaceMenu::INV_SLOT_START;
break;
case eSectionFurnaceUsing:
offset = FurnaceMenu::INV_SLOT_START + 27;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,15 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
// The 0-indexed slot in the inventory list that lines up with the result slot
#define FURNACE_SCENE_RESULT_SLOT_UP_OFFSET 6
#define FURNACE_SCENE_RESULT_SLOT_DOWN_OFFSET -7
#define FURNACE_SCENE_FUEL_SLOT_UP_OFFSET 0
#define FURNACE_SCENE_FUEL_SLOT_DOWN_OFFSET -3
class IUIScene_FurnaceMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
+264
View File
@@ -0,0 +1,264 @@
#include "stdafx.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.effect.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.ai.attributes.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.monster.h"
#include "IUIScene_HUD.h"
IUIScene_HUD::IUIScene_HUD()
{
m_lastActiveSlot = -1;
m_iGuiScale = -1;
m_bToolTipsVisible = true;
m_lastExpProgress = 0.0f;
m_lastExpLevel = 0;
m_iCurrentHealth = 0;
m_lastMaxHealth = 20;
m_lastHealthBlink = false;
m_lastHealthPoison = false;
m_iCurrentFood = -1;
m_lastFoodPoison = false;
m_lastAir = 10;
m_currentExtraAir = 0;
m_lastArmour = 0;
m_showHealth = true;
m_showHorseHealth = true;
m_showFood = true;
m_showAir = true;
m_showArmour = true;
m_showExpBar = true;
m_bRegenEffectEnabled = false;
m_iFoodSaturation = 0;
m_lastDragonHealth = 0.0f;
m_showDragonHealth = false;
m_ticksWithNoBoss = 0;
m_uiSelectedItemOpacityCountDown = 0;
m_displayName = L"";
m_lastShowDisplayName = true;
m_bRidingHorse = true;
m_horseHealth = 1;
m_lastHealthWither = true;
m_iCurrentHealthAbsorb = -1;
m_horseJumpProgress = 1.0f;
m_iHeartOffsetIndex = -1;
m_bHealthAbsorbActive = false;
m_iHorseMaxHealth = -1;
m_bIsJumpable = false;
}
void IUIScene_HUD::updateFrameTick()
{
int iPad = getPad();
Minecraft *pMinecraft = Minecraft::GetInstance();
int iGuiScale;
if(pMinecraft->localplayers[iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{
iGuiScale=app.GetGameSettings(iPad,eGameSetting_UISize);
}
else
{
iGuiScale=app.GetGameSettings(iPad,eGameSetting_UISizeSplitscreen);
}
SetHudSize(iGuiScale);
SetDisplayName(ProfileManager.GetDisplayName(iPad));
SetTooltipsEnabled(((ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) || (app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Tooltips) != 0)));
SetActiveSlot(pMinecraft->localplayers[iPad]->inventory->selected);
if (pMinecraft->localgameModes[iPad]->canHurtPlayer())
{
renderPlayerHealth();
}
else
{
//SetRidingHorse(false, 0);
shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
if(riding == NULL)
{
SetRidingHorse(false, false, 0);
}
else
{
SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), 0);
}
ShowHorseHealth(false);
m_horseHealth = 0;
ShowHealth(false);
ShowFood(false);
ShowAir(false);
ShowArmour(false);
ShowExpBar(false);
SetHealthAbsorb(0);
}
if(pMinecraft->localplayers[iPad]->isRidingJumpable())
{
SetHorseJumpBarProgress(pMinecraft->localplayers[iPad]->getJumpRidingScale());
}
else if (pMinecraft->localgameModes[iPad]->hasExperience())
{
// Update xp progress
ShowExpBar(true);
SetExpBarProgress(pMinecraft->localplayers[iPad]->experienceProgress, pMinecraft->localplayers[iPad]->getXpNeededForNextLevel());
// Update xp level
SetExpLevel(pMinecraft->localplayers[iPad]->experienceLevel);
}
else
{
ShowExpBar(false);
SetExpLevel(0);
}
if(m_uiSelectedItemOpacityCountDown>0)
{
--m_uiSelectedItemOpacityCountDown;
// 4J Stu - Timing here is kept the same as on Xbox360, even though we do it differently now and do the fade out in Flash rather than directly setting opacity
if(m_uiSelectedItemOpacityCountDown < (SharedConstants::TICKS_PER_SECOND * 1) )
{
HideSelectedLabel();
m_uiSelectedItemOpacityCountDown = 0;
}
}
unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity);
float fVal;
if(ucAlpha<80)
{
// if we are in a menu, set the minimum opacity for tooltips to 15%
if(ui.GetMenuDisplayed(iPad) && (ucAlpha<15))
{
ucAlpha=15;
}
// check if we have the timer running for the opacity
unsigned int uiOpacityTimer=app.GetOpacityTimer(iPad);
if(uiOpacityTimer!=0)
{
if(uiOpacityTimer<10)
{
float fStep=(80.0f-(float)ucAlpha)/10.0f;
fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep));
}
else
{
fVal=0.01f*80.0f;
}
}
else
{
fVal=0.01f*(float)ucAlpha;
}
}
else
{
// if we are in a menu, set the minimum opacity for tooltips to 15%
if(ui.GetMenuDisplayed(iPad) && (ucAlpha<15))
{
ucAlpha=15;
}
fVal=0.01f*(float)ucAlpha;
}
SetOpacity(fVal);
bool bDisplayGui=app.GetGameStarted() && !ui.GetMenuDisplayed(iPad) && !(app.GetXuiAction(iPad)==eAppAction_AutosaveSaveGameCapturedThumbnail) && app.GetGameSettings(iPad,eGameSetting_DisplayHUD)!=0;
if(bDisplayGui && pMinecraft->localplayers[iPad] != NULL)
{
SetVisible(true);
}
else
{
SetVisible(false);
}
}
void IUIScene_HUD::renderPlayerHealth()
{
Minecraft *pMinecraft = Minecraft::GetInstance();
int iPad = getPad();
ShowHealth(true);
SetRegenerationEffect(pMinecraft->localplayers[iPad]->hasEffect(MobEffect::regeneration));
// Update health
bool blink = pMinecraft->localplayers[iPad]->invulnerableTime / 3 % 2 == 1;
if (pMinecraft->localplayers[iPad]->invulnerableTime < 10) blink = false;
int currentHealth = pMinecraft->localplayers[iPad]->getHealth();
int oldHealth = pMinecraft->localplayers[iPad]->lastHealth;
bool bHasPoison = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::poison);
bool bHasWither = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::wither);
AttributeInstance *maxHealthAttribute = pMinecraft->localplayers[iPad]->getAttribute(SharedMonsterAttributes::MAX_HEALTH);
float maxHealth = (float)maxHealthAttribute->getValue();
float totalAbsorption = pMinecraft->localplayers[iPad]->getAbsorptionAmount();
// Update armour
int armor = pMinecraft->localplayers[iPad]->getArmorValue();
SetHealth(currentHealth, oldHealth, blink, bHasPoison || bHasWither, bHasWither);
SetHealthAbsorb(totalAbsorption);
if(armor > 0)
{
ShowArmour(true);
SetArmour(armor);
}
else
{
ShowArmour(false);
}
shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
if(riding == NULL || riding && !riding->instanceof(eTYPE_LIVINGENTITY))
{
SetRidingHorse(false, false, 0);
ShowFood(true);
ShowHorseHealth(false);
m_horseHealth = 0;
// Update food
//bool foodBlink = false;
FoodData *foodData = pMinecraft->localplayers[iPad]->getFoodData();
int food = foodData->getFoodLevel();
int oldFood = foodData->getLastFoodLevel();
bool hasHungerEffect = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::hunger);
int saturationLevel = pMinecraft->localplayers[iPad]->getFoodData()->getSaturationLevel();
SetFood(food, oldFood, hasHungerEffect);
SetFoodSaturationLevel(saturationLevel);
// Update air
if (pMinecraft->localplayers[iPad]->isUnderLiquid(Material::water))
{
ShowAir(true);
int count = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
int extra = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
SetAir(count, extra);
}
else
{
ShowAir(false);
}
}
else if(riding->instanceof(eTYPE_LIVINGENTITY) )
{
shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(riding);
int riderCurrentHealth = (int) ceil(living->getHealth());
float maxRiderHealth = living->getMaxHealth();
SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), maxRiderHealth);
SetHorseHealth(riderCurrentHealth);
ShowHorseHealth(true);
}
}
+85
View File
@@ -0,0 +1,85 @@
#pragma once
class IUIScene_HUD
{
protected:
int m_lastActiveSlot;
int m_iGuiScale;
bool m_bToolTipsVisible;
float m_lastExpProgress;
int m_lastExpLevel;
int m_iCurrentHealth;
int m_lastMaxHealth;
bool m_lastHealthBlink, m_lastHealthPoison, m_lastHealthWither;
int m_iCurrentFood;
bool m_lastFoodPoison;
int m_lastAir, m_currentExtraAir;
int m_lastArmour;
float m_lastDragonHealth;
bool m_showDragonHealth;
int m_ticksWithNoBoss;
bool m_lastShowDisplayName;
int m_horseHealth;
int m_iCurrentHealthAbsorb;
float m_horseJumpProgress;
int m_iHeartOffsetIndex;
bool m_bHealthAbsorbActive;
int m_iHorseMaxHealth;
bool m_showHealth, m_showHorseHealth, m_showFood, m_showAir, m_showArmour, m_showExpBar, m_bRidingHorse, m_bIsJumpable;
bool m_bRegenEffectEnabled;
int m_iFoodSaturation;
unsigned int m_uiSelectedItemOpacityCountDown;
wstring m_displayName;
IUIScene_HUD();
virtual int getPad() = 0;
virtual void SetOpacity(float opacity) = 0;
virtual void SetVisible(bool visible) = 0;
virtual void SetHudSize(int scale) = 0;
virtual void SetExpBarProgress(float progress, int xpNeededForNextLevel) = 0;
virtual void SetExpLevel(int level) = 0;
virtual void SetActiveSlot(int slot) = 0;
virtual void SetHealth(int iHealth, int iLastHealth, bool bBlink, bool bPoison, bool bWither) = 0;
virtual void SetFood(int iFood, int iLastFood, bool bPoison) = 0;
virtual void SetAir(int iAir, int extra) = 0;
virtual void SetArmour(int iArmour) = 0;
virtual void ShowHealth(bool show) = 0;
virtual void ShowHorseHealth(bool show) = 0;
virtual void ShowFood(bool show) = 0;
virtual void ShowAir(bool show) = 0;
virtual void ShowArmour(bool show) = 0;
virtual void ShowExpBar(bool show) = 0;
virtual void SetRegenerationEffect(bool bEnabled) = 0;
virtual void SetFoodSaturationLevel(int iSaturation) = 0;
virtual void SetDragonHealth(float health) = 0;
virtual void SetDragonLabel(const wstring &label) = 0;
virtual void ShowDragonHealth(bool show) = 0;
virtual void HideSelectedLabel() = 0;
virtual void SetDisplayName(const wstring &displayName) = 0;
virtual void SetTooltipsEnabled(bool bEnabled) = 0;
virtual void SetRidingHorse(bool ridingHorse, bool bIsJumpable, int maxHorseHealth) = 0;
virtual void SetHorseHealth(int health, bool blink = false) = 0;
virtual void SetHorseJumpBarProgress(float progress) = 0;
virtual void SetHealthAbsorb(int healthAbsorb) = 0;
virtual void SetSelectedLabel(const wstring &label) = 0;
virtual void ShowDisplayName(bool show) = 0;
public:
void updateFrameTick();
void renderPlayerHealth();
};
@@ -0,0 +1,77 @@
#include "stdafx.h"
#include "IUIScene_HopperMenu.h"
#include "../Minecraft.World/net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_HopperMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionHopperContents:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionHopperInventory;
xOffset = -2;
}
else if(eTapDirection == eTapStateUp)
{
xOffset = -2;
newSection = eSectionHopperUsing;
}
break;
case eSectionHopperInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionHopperUsing;
}
else if(eTapDirection == eTapStateUp)
{
xOffset = 2;
newSection = eSectionHopperContents;
}
break;
case eSectionHopperUsing:
if(eTapDirection == eTapStateDown)
{
xOffset = 2;
newSection = eSectionHopperContents;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionHopperInventory;
}
break;
default:
assert(false);
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
return newSection;
}
int IUIScene_HopperMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionHopperContents:
offset = HopperMenu::CONTENTS_SLOT_START;
break;
case eSectionHopperInventory:
offset = HopperMenu::INV_SLOT_START;
break;
case eSectionHopperUsing:
offset = HopperMenu::USE_ROW_SLOT_START;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,12 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
#include "../../../Minecraft.World/Container.h"
#include "../../../Minecraft.World/Inventory.h"
class IUIScene_HopperMenu : public virtual IUIScene_AbstractContainerMenu
{
public:
virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY);
int getSectionStartOffset(ESceneSection eSection);
};
@@ -0,0 +1,251 @@
#include "stdafx.h"
#include "IUIScene_HorseInventoryMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.animal.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_HorseInventoryMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
int xOffset = 0;
int yOffset = 0;
// Find the new section if there is one
switch( eSection )
{
case eSectionHorseUsing:
if(eTapDirection == eTapStateDown)
{
if(m_horse->isChestedHorse() && *piTargetX >= 4)
{
newSection = eSectionHorseChest;
xOffset = 4;
}
else
{
newSection = eSectionHorseSaddle;
}
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionHorseInventory;
}
break;
case eSectionHorseInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionHorseUsing;
}
else if(eTapDirection == eTapStateUp)
{
if(m_horse->isChestedHorse() && *piTargetX >= 4)
{
xOffset = 4;
newSection = eSectionHorseChest;
}
else if(m_horse->canWearArmor())
{
newSection = eSectionHorseArmor;
}
else
{
newSection = eSectionHorseSaddle;
}
}
break;
case eSectionHorseChest:
if(eTapDirection == eTapStateDown)
{
xOffset = -4;
newSection = eSectionHorseInventory;
}
else if(eTapDirection == eTapStateUp)
{
xOffset = -4;
newSection = eSectionHorseUsing;
}
else if(eTapDirection == eTapStateLeft)
{
if(*piTargetX < 0)
{
if(m_horse->canWearArmor() && *piTargetY == 1)
{
newSection = eSectionHorseArmor;
}
else if( *piTargetY == 0)
{
newSection = eSectionHorseSaddle;
}
}
}
else if(eTapDirection == eTapStateRight)
{
if(*piTargetX >= getSectionColumns(eSectionHorseChest))
{
if(m_horse->canWearArmor() && *piTargetY == 1)
{
newSection = eSectionHorseArmor;
}
else if( *piTargetY == 0)
{
newSection = eSectionHorseSaddle;
}
}
}
break;
case eSectionHorseArmor:
if(eTapDirection == eTapStateDown)
{
if(m_horse->isChestedHorse())
{
newSection = eSectionHorseChest;
}
else
{
newSection = eSectionHorseInventory;
}
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionHorseSaddle;
}
else if(eTapDirection == eTapStateRight)
{
if(m_horse->isChestedHorse())
{
yOffset = -1;
*piTargetX = 0;
newSection = eSectionHorseChest;
}
}
else if(eTapDirection == eTapStateLeft)
{
if(m_horse->isChestedHorse())
{
yOffset = -1;
*piTargetX = getSectionColumns(eSectionHorseChest);
newSection = eSectionHorseChest;
}
}
break;
case eSectionHorseSaddle:
if(eTapDirection == eTapStateDown)
{
if(m_horse->canWearArmor())
{
newSection = eSectionHorseArmor;
}
else
{
newSection = eSectionHorseInventory;
}
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionHorseUsing;
}
else if(eTapDirection == eTapStateRight)
{
if(m_horse->isChestedHorse())
{
*piTargetX = 0;
newSection = eSectionHorseChest;
}
}
else if(eTapDirection == eTapStateLeft)
{
if(m_horse->isChestedHorse())
{
*piTargetX = getSectionColumns(eSectionHorseChest);
newSection = eSectionHorseChest;
}
}
break;
default:
assert(false);
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset, yOffset);
return newSection;
}
// TODO: Offset will vary by type of horse, add in once horse menu and horse entity are implemented
int IUIScene_HorseInventoryMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionHorseSaddle:
offset = EntityHorse::INV_SLOT_SADDLE;
break;
case eSectionHorseArmor:
offset = EntityHorse::INV_SLOT_ARMOR;
break;
case eSectionHorseChest:
offset = EntityHorse::INV_BASE_COUNT;
break;
case eSectionHorseInventory:
offset = EntityHorse::INV_BASE_COUNT;
if(m_horse->isChestedHorse())
{
offset += EntityHorse::INV_DONKEY_CHEST_COUNT;
}
break;
case eSectionHorseUsing:
offset = EntityHorse::INV_BASE_COUNT + 27;
if(m_horse->isChestedHorse())
{
offset += EntityHorse::INV_DONKEY_CHEST_COUNT;
}
break;
default:
assert( false );
break;
}
return offset;
}
bool IUIScene_HorseInventoryMenu::IsSectionSlotList( ESceneSection eSection )
{
switch( eSection )
{
case eSectionHorseChest:
if(!m_horse->isChestedHorse())
return false;
else
return true;
case eSectionHorseArmor:
if(!m_horse->canWearArmor())
return false;
else
return true;
case eSectionHorseSaddle:
case eSectionHorseInventory:
case eSectionHorseUsing:
return true;
}
return false;
}
bool IUIScene_HorseInventoryMenu::IsVisible( ESceneSection eSection )
{
switch( eSection )
{
case eSectionHorseChest:
if(!m_horse->isChestedHorse())
return false;
else
return true;
case eSectionHorseArmor:
if(!m_horse->canWearArmor())
return false;
else
return true;
case eSectionHorseSaddle:
case eSectionHorseInventory:
case eSectionHorseUsing:
return true;
}
return false;
}
@@ -0,0 +1,20 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
#include "../../../Minecraft.World/Container.h"
#include "../../../Minecraft.World/Inventory.h"
#include "../../../Minecraft.World/EntityHorse.h"
class IUIScene_HorseInventoryMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
shared_ptr<Inventory> m_inventory;
shared_ptr<Container> m_container;
shared_ptr<EntityHorse> m_horse;
public:
virtual ESceneSection GetSectionAndSlotInDirection(ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY);
int getSectionStartOffset(ESceneSection eSection);
bool IsSectionSlotList( ESceneSection eSection );
bool IsVisible( ESceneSection eSection );
};
@@ -0,0 +1,72 @@
#include "stdafx.h"
#include "IUIScene_InventoryMenu.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
{
ESceneSection newSection = eSection;
// Find the new section if there is one
switch( eSection )
{
case eSectionInventoryArmor:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryInventory;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryUsing;
}
break;
case eSectionInventoryInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryUsing;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryArmor;
}
break;
case eSectionInventoryUsing:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryArmor;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryInventory;
}
break;
default:
assert( false );
break;
}
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, 0);
return newSection;
}
int IUIScene_InventoryMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionInventoryArmor:
offset = InventoryMenu::ARMOR_SLOT_START;
break;
case eSectionInventoryInventory:
offset = InventoryMenu::INV_SLOT_START;
break;
case eSectionInventoryUsing:
offset = InventoryMenu::INV_SLOT_START + 27;
break;
default:
assert( false );
break;
}
return offset;
}
@@ -0,0 +1,10 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
class IUIScene_InventoryMenu : public virtual IUIScene_AbstractContainerMenu
{
protected:
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY );
int getSectionStartOffset(ESceneSection eSection);
};
@@ -0,0 +1,711 @@
#include "stdafx.h"
#include "IUIScene_PauseMenu.h"
#include "..\..\Minecraft.h"
#include "..\..\MinecraftServer.h"
#include "..\..\MultiPlayerLevel.h"
#include "..\..\ProgressRenderer.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h"
#include "..\..\TexturePackRepository.h"
#include "..\..\TexturePack.h"
#include "..\..\DLCTexturePack.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#ifndef _XBOX
#include "UI.h"
#endif
int IUIScene_PauseMenu::ExitGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
#ifdef _XBOX
IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam;
#else
IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam));
#endif
// Results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
if(pScene) pScene->SetIgnoreInput(true);
app.SetAction(iPad,eAppAction_ExitWorld);
}
return 0;
}
int IUIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
#ifdef _XBOX
IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam;
#else
IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam));
#endif
// Exit with or without saving
// Decline means save in this dialog
if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption)
{
if( result==C4JStorage::EMessage_ResultDecline ) // Save
{
// 4J-PB - Is the player trying to save but they are using a trial texturepack ?
if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
{
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
{
#ifdef _XBOX
// upsell
ULONGLONG ullOfferID_Full;
// get the dlc texture pack
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full);
// tell sentient about the upsell of the full version of the skin pack
TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
#endif
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_OK;
uiIDA[1]=IDS_CONFIRM_CANCEL;
// Give the player a warning about the trial version of the texture pack
ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad() , &IUIScene_PauseMenu::WarningTrialTexturePackReturned, pParam);
return S_OK;
}
}
// does the save exist?
bool bSaveExists;
StorageManager.DoesSaveExist(&bSaveExists);
// 4J-PB - we check if the save exists inside the libs
// we need to ask if they are sure they want to overwrite the existing game
if(bSaveExists)
{
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
ui.RequestAlertMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameAndSaveReturned, pParam);
return 0;
}
else
{
#if defined(_XBOX_ONE) || defined(__ORBIS__)
StorageManager.SetSaveDisabled(false);
#endif
MinecraftServer::getInstance()->setSaveOnExit( true );
}
}
else
{
// been a few requests for a confirm on exit without saving
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
ui.RequestAlertMessage(IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameDeclineSaveReturned, pParam);
return 0;
}
if(pScene) pScene->SetIgnoreInput(true);
app.SetAction(iPad,eAppAction_ExitWorld);
}
return 0;
}
int IUIScene_PauseMenu::ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
// 4J-PB - we won't come in here if we have a trial texture pack
#ifdef _XBOX
IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam;
#else
IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam));
#endif
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
//INT saveOrCheckpointId = 0;
//bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId);
//SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId);
#if defined(_XBOX_ONE) || defined(__ORBIS__)
StorageManager.SetSaveDisabled(false);
#endif
if(pScene) pScene->SetIgnoreInput(true);
MinecraftServer::getInstance()->setSaveOnExit( true );
// flag a app action of exit game
app.SetAction(iPad,eAppAction_ExitWorld);
}
else
{
// has someone disconnected the ethernet here, causing the pause menu to shut?
if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()))
{
UINT uiIDA[3];
// you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then.
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_EXIT_GAME_SAVE;
uiIDA[2]=IDS_EXIT_GAME_NO_SAVE;
if(g_NetworkManager.GetPlayerCount()>1)
{
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam);
}
else
{
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(), &IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam);
}
}
}
return 0;
}
int IUIScene_PauseMenu::ExitGameDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
#ifdef _XBOX
IUIScene_PauseMenu *pScene = (IUIScene_PauseMenu *)pParam;
#else
IUIScene_PauseMenu *pScene = dynamic_cast<IUIScene_PauseMenu *>(ui.GetSceneFromCallbackId((size_t)pParam));
#endif
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
#if defined(_XBOX_ONE) || defined(__ORBIS__)
// Don't do this here, as it will still try and save some things even though it shouldn't!
//StorageManager.SetSaveDisabled(false);
#endif
if(pScene) pScene->SetIgnoreInput(true);
MinecraftServer::getInstance()->setSaveOnExit( false );
// flag a app action of exit game
app.SetAction(iPad,eAppAction_ExitWorld);
}
else
{
// has someone disconnected the ethernet here, causing the pause menu to shut?
if(ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()))
{
UINT uiIDA[3];
// you cancelled the save on exit after choosing exit and save? You go back to the Exit choices then.
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_EXIT_GAME_SAVE;
uiIDA[2]=IDS_EXIT_GAME_NO_SAVE;
if(g_NetworkManager.GetPlayerCount()>1)
{
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam);
}
else
{
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, ProfileManager.GetPrimaryPad(),&IUIScene_PauseMenu::ExitGameSaveDialogReturned, pParam);
}
}
}
return 0;
}
int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
if(result==C4JStorage::EMessage_ResultAccept)
{
if(!ProfileManager.IsSignedInLive(iPad))
{
// you're not signed in to PSN!
}
else
{
// 4J-PB - need to check this user can access the store
bool bContentRestricted;
ProfileManager.GetChatAndContentRestrictions(iPad,true,NULL,&bContentRestricted,NULL);
if(bContentRestricted)
{
UINT uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
}
else
{
// need to get info on the pack to see if the user has already downloaded it
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
// retrieve the store name for the skin pack
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
const char *pchPackName=wstringtofilename(pDLCPack->getName());
app.DebugPrintf("Texture Pack - %s\n",pchPackName);
SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
if(pSONYDLCInfo!=NULL)
{
char chName[42];
char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN];
memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN);
// find the info on the skin pack
// we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it.
// So we assume the first sku for the product is the one we want
#ifdef __ORBIS__
sprintf(chName,"%s",pSONYDLCInfo->chDLCKeyname);
#else
sprintf(chName,"%s-%s",app.GetCommerceCategory(),pSONYDLCInfo->chDLCKeyname);
#endif
app.GetDLCSkuIDFromProductList(chName,chSkuID);
// 4J-PB - need to check for an empty store
#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__
if(app.CheckForEmptyStore(iPad)==false)
#endif
{
if(app.DLCAlreadyPurchased(chSkuID))
{
app.DownloadAlreadyPurchased(chSkuID);
}
else
{
app.Checkout(chSkuID);
}
}
}
}
}
}
#endif //
#ifdef _XBOX_ONE
IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam;
if(result==C4JStorage::EMessage_ResultAccept)
{
if(ProfileManager.IsSignedIn(iPad))
{
if (ProfileManager.IsSignedInLive(iPad))
{
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
// get the dlc texture pack
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();
DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str());
StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL);
// the license change coming in when the offer has been installed will cause this scene to refresh
}
else
{
// 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no active network connection user is unable to convert from Trial to Full texture pack and is not messaged why.
UINT uiIDA[1] = { IDS_CONFIRM_OK };
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad);
}
}
}
#endif
#ifdef _XBOX
IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam;
//pScene->m_bIgnoreInput = false;
pScene->ShowScene( true );
if(result==C4JStorage::EMessage_ResultAccept)
{
if(ProfileManager.IsSignedIn(iPad))
{
ULONGLONG ullIndexA[1];
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
// get the dlc texture pack
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
// Need to get the parent packs id, since this may be one of many child packs with their own ids
app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullIndexA[0]);
// need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth...
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW);
StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
}
}
else
{
TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined);
}
#endif
return 0;
}
int IUIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter )
{
bool bAutosave=(bool)lpParameter;
if(bAutosave)
{
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_AutoSaveGame);
}
else
{
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_SaveGame);
}
// Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
Minecraft *pMinecraft=Minecraft::GetInstance();
//wprintf(L"Loading world on thread\n");
if(ProfileManager.IsFullVersion())
{
app.SetGameStarted(false);
while( app.GetXuiServerAction(ProfileManager.GetPrimaryPad() ) != eXuiServerAction_Idle && !MinecraftServer::serverHalted() )
{
Sleep(10);
}
if(!MinecraftServer::serverHalted() && !app.GetChangingSessionType() ) app.SetGameStarted(true);
#if defined(_XBOX_ONE) || defined(__ORBIS__)
if(app.GetGameHostOption(eGameHostOption_DisableSaving)) StorageManager.SetSaveDisabled(true);
#endif
}
HRESULT hr = S_OK;
if(app.GetChangingSessionType())
{
// 4J Stu - This causes the fullscreenprogress scene to ignore the action it was given
hr = ERROR_CANCELLED;
}
return hr;
}
int IUIScene_PauseMenu::ExitWorldThreadProc( void* lpParameter )
{
// Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
//app.SetGameStarted(false);
_ExitWorld(lpParameter);
return S_OK;
}
// This function performs the meat of exiting from a level. It should be called from a thread other than the main thread.
void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
int exitReasonStringId = pMinecraft->progressRenderer->getCurrentTitle();
int exitReasonTitleId = IDS_CONNECTION_LOST;
bool saveStats = true;
if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession())
{
if(lpParameter != NULL )
{
// 4J-PB - check if we have lost connection to Live
if(ProfileManager.GetLiveConnectionStatus()!=XONLINE_S_LOGON_CONNECTION_ESTABLISHED )
{
exitReasonStringId = IDS_CONNECTION_LOST_LIVE;
}
else
{
switch( app.GetDisconnectReason() )
{
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#if defined(__PS3__) || defined(__ORBIS__)
case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal:
exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local:
exitReasonStringId = IDS_CONTENT_RESTRICTION;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
#ifdef _XBOX
case DisconnectPacket::eDisconnect_NoUGC_Remote:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
case DisconnectPacket::eDisconnect_NoFlying:
exitReasonStringId = IDS_DISCONNECTED_FLYING;
break;
case DisconnectPacket::eDisconnect_Quitting:
exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
break;
#ifdef __ORBIS__
case DisconnectPacket::eDisconnect_NetworkError:
exitReasonStringId = IDS_ERROR_NETWORK_EXIT;
exitReasonTitleId = IDS_ERROR_NETWORK_TITLE;
break;
#endif
case DisconnectPacket::eDisconnect_NoFriendsInGame:
exitReasonStringId = IDS_DISCONNECTED_NO_FRIENDS_IN_GAME;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_Banned:
exitReasonStringId = IDS_DISCONNECTED_BANNED;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_NotFriendsWithHost:
exitReasonStringId = IDS_NOTALLOWED_FRIENDSOFFRIENDS;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_ServerFull:
exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
#ifdef _XBOX_ONE
case DisconnectPacket::eDisconnect_ExitedGame:
exitReasonTitleId = IDS_EXIT_GAME;
exitReasonStringId = IDS_DISCONNECTED_EXITED_GAME;
break;
#endif
#if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__
case DisconnectPacket::eDisconnect_NATMismatch:
exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
default:
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
}
}
//pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId );
UINT uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
// 4J Stu - Fix for #48669 - TU5: Code: Compliance: TCR #15: Incorrect/misleading messages after signing out a profile during online game session.
// If the primary player is signed out, then that is most likely the cause of the disconnection so don't display a message box. This will allow the message box requested by the libraries to be brought up
if( ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) ui.RequestErrorMessage( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad());
exitReasonStringId = -1;
// 4J - Force a disconnection, this handles the situation that the server has already disconnected
if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false);
if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false);
if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect(false);
}
else
{
exitReasonStringId = IDS_EXITING_GAME;
pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME );
if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect();
if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect();
if( pMinecraft->levels[2] != NULL ) pMinecraft->levels[2]->disconnect();
}
// 4J Stu - This only does something if we actually have a server, so don't need to do any other checks
MinecraftServer::HaltServer();
// We need to call the stats & leaderboards save before we exit the session
// 4J We need to do this in a QNet callback where it is safe
//pMinecraft->forceStatsSave();
saveStats = false;
// 4J Stu - Leave the session once the disconnect packet has been sent
g_NetworkManager.LeaveGame(FALSE);
}
else
{
if(lpParameter != NULL && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) )
{
switch( app.GetDisconnectReason() )
{
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#if defined(__PS3__) || defined(__ORBIS__)
case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal:
exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local:
exitReasonStringId = IDS_CONTENT_RESTRICTION;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
#ifdef _XBOX
case DisconnectPacket::eDisconnect_NoUGC_Remote:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
case DisconnectPacket::eDisconnect_Quitting:
exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
break;
#ifdef __ORBIS__
case DisconnectPacket::eDisconnect_NetworkError:
exitReasonStringId = IDS_ERROR_NETWORK_EXIT;
exitReasonTitleId = IDS_ERROR_NETWORK_TITLE;
break;
#endif
case DisconnectPacket::eDisconnect_NoMultiplayerPrivilegesJoin:
exitReasonStringId = IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
case DisconnectPacket::eDisconnect_ServerFull:
exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
exitReasonTitleId = IDS_CANTJOIN_TITLE;
break;
#if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__
case DisconnectPacket::eDisconnect_NATMismatch:
exitReasonStringId = IDS_DISCONNECTED_NAT_TYPE_MISMATCH;
exitReasonTitleId = IDS_CONNECTION_FAILED;
break;
#endif
default:
exitReasonStringId = IDS_DISCONNECTED;
}
//pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId );
UINT uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
ui.RequestErrorMessage( exitReasonTitleId, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad());
exitReasonStringId = -1;
}
}
// Fix for #93148 - TCR 001: BAS Game Stability: Title will crash for the multiplayer client if host of the game will exit during the clients loading to created world.
while( g_NetworkManager.IsNetworkThreadRunning() )
{
Sleep(1);
}
pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats);
TelemetryManager->Flush();
app.m_gameRules.unloadCurrentGameRules();
//app.m_Audio.unloadCurrentAudioDetails();
MinecraftServer::resetFlags();
// Fix for #48385 - BLACK OPS :TU5: Functional: Client becomes pseudo soft-locked when returned to the main menu after a remote disconnect
// Make sure there is text explaining why the player is waiting
pMinecraft->progressRenderer->progressStart(IDS_EXITING_GAME);
// Fix for #13259 - CRASH: Gameplay: loading process is halted when player loads saved data
// We can't start/join a new game until the session is destroyed, so wait for it to be idle again
while( g_NetworkManager.IsInSession() )
{
Sleep(1);
}
app.SetChangingSessionType(false);
app.SetReallyChangingSessionType(false);
#if defined(_XBOX_ONE) || defined(__ORBIS__)
// Make sure we don't think saving is disabled in the menus
StorageManager.SetSaveDisabled(false);
#endif
}
int IUIScene_PauseMenu::SaveGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
#if defined(_XBOX_ONE) || defined(__ORBIS__)
UINT uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
ui.RequestAlertMessage(IDS_TITLE_ENABLE_AUTOSAVE, IDS_CONFIRM_ENABLE_AUTOSAVE, uiIDA, 2, iPad,&IUIScene_PauseMenu::EnableAutosaveDialogReturned,pParam);
#else
// flag a app action of save game
app.SetAction(iPad,eAppAction_SaveGame);
#endif
}
return 0;
}
int IUIScene_PauseMenu::EnableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
// Set the global flag, so that we don't disable saving again once the save is complete
app.SetGameHostOption(eGameHostOption_DisableSaving, 0);
}
else
{
// Set the global flag, so that we do disable saving again once the save is complete
// We need to set this on as we may have only disabled it due to having a trial texture pack
app.SetGameHostOption(eGameHostOption_DisableSaving, 1);
}
// Re-enable saving temporarily
StorageManager.SetSaveDisabled(false);
// flag a app action of save game
app.SetAction(iPad,eAppAction_SaveGame);
return 0;
}
int IUIScene_PauseMenu::DisableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
// results switched for this dialog
if(result==C4JStorage::EMessage_ResultDecline)
{
// Set the global flag, so that we disable saving again once the save is complete
app.SetGameHostOption(eGameHostOption_DisableSaving, 1);
StorageManager.SetSaveDisabled(false);
// flag a app action of save game
app.SetAction(iPad,eAppAction_SaveGame);
}
return 0;
}
@@ -0,0 +1,25 @@
#pragma once
class IUIScene_PauseMenu
{
protected:
DLCPack *m_pDLCPack;
public:
static int ExitGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitGameDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int SaveGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int EnableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int DisableAutosaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int SaveWorldThreadProc( void* lpParameter );
static int ExitWorldThreadProc( void* lpParameter );
static void _ExitWorld(LPVOID lpParameter); // Call only from a thread
protected:
virtual void ShowScene(bool show) = 0;
virtual void SetIgnoreInput(bool ignoreInput) = 0;
};
@@ -0,0 +1,379 @@
#include "stdafx.h"
#include "UI.h"
#include "TexturePack.h"
#include "TexturePackRepository.h"
#include "Minecraft.h"
#include "IUIScene_StartGame.h"
IUIScene_StartGame::IUIScene_StartGame(int iPad, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
m_bIgnoreInput = false;
m_iTexturePacksNotInstalled=0;
m_texturePackDescDisplayed = false;
m_bShowTexturePackDescription = false;
m_iSetTexturePackDescription = -1;
Minecraft *pMinecraft = Minecraft::GetInstance();
m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(0);
}
void IUIScene_StartGame::HandleDLCMountingComplete()
{
Minecraft *pMinecraft = Minecraft::GetInstance();
// clear out the current texture pack list
m_texturePackList.clearSlots();
int texturePacksCount = pMinecraft->skins->getTexturePackCount();
for(unsigned int i = 0; i < texturePacksCount; ++i)
{
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
DWORD dwImageBytes;
PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
if(dwImageBytes > 0 && pbImageData)
{
wchar_t imageName[64];
swprintf(imageName,64,L"tpack%08x",tp->getId());
registerSubstitutionTexture(imageName, pbImageData, dwImageBytes);
m_texturePackList.addPack(i,imageName);
}
}
m_iTexturePacksNotInstalled=0;
// 4J-PB - there may be texture packs we don't have, so use the info from TMS for this
// REMOVE UNTIL WORKING
DLC_INFO *pDLCInfo=NULL;
// first pass - look to see if there are any that are not in the list
bool bTexturePackAlreadyListed;
bool bNeedToGetTPD=false;
for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
{
bTexturePackAlreadyListed=false;
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
char *pchName=app.GetDLCInfoTextures(i);
pDLCInfo=app.GetDLCInfo(pchName);
#elif defined _XBOX_ONE
pDLCInfo=app.GetDLCInfoForFullOfferID((WCHAR *)app.GetDLCInfoTexturesFullOffer(i).c_str());
#else
ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
#endif
for(unsigned int i = 0; i < texturePacksCount; ++i)
{
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
if(pDLCInfo->iConfig==tp->getDLCParentPackId())
{
bTexturePackAlreadyListed=true;
}
}
if(bTexturePackAlreadyListed==false)
{
// some missing
bNeedToGetTPD=true;
m_iTexturePacksNotInstalled++;
}
}
#if TO_BE_IMPLEMENTED
if(bNeedToGetTPD==true)
{
// add a TMS request for them
app.DebugPrintf("+++ Adding TMSPP request for texture pack data\n");
app.AddTMSPPFileTypeRequest(e_DLC_TexturePackData);
if(m_iConfigA!=NULL)
{
delete m_iConfigA;
}
m_iConfigA= new int [m_iTexturePacksNotInstalled];
m_iTexturePacksNotInstalled=0;
for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
{
bTexturePackAlreadyListed=false;
ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i);
pDLCInfo=app.GetDLCInfoForFullOfferID(ull);
for(unsigned int i = 0; i < texturePacksCount; ++i)
{
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i);
if(pDLCInfo->iConfig==tp->getDLCParentPackId())
{
bTexturePackAlreadyListed=true;
}
}
if(bTexturePackAlreadyListed==false)
{
m_iConfigA[m_iTexturePacksNotInstalled++]=pDLCInfo->iConfig;
}
}
}
#endif
m_currentTexturePackIndex = pMinecraft->skins->getTexturePackIndex(0);
UpdateTexturePackDescription(m_currentTexturePackIndex);
m_texturePackList.selectSlot(m_currentTexturePackIndex);
m_bIgnoreInput=false;
app.m_dlcManager.checkForCorruptDLCAndAlert();
}
void IUIScene_StartGame::handleSelectionChanged(F64 selectedId)
{
m_iSetTexturePackDescription = (int)selectedId;
if(!m_texturePackDescDisplayed)
{
m_bShowTexturePackDescription = true;
}
}
void IUIScene_StartGame::UpdateTexturePackDescription(int index)
{
TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(index);
if(tp==NULL)
{
#if TO_BE_IMPLEMENTED
// this is probably a texture pack icon added from TMS
DWORD dwBytes=0,dwFileBytes=0;
PBYTE pbData=NULL,pbFileData=NULL;
CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
// get the current index of the list, and then get the data
ListItem=m_pTexturePacksList->GetData(index);
app.GetTPD(ListItem.iData,&pbData,&dwBytes);
app.GetFileFromTPD(eTPDFileType_Loc,pbData,dwBytes,&pbFileData,&dwFileBytes );
if(dwFileBytes > 0 && pbFileData)
{
StringTable *pStringTable = new StringTable(pbFileData, dwFileBytes);
m_texturePackTitle.SetText(pStringTable->getString(L"IDS_DISPLAY_NAME"));
m_texturePackDescription.SetText(pStringTable->getString(L"IDS_TP_DESCRIPTION"));
}
app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes );
if(dwFileBytes >= 0 && pbFileData)
{
XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush);
m_texturePackIcon->UseBrush(m_hTexturePackIconBrush);
}
app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes );
if(dwFileBytes >= 0 && pbFileData)
{
XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush);
m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush);
}
else
{
m_texturePackComparison->UseBrush(NULL);
}
#endif
}
else
{
m_labelTexturePackName.setLabel(tp->getName());
m_labelTexturePackDescription.setLabel(tp->getDesc1());
DWORD dwImageBytes;
PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
//if(dwImageBytes > 0 && pbImageData)
//{
// registerSubstitutionTexture(L"texturePackIcon", pbImageData, dwImageBytes);
// m_bitmapTexturePackIcon.setTextureName(L"texturePackIcon");
//}
wchar_t imageName[64];
swprintf(imageName,64,L"tpack%08x",tp->getId());
m_bitmapTexturePackIcon.setTextureName(imageName);
pbImageData = tp->getPackComparison(dwImageBytes);
if(dwImageBytes > 0 && pbImageData)
{
swprintf(imageName,64,L"texturePackComparison%08x",tp->getId());
registerSubstitutionTexture(imageName, pbImageData, dwImageBytes);
m_bitmapComparison.setTextureName(imageName);
}
else
{
m_bitmapComparison.setTextureName(L"");
}
}
}
void IUIScene_StartGame::UpdateCurrentTexturePack(int iSlot)
{
m_currentTexturePackIndex = iSlot;
TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackByIndex(m_currentTexturePackIndex);
// if the texture pack is null, you don't have it yet
if(tp==NULL)
{
#if TO_BE_IMPLEMENTED
// Upsell
CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
// get the current index of the list, and then get the data
ListItem=m_pTexturePacksList->GetData(m_currentTexturePackIndex);
// upsell the texture pack
// tell sentient about the upsell of the full version of the skin pack
ULONGLONG ullOfferID_Full;
app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full);
TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
UINT uiIDA[3];
uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION;
uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION;
uiIDA[2]=IDS_CONFIRM_CANCEL;
// Give the player a warning about the texture pack missing
ui.RequestErrorMessage(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 3, ProfileManager.GetPrimaryPad(),&:TexturePackDialogReturned,this);
// do set the texture pack id, and on the user pressing create world, check they have it
m_MoreOptionsParams.dwTexturePack = ListItem.iData;
return ;
#endif
}
else
{
m_MoreOptionsParams.dwTexturePack = tp->getId();
}
}
int IUIScene_StartGame::TrialTexturePackWarningReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam;
if(result==C4JStorage::EMessage_ResultAccept)
{
pScene->checkStateAndStartGame();
}
else
{
pScene->m_bIgnoreInput=false;
}
return 0;
}
int IUIScene_StartGame::UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
IUIScene_StartGame* pScene = (IUIScene_StartGame*)pParam;
if(result==C4JStorage::EMessage_ResultAccept)
{
if(ProfileManager.IsSignedIn(iPad))
{
#if defined _XBOX //|| defined _XBOX_ONE
ULONGLONG ullIndexA[1];
DLC_INFO *pDLCInfo = app.GetDLCInfoForTrialOfferID(pScene->m_pDLCPack->getPurchaseOfferId());
if(pDLCInfo!=NULL)
{
ullIndexA[0]=pDLCInfo->ullOfferID_Full;
}
else
{
ullIndexA[0]=pScene->m_pDLCPack->getPurchaseOfferId();
}
StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
#elif defined _XBOX_ONE
//StorageManager.InstallOffer(1,StorageManager.GetOffer(iIndex).wszProductID,NULL,NULL);
#endif
// the license change coming in when the offer has been installed will cause this scene to refresh
}
}
else
{
#if defined _XBOX
TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined);
#endif
}
pScene->m_bIgnoreInput = false;
return 0;
}
int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
IUIScene_StartGame *pClass = (IUIScene_StartGame *)pParam;
#ifdef _XBOX
// Exit with or without saving
// Decline means install full version of the texture pack in this dialog
if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultAccept)
{
// we need to enable background downloading for the DLC
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW);
ULONGLONG ullOfferID_Full;
ULONGLONG ullIndexA[1];
CXuiCtrl4JList::LIST_ITEM_INFO ListItem;
// get the current index of the list, and then get the data
ListItem=pClass->m_pTexturePacksList->GetData(pClass->m_currentTexturePackIndex);
app.GetDLCFullOfferIDForPackID(ListItem.iData,&ullOfferID_Full);
if( result==C4JStorage::EMessage_ResultAccept ) // Full version
{
ullIndexA[0]=ullOfferID_Full;
StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
}
else // trial version
{
// if there is no trial version, this is a Cancel
DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full);
if(pDLCInfo->ullOfferID_Trial!=0LL)
{
ullIndexA[0]=pDLCInfo->ullOfferID_Trial;
StorageManager.InstallOffer(1,ullIndexA,NULL,NULL);
}
}
}
#elif defined _XBOX_ONE
// Get the product id from the texture pack id
if(result==C4JStorage::EMessage_ResultAccept)
{
if(ProfileManager.IsSignedIn(iPad))
{
if (ProfileManager.IsSignedInLive(iPad))
{
wstring ProductId;
app.GetDLCFullOfferIDForPackID(pClass->m_MoreOptionsParams.dwTexturePack,ProductId);
StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL);
// the license change coming in when the offer has been installed will cause this scene to refresh
}
else
{
// 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no active network connection user is unable to convert from Trial to Full texture pack and is not messaged why.
UINT uiIDA[1] = { IDS_CONFIRM_OK };
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad);
}
}
}
#endif
pClass->m_bIgnoreInput=false;
return 0;
}
@@ -0,0 +1,48 @@
#pragma once
#include "UIScene.h"
// Shared functions between CreteWorld, Load and Join
class IUIScene_StartGame : public UIScene
{
protected:
UIControl_TexturePackList m_texturePackList;
UIControl m_controlTexturePackPanel;
UIControl_Label m_labelTexturePackName, m_labelTexturePackDescription;
UIControl_BitmapIcon m_bitmapTexturePackIcon, m_bitmapComparison;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_controlTexturePackPanel, "TexturePackPanel" )
UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlTexturePackPanel )
UI_MAP_ELEMENT( m_labelTexturePackName, "TexturePackName")
UI_MAP_ELEMENT( m_labelTexturePackDescription, "TexturePackDescription")
UI_MAP_ELEMENT( m_bitmapTexturePackIcon, "Icon")
UI_MAP_ELEMENT( m_bitmapComparison, "ComparisonPic")
UI_END_MAP_CHILD_ELEMENTS()
UI_END_MAP_ELEMENTS_AND_NAMES()
LaunchMoreOptionsMenuInitData m_MoreOptionsParams;
bool m_bIgnoreInput;
int m_iTexturePacksNotInstalled;
unsigned int m_currentTexturePackIndex;
bool m_bShowTexturePackDescription;
bool m_texturePackDescDisplayed;
int m_iSetTexturePackDescription;
IUIScene_StartGame(int iPad, UILayer *parentLayer);
virtual void checkStateAndStartGame() = 0;
virtual void handleSelectionChanged(F64 selectedId);
virtual void HandleDLCMountingComplete();
void UpdateTexturePackDescription(int index);
void UpdateCurrentTexturePack(int iSlot);
static int TrialTexturePackWarningReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
};
@@ -0,0 +1,384 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.trading.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\ClientConnection.h"
#include "IUIScene_TradingMenu.h"
IUIScene_TradingMenu::IUIScene_TradingMenu()
{
m_validOffersCount = 0;
m_selectedSlot = 0;
m_offersStartIndex = 0;
m_menu = NULL;
m_bHasUpdatedOnce = false;
}
shared_ptr<Merchant> IUIScene_TradingMenu::getMerchant()
{
return m_merchant;
}
bool IUIScene_TradingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat)
{
bool handled = false;
//MerchantRecipeList *offers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]);
bool changed = false;
Minecraft *pMinecraft = Minecraft::GetInstance();
if( pMinecraft->localgameModes[getPad()] != NULL )
{
Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial();
if(tutorial != NULL)
{
tutorial->handleUIInput(iAction);
if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction))
{
return S_OK;
}
}
}
switch(iAction)
{
case ACTION_MENU_B:
ui.ShowTooltip( iPad, eToolTipButtonX, false );
ui.ShowTooltip( iPad, eToolTipButtonB, false );
ui.ShowTooltip( iPad, eToolTipButtonA, false );
ui.ShowTooltip( iPad, eToolTipButtonRB, false );
// kill the crafting xui
//ui.PlayUISFX(eSFX_Back);
ui.CloseUIScenes(iPad);
handled = true;
break;
case ACTION_MENU_A:
#ifdef __ORBIS__
case ACTION_MENU_TOUCHPAD_PRESS:
#endif
if(!m_activeOffers.empty())
{
int selectedShopItem = (m_selectedSlot + m_offersStartIndex);
if( selectedShopItem < m_activeOffers.size() )
{
MerchantRecipe *activeRecipe = m_activeOffers.at(selectedShopItem).first;
if(!activeRecipe->isDeprecated())
{
// Do we have the ingredients?
shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->localplayers[getPad()];
int buyAMatches = player->inventory->countMatches(buyAItem);
int buyBMatches = player->inventory->countMatches(buyBItem);
if( (buyAItem != NULL && buyAMatches >= buyAItem->count) && (buyBItem == NULL || buyBMatches >= buyBItem->count) )
{
// 4J-JEV: Fix for PS4 #7111: [PATCH 1.12] Trading Librarian villagers for multiple ‘Enchanted Books’ will cause the title to crash.
int actualShopItem = m_activeOffers.at(selectedShopItem).second;
m_merchant->notifyTrade(activeRecipe);
// Remove the items we are purchasing with
player->inventory->removeResources(buyAItem);
player->inventory->removeResources(buyBItem);
// Add the item we have purchased
shared_ptr<ItemInstance> result = activeRecipe->getSellItem()->copy();
if(!player->inventory->add( result ) )
{
player->drop(result);
}
// Send a packet to the server
player->connection->send( shared_ptr<TradeItemPacket>( new TradeItemPacket(m_menu->containerId, actualShopItem) ) );
updateDisplay();
}
}
}
}
handled = true;
break;
case ACTION_MENU_LEFT:
handled = true;
if(m_selectedSlot == 0)
{
if(m_offersStartIndex > 0)
{
--m_offersStartIndex;
changed = true;
}
}
else
{
--m_selectedSlot;
changed = true;
moveSelector(false);
}
break;
case ACTION_MENU_RIGHT:
handled = true;
if(m_selectedSlot == (DISPLAY_TRADES_COUNT - 1))
{
if((m_offersStartIndex + DISPLAY_TRADES_COUNT) < m_activeOffers.size())
{
++m_offersStartIndex;
changed = true;
}
}
else
{
++m_selectedSlot;
changed = true;
moveSelector(true);
}
break;
}
if (changed)
{
updateDisplay();
int selectedShopItem = (m_selectedSlot + m_offersStartIndex);
if( selectedShopItem < m_activeOffers.size() )
{
int actualShopItem = m_activeOffers.at(selectedShopItem).second;
m_menu->setSelectionHint(actualShopItem);
ByteArrayOutputStream rawOutput;
DataOutputStream output(&rawOutput);
output.writeInt(actualShopItem);
Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())));
}
}
return handled;
}
void IUIScene_TradingMenu::handleTick()
{
int offerCount = 0;
MerchantRecipeList *offers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]);
if (offers != NULL)
{
offerCount = offers->size();
if(!m_bHasUpdatedOnce)
{
updateDisplay();
}
}
showScrollRightArrow( (m_offersStartIndex + DISPLAY_TRADES_COUNT) < m_activeOffers.size());
showScrollLeftArrow(m_offersStartIndex > 0);
}
void IUIScene_TradingMenu::updateDisplay()
{
int iA = -1;
MerchantRecipeList *unfilteredOffers = m_merchant->getOffers(Minecraft::GetInstance()->localplayers[getPad()]);
if (unfilteredOffers != NULL)
{
m_activeOffers.clear();
int unfilteredIndex = 0;
int firstValidTrade = INT_MAX;
for(AUTO_VAR(it, unfilteredOffers->begin()); it != unfilteredOffers->end(); ++it)
{
MerchantRecipe *recipe = *it;
if(!recipe->isDeprecated())
{
m_activeOffers.push_back( pair<MerchantRecipe *,int>(recipe,unfilteredIndex));
firstValidTrade = min(firstValidTrade,unfilteredIndex);
}
++unfilteredIndex;
}
if(!m_bHasUpdatedOnce)
{
if(firstValidTrade != 0 && firstValidTrade < unfilteredOffers->size())
{
m_menu->setSelectionHint(firstValidTrade);
ByteArrayOutputStream rawOutput;
DataOutputStream output(&rawOutput);
output.writeInt(firstValidTrade);
Minecraft::GetInstance()->getConnection(getPad())->send(shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_SELECTION_PACKET, rawOutput.toByteArray())));
}
}
if( (m_offersStartIndex + DISPLAY_TRADES_COUNT) > m_activeOffers.size())
{
m_offersStartIndex = m_activeOffers.size() - DISPLAY_TRADES_COUNT;
if(m_offersStartIndex < 0) m_offersStartIndex = 0;
}
for(unsigned int i = 0; i < DISPLAY_TRADES_COUNT; ++i)
{
int offerIndex = i + m_offersStartIndex;
bool showRedBox = false;
if(offerIndex < m_activeOffers.size())
{
showRedBox = !canMake(m_activeOffers.at(offerIndex).first);
setTradeItem(i, m_activeOffers.at(offerIndex).first->getSellItem() );
}
else
{
setTradeItem(i, nullptr);
}
setTradeRedBox( i, showRedBox);
}
int selectedShopItem = (m_selectedSlot + m_offersStartIndex);
if( selectedShopItem < m_activeOffers.size() )
{
MerchantRecipe *activeRecipe = m_activeOffers.at(selectedShopItem).first;
wstring wsTemp;
// 4J-PB - need to get the villager type here
wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM);
wsTemp = replaceAll(wsTemp,L"{*VILLAGER_TYPE*}",m_merchant->getDisplayName());
int iPos=wsTemp.find(L"%s");
wsTemp.replace(iPos,2,activeRecipe->getSellItem()->getHoverName());
setTitle(wsTemp.c_str());
vector<HtmlString> *offerDescription = GetItemDescription(activeRecipe->getSellItem());
setOfferDescription(offerDescription);
shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
setRequest1Item(buyAItem);
setRequest2Item(buyBItem);
if(buyAItem != NULL) setRequest1Name(buyAItem->getHoverName());
else setRequest1Name(L"");
if(buyBItem != NULL) setRequest2Name(buyBItem->getHoverName());
else setRequest2Name(L"");
bool canMake = true;
shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->localplayers[getPad()];
int buyAMatches = player->inventory->countMatches(buyAItem);
if(buyAMatches > 0)
{
setRequest1RedBox(buyAMatches < buyAItem->count);
canMake = buyAMatches > buyAItem->count;
}
else
{
setRequest1RedBox(true);
canMake = false;
}
int buyBMatches = player->inventory->countMatches(buyBItem);
if(buyBMatches > 0)
{
setRequest2RedBox(buyBMatches < buyBItem->count);
canMake = canMake && buyBMatches > buyBItem->count;
}
else
{
if(buyBItem!=NULL)
{
setRequest2RedBox(true);
canMake = false;
}
else
{
setRequest2RedBox(buyBItem != NULL);
canMake = canMake && buyBItem == NULL;
}
}
if(canMake) iA = IDS_TOOLTIPS_TRADE;
}
else
{
setTitle(m_merchant->getDisplayName());
setRequest1Name(L"");
setRequest2Name(L"");
setRequest1RedBox(false);
setRequest2RedBox(false);
setRequest1Item(nullptr);
setRequest2Item(nullptr);
vector<HtmlString> offerDescription;
setOfferDescription(&offerDescription);
}
m_bHasUpdatedOnce = true;
}
ui.SetTooltips(getPad(), iA, IDS_TOOLTIPS_EXIT);
}
bool IUIScene_TradingMenu::canMake(MerchantRecipe *recipe)
{
bool canMake = false;
if (recipe != NULL)
{
if(recipe->isDeprecated()) return false;
shared_ptr<ItemInstance> buyAItem = recipe->getBuyAItem();
shared_ptr<ItemInstance> buyBItem = recipe->getBuyBItem();
shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->localplayers[getPad()];
int buyAMatches = player->inventory->countMatches(buyAItem);
if(buyAMatches > 0)
{
canMake = buyAMatches >= buyAItem->count;
}
else
{
canMake = buyAItem == NULL;
}
int buyBMatches = player->inventory->countMatches(buyBItem);
if(buyBMatches > 0)
{
canMake = canMake && buyBMatches >= buyBItem->count;
}
else
{
canMake = canMake && buyBItem == NULL;
}
}
return canMake;
}
void IUIScene_TradingMenu::setRequest1Item(shared_ptr<ItemInstance> item)
{
}
void IUIScene_TradingMenu::setRequest2Item(shared_ptr<ItemInstance> item)
{
}
void IUIScene_TradingMenu::setTradeItem(int index, shared_ptr<ItemInstance> item)
{
}
vector<HtmlString> *IUIScene_TradingMenu::GetItemDescription(shared_ptr<ItemInstance> item)
{
vector<HtmlString> *lines = item->getHoverText(nullptr, false);
// Add rarity to first line
if (lines->size() > 0)
{
lines->at(0).color = item->getRarity()->color;
}
return lines;
}
void IUIScene_TradingMenu::HandleInventoryUpdated()
{
updateDisplay();
}
@@ -0,0 +1,61 @@
#pragma once
#include "..\Minecraft.World\MerchantMenu.h"
class MerchantRecipe;
class IUIScene_TradingMenu
{
protected:
MerchantMenu *m_menu;
shared_ptr<Merchant> m_merchant;
vector< pair<MerchantRecipe *,int> > m_activeOffers;
int m_validOffersCount;
int m_selectedSlot;
int m_offersStartIndex;
bool m_bHasUpdatedOnce;
eTutorial_State m_previousTutorialState;
static const int DISPLAY_TRADES_COUNT = 7;
static const int BUY_A = MerchantMenu::USE_ROW_SLOT_END;
static const int BUY_B = BUY_A + 1;
static const int TRADES_START = BUY_B + 1;
protected:
IUIScene_TradingMenu();
bool handleKeyDown(int iPad, int iAction, bool bRepeat);
void handleTick();
virtual void showScrollRightArrow(bool show) = 0;
virtual void showScrollLeftArrow(bool show) = 0;
virtual void moveSelector(bool right) = 0;
virtual void setRequest1Name(const wstring &name) = 0;
virtual void setRequest2Name(const wstring &name) = 0;
virtual void setTitle(const wstring &name) = 0;
virtual void setRequest1RedBox(bool show) = 0;
virtual void setRequest2RedBox(bool show) = 0;
virtual void setTradeRedBox(int index, bool show) = 0;
virtual void setOfferDescription(vector<HtmlString> *description) = 0;
virtual void setRequest1Item(shared_ptr<ItemInstance> item);
virtual void setRequest2Item(shared_ptr<ItemInstance> item);
virtual void setTradeItem(int index, shared_ptr<ItemInstance> item);
void updateDisplay();
void HandleInventoryUpdated();
private:
bool canMake(MerchantRecipe *recipe);
vector<HtmlString> *GetItemDescription(shared_ptr<ItemInstance> item);
public:
shared_ptr<Merchant> getMerchant();
virtual int getPad() = 0;
};
+126
View File
@@ -0,0 +1,126 @@
#pragma once
#include "UIEnums.h"
#include "UIStructs.h"
#include "UIBitmapFont.h"
#include "UITTFFont.h"
#include "UIScene.h"
#include "UILayer.h"
#include "UIGroup.h"
#include "UIController.h"
#include "UIControl.h"
#include "UIControl_Base.h"
#include "UIControl_Button.h"
#include "UIControl_CheckBox.h"
#include "UIControl_Slider.h"
#include "UIControl_Label.h"
#include "UIControl_TextInput.h"
#include "UIControl_SlotList.h"
#include "UIControl_Cursor.h"
#include "UIControl_ButtonList.h"
#include "UIControl_Progress.h"
#include "UIControl_TexturePackList.h"
#include "UIControl_LeaderboardList.h"
#include "UIControl_SaveList.h"
#include "UIControl_PlayerList.h"
#include "UIControl_BitmapIcon.h"
#include "UIControl_DLCList.h"
#include "UIControl_HTMLLabel.h"
#include "UIControl_DynamicLabel.h"
#include "UIControl_MinecraftPlayer.h"
#include "UIControl_MinecraftHorse.h"
#include "UIControl_PlayerSkinPreview.h"
#include "UIControl_EnchantmentButton.h"
#include "UIControl_EnchantmentBook.h"
#include "UIControl_SpaceIndicatorBar.h"
#include "UIControl_BeaconEffectButton.h"
#ifdef __PSVITA__
#include "UIControl_Touch.h"
#endif
#include "UIScene_HUD.h"
#include "UIComponent_Panorama.h"
#include "UIComponent_Logo.h"
#include "UIComponent_Tooltips.h"
#include "UIComponent_TutorialPopup.h"
#include "UIComponent_Chat.h"
#include "UIComponent_PressStartToPlay.h"
#include "UIComponent_MenuBackground.h"
#include "UIScene_QuadrantSignin.h"
#include "UIScene_MessageBox.h"
#include "UIScene_Timer.h"
#include "UIScene_Keyboard.h"
#include "UIScene_DebugOverlay.h"
#include "UIScene_DebugOptions.h"
#include "UIComponent_DebugUIConsole.h"
#include "UIComponent_DebugUIMarketingGuide.h"
#include "UIScene_DebugSetCamera.h"
#include "UIScene_DebugCreateSchematic.h"
#include "UIScene_TrialExitUpsell.h"
#include "UIScene_Intro.h"
#include "UIScene_SaveMessage.h"
#include "UIScene_MainMenu.h"
#include "UIScene_LoadMenu.h"
#include "UIScene_JoinMenu.h"
#include "UIScene_LoadOrJoinMenu.h"
#include "UIScene_CreateWorldMenu.h"
#include "UIScene_LaunchMoreOptionsMenu.h"
#include "UIScene_FullscreenProgress.h"
#include "UIScene_LeaderboardsMenu.h"
#include "UIScene_DLCMainMenu.h"
#include "UIScene_DLCOffersMenu.h"
#include "UIScene_ReinstallMenu.h"
#include "UIScene_HelpAndOptionsMenu.h"
#include "UIScene_SettingsMenu.h"
#include "UIScene_SettingsOptionsMenu.h"
#include "UIScene_SettingsAudioMenu.h"
#include "UIScene_SettingsControlMenu.h"
#include "UIScene_SettingsGraphicsMenu.h"
#include "UIScene_SettingsUIMenu.h"
#include "UIScene_SkinSelectMenu.h"
#include "UIScene_HowToPlayMenu.h"
#include "UIScene_LanguageSelector.h"
#include "UIScene_HowToPlay.h"
#include "UIScene_ControlsMenu.h"
#include "UIScene_Credits.h"
#include "UIScene_PauseMenu.h"
#include "UIScene_AbstractContainerMenu.h"
#include "UIScene_BrewingStandMenu.h"
#include "UIScene_ContainerMenu.h"
#include "UIScene_DispenserMenu.h"
#include "UIScene_EnchantingMenu.h"
#include "UIScene_InventoryMenu.h"
#include "UIScene_FurnaceMenu.h"
#include "UIScene_CreativeMenu.h"
#include "UIScene_TradingMenu.h"
#include "UIScene_AnvilMenu.h"
#include "UIScene_HorseInventoryMenu.h"
#include "UIScene_HopperMenu.h"
#include "UIScene_BeaconMenu.h"
#include "UIScene_FireworksMenu.h"
#include "UIScene_CraftingMenu.h"
#include "UIScene_SignEntryMenu.h"
#include "UIScene_ConnectingProgress.h"
#include "UIScene_DeathMenu.h"
#include "UIScene_InGameInfoMenu.h"
#include "UIScene_InGameHostOptionsMenu.h"
#include "UIScene_InGamePlayerOptionsMenu.h"
#if defined(_XBOX_ONE) || defined(__ORBIS__)
#include "UIScene_InGameSaveManagementMenu.h"
#endif
#include "UIScene_TeleportMenu.h"
#include "UIScene_EndPoem.h"
#include "UIScene_EULA.h"
#include "UIScene_NewUpdateMessage.h"
+364
View File
@@ -0,0 +1,364 @@
#include "stdafx.h"
#include "BufferedImage.h"
#include "UIFontData.h"
#include <unordered_set>
#include "UIBitmapFont.h"
/////////////////////////////
// UI Abstract Bitmap Font //
/////////////////////////////
UIAbstractBitmapFont::~UIAbstractBitmapFont()
{
if (m_registered) IggyFontRemoveUTF8( m_fontname.c_str(),-1,IGGY_FONTFLAG_none );
delete m_bitmapFontProvider;
}
UIAbstractBitmapFont::UIAbstractBitmapFont(const string &fontname)
{
m_fontname = fontname;
m_registered = false;
m_bitmapFontProvider = new IggyBitmapFontProvider();
m_bitmapFontProvider->get_font_metrics = &UIAbstractBitmapFont::GetFontMetrics_Callback;
m_bitmapFontProvider->get_glyph_for_codepoint = &UIAbstractBitmapFont::GetCodepointGlyph_Callback;
m_bitmapFontProvider->get_glyph_metrics = &UIAbstractBitmapFont::GetGlyphMetrics_Callback;
m_bitmapFontProvider->is_empty = &UIAbstractBitmapFont::IsGlyphEmpty_Callback;
m_bitmapFontProvider->get_kerning = &UIAbstractBitmapFont::GetKerningForGlyphPair_Callback;
m_bitmapFontProvider->can_bitmap = &UIAbstractBitmapFont::CanProvideBitmap_Callback;
m_bitmapFontProvider->get_bitmap = &UIAbstractBitmapFont::GetGlyphBitmap_Callback;
m_bitmapFontProvider->free_bitmap = &UIAbstractBitmapFont::FreeGlyphBitmap_Callback;
m_bitmapFontProvider->userdata = this;
}
void UIAbstractBitmapFont::registerFont()
{
if (!m_registered)
{
// 4J-JEV: These only need registering the once when we first use this font in Iggy.
m_bitmapFontProvider->num_glyphs = m_numGlyphs;
IggyFontInstallBitmapUTF8( m_bitmapFontProvider, m_fontname.c_str(), -1, IGGY_FONTFLAG_none );
m_registered = true;
}
// 4J-JEV: Reset the font redirect to these fonts (we must do this everytime in-case we switched away elsewhere).
IggyFontSetIndirectUTF8( m_fontname.c_str(), -1, IGGY_FONTFLAG_all, m_fontname.c_str(), -1, IGGY_FONTFLAG_none );
}
IggyFontMetrics * RADLINK UIAbstractBitmapFont::GetFontMetrics_Callback(void *user_context,IggyFontMetrics *metrics)
{
return ((UIAbstractBitmapFont *) user_context)->GetFontMetrics(metrics);
}
S32 RADLINK UIAbstractBitmapFont::GetCodepointGlyph_Callback(void *user_context,U32 codepoint)
{
return ((UIAbstractBitmapFont *) user_context)->GetCodepointGlyph(codepoint);
}
IggyGlyphMetrics * RADLINK UIAbstractBitmapFont::GetGlyphMetrics_Callback(void *user_context,S32 glyph,IggyGlyphMetrics *metrics)
{
return ((UIAbstractBitmapFont *) user_context)->GetGlyphMetrics(glyph,metrics);
}
rrbool RADLINK UIAbstractBitmapFont::IsGlyphEmpty_Callback(void *user_context,S32 glyph)
{
return ((UIAbstractBitmapFont *) user_context)->IsGlyphEmpty(glyph);
}
F32 RADLINK UIAbstractBitmapFont::GetKerningForGlyphPair_Callback(void *user_context,S32 first_glyph,S32 second_glyph)
{
return ((UIAbstractBitmapFont *) user_context)->GetKerningForGlyphPair(first_glyph,second_glyph);
}
rrbool RADLINK UIAbstractBitmapFont::CanProvideBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale)
{
return ((UIAbstractBitmapFont *) user_context)->CanProvideBitmap(glyph,pixel_scale);
}
rrbool RADLINK UIAbstractBitmapFont::GetGlyphBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap)
{
return ((UIAbstractBitmapFont *) user_context)->GetGlyphBitmap(glyph,pixel_scale,bitmap);
}
void RADLINK UIAbstractBitmapFont::FreeGlyphBitmap_Callback(void *user_context,S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap)
{
return ((UIAbstractBitmapFont *) user_context)->FreeGlyphBitmap(glyph,pixel_scale,bitmap);
}
UIBitmapFont::UIBitmapFont( SFontData &sfontdata )
: UIAbstractBitmapFont( sfontdata.m_strFontName )
{
m_numGlyphs = sfontdata.m_uiGlyphCount;
BufferedImage bimg(sfontdata.m_wstrFilename);
int *bimgData = bimg.getData();
m_cFontData = new CFontData(sfontdata, bimgData);
//delete [] bimgData;
}
UIBitmapFont::~UIBitmapFont()
{
m_cFontData->release();
}
//Callback function type for returning vertical font metrics
IggyFontMetrics *UIBitmapFont::GetFontMetrics(IggyFontMetrics *metrics)
{
//Description
// Vertical metrics for a font
//Members
// ascent - extent of characters above baseline (positive)
// descent - extent of characters below baseline (positive)
// line_gap - spacing between one row's descent and the next line's ascent
// average_glyph_width_for_tab_stops - spacing of "average" character for computing default tab stops
// largest_glyph_bbox_y1 - lowest point below baseline of any character in the font
metrics->ascent = m_cFontData->getFontData()->m_fAscent;
metrics->descent = m_cFontData->getFontData()->m_fDescent;
metrics->average_glyph_width_for_tab_stops = 8.0f;
// This is my best guess, there's no reference to a specific glyph here
// so aren't these just exactly the same.
metrics->largest_glyph_bbox_y1 = metrics->descent;
// metrics->line_gap; // 4J-JEV: Sean said this does nothing.
return metrics;
}
//Callback function type for mapping 32-bit unicode code point to internal font glyph number; use IGGY_GLYPH_INVALID to mean "invalid character"
S32 UIBitmapFont::GetCodepointGlyph(U32 codepoint)
{
// 4J-JEV: Change "right single quotation marks" to apostrophies.
if (codepoint == 0x2019) codepoint = 0x27;
return m_cFontData->getGlyphId(codepoint);
}
//Callback function type for returning horizontal metrics for each glyph
IggyGlyphMetrics * UIBitmapFont::GetGlyphMetrics(S32 glyph,IggyGlyphMetrics *metrics)
{
// 4J-JEV: Information about 'Glyph Metrics'.
// http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-3.html - Overview.
// http://en.wikipedia.org/wiki/Kerning#Kerning_values - 'Font Units'
//Description
// Horizontal metrics for a glyph
//Members
// x0 y0 x1 y1 - bounding box
// advance - horizontal distance to move character origin after drawing this glyph
/* 4J-JEV: *IMPORTANT*
*
* I believe these are measured wrt the scale mentioned in GetGlyphBitmap
* i.e. 1.0f == pixel_scale,
*
* However we do not have that information here, then all these values need to be
* the same for every scale in this font.
*
* We have 2 scales of bitmap glyph, and we can only scale these up by powers of 2
* otherwise the fonts will become blurry. The appropriate glyph is chosen in
* 'GetGlyphBitmap' however we need to set the horizontal sizes here.
*/
float glyphAdvance = m_cFontData->getAdvance(glyph);
// 4J-JEV: Anything outside this measurement will be
// cut off if it's at the start or end of the row.
metrics->x0 = 0.0f;
if ( m_cFontData->glyphIsWhitespace(glyph) )
metrics->x1 = 0.0f;
else
metrics->x1 = glyphAdvance;
// The next Glyph just starts right after this one.
metrics->advance = glyphAdvance;
//app.DebugPrintf("[UIBitmapFont] GetGlyphMetrics:\n\tmetrics->advance == %f,\n", metrics->advance);
// These don't do anything either.
metrics->y0 = 0.0f; metrics->y1 = 1.0f;
return metrics;
}
//Callback function type that should return true iff the glyph has no visible elements
rrbool UIBitmapFont::IsGlyphEmpty (S32 glyph)
{
if (m_cFontData->glyphIsWhitespace(glyph)) return true;
return false;//app.DebugPrintf("Is glyph %d empty? %s\n",glyph,isEmpty?"TRUE":"FALSE");
}
//Callback function type for returning the kerning amount for a given pair of glyphs
F32 UIBitmapFont::GetKerningForGlyphPair(S32 first_glyph,S32 second_glyph)
{
//UIBitmapFont *uiFont = (UIBitmapFont *) user_context;
//app.DebugPrintf("Get kerning for glyph pair %d,%d\n",first_glyph,second_glyph);
// 4J-JEV: Yet another field that doesn't do anything.
// Only set out of paranoia.
return 0.0f;
}
//Callback function type used for reporting whether a bitmap supports a given glyph at the given scale
rrbool UIBitmapFont::CanProvideBitmap(S32 glyph,F32 pixel_scale)
{
//app.DebugPrintf("Can provide bitmap for glyph %d at scale %f? %s\n",glyph,pixel_scale,canProvideBitmap?"TRUE":"FALSE");
return true;
}
// Description
// Callback function type used for getting the bitmap for a given glyph
// Parameters
// glyph The glyph to compute/get the bitmap for
// pixel_scale The scale factor (pseudo point size) requested by the textfield,adjusted for display resolution
// bitmap The structure to store the bitmap into
rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap)
{
//Description
// Data structure used to return to Iggy the bitmap to use for a glyph
//Members
// pixels_one_per_byte - pixels startin with the top-left-most; 0 is transparent and 255 is opaque
// width_in_pixels - this is the width of the bitmap data
// height_in_pixels - this is the height of the bitmap data
// stride_in_bytes - the distance from one row to the next
// oversample - this is the amount of oversampling (0 or 1 = not oversample,2 = 2x oversampled,4 = 4x oversampled)
// point_sample - if true,the bitmap will be drawn with point sampling; if false,it will be drawn with bilinear
// top_left_x - the offset of the top left corner from the character origin
// top_left_y - the offset of the top left corner from the character origin
// pixel_scale_correct - the pixel_scale at which this character should be displayed at displayed_width_in_pixels
// pixel_scale_min - the smallest pixel_scale to allow using this character (scaled down)
// pixel_scale_max - the largest pixels cale to allow using this character (scaled up)
// user_context_for_free - you can use this to store data to access on the corresponding free call
int row = 0,col = 0;
m_cFontData->getPos(glyph,row,col);
// Skip to glyph start.
bitmap->pixels_one_per_byte = m_cFontData->topLeftPixel(row,col);
// Choose a reasonable glyph scale.
float glyphScale = 1.0f, truePixelScale = 1.0f / m_cFontData->getFontData()->m_fAdvPerPixel;
F32 targetPixelScale = pixel_scale;
//if(!RenderManager.IsWidescreen())
//{
// // Fix for different scales in 480
// targetPixelScale = pixel_scale*2/3;
//}
while ( (0.5f + glyphScale) * truePixelScale < targetPixelScale)
glyphScale++;
// 4J-JEV: Debug code to check which font sizes are being used.
#if (!defined _CONTENT_PACKAGE) && (VERBOSE_FONT_OUTPUT > 0)
struct DebugData
{
string name;
long scale;
long mul;
bool operator==(const DebugData& dd) const
{
if ( name.compare(dd.name) != 0 ) return false;
else if (scale != dd.scale) return false;
else if (mul != dd.mul) return false;
else return true;
}
};
static long long lastPrint = System::currentTimeMillis();
static unordered_set<DebugData> debug_fontSizesRequested;
{
DebugData dData = { m_cFontData->getFontName(), (long) pixel_scale, (long) glyphScale };
debug_fontSizesRequested.insert(dData);
if ( (lastPrint - System::currentTimeMillis()) > VERBOSE_FONT_OUTPUT )
{
app.DebugPrintf("<UIBitmapFont> Requested font/sizes:\n");
unordered_set<DebugData>::iterator itr;
for ( itr = debug_fontSizesRequested.begin();
itr != debug_fontSizesRequested.end();
itr++
)
{
app.DebugPrintf("<UIBitmapFont>\t- %s:%i\t(x%i)\n", itr->name.c_str(), itr->scale, itr->mul);
}
lastPrint = System::currentTimeMillis();
debug_fontSizesRequested.clear();
}
}
#endif
//app.DebugPrintf("Request glyph_%d (U+%.4X) at %f, converted to %f (%f)\n",
// glyph, GetUnicode(glyph), pixel_scale, targetPixelScale, glyphScale);
// It is not necessary to shrink the glyph width here
// as its already been done in 'GetGlyphMetrics' by:
// > metrics->x1 = m_kerningTable[glyph] * ratio;
bitmap->width_in_pixels = m_cFontData->getFontData()->m_uiGlyphWidth;
bitmap->height_in_pixels = m_cFontData->getFontData()->m_uiGlyphHeight;
/* 4J-JEV: This is to do with glyph placement,
* and not the position in the archive.
* I don't know why the 0.65 is needed, or what it represents,
* although it doesn't look like its the baseline.
*/
bitmap->top_left_x = 0;
// 4J-PB - this was chopping off the top of the characters, so accented ones were losing a couple of pixels at the top
// DaveK has reduced the height of the accented capitalised characters, and we've dropped this from 0.65 to 0.64
bitmap->top_left_y = -((S32) m_cFontData->getFontData()->m_uiGlyphHeight) * m_cFontData->getFontData()->m_fAscent;
bitmap->oversample = 0;
bitmap->point_sample = true;
// 4J-JEV:
// pixel_scale == font size chosen in flash.
// bitmap->pixel_scale_correct = (float) m_glyphHeight; // Scales the glyph to desired size.
// bitmap->pixel_scale_correct = pixel_scale; // Always the same size (not desired size).
// bitmap->pixel_scale_correct = pixel_scale * 0.5; // Doubles original size.
// bitmap->pixel_scale_correct = pixel_scale * 2; // Halves original size.
// Actual scale, and possible range of scales.
bitmap->pixel_scale_correct = pixel_scale / glyphScale;
bitmap->pixel_scale_max = 99.0f;
bitmap->pixel_scale_min = 0.0f;
/* 4J-JEV: Some of Sean's code.
int glyphScaleMin = 1;
int glyphScaleMax = 3;
float actualScale = pixel_scale / glyphScale;
bitmap->pixel_scale_correct = actualScale;
bitmap->pixel_scale_min = actualScale * glyphScaleMin * 0.999f;
bitmap->pixel_scale_max = actualScale * glyphScaleMax * 1.001f; */
// 4J-JEV: Nothing to do with glyph placement,
// entirely to do with cropping your glyph out of an archive.
bitmap->stride_in_bytes = m_cFontData->getFontData()->m_uiGlyphMapX;
// 4J-JEV: Additional information needed to release memory afterwards.
bitmap->user_context_for_free = NULL;
return true;
}
//Callback function type for freeing a bitmap shape returned by GetGlyphBitmap
void UIBitmapFont::FreeGlyphBitmap(S32 glyph,F32 pixel_scale,IggyBitmapCharacter *bitmap)
{
// We don't need to free anything,it just comes from the archive.
//app.DebugPrintf("Free bitmap for glyph %d at scale %f\n",glyph,pixel_scale);
}
+75
View File
@@ -0,0 +1,75 @@
#pragma once
struct SFontData;
class CFontData;
#define VERBOSE_FONT_OUTPUT 0
// const int BITMAP_FONT_LANGUAGES = XC_LANGUAGE_ENGLISH
// | XC_LANGUAGE_GERMAN
// | XC_LANGUAGE_FRENCH
// | XC_LANGUAGE_SPANISH
// | XC_LANGUAGE_ITALIAN
// | XC_LANGUAGE_PORTUGUESE
// | XC_LANGUAGE_BRAZILIAN;
using namespace std;
class UIAbstractBitmapFont
{
protected:
string m_fontname;
IggyBitmapFontProvider *m_bitmapFontProvider;
bool m_registered;
unsigned int m_numGlyphs;
public:
UIAbstractBitmapFont(const string &fontname);
~UIAbstractBitmapFont();
void registerFont();
// Virtual Functions.
virtual IggyFontMetrics *GetFontMetrics(IggyFontMetrics *metrics) = 0;
virtual S32 GetCodepointGlyph(U32 codepoint) = 0;
virtual IggyGlyphMetrics *GetGlyphMetrics(S32 glyph, IggyGlyphMetrics *metrics) = 0;
virtual rrbool IsGlyphEmpty(S32 glyph) = 0;
virtual F32 GetKerningForGlyphPair(S32 first_glyph, S32 second_glyph) = 0;
virtual rrbool CanProvideBitmap(S32 glyph, F32 pixel_scale) = 0;
virtual rrbool GetGlyphBitmap(S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap) = 0;
virtual void FreeGlyphBitmap(S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap) = 0;
// Static Callbacks
// Just wrappers for the virtual functions.
static IggyFontMetrics * RADLINK GetFontMetrics_Callback(void *user_context, IggyFontMetrics *metrics);
static S32 RADLINK GetCodepointGlyph_Callback(void *user_context, U32 codepoint);
static IggyGlyphMetrics * RADLINK GetGlyphMetrics_Callback(void *user_context, S32 glyph, IggyGlyphMetrics *metrics);
static rrbool RADLINK IsGlyphEmpty_Callback(void *user_context, S32 glyph);
static F32 RADLINK GetKerningForGlyphPair_Callback(void *user_context, S32 first_glyph, S32 second_glyph);
static rrbool RADLINK CanProvideBitmap_Callback(void *user_context, S32 glyph, F32 pixel_scale);
static rrbool RADLINK GetGlyphBitmap_Callback(void *user_context, S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap);
static void RADLINK FreeGlyphBitmap_Callback(void *user_context, S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap);
};
class UIBitmapFont : public UIAbstractBitmapFont
{
protected:
CFontData *m_cFontData;
public:
UIBitmapFont(SFontData &sfontdata);
~UIBitmapFont();
virtual IggyFontMetrics * GetFontMetrics(IggyFontMetrics *metrics);
virtual S32 GetCodepointGlyph(U32 codepoint);
virtual IggyGlyphMetrics * GetGlyphMetrics(S32 glyph, IggyGlyphMetrics *metrics);
virtual rrbool IsGlyphEmpty(S32 glyph);
virtual F32 GetKerningForGlyphPair(S32 first_glyph, S32 second_glyph);
virtual rrbool CanProvideBitmap(S32 glyph, F32 pixel_scale);
virtual rrbool GetGlyphBitmap(S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap);
virtual void FreeGlyphBitmap(S32 glyph, F32 pixel_scale, IggyBitmapCharacter *bitmap);
};
@@ -0,0 +1,157 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_Chat.h"
#include "..\..\Minecraft.h"
#include "..\..\Gui.h"
UIComponent_Chat::UIComponent_Chat(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i)
{
m_labelChatText[i].init(L"");
}
m_labelJukebox.init(L"");
addTimer(0, 100);
}
wstring UIComponent_Chat::getMoviePath()
{
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
m_bSplitscreen = true;
return L"ComponentChatSplit";
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
m_bSplitscreen = false;
return L"ComponentChat";
break;
}
}
void UIComponent_Chat::handleTimerComplete(int id)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
bool anyVisible = false;
if(pMinecraft->localplayers[m_iPad]!= NULL)
{
Gui *pGui = pMinecraft->gui;
//DWORD messagesToDisplay = min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) );
for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
{
float opacity = pGui->getOpacity(m_iPad, i);
if( opacity > 0 )
{
m_controlLabelBackground[i].setOpacity(opacity);
m_labelChatText[i].setOpacity(opacity);
m_labelChatText[i].setLabel( pGui->getMessage(m_iPad,i) );
anyVisible = true;
}
else
{
m_controlLabelBackground[i].setOpacity(0);
m_labelChatText[i].setOpacity(0);
m_labelChatText[i].setLabel(L"");
}
}
if(pGui->getJukeboxOpacity(m_iPad) > 0) anyVisible = true;
m_labelJukebox.setOpacity( pGui->getJukeboxOpacity(m_iPad) );
m_labelJukebox.setLabel( pGui->getJukeboxMessage(m_iPad) );
}
else
{
for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
{
m_controlLabelBackground[i].setOpacity(0);
m_labelChatText[i].setOpacity(0);
m_labelChatText[i].setLabel(L"");
}
m_labelJukebox.setOpacity( 0 );
}
setVisible(anyVisible);
}
void UIComponent_Chat::render(S32 width, S32 height, C4JRender::eViewportType viewport)
{
if(m_bSplitscreen)
{
S32 xPos = 0;
S32 yPos = 0;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
yPos = (S32)(ui.getScreenHeight() / 2);
break;
}
ui.setupRenderPosition(xPos, yPos);
S32 tileXStart = 0;
S32 tileYStart = 0;
S32 tileWidth = width;
S32 tileHeight = height;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
tileHeight = (S32)(ui.getScreenHeight());
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
tileYStart = (S32)(m_movieHeight / 2);
break;
}
IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
IggyPlayerDrawTilesStart ( getMovie() );
m_renderWidth = tileWidth;
m_renderHeight = tileHeight;
IggyPlayerDrawTile ( getMovie() ,
tileXStart ,
tileYStart ,
tileXStart + tileWidth ,
tileYStart + tileHeight ,
0 );
IggyPlayerDrawTilesEnd ( getMovie() );
}
else
{
UIScene::render(width, height, viewport);
}
}
@@ -0,0 +1,66 @@
#pragma once
#include "UIScene.h"
#define CHAT_LINES_COUNT 10
class UIComponent_Chat : public UIScene
{
private:
bool m_bSplitscreen;
protected:
UIControl_Label m_labelChatText[CHAT_LINES_COUNT];
UIControl_Label m_labelJukebox;
UIControl m_controlLabelBackground[CHAT_LINES_COUNT];
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT(m_labelChatText[0],"Label1")
UI_MAP_ELEMENT(m_labelChatText[1],"Label2")
UI_MAP_ELEMENT(m_labelChatText[2],"Label3")
UI_MAP_ELEMENT(m_labelChatText[3],"Label4")
UI_MAP_ELEMENT(m_labelChatText[4],"Label5")
UI_MAP_ELEMENT(m_labelChatText[5],"Label6")
UI_MAP_ELEMENT(m_labelChatText[6],"Label7")
UI_MAP_ELEMENT(m_labelChatText[7],"Label8")
UI_MAP_ELEMENT(m_labelChatText[8],"Label9")
UI_MAP_ELEMENT(m_labelChatText[9],"Label10")
UI_MAP_ELEMENT(m_controlLabelBackground[0],"Label1Background")
UI_MAP_ELEMENT(m_controlLabelBackground[1],"Label2Background")
UI_MAP_ELEMENT(m_controlLabelBackground[2],"Label3Background")
UI_MAP_ELEMENT(m_controlLabelBackground[3],"Label4Background")
UI_MAP_ELEMENT(m_controlLabelBackground[4],"Label5Background")
UI_MAP_ELEMENT(m_controlLabelBackground[5],"Label6Background")
UI_MAP_ELEMENT(m_controlLabelBackground[6],"Label7Background")
UI_MAP_ELEMENT(m_controlLabelBackground[7],"Label8Background")
UI_MAP_ELEMENT(m_controlLabelBackground[8],"Label9Background")
UI_MAP_ELEMENT(m_controlLabelBackground[9],"Label10Background")
UI_MAP_ELEMENT(m_labelJukebox,"Jukebox")
UI_END_MAP_ELEMENTS_AND_NAMES()
public:
UIComponent_Chat(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_Chat;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
// RENDERING
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
protected:
void handleTimerComplete(int id);
};
@@ -0,0 +1,39 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_DebugUIConsole.h"
UIComponent_DebugUIConsole::UIComponent_DebugUIConsole(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_bTextChanged = false;
}
wstring UIComponent_DebugUIConsole::getMoviePath()
{
return L"DebugUIConsoleComponent";
}
void UIComponent_DebugUIConsole::tick()
{
UIScene::tick();
if(m_bTextChanged)
{
m_bTextChanged = false;
for(unsigned int i = 0; i < 10 && i < m_textList.size(); ++i)
{
m_labels[i].setLabel(m_textList[i]);
}
}
}
void UIComponent_DebugUIConsole::addText(const string &text)
{
if(!text.empty() && text.compare("\n") != 0)
{
if(m_textList.size() >= 10) m_textList.pop_front();
m_textList.push_back(text);
m_bTextChanged = true;
}
}
@@ -0,0 +1,49 @@
#pragma once
#include "UIScene.h"
#include "UIControl_Label.h"
class UIComponent_DebugUIConsole : public UIScene
{
private:
UIControl_Label m_labels[10];
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_labels[0], "consoleLine1")
UI_MAP_ELEMENT( m_labels[1], "consoleLine2")
UI_MAP_ELEMENT( m_labels[2], "consoleLine3")
UI_MAP_ELEMENT( m_labels[3], "consoleLine4")
UI_MAP_ELEMENT( m_labels[4], "consoleLine5")
UI_MAP_ELEMENT( m_labels[5], "consoleLine6")
UI_MAP_ELEMENT( m_labels[6], "consoleLine7")
UI_MAP_ELEMENT( m_labels[7], "consoleLine8")
UI_MAP_ELEMENT( m_labels[8], "consoleLine9")
UI_MAP_ELEMENT( m_labels[9], "consoleLine10")
UI_END_MAP_ELEMENTS_AND_NAMES()
deque<string> m_textList;
bool m_bTextChanged;
public:
UIComponent_DebugUIConsole(int iPad, void *initData, UILayer *parentLayer);
virtual void tick();
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_DebugUIConsole;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
void addText(const string &text);
};
@@ -0,0 +1,33 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_DebugUIMarketingGuide.h"
UIComponent_DebugUIMarketingGuide::UIComponent_DebugUIMarketingGuide(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (F64)0; // WIN64
#if defined _XBOX
value[0].number = (F64)1;
#elif defined _DURANGO
value[0].number = (F64)2;
#elif defined __PS3__
value[0].number = (F64)3;
#elif defined __ORBIS__
value[0].number = (F64)4;
#elif defined __PSVITA__
value[0].number = (F64)5;
#elif defined _WINDOWS64
value[0].number = (F64)0;
#endif
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlatform , 1 , value );
}
wstring UIComponent_DebugUIMarketingGuide::getMoviePath()
{
return L"DebugUIMarketingGuide";
}
@@ -0,0 +1,34 @@
#pragma once
#include "UIScene.h"
#include "UIControl_Label.h"
class UIComponent_DebugUIMarketingGuide : public UIScene
{
private:
IggyName m_funcSetPlatform;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_NAME( m_funcSetPlatform, L"SetPlatform")
UI_END_MAP_ELEMENTS_AND_NAMES()
public:
UIComponent_DebugUIMarketingGuide(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_DebugUIMarketingGuide;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
};
@@ -0,0 +1,30 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_Logo.h"
UIComponent_Logo::UIComponent_Logo(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
}
wstring UIComponent_Logo::getMoviePath()
{
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
return L"ComponentLogoSplit";
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
return L"ComponentLogo";
break;
}
}
@@ -0,0 +1,25 @@
#pragma once
#include "UIScene.h"
class UIComponent_Logo : public UIScene
{
public:
UIComponent_Logo(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_Logo;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
};
@@ -0,0 +1,103 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_MenuBackground.h"
UIComponent_MenuBackground::UIComponent_MenuBackground(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
m_bSplitscreen = false;
// Setup all the Iggy references we need for this scene
initialiseMovie();
}
wstring UIComponent_MenuBackground::getMoviePath()
{ switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
m_bSplitscreen = true;
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
m_bSplitscreen = false;
break;
}
// We use the fullscreen one even in splitscreen, just draw different parts of it
return L"MenuBackground";
}
void UIComponent_MenuBackground::render(S32 width, S32 height, C4JRender::eViewportType viewport)
{
if(m_bSplitscreen)
{
S32 xPos = 0;
S32 yPos = 0;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
yPos = (S32)(ui.getScreenHeight() / 2);
break;
}
ui.setupRenderPosition(xPos, yPos);
S32 tileXStart = 0;
S32 tileYStart = 0;
S32 tileWidth = width;
S32 tileHeight = height;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
tileHeight = (S32)(ui.getScreenHeight());
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
tileYStart = (S32)(m_movieHeight / 2);
break;
}
IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
IggyPlayerDrawTilesStart ( getMovie() );
m_renderWidth = tileWidth;
m_renderHeight = tileHeight;
IggyPlayerDrawTile ( getMovie() ,
tileXStart ,
tileYStart ,
tileXStart + tileWidth ,
tileYStart + tileHeight ,
0 );
IggyPlayerDrawTilesEnd ( getMovie() );
}
else
{
UIScene::render(width, height, viewport);
}
}
@@ -0,0 +1,30 @@
#pragma once
#include "UIScene.h"
class UIComponent_MenuBackground : public UIScene
{
private:
bool m_bSplitscreen;
public:
UIComponent_MenuBackground(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_MenuBackground;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
// RENDERING
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
};
@@ -0,0 +1,144 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_Panorama.h"
#include "Minecraft.h"
#include "MultiPlayerLevel.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.dimension.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.storage.h"
UIComponent_Panorama::UIComponent_Panorama(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_bShowingDay = true;
while(!m_hasTickedOnce) tick();
}
wstring UIComponent_Panorama::getMoviePath()
{
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
m_bSplitscreen = true;
return L"PanoramaSplit";
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
m_bSplitscreen = false;
return L"Panorama";
break;
}
}
void UIComponent_Panorama::tick()
{
if(!hasMovie()) return;
Minecraft *pMinecraft = Minecraft::GetInstance();
EnterCriticalSection(&pMinecraft->m_setLevelCS);
if(pMinecraft->level!=NULL)
{
__int64 i64TimeOfDay =0;
// are we in the Nether? - Leave the time as 0 if we are, so we show daylight
if(pMinecraft->level->dimension->id==0)
{
i64TimeOfDay = pMinecraft->level->getLevelData()->getGameTime() % 24000;
}
if(i64TimeOfDay>14000)
{
setPanorama(false);
}
else
{
setPanorama(true);
}
}
else
{
setPanorama(true);
}
LeaveCriticalSection(&pMinecraft->m_setLevelCS);
UIScene::tick();
}
void UIComponent_Panorama::render(S32 width, S32 height, C4JRender::eViewportType viewport)
{
bool specialViewport = (viewport == C4JRender::VIEWPORT_TYPE_SPLIT_TOP) ||
(viewport == C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM) ||
(viewport == C4JRender::VIEWPORT_TYPE_SPLIT_LEFT) ||
(viewport == C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT);
if(m_bSplitscreen && specialViewport)
{
S32 xPos = 0;
S32 yPos = 0;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
break;
}
ui.setupRenderPosition(xPos, yPos);
if((viewport == C4JRender::VIEWPORT_TYPE_SPLIT_LEFT) || (viewport == C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT))
{
// Need to render at full height, but only the left side of the scene
S32 tileXStart = 0;
S32 tileYStart = 0;
S32 tileWidth = width;
S32 tileHeight = (S32)(ui.getScreenHeight());
IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
IggyPlayerDrawTilesStart ( getMovie() );
m_renderWidth = tileWidth;
m_renderHeight = tileHeight;
IggyPlayerDrawTile ( getMovie() ,
tileXStart ,
tileYStart ,
tileXStart + tileWidth ,
tileYStart + tileHeight ,
0 );
IggyPlayerDrawTilesEnd ( getMovie() );
}
else
{
// Need to render at full height, and full width. But compressed into the viewport
IggyPlayerSetDisplaySize( getMovie(), ui.getScreenWidth(), ui.getScreenHeight()/2 );
IggyPlayerDraw( getMovie() );
}
}
else
{
UIScene::render(width, height, viewport);
}
}
void UIComponent_Panorama::setPanorama(bool isDay)
{
if(isDay != m_bShowingDay)
{
m_bShowingDay = isDay;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = isDay;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcShowPanoramaDay , 1 , value );
}
}
@@ -0,0 +1,40 @@
#pragma once
#include "UIScene.h"
class UIComponent_Panorama : public UIScene
{
private:
bool m_bSplitscreen;
bool m_bShowingDay;
protected:
IggyName m_funcShowPanoramaDay;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_NAME(m_funcShowPanoramaDay, L"ShowPanoramaDay");
UI_END_MAP_ELEMENTS_AND_NAMES()
public:
UIComponent_Panorama(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_Panorama;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
virtual void tick();
// RENDERING
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
private:
void setPanorama(bool isDay);
};
@@ -0,0 +1,164 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_PressStartToPlay.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
UIComponent_PressStartToPlay::UIComponent_PressStartToPlay(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_showingSaveIcon = false;
m_showingAutosaveTimer = false;
m_showingTrialTimer = false;
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
{
m_showingPressStart[i] = false;
}
m_trialTimer = L"";
m_autosaveTimer = L"";
m_labelTrialTimer.init(L"");
m_labelTrialTimer.setVisible(false);
// 4J-JEV: This object is persistent, so this string needs to be able to handle language changes.
#ifdef __ORBIS__
m_labelPressStart.init( (UIString) [] { return replaceAll(app.GetString(IDS_PRESS_X_TO_JOIN), L"{*CONTROLLER_VK_A*}", app.GetVKReplacement(VK_PAD_A) ); });
#elif defined _XBOX_ONE
m_labelPressStart.init( (UIString) [] { return replaceAll(app.GetString(IDS_PRESS_START_TO_JOIN), L"{*CONTROLLER_VK_START*}", app.GetVKReplacement(VK_PAD_START) ); });
#else
m_labelPressStart.init(IDS_PRESS_START_TO_JOIN);
#endif
m_controlSaveIcon.setVisible(false);
m_controlPressStartPanel.setVisible(false);
m_playerDisplayName.setVisible(false);
}
wstring UIComponent_PressStartToPlay::getMoviePath()
{
return L"PressStartToPlay";
}
void UIComponent_PressStartToPlay::handleReload()
{
// 4J Stu - It's possible these could change during the reload, so can't use the normal controls refresh of it's state
m_controlSaveIcon.setVisible(m_showingSaveIcon);
m_labelTrialTimer.setVisible(m_showingAutosaveTimer);
m_labelTrialTimer.setLabel(m_autosaveTimer);
m_labelTrialTimer.setVisible(m_showingTrialTimer);
m_labelTrialTimer.setLabel(m_trialTimer);
bool showPressStart = false;
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
{
bool show = m_showingPressStart[i];
showPressStart |= show;
if(show)
{
addTimer(0,3000);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = i;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcShowController , 1 , value );
}
}
m_controlPressStartPanel.setVisible(showPressStart);
}
void UIComponent_PressStartToPlay::handleTimerComplete(int id)
{
m_controlPressStartPanel.setVisible(false);
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
{
m_showingPressStart[i] = false;
}
ui.ClearPressStart();
}
void UIComponent_PressStartToPlay::showPressStart(int iPad, bool show)
{
m_showingPressStart[iPad] = show;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_controlPressStartPanel.setVisible(show);
if(show)
{
addTimer(0,3000);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iPad;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcShowController , 1 , value );
}
}
}
void UIComponent_PressStartToPlay::setTrialTimer(const wstring &label)
{
m_trialTimer = label;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_labelTrialTimer.setLabel(label);
}
}
void UIComponent_PressStartToPlay::showTrialTimer(bool show)
{
m_showingTrialTimer = show;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_labelTrialTimer.setVisible(show);
}
}
void UIComponent_PressStartToPlay::setAutosaveTimer(const wstring &label)
{
m_autosaveTimer = label;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_labelTrialTimer.setLabel(label);
}
}
void UIComponent_PressStartToPlay::showAutosaveTimer(bool show)
{
m_showingAutosaveTimer = show;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_labelTrialTimer.setVisible(show);
}
}
void UIComponent_PressStartToPlay::showSaveIcon(bool show)
{
m_showingSaveIcon = show;
if(!ui.IsExpectingOrReloadingSkin() && hasMovie())
{
m_controlSaveIcon.setVisible(show);
}
else
{
if(show) app.DebugPrintf("Tried to show save icon while texture pack reload was in progress\n");
}
}
void UIComponent_PressStartToPlay::showPlayerDisplayName(bool show)
{
#ifdef _XBOX_ONE
if(show)
{
m_playerDisplayName.setLabel(ProfileManager.GetDisplayName(ProfileManager.GetPrimaryPad()));
}
m_playerDisplayName.setVisible(show);
#else
m_playerDisplayName.setVisible(false);
#endif
}
@@ -0,0 +1,60 @@
#pragma once
#include "UIScene.h"
class UIComponent_PressStartToPlay : public UIScene
{
private:
bool m_showingSaveIcon;
bool m_showingAutosaveTimer;
bool m_showingTrialTimer;
bool m_showingPressStart[XUSER_MAX_COUNT];
wstring m_trialTimer;
wstring m_autosaveTimer;
protected:
UIControl_Label m_labelTrialTimer, m_labelPressStart, m_playerDisplayName;
UIControl m_controlSaveIcon, m_controlPressStartPanel;
IggyName m_funcShowController;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT(m_labelTrialTimer, "TrialTimer")
UI_MAP_ELEMENT(m_controlSaveIcon, "SaveIcon")
UI_MAP_ELEMENT(m_playerDisplayName, "PlayerName")
UI_MAP_ELEMENT(m_controlPressStartPanel, "MainPanel")
UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlPressStartPanel)
UI_MAP_ELEMENT(m_labelPressStart, "PressStartLabel" )
UI_END_MAP_CHILD_ELEMENTS()
UI_MAP_NAME(m_funcShowController, L"ShowController");
UI_END_MAP_ELEMENTS_AND_NAMES()
public:
UIComponent_PressStartToPlay(int iPad, void *initData, UILayer *parentLayer);
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_PressStartToPlay;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
virtual void handleReload();
virtual void handleTimerComplete(int id);
void showPressStart(int iPad, bool show);
void setTrialTimer(const wstring &label);
void showTrialTimer(bool show);
void setAutosaveTimer(const wstring &label);
void showAutosaveTimer(bool show);
void showSaveIcon(bool show);
void showPlayerDisplayName(bool show);
};
@@ -0,0 +1,534 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_Tooltips.h"
UIComponent_Tooltips::UIComponent_Tooltips(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
for(int j=0;j<ACTION_MAX_MENU;j++)
{
m_overrideSFX[i][j]=false;
}
}
// Setup all the Iggy references we need for this scene
initialiseMovie();
#ifdef __PSVITA__
// initialise vita touch controls with ids
for(unsigned int i = 0; i < ETouchInput_Count; ++i)
{
m_TouchController[i].init(i);
}
#endif
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
if(InputManager.IsCircleCrossSwapped())
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = true;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetABSwap , 1 , value );
}
#endif
}
wstring UIComponent_Tooltips::getMoviePath()
{
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
m_bSplitscreen = true;
return L"ToolTipsSplit";
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
m_bSplitscreen = false;
return L"ToolTips";
break;
}
}
F64 UIComponent_Tooltips::getSafeZoneHalfWidth()
{
float width = ui.getScreenWidth();
float safeWidth = 0.0f;
#ifndef __PSVITA__
// 85% safezone for tooltips in either SD mode
if( !RenderManager.IsHiDef() )
{
// 85% safezone
safeWidth = m_movieWidth * (0.15f / 2);
}
else
{
// 90% safezone
safeWidth = width * (0.1f / 2);
}
#endif
return safeWidth;
}
void UIComponent_Tooltips::updateSafeZone()
{
// Distance from edge
F64 safeTop = 0.0;
F64 safeBottom = 0.0;
F64 safeLeft = 0.0;
F64 safeRight = 0.0;
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
safeTop = getSafeZoneHalfHeight();
safeLeft = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
safeBottom = getSafeZoneHalfHeight();
safeLeft = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
safeLeft = getSafeZoneHalfWidth();
safeBottom = getSafeZoneHalfHeight();
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
safeRight = getSafeZoneHalfWidth();
safeBottom = getSafeZoneHalfHeight();
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
safeTop = getSafeZoneHalfHeight();
safeLeft = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
safeTop = getSafeZoneHalfHeight();
safeRight = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
safeBottom = getSafeZoneHalfHeight();
safeLeft = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
safeBottom = getSafeZoneHalfHeight();
safeRight = getSafeZoneHalfWidth();
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
safeTop = getSafeZoneHalfHeight();
safeBottom = getSafeZoneHalfHeight();
safeLeft = getSafeZoneHalfWidth();
safeRight = getSafeZoneHalfWidth();
break;
}
setSafeZone(safeTop, safeBottom, safeLeft, safeRight);
}
void UIComponent_Tooltips::tick()
{
UIScene::tick();
// set the opacity of the tooltip items
unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity);
float fVal;
if(ucAlpha<80)
{
// if we are in a menu, set the minimum opacity for tooltips to 15%
if(ui.GetMenuDisplayed(m_iPad) && (ucAlpha<15))
{
ucAlpha=15;
}
// check if we have the timer running for the opacity
unsigned int uiOpacityTimer=app.GetOpacityTimer(m_iPad);
if(uiOpacityTimer!=0)
{
if(uiOpacityTimer<10)
{
float fStep=(80.0f-(float)ucAlpha)/10.0f;
fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep));
}
else
{
fVal=0.01f*80.0f;
}
}
else
{
fVal=0.01f*(float)ucAlpha;
}
}
else
{
// if we are in a menu, set the minimum opacity for tooltips to 15%
if(ui.GetMenuDisplayed(m_iPad) && (ucAlpha<15))
{
ucAlpha=15;
}
fVal=0.01f*(float)ucAlpha;
}
setOpacity(fVal);
bool layoutChanges = false;
for (int i = 0; i < eToolTipNumButtons; i++)
{
if ( !ui.IsReloadingSkin() && m_tooltipValues[i].show && m_tooltipValues[i].label.needsUpdating() )
{
layoutChanges = true;
_SetTooltip(i, m_tooltipValues[i].label, m_tooltipValues[i].show, true);
m_tooltipValues[i].label.setUpdated();
}
}
if (layoutChanges) _Relayout();
}
void UIComponent_Tooltips::render(S32 width, S32 height, C4JRender::eViewportType viewport)
{
if((ProfileManager.GetLockedProfile()!=-1) && !ui.GetMenuDisplayed(m_iPad) && (app.GetGameSettings(m_iPad,eGameSetting_Tooltips)==0 || app.GetGameSettings(m_iPad,eGameSetting_DisplayHUD)==0))
{
return;
}
if(m_bSplitscreen)
{
S32 xPos = 0;
S32 yPos = 0;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
yPos = (S32)(ui.getScreenHeight() / 2);
break;
}
ui.setupRenderPosition(xPos, yPos);
S32 tileXStart = 0;
S32 tileYStart = 0;
S32 tileWidth = width;
S32 tileHeight = height;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
tileHeight = (S32)(ui.getScreenHeight());
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
tileWidth = (S32)(ui.getScreenWidth());
tileYStart = (S32)(m_movieHeight / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
tileYStart = (S32)(m_movieHeight / 2);
break;
}
IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
IggyPlayerDrawTilesStart ( getMovie() );
m_renderWidth = tileWidth;
m_renderHeight = tileHeight;
IggyPlayerDrawTile ( getMovie() ,
tileXStart ,
tileYStart ,
tileXStart + tileWidth ,
tileYStart + tileHeight ,
0 );
IggyPlayerDrawTilesEnd ( getMovie() );
}
else
{
UIScene::render(width, height, viewport);
}
}
void UIComponent_Tooltips::SetTooltipText( unsigned int tooltip, int iTextID )
{
if( _SetTooltip(tooltip, iTextID) ) _Relayout();
}
void UIComponent_Tooltips::SetEnableTooltips( bool bVal )
{
}
void UIComponent_Tooltips::ShowTooltip( unsigned int tooltip, bool show )
{
if(show != m_tooltipValues[tooltip].show)
{
_SetTooltip(tooltip, L"", show);
_Relayout();
}
}
void UIComponent_Tooltips::SetTooltips( int iA, int iB, int iX, int iY , int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, bool forceUpdate)
{
bool needsRelayout = false;
needsRelayout = _SetTooltip( eToolTipButtonA, iA ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonB, iB ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonX, iX ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonY, iY ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonLT, iLT ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonRT, iRT ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonLB, iLB ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonRB, iRB ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonLS, iLS ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonRS, iRS ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonRS, iRS ) || needsRelayout;
needsRelayout = _SetTooltip( eToolTipButtonBack, iBack ) || needsRelayout;
if (needsRelayout) _Relayout();
}
void UIComponent_Tooltips::EnableTooltip( unsigned int tooltip, bool enable )
{
}
bool UIComponent_Tooltips::_SetTooltip(unsigned int iToolTip, int iTextID)
{
bool changed = false;
if(iTextID != m_tooltipValues[iToolTip].iString || (iTextID > -1 && !m_tooltipValues[iToolTip].show))
{
m_tooltipValues[iToolTip].iString = iTextID;
changed = true;
if(iTextID > -1) _SetTooltip(iToolTip, iTextID, true);
else if(iTextID == -2) _SetTooltip(iToolTip, L"", true);
else _SetTooltip(iToolTip, L"", false);
}
return changed;
}
void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, UIString label, bool show, bool force)
{
if(!force && !show && !m_tooltipValues[iToolTipId].show)
{
return;
}
m_tooltipValues[iToolTipId].show = show;
m_tooltipValues[iToolTipId].label = label;
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iToolTipId;
value[1].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[1].string16 = stringVal;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = show;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetTooltip , 3 , value );
//app.DebugPrintf("Actual tooltip update!\n");
}
void UIComponent_Tooltips::_Relayout()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcUpdateLayout, 0 , NULL );
#ifdef __PSVITA__
// rebuild touchboxes
ui.TouchBoxRebuild(this);
#endif
}
#ifdef __PSVITA__
void UIComponent_Tooltips::handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased)
{
//app.DebugPrintf("ToolTip Touch ID = %i\n", iId);
bool handled = false;
// 4J - TomK no tooltips no touch!
if((!ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) && (app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Tooltips) == 0))
return;
// perform action on release
if(bReleased)
{
switch(iId)
{
case ETouchInput_Touch_A:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_X\n", iId);
if(InputManager.IsCircleCrossSwapped())
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O);
else
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X);
break;
case ETouchInput_Touch_B:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_O\n", iId);
if(InputManager.IsCircleCrossSwapped())
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X);
else
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O);
break;
case ETouchInput_Touch_X:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SQUARE\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SQUARE);
break;
case ETouchInput_Touch_Y:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_TRIANGLE\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_TRIANGLE);
break;
case ETouchInput_Touch_LT:
/* not in use on vita */
app.DebugPrintf("ToolTip no action\n", iId);
break;
case ETouchInput_Touch_RightTrigger:
app.DebugPrintf("ToolTip no action\n", iId);
/* no action */
break;
case ETouchInput_Touch_LeftBumper:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_L1\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_L1);
break;
case ETouchInput_Touch_RightBumper:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_R1\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_R1);
break;
case ETouchInput_Touch_LeftStick:
app.DebugPrintf("ToolTip no action\n", iId);
/* no action */
break;
case ETouchInput_Touch_RightStick:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_DPAD_DOWN\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_DPAD_DOWN);
break;
case ETouchInput_Touch_Select:
app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SELECT\n", iId);
InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SELECT);
break;
}
}
}
#endif
void UIComponent_Tooltips::handleReload()
{
app.DebugPrintf("UIComponent_Tooltips::handleReload\n");
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
if(InputManager.IsCircleCrossSwapped())
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = true;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetABSwap , 1 , value );
}
#endif
for(unsigned int i = 0; i < eToolTipNumButtons; ++i)
{
_SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show, true);
}
_Relayout();
}
void UIComponent_Tooltips::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
{
if( (0 <= iPad) && (iPad <= 3) && m_overrideSFX[iPad][key] )
{
// don't play a sound for this action
switch(key)
{
case ACTION_MENU_A:
case ACTION_MENU_OK:
case ACTION_MENU_PAGEUP:
case ACTION_MENU_PAGEDOWN:
case ACTION_MENU_X:
case ACTION_MENU_Y:
case ACTION_MENU_B:
case ACTION_MENU_CANCEL:
case ACTION_MENU_LEFT_SCROLL:
case ACTION_MENU_RIGHT_SCROLL:
case ACTION_MENU_LEFT:
case ACTION_MENU_RIGHT:
case ACTION_MENU_UP:
case ACTION_MENU_DOWN:
sendInputToMovie(key, repeat, pressed, released);
break;
}
}
else
{
switch(key)
{
case ACTION_MENU_OK:
case ACTION_MENU_CANCEL:
// 4J-PB - We get both A and OK, and B and Cancel, so only play a sound on one of them.
sendInputToMovie(key, repeat, pressed, released);
break;
case ACTION_MENU_A:
case ACTION_MENU_X:
case ACTION_MENU_Y:
// 4J-PB - play a Press sound
//CD - Removed, causes a sound on all presses
/*if(pressed)
{
ui.PlayUISFX(eSFX_Press);
}*/
sendInputToMovie(key, repeat, pressed, released);
break;
case ACTION_MENU_B:
// 4J-PB - play a Press sound
//CD - Removed, causes a sound on all presses
/*if(pressed)
{
ui.PlayUISFX(eSFX_Back);
}*/
sendInputToMovie(key, repeat, pressed, released);
break;
case ACTION_MENU_LEFT_SCROLL:
case ACTION_MENU_RIGHT_SCROLL:
//CD - Removed, causes a sound on all presses
/*if(pressed)
{
ui.PlayUISFX(eSFX_Scroll);
}*/
sendInputToMovie(key, repeat, pressed, released);
break;
case ACTION_MENU_PAGEUP:
case ACTION_MENU_PAGEDOWN:
case ACTION_MENU_LEFT:
case ACTION_MENU_RIGHT:
case ACTION_MENU_UP:
case ACTION_MENU_DOWN:
sendInputToMovie(key, repeat, pressed, released);
break;
}
}
}
void UIComponent_Tooltips::overrideSFX(int iPad, int key, bool bVal)
{
m_overrideSFX[iPad][key]=bVal;
}
@@ -0,0 +1,116 @@
#pragma once
#include "UIScene.h"
class UIComponent_Tooltips : public UIScene
{
private:
bool m_bSplitscreen;
protected:
typedef struct _TooltipValues
{
bool show;
int iString;
UIString label;
_TooltipValues()
{
show = false;
iString = -1;
}
} TooltipValues;
TooltipValues m_tooltipValues[eToolTipNumButtons];
IggyName m_funcSetTooltip, m_funcSetOpacity, m_funcSetABSwap, m_funcUpdateLayout;
#ifdef __PSVITA__
enum ETouchInput
{
ETouchInput_Touch_A,
ETouchInput_Touch_B,
ETouchInput_Touch_X,
ETouchInput_Touch_Y,
ETouchInput_Touch_LT,
ETouchInput_Touch_RightTrigger,
ETouchInput_Touch_LeftBumper,
ETouchInput_Touch_RightBumper,
ETouchInput_Touch_LeftStick,
ETouchInput_Touch_RightStick,
ETouchInput_Touch_Select,
ETouchInput_Count,
};
UIControl_Touch m_TouchController[ETouchInput_Count];
#endif
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
#ifdef __PSVITA__
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_A], "Touch_A")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_B], "Touch_B")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_X], "Touch_X")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_Y], "Touch_Y")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_LT], "Touch_LT")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_RightTrigger], "Touch_RightTrigger")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_LeftBumper], "Touch_LeftBumper")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_RightBumper], "Touch_RightBumper")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_LeftStick], "Touch_LeftStick")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_RightStick], "Touch_RightStick")
UI_MAP_ELEMENT( m_TouchController[ETouchInput_Touch_Select], "Touch_Select")
#endif
UI_MAP_NAME( m_funcSetTooltip, L"SetToolTip")
UI_MAP_NAME( m_funcSetOpacity, L"SetOpacity")
UI_MAP_NAME( m_funcSetABSwap, L"SetABSwap")
UI_MAP_NAME( m_funcUpdateLayout, L"UpdateLayout")
UI_END_MAP_ELEMENTS_AND_NAMES()
virtual wstring getMoviePath();
virtual F64 getSafeZoneHalfWidth();
public:
UIComponent_Tooltips(int iPad, void *initData, UILayer *parentLayer);
virtual EUIScene getSceneType() { return eUIComponent_Tooltips;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
virtual void updateSafeZone();
virtual void tick();
// RENDERING
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
virtual void SetTooltipText( unsigned int tooltip, int iTextID );
virtual void SetEnableTooltips( bool bVal );
virtual void ShowTooltip( unsigned int tooltip, bool show );
virtual void SetTooltips( int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, int iRS=-1, int iBack=-1, bool forceUpdate = false);
virtual void EnableTooltip( unsigned int tooltip, bool enable );
virtual void handleReload();
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
void overrideSFX(int iPad, int key, bool bVal);
private:
bool _SetTooltip(unsigned int iToolTip, int iTextID);
void _SetTooltip(unsigned int iToolTipId, UIString label, bool show, bool force = false);
void _Relayout();
bool m_overrideSFX[XUSER_MAX_COUNT][ACTION_MAX_MENU];
#ifdef __PSVITA__
virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased);
#endif
};
@@ -0,0 +1,545 @@
#include "stdafx.h"
#include "UI.h"
#include "UIComponent_TutorialPopup.h"
#include "..\..\Common\Tutorial\Tutorial.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "..\..\Minecraft.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_interactScene = NULL;
m_lastInteractSceneMoved = NULL;
m_lastSceneMovedLeft = false;
m_bAllowFade = false;
m_iconItem = nullptr;
m_iconIsFoil = false;
m_bContainerMenuVisible = false;
m_bSplitscreenGamertagVisible = false;
m_iconType = e_ICON_TYPE_IGGY;
m_labelDescription.init(L"");
}
wstring UIComponent_TutorialPopup::getMoviePath()
{
switch( m_parentLayer->getViewport() )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
return L"TutorialPopupSplit";
break;
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
default:
return L"TutorialPopup";
break;
}
}
void UIComponent_TutorialPopup::UpdateTutorialPopup()
{
// has the Splitscreen Gamertag visibility been changed? Re-Adjust Layout to prevent overlaps!
if(m_bSplitscreenGamertagVisible != (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags) != 0))
{
m_bSplitscreenGamertagVisible = (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags) != 0);
handleReload();
}
}
void UIComponent_TutorialPopup::handleReload()
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = (bool)((app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0) && !m_bContainerMenuVisible); // 4J - TomK - Offset for splitscreen gamertag?
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAdjustLayout, 1 , value );
setupIconHolder(m_iconType);
}
void UIComponent_TutorialPopup::SetTutorialDescription(TutorialPopupInfo *info)
{
m_interactScene = info->interactScene;
wstring parsed = _SetIcon(info->icon, info->iAuxVal, info->isFoil, info->desc);
parsed = _SetImage( parsed );
parsed = ParseDescription(m_iPad, parsed);
if(parsed.empty())
{
_SetDescription( info->interactScene, L"", L"", info->allowFade, info->isReminder );
}
else
{
_SetDescription( info->interactScene, parsed, info->title, info->allowFade, info->isReminder );
}
}
void UIComponent_TutorialPopup::RemoveInteractSceneReference(UIScene *scene)
{
if( m_interactScene == scene )
{
m_interactScene = NULL;
}
}
void UIComponent_TutorialPopup::SetVisible(bool visible)
{
m_parentLayer->showComponent(0,eUIComponent_TutorialPopup,visible);
if( visible && m_bAllowFade )
{
//Initialise a timer to fade us out again
app.DebugPrintf("UIComponent_TutorialPopup::SetVisible: setting TUTORIAL_POPUP_FADE_TIMER_ID to %d\n",m_tutorial->GetTutorialDisplayMessageTime());
addTimer(TUTORIAL_POPUP_FADE_TIMER_ID,m_tutorial->GetTutorialDisplayMessageTime());
}
}
bool UIComponent_TutorialPopup::IsVisible()
{
return m_parentLayer->isComponentVisible(eUIComponent_TutorialPopup);
}
void UIComponent_TutorialPopup::handleTimerComplete(int id)
{
switch(id)
{
case TUTORIAL_POPUP_FADE_TIMER_ID:
SetVisible(false);
killTimer(id);
app.DebugPrintf("handleTimerComplete: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
break;
case TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID:
UpdateInteractScenePosition(IsVisible());
killTimer(id);
break;
}
}
void UIComponent_TutorialPopup::_SetDescription(UIScene *interactScene, const wstring &desc, const wstring &title, bool allowFade, bool isReminder)
{
m_interactScene = interactScene;
app.DebugPrintf("Setting m_interactScene to %08x\n", m_interactScene);
if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = NULL;
if(desc.empty())
{
SetVisible( false );
app.DebugPrintf("_SetDescription1: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
killTimer(TUTORIAL_POPUP_FADE_TIMER_ID);
}
else
{
SetVisible( true );
app.DebugPrintf("_SetDescription2: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
if( allowFade )
{
//Initialise a timer to fade us out again
app.DebugPrintf("_SetDescription: setting TUTORIAL_POPUP_FADE_TIMER_ID\n");
addTimer(TUTORIAL_POPUP_FADE_TIMER_ID,m_tutorial->GetTutorialDisplayMessageTime());
}
else
{
app.DebugPrintf("_SetDescription: killing TUTORIAL_POPUP_FADE_TIMER_ID\n");
killTimer(TUTORIAL_POPUP_FADE_TIMER_ID);
}
m_bAllowFade = allowFade;
if(isReminder)
{
wstring text(app.GetString( IDS_TUTORIAL_REMINDER ));
text.append( desc );
stripWhitespaceForHtml( text );
// set the text colour
wchar_t formatting[40];
// 4J Stu - Don't set HTML font size, that's set at design time in flash
//swprintf(formatting, 40, L"<font color=\"#%08x\" size=\"%d\">",app.GetHTMLColour(eHTMLColor_White),m_textFontSize);
swprintf(formatting, 40, L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White));
text = formatting + text;
m_labelDescription.setLabel( text, true );
}
else
{
wstring text(desc);
stripWhitespaceForHtml( text );
// set the text colour
wchar_t formatting[40];
// 4J Stu - Don't set HTML font size, that's set at design time in flash
//swprintf(formatting, 40, L"<font color=\"#%08x\" size=\"%d\">",app.GetHTMLColour(eHTMLColor_White),m_textFontSize);
swprintf(formatting, 40, L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White));
text = formatting + text;
m_labelDescription.setLabel( text, true );
}
m_labelTitle.setLabel( title, true );
m_labelTitle.setVisible(!title.empty());
// read host setting if gamertag is visible or not and pass on to Adjust Layout function (so we can offset it to stay clear of the gamertag)
m_bSplitscreenGamertagVisible = (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = (m_bSplitscreenGamertagVisible && !m_bContainerMenuVisible); // 4J - TomK - Offset for splitscreen gamertag?
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAdjustLayout, 1 , value );
}
}
wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc)
{
wstring temp(desc);
bool isFixedIcon = false;
m_iconIsFoil = isFoil;
if( icon != TUTORIAL_NO_ICON )
{
m_iconIsFoil = false;
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(icon,1,iAuxVal));
}
else
{
m_iconItem = nullptr;
wstring openTag(L"{*ICON*}");
wstring closeTag(L"{*/ICON*}");
int iconTagStartPos = (int)temp.find(openTag);
int iconStartPos = iconTagStartPos + (int)openTag.length();
if( iconTagStartPos > 0 && iconStartPos < (int)temp.length() )
{
int iconEndPos = (int)temp.find( closeTag, iconStartPos );
if(iconEndPos > iconStartPos && iconEndPos < (int)temp.length() )
{
wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos);
vector<wstring> idAndAux = stringSplit(id,L':');
int iconId = _fromString<int>(idAndAux[0]);
if(idAndAux.size() > 1)
{
iAuxVal = _fromString<int>(idAndAux[1]);
}
else
{
iAuxVal = 0;
}
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(iconId,1,iAuxVal));
temp.replace(iconTagStartPos, iconEndPos - iconTagStartPos + closeTag.length(), L"");
}
}
// remove any icon text
else if(temp.find(L"{*CraftingTableIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::workBench_Id,1,0));
}
else if(temp.find(L"{*SticksIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::stick_Id,1,0));
}
else if(temp.find(L"{*PlanksIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::wood_Id,1,0));
}
else if(temp.find(L"{*WoodenShovelIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::shovel_wood_Id,1,0));
}
else if(temp.find(L"{*WoodenHatchetIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::hatchet_wood_Id,1,0));
}
else if(temp.find(L"{*WoodenPickaxeIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::pickAxe_wood_Id,1,0));
}
else if(temp.find(L"{*FurnaceIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::furnace_Id,1,0));
}
else if(temp.find(L"{*WoodenDoorIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::door_wood,1,0));
}
else if(temp.find(L"{*TorchIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::torch_Id,1,0));
}
else if(temp.find(L"{*BoatIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::boat_Id,1,0));
}
else if(temp.find(L"{*FishingRodIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::fishingRod_Id,1,0));
}
else if(temp.find(L"{*FishIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::fish_raw_Id,1,0));
}
else if(temp.find(L"{*MinecartIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Item::minecart_Id,1,0));
}
else if(temp.find(L"{*RailIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::rail_Id,1,0));
}
else if(temp.find(L"{*PoweredRailIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::goldenRail_Id,1,0));
}
else if(temp.find(L"{*StructuresIcon*}")!=wstring::npos)
{
isFixedIcon = true;
setupIconHolder(e_ICON_TYPE_STRUCTURES);
}
else if(temp.find(L"{*ToolsIcon*}")!=wstring::npos)
{
isFixedIcon = true;
setupIconHolder(e_ICON_TYPE_TOOLS);
}
else if(temp.find(L"{*StoneIcon*}")!=wstring::npos)
{
m_iconItem = shared_ptr<ItemInstance>(new ItemInstance(Tile::stone_Id,1,0));
}
else
{
m_iconItem = nullptr;
}
}
if(!isFixedIcon && m_iconItem != NULL) setupIconHolder(e_ICON_TYPE_IGGY);
m_controlIconHolder.setVisible( isFixedIcon || m_iconItem != NULL);
return temp;
}
wstring UIComponent_TutorialPopup::_SetImage(wstring &desc)
{
// 4J Stu - Unused
#if 0
BOOL imageShowAtStart = m_image.IsShown();
wstring openTag(L"{*IMAGE*}");
wstring closeTag(L"{*/IMAGE*}");
int imageTagStartPos = (int)desc.find(openTag);
int imageStartPos = imageTagStartPos + (int)openTag.length();
if( imageTagStartPos > 0 && imageStartPos < (int)desc.length() )
{
int imageEndPos = (int)desc.find( closeTag, imageStartPos );
if(imageEndPos > imageStartPos && imageEndPos < (int)desc.length() )
{
wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos);
m_image.SetImagePath( id.c_str() );
m_image.SetShow( TRUE );
desc.replace(imageTagStartPos, imageEndPos - imageTagStartPos + closeTag.length(), L"");
}
}
else
{
// hide the icon slot
m_image.SetShow( FALSE );
}
BOOL imageShowAtEnd = m_image.IsShown();
if(imageShowAtStart != imageShowAtEnd)
{
float fHeight, fWidth, fIconHeight, fDescHeight, fDescWidth;
m_image.GetBounds(&fWidth,&fIconHeight);
GetBounds(&fWidth,&fHeight);
// 4J Stu - For some reason when we resize the scene it resets the size of the HTML control
// We don't want that to happen, so get it's size before and set it back after
m_description.GetBounds(&fDescWidth,&fDescHeight);
if(imageShowAtEnd)
{
SetBounds(fWidth, fHeight + fIconHeight);
}
else
{
SetBounds(fWidth, fHeight - fIconHeight);
}
m_description.SetBounds(fDescWidth, fDescHeight);
}
#endif
return desc;
}
wstring UIComponent_TutorialPopup::ParseDescription(int iPad, wstring &text)
{
text = replaceAll(text, L"{*CraftingTableIcon*}", L"");
text = replaceAll(text, L"{*SticksIcon*}", L"");
text = replaceAll(text, L"{*PlanksIcon*}", L"");
text = replaceAll(text, L"{*WoodenShovelIcon*}", L"");
text = replaceAll(text, L"{*WoodenHatchetIcon*}", L"");
text = replaceAll(text, L"{*WoodenPickaxeIcon*}", L"");
text = replaceAll(text, L"{*FurnaceIcon*}", L"");
text = replaceAll(text, L"{*WoodenDoorIcon*}", L"");
text = replaceAll(text, L"{*TorchIcon*}", L"");
text = replaceAll(text, L"{*MinecartIcon*}", L"");
text = replaceAll(text, L"{*BoatIcon*}", L"");
text = replaceAll(text, L"{*FishingRodIcon*}", L"");
text = replaceAll(text, L"{*FishIcon*}", L"");
text = replaceAll(text, L"{*RailIcon*}", L"");
text = replaceAll(text, L"{*PoweredRailIcon*}", L"");
text = replaceAll(text, L"{*StructuresIcon*}", L"");
text = replaceAll(text, L"{*ToolsIcon*}", L"");
text = replaceAll(text, L"{*StoneIcon*}", L"");
bool exitScreenshot = false;
size_t pos = text.find(L"{*EXIT_PICTURE*}");
if(pos != wstring::npos) exitScreenshot = true;
text = replaceAll(text, L"{*EXIT_PICTURE*}", L"");
m_controlExitScreenshot.setVisible(exitScreenshot);
/*
#define MINECRAFT_ACTION_RENDER_DEBUG ACTION_INGAME_13
#define MINECRAFT_ACTION_PAUSEMENU ACTION_INGAME_15
#define MINECRAFT_ACTION_SNEAK_TOGGLE ACTION_INGAME_17
*/
return app.FormatHTMLString(iPad,text);
}
void UIComponent_TutorialPopup::UpdateInteractScenePosition(bool visible)
{
if( m_interactScene == NULL ) return;
// 4J-PB - check this players screen section to see if we should allow the animation
bool bAllowAnim=false;
bool isCraftingScene = (m_interactScene->getSceneType() == eUIScene_Crafting2x2Menu) || (m_interactScene->getSceneType() == eUIScene_Crafting3x3Menu);
bool isCreativeScene = (m_interactScene->getSceneType() == eUIScene_CreativeMenu);
bool isTradingScene = (m_interactScene->getSceneType() == eUIScene_TradingMenu);
switch(Minecraft::GetInstance()->localplayers[m_iPad]->m_iScreenSection)
{
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
bAllowAnim=true;
break;
default:
// anim allowed for everything except the crafting 2x2 and 3x3, and the creative menu
if(!isCraftingScene && !isCreativeScene && !isTradingScene)
{
bAllowAnim=true;
}
break;
}
if(bAllowAnim)
{
bool movingLeft = visible;
if( (m_lastInteractSceneMoved != m_interactScene && movingLeft) || ( m_lastInteractSceneMoved == m_interactScene && m_lastSceneMovedLeft != movingLeft ) )
{
if(movingLeft)
{
m_interactScene->slideLeft();
}
else
{
m_interactScene->slideRight();
}
m_lastInteractSceneMoved = m_interactScene;
m_lastSceneMovedLeft = movingLeft;
}
}
}
void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewportType viewport)
{
if(viewport != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{
S32 xPos = 0;
S32 yPos = 0;
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
xPos = (S32)(ui.getScreenWidth() / 2);
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
yPos = (S32)(ui.getScreenHeight() / 2);
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos = (S32)(ui.getScreenWidth() / 2);
yPos = (S32)(ui.getScreenHeight() / 2);
break;
}
//Adjust for safezone
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
yPos += getSafeZoneHalfHeight();
break;
}
switch( viewport )
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos -= getSafeZoneHalfWidth();
break;
}
ui.setupRenderPosition(xPos, yPos);
IggyPlayerSetDisplaySize( getMovie(), width, height );
IggyPlayerDraw( getMovie() );
}
else
{
UIScene::render(width, height, viewport);
}
}
void UIComponent_TutorialPopup::customDraw(IggyCustomDrawCallbackRegion *region)
{
if(m_iconItem != NULL) customDrawSlotControl(region,m_iPad,m_iconItem,1.0f,m_iconItem->isFoil() || m_iconIsFoil,false);
}
void UIComponent_TutorialPopup::setupIconHolder(EIcons icon)
{
app.DebugPrintf("Setting icon holder to %d\n", icon);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (F64)icon;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetupIconHolder , 1 , value );
m_iconType = icon;
}
@@ -0,0 +1,103 @@
#pragma once
#include "UIScene.h"
#define TUTORIAL_POPUP_FADE_TIMER_ID 0
#define TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID 1
#define TUTORIAL_POPUP_MOVE_SCENE_TIME 500
class UIComponent_TutorialPopup : public UIScene
{
private:
// A scene that may be displayed behind the popup that the player is using, that will need shifted so we can see it clearly.
UIScene *m_interactScene, *m_lastInteractSceneMoved;
bool m_lastSceneMovedLeft;
bool m_bAllowFade;
Tutorial *m_tutorial;
shared_ptr<ItemInstance> m_iconItem;
bool m_iconIsFoil;
//int m_iLocalPlayerC;
bool m_bContainerMenuVisible;
bool m_bSplitscreenGamertagVisible;
// Maps to values in AS
enum EIcons
{
e_ICON_TYPE_IGGY = 0,
e_ICON_TYPE_ARMOUR = 1,
e_ICON_TYPE_BREWING = 2,
e_ICON_TYPE_DECORATION = 3,
e_ICON_TYPE_FOOD = 4,
e_ICON_TYPE_MATERIALS = 5,
e_ICON_TYPE_MECHANISMS = 6,
e_ICON_TYPE_MISC = 7,
e_ICON_TYPE_REDSTONE_AND_TRANSPORT = 8,
e_ICON_TYPE_STRUCTURES = 9,
e_ICON_TYPE_TOOLS = 10,
e_ICON_TYPE_TRANSPORT = 11,
};
EIcons m_iconType;
public:
UIComponent_TutorialPopup(int iPad, void *initData, UILayer *parentLayer);
protected:
UIControl_Label m_labelDescription, m_labelTitle;
UIControl m_controlIconHolder;
UIControl m_controlExitScreenshot;
IggyName m_funcAdjustLayout, m_funcSetupIconHolder;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_labelTitle, "Title")
UI_MAP_ELEMENT( m_labelDescription, "Description")
UI_MAP_ELEMENT( m_controlIconHolder, "IconHolder")
UI_MAP_ELEMENT( m_controlExitScreenshot, "ExitScreenShot")
UI_MAP_NAME( m_funcAdjustLayout, L"AdjustLayout")
UI_MAP_NAME( m_funcSetupIconHolder, L"SetupIconHolder")
UI_END_MAP_ELEMENTS_AND_NAMES()
virtual wstring getMoviePath();
public:
virtual EUIScene getSceneType() { return eUIComponent_TutorialPopup;}
// Returns true if this scene handles input
virtual bool stealsFocus() { return false; }
// Returns true if this scene has focus for the pad passed in
virtual bool hasFocus(int iPad) { return false; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
virtual void handleReload();
void SetContainerMenuVisible(bool bContainerMenuVisible) { m_bContainerMenuVisible = bContainerMenuVisible; }
void UpdateTutorialPopup();
void SetTutorial( Tutorial *tutorial ) { m_tutorial = tutorial; }
void SetTutorialDescription(TutorialPopupInfo *info);
void RemoveInteractSceneReference(UIScene *scene);
void SetVisible(bool visible);
bool IsVisible();
// RENDERING
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
virtual void customDraw(IggyCustomDrawCallbackRegion *region);
protected:
void handleTimerComplete(int id);
private:
void _SetDescription(UIScene *interactScene, const wstring &desc, const wstring &title, bool allowFade, bool isReminder);
wstring _SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc);
wstring _SetImage(wstring &desc);
wstring ParseDescription(int iPad, wstring &text);
void UpdateInteractScenePosition(bool visible);
void setupIconHolder(EIcons icon);
};
+153
View File
@@ -0,0 +1,153 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\JavaMath.h"
UIControl::UIControl()
{
m_parentScene = NULL;
m_lastOpacity = 1.0f;
m_controlName = "";
m_isVisible = true;
m_bHidden = false;
m_eControlType = eNoControl;
}
bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
m_parentScene = scene;
m_controlName = controlName;
rrbool res = IggyValuePathMakeNameRef ( &m_iggyPath , parent , controlName.c_str() );
m_nameXPos = registerFastName(L"x");
m_nameYPos = registerFastName(L"y");
m_nameWidth = registerFastName(L"width");
m_nameHeight = registerFastName(L"height");
m_funcSetAlpha = registerFastName(L"SetControlAlpha");
m_nameVisible = registerFastName(L"visible");
F64 fx, fy, fwidth, fheight;
IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , NULL , &fx );
IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , NULL , &fy );
IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth );
IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight );
m_x = (S32)fx;
m_y = (S32)fy;
m_width = (S32)Math::round(fwidth);
m_height = (S32)Math::round(fheight);
return res;
}
#ifdef __PSVITA__
void UIControl::UpdateControl()
{
F64 fx, fy, fwidth, fheight;
IggyValueGetF64RS( getIggyValuePath() , m_nameXPos , NULL , &fx );
IggyValueGetF64RS( getIggyValuePath() , m_nameYPos , NULL , &fy );
IggyValueGetF64RS( getIggyValuePath() , m_nameWidth , NULL , &fwidth );
IggyValueGetF64RS( getIggyValuePath() , m_nameHeight , NULL , &fheight );
m_x = (S32)fx;
m_y = (S32)fy;
m_width = (S32)Math::round(fwidth);
m_height = (S32)Math::round(fheight);
}
#endif // __PSVITA__
void UIControl::ReInit()
{
if(m_lastOpacity != 1.0f)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char *)m_controlName.c_str();
stringVal.length = m_controlName.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_lastOpacity;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, m_parentScene->m_rootPath , m_funcSetAlpha , 2 , value );
}
IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, NULL, m_isVisible );
}
IggyValuePath *UIControl::getIggyValuePath()
{
return &m_iggyPath;
}
S32 UIControl::getXPos()
{
return m_x;
}
S32 UIControl::getYPos()
{
return m_y;
}
S32 UIControl::getWidth()
{
return m_width;
}
S32 UIControl::getHeight()
{
return m_height;
}
void UIControl::setOpacity(float percent)
{
if(percent != m_lastOpacity)
{
m_lastOpacity = percent;
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char *)m_controlName.c_str();
stringVal.length = m_controlName.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_lastOpacity;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, m_parentScene->m_rootPath , m_funcSetAlpha , 2 , value );
}
}
void UIControl::setVisible(bool visible)
{
if(visible != m_isVisible)
{
rrbool succ = IggyValueSetBooleanRS( getIggyValuePath(), m_nameVisible, NULL, visible );
if(succ) m_isVisible = visible;
else app.DebugPrintf("Failed to set visibility for control\n");
}
}
bool UIControl::getVisible()
{
rrbool bVisible = false;
IggyResult result = IggyValueGetBooleanRS ( getIggyValuePath() , m_nameVisible, NULL, &bVisible );
m_isVisible = bVisible;
return bVisible;
}
IggyName UIControl::registerFastName(const wstring &name)
{
return m_parentScene->registerFastName(name);
}
+93
View File
@@ -0,0 +1,93 @@
#pragma once
// This class for any name object in the flash scene
class UIControl
{
public:
enum eUIControlType
{
eNoControl,
eButton,
eButtonList,
eCheckBox,
eCursor,
eDLCList,
eDynamicLabel,
eEnchantmentBook,
eEnchantmentButton,
eHTMLLabel,
eLabel,
eLeaderboardList,
eMinecraftPlayer,
eMinecraftHorse,
ePlayerList,
ePlayerSkinPreview,
eProgress,
eSaveList,
eSlider,
eSlotList,
eTextInput,
eTexturePackList,
eBitmapIcon,
eTouchControl,
};
protected:
eUIControlType m_eControlType;
int m_id;
bool m_bHidden; // set by the Remove call
public:
void setControlType(eUIControlType eType) {m_eControlType=eType;}
eUIControlType getControlType() {return m_eControlType;}
void setId(int iID) { m_id=iID; }
int getId() { return m_id; }
UIScene * getParentScene() {return m_parentScene;}
protected:
IggyValuePath m_iggyPath;
UIScene *m_parentScene;
string m_controlName;
IggyName m_nameXPos, m_nameYPos, m_nameWidth, m_nameHeight;
IggyName m_funcSetAlpha, m_nameVisible;
S32 m_x,m_y,m_width,m_height;
float m_lastOpacity;
bool m_isVisible;
public:
UIControl();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
#ifdef __PSVITA__
void UpdateControl();
void setHidden(bool bHidden) {m_bHidden=bHidden;}
bool getHidden(void) {return m_bHidden;}
#endif
IggyValuePath *getIggyValuePath();
string getControlName() { return m_controlName; }
virtual void tick() {}
virtual void ReInit();
virtual void setFocus(bool focus) {}
S32 getXPos();
S32 getYPos();
S32 getWidth();
S32 getHeight();
void setOpacity(float percent);
void setVisible(bool visible);
bool getVisible();
bool isVisible() { return m_isVisible; }
virtual bool hasFocus() { return false; }
protected:
IggyName registerFastName(const wstring &name);
};
@@ -0,0 +1,108 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\JavaMath.h"
UIControl_Base::UIControl_Base()
{
m_bLabelChanged = false;
m_label;
m_id = 0;
}
bool UIControl_Base::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
bool success = UIControl::setupControl(scene,parent,controlName);
m_setLabelFunc = registerFastName(L"SetLabel");
m_initFunc = registerFastName(L"Init");
m_funcGetLabel = registerFastName(L"GetLabel");
m_funcCheckLabelWidths = registerFastName(L"CheckLabelWidths");
return success;
}
void UIControl_Base::tick()
{
UIControl::tick();
if ( m_label.needsUpdating() || m_bLabelChanged )
{
//app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str());
m_bLabelChanged = false;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*) m_label.c_str();
stringVal.length = m_label.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value );
m_label.setUpdated();
}
}
void UIControl_Base::setLabel(UIString label, bool instant, bool force)
{
if( force || ((!m_label.empty() || !label.empty()) && m_label.compare(label) != 0) ) m_bLabelChanged = true;
m_label = label;
if(m_bLabelChanged && instant)
{
m_bLabelChanged = false;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)m_label.c_str();
stringVal.length = m_label.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value );
}
}
const wchar_t* UIControl_Base::getLabel()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcGetLabel, 0, NULL);
if(result.type == IGGY_DATATYPE_string_UTF16)
{
m_label = wstring((wchar_t *)result.string16.string, result.string16.length);
}
return m_label.c_str();
}
void UIControl_Base::setAllPossibleLabels(int labelCount, wchar_t labels[][256])
{
IggyDataValue result;
IggyDataValue *value = new IggyDataValue[labelCount];
IggyStringUTF16 * stringVal = new IggyStringUTF16[labelCount];
for(unsigned int i = 0; i < labelCount; ++i)
{
stringVal[i].string = (IggyUTF16 *)labels[i];
stringVal[i].length = wcslen(labels[i]);
value[i].type = IGGY_DATATYPE_string_UTF16;
value[i].string16 = stringVal[i];
}
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcCheckLabelWidths , labelCount , value );
delete [] value;
delete [] stringVal;
}
bool UIControl_Base::hasFocus()
{
return m_parentScene->controlHasFocus( this );
}
@@ -0,0 +1,33 @@
#pragma once
#include "UIControl.h"
#include "UIString.h"
// This class maps to the FJ_Base class in actionscript
class UIControl_Base : public UIControl
{
protected:
IggyName m_initFunc;
IggyName m_setLabelFunc;
IggyName m_funcGetLabel;
IggyName m_funcCheckLabelWidths;
bool m_bLabelChanged;
UIString m_label;
public:
UIControl_Base();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
virtual void tick();
virtual void setLabel(UIString label, bool instant = false, bool force = false);
//virtual void setLabel(wstring label, bool instant = false, bool force = false) { this->setLabel(UIString::CONSTANT(label), instant, force); }
const wchar_t* getLabel();
virtual void setAllPossibleLabels(int labelCount, wchar_t labels[][256]);
int getId() { return m_id; }
virtual bool hasFocus();
};
@@ -0,0 +1,121 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_BeaconEffectButton.h"
UIControl_BeaconEffectButton::UIControl_BeaconEffectButton()
{
m_data = 0;
m_icon = 0;
m_selected = false;
m_active = false;
m_focus = false;
}
bool UIControl_BeaconEffectButton::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
bool success = UIControl::setupControl(scene,parent,controlName);
m_funcChangeState = registerFastName(L"ChangeState");
m_funcSetIcon = registerFastName(L"SetIcon");
return success;
}
void UIControl_BeaconEffectButton::SetData(int data, int icon, bool active, bool selected)
{
m_data = data;
m_active = active;
m_selected = selected;
SetIcon(icon);
UpdateButtonState();
}
int UIControl_BeaconEffectButton::GetData()
{
return m_data;
}
void UIControl_BeaconEffectButton::SetButtonSelected(bool selected)
{
if(selected != m_selected)
{
m_selected = selected;
UpdateButtonState();
}
}
bool UIControl_BeaconEffectButton::IsButtonSelected()
{
return m_selected;
}
void UIControl_BeaconEffectButton::SetButtonActive(bool active)
{
if(m_active != active)
{
m_active = active;
UpdateButtonState();
}
}
void UIControl_BeaconEffectButton::setFocus(bool focus)
{
if(m_focus != focus)
{
m_focus = focus;
UpdateButtonState();
}
}
void UIControl_BeaconEffectButton::SetIcon(int icon)
{
if(icon != m_icon)
{
m_icon = icon;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = m_icon;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetIcon , 1 , value );
}
}
void UIControl_BeaconEffectButton::UpdateButtonState()
{
EState state = eState_Disabled;
if(!m_active)
{
state = eState_Disabled;
}
else if(m_selected)
{
state = eState_Pressed;
}
else if(m_focus)
{
state = eState_Enabled_Selected;
}
else
{
state = eState_Enabled_Unselected;
}
if(state != m_lastState)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = state;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcChangeState , 1 , value );
if(out == IGGY_RESULT_SUCCESS) m_lastState = state;
}
}
@@ -0,0 +1,49 @@
#pragma once
#include "UIControl.h"
class UIControl_BeaconEffectButton : public UIControl
{
private:
static const int BUTTON_DISABLED = 0;
static const int BUTTON_ENABLED_UNSELECTED = 1;
static const int BUTTON_ENABLED_SELECTED = 2;
static const int BUTTON_PRESSED = 3;
enum EState
{
eState_Disabled,
eState_Enabled_Unselected,
eState_Enabled_Selected,
eState_Pressed
};
EState m_lastState;
int m_data;
int m_icon;
bool m_selected;
bool m_active;
bool m_focus;
IggyName m_funcChangeState, m_funcSetIcon;
public:
UIControl_BeaconEffectButton();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void SetData(int data, int icon, bool active, bool selected);
int GetData();
void SetButtonSelected(bool selected);
bool IsButtonSelected();
void SetButtonActive(bool active);
virtual void setFocus(bool focus);
void SetIcon(int icon);
private:
void UpdateButtonState();
};
@@ -0,0 +1,27 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_BitmapIcon.h"
bool UIControl_BitmapIcon::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eBitmapIcon);
bool success = UIControl::setupControl(scene,parent,controlName);
//SlotList specific initialisers
m_funcSetTextureName = registerFastName(L"SetTextureName");
return success;
}
void UIControl_BitmapIcon::setTextureName(const wstring &iconName)
{
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)iconName.c_str();
stringVal.length = iconName.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetTextureName , 1 , value );
}
@@ -0,0 +1,14 @@
#pragma once
#include "UIControl.h"
class UIControl_BitmapIcon : public UIControl
{
private:
IggyName m_funcSetTextureName;
public:
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void setTextureName(const wstring &iconName);
};
@@ -0,0 +1,68 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_Button.h"
UIControl_Button::UIControl_Button()
{
}
bool UIControl_Button::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eButton);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Button specific initialisers
m_funcEnableButton = registerFastName(L"EnableButton");
return success;
}
void UIControl_Button::init(UIString label, int id)
{
m_label = label;
m_id = id;
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = id;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 2 , value );
#ifdef __PSVITA__
// 4J-PB - add this button to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Error:
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
void UIControl_Button::ReInit()
{
UIControl_Base::ReInit();
init(m_label, m_id);
}
void UIControl_Button::setEnable(bool enable)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = enable;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcEnableButton , 1 , value );
}
@@ -0,0 +1,21 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Button : public UIControl_Base
{
private:
IggyName m_funcEnableButton;
public:
UIControl_Button();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(UIString label, int id);
//void init(const wstring &label, int id) { init(UIString::CONSTANT(label), id); }
virtual void ReInit();
void setEnable(bool enable);
};
@@ -0,0 +1,241 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_ButtonList.h"
UIControl_ButtonList::UIControl_ButtonList()
{
m_itemCount = 0;
m_iCurrentSelection = 0;
}
bool UIControl_ButtonList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eButtonList);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//SlotList specific initialisers
m_addNewItemFunc = registerFastName(L"addNewItem");
m_removeAllItemsFunc = registerFastName(L"removeAllItems");
m_funcHighlightItem = registerFastName(L"HighlightItem");
m_funcRemoveItem = registerFastName(L"RemoveItem");
m_funcSetButtonLabel = registerFastName(L"SetButtonLabel");
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger");
return success;
}
void UIControl_ButtonList::init(int id)
{
m_id = id;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
#ifdef __PSVITA__
// 4J-PB - add this buttonlist to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
void UIControl_ButtonList::ReInit()
{
UIControl_Base::ReInit();
init(m_id);
m_itemCount = 0;
m_iCurrentSelection = 0;
}
void UIControl_ButtonList::clearList()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_removeAllItemsFunc , 0 , NULL );
m_itemCount = 0;
}
void UIControl_ButtonList::addItem(const string &label)
{
addItem(label, m_itemCount);
}
void UIControl_ButtonList::addItem(const wstring &label)
{
addItem(label, m_itemCount);
}
void UIControl_ButtonList::addItem(const string &label, int data)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 2 , value );
++m_itemCount;
}
void UIControl_ButtonList::addItem(const wstring &label, int data)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 2 , value );
++m_itemCount;
}
void UIControl_ButtonList::removeItem(int index)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = index;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcRemoveItem , 1 , value );
--m_itemCount;
}
void UIControl_ButtonList::setCurrentSelection(int iSelection)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iSelection;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcHighlightItem , 1 , value );
}
int UIControl_ButtonList::getCurrentSelection()
{
return m_iCurrentSelection;
}
void UIControl_ButtonList::updateChildFocus(int iChild)
{
m_iCurrentSelection = iChild;
}
void UIControl_ButtonList::setButtonLabel(int iButtonId, const wstring &label)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iButtonId;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetButtonLabel, 2 , value );
}
#ifdef __PSVITA__
void UIControl_ButtonList::SetTouchFocus(S32 iX, S32 iY, bool bRepeat)
{
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iX;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iY;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = bRepeat;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3 , value );
}
bool UIControl_ButtonList::CanTouchTrigger(S32 iX, S32 iY)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iX;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iY;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcCanTouchTrigger, 2 , value );
S32 bCanTouchTrigger = false;
if(result.type == IGGY_DATATYPE_boolean)
{
bCanTouchTrigger = (bool)result.boolval;
}
return bCanTouchTrigger;
}
#endif
void UIControl_DynamicButtonList::tick()
{
UIControl_ButtonList::tick();
int buttonIndex = 0;
vector<UIString>::iterator itr;
for (itr = m_labels.begin(); itr != m_labels.end(); itr++)
{
if ( itr->needsUpdating() )
{
setButtonLabel(buttonIndex, itr->getString());
itr->setUpdated();
}
buttonIndex++;
}
}
void UIControl_DynamicButtonList::addItem(UIString label, int data)
{
if (data < 0) data = m_itemCount;
if (data < m_labels.size())
{
m_labels[data] = label;
}
else
{
while (data > m_labels.size())
{
m_labels.push_back(UIString());
}
m_labels.push_back(label);
}
UIControl_ButtonList::addItem(label.getString(), data);
}
void UIControl_DynamicButtonList::removeItem(int index)
{
m_labels.erase( m_labels.begin() + index );
UIControl_ButtonList::removeItem(index);
}
@@ -0,0 +1,58 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_ButtonList : public UIControl_Base
{
protected:
IggyName m_addNewItemFunc, m_removeAllItemsFunc, m_funcHighlightItem, m_funcRemoveItem, m_funcSetButtonLabel, m_funcSetTouchFocus, m_funcCanTouchTrigger;
int m_itemCount;
int m_iCurrentSelection;
public:
UIControl_ButtonList();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(int id);
virtual void ReInit();
void clearList();
void addItem(const wstring &label);
void addItem(const string &label);
void addItem(const wstring &label, int data);
void addItem(const string &label, int data);
void removeItem(int index);
int getItemCount() { return m_itemCount; }
void setCurrentSelection(int iSelection);
int getCurrentSelection();
void updateChildFocus(int iChild);
void setButtonLabel(int iButtonId, const wstring &label);
#ifdef __PSVITA__
void SetTouchFocus(S32 iX, S32 iY, bool bRepeat);
bool CanTouchTrigger(S32 iX, S32 iY);
#endif
};
class UIControl_DynamicButtonList : public UIControl_ButtonList
{
protected:
vector<UIString> m_labels;
public:
virtual void tick();
virtual void addItem(UIString label, int data = -1);
virtual void removeItem(int index);
};
@@ -0,0 +1,109 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_CheckBox.h"
UIControl_CheckBox::UIControl_CheckBox()
{
}
bool UIControl_CheckBox::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eCheckBox);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//CheckBox specific initialisers
m_checkedProp = registerFastName(L"Checked");
m_funcEnable = registerFastName(L"EnableCheckBox");
m_funcSetCheckBox = registerFastName(L"SetCheckBox");
m_bEnabled = true;
return success;
}
void UIControl_CheckBox::init(UIString label, int id, bool checked)
{
m_label = label;
m_id = id;
m_bChecked = checked;
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (int)id;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = checked;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 3 , value );
#ifdef __PSVITA__
// 4J-TomK - add checkbox to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
bool UIControl_CheckBox::IsChecked()
{
rrbool checked = false;
IggyResult result = IggyValueGetBooleanRS ( &m_iggyPath , m_checkedProp, NULL, &checked );
m_bChecked = checked;
return checked;
}
bool UIControl_CheckBox::IsEnabled()
{
return m_bEnabled;
}
void UIControl_CheckBox::SetEnable(bool enable)
{
m_bEnabled = enable;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = enable;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcEnable , 1 , value );
}
// 4J HEG - this is only ever used when required, most of this should happen in the flash
void UIControl_CheckBox::setChecked(bool checked)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = checked;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetCheckBox , 1 , value );
}
// 4J-TomK we need to trigger this one via function instead of key down event because of how it works
void UIControl_CheckBox::TouchSetCheckbox(bool checked)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = checked;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetCheckBox , 1 , value );
}
void UIControl_CheckBox::ReInit()
{
UIControl_Base::ReInit();
init(m_label, m_id, m_bChecked);
}
@@ -0,0 +1,27 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_CheckBox : public UIControl_Base
{
private:
IggyName m_checkedProp, m_funcEnable, m_funcSetCheckBox;
bool m_bChecked, m_bEnabled;
public:
UIControl_CheckBox();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(UIString label, int id, bool checked);
bool IsChecked();
bool IsEnabled();
void SetEnable(bool enable);
void setChecked(bool checked);
void TouchSetCheckbox(bool checked);
virtual void ReInit();
};
@@ -0,0 +1,17 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_Cursor.h"
UIControl_Cursor::UIControl_Cursor()
{
}
bool UIControl_Cursor::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eCursor);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Label specific initialisers
return success;
}
@@ -0,0 +1,11 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Cursor : public UIControl_Base
{
public:
UIControl_Cursor();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
};
@@ -0,0 +1,69 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_DLCList.h"
bool UIControl_DLCList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eDLCList);
bool success = UIControl_ButtonList::setupControl(scene,parent,controlName);
//SlotList specific initialisers
m_funcShowTick = registerFastName(L"ShowTick");
return success;
}
void UIControl_DLCList::addItem(const string &label, bool showTick, int iId)
{
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = showTick;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 3 , value );
++m_itemCount;
}
void UIControl_DLCList::addItem(const wstring &label, bool showTick, int iId)
{
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16 *)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = showTick;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 3 , value );
++m_itemCount;
}
void UIControl_DLCList::showTick(int iId, bool showTick)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = showTick;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcShowTick , 2 , value );
}
@@ -0,0 +1,17 @@
#pragma once
#include "UIControl_ButtonList.h"
class UIControl_DLCList : public UIControl_ButtonList
{
private:
IggyName m_funcShowTick;
public:
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
using UIControl_ButtonList::addItem;
void addItem(const string &label, bool showTick, int iId);
void addItem(const wstring &label, bool showTick, int iId);
void showTick(int iId, bool showTick);
};
@@ -0,0 +1,98 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_DynamicLabel.h"
UIControl_DynamicLabel::UIControl_DynamicLabel()
{
}
bool UIControl_DynamicLabel::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eDynamicLabel);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Label specific initialisers
m_funcAddText = registerFastName(L"AddText");
m_funcTouchScroll = registerFastName(L"TouchScroll");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
m_funcGetRealHeight = registerFastName(L"GetRealHeight");
return success;
}
void UIControl_DynamicLabel::addText(const wstring &text, bool bLastEntry)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)text.c_str();
stringVal.length = text.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bLastEntry;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcAddText , 2 , value );
}
void UIControl_DynamicLabel::ReInit()
{
UIControl_Base::ReInit();
}
void UIControl_DynamicLabel::SetupTouch()
{
#ifdef __PSVITA__
// 4J-TomK - add this dynamic label to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
void UIControl_DynamicLabel::TouchScroll(S32 iY, bool bActive)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iY;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bActive;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcTouchScroll, 2 , value );
}
S32 UIControl_DynamicLabel::GetRealWidth()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , NULL );
S32 iRealWidth = m_width;
if(result.type == IGGY_DATATYPE_number)
{
iRealWidth = (S32)result.number;
}
return iRealWidth;
}
S32 UIControl_DynamicLabel::GetRealHeight()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , NULL );
S32 iRealHeight = m_height;
if(result.type == IGGY_DATATYPE_number)
{
iRealHeight = (S32)result.number;
}
return iRealHeight;
}
@@ -0,0 +1,25 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_DynamicLabel : public UIControl_Label
{
private:
IggyName m_funcAddText, m_funcTouchScroll, m_funcGetRealWidth, m_funcGetRealHeight;
public:
UIControl_DynamicLabel();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
virtual void addText(const wstring &text, bool bLastEntry);
virtual void ReInit();
virtual void SetupTouch();
virtual void TouchScroll(S32 iY, bool bActive);
S32 GetRealWidth();
S32 GetRealHeight();
};
@@ -0,0 +1,138 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_EnchantmentBook.h"
#include "..\..\Minecraft.h"
#include "..\..\TileEntityRenderDispatcher.h"
#include "..\..\EnchantTableRenderer.h"
#include "..\..\Lighting.h"
#include "..\..\BookModel.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
UIControl_EnchantmentBook::UIControl_EnchantmentBook()
{
UIControl::setControlType(UIControl::eEnchantmentBook);
model = NULL;
last = nullptr;
time = 0;
flip = oFlip = flipT = flipA = 0.0f;
open = oOpen = 0.0f;
}
void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion *region)
{
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
// Revert the scale from the setup
float ssX = width/m_width;
float ssY = height/m_height;
glScalef(ssX, ssY,1.0f);
glTranslatef(m_width/2, m_height/2, 50.0f);
// Add a uniform scale
glScalef(-57/ssX, 57/ssX, 360.0f);
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
//float sss = 4;
//glTranslatef(0, 3.3f, -16);
//glScalef(sss, sss, sss);
Minecraft *pMinecraft = Minecraft::GetInstance();
int tex = pMinecraft->textures->loadTexture(TN_ITEM_BOOK); // 4J was L"/1_2_2/item/book.png"
pMinecraft->textures->bind(tex);
glRotatef(20, 1, 0, 0);
float a = 1;
float o = oOpen + (open - oOpen) * a;
glTranslatef((1 - o) * 0.2f, (1 - o) * 0.1f, (1 - o) * 0.25f);
glRotatef(-(1 - o) * 90 - 90, 0, 1, 0);
glRotatef(180, 1, 0, 0);
float ff1 = oFlip + (flip - oFlip) * a + 0.25f;
float ff2 = oFlip + (flip - oFlip) * a + 0.75f;
ff1 = (ff1 - floor(ff1)) * 1.6f - 0.3f;
ff2 = (ff2 - floor(ff2)) * 1.6f - 0.3f;
if (ff1 < 0) ff1 = 0;
if (ff2 < 0) ff2 = 0;
if (ff1 > 1) ff1 = 1;
if (ff2 > 1) ff2 = 1;
glEnable(GL_CULL_FACE);
if(model == NULL)
{
// Share the model the the EnchantTableRenderer
EnchantTableRenderer *etr = (EnchantTableRenderer*)TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY);
if(etr != NULL)
{
model = etr->bookModel;
}
else
{
model = new BookModel();
}
}
model->render(nullptr, 0, ff1, ff2, o, 0, 1 / 16.0f,true);
glDisable(GL_CULL_FACE);
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
tickBook();
}
void UIControl_EnchantmentBook::tickBook()
{
UIScene_EnchantingMenu *m_containerScene = (UIScene_EnchantingMenu *)m_parentScene;
EnchantmentMenu *menu = m_containerScene->getMenu();
shared_ptr<ItemInstance> current = menu->getSlot(0)->getItem();
if (!ItemInstance::matches(current, last))
{
last = current;
do
{
flipT += random.nextInt(4) - random.nextInt(4);
} while (flip <= flipT + 1 && flip >= flipT - 1);
}
time++;
oFlip = flip;
oOpen = open;
bool shouldBeOpen = false;
for (int i = 0; i < 3; i++)
{
if (menu->costs[i] != 0)
{
shouldBeOpen = true;
}
}
if (shouldBeOpen) open += 0.2f;
else open -= 0.2f;
if (open < 0) open = 0;
if (open > 1) open = 1;
float diff = (flipT - flip) * 0.4f;
float max = 0.2f;
if (diff < -max) diff = -max;
if (diff > +max) diff = +max;
flipA += (diff - flipA) * 0.9f;
flip = flip + flipA;
}
@@ -0,0 +1,33 @@
#pragma once
#include "UIControl.h"
class UIScene_EnchantingMenu;
class BookModel;
class UIControl_EnchantmentBook : public UIControl
{
private:
BookModel *model;
Random random;
// 4J JEV: Book animation variables.
int time;
float flip, oFlip, flipT, flipA;
float open, oOpen;
//BOOL m_bDirty;
//float m_fScale,m_fAlpha;
//int m_iPad;
shared_ptr<ItemInstance> last;
//float m_fScreenWidth,m_fScreenHeight;
//float m_fRawWidth,m_fRawHeight;
void tickBook();
public:
UIControl_EnchantmentBook();
void render(IggyCustomDrawCallbackRegion *region);
};
@@ -0,0 +1,217 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_EnchantmentButton.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
UIControl_EnchantmentButton::UIControl_EnchantmentButton()
{
m_index = 0;
m_lastState = eState_Inactive;
m_lastCost = 0;
m_enchantmentString = L"";
m_bHasFocus = false;
m_textColour = app.GetHTMLColour(eTextColor_Enchant);
m_textFocusColour = app.GetHTMLColour(eTextColor_EnchantFocus);
m_textDisabledColour = app.GetHTMLColour(eTextColor_EnchantDisabled);
}
bool UIControl_EnchantmentButton::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eEnchantmentButton);
bool success = UIControl_Button::setupControl(scene,parent,controlName);
//Button specific initialisers
m_funcChangeState = registerFastName(L"ChangeState");
return success;
}
void UIControl_EnchantmentButton::init(int index)
{
m_index = index;
}
void UIControl_EnchantmentButton::ReInit()
{
UIControl_Button::ReInit();
m_lastState = eState_Inactive;
m_lastCost = 0;
m_bHasFocus = false;
updateState();
}
void UIControl_EnchantmentButton::tick()
{
updateState();
UIControl_Button::tick();
}
void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion *region)
{
UIScene_EnchantingMenu *enchantingScene = (UIScene_EnchantingMenu *)m_parentScene;
EnchantmentMenu *menu = enchantingScene->getMenu();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width/2;
float yo = height;
//glTranslatef(xo, yo, 50.0f);
// Revert the scale from the setup
float ssX = width/m_width;
float ssY = height/m_height;
glScalef(ssX, ssY,1.0f);
float ss = 1.0f;
#if TO_BE_IMPLEMENTED
if(!enchantingScene->m_bSplitscreen)
#endif
{
switch(enchantingScene->getSceneResolution())
{
case UIScene::eSceneResolution_1080:
ss = 3.0f;
break;
default:
ss = 2.0f;
break;
}
}
glScalef(ss, ss, ss);
int cost = menu->costs[m_index];
//if(cost != m_lastCost)
//{
// updateState();
//}
glColor4f(1, 1, 1, 1);
if (cost != 0)
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
Minecraft *pMinecraft = Minecraft::GetInstance();
wstring line = _toString<int>(cost);
Font *font = pMinecraft->altFont;
//int col = 0x685E4A;
unsigned int col = m_textColour;
if (pMinecraft->localplayers[enchantingScene->getPad()]->experienceLevel < cost && !pMinecraft->localplayers[enchantingScene->getPad()]->abilities.instabuild)
{
col = m_textDisabledColour;
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width/ss, col, (float)m_height/ss);
font = pMinecraft->font;
//col = (0x80ff20 & 0xfefefe) >> 1;
//font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
else
{
if (m_bHasFocus)
{
//col = 0xffff80;
col = m_textFocusColour;
}
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width/ss, col, (float)m_height/ss);
font = pMinecraft->font;
//col = 0x80ff20;
//font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
glDisable(GL_ALPHA_TEST);
}
else
{
}
//Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
void UIControl_EnchantmentButton::updateState()
{
UIScene_EnchantingMenu *enchantingScene = (UIScene_EnchantingMenu *)m_parentScene;
EnchantmentMenu *menu = enchantingScene->getMenu();
EState state = eState_Inactive;
int cost = menu->costs[m_index];
Minecraft *pMinecraft = Minecraft::GetInstance();
if(cost > pMinecraft->localplayers[enchantingScene->getPad()]->experienceLevel && !pMinecraft->localplayers[enchantingScene->getPad()]->abilities.instabuild)
{
// Dark background
state = eState_Inactive;
}
else
{
// Light background and focus background
if(m_bHasFocus)
{
state = eState_Selected;
}
else
{
state = eState_Active;
}
}
if(cost != m_lastCost)
{
setLabel( _toString<int>(cost) );
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
if(cost == 0)
{
// Dark background
state = eState_Inactive;
setLabel(L"");
}
if(state != m_lastState)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (int)state;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcChangeState , 1 , value );
if(out == IGGY_RESULT_SUCCESS) m_lastState = state;
}
}
void UIControl_EnchantmentButton::setFocus(bool focus)
{
m_bHasFocus = focus;
updateState();
}
UIControl_EnchantmentButton::EnchantmentNames UIControl_EnchantmentButton::EnchantmentNames::instance;
UIControl_EnchantmentButton::EnchantmentNames::EnchantmentNames()
{
wstring allWords = L"the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale ";
std::wistringstream iss(allWords);
std::copy(std::istream_iterator< std::wstring, wchar_t, std::char_traits<wchar_t> >(iss), std::istream_iterator< std::wstring, wchar_t, std::char_traits<wchar_t> >(),std::back_inserter(words));
}
wstring UIControl_EnchantmentButton::EnchantmentNames::getRandomName()
{
int wordCount = random.nextInt(2) + 3;
wstring word = L"";
for (int i = 0; i < wordCount; i++)
{
if (i > 0) word += L" ";
word += words[random.nextInt(words.size())];
}
return word;
}
@@ -0,0 +1,55 @@
#pragma once
#include "UIControl_Button.h"
class UIControl_EnchantmentButton : public UIControl_Button
{
private:
// Maps to values in AS
enum EState
{
eState_Inactive = 0,
eState_Active = 1,
eState_Selected = 2,
};
EState m_lastState;
int m_lastCost;
int m_index;
wstring m_enchantmentString;
bool m_bHasFocus;
IggyName m_funcChangeState;
unsigned int m_textColour, m_textFocusColour, m_textDisabledColour;
class EnchantmentNames
{
public:
static EnchantmentNames instance;
private:
Random random;
vector<wstring> words;
EnchantmentNames();
public:
wstring getRandomName();
};
public:
UIControl_EnchantmentButton();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
virtual void tick();
void init(int index);
virtual void ReInit();
void render(IggyCustomDrawCallbackRegion *region);
void updateState();
virtual void setFocus(bool focus);
};
@@ -0,0 +1,103 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_HTMLLabel.h"
UIControl_HTMLLabel::UIControl_HTMLLabel()
{
}
bool UIControl_HTMLLabel::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eHTMLLabel);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Label specific initialisers
m_funcStartAutoScroll = registerFastName(L"StartAutoScroll");
m_funcTouchScroll = registerFastName(L"TouchScroll");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
m_funcGetRealHeight = registerFastName(L"GetRealHeight");
return success;
}
void UIControl_HTMLLabel::startAutoScroll()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcStartAutoScroll , 0 , NULL );
}
void UIControl_HTMLLabel::ReInit()
{
UIControl_Base::ReInit();
// Don't set the label, HTML sizes will have changed. Let the scene update us.
init(L"");
}
void UIControl_HTMLLabel::setLabel(const string &label)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF8;
IggyStringUTF8 stringVal;
stringVal.string = (char *) label.c_str();
stringVal.length = label.length();
value[0].string8 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value );
}
void UIControl_HTMLLabel::SetupTouch()
{
#ifdef __PSVITA__
// 4J-TomK - add this dynamic label to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
void UIControl_HTMLLabel::TouchScroll(S32 iY, bool bActive)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iY;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bActive;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcTouchScroll, 2 , value );
}
S32 UIControl_HTMLLabel::GetRealWidth()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth, 0 , NULL );
S32 iRealWidth = m_width;
if(result.type == IGGY_DATATYPE_number)
{
iRealWidth = (S32)result.number;
}
return iRealWidth;
}
S32 UIControl_HTMLLabel::GetRealHeight()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealHeight, 0 , NULL );
S32 iRealHeight = m_height;
if(result.type == IGGY_DATATYPE_number)
{
iRealHeight = (S32)result.number;
}
return iRealHeight;
}
@@ -0,0 +1,27 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_HTMLLabel : public UIControl_Label
{
private:
IggyName m_funcStartAutoScroll, m_funcTouchScroll, m_funcGetRealWidth, m_funcGetRealHeight;
public:
UIControl_HTMLLabel();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void startAutoScroll();
virtual void ReInit();
using UIControl_Base::setLabel;
void setLabel(const string &label);
virtual void SetupTouch();
virtual void TouchScroll(S32 iY, bool bActive);
S32 GetRealWidth();
S32 GetRealHeight();
};
@@ -0,0 +1,45 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_Label.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
UIControl_Label::UIControl_Label()
{
m_reinitEnabled = true;
}
bool UIControl_Label::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eLabel);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Label specific initialisers
return success;
}
void UIControl_Label::init(UIString label)
{
m_label = label;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
}
void UIControl_Label::ReInit()
{
UIControl_Base::ReInit();
// 4J-JEV: This can't be reinitialised.
if (m_reinitEnabled)
{
init(m_label);
}
}
@@ -0,0 +1,19 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Label : public UIControl_Base
{
private:
bool m_reinitEnabled;
public:
UIControl_Label();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(UIString label);
virtual void ReInit();
void disableReinitialisation() { m_reinitEnabled = false; }
};
@@ -0,0 +1,238 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_LeaderboardList.h"
UIControl_LeaderboardList::UIControl_LeaderboardList()
{
}
bool UIControl_LeaderboardList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eLeaderboardList);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//UIControl_LeaderboardList specific initialisers
m_funcInitLeaderboard = registerFastName(L"InitLeaderboard");
m_funcAddDataSet = registerFastName(L"AddDataSet");
m_funcResetLeaderboard = registerFastName(L"ResetLeaderboard");
m_funcSetupTitles = registerFastName(L"SetupTitles");
m_funcSetColumnIcon = registerFastName(L"SetColumnIcon");
#ifdef __PSVITA__
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
m_bTouchInitialised = false;
#endif
return success;
}
void UIControl_LeaderboardList::init(int id)
{
m_id = id;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
}
void UIControl_LeaderboardList::ReInit()
{
UIControl_Base::ReInit();
init(m_id);
}
void UIControl_LeaderboardList::clearList()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcResetLeaderboard , 0 , NULL );
}
void UIControl_LeaderboardList::setupTitles(const wstring &rank, const wstring &gamertag)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal0;
stringVal0.string = (IggyUTF16*)rank.c_str();
stringVal0.length = rank.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal0;
IggyStringUTF16 stringVal1;
stringVal1.string = (IggyUTF16*)gamertag.c_str();
stringVal1.length = gamertag.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal1;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetupTitles , 2 , value );
}
void UIControl_LeaderboardList::initLeaderboard(int iFirstFocus, int iTotalEntries, int iNumColumns)
{
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iFirstFocus;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iTotalEntries;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iNumColumns;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcInitLeaderboard , 3 , value );
#ifdef __PSVITA__
// 4J-PB - add this button to the vita touch box list
if(!m_bTouchInitialised)
{
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
m_bTouchInitialised = true;
}
#endif
}
void UIControl_LeaderboardList::setColumnIcon(int iColumn, int iType)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iColumn;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (iType<=32000)?0:(iType-32000);
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetColumnIcon , 2 , value );
}
void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const wstring &gamertag, bool bDisplayMessage, const wstring &col0, const wstring &col1, const wstring &col2, const wstring &col3, const wstring &col4, const wstring &col5, const wstring &col6)
{
IggyDataValue result;
IggyDataValue value[12];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = bLast;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iRank;
IggyStringUTF16 stringVal0;
stringVal0.string = (IggyUTF16*)gamertag.c_str();
stringVal0.length = gamertag.length();
value[3].type = IGGY_DATATYPE_string_UTF16;
value[3].string16 = stringVal0;
value[4].type = IGGY_DATATYPE_boolean;
value[4].boolval = bDisplayMessage;
IggyStringUTF16 stringVal1;
stringVal1.string = (IggyUTF16*)col0.c_str();
stringVal1.length = col0.length();
value[5].type = IGGY_DATATYPE_string_UTF16;
value[5].string16 = stringVal1;
if(col1.empty())
{
value[6].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)col1.c_str();
stringVal2.length = col1.length();
value[6].type = IGGY_DATATYPE_string_UTF16;
value[6].string16 = stringVal2;
}
if(col2.empty())
{
value[7].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal3;
stringVal3.string = (IggyUTF16*)col2.c_str();
stringVal3.length = col2.length();
value[7].type = IGGY_DATATYPE_string_UTF16;
value[7].string16 = stringVal3;
}
if(col3.empty())
{
value[8].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal4;
stringVal4.string = (IggyUTF16*)col3.c_str();
stringVal4.length = col3.length();
value[8].type = IGGY_DATATYPE_string_UTF16;
value[8].string16 = stringVal4;
}
if(col4.empty())
{
value[9].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal5;
stringVal5.string = (IggyUTF16*)col4.c_str();
stringVal5.length = col4.length();
value[9].type = IGGY_DATATYPE_string_UTF16;
value[9].string16 = stringVal5;
}
if(col5.empty())
{
value[10].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal6;
stringVal6.string = (IggyUTF16*)col5.c_str();
stringVal6.length = col5.length();
value[10].type = IGGY_DATATYPE_string_UTF16;
value[10].string16 = stringVal6;
}
if(col6.empty())
{
value[11].type = IGGY_DATATYPE_null;
}
else
{
IggyStringUTF16 stringVal7;
stringVal7.string = (IggyUTF16*)col6.c_str();
stringVal7.length = col6.length();
value[11].type = IGGY_DATATYPE_string_UTF16;
value[11].string16 = stringVal7;
}
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcAddDataSet , 12 , value );
}
#ifdef __PSVITA__
void UIControl_LeaderboardList::SetTouchFocus(S32 iX, S32 iY, bool bRepeat)
{
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iX;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iY;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = bRepeat;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3 , value );
}
#endif
@@ -0,0 +1,50 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_LeaderboardList : public UIControl_Base
{
private:
IggyName m_funcInitLeaderboard, m_funcAddDataSet;
IggyName m_funcResetLeaderboard;
IggyName m_funcSetupTitles, m_funcSetColumnIcon;
#ifdef __PSVITA__
IggyName m_funcSetTouchFocus;
bool m_bTouchInitialised;
#endif
public:
enum ELeaderboardIcons
{
e_ICON_TYPE_IGGY = 0,
e_ICON_TYPE_CLIMBED = 32001,
e_ICON_TYPE_FALLEN = 32002,
e_ICON_TYPE_WALKED = 32003,
e_ICON_TYPE_SWAM = 32004,
e_ICON_TYPE_ZOMBIE = 32005,
e_ICON_TYPE_ZOMBIEPIGMAN = 32006,
e_ICON_TYPE_GHAST = 32007,
e_ICON_TYPE_CREEPER = 32008,
e_ICON_TYPE_SKELETON = 32009,
e_ICON_TYPE_SPIDER = 32010,
e_ICON_TYPE_SPIDERJOKEY = 32011,
e_ICON_TYPE_SLIME = 32012,
e_ICON_TYPE_PORTAL = 32013,
};
UIControl_LeaderboardList();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(int id);
virtual void ReInit();
void clearList();
void setupTitles(const wstring &rank, const wstring &gamertag);
void initLeaderboard(int iFirstFocus, int iTotalEntries, int iNumColumns);
void setColumnIcon(int iColumn, int iType);
void addDataSet(bool bLast, int iId, int iRank, const wstring &gamertag, bool bDisplayMessage, const wstring &col0, const wstring &col1, const wstring &col2, const wstring &col3, const wstring &col4, const wstring &col5, const wstring &col6);
#ifdef __PSVITA__
void SetTouchFocus(S32 iX, S32 iY, bool bRepeat);
#endif
};
@@ -0,0 +1,103 @@
#include "stdafx.h"
#include "..\..\Minecraft.h"
#include "..\..\ScreenSizeCalculator.h"
#include "..\..\EntityRenderDispatcher.h"
#include "..\..\PlayerRenderer.h"
#include "..\..\HorseRenderer.h"
#include "..\..\HumanoidModel.h"
#include "..\..\ModelHorse.h"
#include "..\..\Lighting.h"
#include "..\..\ModelPart.h"
#include "..\..\Options.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
//#include "..\..\..\Minecraft.World\net.minecraft.world.entity.animal.EntityHorse.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "UI.h"
#include "UIControl_MinecraftHorse.h"
UIControl_MinecraftHorse::UIControl_MinecraftHorse()
{
UIControl::setControlType(UIControl::eMinecraftHorse);
Minecraft *pMinecraft=Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
}
void UIControl_MinecraftHorse::render(IggyCustomDrawCallbackRegion *region)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width/2;
float yo = height;
// dynamic y offset according to region height
glTranslatef(xo, yo - (height / 7.5f), 50.0f);
//UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu *)m_parentScene;
UIScene_HorseInventoryMenu *containerMenu = (UIScene_HorseInventoryMenu *)m_parentScene;
shared_ptr<LivingEntity> entityHorse = containerMenu->m_horse;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
float ss = width / (m_fScreenWidth / m_fScreenHeight) * 0.71f;
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
float oybr = entityHorse->yBodyRot;
float oyr = entityHorse->yRot;
float oxr = entityHorse->xRot;
float oyhr = entityHorse->yHeadRot;
//float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x;
float xd = (m_x + m_width/2) - containerMenu->m_pointerPos.x;
// Need to base Y on head position, not centre of mass
//float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) - m_pointerPos.y;
float yd = (m_y + m_height/2 - 40) - containerMenu->m_pointerPos.y;
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float) atan(yd / 40.0f) * 20, 1, 0, 0);
entityHorse->yBodyRot = (float) atan(xd / 40.0f) * 20;
entityHorse->yRot = (float) atan(xd / 40.0f) * 40;
entityHorse->xRot = -(float) atan(yd / 40.0f) * 20;
entityHorse->yHeadRot = entityHorse->yRot;
//entityHorse->glow = 1;
glTranslatef(0, entityHorse->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(entityHorse, 0, 0, 0, 0, 1, false, false);
pMinecraft->options->hideGui = wasHidingGui;
//entityHorse->glow = 0;
entityHorse->yBodyRot = oybr;
entityHorse->yRot = oyr;
entityHorse->xRot = oxr;
entityHorse->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
@@ -0,0 +1,15 @@
#pragma once
#include "UIControl.h"
class UIControl_MinecraftHorse : public UIControl
{
private:
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
public:
UIControl_MinecraftHorse();
void render(IggyCustomDrawCallbackRegion *region);
};
@@ -0,0 +1,94 @@
#include "stdafx.h"
#include "..\..\Minecraft.h"
#include "..\..\ScreenSizeCalculator.h"
#include "..\..\EntityRenderDispatcher.h"
#include "..\..\PlayerRenderer.h"
#include "..\..\HumanoidModel.h"
#include "..\..\Lighting.h"
#include "..\..\ModelPart.h"
#include "..\..\Options.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "UI.h"
#include "UIControl_MinecraftPlayer.h"
UIControl_MinecraftPlayer::UIControl_MinecraftPlayer()
{
UIControl::setControlType(UIControl::eMinecraftPlayer);
Minecraft *pMinecraft=Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
}
void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion *region)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width/2;
float yo = height;
// dynamic y offset according to region height
glTranslatef(xo, yo - (height / 9.0f), 50.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = width / (m_fScreenWidth / m_fScreenHeight);
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu *)m_parentScene;
float oybr = pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot;
float oyr = pMinecraft->localplayers[containerMenu->getPad()]->yRot;
float oxr = pMinecraft->localplayers[containerMenu->getPad()]->xRot;
float oyhr = pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot;
//float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x;
float xd = (m_x + m_width/2) - containerMenu->m_pointerPos.x;
// Need to base Y on head position, not centre of mass
//float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) - m_pointerPos.y;
float yd = (m_y + m_height/2 - 40) - containerMenu->m_pointerPos.y;
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float) atan(yd / 40.0f) * 20, 1, 0, 0);
pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot = (float) atan(xd / 40.0f) * 20;
pMinecraft->localplayers[containerMenu->getPad()]->yRot = (float) atan(xd / 40.0f) * 40;
pMinecraft->localplayers[containerMenu->getPad()]->xRot = -(float) atan(yd / 40.0f) * 20;
pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot = pMinecraft->localplayers[containerMenu->getPad()]->yRot;
//pMinecraft->localplayers[m_iPad]->glow = 1;
glTranslatef(0, pMinecraft->localplayers[containerMenu->getPad()]->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(pMinecraft->localplayers[containerMenu->getPad()], 0, 0, 0, 0, 1, false, false);
pMinecraft->options->hideGui = wasHidingGui;
//pMinecraft->localplayers[m_iPad]->glow = 0;
pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot = oybr;
pMinecraft->localplayers[containerMenu->getPad()]->yRot = oyr;
pMinecraft->localplayers[containerMenu->getPad()]->xRot = oxr;
pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
@@ -0,0 +1,15 @@
#pragma once
#include "UIControl.h"
class UIControl_MinecraftPlayer : public UIControl
{
private:
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
public:
UIControl_MinecraftPlayer();
void render(IggyCustomDrawCallbackRegion *region);
};
@@ -0,0 +1,65 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_PlayerList.h"
bool UIControl_PlayerList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::ePlayerList);
bool success = UIControl_ButtonList::setupControl(scene,parent,controlName);
//SlotList specific initialisers
m_funcSetPlayerIcon = registerFastName(L"SetPlayerIcon");
m_funcSetVOIPIcon = registerFastName(L"SetVOIPIcon");
return success;
}
void UIControl_PlayerList::addItem(const wstring &label, int iPlayerIcon, int iVOIPIcon)
{
IggyDataValue result;
IggyDataValue value[4];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iPlayerIcon + 1;
value[3].type = IGGY_DATATYPE_number;
value[3].number = iVOIPIcon + 1;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 4 , value );
++m_itemCount;
}
void UIControl_PlayerList::setPlayerIcon(int iId, int iPlayerIcon)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iPlayerIcon + 1;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetPlayerIcon , 2 , value );
}
void UIControl_PlayerList::setVOIPIcon(int iId, int iVOIPIcon)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iVOIPIcon + 1;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetVOIPIcon , 2 , value );
}
@@ -0,0 +1,17 @@
#pragma once
#include "UIControl_ButtonList.h"
class UIControl_PlayerList : public UIControl_ButtonList
{
private:
IggyName m_funcSetPlayerIcon, m_funcSetVOIPIcon;
public:
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
using UIControl_ButtonList::addItem;
void addItem(const wstring &label, int iPlayerIcon, int iVOIPIcon);
void setPlayerIcon(int iId, int iPlayerIcon);
void setVOIPIcon(int iId, int iVOIPIcon);
};
@@ -0,0 +1,519 @@
#include "stdafx.h"
#include "..\..\Minecraft.h"
#include "..\..\ScreenSizeCalculator.h"
#include "..\..\EntityRenderDispatcher.h"
#include "..\..\PlayerRenderer.h"
#include "..\..\HumanoidModel.h"
#include "..\..\Lighting.h"
#include "..\..\ModelPart.h"
#include "..\..\Options.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "UIControl_PlayerSkinPreview.h"
//#define SKIN_PREVIEW_BOB_ANIM
#define SKIN_PREVIEW_WALKING_ANIM
UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview()
{
UIControl::setControlType(UIControl::ePlayerSkinPreview);
m_bDirty = FALSE;
m_fScale = 1.0f;
m_fAlpha = 1.0f;
Minecraft *pMinecraft=Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
m_customTextureUrl = L"default";
m_backupTexture = TN_MOB_CHAR;
m_capeTextureUrl = L"";
m_yRot = 0;
m_xRot = 0;
m_swingTime = 0.0f;
m_bobTick = 0.0f;
m_walkAnimSpeedO = 0.0f;
m_walkAnimSpeed = 0.0f;
m_walkAnimPos = 0.0f;
m_bAutoRotate = false;
m_bRotatingLeft = false;
m_incXRot = false;
m_decXRot = false;
m_incYRot = false;
m_decYRot = false;
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_fTargetRotation = 0.0f;
m_fOriginalRotation = 0.0f;
m_framesAnimatingRotation = 0;
m_bAnimatingToFacing = false;
m_pvAdditionalModelParts=NULL;
m_uiAnimOverrideBitmask=0L;
}
void UIControl_PlayerSkinPreview::tick()
{
UIControl::tick();
if( m_bAnimatingToFacing )
{
++m_framesAnimatingRotation;
m_yRot = m_fOriginalRotation + m_framesAnimatingRotation * ( (m_fTargetRotation - m_fOriginalRotation) / CHANGING_SKIN_FRAMES );
//if(m_framesAnimatingRotation == CHANGING_SKIN_FRAMES) m_bAnimatingToFacing = false;
}
else
{
if( m_incXRot ) IncrementXRotation();
if( m_decXRot ) DecrementXRotation();
if( m_incYRot ) IncrementYRotation();
if( m_decYRot ) DecrementYRotation();
if(m_bAutoRotate)
{
++m_rotateTick;
if(m_rotateTick%4==0)
{
if(m_yRot >= LOOK_LEFT_EXTENT)
{
m_bRotatingLeft = false;
}
else if(m_yRot <= LOOK_RIGHT_EXTENT)
{
m_bRotatingLeft = true;
}
if(m_bRotatingLeft)
{
IncrementYRotation();
}
else
{
DecrementYRotation();
}
}
}
}
}
void UIControl_PlayerSkinPreview::SetTexture(const wstring &url, TEXTURE_NAME backupTexture)
{
m_customTextureUrl = url;
m_backupTexture = backupTexture;
unsigned int uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask( app.getSkinIdFromPath(m_customTextureUrl) );
if(app.GetGameSettings(eGameSetting_CustomSkinAnim)==0 )
{
// We have a force animation for some skins (claptrap)
// 4J-PB - treat all the eAnim_Disable flags as a force anim
if((uiAnimOverrideBitmask & HumanoidModel::m_staticBitmaskIgnorePlayerCustomAnimSetting)!=0)
{
m_uiAnimOverrideBitmask=uiAnimOverrideBitmask;
}
else
{
m_uiAnimOverrideBitmask=0;
}
}
else
{
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
}
m_pvAdditionalModelParts=app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl));
}
void UIControl_PlayerSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAnimate /*= false*/)
{
switch(facing)
{
case e_SkinPreviewFacing_Forward:
m_fTargetRotation = 0;
m_bRotatingLeft = true;
break;
case e_SkinPreviewFacing_Left:
m_fTargetRotation = LOOK_LEFT_EXTENT;
m_bRotatingLeft = false;
break;
case e_SkinPreviewFacing_Right:
m_fTargetRotation = LOOK_RIGHT_EXTENT;
m_bRotatingLeft = true;
break;
}
if(!bAnimate)
{
m_yRot = m_fTargetRotation;
m_bAnimatingToFacing = false;
}
else
{
m_fOriginalRotation = m_yRot;
m_bAnimatingToFacing = true;
m_framesAnimatingRotation = 0;
}
}
void UIControl_PlayerSkinPreview::CycleNextAnimation()
{
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1);
if(m_currentAnimation >= e_SkinPreviewAnimation_Count) m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_swingTime = 0.0f;
}
void UIControl_PlayerSkinPreview::CyclePreviousAnimation()
{
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1);
if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = (ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1);
m_swingTime = 0.0f;
}
void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion *region)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width/2;
float yo = height;
glTranslatef(xo, yo - 3.5f, 50.0f);
//glTranslatef(120.0f, 294, 0.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = width / (m_fScreenWidth / m_fScreenHeight);
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
//glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
//glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)m_xRot, 1, 0, 0);
// 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
//EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0, 0, 0, 0, 1);
EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_LOCALPLAYER);
if (renderer != NULL)
{
// 4J-PB - any additional parts to turn on for this player (skin dependent)
//vector<ModelPart *> *pAdditionalModelParts=mob->GetAdditionalModelParts();
if(m_pvAdditionalModelParts && m_pvAdditionalModelParts->size()!=0)
{
for(AUTO_VAR(it, m_pvAdditionalModelParts->begin()); it != m_pvAdditionalModelParts->end(); ++it)
{
ModelPart *pModelPart=*it;
pModelPart->visible=true;
}
}
render(renderer,0,0,0,0,1);
//renderer->postRender(entity, x, y, z, rot, a);
// hide the additional parts
if(m_pvAdditionalModelParts && m_pvAdditionalModelParts->size()!=0)
{
for(AUTO_VAR(it, m_pvAdditionalModelParts->begin()); it != m_pvAdditionalModelParts->end(); ++it)
{
ModelPart *pModelPart=*it;
pModelPart->visible=false;
}
}
}
pMinecraft->options->hideGui = wasHidingGui;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
// 4J Stu - Modified version of MobRenderer::render that does not require an actual entity
void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, double y, double z, float rot, float a)
{
glPushMatrix();
glDisable(GL_CULL_FACE);
HumanoidModel *model = (HumanoidModel *)renderer->getModel();
//getAttackAnim(mob, a);
//if (armor != NULL) armor->attackTime = model->attackTime;
//model->riding = mob->isRiding();
//if (armor != NULL) armor->riding = model->riding;
// 4J Stu - Remember to reset these values once the rendering is done if you add another one
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
model->idle = false;
model->eating = false;
model->eating_swing = 0;
model->eating_t = 0;
model->young = false;
model->riding = false;
model->m_uiAnimOverrideBitmask = m_uiAnimOverrideBitmask;
if( !m_bAnimatingToFacing )
{
switch( m_currentAnimation )
{
case e_SkinPreviewAnimation_Sneaking:
model->sneaking = true;
break;
case e_SkinPreviewAnimation_Attacking:
model->holdingRightHand = true;
m_swingTime++;
if (m_swingTime >= (Player::SWING_DURATION * 3) )
{
m_swingTime = 0;
}
model->attackTime = m_swingTime / (float) (Player::SWING_DURATION * 3);
break;
default:
break;
};
}
float bodyRot = m_yRot; //(mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
float headRot = m_yRot; //(mob->yRotO + (mob->yRot - mob->yRotO) * a);
float headRotx = 0; //(mob->xRotO + (mob->xRot - mob->xRotO) * a);
//setupPosition(mob, x, y, z);
// is equivalent to
glTranslatef((float) x, (float) y, (float) z);
//float bob = getBob(mob, a);
#ifdef SKIN_PREVIEW_BOB_ANIM
float bob = (m_bobTick + a)/2;
++m_bobTick;
if(m_bobTick>=360*2) m_bobTick = 0;
#else
float bob = 0.0f;
#endif
//setupRotations(mob, bob, bodyRot, a);
// is equivalent to
glRotatef(180 - bodyRot, 0, 1, 0);
float _scale = 1 / 16.0f;
glEnable(GL_RESCALE_NORMAL);
glScalef(-1, -1, 1);
//scale(mob, a);
// is equivalent to
float s = 15 / 16.0f;
glScalef(s, s, s);
// 4J - TomK - pull up character a bit more to make sure extra geo around feet doesn't cause rendering problems on PSVita
#ifdef __PSVITA__
glTranslatef(0, -24 * _scale - 1.0f / 16.0f, 0);
#else
glTranslatef(0, -24 * _scale - 0.125f / 16.0f, 0);
#endif
#ifdef SKIN_PREVIEW_WALKING_ANIM
m_walkAnimSpeedO = m_walkAnimSpeed;
m_walkAnimSpeed += (0.1f - m_walkAnimSpeed) * 0.4f;
m_walkAnimPos += m_walkAnimSpeed;
float ws = m_walkAnimSpeedO + (m_walkAnimSpeed - m_walkAnimSpeedO) * a;
float wp = m_walkAnimPos - m_walkAnimSpeed * (1 - a);
#else
float ws = 0;
float wp = 0;
#endif
if (ws > 1) ws = 1;
MemSect(31);
bindTexture(m_customTextureUrl, m_backupTexture);
MemSect(0);
glEnable(GL_ALPHA_TEST);
//model->prepareMobModel(mob, wp, ws, a);
model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true);
/*for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmor(mob, i, a))
{
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, true);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
}
}*/
//additionalRendering(mob, a);
if (bindTexture(m_capeTextureUrl, L"" ))
{
glPushMatrix();
glTranslatef(0, 0, 2 / 16.0f);
double xd = 0;//(mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) - (mob->xo + (mob->x - mob->xo) * a);
double yd = 0;//(mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) - (mob->yo + (mob->y - mob->yo) * a);
double zd = 0;//(mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) - (mob->zo + (mob->z - mob->zo) * a);
float yr = 1;//mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a;
double xa = sin(yr * PI / 180);
double za = -cos(yr * PI / 180);
float flap = (float) yd * 10;
if (flap < -6) flap = -6;
if (flap > 32) flap = 32;
float lean = (float) (xd * xa + zd * za) * 100;
float lean2 = (float) (xd * za - zd * xa) * 100;
if (lean < 0) lean = 0;
//float pow = 1;//mob->oBob + (bob - mob->oBob) * a;
flap += 1;//sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) * a) * 6) * 32 * pow;
if (model->sneaking)
{
flap += 25;
}
glRotatef(6.0f + lean / 2 + flap, 1, 0, 0);
glRotatef(lean2 / 2, 0, 0, 1);
glRotatef(-lean2 / 2, 0, 1, 0);
glRotatef(180, 0, 1, 0);
model->renderCloak(1 / 16.0f,true);
glPopMatrix();
}
/*
float br = mob->getBrightness(a);
int overlayColor = getOverlayColor(mob, br, a);
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 || mob->deathTime > 0)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_EQUAL);
// 4J - changed these renders to not use the compiled version of their models, because otherwise the render states set
// about (in particular the depth & alpha test) don't work with our command buffer versions
if (mob->hurtTime > 0 || mob->deathTime > 0)
{
glColor4f(br, 0, 0, 0.4f);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(br, 0, 0, 0.4f);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
}
}
if (((overlayColor >> 24) & 0xff) > 0)
{
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
float b = ((overlayColor) & 0xff) / 255.0f;
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
glColor4f(r, g, b, aa);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(r, g, b, aa);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
}
}
glDepthFunc(GL_LEQUAL);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
}
*/
glDisable(GL_RESCALE_NORMAL);
glEnable(GL_CULL_FACE);
glPopMatrix();
MemSect(31);
//renderName(mob, x, y, z);
MemSect(0);
// Reset the model values to stop the changes we made here affecting anything in game (like the player hand render)
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
}
bool UIControl_PlayerSkinPreview::bindTexture(const wstring& urlTexture, int backupTexture)
{
Textures *t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
//int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0)
{
t->bind(id);
return true;
}
else
{
return false;
}
}
bool UIControl_PlayerSkinPreview::bindTexture(const wstring& urlTexture, const wstring& backupTexture)
{
Textures *t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
//int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0)
{
t->bind(id);
return true;
}
else
{
return false;
}
}
@@ -0,0 +1,90 @@
#pragma once
#include "UIControl.h"
#include "..\..\Textures.h"
class ModelPart;
class EntityRenderer;
class UIControl_PlayerSkinPreview : public UIControl
{
private:
static const int LOOK_LEFT_EXTENT = 45;
static const int LOOK_RIGHT_EXTENT = -45;
static const int CHANGING_SKIN_FRAMES = 15;
enum ESkinPreviewAnimations
{
e_SkinPreviewAnimation_Walking,
e_SkinPreviewAnimation_Sneaking,
e_SkinPreviewAnimation_Attacking,
e_SkinPreviewAnimation_Count,
};
BOOL m_bDirty;
float m_fScale,m_fAlpha;
wstring m_customTextureUrl;
TEXTURE_NAME m_backupTexture;
wstring m_capeTextureUrl;
unsigned int m_uiAnimOverrideBitmask;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
int m_yRot,m_xRot;
float m_bobTick;
float m_walkAnimSpeedO;
float m_walkAnimSpeed;
float m_walkAnimPos;
bool m_bAutoRotate, m_bRotatingLeft;
BYTE m_rotateTick;
float m_fTargetRotation, m_fOriginalRotation;
int m_framesAnimatingRotation;
bool m_bAnimatingToFacing;
float m_swingTime;
ESkinPreviewAnimations m_currentAnimation;
//vector<Model::SKIN_BOX *> *m_pvAdditionalBoxes;
vector<ModelPart *> *m_pvAdditionalModelParts;
public:
enum ESkinPreviewFacing
{
e_SkinPreviewFacing_Forward,
e_SkinPreviewFacing_Left,
e_SkinPreviewFacing_Right,
};
UIControl_PlayerSkinPreview();
virtual void tick();
void render(IggyCustomDrawCallbackRegion *region);
void SetTexture(const wstring &url, TEXTURE_NAME backupTexture = TN_MOB_CHAR);
void SetCapeTexture(const wstring &url) { m_capeTextureUrl = url; }
void ResetRotation() { m_xRot = 0; m_yRot = 0; }
void IncrementYRotation() { m_yRot = (m_yRot+4); if(m_yRot >= 180) m_yRot = -180; }
void DecrementYRotation() { m_yRot = (m_yRot-4); if(m_yRot <= -180) m_yRot = 180; }
void IncrementXRotation() { m_xRot = (m_xRot+2); if(m_xRot > 22) m_xRot = 22; }
void DecrementXRotation() { m_xRot = (m_xRot-2); if(m_xRot < -22) m_xRot = -22; }
void SetAutoRotate(bool autoRotate) { m_bAutoRotate = autoRotate; }
void SetFacing(ESkinPreviewFacing facing, bool bAnimate = false);
void CycleNextAnimation();
void CyclePreviousAnimation();
bool m_incXRot, m_decXRot;
bool m_incYRot, m_decYRot;
private:
void render(EntityRenderer *renderer, double x, double y, double z, float rot, float a);
bool bindTexture(const wstring& urlTexture, int backupTexture);
bool bindTexture(const wstring& urlTexture, const wstring& backupTexture);
};
@@ -0,0 +1,84 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_Progress.h"
UIControl_Progress::UIControl_Progress()
{
m_min = 0;
m_max = 100;
m_current = 0;
m_lastPercent = 0.0f;
m_showingBar = true;
}
bool UIControl_Progress::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eProgress);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Progress specific initialisers
m_setProgressFunc = registerFastName(L"setProgress");
m_showBarFunc = registerFastName(L"ShowBar");
return success;
}
void UIControl_Progress::init(UIString label, int id, int min, int max, int current)
{
m_label = label;
m_id = id;
m_min = min;
m_max = max;
m_current = current;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
}
void UIControl_Progress::ReInit()
{
UIControl_Base::ReInit();
init(m_label, m_id, m_min, m_max, m_current);
}
void UIControl_Progress::setProgress(int current)
{
m_current = current;
float percent = (float)((m_current-m_min))/(m_max-m_min);
if(percent != m_lastPercent)
{
m_lastPercent = percent;
//app.DebugPrintf("Setting progress value to %d/%f\n", m_current, percent);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = percent;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setProgressFunc , 1 , value );
}
}
void UIControl_Progress::showBar(bool show)
{
if(show != m_showingBar)
{
m_showingBar = show;
//app.DebugPrintf("Setting progress value to %d/%f\n", m_current, percent);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = show;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_showBarFunc , 1 , value );
}
}
@@ -0,0 +1,25 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Progress : public UIControl_Base
{
private:
IggyName m_setProgressFunc, m_showBarFunc;
int m_min;
int m_max;
int m_current;
float m_lastPercent;
bool m_showingBar;
public:
UIControl_Progress();
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
void init(UIString label, int id, int min, int max, int current);
virtual void ReInit();
void setProgress(int current);
void showBar(bool show);
};
Loaded 100 of 5375 files, more files were not shown because too many files have changed in this diff. Show more