From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- .../Common/XUI/XUI_Control_ComboBox.cpp | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp (limited to 'Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp') diff --git a/Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp b/Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp new file mode 100644 index 00000000..0096da44 --- /dev/null +++ b/Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp @@ -0,0 +1,98 @@ +#include "stdafx.h" +#include "XUI_Control_ComboBox.h" +#include "..\Xbox_App.h" + +HRESULT CXuiControl4JComboBox::OnInit(XUIMessageInit *pInitData, BOOL& bHandled) +{ + m_ListData.nItems=0; + m_ListData.pItems=NULL; + + return S_OK; +} + +void CXuiControl4JComboBox::SetData(LIST_ITEM_INFO *pItems,int iCount) +{ + CXuiControl4JComboBox *pThis; + HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis); + + // copy the data in + pThis->m_ListData.pItems= new LIST_ITEM_INFO [iCount] ; + memcpy(pThis->m_ListData.pItems,pItems,sizeof(LIST_ITEM_INFO)*iCount); + pThis->m_ListData.nItems=iCount; + + //InsertItems( 0, iCount ); +} + +int CXuiControl4JComboBox::GetSelectedIndex() +{ + return XuiListGetCurSel(GetListObject(),NULL); +} + +// Gets called every frame +HRESULT CXuiControl4JComboBox::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled) +{ + if( ( 0 == pGetSourceTextData->iData ) && ( ( pGetSourceTextData->bItemData ) ) ) + { + pGetSourceTextData->szText = + m_ListData.pItems[pGetSourceTextData->iItem].pwszText; + bHandled = TRUE; + } + return S_OK; +} + +HRESULT CXuiControl4JComboBox::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData,BOOL& bHandled) +{ + pGetItemCountData->cItems = m_ListData.nItems; + bHandled = TRUE; + return S_OK; +} + +HRESULT CXuiControl4JComboBox::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled) +{ + return S_OK; + + //if( ( 0 == pGetSourceImageData->iData ) && ( pGetSourceImageData->bItemData ) ) + //{ + // // Check for a brush + + // if(m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush!=NULL) + // { + // pGetSourceImageData->hBrush=m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush; + // } + // else + // { + // pGetSourceImageData->szPath = + // m_ListData.pItems[pGetSourceImageData->iItem].pwszImage; + // } + // bHandled = TRUE; + //} + //return S_OK; +} + +HRESULT CXuiControl4JComboBox::OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled) +{ + if(m_ListData.pItems!=NULL && m_ListData.nItems!=0) + { + pGetItemEnableData->bEnabled = + m_ListData.pItems[pGetItemEnableData->iItem].fEnabled; + } + bHandled = TRUE; + return S_OK; +} + +//---------------------------------------------------------------------------------- +// Handler for the button press message. +//---------------------------------------------------------------------------------- +HRESULT CXuiControl4JComboBox::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) +{ + // This assumes all buttons can only be pressed with the A button + CScene_Base::HandleKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); + + if(hObjPressed==GetValueObject()) + { + XuiElementSetShow(GetListObject(),TRUE); + XuiElementSetFocus(GetListObject()); + rfHandled = TRUE; + } + return S_OK; +} \ No newline at end of file -- cgit v1.2.3