gzdoom/src/events.h

86 lines
2.5 KiB
C
Raw Normal View History

2017-01-22 00:33:53 +00:00
#ifndef EVENTS_H
#define EVENTS_H
#include "dobject.h"
#include "serializer.h"
2017-01-22 00:33:53 +00:00
class DStaticEventHandler;
2017-01-22 05:04:35 +00:00
// register
bool E_RegisterHandler(DStaticEventHandler* handler);
2017-01-22 05:04:35 +00:00
// unregister
bool E_UnregisterHandler(DStaticEventHandler* handler);
// find
bool E_CheckHandler(DStaticEventHandler* handler);
// check type
bool E_IsStaticType(PClass* type);
// init static handlers
void E_InitStaticHandlers(bool map);
2017-01-22 05:04:35 +00:00
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
void E_MapLoaded();
// called when the map is about to unload (approximately same time as UNLOADING ACS scripts)
void E_MapUnloading();
// called on each render frame once.
void E_RenderFrame();
// serialization stuff
void E_SerializeEvents(FSerializer& arc);
2017-01-22 05:04:35 +00:00
class DStaticEventHandler : public DObject // make it a part of normal GC process
2017-01-22 00:33:53 +00:00
{
DECLARE_CLASS(DStaticEventHandler, DObject)
2017-01-22 00:33:53 +00:00
public:
DStaticEventHandler* prev;
DStaticEventHandler* next;
DStaticEventHandler* unregPrev;
DStaticEventHandler* unregNext;
bool isMapScope; // this is only used with IsStatic=true
virtual bool IsStatic() { return true; }
2017-01-22 00:33:53 +00:00
// destroy handler. this unlinks EventHandler from the list automatically.
void OnDestroy() override;
// this checks if we are /actually/ static, using DObject dynamic typing system.
static bool IsActuallyStatic(PClass* type);
2017-01-22 00:33:53 +00:00
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
virtual void MapLoaded();
// called when the map is about to unload (approximately same time as UNLOADING ACS scripts)
virtual void MapUnloading();
// called on each render frame once.
virtual void RenderFrame();
};
class DEventHandler : public DStaticEventHandler
{
DECLARE_CLASS(DEventHandler, DStaticEventHandler) // TODO: make sure this does not horribly break anything
public:
bool IsStatic() override { return false; }
};
extern DStaticEventHandler* E_FirstEventHandler;
2017-01-22 00:33:53 +00:00
class DStaticRenderEventHandler : public DStaticEventHandler
2017-01-22 00:33:53 +00:00
{
DECLARE_CLASS(DStaticRenderEventHandler, DStaticEventHandler)
2017-01-22 00:33:53 +00:00
public:
2017-01-22 05:04:35 +00:00
// these are for all render events
2017-01-22 00:33:53 +00:00
DVector3 ViewPos;
DAngle ViewAngle;
DAngle ViewPitch;
DAngle ViewRoll;
double FracTic; // 0..1 value that describes where we are inside the current gametic, render-wise.
2017-01-22 05:04:35 +00:00
AActor* Camera;
2017-01-22 00:33:53 +00:00
void RenderFrame() override;
private:
void Setup();
};
class DRenderEventHandler : public DStaticRenderEventHandler
{
DECLARE_CLASS(DRenderEventHandler, DStaticRenderEventHandler) // TODO: make sure this does not horribly break anythings
public:
bool IsStatic() override { return false; }
};
2017-01-22 00:33:53 +00:00
#endif