343 lines
10 KiB
C++
343 lines
10 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "KUIControlEdit.h"
|
|
#include "SUIInputTextWnd.h"
|
|
#include "SGameManager.h"
|
|
#include "KUIControlStatic.h"
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SStringDB.h"
|
|
#include "KUIControlButton.h"
|
|
|
|
const int c_nDefaultWidthSize = 268;
|
|
const int c_nDefaultHeightSize = 135;
|
|
const int c_nAddOneLineSize = 15;
|
|
|
|
|
|
bool SUIInputTextWnd::InitControls( KPoint kPos )
|
|
{
|
|
m_nLimitText = 18;
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
{
|
|
pEdit->SetLimitation( m_nLimitText, true );
|
|
pEdit->SetLineChange( true );
|
|
}
|
|
|
|
SetCustomMovingRect( KRect(0, 0, c_nDefaultWidthSize, 15) );
|
|
|
|
/// 2011.11.21 - prodongi
|
|
KUIControlButton* okButton = dynamicCast<KUIControlButton*>(GetChild("button_ok"));
|
|
if (okButton)
|
|
okButton->SetEnableColor("<#ffffff>");
|
|
|
|
/// cancel, 취소 스트링은 고정이다
|
|
KUIControlButton* cancelButton = dynamicCast<KUIControlButton*>(GetChild("button_cancel"));
|
|
if (cancelButton)
|
|
cancelButton->SetEnableColor("<#ffffff>");
|
|
return SUIWnd::InitControls(kPos);
|
|
}
|
|
bool SUIInputTextWnd::InitData( bool bReload )
|
|
{
|
|
m_SendWindow = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_LAST;
|
|
m_RequestWindow = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTTEXT;
|
|
m_nLimitText = 18;
|
|
|
|
return SUIWnd::InitData(bReload);
|
|
}
|
|
|
|
bool SUIInputTextWnd::IsInputEditFocus()
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
return pEdit->HasFocus();
|
|
|
|
return false;
|
|
}
|
|
|
|
void SUIInputTextWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch(nMessage)
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( ::_stricmp( lpszControlID, "button_cancel" ) == 0 || ::_stricmp( lpszControlID, "button_close_trim_01" ) == 0 )
|
|
{
|
|
SAFE_DELETE( m_pMessageChain );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_INPUTTEXT( m_RequestWindow, "", m_nUsage, m_SendWindow ) );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTTEXT ) );
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_ok" ) == 0 ) //servantes 2010.10.13
|
|
{
|
|
// 요청한 윈도우로 보내준다.
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
{
|
|
if( m_pMessageChain )
|
|
{
|
|
switch( m_pMessageChain->nType )
|
|
{
|
|
case IMSG_UI_ACT_INVENTORY:
|
|
{
|
|
SIMSG_UI_ACT_INVENTORY* msg =
|
|
dynamicCast< SIMSG_UI_ACT_INVENTORY* >( m_pMessageChain );
|
|
msg->m_strParameter = pEdit->GetText();
|
|
}
|
|
break;
|
|
case IMSG_REQ_SET_PET_NAME: // sonador 10.2.1 팻 시스템 구현
|
|
{
|
|
SIMSG_REQ_SET_PET_NAME* msg = dynamicCast< SIMSG_REQ_SET_PET_NAME* >( m_pMessageChain );
|
|
msg->name = pEdit->GetText();
|
|
}
|
|
break;
|
|
};
|
|
m_pGameManager->ProcMsgAtStatic( m_pMessageChain );
|
|
SAFE_DELETE( m_pMessageChain );
|
|
}
|
|
else
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic(
|
|
new SIMSG_UI_INPUTTEXT(
|
|
m_RequestWindow, pEdit->GetText(), m_nUsage, m_SendWindow ) );
|
|
}
|
|
}
|
|
|
|
/// 2012.07.25 usage가 아레나 이름 변경일 경우에는 서버로 부터 응답을 받고 창을 닫아야 된다 - prodongi
|
|
if (SIMSG_UI_REQ_INPUTTEXT::USAGE_ARENA_CHANGE_PLAYER_NAME != m_nUsage)
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTTEXT ) );
|
|
}
|
|
}
|
|
break;
|
|
|
|
case KUI_MESSAGE::KEDIT_LINE_CHANGE: //쳇 출력창의 범위를 초과하여 라인이 늘거나 줄었을때 발생하는 메세지
|
|
{
|
|
KUIControlEdit* pInputEdit = dynamicCast<KUIControlEdit*>(GetChild( lpszControlID )); //에디트창 얻기
|
|
if( NULL == pInputEdit ) return;
|
|
|
|
static int def_height = pInputEdit->GetRect().GetHeight();
|
|
|
|
int nOldLineCnt = static_cast<int>(lparam);
|
|
int nNewLineCnt = static_cast<int>(wparam);
|
|
|
|
nNewLineCnt = std::max(0, nNewLineCnt);
|
|
|
|
KRect editRect = pInputEdit->GetRect();
|
|
editRect.top = editRect.bottom - def_height*nNewLineCnt;
|
|
pInputEdit->SetReSize( editRect );
|
|
}
|
|
break;
|
|
|
|
// case KUI_MESSAGE::KEDIT_CHANGE:
|
|
// break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUIInputTextWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch(pMsg->nType)
|
|
{
|
|
case IMSG_UI_REQ_INPUTTEXT:
|
|
{
|
|
SIMSG_UI_REQ_INPUTTEXT* pReqInputTextMsg = (SIMSG_UI_REQ_INPUTTEXT*)pMsg;
|
|
|
|
m_SendWindow = pReqInputTextMsg->m_Sender;
|
|
m_RequestWindow = pReqInputTextMsg->m_Receiver;
|
|
/// 2011.11.21 - prodongi
|
|
m_subTitle = pReqInputTextMsg->m_subTitle;
|
|
int mainTitleId = pReqInputTextMsg->m_mainTitleId;
|
|
int okCaptionId = pReqInputTextMsg->m_okCaptionId;
|
|
SetStaticControlCaption(m_subTitle.c_str(), mainTitleId, okCaptionId);
|
|
m_nLimitText = pReqInputTextMsg->m_nLimitText;
|
|
ChangeUsage( pReqInputTextMsg->m_nUsage );
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
pEdit->SetText( "" );
|
|
pEdit->SetLineChange( true );
|
|
pEdit->SetLimitation( m_nLimitText, true );
|
|
}
|
|
|
|
// { [sonador]
|
|
if( pReqInputTextMsg->m_pMessageChain )
|
|
m_pMessageChain = pReqInputTextMsg->m_pMessageChain;
|
|
// }
|
|
|
|
/// 2012.07.27 - prodongi
|
|
if (SIMSG_UI_REQ_INPUTTEXT::USAGE_ARENA_CHANGE_PLAYER_NAME == pReqInputTextMsg->m_nUsage)
|
|
{
|
|
/// 아스테리크 + 중복 구분 숫자 제외
|
|
pEdit->SetLimitation( 15, true );
|
|
}
|
|
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
|
|
case IMSG_UI_INPUTTEXT_UPDATE:
|
|
{
|
|
//지금은 IMSG_UI_INPUTTEXT_UPDATE를 호출하는 경우가 인벤토리에서 크리처 이름 변경에서 뿐이 없다
|
|
//따라서 이렇게 처리하지만 추후에 더 많은 윈도우에서 이 메세지를 호출하게 된다면 멤버로 현재변경중인 상태값을 저장하는 것이 좋을 듯
|
|
SIMSG_UI_INPUTTEXT_UPDATE* pInputTextMsg = (SIMSG_UI_INPUTTEXT_UPDATE*)pMsg;
|
|
|
|
if( IsUsedFor( pInputTextMsg->m_nUsage ) )
|
|
{
|
|
if( m_RequestWindow == SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INVENTORY )
|
|
{
|
|
m_subTitle = pInputTextMsg->m_subTitle;
|
|
int mainTitleId = pInputTextMsg->m_mainTitleId;
|
|
int okCaptionId = pInputTextMsg->m_okCaptionId;
|
|
SetStaticControlCaption(m_subTitle.c_str(), mainTitleId, okCaptionId);
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
pEdit->SetText( "" );
|
|
pEdit->SetLineChange( true );
|
|
pEdit->SetLimitation( m_nLimitText, true );
|
|
}
|
|
}
|
|
}
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
//StaticControl 에 입력해줘야할 Caption을 택스트 길이를 고려하여 윈도우 크기도 조정하고 Caption 쎄팅
|
|
void SUIInputTextWnd::SetStaticControlCaption( const char* lpText, int mainTitleId, int okCaptionId )
|
|
{
|
|
if( lpText == NULL ) return;
|
|
|
|
KUIControlStatic* pStaticCtr = dynamicCast<KUIControlStatic*>(GetChild("static_msg"));
|
|
if( !pStaticCtr ) return;
|
|
|
|
std::string strResultText;
|
|
std::vector<std::string> lineList;
|
|
pStaticCtr->SplitLine(lineList, lpText, "Default", 10, true);
|
|
|
|
for( int i(0); i<lineList.size(); ++i )
|
|
{
|
|
if( i!=0 ) strResultText += "<BR>";
|
|
strResultText += lineList[i];
|
|
}
|
|
|
|
m_nTextLineSize = lineList.size();
|
|
|
|
lineList.clear();
|
|
|
|
strResultText = CStringUtil::StringFormat( "<font:font_01><size:9><#ffffff><hcenter><vcenter>%s", strResultText.c_str() );
|
|
|
|
//윈도우의 크기가 Height만 변경되기 때문에 Width는 신경 쓸 필요 없다.
|
|
//위에서 구한 라인수에 맞게 윈도우의 크기를 조정
|
|
KRect WndRc = GetRect();
|
|
if( m_nTextLineSize>1 )
|
|
{
|
|
int offset = c_nAddOneLineSize*(m_nTextLineSize-1);
|
|
WndRc.bottom = WndRc.top + c_nDefaultHeightSize + offset;
|
|
}
|
|
else
|
|
{
|
|
WndRc.bottom = WndRc.top + c_nDefaultHeightSize;
|
|
}
|
|
|
|
Resize(WndRc);
|
|
|
|
KUIControlStatic* outframe = dynamicCast<KUIControlStatic*>(GetChild("outframe"));
|
|
if (outframe)
|
|
outframe->Resize(WndRc);
|
|
|
|
/// 2010.10.29 확인/취소/에디트 버튼도 위치를 조정해 줘야 된다, offset값은 uitool보고 맞춘것임 - prodongi
|
|
// ok
|
|
setControlPosBasisParentBottom("button_ok", 36);
|
|
// cancel
|
|
setControlPosBasisParentBottom("button_cancel", 36);
|
|
// edit
|
|
setControlPosBasisParentBottom("input_edit", 70);
|
|
|
|
//Caption쎄팅
|
|
pStaticCtr->SetCaption( strResultText.c_str() );
|
|
|
|
std::string str;
|
|
/// main title
|
|
KUIControlStatic* ctrlMainTitle = dynamicCast<KUIControlStatic*>(GetChild("text_title_01"));
|
|
if (ctrlMainTitle)
|
|
{
|
|
if (0 <= mainTitleId)
|
|
{
|
|
XStringUtil::Format(str, "<font:font_01><size:9><#246771><hcenter><vcenter><left>%s", S(mainTitleId));
|
|
ctrlMainTitle->SetCaption(str.c_str());
|
|
}
|
|
else
|
|
{
|
|
ctrlMainTitle->SetCaption("");
|
|
}
|
|
}
|
|
/// ok caption
|
|
KUIControlButton* okButton = dynamicCast<KUIControlButton*>(GetChild("button_ok"));
|
|
if (okButton)
|
|
{
|
|
int strId = 3025; /// 확인
|
|
if (0 <= okCaptionId)
|
|
{
|
|
strId = okCaptionId;
|
|
}
|
|
XStringUtil::Format(str, "<font:font_02><size:9><hcenter><vcenter>%s", S(strId));
|
|
okButton->SetCaption(str.c_str());
|
|
}
|
|
/// cancel, 우선 취소 스트링은 고정으로 해놓는다
|
|
KUIControlButton* cancelButton = dynamicCast<KUIControlButton*>(GetChild("button_cancel"));
|
|
if (cancelButton)
|
|
{
|
|
XStringUtil::Format(str, "<font:font_02><size:9><hcenter><vcenter>%s", S(6163));
|
|
cancelButton->SetCaption(str.c_str());
|
|
}
|
|
}
|
|
|
|
void SUIInputTextWnd::OnSizeChangeNofity(const KRect& rcNewRect)
|
|
{
|
|
SUIWnd::OnSizeChangeNofity(rcNewRect);
|
|
}
|
|
|
|
void SUIInputTextWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
if( !bOpen )
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit ) pEdit->SetFocus(false);
|
|
|
|
ChangeUsage( SIMSG_UI_REQ_INPUTTEXT::USAGE_NONE ); // { [sonador][7.0.6] Mantis 0002624 염원의 깃털 사용중 소환수 소환할 때 입력창 오류 수정
|
|
}
|
|
}
|
|
|
|
void SUIInputTextWnd::OnFocusNotify()
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit ) pEdit->SetFocus(true);
|
|
}
|
|
|
|
// { [sonador][7.0.6] Mantis 0002624 염원의 깃털 사용중 소환수 소환할 때 입력창 오류 수정
|
|
void SUIInputTextWnd::ChangeUsage( SIMSG_UI_REQ_INPUTTEXT::USAGE nUsage )
|
|
{
|
|
m_nUsage = nUsage;
|
|
}
|
|
|
|
bool SUIInputTextWnd::IsUsedFor( SIMSG_UI_REQ_INPUTTEXT::USAGE nUsage ) const
|
|
{
|
|
return ( m_nUsage == nUsage ) ? true : false;
|
|
}
|
|
// }
|
|
|
|
|
|
/// 2010.10.29 - prodongi
|
|
void SUIInputTextWnd::setControlPosBasisParentBottom(const char *controlName, int offset)
|
|
{
|
|
KUIControl* ctrl = dynamicCast<KUIControl*>(GetChild(controlName));
|
|
if (ctrl)
|
|
{
|
|
KRect WndRc = ctrl->GetRect();
|
|
ctrl->MovePos(WndRc.left, GetRect().bottom - offset);
|
|
}
|
|
} |