diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp')
| -rw-r--r-- | Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp new file mode 100644 index 00000000..dfb9b5ca --- /dev/null +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_EnchantButton.cpp @@ -0,0 +1,90 @@ +#include "stdafx.h" +#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" +#include "..\..\..\Minecraft.World\StringHelpers.h" +#include "..\..\Font.h" +#include "..\..\Lighting.h" +#include "..\..\MultiPlayerLocalPlayer.h" +#include "XUI_Scene_Enchant.h" +#include "XUI_Ctrl_EnchantButton.h" + +//----------------------------------------------------------------------------- +HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled) +{ + HRESULT hr=S_OK; + + 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; + + HXUIOBJ parent = m_hObj; + HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneEnchant" ); + HXUICLASS currentClass; + + do + { + XuiElementGetParent(parent,&parent); + currentClass = XuiGetObjectClass( parent ); + } while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) ); + + assert( parent != NULL ); + + VOID *pObj; + XuiObjectFromHandle( parent, &pObj ); + m_containerScene = (CXuiSceneEnchant *)pObj; + + m_index = 0; + m_lastCost = 0; + m_iPad = 0; + m_costString = L""; + + return hr; +} + +void CXuiCtrlEnchantmentButton::SetData(int iPad, int index) +{ + m_iPad = iPad; + m_index = index; +} + +HRESULT CXuiCtrlEnchantmentButton::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled) +{ + EnchantmentMenu *menu = m_containerScene->getMenu(); + + int cost = menu->costs[m_index]; + + if(cost != m_lastCost) + { + Minecraft *pMinecraft = Minecraft::GetInstance(); + if(cost > pMinecraft->localplayers[m_iPad]->experienceLevel && !pMinecraft->localplayers[m_iPad]->abilities.instabuild) + { + // Dark background + SetEnable(FALSE); + } + else + { + // Light background and focus background + SetEnable(TRUE); + } + m_costString = _toString<int>(cost); + m_lastCost = cost; + } + if(cost == 0) + { + // Dark background + SetEnable(FALSE); + pGetSourceTextData->bDisplay = FALSE; + } + else + { + pGetSourceTextData->szText = m_costString.c_str(); + pGetSourceTextData->bDisplay = TRUE; + } + + bHandled = TRUE; + + return S_OK; +}
\ No newline at end of file |
