From 4cc0bd5e25d860158c0c157e09a29eaad1e4dd38 Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Sat, 14 Mar 2026 07:17:22 +1100 Subject: [PATCH] Remove WinAPI helper types from XUI controls --- .../Platform/Common/XUI/XUI_Ctrl_4JList.cpp | 50 +++++++++---------- .../Platform/Common/XUI/XUI_Ctrl_4JList.h | 4 +- .../XUI/XUI_Ctrl_CraftIngredientSlot.cpp | 12 ++--- .../Common/XUI/XUI_Ctrl_CraftIngredientSlot.h | 8 +-- .../Common/XUI/XUI_Ctrl_EnchantButton.cpp | 4 +- .../Common/XUI/XUI_Ctrl_EnchantmentBook.cpp | 6 +-- .../XUI/XUI_Ctrl_EnchantmentButtonText.cpp | 4 +- .../Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp | 5 +- .../Common/XUI/XUI_Ctrl_MinecraftSlot.cpp | 6 +-- .../Common/XUI/XUI_Ctrl_MinecraftSlot.h | 6 +-- .../Common/XUI/XUI_Ctrl_SliderWrapper.cpp | 14 +++--- .../Common/XUI/XUI_Ctrl_SliderWrapper.h | 4 +- 12 files changed, 61 insertions(+), 62 deletions(-) diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.cpp index 4016335ee..0ab6614bf 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.cpp @@ -16,41 +16,41 @@ void CXuiCtrl4JList::AddData( const LIST_ITEM_INFO& ItemInfo , int iSortListFrom { // need to allocate memory for the structure and its strings // and remap the string pointers - DWORD dwBytes=0; - DWORD dwLen1=0; - DWORD dwLen2=0; + std::size_t totalBytes = 0; + std::size_t textBytes = 0; + std::size_t imageBytes = 0; if(ItemInfo.pwszText) { - dwLen1=(int)wcslen(ItemInfo.pwszText)*sizeof(WCHAR); - dwBytes+=dwLen1+sizeof(WCHAR); + textBytes = wcslen(ItemInfo.pwszText) * sizeof(WCHAR); + totalBytes += textBytes + sizeof(WCHAR); } if(ItemInfo.pwszImage) { - dwLen2=(int)(wcslen(ItemInfo.pwszImage))*sizeof(WCHAR); - dwBytes+=dwLen2+sizeof(WCHAR); + imageBytes = wcslen(ItemInfo.pwszImage) * sizeof(WCHAR); + totalBytes += imageBytes + sizeof(WCHAR); } - dwBytes+=sizeof( LIST_ITEM_INFO ); - LIST_ITEM_INFO *pItemInfo = (LIST_ITEM_INFO *)new BYTE[dwBytes]; - ZeroMemory(pItemInfo,dwBytes); + totalBytes += sizeof(LIST_ITEM_INFO); + LIST_ITEM_INFO *pItemInfo = reinterpret_cast(new unsigned char[totalBytes]); + ZeroMemory(pItemInfo, totalBytes); XMemCpy( pItemInfo, &ItemInfo, sizeof( LIST_ITEM_INFO ) ); - if(dwLen1!=0) + if(textBytes != 0) { - XMemCpy( &pItemInfo[1], ItemInfo.pwszText, dwLen1 ); + XMemCpy( &pItemInfo[1], ItemInfo.pwszText, textBytes ); pItemInfo->pwszText=(LPCWSTR)&pItemInfo[1]; - if(dwLen2!=0) + if(imageBytes != 0) { - BYTE *pwszImage = ((BYTE *)&pItemInfo[1])+dwLen1+sizeof(WCHAR); - XMemCpy( pwszImage, ItemInfo.pwszImage, dwLen2 ); - pItemInfo->pwszImage=(LPCWSTR)pwszImage; + unsigned char *imageText = reinterpret_cast(&pItemInfo[1]) + textBytes + sizeof(WCHAR); + XMemCpy( imageText, ItemInfo.pwszImage, imageBytes ); + pItemInfo->pwszImage = reinterpret_cast(imageText); } } - else if(dwLen2!=0) + else if(imageBytes != 0) { - XMemCpy( &pItemInfo[1], ItemInfo.pwszImage, dwLen2 ); + XMemCpy( &pItemInfo[1], ItemInfo.pwszImage, imageBytes ); pItemInfo->pwszImage=(LPCWSTR)&pItemInfo[1]; } @@ -162,9 +162,9 @@ int CXuiCtrl4JList::GetIndexByUserData(int iData) return 0; } -CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(DWORD dw) +CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(int index) { - return *m_vListData[dw]; + return *m_vListData[index]; } CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetDataiData(int iData) @@ -356,14 +356,14 @@ HRESULT CXuiCtrl4JList::OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableD } -HRESULT CXuiCtrl4JList::SetBorder(DWORD dw,BOOL bShow) +HRESULT CXuiCtrl4JList::SetBorder(int index, bool show) { CXuiControl Control; HXUIOBJ hVisual,hBorder; - GetItemControl(dw,&Control); + GetItemControl(index,&Control); Control.GetVisual(&hVisual); XuiElementGetChildById(hVisual,L"Border",&hBorder); - return XuiElementSetShow(hBorder,bShow); + return XuiElementSetShow(hBorder,show); } void CXuiCtrl4JList::SetSelectionChangedHandle(HXUIOBJ hObj) @@ -383,7 +383,7 @@ HRESULT CXuiCtrl4JList::OnDestroy() { XuiDestroyBrush( m_vListData[i]->hXuiBrush ); } - delete [] (BYTE *)m_vListData[i]; + delete [] reinterpret_cast(m_vListData[i]); } } return S_OK; @@ -402,4 +402,4 @@ HRESULT CXuiCtrl4JList::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChan bHandled = xuiMsg.bHandled; } return S_OK; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.h b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.h index 0cd03b218..b83bfcf38 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.h +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_4JList.h @@ -40,10 +40,10 @@ public: void UpdateGraphic(int iItem,HXUIBRUSH hXuiBrush ); void UpdateGraphic(FILETIME *pfTime,HXUIBRUSH hXuiBrush ); void UpdateGraphicFromiData(int iData,HXUIBRUSH hXuiBrush ); - LIST_ITEM_INFO& GetData(DWORD dw); + LIST_ITEM_INFO& GetData(int index); LIST_ITEM_INFO& GetData(FILETIME *pFileTime); LIST_ITEM_INFO& GetDataiData(int iData); - HRESULT SetBorder(DWORD dw,BOOL bShow); // for a highlight around the current selected item in the controls layout + HRESULT SetBorder(int index, bool show); // for a highlight around the current selected item in the controls layout void SetSelectionChangedHandle(HXUIOBJ hObj); protected: diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp index 2ea13a5f5..5b8843add 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp @@ -55,19 +55,19 @@ HRESULT CXuiCtrlCraftIngredientSlot::OnGetSourceText(XUIMessageGetSourceText *pG return S_OK; } -void CXuiCtrlCraftIngredientSlot::SetRedBox(BOOL bVal) +void CXuiCtrlCraftIngredientSlot::SetRedBox(bool show) { HRESULT hr=S_OK; HXUIOBJ hObj,hObjChild; hr=GetVisual(&hObj); XuiElementGetChildById(hObj,L"BoxRed",&hObjChild); - XuiElementSetShow(hObjChild,bVal); + XuiElementSetShow(hObjChild,show); XuiElementGetChildById(hObj,L"Exclaim",&hObjChild); - XuiElementSetShow(hObjChild,bVal); + XuiElementSetShow(hObjChild,show); } -void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool isFoil, BOOL bShow) +void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool isFoil, bool bShow) { m_item = nullptr; m_iID=iId; @@ -92,7 +92,7 @@ void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCo XuiElementSetShow(m_hObj,bShow); } -void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow) +void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow) { if(item == NULL) SetIcon(iPad, 0,0,0,0,0,false,false,bShow); else @@ -120,4 +120,4 @@ void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc) XuiControlSetText(hObjChild,Desc); XuiElementSetShow(hObjChild,Desc==NULL?FALSE:TRUE); m_Desc=Desc; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.h b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.h index 0a46227be..771f27fbf 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.h +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_CraftIngredientSlot.h @@ -14,9 +14,9 @@ public: CXuiCtrlCraftIngredientSlot(); virtual ~CXuiCtrlCraftIngredientSlot() { }; - void SetRedBox(BOOL bVal); - void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha, bool bDecorations, bool isFoil = false, BOOL bShow=TRUE); - void SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow=TRUE); + void SetRedBox(bool show); + void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha, bool bDecorations, bool isFoil = false, bool bShow=true); + void SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow=true); void SetDescription(LPCWSTR Desc); protected: @@ -42,4 +42,4 @@ private: bool m_isFoil; LPCWSTR m_Desc; bool m_isDirty; -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantButton.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantButton.cpp index b655644ac..b9734bcb0 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantButton.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantButton.cpp @@ -32,7 +32,7 @@ HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHan assert( parent != NULL ); - VOID *pObj; + void *pObj; XuiObjectFromHandle( parent, &pObj ); m_containerScene = (CXuiSceneEnchant *)pObj; @@ -87,4 +87,4 @@ HRESULT CXuiCtrlEnchantmentButton::OnGetSourceDataText(XUIMessageGetSourceText * bHandled = TRUE; return S_OK; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp index 50cc6bce7..741e0cd8e 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentBook.cpp @@ -23,7 +23,7 @@ //----------------------------------------------------------------------------- CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook() : - m_bDirty(FALSE), + m_bDirty(false), m_fScale(1.0f), m_fAlpha(1.0f) { @@ -64,7 +64,7 @@ HRESULT CXuiCtrlEnchantmentBook::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl assert( parent != NULL ); - VOID *pObj; + void *pObj; XuiObjectFromHandle( parent, &pObj ); m_containerScene = (CXuiSceneEnchant *)pObj; @@ -343,4 +343,4 @@ void CXuiCtrlEnchantmentBook::tickBook() flipA += (diff - flipA) * 0.9f; flip = flip + flipA; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp index 609050b06..a2de1fa4e 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_EnchantmentButtonText.cpp @@ -42,7 +42,7 @@ HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData, BOOL& r assert( parent != NULL ); - VOID *pObj; + void *pObj; XuiObjectFromHandle( parent, &pObj ); m_parentControl = (CXuiCtrlEnchantmentButton *)pObj; @@ -182,4 +182,4 @@ std::wstring CXuiCtrlEnchantmentButtonText::EnchantmentNames::getRandomName() word += words[random.nextInt(words.size())]; } return word; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp index f9a10b2ab..fdd732787 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftPlayer.cpp @@ -15,7 +15,7 @@ //----------------------------------------------------------------------------- CXuiCtrlMinecraftPlayer::CXuiCtrlMinecraftPlayer() : - m_bDirty(FALSE), + m_bDirty(false), m_fScale(1.0f), m_fAlpha(1.0f) { @@ -45,7 +45,7 @@ HRESULT CXuiCtrlMinecraftPlayer::OnInit(XUIMessageInit* pInitData, BOOL& rfHandl assert( parent != NULL ); - VOID *pObj; + void *pObj; XuiObjectFromHandle( parent, &pObj ); m_containerScene = (CXuiSceneInventory *)pObj; @@ -187,4 +187,3 @@ HRESULT CXuiCtrlMinecraftPlayer::OnRender(XUIMessageRender *pRenderData, BOOL &b } - diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp index b26bbf8e7..858b15cc0 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.cpp @@ -73,7 +73,7 @@ CXuiCtrlMinecraftSlot::~CXuiCtrlMinecraftSlot() delete m_pItemRenderer; } -VOID CXuiCtrlMinecraftSlot::SetPassThroughDataAssociation(unsigned int iID, unsigned int iData) +void CXuiCtrlMinecraftSlot::SetPassThroughDataAssociation(unsigned int iID, unsigned int iData) { m_item = nullptr; m_iPassThroughIdAssociation = iID; @@ -309,7 +309,7 @@ HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHa } -void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,BOOL bShow, bool isFoil) +void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool bShow, bool isFoil) { m_item = nullptr; m_iID=iId; @@ -343,7 +343,7 @@ void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, i XuiElementSetShow(m_hObj,bShow); } -void CXuiCtrlMinecraftSlot::SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow) +void CXuiCtrlMinecraftSlot::SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow) { m_item = item; m_isFoil = item->isFoil(); diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.h b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.h index 7c9aca131..2bb03eebd 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.h +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_MinecraftSlot.h @@ -16,14 +16,14 @@ class CXuiCtrlMinecraftSlot : public CXuiControlImpl public: XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSlot, L"CXuiCtrlMinecraftSlot", XUI_CLASS_LABEL) - VOID SetPassThroughDataAssociation(unsigned int iID, unsigned int iData); + void SetPassThroughDataAssociation(unsigned int iID, unsigned int iData); CXuiCtrlMinecraftSlot(); virtual ~CXuiCtrlMinecraftSlot(); void renderGuiItem(Font *font, Textures *textures,ItemInstance *item, int x, int y); void RenderItem(); - void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,BOOL bShow, bool isFoil); - void SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow=TRUE); + void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool bShow, bool isFoil); + void SetIcon(int iPad, std::shared_ptr item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow=true); protected: diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.cpp index ddc01ef3d..6b3424d49 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.cpp @@ -5,7 +5,7 @@ HRESULT CXuiCtrlSliderWrapper::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) { - VOID *pObj; + void *pObj; HXUIOBJ hObjChild; XuiElementGetChildById(m_hObj,L"FocusSink",&hObjChild); @@ -17,8 +17,8 @@ HRESULT CXuiCtrlSliderWrapper::OnInit( XUIMessageInit* pInitData, BOOL& bHandled m_pSlider = (CXuiSlider *)pObj; m_sliderActive = false; - m_bDisplayVal=true; - m_bPlaySound=false; // make this false to avoid a sound being played in the first setting of the slider value in a scene + m_bDisplayVal = true; + m_bPlaySound = false; // make this false to avoid a sound being played in the first setting of the slider value in a scene XuiSetTimer( m_hObj,NO_SOUND_TIMER,50); bHandled = TRUE; return S_OK; @@ -66,7 +66,7 @@ HRESULT CXuiCtrlSliderWrapper::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINoti if(m_bPlaySound) { - m_bPlaySound=false; + m_bPlaySound = false; CXuiSceneBase::PlayUISFX(eSFX_Scroll); XuiSetTimer( m_hObj,NO_SOUND_TIMER,150); } @@ -108,7 +108,7 @@ HRESULT CXuiCtrlSliderWrapper::SetValue( int nValue ) return S_OK; } -HRESULT CXuiCtrlSliderWrapper::SetValueDisplay( BOOL bShow ) +HRESULT CXuiCtrlSliderWrapper::SetValueDisplay(bool show) { CXuiCtrlSliderWrapper *pThis; HXUIOBJ hVisual,hText; @@ -121,7 +121,7 @@ HRESULT CXuiCtrlSliderWrapper::SetValueDisplay( BOOL bShow ) if(hText!=NULL) { - XuiElementSetShow(hText,bShow); + XuiElementSetShow(hText,show); } return S_OK; @@ -171,4 +171,4 @@ HRESULT CXuiCtrlSliderWrapper::SetRange( int nRangeMin, int nRangeMax) return hr; pThis->m_pSlider->SetRange(nRangeMin, nRangeMax); return S_OK; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.h b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.h index 03659fcae..0b8be115b 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.h +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Ctrl_SliderWrapper.h @@ -33,6 +33,6 @@ public: HRESULT SetRange( int nRangeMin, int nRangeMax); LPCWSTR GetText( ); HRESULT SetText(LPCWSTR text, int iDataAssoc=0 ); - HRESULT SetValueDisplay( BOOL bShow ); + HRESULT SetValueDisplay( bool show ); -}; \ No newline at end of file +};