#include "stdafx.h" #include "InvenEquipWindow.h" #include "DragWindow.h" #include "ItemIcon.h" #include "ObjectManager.h" #include "Hero.h" cInvenEquipWindow::cInvenEquipWindow() { for( int i = 0; i < EQUIP_SLOT_COUNT; ++i ) mIcon[i] = 0; } cInvenEquipWindow::~cInvenEquipWindow() { } void cInvenEquipWindow::Open() { /// ¾ÆÀÌÅÛ ½½·Ô °Ë»ç ITEMMAN->CheckItemSlot( INVENTORY_HAND_RIGHT1 ); ITEMMAN->CheckItemSlot( INVENTORY_HAND_RIGHT2 ); ITEMMAN->CheckItemSlot( INVENTORY_COSTUME_BODY1 ); /// ½½·Ô Àá±×±â. unsigned short slotEndIndex = HERO->GetWearCardEndSlot(); if( slotEndIndex < INVENTORY_WEAR_RING || slotEndIndex > INVENTORY_WEAR_CARD3 ) { assert( 0 && "Bad slot index" ); return; } /// ÇØ´ç ½½·Ô À妽º±îÁö ¾ÆÀÌÄÜ enable ½Ã۱â for( int slotIndex = INVENTORY_WEAR_CARD1; slotIndex <= INVENTORY_WEAR_CARD3; ++slotIndex ) { int iconIndex = slotIndex - INVENTORY_WEAR_BEGIN; if( slotIndex <= slotEndIndex ) { mIcon[iconIndex]->SetEnabled( true ); } else { mIcon[iconIndex]->SetEnabled( false ); /// ½½·Ô ¸·Èû À̹ÌÁö·Î ¹Ù²Ù±â cIconParam* pIconParam = UIMAN->GetIconParam( 217 ); mIcon[iconIndex]->ChangeImage( pIconParam ); } } } bool cInvenEquipWindow::OnCreate( cUINodeProperty* /*property*/ ) { /// ¾ÆÀÌÄÜÀ» »ý¼ºx cString str; for( unsigned short i = 0, slotIndex = INVENTORY_WEAR_BEGIN; i < EQUIP_SLOT_COUNT; ++i, ++slotIndex ) { str.Format( "InvenEquip_Icon%02d", i ); cItemIcon* icon = new cItemIcon; if( icon->CreateBySkinName( str, this, slotIndex ) == false ) return false; mIcon[i] = icon; ITEMMAN->BindIcon( slotIndex, icon ); /// ¾ÆÀÌÄÜ ÁÂÇ¥ ¼¼ÆÃ( ¹«±â½ºÀ§Äª°ü·Ã ) ITEMMAN->SetWeaponIconPos( slotIndex, icon->GetRelativeRect() ); } return true; } void cInvenEquipWindow::OnIconDragged( cUINode* caller, unsigned int id, const cUIPos& pos, bool shift ) { cItemIcon* icon = (cItemIcon*)caller; if( icon ) UIMAN->ShowDrag( (cUIWindow*)mpParent, DRAG_FROM_INVENTORY, icon, pos, shift ); } void cInvenEquipWindow::OnIconDoubleClicked( cUINode* caller, unsigned int /*id*/ ) { cItemIcon* icon = (cItemIcon*)caller; if( icon ) ITEMMAN->TryToUnEquipItem( icon->GetSlotIndex() ); } void cInvenEquipWindow::OnIconClicked( cUINode* caller, unsigned int id ) { /// Àκ¥Å丮 À©µµ¿ì¿¡ ¾ÆÀÌÄÜ ´­¸² À̺¥Æ® if( caller ) SendEvent( mpParent, eUIEVENT_ICON_CLICKED, caller, id ); } bool cInvenEquipWindow::SetWearCardSlot( unsigned short slotEndIndex ) { if( slotEndIndex < INVENTORY_WEAR_CARD1 || slotEndIndex > INVENTORY_WEAR_CARD3 ) { assert( 0 && "Bad slot index" ); return false; } if( slotEndIndex <= INVENTORY_WEAR_BEGIN ) { assert(0); return false; } /// ÇØ´ç ½½·Ô À妽º ¾ÆÀÌÄÜ enable ½Ã۱â unsigned short iconIndex = (unsigned short)(slotEndIndex - INVENTORY_WEAR_BEGIN); if( mIcon[iconIndex] ) { mIcon[iconIndex]->SetEnabled( true ); mIcon[iconIndex]->ClearImage(); } return true; }