Files
Leviathan/Client/Game/game/Interface/SUIProperty.cpp
T
2026-06-01 12:46:52 +02:00

470 lines
11 KiB
C++

#include "stdafx.h"
#include "KTypes.h"
//#include "Util.h"
#include "SUIDefine.h"
#include "KUIControlStatic.h"
#include "KUIControlQuickEffect.h"
//#include "SUIWnd.h"
#include "SUIDisplayInfo.h"
//#include "SUIUtil.h"
#include "SUIProperty.h"
#include "SUILazyTooltip.h"
#include "SStringDB.h"
#include "SItemDB.h"
#include "SInventoryMgr.h"
#include "SSkillSlot.h"
#include "SSkillDB.h"
#include "MonsterBase.h"
#include "SDebug_Util.h"
#include "SGameSystem.h"
extern SGameSystem * g_pCurrentGameSystem;
using namespace sui;
using namespace rp;
//
// kui_window_caption_property
//
void kui_window_caption_property::get_caption_string( property& data, std::string& caption )
{
switch( data.get_class() )
{
case CID_STRING:
caption += data.get_string_value();
break;
case CID_INT:
{
std::string buffer;
XStringUtil::Format( buffer, "%d", data.get_int_value() );
caption += buffer;
}
break;
case CID_FLOAT:
{
std::string buffer;
XStringUtil::Format( buffer, "%f", data.get_float_value() );
caption += buffer;
}
break;
case CID_INT64:
{
std::string buffer;
XStringUtil::Format( buffer, "%I64d", data.get_int64_value() );
caption += buffer;
}
break;
}
}
void kui_window_caption_property::on_update( property& data )
{
KUIWnd* window = get_window();
if( window )
{
std::string caption;
if( data.is_valid() )
{
get_caption_string( data, caption );
if( caption.size() > 0 && m_caption_decorator )
XStringUtil::Format( caption, m_caption_decorator, caption.c_str() );
}
window->SetCaption( caption.c_str() );
}
}
//
// kui_window_numeric_caption_property
//
void kui_window_numeric_caption_property::get_caption_string( property& data, std::string& caption )
{
if( data.get_class() == CID_INT )
{
caption += helper::int_to_comma_numeric( data.get_int_value() );
return;
}
else if( data.get_class() == CID_INT64 )
{
caption += helper::int_to_comma_numeric( data.get_int64_value() );
return;
}
assert( false && "kui_window_numeric_caption_property : not numeric value!!" );
}
//
// kui_window_itemslot_icon_property
//
void kui_window_itemslot_icon_property::on_update( property& data )
{
KUIControlMultiIcon* icon = static_cast< KUIControlMultiIcon* >( get_pointer_value() );
if( icon )
{
ResetMultiIcon( icon, 0, 8 );
SInventorySlot* item = 0;
if( data.is_valid() )
{
assert( data.get_class() == CID_UINT );
AR_HANDLE item_handle = static_cast< AR_HANDLE >( data.get_uint_value() );
item = m_display->GetInventoryManager()->GetItemInfo( item_handle );
}
if( data.is_valid() && item )
{
// 2010.06.10 - prodongi
//icon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( item->GetItemCode() ) );
/// 2011.08.03 - prodongi
if( !setSkillCardIcon(icon, item->GetItemCode()) && !setSummonCardIcon( icon, item ) )
{
std::string iconName;
getIconNameAtDurability(item, iconName);
icon->SetIcon( 0, c_szDEF_SPR_NAME, iconName.c_str());
//gmpbigsun( 20130225 ) 빈카드 표시 제거예정
/// 2011.10.21 빈카드 표시 - prodongi
//if (isEmptyCreatureCard(item->GetItemCode(), item->GetXFlag()))
// icon->SetIcon( 2, c_szDEF_SPR_NAME, "common_mark_titanium_empty_card");
}
if(item->GetItemAppearance())
icon->SetIcon( 4, c_szDEF_SPR_NAME, g_strLookChangeIcon );
icon->SetIcon( 1, c_szDEF_SPR_NAME, item->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( icon, item );
//tooltip 수정
//2009-02-05: hunee
icon->SetLazyTooltip( new rp::KLazyItemTooltip( *m_display, item, true ) );
if( m_pParent->IsAlt() )
{
m_display->SetComparableEquipItemSubTooltip( icon, item );
}
}
else
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
icon->SetTooltip();
}
}
}
kui_window_property& kui_window_itemslot_icon_property::set_value( KUIWnd* value )
{
kui_window_property::set_value( value );
KUIControlMultiIcon* icon = static_cast< KUIControlMultiIcon* >( get_window() );
if( icon )
icon->SetIconLayer( 8 );
return *this;
}
//
// SCaptionUpdator
//
void SCaptionUpdator::Update( KUIWnd& window, property& data )
{
std::string caption;
if( data.is_valid() )
{
GetCaptionString( data, caption );
if( caption.size() > 0 && mDecorator )
XStringUtil::Format( caption, mDecorator, caption.c_str() );
}
window.SetCaption( caption.c_str() );
}
void SEnableColorUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() && data.get_class() == property::CID_STRING )
{
KUIControl* control = dynamicCast< KUIControl* >( &window );
if( control )
control->SetEnableColor( data.get_string_value() );
}
}
void SCaptionUpdator::GetCaptionString( property& data, std::string& caption )
{
switch( data.get_class() )
{
case property::CID_STRING:
caption += data.get_string_value();
break;
case property::CID_INT:
{
std::string buffer;
XStringUtil::Format( buffer, "%d", data.get_int_value() );
caption += buffer;
}
break;
case property::CID_FLOAT:
{
std::string buffer;
XStringUtil::Format( buffer, "%f", data.get_float_value() );
caption += buffer;
}
break;
case property::CID_INT64:
{
std::string buffer;
XStringUtil::Format( buffer, "%I64d", data.get_int64_value() );
caption += buffer;
}
break;
}
}
void SOnOffUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
KUIControl* control = dynamicCast< KUIControl* >( &window );
if( control )
{
if( data.get_boolean_value() )
control->Enable();
else
control->Disable();
}
}
}
//
// SItemSlotIconUpdator
//
void SItemSlotIconUpdator::Update( KUIWnd& window, property& data )
{
KUIControlMultiIcon* icon = dynamicCast< KUIControlMultiIcon* >( &window );
if( icon )
{
ResetMultiIcon( icon, 0, 8 );
if( icon->GetIconLayerCount() < 8 )
icon->SetIconLayer( 8 );
SInventorySlot* item = 0;
if( data.is_valid() )
{
assert( data.get_class() == property::CID_UINT );
AR_HANDLE item_handle = static_cast< AR_HANDLE >( data.get_uint_value() );
item = mDisplayInfo->GetInventoryManager()->GetItemInfo( item_handle );
}
if( data.is_valid() && item )
{
/// 2011.08.03 - prodongi
if (!setSkillCardIcon(icon, item->GetItemCode()) && !setSummonCardIcon( icon, item ) )
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, GetItemDB().GetIconName( item->GetItemCode() ) );
//gmpbigsun( 20130225 ) 빈카드 표시 제거예정
/// 2011.10.21 빈카드 표시 - prodongi
//if (isEmptyCreatureCard(item->GetItemCode(), item->GetXFlag()))
// icon->SetIcon( 2, c_szDEF_SPR_NAME, "common_mark_titanium_empty_card");
}
icon->SetIcon( 1, c_szDEF_SPR_NAME, item->GetXFlag().IsOn( ItemInstance::ITEM_FLAG_CARD ) ? "static_common_useunitcardicon" : NULL );
EquipItemAddtionalIconSetter icon_setter( icon, item );
icon->SetLazyTooltip( new rp::KLazyItemTooltip( *mDisplayInfo, item, true ) );
if( m_pParent->IsAlt() )
{
mDisplayInfo->SetComparableEquipItemSubTooltip( icon, item );
}
}
else
{
icon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
icon->SetTooltip();
}
}
}
//
// SPetGradeIconUpdator
//
void SPetGradeIconUpdator::Update( KUIWnd& window, property& data )
{
if( !data.is_valid() )
return;
char Grade = data.get_char_value();
std::string Rank;
switch( Grade )
{
case PetBase::ATTRIBUTE_BASIC: Rank = "#@C1R@#"; break;
case PetBase::ATTRIBUTE_RARE: Rank = "#@C4R@#"; break;
}
window.SetCaption( Rank.c_str() );
}
//
// SSkillSlotIconUpdator
//
void SSkillSlotIconUpdator::Update( KUIWnd& window, property& data )
{
KUIControlMultiIcon* Icon = static_cast< KUIControlMultiIcon* >( &window );
if( !Icon )
return;
if( Icon->GetIconLayerCount() < 2 )
Icon->SetIconLayer( 2 );
if( !data.is_valid() )
{
Icon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
Icon->SetIcon( 1 );
Icon->SetTooltip();
return;
}
assert( data.get_class() == property::CID_POINTER );
SkillBaseEx* Skill = 0;
SSkillSlot* SkillSlot = 0;
data.get_value( SkillSlot );
Skill = GetSkillDB().GetSkillData( SkillSlot->GetSkillID() );
if( !Skill )
{
Icon->SetIcon( 0, c_szDEF_SPR_NAME, "static_common_itemslot" );
Icon->SetIcon( 1 );
Icon->SetTooltip();
return;
}
Icon->SetIcon( 0, c_szDEF_SPR_NAME, Skill->GetIconName() );
Icon->SetIcon( 1 );
Icon->SetLazyTooltip( new KLazySkillTooltip( *mDisplayInfo, SkillSlot->GetSkillID(), SkillSlot->GetUseLevel(), true ) );
}
void SSkillSlotFxUpdator::Update( KUIWnd& window, property& data )
{
KUIControlQuickEffect* FxWindow = static_cast< KUIControlQuickEffect* >( &window );
if( !FxWindow )
return;
if( !data.is_valid() )
{
FxWindow->Cancel();
return;
}
assert( data.get_class() == property::CID_UINT );
QUICK_SKILL::STATE_QUICK_SLOT QuickSlotState = (QUICK_SKILL::STATE_QUICK_SLOT)data.get_uint_value();
switch( QuickSlotState )
{
case QUICK_SKILL::STATE_NONE:
FxWindow->Cancel();
break;
case QUICK_SKILL::STATE_CASTING:
if( !FxWindow->IsToggleOn() )
FxWindow->Cast( 0 );
break;
case QUICK_SKILL::STATE_FIRE:
if( !FxWindow->IsToggleOn() )
FxWindow->Cancel();
break;
case QUICK_SKILL::STATE_CANCEL:
if( !FxWindow->IsToggleOn() )
FxWindow->Cancel();
break;
case QUICK_SKILL::STATE_TOGGLE_ON:
case QUICK_SKILL::STATE_TOGGLE_ON_BY_USER:
if( !FxWindow->IsToggleOn() )
FxWindow->ToggleOn( true );
break;
case QUICK_SKILL::STATE_TOGGLE_OFF:
case QUICK_SKILL::STATE_TOGGLE_OFF_BY_USER:
if( FxWindow->IsToggleOn() )
FxWindow->ToggleOn( false );
break;
}
}
void SAniUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() && data.get_class() == property::CID_STRING )
{
window.SetBack( window.GetSprName(), data.get_string_value() );
}
}
void SAniFrameIndexUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
window.SetBack( window.GetSprName(), window.GetAniName(), data.get_int_value() );
}
}
void SVisibilityUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
window.ChangeAlpha( data.get_float_value() );
}
else
{
window.ChangeAlpha( 0.f );
}
}
void SPositionXUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
window.MovePos( data.get_int_value(), window.GetRect().top );
}
}
void SPositionYUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
window.MovePos( window.GetRect().left, data.get_int_value() );
}
}
void SWidthUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
KRect newRegion = window.GetRect();
newRegion.right = newRegion.left + data.get_int_value();
window.Resize( newRegion );
}
}
void SHeightUpdator::Update( KUIWnd& window, property& data )
{
if( data.is_valid() )
{
KRect newRegion = window.GetRect();
newRegion.bottom = newRegion.top + data.get_int_value();
window.Resize( newRegion );
}
}