mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
document CComponent
This commit is contained in:
parent
baab5ca998
commit
f6220ed18d
|
@ -18,6 +18,11 @@
|
||||||
|
|
||||||
class CGameClient;
|
class CGameClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is inherited by all the client components.
|
||||||
|
*
|
||||||
|
* These components can implement the virtual methods such as OnInit(), OnMessage(int Msg, void *pRawMsg) to provide their functionality.
|
||||||
|
*/
|
||||||
class CComponent
|
class CComponent
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -25,54 +30,178 @@ protected:
|
||||||
|
|
||||||
CGameClient *m_pClient;
|
CGameClient *m_pClient;
|
||||||
|
|
||||||
// perhaps propagte pointers for these as well
|
// perhaps propagate pointers for these as well
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the kernel interface.
|
||||||
|
*/
|
||||||
class IKernel *Kernel() const;
|
class IKernel *Kernel() const;
|
||||||
|
/**
|
||||||
|
* Get the graphics interface.
|
||||||
|
*/
|
||||||
class IGraphics *Graphics() const;
|
class IGraphics *Graphics() const;
|
||||||
|
/**
|
||||||
|
* Get the text rendering interface.
|
||||||
|
*/
|
||||||
class ITextRender *TextRender() const;
|
class ITextRender *TextRender() const;
|
||||||
|
/**
|
||||||
|
* Get the input interface.
|
||||||
|
*/
|
||||||
class IInput *Input() const;
|
class IInput *Input() const;
|
||||||
|
/**
|
||||||
|
* Get the storage interface.
|
||||||
|
*/
|
||||||
class IStorage *Storage() const;
|
class IStorage *Storage() const;
|
||||||
|
/**
|
||||||
|
* Get the ui interface.
|
||||||
|
*/
|
||||||
class CUI *UI() const;
|
class CUI *UI() const;
|
||||||
|
/**
|
||||||
|
* Get the sound interface.
|
||||||
|
*/
|
||||||
class ISound *Sound() const;
|
class ISound *Sound() const;
|
||||||
|
/**
|
||||||
|
* Get the render tools interface.
|
||||||
|
*/
|
||||||
class CRenderTools *RenderTools() const;
|
class CRenderTools *RenderTools() const;
|
||||||
|
/**
|
||||||
|
* Get the config interface.
|
||||||
|
*/
|
||||||
class CConfig *Config() const;
|
class CConfig *Config() const;
|
||||||
|
/**
|
||||||
|
* Get the console interface.
|
||||||
|
*/
|
||||||
class IConsole *Console() const;
|
class IConsole *Console() const;
|
||||||
|
/**
|
||||||
|
* Get the demo player interface.
|
||||||
|
*/
|
||||||
class IDemoPlayer *DemoPlayer() const;
|
class IDemoPlayer *DemoPlayer() const;
|
||||||
|
/**
|
||||||
|
* Get the demo recorder interface.
|
||||||
|
*
|
||||||
|
* @param Recorder A member of the RECORDER_x enum
|
||||||
|
* @see RECORDER_MANUAL
|
||||||
|
* @see RECORDER_AUTO
|
||||||
|
* @see RECORDER_RACE
|
||||||
|
* @see RECORDER_REPLAYS
|
||||||
|
*/
|
||||||
class IDemoRecorder *DemoRecorder(int Recorder) const;
|
class IDemoRecorder *DemoRecorder(int Recorder) const;
|
||||||
|
/**
|
||||||
|
* Get the server browser interface.
|
||||||
|
*/
|
||||||
class IServerBrowser *ServerBrowser() const;
|
class IServerBrowser *ServerBrowser() const;
|
||||||
|
/**
|
||||||
|
* Get the layers interface.
|
||||||
|
*/
|
||||||
class CLayers *Layers() const;
|
class CLayers *Layers() const;
|
||||||
|
/**
|
||||||
|
* Get the collision interface.
|
||||||
|
*/
|
||||||
class CCollision *Collision() const;
|
class CCollision *Collision() const;
|
||||||
#if defined(CONF_AUTOUPDATE)
|
#if defined(CONF_AUTOUPDATE)
|
||||||
|
/**
|
||||||
|
* Get the updater interface.
|
||||||
|
*/
|
||||||
class IUpdater *Updater() const;
|
class IUpdater *Updater() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONF_VIDEORECORDER)
|
#if defined(CONF_VIDEORECORDER)
|
||||||
|
/**
|
||||||
|
* Gets the current time.
|
||||||
|
* @see time_get()
|
||||||
|
*/
|
||||||
int64_t time() const
|
int64_t time() const
|
||||||
{
|
{
|
||||||
return IVideo::Current() ? IVideo::Time() : time_get();
|
return IVideo::Current() ? IVideo::Time() : time_get();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
/**
|
||||||
|
* Gets the current time.
|
||||||
|
* @see time_get()
|
||||||
|
*/
|
||||||
int64_t time() const
|
int64_t time() const
|
||||||
{
|
{
|
||||||
return time_get();
|
return time_get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* Gets the local time.
|
||||||
|
*/
|
||||||
float LocalTime() const;
|
float LocalTime() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* The component virtual destructor.
|
||||||
|
*/
|
||||||
virtual ~CComponent() {}
|
virtual ~CComponent() {}
|
||||||
|
/**
|
||||||
|
* Get a pointer to the game client.
|
||||||
|
*/
|
||||||
class CGameClient *GameClient() const { return m_pClient; }
|
class CGameClient *GameClient() const { return m_pClient; }
|
||||||
|
/**
|
||||||
|
* Get the client interface.
|
||||||
|
*/
|
||||||
class IClient *Client() const;
|
class IClient *Client() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the client changes state, e.g from offline to online.
|
||||||
|
* @see IClient::STATE_CONNECTING
|
||||||
|
* @see IClient::STATE_LOADING
|
||||||
|
* @see IClient::STATE_ONLINE
|
||||||
|
*/
|
||||||
virtual void OnStateChange(int NewState, int OldState){};
|
virtual void OnStateChange(int NewState, int OldState){};
|
||||||
|
/**
|
||||||
|
* Called to let the components register their console commands.
|
||||||
|
*/
|
||||||
virtual void OnConsoleInit(){};
|
virtual void OnConsoleInit(){};
|
||||||
|
/**
|
||||||
|
* Called to let the components run initialization code.
|
||||||
|
*/
|
||||||
virtual void OnInit(){};
|
virtual void OnInit(){};
|
||||||
|
/**
|
||||||
|
* Called to reset the component.
|
||||||
|
* This method is usually called on your component constructor to avoid code duplication.
|
||||||
|
* @see CHud::CHud()
|
||||||
|
* @see CHud::OnReset()
|
||||||
|
*/
|
||||||
virtual void OnReset(){};
|
virtual void OnReset(){};
|
||||||
|
/**
|
||||||
|
* Called when the window has been resized.
|
||||||
|
*/
|
||||||
virtual void OnWindowResize() {}
|
virtual void OnWindowResize() {}
|
||||||
|
/**
|
||||||
|
* Called when the component should get rendered.
|
||||||
|
*
|
||||||
|
* The render order depends on the component insertion order.
|
||||||
|
*/
|
||||||
virtual void OnRender(){};
|
virtual void OnRender(){};
|
||||||
|
/**
|
||||||
|
* Called when the input gets released, for example when a text box loses focus.
|
||||||
|
*/
|
||||||
virtual void OnRelease(){};
|
virtual void OnRelease(){};
|
||||||
|
/**
|
||||||
|
* Called on map load.
|
||||||
|
*/
|
||||||
virtual void OnMapLoad(){};
|
virtual void OnMapLoad(){};
|
||||||
|
/**
|
||||||
|
* Called when receiving a network message.
|
||||||
|
* @param Msg The message type.
|
||||||
|
* @param pRawMsg The message data.
|
||||||
|
* @see NETMSGTYPE_SV_DDRACETIME
|
||||||
|
* @see CNetMsg_Sv_DDRaceTime
|
||||||
|
*/
|
||||||
virtual void OnMessage(int Msg, void *pRawMsg) {}
|
virtual void OnMessage(int Msg, void *pRawMsg) {}
|
||||||
|
/**
|
||||||
|
* Called on mouse movement
|
||||||
|
*
|
||||||
|
* @param x The x coordinates of the mouse.
|
||||||
|
* @param y The y coordinates of the mouse.
|
||||||
|
*/
|
||||||
virtual bool OnMouseMove(float x, float y) { return false; }
|
virtual bool OnMouseMove(float x, float y) { return false; }
|
||||||
|
/**
|
||||||
|
* Called on a input event
|
||||||
|
* @param e The input event.
|
||||||
|
*/
|
||||||
virtual bool OnInput(IInput::CEvent e) { return false; }
|
virtual bool OnInput(IInput::CEvent e) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue