Files
Sun1602/Client/GameClient/Interface/uiNotificationsSystemDialog/uiNotificationsSystemDialog.cpp
T
2022-10-26 12:25:11 +08:00

706 lines
18 KiB
C++

#include "SunClientPrecompiledHeader.h"
#ifdef _NA_008283_20150511_NOTIFICATIONS_SYSTEM
#include "uiNotificationsSystemDialog.h"
#include "uiNotificationsSystemMan/uiNotificationsSystemMan.h"
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
#include "uiCombatRecordMan/uiCombatRecordMan.h"
#include "uiBattleZoneList/uiBattleZoneList.h"
#include "uiChatMan/uiChatMan.h"
#include "Mouse.h"
#include "uiToolTipMan/uiToolTipMan.h"
#include "TextureListInfoParser.h"
#include "TextureListInfoHandleManager.h"
#include "ChatDialog.h"
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
#include "InterfaceManager.h"
#include "Application.h"
WzID uiNotificationsSystemDialog::wz_id_[DIALOG_MAX] =
{
StrToWzID("L001"),
StrToWzID("L000"),
StrToWzID("S000"),
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
StrToWzID("C002"),
StrToWzID("C000"),
StrToWzID("C001"),
#else
StrToWzID("B001"),
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
};
uiNotificationsSystemDialog::uiNotificationsSystemDialog(InterfaceManager* ui_manager) :
uiBase(ui_manager),
is_show_(FALSE)
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
, tooltip_manager_ptr_(NULL)
, eye_check_control_(NULL)
, combat_check_control_(NULL)
, system_check_control_(NULL)
, save_check_(0)
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
{
}
uiNotificationsSystemDialog::~uiNotificationsSystemDialog(void)
{
}
void uiNotificationsSystemDialog::Init( CDrawBase* draw_base )
{
uiBase::Init(draw_base);
notifications_text_control_ = static_cast<CCtrlListWZ*>(GetControlWZ(wz_id_[DLGPOS_NOTIFICATIONS_TEXT]));
notifications_special_text_control_ = static_cast<CCtrlListWZ*>(GetControlWZ(wz_id_[DLGPOS_NOTIFICATIONS_SPECIAL_LIST]));
notifications_special_text_control_->ShowWindowWZ(WZ_HIDE);
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
for (int i = CBM_SYSTEM; i < CBM_MAX; ++i)
{
TextureListInfoHandleManager::Instance()->LoadIcon(i);
}
system_check_control_ = static_cast<CCtrlButtonCheckWZ*>(GetControlWZ(wz_id_[DLGPOS_SYSTEM_CHECK]));
if (system_check_control_)
{
system_check_control_->SetCheckState(false);
}
eye_check_control_ = static_cast<CCtrlButtonCheckWZ*>(GetControlWZ(wz_id_[DLGPOS_EYE_CHECK]));
if (eye_check_control_)
{
eye_check_control_->SetCheckState(false);
}
combat_check_control_ = static_cast<CCtrlButtonCheckWZ*>(GetControlWZ(wz_id_[DLGPOS_COMBAT_CHECK]));
if (combat_check_control_)
{
combat_check_control_->SetCheckState(false);
}
if (tooltip_manager_ptr_ == NULL)
{
tooltip_manager_ptr_ = GET_DIALOG_MANAGER(uiToolTipMan, UIMAN_TOOLTIP);
}
#else
eye_button_control_ = static_cast<CCtrlButtonWZ*>(GetControlWZ(wz_id_[DLGPOS_EYE_BTN]));
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
notifications_text_rect_ = notifications_text_control_->GetSizeRect();
const int width_offset = 7;
const int right_width_offset = 3;
notifications_text_rect_.left += width_offset;
notifications_text_rect_.right -= right_width_offset;
notifications_text_rect_.right = notifications_text_rect_.right + (notifications_text_rect_.right - notifications_text_rect_.left);
notifications_system_manager_ = static_cast<uiNotificationsSystemMan*>(GetMan());
// 񃧯 SystemChat
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(FALSE);
}
save_check_ = 0;
move_offset_ = 0;
second_move_offset_ = 0;
is_second_move_ = false;
}
void uiNotificationsSystemDialog::Release()
{
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
tooltip_manager_ptr_ = NULL;
save_check_ = 0;
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
}
void uiNotificationsSystemDialog::OnShowWindow( BOOL is_show )
{
if ( is_show )
{
move_offset_ = 0;
second_move_offset_ = 0;
is_second_move_ = false;
is_show_ = TRUE;
MoveDefaultPosition();
}
else
{
move_offset_ = 0;
second_move_offset_ = 0;
is_second_move_ = false;
is_show_ = FALSE;
}
}
void uiNotificationsSystemDialog::OnUpdateSolarDialog()
{
if (FALSE == is_show_)
return;
//DWORD tick = clock_function::GetTickCount();
static DWORD prev_tick = clock_function::GetTickCount();
DWORD cur_tick = clock_function::GetTickCount();
DWORD tick = cur_tick - prev_tick;
if (tick < 3)
{
return;
}
prev_tick = cur_tick;
notifications_system_manager_->CheckNextNotificationsShow();
std::vector<HANDLE>& temp_text_texture_vector = notifications_system_manager_->get_text_texture_vector();
if ( temp_text_texture_vector.empty() == true )
{
return;
}
static bool is_change = false;
if ( notifications_text_rect_.left > notifications_text_control_->GetSizeRect().left )
{
notifications_text_rect_.left -= 1;
if ( notifications_text_rect_.left <= notifications_text_control_->GetSizeRect().left )
{
notifications_text_rect_.left = notifications_text_control_->GetSizeRect().left;
is_change = true;
}
}
if ( notifications_text_rect_.left <= notifications_text_control_->GetSizeRect().left )
{
if ( is_change == false )
{
++move_offset_;
}
else
{
is_change = false;
}
}
if ( is_second_move_ == true )
{
++second_move_offset_;
}
}
void uiNotificationsSystemDialog::OnRenderSolarDialog()
{
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
UpdateTooltip();
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
std::vector<HANDLE>& temp_text_texture_vector = notifications_system_manager_->get_text_texture_vector();
if ( temp_text_texture_vector.empty() == true )
{
return;
}
if ( temp_text_texture_vector[0] != INVALID_HANDLE_VALUE )
{
St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(temp_text_texture_vector[0]);
if ( TexInfo )
{
// ¼¼·Î °¡¿îµ¥ Á¤·Ä.
int height_differ = notifications_text_rect_.bottom - notifications_text_rect_.top;
int image_height_half = TexInfo->m_nImageHeight / 2;
int result_height = notifications_text_rect_.top + (height_differ / 2) - (image_height_half);
if ( notifications_text_rect_.left > notifications_text_control_->GetSizeRect().left /* + width_offset */)
{
int result_width = notifications_text_rect_.right - notifications_text_rect_.left;
if ( result_width > TexInfo->m_nImageWidth )
{
result_width = TexInfo->m_nImageWidth;
}
g_pSunRenderer->RenderTexture(temp_text_texture_vector[0],
(float)notifications_text_rect_.left,
(float)result_height,
(float)result_width,
(float)TexInfo->m_nImageHeight,
(float)0,
(float)0,
(float)result_width,
(float)TexInfo->m_nImageHeight,
NULL);
}
else
{
int result_width = notifications_text_rect_.right - notifications_text_rect_.left;
if ( result_width > TexInfo->m_nImageWidth - move_offset_ )
{
result_width = TexInfo->m_nImageWidth - (int)move_offset_;
}
g_pSunRenderer->RenderTexture(temp_text_texture_vector[0],
(float)notifications_text_rect_.left,
(float)result_height,
(float)result_width,
(float)TexInfo->m_nImageHeight,
(float)move_offset_,
(float)0,
(float)result_width,
(float)TexInfo->m_nImageHeight,
NULL);
if ( temp_text_texture_vector.size() == 1 &&
notifications_text_rect_.left + result_width < notifications_text_control_->GetSize().left )
{
notifications_system_manager_->ClearTextTextureVector();
notifications_system_manager_->DeleteNotificationsListBegin();
ResetUIType();
}
if ( temp_text_texture_vector.size() > 1 )
{
for (unsigned int i = 1; i < temp_text_texture_vector.size(); ++i)
{
int second_width = 0;
TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(temp_text_texture_vector[i]);
second_width = TexInfo->m_nImageWidth;
if (notifications_text_rect_.right < notifications_text_rect_.left + result_width + second_width)
{
second_width = notifications_text_rect_.right - (notifications_text_rect_.left + result_width);
}
int rect_left = notifications_text_rect_.left + result_width;
if ( rect_left > notifications_text_control_->GetSize().left )
{
g_pSunRenderer->RenderTexture(temp_text_texture_vector[i],
(float)notifications_text_rect_.left + result_width,
(float)result_height,
(float)second_width,
(float)TexInfo->m_nImageHeight,
(float)0,
(float)0,
(float)second_width,
(float)TexInfo->m_nImageHeight,
NULL);
}
else
{
is_second_move_ = true;
rect_left = notifications_text_control_->GetSize().left;
second_width = second_width - (int)second_move_offset_;
g_pSunRenderer->RenderTexture(temp_text_texture_vector[i],
(float)rect_left,
(float)result_height,
(float)second_width,
(float)TexInfo->m_nImageHeight,
(float)second_move_offset_,
0,
(float)second_width,
(float)TexInfo->m_nImageHeight,
NULL);
if ( rect_left + second_width < notifications_text_control_->GetSize().left )
{
notifications_system_manager_->ClearTextTextureVector();
notifications_system_manager_->DeleteNotificationsListBegin();
ResetUIType();
}
}
}
}
}
}
}
}
void uiNotificationsSystemDialog::MessageProc( SI_MESSAGE* message )
{
switch ( message->eResultMsg )
{
case RT_MSG_LBUTTONCLICK:
{
switch ( getCtrlIDToPos(message->dwCtrlID) )
{
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
case DLGPOS_SYSTEM_CHECK:
{
if (system_check_control_->GetCheckState())
{
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(TRUE);
save_check_ = DLGPOS_SYSTEM_CHECK;
}
uiCombatRecordMan* ui_combat_record_manager =
GET_DIALOG_MANAGER(uiCombatRecordMan, UIMAN_COMBAT_RECORD);
if (ui_combat_record_manager)
{
ui_combat_record_manager->CloseCombatRecordDialog();
}
notifications_system_manager_->CloseNotificationsList();
}
else
{
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(FALSE);
save_check_ = 0;
}
}
}
break;
case DLGPOS_EYE_CHECK:
{
if (eye_check_control_->GetCheckState())
{
notifications_system_manager_->ShowNotificationsList();
save_check_ = DLGPOS_EYE_CHECK;
uiCombatRecordMan* ui_combat_record_manager =
GET_DIALOG_MANAGER(uiCombatRecordMan, UIMAN_COMBAT_RECORD);
if (ui_combat_record_manager)
{
ui_combat_record_manager->CloseCombatRecordDialog();
}
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(FALSE);
}
}
else
{
notifications_system_manager_->CloseNotificationsList();
save_check_ = 0;
}
}
break;
#else
case DLGPOS_EYE_BTN:
{
notifications_system_manager_->ToggleNotificationsList();
}
break;
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
case DLGPOS_COMBAT_CHECK:
{
uiCombatRecordMan* ui_combat_record_manager =
GET_DIALOG_MANAGER(uiCombatRecordMan, UIMAN_COMBAT_RECORD);
if (combat_check_control_->GetCheckState())
{
if (ui_combat_record_manager)
{
ui_combat_record_manager->ShowCombatRecordDialog();
save_check_ = DLGPOS_COMBAT_CHECK;
}
notifications_system_manager_->CloseNotificationsList();
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(FALSE);
}
}
else
{
if (ui_combat_record_manager)
{
ui_combat_record_manager->CloseCombatRecordDialog();
save_check_ = 0;
}
}
}
break;
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
}
}
break;
default:
{
SolarDialog::MessageProc( message );
}
}
}
void uiNotificationsSystemDialog::ResetNotificationsTextRect()
{
notifications_text_rect_ = notifications_text_control_->GetSizeRect();
const int width_offset = 7;
const int right_width_offset = 3;
notifications_text_rect_.left += width_offset;
notifications_text_rect_.right -= right_width_offset;
notifications_text_rect_.left = notifications_text_rect_.right;
}
void uiNotificationsSystemDialog::MoveDefaultPosition()
{
POINT pt = g_pApplication->Get2DModeMapping();
RECT rcClient;
GetDialogWZ()->GetClientRect(&rcClient);
POINT MyInitialPoint;
MyInitialPoint.x = pt.x - (rcClient.right- rcClient.left);//-386;
MyInitialPoint.y = pt.y - (rcClient.bottom - rcClient.top + 100) - 4;
this->MoveWindowWZ((float)MyInitialPoint.x, (float)MyInitialPoint.y);
}
POSTYPE uiNotificationsSystemDialog::getCtrlIDToPos( WzID wzId )
{
for( POSTYPE i = 0 ; i < DIALOG_MAX ; ++i )
{
if( wz_id_[i] == wzId )
{
return i;
}
}
return DIALOG_MAX;
}
void uiNotificationsSystemDialog::MoveDefaultWindowPos()
{
SolarDialog::MoveDefaultWindowPos();
MoveDefaultPosition();
}
void uiNotificationsSystemDialog::ResetNotificationsTime()
{
move_offset_ = 0;
second_move_offset_ = 0;
is_second_move_ = false;
}
void uiNotificationsSystemDialog::ResetUIType()
{
if ( notifications_special_text_control_ )
{
notifications_special_text_control_->ShowWindowWZ(WZ_HIDE);
}
}
void uiNotificationsSystemDialog::SpecialTextUIShow()
{
if ( notifications_special_text_control_ )
{
notifications_special_text_control_->ShowWindowWZ(WZ_SHOW);
}
}
#ifdef _NA_008800_20160510_COMBAT_RECORD_SYSTEM
void uiNotificationsSystemDialog::SetSystemMessageCheckState( const bool& state )
{
if (system_check_control_)
{
system_check_control_->SetCheckState(state);
}
}
void uiNotificationsSystemDialog::SetCombatRecordCheckState( const bool& state )
{
if (combat_check_control_)
{
combat_check_control_->SetCheckState(state);
}
}
void uiNotificationsSystemDialog::SetEyeCheckState( const bool& state )
{
if (eye_check_control_)
{
eye_check_control_->SetCheckState(state);
}
}
void uiNotificationsSystemDialog::PrintTooltip( const int& check_pos )
{
int message_index = 0;
switch ( check_pos )
{
case DLGPOS_SYSTEM_CHECK:
{
message_index = 2077;
}
break;
case DLGPOS_COMBAT_CHECK:
{
message_index = 2079;
}
break;
case DLGPOS_EYE_CHECK:
{
message_index = 2078;
}
break;
default:
{
return;
}
break;
}
TCHAR result_message[INTERFACE_STRING_LENGTH] = {0, };
g_InterfaceManager.GetInterfaceString(message_index, result_message);
tooltip_manager_ptr_->InitTooltip();
tooltip_manager_ptr_->RegisterTooltip(result_message,
-1,
22,
StrToWzID("s210"),
WzColor_RGBA(255, 255, 255, 255),
TOOLTIP_BG_WZCOLOR,
c_dwTOOLTIP_EXTRA_INFO_DT_LEFT);
tooltip_manager_ptr_->SetTooltipDialogID(GetDialogKey());
}
void uiNotificationsSystemDialog::UpdateTooltip()
{
int iMouseX = Mouse::Instance()->GetMouseX();
int iMouseY = Mouse::Instance()->GetMouseY();
{
CControlWZ* control_ptr = NULL;
for (int i = DLGPOS_SYSTEM_CHECK; i <= DLGPOS_EYE_CHECK; ++i)
{
control_ptr = GetControlWZ(wz_id_[i]);
if (control_ptr)
{
RECT control_rect = control_ptr->GetSizeRect();
if (control_rect.left <= iMouseX && control_rect.right >= iMouseX
&& control_rect.top <= iMouseY && control_rect.bottom >= iMouseY)
{
if ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) == false)
{
BASE_TextureListInfo* tex_info = NULL;
HANDLE tex_handle = TextureListInfoHandleManager::Instance()->GetTexture(i - DLGPOS_SYSTEM_CHECK + CBM_SYSTEM, tex_info);
if (tex_handle != INVALID_HANDLE_VALUE && tex_info != NULL)
{
g_pSunRenderer->RenderTexture(tex_handle,
(float)control_rect.left,
(float)control_rect.top,
(float)control_rect.right - control_rect.left,
(float)control_rect.bottom - control_rect.top,
(float)tex_info->tex_size.left,
(float)tex_info->tex_size.top,
(float)tex_info->tex_size.right,
(float)tex_info->tex_size.bottom);
}
}
PrintTooltip(i);
}
}
}
}
}
void uiNotificationsSystemDialog::ShowGameInterface( const BOOL& flag )
{
if (system_check_control_ && system_check_control_->GetCheckState())
{
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(flag);
}
}
if (combat_check_control_ && combat_check_control_->GetCheckState())
{
uiCombatRecordMan* ui_combat_record_manager =
GET_DIALOG_MANAGER(uiCombatRecordMan, UIMAN_COMBAT_RECORD);
if (ui_combat_record_manager)
{
if (flag == TRUE)
ui_combat_record_manager->ShowCombatRecordDialog();
else
ui_combat_record_manager->CloseCombatRecordDialog();
}
}
if (eye_check_control_ && eye_check_control_->GetCheckState())
{
if (notifications_system_manager_)
{
if (flag == TRUE)
notifications_system_manager_->ShowNotificationsList();
else
notifications_system_manager_->CloseNotificationsList();
}
}
uiBattleZoneList* pZoneListDlg=(uiBattleZoneList*)g_InterfaceManager.GetDialog(InterfaceManager::DIALOG_BATTLEZONE_LIST);
if(pZoneListDlg)
{
if(pZoneListDlg->IsVisible())
{
pZoneListDlg->AttachChatDialog();
}
}
if (flag == TRUE)
{
switch (save_check_)
{
case DLGPOS_SYSTEM_CHECK:
{
ChatDialog* chat_dialog =
GET_CAST_DIALOG(ChatDialog, IM_CHAT_MANAGER::CHAT_DIALOG);
if (chat_dialog != NULL)
{
chat_dialog->ShowSystemChatDialog(TRUE);
}
}
break;
case DLGPOS_COMBAT_CHECK:
{
uiCombatRecordMan* ui_combat_record_manager =
GET_DIALOG_MANAGER(uiCombatRecordMan, UIMAN_COMBAT_RECORD);
if (ui_combat_record_manager)
{
ui_combat_record_manager->ShowCombatRecordDialog();
}
}
break;
case DLGPOS_EYE_CHECK:
{
notifications_system_manager_->ShowNotificationsList();
}
break;
}
}
}
#endif // _NA_008800_20160510_COMBAT_RECORD_SYSTEM
#endif // _NA_008283_20150511_NOTIFICATIONS_SYSTEM