the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 90 lines 2.3 kB view raw
1#include "stdafx.h" 2#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 3#include "..\..\..\Minecraft.World\StringHelpers.h" 4#include "..\..\Font.h" 5#include "..\..\Lighting.h" 6#include "..\..\MultiPlayerLocalPlayer.h" 7#include "XUI_Scene_Enchant.h" 8#include "XUI_Ctrl_EnchantButton.h" 9 10//----------------------------------------------------------------------------- 11HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled) 12{ 13 HRESULT hr=S_OK; 14 15 Minecraft *pMinecraft=Minecraft::GetInstance(); 16 17 ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys); 18 m_fScreenWidth=(float)pMinecraft->width_phys; 19 m_fRawWidth=(float)ssc.rawWidth; 20 m_fScreenHeight=(float)pMinecraft->height_phys; 21 m_fRawHeight=(float)ssc.rawHeight; 22 23 HXUIOBJ parent = m_hObj; 24 HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneEnchant" ); 25 HXUICLASS currentClass; 26 27 do 28 { 29 XuiElementGetParent(parent,&parent); 30 currentClass = XuiGetObjectClass( parent ); 31 } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); 32 33 assert( parent != NULL ); 34 35 VOID *pObj; 36 XuiObjectFromHandle( parent, &pObj ); 37 m_containerScene = (CXuiSceneEnchant *)pObj; 38 39 m_index = 0; 40 m_lastCost = 0; 41 m_iPad = 0; 42 m_costString = L""; 43 44 return hr; 45} 46 47void CXuiCtrlEnchantmentButton::SetData(int iPad, int index) 48{ 49 m_iPad = iPad; 50 m_index = index; 51} 52 53HRESULT CXuiCtrlEnchantmentButton::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled) 54{ 55 EnchantmentMenu *menu = m_containerScene->getMenu(); 56 57 int cost = menu->costs[m_index]; 58 59 if(cost != m_lastCost) 60 { 61 Minecraft *pMinecraft = Minecraft::GetInstance(); 62 if(cost > pMinecraft->localplayers[m_iPad]->experienceLevel && !pMinecraft->localplayers[m_iPad]->abilities.instabuild) 63 { 64 // Dark background 65 SetEnable(FALSE); 66 } 67 else 68 { 69 // Light background and focus background 70 SetEnable(TRUE); 71 } 72 m_costString = _toString<int>(cost); 73 m_lastCost = cost; 74 } 75 if(cost == 0) 76 { 77 // Dark background 78 SetEnable(FALSE); 79 pGetSourceTextData->bDisplay = FALSE; 80 } 81 else 82 { 83 pGetSourceTextData->szText = m_costString.c_str(); 84 pGetSourceTextData->bDisplay = TRUE; 85 } 86 87 bHandled = TRUE; 88 89 return S_OK; 90}