Files
2026-06-01 12:46:52 +02:00

245 lines
8.3 KiB
C++

#pragma once
#include <mmo/ArType.h>
//#include "SUIWnd.h"
#include "SGameMessage.h"
#include "SUIDefine.h"
class SUIDisplayInfo;
class SInventorySlot;
class SShopSlot;
//
// 상점
//
class SUIShopWnd : public SUIWnd
{
public:
SUIShopWnd( class SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo );
virtual ~SUIShopWnd();
virtual bool InitControls( KPoint kPos );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
private:
SUIDisplayInfo* m_pDisplayInfo;
/// 아이템 슬롯 정보 표현용 control들의 ID
struct SLOT_INFO
{
std::string strIconControl;
std::string strStaticNameControl;
std::string strStaticCountControl;
std::string strStaticPriceControl;
std::string strStaticUnitControl;
};
SLOT_INFO* m_pSlotControlIDs;
int m_nSlotStartIndex; ///< 첫번째 슬롯의 아이템 인덱스 ( 스크롤 시킴에 따라 바뀐다. )
int m_nSlotCountY; ///< 현재 보여지는 슬롯들의 세로 갯수 ( 리사이즈 시킴에 따라 바뀐다. )
int m_nScrollBarTopOffset; ///< 스크롤바 resize의 기준 offset
int m_nScrollBarBottomOffset;
UI_ITEM_CATEGORY m_CurrentCategory; ///< 현재 선택된 아이템 분류
int m_nCurrentSelect; ///< 현재 선택된 아이템 인덱스 (없으면 -1)
std::vector<SInventorySlot*> m_vecSellItemList;
std::vector<SShopSlot*> m_vecBuyItemList;
void RefreshScrollBar();
void RefreshSlots();
void RefreshSelection();
void RefreshItems();
void RefreshGold();
void RefreshWeight();
void SelectItemSendToKart();
void MoveShoppingKartWindow();
void SetBuyModeShoppingKartWindow();
int GetSlotSellItemIndex( int nSlotControlNum ) const;
int GetSlotBuyItemIndex( int nSlotControlNum ) const;
SInventorySlot* GetSlotSellItem( int nSlotControlNum ) const;
SShopSlot* GetSlotBuyItem( int nSlotControlNum ) const;
bool IsBuyMode() const;
int GetSlotControlNum( const char* szSlotControlID ) const;
bool m_bCtrlKey;
bool m_bShiptKey;
};
class SUIShopKartWnd : public SUIWnd
{
public:
SUIShopKartWnd( SGameManager* pGameManager, SUIDisplayInfo* pDisplayInfo );
virtual ~SUIShopKartWnd();
virtual bool InitControls( KPoint kPos );
virtual bool InitData( bool bReload = false );
virtual void* Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void ProcMsgAtStatic( SGameMessage* pMsg );
virtual void OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd = true );
private:
SUIDisplayInfo* m_pDisplayInfo;
/// 아이템 슬롯 정보 표현용 control들의 ID
struct SLOT_INFO
{
std::string strIconControl;
std::string strStaticNameControl;
std::string strStaticCountControl;
std::string strStaticPriceControl;
std::string strStaticUnitControl;
};
SLOT_INFO* m_pSlotControlIDs;
int m_nSlotStartIndex; ///< 첫번째 슬롯의 아이템 인덱스 ( 스크롤 시킴에 따라 바뀐다. )
bool m_bIsShop;
bool m_bBuyMode; ///< 구입 or 판매
bool m_bCtrlKey;
bool m_bShiptKey;
int m_nCurrentSelect;
bool m_bAct; // 카트에 구분 : 기본 FALSE, 구입/판매 TRUE;
DWORD m_PrevProcessTime;
struct KART_BUYITEM
{
ItemBase::ItemCode ItemID;
int nSummonID;
int nEnhance;
int nLevel;
int nEndurance;
int nFlag;
count_t nItemCount;
int nSocket[ ItemBase::MAX_SOCKET_NUMBER ];
int nIndex;
int remain_time;
char elemental_effect_type;
int elemental_effect_remain_time;
int elemental_effect_attack_point;
int elemental_effect_magic_point;
int ethereal_durability; // 노점bintitle
ItemBase::ItemCode appearanceCode;
TS_ITEM_BASE_INFO::AwakenOption stAwakenOption;
TS_ITEM_BASE_INFO::RANDOM_OPTION stRandomOption;
int nAdditionalItemEffect; // Fraun Sky Accessories 7/12/2025
KART_BUYITEM( ItemBase::ItemCode id,
int _nSummonID,
count_t _nItemCount,
int _nEnhance = 0,
int _nLevel = 0,
int _nFlag = 0,
int _nEndurance = 0,
int* pnSocket = NULL,
int _nIndex = 0,
int _remain_time = 0,
char elemental_effect_type_ = 0,
int elemental_effect_remain_time_ = 0,
int elemental_effect_attack_point_ = 0,
int elemental_effect_magic_point_ = 0,
int ethereal_durability_ = 0,
ItemBase::ItemCode appearanceCode_ = 0,
TS_ITEM_BASE_INFO::AwakenOption* pAwakenOption = NULL, // 아 짜증나... 위에 디폴트 인자 때문에 어쩔수없이 포인터로... 코드 꼬라지 보소 ㅠㅠ (lenahyang)
TS_ITEM_BASE_INFO::RANDOM_OPTION* pRandomOption = NULL,
int nAdditionalItemEffect = 0 // Fraun Sky Accessories 7/12/2025
)
: ItemID( id ), nSummonID( _nSummonID ), nItemCount( _nItemCount ), nEnhance( _nEnhance ), nLevel( _nLevel ), nFlag( _nFlag ), nEndurance( _nEndurance ), nIndex( _nIndex ),
remain_time(_remain_time),
elemental_effect_type( elemental_effect_type_ ),
elemental_effect_remain_time(elemental_effect_remain_time_),
elemental_effect_attack_point( elemental_effect_attack_point_ ), elemental_effect_magic_point( elemental_effect_magic_point_ ),
ethereal_durability( ethereal_durability_ ) // bintitle
,appearanceCode( appearanceCode_ )
{
if( pnSocket )
memcpy( nSocket, pnSocket, sizeof( nSocket ) );
else
memset( nSocket, 0, sizeof( nSocket ) );
if( pAwakenOption )
memcpy( &stAwakenOption, pAwakenOption, sizeof( stAwakenOption ) );
if( pRandomOption )
memcpy( &stRandomOption, pRandomOption, sizeof( stRandomOption ) );
}
TS_ITEM_BASE_INFO::AwakenOption* GetAwakenOption( void ) { return &stAwakenOption; }
TS_ITEM_BASE_INFO::RANDOM_OPTION* GetRandomOption( void ) { return &stRandomOption; }
};
struct KART_SELLITEM
{
AR_HANDLE handle;
count_t nItemCount;
int nIndex;
KART_SELLITEM( AR_HANDLE _handle, count_t _nItemCount, int _nIndex )
: handle( _handle ), nItemCount( _nItemCount ), nIndex(_nIndex) { }
};
typedef std::vector<KART_BUYITEM> KARTBUYITEM_VECTOR;
typedef std::vector<KART_SELLITEM> KARTSELLITEM_VECTOR;
KARTSELLITEM_VECTOR m_KartSellItemsVector; ///< 현재 표시중인 판매할 아이템 벡터
KARTBUYITEM_VECTOR m_KartBuyItemsVector; ///< 현재 표시중인 구입할 아이템 벡터
/// 카트 추가 예약 상태
enum KART_RESERVE
{
KART_NO_RESERVE,
KART_BUYITEM_RESERVE,
KART_SELLITEM_RESERVE,
};
KART_RESERVE m_ReserveState;
ItemBase::ItemCode m_ReserveBuyItemID; ///< 카트 추가 예약 구입 아이템
AR_HANDLE m_ReserveSellItemHandle; ///< 카트 추가 예약 판매 아이템
SUIShopKartWnd::KARTBUYITEM_VECTOR::iterator GetBuyItem( ItemBase::ItemCode ItemID );
SUIShopKartWnd::KARTSELLITEM_VECTOR::iterator GetSellItem( AR_HANDLE hItem );
void AddBuyItem( const KART_BUYITEM & itemInfo );
void AddBuyItem( ItemBase::ItemCode ItemID, count_t nItemCount );
void RemoveBuyItem( int nIndex );
void RemoveBuyItem( int nIndex, count_t nCount );
void AddSellItem( AR_HANDLE hItem, count_t nItemCount, int index );
void RemoveSellItem( int nIndex );
void RemoveSellItem( int nIndex, count_t nCount );
void RemoveAllKartItems();
void ShopBuyOrder();
void ShopSellOrder();
void StoreBuyOrder();
void ShopSellbyUser();
void RefreshScrollBar();
void RefreshSlots();
void RefreshGoldAndWeight();
void Process( DWORD time );
int GetSlotKartSellItemIndex( int nSlotControlNum ) const;
int GetSlotKartBuyItemIndex( int nSlotControlNum ) const;
const SUIShopKartWnd::KART_SELLITEM* GetSlotKartSellItem( int nSlotControlNum ) const;
const SUIShopKartWnd::KART_BUYITEM* GetSlotKartBuyItem( int nSlotControlNum ) const;
bool IsShop() const { return m_bIsShop; }
bool IsBuyMode() const { return m_bBuyMode; }
int GetSlotControlNum( const char* szSlotControlID ) const;
void GetTotalPriceAndWeight( money_t& rTotalPrice, float& rTotalWeight ) const;
void CheckWeightOver( int nItemCode, count_t& nItemCnt );
};