#include "SunClientPrecompiledHeader.h" #include "uiGuideSystemMan/uiGuideSystemMan.h" #include "uiGuideMessageDialog/uiGuideMessageDialog.h" #include "uiGuideTutorialDialog/uiGuideTutorialDialog.h" #include "uiGuideTutorialOpenDialog/uiGuideTutorialOpenDialog.h" #include "uiGuideInfomationDialog/uiGuideInfomationDialog.h" #include "Hero.h" #include "GameFramework.h" #include "SceneBase.h" #include "GlobalFunc.h" const DWORD IM_GUIDE_SYSTEM_MANAGER::HELP_ALERT = StrToWzID("0434"); const DWORD IM_GUIDE_SYSTEM_MANAGER::TUTORIAL = StrToWzID("0435"); const DWORD IM_GUIDE_SYSTEM_MANAGER::TUTORIAL_OPEN = StrToWzID("0437"); const DWORD IM_GUIDE_SYSTEM_MANAGER::INFOMATION = StrToWzID("0436"); const char c_guide_system_help_alert_ui_name[] = ("Data\\Interface\\43_4_Help.iwz"); const char c_guide_system_tutorial_ui_name[] = ("Data\\Interface\\43_5_Tutorial.iwz"); const char c_guide_system_tutorial_opeb_ui_name[] = ("Data\\Interface\\43_7_Tutorial.iwz"); const char c_guide_system_infomation_ui_name[] = ("Data\\Interface\\43_6_Tutorial.iwz"); REPEAT_LIST_DATA::REPEAT_LIST_DATA() { InitData(); } REPEAT_LIST_DATA::~REPEAT_LIST_DATA() { } void REPEAT_LIST_DATA::InitData() { repeat_data_header.packet_ver = REPEAT_DATA_PACKET_VER; repeat_data_header.repeat_list_count = 0; ZeroMemory(repeat_list, sizeof(repeat_list)); } LIBRARY_LIST_DATA::LIBRARY_LIST_DATA() { InitData(); } LIBRARY_LIST_DATA::~LIBRARY_LIST_DATA() { } void LIBRARY_LIST_DATA::InitData() { library_data_header.packet_ver = 0; library_data_header.library_list_count = 0; ZeroMemory(library_list, sizeof(library_list)); } uiGuideSystemMan::uiGuideSystemMan(InterfaceManager* ui_manager) : uiBaseMan(ui_manager) { } void uiGuideSystemMan::OnRelease() { #ifdef _NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT #else SAFE_DELETE(waiting_save_recv_timer_); #endif //_NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT } void uiGuideSystemMan::OnInitialize() { // load ui ui_guide_message_dialog_ = CreateUIDialog(IM_GUIDE_SYSTEM_MANAGER::HELP_ALERT, c_guide_system_help_alert_ui_name, this, TRUE); assert(ui_guide_message_dialog_); ui_guide_tutorial_dialog_ = CreateUIDialog(IM_GUIDE_SYSTEM_MANAGER::TUTORIAL, c_guide_system_tutorial_ui_name, this, TRUE); assert(ui_guide_tutorial_dialog_); ui_guide_tutorial_open_dialog_ = CreateUIDialog(IM_GUIDE_SYSTEM_MANAGER::TUTORIAL_OPEN, c_guide_system_tutorial_opeb_ui_name, this, TRUE); assert(ui_guide_tutorial_open_dialog_); ui_guide_infomation_dialog_ = CreateUIDialog(IM_GUIDE_SYSTEM_MANAGER::INFOMATION, c_guide_system_infomation_ui_name, this, TRUE); assert(ui_guide_infomation_dialog_); #ifdef _NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT #else // initialize logout_type_ = kLogOutTypeEnd; waiting_repeat_save_recv_ = false; waiting_library_save_recv_ = false; waiting_first_packet_recv_ = false; waiting_save_recv_timer_ = new util::Timer; #endif //_NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT is_have_notice_once_ = false; } void uiGuideSystemMan::Update() { #ifdef _NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT #else UpdateSaveTimer(); #endif //_NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT } void uiGuideSystemMan::OpenGuideDialog(BYTE guide_dialog_type, TotalGuideNotice::Index guide_index) { switch (guide_dialog_type) { case kDialogType_HelpAlert: if (ui_guide_message_dialog_) { ui_guide_message_dialog_->AddData(guide_index); //ui_guide_message_dialog_->ShowInterface(TRUE); } break; case kDialogType_Tutorial: if (ui_guide_tutorial_dialog_) { ui_guide_tutorial_dialog_->ShowInterface(FALSE); ui_guide_tutorial_dialog_->SetData(guide_index, 1);//Ç×»ó 1ÆäÀÌÁö ui_guide_tutorial_dialog_->ShowInterface(TRUE); } break; case kDialogType_Information: if (ui_guide_infomation_dialog_) { ui_guide_infomation_dialog_->SetData(guide_index, 1);//Ç×»ó 1ÆäÀÌÁö ui_guide_infomation_dialog_->ShowInterface(TRUE); } break; } } void uiGuideSystemMan::OpenGuideInfoDialog() { if (ui_guide_infomation_dialog_) { if (ui_guide_infomation_dialog_->IsVisible()) { ui_guide_infomation_dialog_->ShowInterface(FALSE); } else { ui_guide_infomation_dialog_->SetData(1, 1);//Ç×»ó 1ÆäÀÌÁö ui_guide_infomation_dialog_->ShowInterface(TRUE); } } } void uiGuideSystemMan::ResetInfomationDialog() { if (ui_guide_infomation_dialog_) { ui_guide_infomation_dialog_->ResetData(); } } void uiGuideSystemMan::AddGuide(DWORD character_status, DWORD param1 /*= 0*/, DWORD param2 /*= 0*/) { bool is_addition = false; const TotalGuideNotice::CharStatus status = static_cast(character_status); const TotalGuideNoticeManager::CharStatusMap& status_map = TotalGuideParser::Instance()->GetNoticeManager().char_status_map; TotalGuideNoticeManager::CharStatusMap::const_iterator pos = status_map.lower_bound(status); TotalGuideNoticeManager::CharStatusMap::const_iterator end_pos = status_map.upper_bound(status); for (;pos != end_pos; ++pos) { const TotalGuideNotice* const notice = pos->second; is_addition = false; if (notice->min_level <= g_pHero->GetLevel() && (notice->min_level > notice->max_level || g_pHero->GetLevel() <= notice->max_level))// ÃÖ´ë ·¹º§ÀÌ ÃÖ¼Ò ·¹º§º¸´Ù ³·À¸¸é ÃÖ´ë·¹º§ üũ ¾ÈÇÔ { switch (character_status) { case TotalGuideNotice::kGetItem: case TotalGuideNotice::kQuest: { if (param1 == notice->GetParam(0) && param2 == notice->GetParam(1)) { is_addition = true; } } break; case TotalGuideNotice::kUnderHP: { if ((notice->GetParam(0) == param1) && (param2 <= notice->GetParam(1))) // ÇØ´ç ¼öÄ¡ or %º¸´Ù ÀÛÀ»¶§ { is_addition = true; } } break; case TotalGuideNotice::kRemainGuide: { if (is_have_notice_once_ == false && ui_guide_infomation_dialog_->IsHaveNoticeGuide()) { is_have_notice_once_ = true; is_addition = true; } } break; default: { if (notice->GetParam(0) == param1) { is_addition = true; } } break; } if (is_addition == false) { continue; } bool is_repeat = false; // TODO: Áߺ¹½ÇÇ൵ Ã¼Å©ÇØ¾ßÇÔ // guide »ç¿ë ÄÚµå´Â ¿©±â¿¡ if (notice->repeat_type != TotalGuideNotice::kContinue) { //Áߺ¹Ã¼Å© is_repeat = CheckRepeatData(notice->code, notice->repeat_type); } if (is_repeat == true) { continue; } else //¹Ýº¹ ±ÝÁö µ¥ÀÌÅÍ + »ý¼ºÀ̸é { if (character_status == TotalGuideNotice::kCreate) { is_have_notice_once_ = true; } } if (ui_guide_message_dialog_) { ui_guide_message_dialog_->AddData(notice->code); } } } } void uiGuideSystemMan::CheckHelpMessage(DWORD character_status, DWORD param1/* = 0*/, DWORD param2/* = 0*/) { if(!g_pHero) return; /*if(!m_bLoadInfo) { LoadReadInfo(); }*/ // ¹èƲ ·Îºñ¿¡¼­´Â üũ ¾ÈÇÑ´Ù(ÃßÈÄ¿¡ ¹èƲÁ¸ ¸®´º¾óÀÌ µÇ¸é üũ ÇÏÁö ¾Êµµ·Ï) if (( GameFramework::GetCurrentScene()->GetType() == SCENE_TYPE_LOBBY ) || ( GameFramework::GetCurrentScene()->GetType() == SCENE_TYPE_CHARSELECT ) || ( GameFramework::GetCurrentScene()->GetType() == SCENE_TYPE_LOGIN ) || ( GameFramework::GetCurrentScene()->GetType() == SCENE_TYPE_NONE ) ) return; switch (character_status) { case TotalGuideNotice::kCreate: //1. ij¸¯ÅÍ »ý¼º { if (GlobalFunc::IsBattleZone()) { return; } } break; case TotalGuideNotice::kNpcClick: //2. NPCŬ¸¯ case TotalGuideNotice::kEnterToMap: //3. ƯÁ¤ ¸Ê ÁøÀÔ case TotalGuideNotice::kGetExp: //4. °æÇèÄ¡ ½Àµæ case TotalGuideNotice::kGetItem://5. ¾ÆÀÌÅÛ ½Àµæ case TotalGuideNotice::kLevelUp://6. ·¹º§¾÷ case TotalGuideNotice::kFreeChaos://7.ÇÁ¸®Ä«¿À case TotalGuideNotice::kChaos://8.Ä«¿À case TotalGuideNotice::kDead://9.ij¸¯ÅÍ »ç¸Á case TotalGuideNotice::kCreateGuild://10.±æµå â¼³ case TotalGuideNotice::kUnderHP://11.HP ƯÁ¤ ÆÛ¼¾Æ® ÀÌÇÏ case TotalGuideNotice::kQuest://12.Äù½ºÆ® ¼ö¶ô/¿Ï·á case TotalGuideNotice::kAccumulatePoint: // 14.Á¢¼ÓÀÚ Æ÷ÀÎÆ® ȹµæ½Ã case TotalGuideNotice::kRemainGuide://16.º¸Áö ¾ÊÀº °¡À̵å Á¤º¸°¡ ÀÖ´Â °æ¿ì break; default: return; } AddGuide(character_status, param1, param2); } void uiGuideSystemMan::AddInfoNotice(TotalGuideNotice::Index guide_index) { if (ui_guide_infomation_dialog_) { ui_guide_infomation_dialog_->AddData(guide_index); ui_guide_infomation_dialog_->SelectList(guide_index); } } void uiGuideSystemMan::DeleteInfoNotice(TotalGuideNotice::Index guide_index) { if (ui_guide_infomation_dialog_) { TotalGuide* guide = TotalGuideParser::Instance()->GetGuide(guide_index); if (guide) { ui_guide_infomation_dialog_->DeleteData(guide->category_code, guide_index); } } } void uiGuideSystemMan::SEND_GUIDE_DATA_GAMEOPTION_LOAD_SYN() { repeat_list_.InitData(); repeat_save_list_.InitData(); MSG_CG_ETC_GAMEOPTION_LOAD_SYN sync; sync.option_type_ = GameOption::kNoticePerChar; GlobalFunc::SendPacket(CI_GAMESERVERIDX, &sync, sizeof(sync)); } void uiGuideSystemMan::LoadRepeatData(GameOption* game_option) { //ÃʱâÈ­ repeat_list_.InitData(); repeat_save_list_.InitData(); //¹Ýº¹ ¸®½ºÆ®¸¦ ¹ÞÀ½ const size_t repeat_size = sizeof(repeat_list_.repeat_list[0]); if (game_option->binary_data_size_ > 0) { //Çì´õ¸¦ ¸ÕÀú ÀÐÀ½ memcpy(&repeat_list_.repeat_data_header, game_option->binary_data_, sizeof(REPEAT_DATA_HEADER)); //¹öÀü °Ë»ç if (repeat_list_.repeat_data_header.packet_ver == REPEAT_DATA_PACKET_VER) { //Repeat µ¥ÀÌÅÍ °ËÁõ int currunt_index = 0; void* buffer_pointer = static_cast(game_option->binary_data_ + sizeof(REPEAT_DATA_HEADER)); WORD* repeat_pointer = static_cast(buffer_pointer); for(int index = 0; index < repeat_list_.repeat_data_header.repeat_list_count; ++index) { WORD guide_index = *(repeat_pointer + index); const TotalGuideNotice* notice = TotalGuideParser::Instance()->GetNotice(guide_index); if ((notice == NULL) || (notice->repeat_type != TotalGuideNotice::kOnce)) { //¹Ýº¹¾ÈÇÔ µ¥ÀÌÅͰ¡ ¾Æ´Ô } else { repeat_list_.repeat_list[currunt_index] = guide_index; ++currunt_index; } } repeat_list_.repeat_data_header.repeat_list_count = currunt_index; } //¹ÞÀº µ¥ÀÌÅÍ¿¡ ¹Ýº¹ÇØ¾ß µÇ´Â µ¥ÀÌÅͰ¡ À߸ø µé¾î¿ÍÀÖ´ÂÁöÀÇ °ËÁõ //VerifyRepeatData(&repeat_list_); memcpy(&repeat_save_list_, &repeat_list_, sizeof(REPEAT_LIST_DATA)); } } void uiGuideSystemMan::SaveRepeatData() { //¹Ýº¹ ¸®½ºÆ®¸¦ ÀúÀå MSG_CG_ETC_GAMEOPTION_SAVE_SYN sync; ZeroMemory(&(sync.game_option_), sizeof(sync.game_option_)); sync.game_option_.option_type_ = GameOption::kNoticePerChar; sync.game_option_.binary_data_size_ = repeat_save_list_.GetSize(); memcpy(sync.game_option_.binary_data_, &repeat_save_list_, repeat_save_list_.GetSize()); GlobalFunc::SendPacket(CI_GAMESERVERIDX, &sync, sync.GetSize()); } bool uiGuideSystemMan::CheckRepeatData(WORD guide_notice_code,TotalGuideNotice::RepeatType repeat_type) { //ÇØ´ç ÄÚµåÀÇ Notice°¡ ½ÇÇà ‰ç¾ú´ø °ÇÁö ¹Ýº¹ ¿©ºÎ üũ //½ÇÇà Çß¾úÀ¸¸é true ¸®ÅÏ for (uint index = 0; index < repeat_list_.repeat_data_header.repeat_list_count; ++index) { if (repeat_list_.repeat_list[index] == guide_notice_code) { return true; } } if (repeat_type != TotalGuideNotice::kContinue) { //¼¼À̺ê if (index > TotalGuideNotice::kMaxSize) { //¿¡·¯ : À妽º Ãʰú assert(!"TotalGuideNoticeManager::CheckRepeatData()¿¡¼­ index°¡ ¿¹Ãø ÇÏÁö ¸øÇÑ ¹üÀ§¸¦ ¹þ¾î³µ½À´Ï´Ù."); return false; } repeat_list_.repeat_list[repeat_list_.repeat_data_header.repeat_list_count] = guide_notice_code; repeat_list_.repeat_data_header.repeat_list_count += 1; //¹Ù·Î ÀúÀåÇÒ²¨¸é ¿©±â¼­ ¹Ù·Î ÀúÀå if (repeat_type == TotalGuideNotice::kOnce) { repeat_save_list_.repeat_list[repeat_save_list_.repeat_data_header.repeat_list_count] = guide_notice_code; repeat_save_list_.repeat_data_header.repeat_list_count += 1; } } return false; } #ifdef _NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT void uiGuideSystemMan::SaveData() { SaveRepeatData(); SaveLibraryData(); } #else void uiGuideSystemMan::SaveAndOut(LogOutType logout_type) { SetWaitingSaveTimer(WAITING_SAVE_RECV_TIME); logout_type_ = logout_type; set_waiting_first_packet_recv(false); SaveRepeatData(); SaveLibraryData(); } void uiGuideSystemMan::UpdateSaveTimer() { if ((waiting_repeat_save_recv() == true) && (waiting_library_save_recv() == true)) { //½Ã°£ üũ if (waiting_save_recv_timer_->IsExpired() == true) { set_waiting_repeat_save_recv(false); set_waiting_library_save_recv(false); set_waiting_first_packet_recv(false); //½Ã°£ ´Ù‰çÀ¸¸é Á¾·á switch(logout_type_) { case kGotoCharacterSelect: { logout_type_ = kLogOutTypeEnd; MSG_CG_CONNECTION_BACKTOCHARSELECT_SYN SendPacket; GlobalFunc::SendPacket( CI_GAMESERVERIDX, &SendPacket, sizeof(SendPacket)); } break; case kGotoServerSelect: { logout_type_ = kLogOutTypeEnd; //¼­¹ö ¸®½ºÆ®·Î µ¹¾Æ°¥ ¶§´Â Ŭ¶ó¿¡¼­ Á¦¾î ¾ÈµÊ } break; case kGotoExit: { logout_type_ = kLogOutTypeEnd; GlobalFunc::LogOutGame(false); } break; case kLogOutTypeEnd: { //no operation } break; default: assert(!"Unknown value = logout_type_"); break; } } } } #endif //_NA_008090_20150226_GAMEOPTION_RECVPACKET_DONT_WAIT void uiGuideSystemMan::SEND_LIBRARY_DATA_GAMEOPTION_LOAD_SYN() { library_list_data_.InitData(); MSG_CG_ETC_GAMEOPTION_LOAD_SYN sync; sync.option_type_ = GameOption::kGuidePerChar; GlobalFunc::SendPacket(CI_GAMESERVERIDX, &sync, sizeof(sync)); } void uiGuideSystemMan::LoadLibraryData(GameOption* game_option) { library_list_data_.InitData(); if (game_option->binary_data_size_ > 0) { memcpy(&library_list_data_, game_option->binary_data_, game_option->binary_data_size_); } } void uiGuideSystemMan::SaveLibraryData() { //¿­¶÷½Ç µ¥ÀÌÅ͸¦ ÀúÀå MSG_CG_ETC_GAMEOPTION_SAVE_SYN sync; ZeroMemory(&(sync.game_option_), sizeof(sync.game_option_)); sync.game_option_.option_type_ = GameOption::kGuidePerChar; sync.game_option_.binary_data_size_ = library_list_data_.GetSize(); memcpy(sync.game_option_.binary_data_, &library_list_data_, library_list_data_.GetSize()); GlobalFunc::SendPacket(CI_GAMESERVERIDX, &sync, sync.GetSize()); }