Files
Leviathan/Client/Game/engine/Ui/Controls/KUIControl.h
T
2026-06-01 12:46:52 +02:00

323 lines
9.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef _COUNTRY_ME_
#pragma once
#include "../KUIDefine.h"
#include "KTypes.h"
#include <map>
#include "KUIFactory.h"
#include "KTextRender.h"
#include "RefCounted.h"
#include "IntrusivePtr.h"
class KSpritePrimitive;
struct KUICTRLITEM
{
char* strSprAniName;
int nFrame;
bool bScalable;
KSize sizeTarget;
bool bTiling;
float fVisibility;
};
enum KAPPLICATION_MESSAGE
{
KMOUSE_MOVE = WM_MOUSEMOVE,
KLBUTTON_UP = WM_LBUTTONUP,
KLBUTTON_DOWN = WM_LBUTTONDOWN,
KRBUTTON_UP = WM_RBUTTONUP,
KRBUTTON_DOWN = WM_RBUTTONDOWN,
KKEY_DOWN = WM_KEYDOWN,
KKEY_UP = WM_KEYUP,
KWHEEL_UP,
KWHEEL_DOWN,
KPANEL_BEGIN,
KPANEL_END,
KLBUTTON_DBLCLK = WM_LBUTTONDBLCLK,
KRBUTTON_DBLCLK = WM_RBUTTONDBLCLK,
};
class KViewportObject;
class KUITipControl;
class KUIDragAndDropObject;
/// sonador 1.2.5 Lazy Tooltip 구현
class KLazyTip : public rp::mixin::ref_counted
{
public:
KLazyTip() {}
KLazyTip( const char* tip ) : m_Tip( tip ) {}
virtual ~KLazyTip() {}
virtual const char* getTip()
{
if( m_Tip.empty() )
createTip( m_Tip );
return m_Tip.c_str();
}
virtual void createTip( std::string& tip ) {}
private:
std::string m_Tip;
};
class KUIControl : public KUIWnd
{
public:
KUIControl(void);
virtual ~KUIControl(void);
virtual void Create(KUIWND_CREATE_ARG& CREATE_ARG);
virtual void Render(KViewportObject * pViewport, bool isFront = false );
virtual void Process(DWORD dwTime);
/// 설정하지 않으면 기본값을 사용한다.
void SetTooltipSprite( const char* szSprName, const char* szAniName = NULL )
{
m_strTooltipSprName = szSprName;
if( NULL != szAniName ) m_strTooltipAniName = szAniName;
}
void SetTooltip( LPCSTR lpszText = NULL );
/// sonador 1.2.5 Lazy Tooltip 구현
void SetLazyTooltip( KLazyTip* pLazyTip = NULL ); // sonador #2.1.2.4.3 팻 조작 UI 연동
void AddSubTooltip( LPCSTR lpszText = NULL );
void AddLazySubTooltip( KLazyTip* pLazyTip = NULL );
void ClearSubTooptip();
void SetCaptionRandomColor( bool bFlag )
{
m_bCaptionRandomColor = bFlag;
}
/// Input arguments are all global screen coordinates
virtual DWORD OnMouseMessage(DWORD dwMessage, int x, int y);
virtual void *Perform( KID id, KArg& msg );
virtual void PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam );
virtual void OnChangeCaptionNotify();
virtual void OnChangeAniNameNotify();
virtual void OnChagneBackNotify();
virtual void OnSizeChangeNofity(const KRect& rcNewRect);
virtual void OnParentSizeChangeNotify(const KRect& rcNewRect, int nXMove, int nYMove, int nResizeStyle);
virtual void OnParentPosChangeNotify(int XOffset, int YOffset);
virtual void OnPosChangeNofity(int XOffset, int YOffset);
virtual void OnClipChangeNotify(const KRect& rcClipRect);
virtual void OnParentClipChangeNotify(const KRect& rcClipRect);
virtual void OnAlphaChangeNotify(float fAlpha);
virtual void OnParentAlphaChangeNotify(float fAlphaDiff);
virtual KUIDragAndDropObject* GetDragObject();
/// 2012.07.02 SUIControlStatic와의 호환성을 위해서 추가 함 - prodongi
virtual void SetEnableOption(bool /*enable*/) {}
virtual void UpdateBack();
virtual void UpdateCaption(DWORD maxWidth = 0); // 2010.09.03 - prodongi
void UpdateAniName();
void UpdateTip();
void SetRotate(float fRadian);
static int GetOneLineStringByte(LPCSTR lpszText,DWORD dwWidth);
static void SetNULLToolTipOnControl();
// MJ 2004/12/01
int IsUsePos() const { return m_bUsePos; };
void SetUsePos( bool use ) { m_bUsePos = use; } // #2.1.2.11.1
void SetUseCustomSize( bool use ) { m_bUseCustomSize = use; }
//void UpdateUV( KRect rt, int nTextureCount = 0, int nMapPosX = -1, int nMapPosY = -1 );
void UseEmoticonFilter( bool use ) { m_bUseEmoticonFilter = use; }
int GetTextureSizeX();
int GetTextureSizeY();
void UpdateUV( KRect rt );
virtual void SetTooltipOff();
void Disable() { m_bIsDisable = true; OnChangeCaptionNotify(); }
void Enable() { m_bIsDisable = false; OnChangeCaptionNotify(); }
bool IsDisable() const { return m_bIsDisable; }
/// 캡션관련
void SplitLine( std::vector< std::string > & vecLineList, const std::string& str, const char* szFontName = KTextRender::KDEFAULT_FONT_NAME, int nFontSize = KTextRender::KDEFAULT_FONT_SIZE, bool bBold = false, bool bUseFontSize = false );
void SetEnableColor( const char * pColor ) { m_strEnableColor = pColor; }
void SetDisableColor( const char * pColor ){ m_strDisableColor = pColor; }
static void ToggleDrawRectGrid()
{
s_bIsDrawRectGrid = !s_bIsDrawRectGrid;
}
static void SetBlankWidth( short nWidth ) { s_nBlankWidth = nWidth; }
void SetUsePosEnable( bool bFlag ) { m_bUsePosEnable = bFlag; }
void SetToolTipLeftRender( bool bLeft ) { m_bToolTipLeftRender = bLeft; }
KUITipControl* GetToolTipControl() { return m_pTipControl; }
void RenderToolTip(KViewportObject * pViewport, bool isFront = false);
// 2010.03.15 - bintitle
// 자신과 동일한 control을 생성하여 반환.
KUIControl * Clone();
KUIControl * Clone( const char * newName );
// 2010.04.23 bintitle.
void SetColor( KColor & color );
// 2010.04.30 bintitle.
// Shorten the caption to fit the window, appending .. if needed, and display the full caption as a tooltip
void CutCaptionNTooltip();
int GetFontSize(){
return m_FontSize; // nui의 caption에 설정한 <size:9> 의 9.
}
/// 2010.05.06 - prodongi
void clearEmoticonSizeList() { m_emoticonSizeList.clear(); }
void addEmoticonSize(std::string const& aniName, int width, int height);
bool GetUVScrollEndFlag(); // 2011.03.23 - servantes
void ResetUVScrollEndFlag(); // 2011.03.23 - servantes
void OnAlphaChangeNotNotify(float alpha); /// 2011.09.23 자신만 알파값 변화를 시킨다 - prodongi
protected:
virtual void _destroyControl();
virtual void _initControl();
/// Rendering Relative function
void _renderChild(KViewportObject* pViewport, bool isFront = false);
void _renderBack(KViewportObject *pViewport, bool isFront = false);
void _renderCaption(KViewportObject * pViewport, bool isFront = false);
void _renderToolTip(KViewportObject * pViewport, bool isFront = false);
/// Process Relative function
void _processToolTip();
/// process alpha show
void _processAlphaShow( DWORD dwTime );
/** Argument is flag for vertical,horizontal split when piece count is three(3)
사각 재 정리 */
void _reArrangeRect(bool bHorizonPiece = true);
void _makeSpriteForArrangedRect();
void _clearRegisteredSprite()
{
m_vtSprite.clear();
}
void _registerSprite(KSpritePrimitive* pPrSprite)
{
m_vtSprite.push_back( pPrSprite);
}
void _registerPhrase(KTextPhrase* pPhrase)
{
m_vtTextPhrase.push_back( pPhrase);
}
void _setToolTipOff();
static void OnToolTipOnControl( KUIControl* pControl );
static void OffToolTipOnControl( KUIControl* pNewControl );
private:
/// 2010.05.06 이모티콘의 사이즈를 m_pTipControl에 변경되도록 설정- prodongi
void updateToolTipEmoticonSize();
// 2010.10.01 str의 뒷에 붙는 태그를 고려해서 ..을 붙힌다- prodongi
void cutCaptionNToolTipWithTag(std::wstring& wstr, size_t strEraseCount);
/// 2010.11.01 툴팁의 화면 경계 체크 - prodongi
void checkToolTipScreenBound();
protected:
bool m_bUsePosEnable;
bool m_bUsePos;
bool m_bUseHorizonPiece;
bool m_bUseCustomSize; // #2.1.2.11.1
bool m_bCaptionRandomColor;
bool m_bUseEmoticonFilter;
KRect m_rcPieceArea[9]; ///< 최대 9조각
int m_nPieceCount; ///< 사용 조각 수
KSpritePrimitive* m_pSpriteList;
/// The derivative class has their unique rendering items in these vectors.
std::vector<KSpritePrimitive *> m_vtSprite;
std::vector<KTextPhrase *> m_vtTextPhrase;
DWORD m_dwToolTipPreStartTime;
DWORD m_dwToolTipStartTime;
int m_nToolTipPosX, m_nToolTipPosY;
int m_nOldPosX, m_nOldPosY;
std::string m_strTooltipSprName;
std::string m_strTooltipAniName;
rp::intrusive_ptr< KLazyTip > m_LazyTip; ///< sonador 1.2.5 Lazy Tooltip 구현
KUITipControl* m_pTipControl;
std::vector< rp::intrusive_ptr< KLazyTip > > m_SubLazyTip;
std::vector< std::string > m_SubTip;
std::vector< KUITipControl* > m_SubTipContorl;
KUIDragAndDropObject* m_pDragObject;
int m_nToolTipTextWidth;
int m_nToolTipTextHeight;
bool m_bIsDisable;
std::string m_strEnableColor;
std::string m_strDisableColor;
static bool s_bIsDrawRectGrid;
static short s_nBlankWidth;
KWireUtilPrimitive * m_pRectGrid;
bool m_bToolTipLeftRender;
static KUIControl* s_pToolTipOnControl;
//--------------------------------------
// 추가. bintitle. 2010.04.30
bool m_bCutCaption; // 제목의 잘림처리 여부.
int m_FontSize; // nui의 caption에 설정한 <size:9> 의 9.
// std::string m_sOrgCaption; // 원본제목. m_bCutCaption가 활성화된경우에는 m_sCaption 에 잘려진 제목이 들어간다. ( .. ). KUIWnd 로 옮김.
//--------------------------------------
// 2010.05.06 이모티콘의 사이즈를 변경시키기 위해서 - prodongi
struct sEmoticonSize
{
sEmoticonSize(std::string const& aniName, int width, int height) : m_aniName(aniName), m_width(width), m_height(height) {}
std::string m_aniName;
int m_width;
int m_height;
};
std::vector<sEmoticonSize> m_emoticonSizeList;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <algorithm>
inline float getClampRatio(DWORD curTime, DWORD totalTime)
{
return std::min(static_cast<float>(curTime)/ totalTime, 1.f);
}
inline float getClampRatioPow(DWORD curTime, DWORD totalTime)
{
return std::min(static_cast<float>(curTime * curTime) / (totalTime * totalTime),1.f);
}
inline float getClampRatioSqrt(DWORD curTime, DWORD totalTime)
{
return std::min( ::sqrtf(getClampRatio(curTime,totalTime)) , 1.f);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#else
#include "../Localization/MiddleEast/KUIControl_ME.h"
#endif