#include "stdafx.h" #include "KUIControl3DStatic.h" #include "SUINPCDialogWnd.h" #include "SUIDisplayInfo.h" #include "SGameManager.h" #include "SGameMessage.h" //#include "SGameMessageUI.h" #include "SUISysMsgDefine.h" #include #include "SNpcResourceDB.h" #include "SUIDefine.h" namespace { const char* c_szNoClose = "no_close"; #ifdef _COUNTRY_ME_ const char* c_szFont = "Tahoma"; #else const char* c_szFont = "Default"; #endif const char* c_szButtonHide = "button_hide"; const char* c_szNpcSelect = "npc_select"; const char* c_szNpcButtonNext = "npc_button_next"; const char* c_szButtonPrev = "button_prev"; const int c_nMiddleEastNPCDialogFontSize = 15; }; extern void MsgSplit( const char* szMsg, std::vector& vecText, const wchar_t* lpDelimiter, bool bProcSpecialCharacter=false ); bool SUINPCDialogWnd::InitData( bool bReload ) { m_nMaxPageCount = 0; m_nCurPageCount = 0; m_bNoClose = false; m_hNPC = NULL; m_hTarget = 0; m_hFaceNPC = 0; m_bToggleHide = false; // SetChildShow( "quest_button" ); // SetChildShow( "_Resize" ); SetChildShow( "outframe_choice", false ); SetChildShow( "button_prev" , false ); if( bReload ) { m_vecTextList.clear(); m_vecMenuList.clear(); DestroyDlgButton(); } //#define _TEST_ #ifdef _TEST_ STRING_VECTOR vtTexts; //영어 문제 있는 것 // vtTexts.push_back( "Armor Trader Justice and Blacksmith Tiriel are in the southern portion of Santuary's square. Weapon Trader Lippen and Merchant Christe are in the eastern portion of the square. Christe is selling potions and spellbooks." ); //한글 문제 있는 것 텍스트에
이 들어 있었음. vtTexts.push_back( "라크 교환 및 구입은 북서쪽 용자의 계단 앞에 있는 라크 트레이더 마린느를 찾아가십시오." ); CheckPage( vtTexts ); m_nMaxPageCount = static_cast( m_vecTextList.size() ); RefreshPage(); SetChildShow( "npc_story", true ); #endif #ifdef _KUI_INVALIDATION // { [sonador] KUIControl3DStatic* pFacecutStaticTarget = dynamicCast(GetChild( "facecut" )); KUIControl3DStatic* pFaceStaticTarget = dynamicCast(GetChild( "npc_face" )); if( pFacecutStaticTarget ) this->AddPopupControl( pFacecutStaticTarget ); if( pFaceStaticTarget ) this->AddPopupControl( pFaceStaticTarget ); // } #endif SetChildCaption( c_szButtonHide, GetStringDB().GetString( STRING_HIDE ) ); SetChildCaption( c_szNpcSelect, GetStringDB().GetString( STRING_SELECT ) ); SetChildCaption( c_szNpcButtonNext, GetStringDB().GetString( STRING_NEXT ) ); SetChildCaption( c_szButtonPrev, GetStringDB().GetString( STRING_PREV ) ); return SUIWnd::InitData(bReload); } void SUINPCDialogWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd ) { if( !bOpen ) { DestroyDlgButton(); if( m_hTarget ) { //타겟 설정 해 놓은 것이 있으므로, 타겟을 요청 한다. SIMSG_UI_ACT_TARGET* pMsg = new SIMSG_UI_ACT_TARGET; pMsg->m_nTargetHandle = m_hTarget; m_pGameManager->PostMsgAtDynamic( pMsg ); } } else { //열릴때, 소리 재생 m_pGameManager->StartSound( "ui_popup_window01.wav" ); } SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd ); } void SUINPCDialogWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam ) { switch( nMessage ) { case KUI_MESSAGE::KBUTTON_CLICK: { if( ::_stricmp( "button_hide", lpszControlID ) == 0 ) { // 제대로 동작하지 않아서 일단 막음. by Testors m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG, false) ); m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_REWARD, false) ); break; m_bToggleHide = !m_bToggleHide; SetChildShow( "button_prev", false ); //강제로 숨긴다. for( int i = 0; i < static_cast(m_vecButtonList.size()); i++ ) SetChildToggleShow( m_vecButtonList[i]->GetID() ); SetChildToggleShow( "ourframe00" ); SetChildToggleShow( "ourframe01" ); SetChildToggleShow( "ourframe02" ); SetChildToggleShow( "ourframe03" ); SetChildToggleShow( "outframe_choice" ); SetChildToggleShow( c_szNpcButtonNext ); SetChildToggleShow( "npc_job_name" ); SetChildToggleShow( "npc_name" ); SetChildToggleShow( "npc_story" ); SetChildToggleShow( "facecut_background" ); SetChildToggleShow( "npc_face" ); SetChildToggleShow( "facecut" ); // m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG ) ); // m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_REWARD, false) ); } else if( ::_stricmp( c_szNpcButtonNext, lpszControlID ) == 0 ) { m_nCurPageCount++; RefreshPage(); } else if( ::_stricmp( "button_prev", lpszControlID ) == 0 ) { m_nCurPageCount--; if( m_nCurPageCount < 0 ) m_nCurPageCount = 0; RefreshPage(); } else { if( m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_REWARD ) ) { m_pDisplayInfo->AddSystemMessage( S( SYS_MSG_QUEST_UNSELECT ), 99 ); // Please select the reward first. break; } m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_REWARD, false) ); if( !m_vecMenuList.empty() ) { std::vector::iterator it = m_vecMenuList.begin(); while( it != m_vecMenuList.end() ) { DLGMENU menu = (*it); // 2010.08.26 - prodongi //if( ::_stricmp( menu.m_strMenuName.c_str(), lpszControlID ) == 0 ) if( ::_stricmp( menu.m_controlName.c_str(), lpszControlID ) == 0 ) { if( menu.m_strTrigger == "open_storage()" ) { if( m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_SHOP) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TRADE) ) { m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG ) ); break; } } if( menu.m_strTrigger.find("open_market(") != -1 ) { if( m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_HOST) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORE_CLIENT) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_STORAGE) || m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TRADE) ) { m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG ) ); break; } } m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG(menu.m_strTrigger.c_str()) ); _performance_print( "NPC Trigger : %s %d\n", menu.m_strTrigger.c_str(), menu.m_strTrigger.length() ); //트리거에 따라 사운드 다르게 출력 while( true ) { if( strstr( menu.m_strTrigger.c_str(), "start_quest" ) ) { m_pGameManager->StartSound( "ui_click_accept01.wav" ); //퀘스트 수락 break; } if( strstr( menu.m_strTrigger.c_str(), "end_quest" ) ) { m_pGameManager->StartSound( "ui_click_complete01.wav" ); //퀘스트 완료 break; } //if( strstr( menu.m_strTrigger.c_str(), "ChipExchange_Do_Exchange" ) || // strstr( menu.m_strTrigger.c_str(), "ChipExchange_RP_num" ) ) //{ // m_pGameManager->StartSound( "ui_click_exchange01.wav" ); //라크 교환 // break; //} //if( strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Beginner" ) || // strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Deva" ) || // strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Asura" ) || // strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Gaia" ) || // strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Rondoh" ) || // strstr( menu.m_strTrigger.c_str(), "ItemLevelUp_Secroute" ) ) //{ // m_pGameManager->StartSound( "ui_click_upgrade01.wav" ); //장비 업그레이드 // break; //} //if( strstr( menu.m_strTrigger.c_str(), "AdventureGuide_rent_card" ) ) //{ // m_pGameManager->StartSound( "ui_click_lend01.wav" ); //크리쳐 대여 // break; //} m_pGameManager->StartSound( "ui_button_click.wav" ); //그외 break; } //중간에 대화상자를 닫아 버리면, 이동 되는 문제가 있다. m_pGameManager->PostMsgAtDynamic( new SIMSG_TOGGLE_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NPCDIALOG ) ); break; } it++; } } } } break; case KUI_MESSAGE::KGENWND_MOVE: LimitMoveWnd(); break; } SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam ); } void SUINPCDialogWnd::ProcMsgAtStatic( SGameMessage* pMsg ) { switch( pMsg->nType ) { case MSG_NPC_DIALOG: { m_nDialogMode = MODE_NPC; const SMSG_NPC_DIALOG* pNPCDialogMsg = (const SMSG_NPC_DIALOG*)pMsg; InitData(true); //직업 이름 분리 { std::string strJob = "<#bea788>"; std::string strName = "<#ff8200>"; #ifdef _COUNTRY_ME_ strJob = "<#ff8200>"; strName = "<#bea788>"; #endif //strJob += "[Job]"; //strName += "[Name]"; std::vector< std::string > vToken; MsgSplit( pNPCDialogMsg->strTitle.c_str(), vToken, L" " ); if( vToken.size() > 1 ) { for( unsigned int i(0); vToken.size()>i; i++ ) { if( i == (vToken.size()-1) ) { strName += ""; strName += vToken[i]; } else { strJob += vToken[i]; if (i > 0) strJob += ""; else strJob += " "; } } SetChildCaption( "npc_job_name", strJob.c_str() ); SetChildCaption( "npc_name" , strName.c_str() ); SetChildShow( "npc_job_name", true ); SetChildShow( "npc_name" , true ); } else { SetChildShow( "npc_job_name", false ); SetChildShow( "npc_name" , false ); } vToken.clear(); } { std::string strJob = "<#bea788>"; std::string strName = "<#ff8200>"; #ifdef _COUNTRY_ME_ strJob = "<#ff8200>"; strName = "<#bea788>"; #endif std::vector< std::string > vToken; MsgSplit( pNPCDialogMsg->strTitle.c_str(), vToken, L"|" ); if( vToken.size() > 1 ) { for( unsigned int i(0); vToken.size()>i; i++ ) { if( i == (vToken.size()-1) ) { strName += ""; strName += vToken[i]; } else { strJob += vToken[i]; if (i > 0) strJob += ""; else strJob += " "; } } SetChildCaption( "npc_job_name", strJob.c_str() ); SetChildCaption( "npc_name" , strName.c_str() ); SetChildShow( "npc_job_name", true ); SetChildShow( "npc_name" , true ); } vToken.clear(); } // 페이지 나눠서 저장 CheckPage( pNPCDialogMsg->vtTexts ); // 2010.08.26 - prodongi char controlName[MAX_PATH]; int count = 0; const std::vector& vecMenuList = pNPCDialogMsg->vtMenus; std::vector::const_iterator it = vecMenuList.begin(); while( it != vecMenuList.end() ) { SMSG_NPC_DIALOG::DLGMENU menu = (*it); if( ::_stricmp(menu.strMenuName.c_str(), c_szNoClose) == 0 && ::_stricmp(menu.strTrigger.c_str(), c_szNoClose) == 0 ) m_bNoClose = true; else { XStringUtil::Replace( menu.strMenuName, "|", "" ); // 2010.08.26 - prodongi //m_vecMenuList.push_back( DLGMENU(menu.strMenuName, menu.strTrigger, menu.nButtonType) ); sprintf(controlName, "%s_%d", menu.strMenuName.c_str(), count); m_vecMenuList.push_back( DLGMENU(menu.strMenuName, menu.strTrigger, controlName, menu.nButtonType) ); } it++; // 2010.08.26 - prodongi ++count; } m_nMaxPageCount = static_cast( m_vecTextList.size() ); m_hNPC = pNPCDialogMsg->npc_handle; CreateDlgButton(); RefreshPage(); } break; } } void SUINPCDialogWnd::CheckPage( const STRING_VECTOR& vecTextList ) { STRING_VECTOR::const_iterator it_str = vecTextList.begin(); while( it_str != vecTextList.end() ) { std::string str = (*it_str); STRING_VECTOR vecLineList; KUIControl* pNPCStory = dynamicCast< KUIControl* >( GetChild( "npc_story" ) ); if( !pNPCStory ) return; #ifdef _COUNTRY_ME_ pNPCStory->SplitLine( vecLineList, str, ENV().GetString( "default_font", "Tahoma" ).c_str(), c_nMiddleEastNPCDialogFontSize, false, true ); #else pNPCStory->SplitLine( vecLineList, str, c_szFont, 18, true ); #endif // vecLineList 를 m_vecTextList 에 4줄씩 한페이지로 저장한다 std::string strLine; int nIndex = 0; STRING_VECTOR::iterator it = vecLineList.begin(); while( it != vecLineList.end() ) { XStringUtil::Replace( (*it), "|", "" ); strLine += (*it); strLine += "
"; if( nIndex == 3 ) { m_vecTextList.push_back( strLine ); nIndex = -1; strLine = ""; } nIndex++; it++; } if( !strLine.empty() ) m_vecTextList.push_back( strLine ); it_str++; } } void SUINPCDialogWnd::RefreshPage() { std::string str; if( m_nCurPageCount < m_nMaxPageCount ) { #ifdef _COUNTRY_ME_ XStringUtil::Format( str, "<#38261a>", c_nMiddleEastNPCDialogFontSize ); #else str = "<#38261a>"; #endif str += m_vecTextList[m_nCurPageCount]; SetChildCaption( "npc_story", str.c_str() ); } // next 버튼 SetChildShow( c_szNpcButtonNext, (m_nMaxPageCount>1 && m_nCurPageCount(m_vecButtonList.size()); i++ ) SetChildShow( m_vecButtonList[i]->GetID(), bShowButton ); KUIWnd * pOutWnd = GetChild( "outframe_choice" ); if( pOutWnd ) { pOutWnd->SetShow( bShowButton ); if( bShowButton ) { SetChildShow( "npc_select", true ); } else SetChildCaption( c_szNpcButtonNext, GetStringDB().GetString( STRING_NEXT ) ); } ShowFacecut( m_hNPC ); } void SUINPCDialogWnd::DestroyDlgButton() { if( m_vecButtonList.empty() ) return; /// 2010.12.22 - prodongi OffToolTipWnd(); std::vector::iterator it = m_vecButtonList.begin(); while( it != m_vecButtonList.end() ) { KUIWnd* pButton = (*it); RemoveChild((*it)); it = m_vecButtonList.erase(it); } m_vecButtonList.end(); } void SUINPCDialogWnd::Create(KUIWND_CREATE_ARG& CREATE_ARG) { CREATE_ARG.dwFlag |= KFLAG_GET_PASS_MESSAGE; CREATE_ARG.dwFlag |= KFLAG_NO_GET_FOCUS; KUIWnd::Create( CREATE_ARG) ; } void SUINPCDialogWnd::CreateDlgButton() { // 버튼의 갯수 만큼 버튼 생성 if( m_vecMenuList.empty() ) return; KUIWnd* pBackWnd = GetChild( "outframe_choice" ); if( pBackWnd == NULL ) return; KUIWnd* pOutWnd = GetChild( "ourframe03" ); if( pOutWnd == NULL ) return; int nOffset = static_cast(m_vecMenuList.size())*34; // Resize( KRect(GetRect().left, GetRect().top, GetRect().right, pBackWnd->GetRect().bottom+nOffset) ); KRect rt, rt_out; rt_out = pBackWnd->GetRect(); rt.left = pBackWnd->GetRect().left + 7;// - (GetRect().GetWidth()/2); rt.top = pBackWnd->GetRect().top + 20; rt.right = pBackWnd->GetRect().right - 7; rt.bottom = rt.top + 30; rt_out.bottom = rt.bottom; // rt_out.top = pBackWnd->GetRect().top; // rt_out.bottom = pOutWnd->GetRect().bottom; // rt_out.left += (-15); // rt_out.right += ( 15); std::vector::iterator it = m_vecMenuList.begin(); while( it != m_vecMenuList.end() ) { DLGMENU menu = (*it); std::string strCaption = "<#cdc1b1>"; strCaption += menu.m_strMenuName; #ifdef _COUNTRY_ME_ if (menu.m_strMenuName.find(">") != std::string::npos) { strCaption = menu.m_strMenuName.substr(0, 9); strCaption += ""; strCaption += " "; strCaption += menu.m_strMenuName.substr(9); strCaption += " "; } #endif char *pszAniName = "button_npc_choice"; // if( (*it).m_nButtonType == SMSG_NPC_DIALOG::BUTTON_QUEST_STARTABLE ) pszAniName = "button_quest_questbegin"; // else if( (*it).m_nButtonType == SMSG_NPC_DIALOG::BUTTON_QUEST_INPROGRESS ) pszAniName = "button_quest_questing"; // else if( (*it).m_nButtonType == SMSG_NPC_DIALOG::BUTTON_QUEST_FINISHABLE ) pszAniName = "button_quest_questok"; /// 2010.11.04 KFLAG_SINGLE_LINE 설정 - prodongi // 2010.08.26 - prodongi //KUIWnd* pWnd = m_pManager->CreateControl( KUIWND_CREATE_ARG( "button", menu.m_strMenuName.c_str(), strCaption.c_str(), // rt, 0, 0, this, pszAniName, c_szDEF_SPR_NAME, m_pManager, 0, "", 0 ) ); KUIWnd* pWnd = m_pManager->CreateControl( KUIWND_CREATE_ARG( "button", menu.m_controlName.c_str(), strCaption.c_str(), rt, 0, KFLAG_SINGLE_LINE/*0*/, this, pszAniName, c_szDEF_SPR_NAME, m_pManager, 0, "", 0 ) ); m_vecButtonList.push_back(pWnd); rt.top = pWnd->GetRect().bottom; rt.bottom = rt.top + pWnd->GetRect().GetHeight(); rt_out.bottom += pWnd->GetRect().GetHeight(); it++; } rt_out.bottom += (-10); pBackWnd->Resize( rt_out ); } void SUINPCDialogWnd::ShowFacecut( AR_HANDLE hNPC ) { SetChildShow( "npc_face", (hNPC!=NULL) ); if( hNPC == NULL ) return; if( m_hFaceNPC > 0 && m_hFaceNPC == hNPC ) return; m_hFaceNPC = hNPC; SIMSG_UI_NPC_SEQFORM_INFO msg( hNPC ); m_pGameManager->ProcMsgAtStatic( &msg ); KUIControl3DStatic* pStaticTarget = dynamicCast(GetChild( "npc_face" )); if( pStaticTarget == NULL ) return; const KRect& rt = pStaticTarget->GetRect(); K3DVertex pos = K3DVertex(0, -8, 13); if( msg.pCobName ) { //NPC 페이스컷 고정 GetNpcResourceDB().GetFaceCut( msg.nContentID, pos ); /* int nRand = rand()%5; if( strstr( msg.pCobName, "dem" ) ) { pos = K3DVertex(cam_pos[0][nRand][0], cam_pos[0][nRand][1], cam_pos[0][nRand][2]); } else if( strstr( msg.pCobName, "def" ) ) { pos = K3DVertex(cam_pos[1][nRand][0], cam_pos[1][nRand][1], cam_pos[1][nRand][2]); } else if( strstr( msg.pCobName, "asm" ) ) { pos = K3DVertex(cam_pos[2][nRand][0], cam_pos[2][nRand][1], cam_pos[2][nRand][2]); } else if( strstr( msg.pCobName, "asf" ) ) { pos = K3DVertex(cam_pos[3][nRand][0], cam_pos[3][nRand][1], cam_pos[3][nRand][2]); } else if( strstr( msg.pCobName, "gam" ) ) { pos = K3DVertex(cam_pos[4][nRand][0], cam_pos[4][nRand][1], cam_pos[4][nRand][2]); } else if( strstr( msg.pCobName, "gaf" ) ) { pos = K3DVertex(cam_pos[5][nRand][0], cam_pos[5][nRand][1], cam_pos[5][nRand][2]); } else{ //그 이외의 것들은 가이아 남자임. pos = K3DVertex(cam_pos[4][nRand][0], cam_pos[4][nRand][1], cam_pos[4][nRand][2]); }*/ } pStaticTarget->SetSeqForm( msg.pSeqForm, KSize( rt.GetWidth(), rt.GetHeight() ), msg.nObjectType, pos ); }