334 lines
11 KiB
C++
334 lines
11 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "KUIWndManager.h"
|
|
#include "KUIControlEdit.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIMsgControl.h"
|
|
|
|
#include "KUIControlButton.h" //servantes 2010.10.25
|
|
|
|
#include "SGameMessage.h"
|
|
#include "SGameManager.h"
|
|
#include "SUIInputNumberWnd.h"
|
|
#include "SStringDB.h"
|
|
#include "SGameInterface.h" //servantes 2010.11.23
|
|
|
|
namespace
|
|
{
|
|
const int c_nButtonClickArea = 10;
|
|
const int c_nInputNumberLimit = 13;
|
|
};
|
|
|
|
|
|
bool SUIInputNumberWnd::InitControls( KPoint kPos )
|
|
{
|
|
m_bIsInputNumber = false;
|
|
|
|
m_nOutput_Mode = NUMBERINPUT_NORMAL; //servantes 2010.10.15
|
|
|
|
// 숫자만 입력
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
{
|
|
pEdit->SetOnlyNumber(true);
|
|
pEdit->SetLimitation( c_nInputNumberLimit );
|
|
pEdit->SetCaptionAlign(KTextRender::KTALIGN_RIGHT | KTextRender::KTALIGN_BOTTOM); // 2010.10.08 servantes
|
|
pEdit->SetFontSize(8); // 2010.10.08 servantes
|
|
}
|
|
SetCustomMovingRect( KRect(0, 0, 224, 20) );
|
|
|
|
KUIControlSimpleButton* pResetButton = dynamicCast<KUIControlSimpleButton*>(GetChild( "button_close_01" )); // 2010.10.08 servantes
|
|
if( NULL != pResetButton )
|
|
{
|
|
pResetButton->Disable();
|
|
}
|
|
|
|
// 버튼 클릭 영역
|
|
//SetValidRect( "input_ok", KRect(0,0,-c_nButtonClickArea,0) );
|
|
//SetValidRect( "input_cancel", KRect(c_nButtonClickArea,0,0,0) );
|
|
|
|
return SUIWnd::InitControls(kPos);
|
|
}
|
|
bool SUIInputNumberWnd::InitData( bool bReload )
|
|
{
|
|
m_nAllValue = count_t( 0 );
|
|
m_RequestWindow = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER;
|
|
|
|
return SUIWnd::InitData(bReload);
|
|
}
|
|
void SUIInputNumberWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch(nMessage)
|
|
{
|
|
case KUI_MESSAGE::KEDIT_CHANGE: //servantes 2010.10.13
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
{
|
|
std::string str = pEdit->GetText();
|
|
if(str.size()) // 입력된 숫자가 있으면 리셋버튼을 활성화시킨다
|
|
{
|
|
// 리셋버튼 활성화
|
|
KUIControlSimpleButton* pResetButton = dynamicCast<KUIControlSimpleButton*>(GetChild( "button_close_01" ));
|
|
if( NULL != pResetButton )
|
|
{
|
|
pResetButton->Enable();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 리셋버튼 활성화
|
|
KUIControlSimpleButton* pResetButton = dynamicCast<KUIControlSimpleButton*>(GetChild( "button_close_01" ));
|
|
if( NULL != pResetButton )
|
|
{
|
|
pResetButton->Disable();
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( ::_stricmp( lpszControlID, "_close" ) == 0 ||
|
|
::_stricmp( lpszControlID, "button_cancel" ) == 0 ||
|
|
::_stricmp( lpszControlID, "idcancel" ) == 0 )
|
|
{
|
|
// 숫자입력창을 닫는다.
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER ) );
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "idok" ) == 0 )
|
|
{ //키보드 엔터 처리
|
|
if( m_nOutput_Mode == NUMBERINPUT_NORMAL )
|
|
{
|
|
// all 값을 세팅한다.
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
count_t nValue = count_t( ::_atoi64( pEdit->GetText() ) );
|
|
if( m_bIsInputNumber || nValue > 0 )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_INPUTNUMBER( m_RequestWindow, nValue ) );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER ) );
|
|
}
|
|
else
|
|
{
|
|
// all 값을 세팅한다.
|
|
pEdit->SetText( CStringUtil::StringFormat( "%I64d", m_nAllValue.getAmount() ).c_str() );
|
|
m_bIsInputNumber = true;
|
|
}
|
|
}
|
|
}
|
|
else if( m_nOutput_Mode == NUMBERINPUT_SCRIPT )
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
count_t nValue = count_t( ::_atoi64( pEdit->GetText() ) );
|
|
if( m_bIsInputNumber || nValue >= 0 )
|
|
{
|
|
std::string strTrigger = CStringUtil::StringFormat( "%s(%s)", m_strTrigger.c_str(), pEdit->GetText() ).c_str();
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG( strTrigger.c_str() ) );
|
|
}
|
|
}
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER ) ); // [sonador][7.0.4] 채널 이동시 숫자 입력기 열려있는 상태 수정
|
|
}
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "input_ok" ) == 0 ||
|
|
::_stricmp( lpszControlID, "button_ok" ) == 0 ||
|
|
::_stricmp( lpszControlID, "button_enter" ) == 0 )
|
|
{
|
|
// 입력된 숫자를 요청한 윈도우로 보내준다.
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
if( m_nOutput_Mode == NUMBERINPUT_NORMAL )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_INPUTNUMBER( m_RequestWindow, count_t( ::_atoi64( pEdit->GetText() ) ) ) );
|
|
}
|
|
else if( m_nOutput_Mode == NUMBERINPUT_SCRIPT )
|
|
{
|
|
std::string strTrigger = CStringUtil::StringFormat( "%s(%s)", m_strTrigger.c_str(), pEdit->GetText() ).c_str();
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG( strTrigger.c_str() ) );
|
|
}
|
|
}
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER ) );
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_number11" ) == 0 )
|
|
{
|
|
// all 값을 세팅한다.
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit ) pEdit->SetText( CStringUtil::StringFormat( "%I64d", m_nAllValue.getAmount() ).c_str() );
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_close_01" ) == 0 ) //servantes 2010.10.13
|
|
{
|
|
// all 값을 세팅한다.
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
// 2011.07.25 - servantes
|
|
if( pEdit ) //2011.07.25 - servantes : redmine( 18783 ) 리셋후 수입력 에디트에 포커스 준다
|
|
{
|
|
pEdit->SetFocus(true);
|
|
pEdit->SetText( "" );
|
|
}
|
|
|
|
// 리셋버튼 비활성화
|
|
KUIControlSimpleButton* pResetButton = dynamicCast<KUIControlSimpleButton*>(GetChild( "button_close_01" ));
|
|
if( NULL != pResetButton )
|
|
{
|
|
pResetButton->Disable();
|
|
}
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_close" ) == 0 ) // close button
|
|
{
|
|
// 숫자입력창을 닫는다.
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER ) );
|
|
}
|
|
else
|
|
{
|
|
// 숫자키를 찾아서 처리
|
|
std::string szID;
|
|
for( int i = 0; i < 10; i++ )
|
|
{
|
|
szID = CStringUtil::StringFormat( "button_number0%d", i );
|
|
if( ::_stricmp( szID.c_str(), lpszControlID ) == 0 )
|
|
{
|
|
int nNum = i;
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
{
|
|
std::string str = pEdit->GetText();
|
|
std::string szNum = CStringUtil::StringFormat( "%d", nNum );
|
|
str += szNum;
|
|
pEdit->SetText( str.c_str() );
|
|
m_bIsInputNumber = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" )); //servantes 2010.10.13
|
|
if( pEdit )
|
|
{
|
|
std::string str = pEdit->GetText();
|
|
if(str.size()) // 입력된 숫자가 있으면 리셋버튼을 활성화시킨다
|
|
{
|
|
// 리셋버튼 활성화
|
|
KUIControlSimpleButton* pResetButton = dynamicCast<KUIControlSimpleButton*>(GetChild( "button_close_01" ));
|
|
if( NULL != pResetButton )
|
|
{
|
|
pResetButton->Enable();
|
|
}
|
|
}
|
|
// 2011.07.25 - servantes
|
|
pEdit->SetFocus(true); //2011.07.25 - servantes : redmine( 18783 ) 리셋후 수입력 에디트에 포커스 준다
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUIInputNumberWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch(pMsg->nType)
|
|
{
|
|
case MSG_SCRIPT_SHOW_WINDOW:
|
|
{
|
|
SMSG_SCRIPT_SHOW_WINDOW* pScriptShowWindow = dynamicCast<SMSG_SCRIPT_SHOW_WINDOW*>(pMsg);
|
|
if( pScriptShowWindow->strWindow == "number_input_window" && pScriptShowWindow->strTrigger == "on_channel_set" )
|
|
{
|
|
m_RequestWindow = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG;
|
|
m_nAllValue = count_t( 0 );// 서버에서 날아와야 함.
|
|
|
|
SetChildCaption( "input_msg", S( 6341 ) );
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit ) pEdit->SetText( "" );
|
|
|
|
m_strWindow = pScriptShowWindow->strWindow;
|
|
m_strTrigger = pScriptShowWindow->strTrigger;
|
|
|
|
m_nOutput_Mode = NUMBERINPUT_SCRIPT;
|
|
|
|
m_bIsInputNumber = false;
|
|
|
|
pMsg->bUse = true;
|
|
}
|
|
}
|
|
break;
|
|
case IMSG_UI_REQ_INPUTNUMBER:
|
|
{
|
|
SIMSG_UI_REQ_INPUTNUMBER* pReqInputNumberMsg = (SIMSG_UI_REQ_INPUTNUMBER*)pMsg;
|
|
|
|
m_RequestWindow = pReqInputNumberMsg->m_Sender;
|
|
m_nAllValue = pReqInputNumberMsg->m_nAllValue;
|
|
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit ) pEdit->SetText( "" );
|
|
|
|
// 텍스트
|
|
if( pReqInputNumberMsg->m_nInputType == SIMSG_UI_REQ_INPUTNUMBER::TYPE_NUMBER )
|
|
SetChildCaption( "input_msg", S( 6342 ) );
|
|
else if( pReqInputNumberMsg->m_nInputType == SIMSG_UI_REQ_INPUTNUMBER::TYPE_GOLD )
|
|
SetChildCaption( "input_msg", S( 6343 ) );
|
|
else if( pReqInputNumberMsg->m_nInputType == SIMSG_UI_REQ_INPUTNUMBER::TYPE_JP )
|
|
SetChildCaption( "input_msg", GetStringDB().GetString( 6758 ) );
|
|
|
|
m_nOutput_Mode = NUMBERINPUT_NORMAL;
|
|
|
|
m_bIsInputNumber = false;
|
|
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SUIInputNumberWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
if( bOpen == false ) //servantes 2010.12.13
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
pEdit->SetFocus(false);
|
|
|
|
m_pManager->SetMouseClickWnd(NULL);
|
|
}
|
|
else
|
|
{
|
|
m_pManager->SetMouseClickWnd(this);
|
|
}
|
|
}
|
|
|
|
void SUIInputNumberWnd::OnFocusNotify()
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( pEdit )
|
|
pEdit->SetFocus(true);
|
|
|
|
m_pManager->SetMouseClickWnd(this); //servantes 2010.12.06
|
|
}
|
|
|
|
// 2011.11.23 - servantes : 추가 (클릭 메세지 체크하기 위해서)
|
|
// 레드마인 : 19770 [클라이언트] 수 입력기 문제
|
|
DWORD SUIInputNumberWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
if( dwMessage == KLBUTTON_UP )
|
|
{
|
|
KUIControlEdit* pEdit = dynamicCast<KUIControlEdit*>(GetChild( "input_edit" ));
|
|
if( NULL != pEdit )
|
|
{
|
|
if(pEdit->GetRect().IsInRect(x, y) == true)
|
|
{
|
|
// pEdit->SetFocus(true);
|
|
KUIWnd* pInputWnd = this->m_pGameManager->GetGameInterface()->GetUIWindow( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_INPUTNUMBER );
|
|
if( pInputWnd )
|
|
m_pGameManager->GetGameInterface()->GetWndManager()->SetFocus(pInputWnd);
|
|
}
|
|
}
|
|
}
|
|
|
|
return SUIWnd::OnMouseMessage( dwMessage, x, y );
|
|
}
|