2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENT_H
|
|
|
|
#define GAME_CLIENT_COMPONENT_H
|
|
|
|
|
2016-08-30 23:39:59 +00:00
|
|
|
#if defined(CONF_VIDEORECORDER)
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <engine/shared/video.h>
|
2016-08-30 23:39:59 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "gameclient.h"
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <engine/input.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
class CComponent
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
friend class CGameClient;
|
|
|
|
|
|
|
|
CGameClient *m_pClient;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// perhaps propagte pointers for these as well
|
|
|
|
class IKernel *Kernel() const { return m_pClient->Kernel(); }
|
|
|
|
class IGraphics *Graphics() const { return m_pClient->Graphics(); }
|
|
|
|
class ITextRender *TextRender() const { return m_pClient->TextRender(); }
|
|
|
|
class IInput *Input() const { return m_pClient->Input(); }
|
|
|
|
class IStorage *Storage() const { return m_pClient->Storage(); }
|
|
|
|
class CUI *UI() const { return m_pClient->UI(); }
|
|
|
|
class ISound *Sound() const { return m_pClient->Sound(); }
|
|
|
|
class CRenderTools *RenderTools() const { return m_pClient->RenderTools(); }
|
|
|
|
class IConsole *Console() const { return m_pClient->Console(); }
|
|
|
|
class IDemoPlayer *DemoPlayer() const { return m_pClient->DemoPlayer(); }
|
2014-10-16 15:42:13 +00:00
|
|
|
class IDemoRecorder *DemoRecorder(int Recorder) const { return m_pClient->DemoRecorder(Recorder); }
|
2010-05-29 07:25:38 +00:00
|
|
|
class IServerBrowser *ServerBrowser() const { return m_pClient->ServerBrowser(); }
|
|
|
|
class CLayers *Layers() const { return m_pClient->Layers(); }
|
|
|
|
class CCollision *Collision() const { return m_pClient->Collision(); }
|
2020-07-09 22:01:00 +00:00
|
|
|
#if defined(CONF_AUTOUPDATE)
|
2020-09-26 19:41:58 +00:00
|
|
|
class IUpdater *Updater() const
|
|
|
|
{
|
|
|
|
return m_pClient->Updater();
|
|
|
|
}
|
2020-07-09 22:01:00 +00:00
|
|
|
#endif
|
2016-08-30 23:39:59 +00:00
|
|
|
|
|
|
|
#if defined(CONF_VIDEORECORDER)
|
2020-09-26 19:41:58 +00:00
|
|
|
int64 time() const
|
|
|
|
{
|
|
|
|
return IVideo::Current() ? IVideo::Time() : time_get();
|
|
|
|
}
|
2017-10-26 20:31:02 +00:00
|
|
|
float LocalTime() const { return IVideo::Current() ? IVideo::LocalTime() : Client()->LocalTime(); }
|
2016-08-30 23:39:59 +00:00
|
|
|
#else
|
2020-09-26 19:41:58 +00:00
|
|
|
int64 time() const
|
|
|
|
{
|
|
|
|
return time_get();
|
|
|
|
}
|
2017-10-26 20:31:02 +00:00
|
|
|
float LocalTime() const { return Client()->LocalTime(); }
|
2016-08-30 23:39:59 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
virtual ~CComponent() {}
|
2014-09-06 23:53:20 +00:00
|
|
|
class CGameClient *GameClient() const { return m_pClient; }
|
2014-08-26 20:06:35 +00:00
|
|
|
class IClient *Client() const { return m_pClient->Client(); }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
virtual void OnStateChange(int NewState, int OldState){};
|
|
|
|
virtual void OnConsoleInit(){};
|
|
|
|
virtual void OnInit(){};
|
|
|
|
virtual void OnReset(){};
|
2018-03-21 14:53:29 +00:00
|
|
|
virtual void OnWindowResize() {}
|
2020-09-26 19:41:58 +00:00
|
|
|
virtual void OnRender(){};
|
|
|
|
virtual void OnRelease(){};
|
|
|
|
virtual void OnMapLoad(){};
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnMessage(int Msg, void *pRawMsg) {}
|
|
|
|
virtual bool OnMouseMove(float x, float y) { return false; }
|
|
|
|
virtual bool OnInput(IInput::CEvent e) { return false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|