aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/SlotProgressControl.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Common/XUI/SlotProgressControl.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/Common/XUI/SlotProgressControl.cpp')
-rw-r--r--Minecraft.Client/Common/XUI/SlotProgressControl.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/XUI/SlotProgressControl.cpp b/Minecraft.Client/Common/XUI/SlotProgressControl.cpp
new file mode 100644
index 00000000..91f362a3
--- /dev/null
+++ b/Minecraft.Client/Common/XUI/SlotProgressControl.cpp
@@ -0,0 +1,88 @@
+#include "stdafx.h"
+
+#include "..\..\..\Minecraft.World\Slot.h"
+#include "..\..\..\Minecraft.World\ItemInstance.h"
+
+#include "SlotItemControlBase.h"
+#include "SlotProgressControl.h"
+
+int SlotProgressControl::GetValue()
+{
+ int value = 0;
+
+ HXUIOBJ hVisual, hParent;
+ this->GetParent( &hVisual );
+ XuiElementGetParent( hVisual, &hParent);
+
+ void* pvUserData;
+ XuiElementGetUserData( hParent, &pvUserData );
+
+ if( pvUserData != NULL )
+ {
+ SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
+
+ shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>();
+
+ if( pUserDataContainer->slot != NULL )
+ {
+ item = pUserDataContainer->slot->getItem();
+ }
+ else
+ {
+ item = pUserDataContainer->item;
+ }
+
+ if( item != NULL )
+ {
+ // TODO Should use getDamage instead even though it returns the same value
+ if( item->isDamaged() )
+ value = item->getDamageValue();
+ else
+ value = 0;
+ }
+ }
+ else
+ {
+ LPCWSTR name;
+ XuiElementGetId( hParent, &name );
+
+ OutputDebugStringW( name );
+ OutputDebugString( "\n" );
+ }
+
+ return value;
+}
+
+void SlotProgressControl::GetRange(int *pnRangeMin, int *pnRangeMax)
+{
+ *pnRangeMin = 0;
+ *pnRangeMax = 0;
+
+ HXUIOBJ hVisual, hParent;
+ this->GetParent( &hVisual );
+ XuiElementGetParent( hVisual, &hParent);
+
+ void* pvUserData;
+ XuiElementGetUserData( hParent, &pvUserData );
+
+ if( pvUserData != NULL )
+ {
+ SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
+
+ shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>();
+
+ if( pUserDataContainer->slot != NULL )
+ {
+ item = pUserDataContainer->slot->getItem();
+ }
+ else
+ {
+ item = pUserDataContainer->item;
+ }
+
+ if( item != NULL )
+ {
+ *pnRangeMax = item->getMaxDamage();
+ }
+ }
+} \ No newline at end of file