void game_cl_TeamDeathmatch::OnTeamMenu_Cancel		()
{
	StartStopMenu(m_game_ui->m_pUITeamSelectWnd, true);
	if (!m_bTeamSelected && !m_bSpectatorSelected)
	{
		if (CanCallTeamSelectMenu() && !m_game_ui->m_pUITeamSelectWnd->IsShown())
		{
			StartStopMenu(m_game_ui->m_pUITeamSelectWnd, true);
			return;
		}
	}
	m_bMenuCalledFromReady = FALSE;
};
Exemple #2
0
void				game_cl_Deathmatch::OnGameRoundStarted				()
{
	inherited::OnGameRoundStarted();
	if (pCurBuyMenu && pCurBuyMenu->IsShown())
		StartStopMenu(pCurBuyMenu, true);
	if (local_player)
	{
		if (pCurBuyMenu) 
		{
			pCurBuyMenu->IgnoreMoneyAndRank(false);
			pCurBuyMenu->SetRank(local_player->rank);
		}
		ClearBuyMenu();
		LoadDefItemsForRank(pCurBuyMenu);
		ChangeItemsCosts(pCurBuyMenu);
		if (pCurBuyMenu && pCurPresetItems)
		{
			LoadTeamDefaultPresetItems(GetTeamMenu(local_player->team), pCurBuyMenu, pCurPresetItems);
		}
	}
	if (pCurBuyMenu) pCurBuyMenu->ClearPreset(_preset_idx_last);
	//-----------------------------------------------------------------
	if ( m_game_ui && m_game_ui->ActorMenu().IsShown() )
	{
		m_game_ui->HideActorMenu();
	}
}
void game_cl_TeamDeathmatch::OnTeamMenuBack			()
{
	if (local_player->testFlag(GAME_PLAYER_FLAG_SPECTATOR))
	{
		StartStopMenu(m_game_ui->m_pMapDesc, true);
//        StartStopMenu(pMapDesc, true);
	}
};
void game_cl_TeamDeathmatch::shedule_Update			(u32 dt)
{
	CStringTable st;
	string512	msg;

	if(!m_game_ui && HUD().GetUI() ) m_game_ui = smart_cast<CUIGameTDM*>( HUD().GetUI()->UIGame() );
	inherited::shedule_Update(dt);

	if (!m_game_ui) return;
	//---------------------------------------------------------
	if (m_game_ui->m_pUITeamSelectWnd && m_game_ui->m_pUITeamSelectWnd->IsShown() && !CanCallTeamSelectMenu())
		StartStopMenu(m_game_ui->m_pUITeamSelectWnd,true);
	//---------------------------------------------------------
	
	switch (m_phase)
	{
	case GAME_PHASE_TEAM1_SCORES:
		{
			sprintf_s(msg, /*team %s wins*/ *st.translate("mp_team_wins"), CTeamInfo::GetTeam_name(1));
			m_game_ui->SetRoundResultCaption(msg);

			SetScore();
		}break;
	case GAME_PHASE_TEAM2_SCORES:
		{
			sprintf_s(msg, /*team %s wins*/ *st.translate("mp_team_wins"), CTeamInfo::GetTeam_name(2));
			m_game_ui->SetRoundResultCaption(msg);
			
			SetScore();
			
		}break;
	case GAME_PHASE_INPROGRESS:
		{
			if (local_player && !local_player->IsSkip())
			{			
				if (Level().CurrentEntity() && Level().CurrentEntity()->CLS_ID == CLSID_SPECTATOR)
				{
					if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
						!(pCurSkinMenu && pCurSkinMenu->IsShown()) &&
						!(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown()) &&
						(HUD().GetUI() && HUD().GetUI()->GameIndicatorsShown())
						)
					{
						if (!m_bTeamSelected)
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_team");
					};
				};
				SetScore();
			};
		}break;
	default:
		{
		}break;
	};

}
Exemple #5
0
void		game_cl_Deathmatch::ShowBuyMenu				()
{
	if (!local_player) return;
	if (!pCurBuyMenu || pCurBuyMenu->IsShown()) return;
	StartStopMenu(pCurBuyMenu, true);
	if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
	{
		const preset_items& _p	= pCurBuyMenu->GetPreset(_preset_idx_last);	
		if (_p.size() != 0) pCurBuyMenu->TryUsePreset(_preset_idx_last);
	}
};
Exemple #6
0
void game_cl_Deathmatch::OnSkinMenu_Cancel		()
{
	if (!m_bSkinSelected && !m_bSpectatorSelected)
	{
		if (CanCallSkinMenu() && !pCurSkinMenu->IsShown())
		{
			StartStopMenu(pCurSkinMenu, true);
			return;
		}
	}
	m_bMenuCalledFromReady = FALSE;
};
Exemple #7
0
void game_cl_Deathmatch::OnGameMenuRespond_ChangeSkin(NET_Packet& P)
{
	s8 NewSkin						= P.r_s8();
	local_player->skin				= NewSkin;
	
	if (pCurSkinMenu && pCurSkinMenu->IsShown())
		StartStopMenu				(pCurSkinMenu, true);

	if (m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown())
		StartStopMenu				(m_game_ui->m_pMapDesc, TRUE);
	

	SetCurrentSkinMenu				();
	if (pCurSkinMenu)				pCurSkinMenu->SetCurSkin(local_player->skin);
	SetCurrentBuyMenu				();
	if (pCurBuyMenu)				pCurBuyMenu->SetSkin(local_player->skin);	
	m_bSpectatorSelected			= FALSE;
	
	if (m_bMenuCalledFromReady)
	{
		OnKeyboardPress				(kJUMP);
	}
};
void				game_cl_TeamDeathmatch::OnGameMenuRespond_ChangeTeam	(NET_Packet& P)
{
	s16 OldTeam = local_player->team;
	local_player->team = u8(P.r_s16() & 0x00ff);
	if (OldTeam != local_player->team)
		OnTeamChanged();

	SetCurrentSkinMenu();
	if (pCurSkinMenu)
	{
		pCurSkinMenu->SetCurSkin(local_player->skin);
		if (CanCallSkinMenu())
			StartStopMenu(pCurSkinMenu, true);
	}
};
bool game_cl_TeamDeathmatch::CanBeReady				()
{
	if (!local_player) return false;
	
	m_bMenuCalledFromReady = TRUE;

	if (!m_bTeamSelected)
	{
		m_bMenuCalledFromReady = FALSE;
		if (CanCallTeamSelectMenu())
			StartStopMenu(m_game_ui->m_pUITeamSelectWnd,true);
		return false;
	}

	return inherited::CanBeReady();
};
bool	game_cl_TeamDeathmatch::OnKeyboardPress			(int key)
{
	if (kTEAM == key )
	{
		if (m_game_ui)
		{
			if (CanCallTeamSelectMenu())
			{
				StartStopMenu(m_game_ui->m_pUITeamSelectWnd,true);
			};

			return true;
		}
	};
	
	return inherited::OnKeyboardPress(key);
}
Exemple #11
0
bool game_cl_Deathmatch::CanBeReady				()
{
	if (!local_player) return false;

	m_bMenuCalledFromReady = TRUE;

	SetCurrentSkinMenu();

	SetCurrentBuyMenu();
	
	if (pCurBuyMenu && !pCurBuyMenu->IsShown())
	{
		pCurBuyMenu->ResetItems();
		SetBuyMenuItems		(&PlayerDefItems);
	}
	
	if (!m_bSkinSelected)
	{
		m_bMenuCalledFromReady = FALSE;
		if (CanCallSkinMenu())
			StartStopMenu(pCurSkinMenu,true);
		return false;
	};

	if (pCurBuyMenu)
	{		
		const preset_items& _p	= pCurBuyMenu->GetPreset(_preset_idx_last);
		bool Passed = false;
		Passed = (_p.size()==0) ? 1 : (s32(pCurBuyMenu->GetPresetCost(_preset_idx_last)) <= local_player->money_for_round);
		Passed |= pCurBuyMenu->IsIgnoreMoneyAndRank();
		if (!Passed)
		{
			if (CanCallBuyMenu())
			{
				ShowBuyMenu();
			}
			return false;
		}
		m_bMenuCalledFromReady = FALSE;
		OnBuyMenu_Ok();
		return true;
	};
	//m_bMenuCalledFromReady = FALSE;
	return true;
};
void game_cl_TeamDeathmatch::SetCurrentSkinMenu	()
{
	s16 new_team;
	if (!local_player) return;
	if (local_player->team == 1){
		new_team		= 1;
	}else 
	{
		new_team		= 2;
	}
	if (pCurSkinMenu && pCurSkinMenu->GetTeam() == new_team)
		return;

	if (pCurSkinMenu && new_team != pCurSkinMenu->GetTeam())
		if (pCurSkinMenu->IsShown()) StartStopMenu(pCurSkinMenu,true);

	xr_delete		(pCurSkinMenu);
	pCurSkinMenu	= InitSkinMenu(new_team);
};
void game_cl_TeamDeathmatch::OnSkinMenuBack			()
{
	if (CanCallTeamSelectMenu())
		StartStopMenu(m_game_ui->m_pUITeamSelectWnd, true);
};
Exemple #14
0
void game_cl_Deathmatch::OnSkinMenuBack			()
{
	StartStopMenu(m_game_ui->m_pMapDesc, true);
};
Exemple #15
0
void game_cl_Deathmatch::OnMapInfoAccept			()
{
	if (CanCallSkinMenu())
		StartStopMenu(pCurSkinMenu, true);
};
Exemple #16
0
void		game_cl_Deathmatch::HideBuyMenu				()
{
	if (!pCurBuyMenu || !pCurBuyMenu->IsShown()) return;
	StartStopMenu(pCurBuyMenu, true);
}
Exemple #17
0
void game_cl_Deathmatch::shedule_Update			(u32 dt)
{
	CStringTable st;

	inherited::shedule_Update(dt);

	if(g_dedicated_server)	return;

	//fake	
	if(!m_game_ui && HUD().GetUI() ) m_game_ui = smart_cast<CUIGameDM*>( HUD().GetUI()->UIGame() );
	if(m_game_ui)
	{
		m_game_ui->SetTimeMsgCaption("");
		m_game_ui->SetRoundResultCaption("");
		m_game_ui->SetSpectatorMsgCaption("");
		m_game_ui->SetPressJumpMsgCaption("");
		m_game_ui->SetPressBuyMsgCaption("");
		m_game_ui->SetForceRespawnTimeCaption("");
		m_game_ui->SetWarmUpCaption("");
	};
	if ((Level().IsDemoPlayStarted() || Level().IsDemoPlayFinished()) && m_game_ui)
	{
		LPCSTR		demo_play_string = NULL;
		string32	tmp_buf1;
		string32	tmp_buf2;
		//st.translate("demo play active : ").c_str() (need to translate ?)
		STRCONCAT(demo_play_string, "demo play active : ",
			itoa( int(Level().GetDemoPlayPos() * 100), tmp_buf1, 10),
			"%%, play speed: ",
			itoa( int(Level().GetDemoPlaySpeed()), tmp_buf2, 10),
			"x");
		m_game_ui->SetDemoPlayCaption(demo_play_string);
	}

//	if (HUD().GetUI() && HUD().GetUI()->UIMainIngameWnd)
//		HUD().GetUI()->UIMainIngameWnd->ZoneCounter().SetText("");

	switch (Phase())
	{
	case GAME_PHASE_INPROGRESS:
		{
			//m_game_ui->ShowPlayersList(false);

			Check_Invincible_Players();

			if (m_s32TimeLimit && m_cl_dwWarmUp_Time == 0)
			{
				if (Level().timeServer()<(m_start_time + m_s32TimeLimit))
				{
					u32 lts = Level().timeServer();
					u32 Rest = (m_start_time + m_s32TimeLimit) - lts;
					string64 S;
					ConvertTime2String(&S, Rest);
					if(m_game_ui)
						m_game_ui->SetTimeMsgCaption(S);
				}
				else
				{
					if(m_game_ui)
						m_game_ui->SetTimeMsgCaption("00:00:00");
				}
			};
			game_PlayerState* lookat_player = Game().lookat_player();
			if(local_player && !local_player->IsSkip())
			{
				if (m_bFirstRun)
				{
					m_bFirstRun = FALSE;
					if (m_game_ui->m_pMapDesc && !Level().IsDemoPlayStarted())
						StartStopMenu(m_game_ui->m_pMapDesc, TRUE);
					GetActiveVoting();
				};

				if (m_game_ui && lookat_player)
				{
					string256 MoneyStr;
					sprintf_s(MoneyStr, "%d", lookat_player->money_for_round);
					m_game_ui->ChangeTotalMoneyIndicator(MoneyStr);
				}				

				m_game_ui->SetPressJumpMsgCaption("");
				m_game_ui->SetPressBuyMsgCaption("");				

				if (m_cl_dwWarmUp_Time > Level().timeServer())
				{
					u32 TimeRemains = m_cl_dwWarmUp_Time - Level().timeServer();
					string64 S;
					ConvertTime2String(&S, TimeRemains);
					string1024 tmpStr = "";
					if (TimeRemains > 10000)
						strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_time2start"), " ", S);
					else
					{
						if (TimeRemains < 1000)
							strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_go"), "");
						else
						{
							static u32 dwLastTimeRemains = 10;
							u32 dwCurTimeRemains = TimeRemains/1000;
							if (dwLastTimeRemains != dwCurTimeRemains)
							{
								if (dwCurTimeRemains > 0 && dwCurTimeRemains <= 5)
									PlaySndMessage(ID_COUNTDOWN_1 + dwCurTimeRemains - 1);
							}
							dwLastTimeRemains = dwCurTimeRemains;
							_itoa(dwCurTimeRemains, S, 10);								
							strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_ready"), "...", S);
						}
					};
					
					m_game_ui->SetWarmUpCaption(tmpStr);
				}

				if (Level().CurrentEntity() && smart_cast<CSpectator*>(Level().CurrentEntity()))
				{
					if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
						!(pCurSkinMenu && pCurSkinMenu->IsShown()) &&
						!(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown()) &&
						(HUD().GetUI() && HUD().GetUI()->GameIndicatorsShown())
						)
					{
						if (!m_bSkinSelected)
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin");
						else
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2start");

						if (CanCallBuyMenu())
							m_game_ui->SetPressBuyMsgCaption("mp_press_to_buy");						
					};
				};

				if (Level().CurrentControlEntity() && 
					smart_cast<CSpectator*>(Level().CurrentControlEntity()) &&
					(HUD().GetUI() && HUD().GetUI()->GameIndicatorsShown())
					)
				{
					
					CSpectator* pSpectator = smart_cast<CSpectator*>(Level().CurrentControlEntity());
					if (pSpectator)
					{
						string1024 SpectatorStr = "";
						pSpectator->GetSpectatorString(SpectatorStr);
						m_game_ui->SetSpectatorMsgCaption(SpectatorStr);
					}
				}

				u32 CurTime = Level().timeServer();
				if (IsVotingEnabled() && IsVotingActive() && m_dwVoteEndTime>=CurTime)
				{
					u32 TimeLeft = m_dwVoteEndTime - Level().timeServer();
					string1024 VoteTimeResStr;
					u32 SecsLeft = (TimeLeft % 60000) / 1000;
					u32 MinitsLeft = (TimeLeft - SecsLeft) / 60000;

					u32 NumAgreed = 0;
					PLAYERS_MAP_IT I;
					I	= players.begin();
					for(;I!=players.end(); ++I)
					{
						game_PlayerState* ps = I->second;
						if (ps->m_bCurrentVoteAgreed == 1) NumAgreed++;
					}
					
					sprintf_s	(VoteTimeResStr, st.translate("mp_timeleft").c_str(), MinitsLeft, SecsLeft, float(NumAgreed)/players.size());
					if (m_game_ui)
						m_game_ui->SetVoteTimeResultMsg(VoteTimeResStr);
				};

				if (	local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD) && 
						m_u32ForceRespawn &&
						!local_player->testFlag(GAME_PLAYER_FLAG_SPECTATOR)		)
				{
					if(m_game_ui)
					{
						u32 Rest			= m_u32ForceRespawn - local_player->DeathTime;
						string64			S;
						ConvertTime2String	(&S, Rest);
						string128			FullS;
						sprintf_s				(FullS, "%s : %s", *st.translate("mp_time2respawn"), S);

						m_game_ui->SetForceRespawnTimeCaption(FullS);
					};
				};


				if (Level().CurrentViewEntity() && m_game_ui)
				{
					game_PlayerState* ps = GetPlayerByGameID(Level().CurrentViewEntity()->ID());
					
					if (ps && m_game_ui) 
						m_game_ui->SetRank(ps->team, ps->rank);

					if (ps && m_game_ui) 
						m_game_ui->SetFraglimit(ps->frags(), m_s32FragLimit);
				}
			};
		}break;
	case GAME_PHASE_PENDING:
		{
			if (m_game_ui)
			{
				m_game_ui->UpdateTeamPanels();
				m_game_ui->ShowPlayersList(true);
			}
		}break;
	case GAME_PHASE_PLAYER_SCORES:
		{
			string128 resstring;
			sprintf_s(resstring, *st.translate("mp_player_wins"), WinnerName);
			m_game_ui->SetRoundResultCaption(resstring);

			SetScore();
			m_game_ui->UpdateTeamPanels();
			m_game_ui->ShowPlayersList(true);
		}break;
	};
	
	//-----------------------------------------
	if (!CanCallBuyMenu()) HideBuyMenu();
		
	if (pCurSkinMenu && pCurSkinMenu->IsShown() && !CanCallSkinMenu())
		StartStopMenu(pCurSkinMenu, true);
	//-----------------------------------------------
	
	//-----------------------------------------------
	//if (m_game_ui->m_pInventoryMenu && m_game_ui->m_pInventoryMenu->IsShown() && !CanCallInventoryMenu())
	//	StartStopMenu(m_game_ui->m_pInventoryMenu,true);
	if ( m_game_ui && m_game_ui->ActorMenu().IsShown() && !CanCallInventoryMenu() )
	{
		m_game_ui->HideActorMenu();
	}
		
	//-----------------------------------------

	u32 cur_game_state = Phase();
	if(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS)
	{
		m_game_ui->m_pMapDesc->GetHolder()->StartStopMenu(m_game_ui->m_pMapDesc, true);
	}

	if(pCurSkinMenu && pCurSkinMenu->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS)
	{
		pCurSkinMenu->GetHolder()->StartStopMenu(pCurSkinMenu, true);
	}
}
Exemple #18
0
bool	game_cl_Deathmatch::OnKeyboardPress			(int key)
{
	if (Level().IsDemoPlay() && (key != kSCORES))
		return false;
	if (kSCORES == key && Phase() == GAME_PHASE_INPROGRESS)
	{
		if(m_game_ui)
#ifdef DEBUG
			if (Level().IR_GetKeyState(DIK_LCONTROL))
				m_game_ui->ShowStatistic(true);
			else
#endif //#ifdef DEBUG
				m_game_ui->ShowFragList(true);
		return true;
	};

	if (kINVENTORY == key )
	{
		if (Level().CurrentControlEntity() && smart_cast<CActor*>(Level().CurrentControlEntity()))
		{
			if (m_game_ui)
			{
				if ( m_game_ui->ActorMenu().IsShown() )
				{
					m_game_ui->HideActorMenu();
				}
				else
				{
					if (CanCallInventoryMenu())
					{
						m_game_ui->ShowActorMenu();
					}
				}
				return true;
			}
		}
	}

	if (kBUY == key )
	{
		if (pCurBuyMenu && pCurBuyMenu->IsShown())
			HideBuyMenu();
		else
		{		
			if(CanCallBuyMenu())
			{
				SetCurrentBuyMenu	();
				
				if (!pCurBuyMenu)
					return true;
				
				pCurBuyMenu->ResetItems();

				if (!pCurBuyMenu->IsShown())
					SetBuyMenuItems		(&PlayerDefItems);				

//				LoadDefItemsForRank(pCurBuyMenu);
				ShowBuyMenu();
			}
		};

		return true;
	};
	
	if (kSKIN == key )
	{
		if (pCurSkinMenu && pCurSkinMenu->IsShown())
			StartStopMenu(pCurSkinMenu,true);
		else
		{
			if (CanCallSkinMenu())
			{
				SetCurrentSkinMenu();
				StartStopMenu(pCurSkinMenu,true);
			}
		}
		return true;
	};

/*
	if( kMAP == key)
	{
		if (m_game_ui)
		{
			if (m_game_ui->m_pPdaMenu && m_game_ui->m_pPdaMenu->IsShown())
				StartStopMenu(m_game_ui->m_pPdaMenu,true);
			else
			{
				m_game_ui->m_pPdaMenu->SetActiveSubdialog(eptMap);
				StartStopMenu(m_game_ui->m_pPdaMenu,true);
			};		
			return true;
		}
	};
*/
	return inherited::OnKeyboardPress(key);
}
void game_cl_TeamDeathmatch::OnMapInfoAccept			()
{
	if (CanCallTeamSelectMenu())
		StartStopMenu(m_game_ui->m_pUITeamSelectWnd, true);
};