seperated ingame input handling from rendering (from TW master)

This commit is contained in:
def 2016-04-29 23:05:20 +02:00
parent abbf2f7e69
commit 11e3fd55db
4 changed files with 7 additions and 28 deletions

View file

@ -201,6 +201,7 @@ public:
virtual void OnEnterGame() = 0;
virtual void OnShutdown() = 0;
virtual void OnRender() = 0;
virtual void OnUpdate() = 0;
virtual void OnStateChange(int NewState, int OldState) = 0;
virtual void OnConnected() = 0;
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, bool IsDummy = 0) = 0;

View file

@ -2463,6 +2463,10 @@ void CClient::Update()
// update the server browser
m_ServerBrowser.Update(m_ResortServerBrowser);
m_ResortServerBrowser = false;
// update gameclient
if(!m_EditorActive)
GameClient()->OnUpdate();
}
void CClient::VersionUpdate()
@ -2752,11 +2756,6 @@ void CClient::Run()
Input()->MouseModeRelative();
}
/*
if(!gfx_window_open())
break;
*/
// render
{
if(g_Config.m_ClEditor)

View file

@ -366,7 +366,7 @@ void CGameClient::OnInit()
}
}
void CGameClient::DispatchInput()
void CGameClient::OnUpdate()
{
// handle mouse movement
float x = 0.0f, y = 0.0f;
@ -390,12 +390,9 @@ void CGameClient::DispatchInput()
for(int h = 0; h < m_Input.m_Num; h++)
{
if(m_Input.m_paComponents[h]->OnInput(e))
{
//dbg_msg("", "%d char=%d key=%d flags=%d", h, e.ch, e.key, e.flags);
break;
}
}
}
// clear all events for this frame
Input()->ClearEvents();
@ -559,27 +556,9 @@ static void Evolve(CNetObj_Character *pCharacter, int Tick)
void CGameClient::OnRender()
{
/*Graphics()->Clear(1,0,0);
menus->render_background();
return;*/
/*
Graphics()->Clear(1,0,0);
Graphics()->MapScreen(0,0,100,100);
Graphics()->QuadsBegin();
Graphics()->SetColor(1,1,1,1);
Graphics()->QuadsDraw(50, 50, 30, 30);
Graphics()->QuadsEnd();
return;*/
// update the local character and spectate position
UpdatePositions();
// dispatch all input to systems
DispatchInput();
// render all systems
for(int i = 0; i < m_All.m_Num; i++)
m_All.m_paComponents[i]->OnRender();

View file

@ -102,7 +102,6 @@ class CGameClient : public IGameClient
class CCollision m_Collision;
CUI m_UI;
void DispatchInput();
void ProcessEvents();
void UpdatePositions();
@ -292,6 +291,7 @@ public:
// hooks
virtual void OnConnected();
virtual void OnRender();
virtual void OnUpdate();
virtual void OnDummyDisconnect();
virtual void OnRelease();
virtual void OnInit();