This was SVN commit r2159.
This commit is contained in:
parent
eb6f978ba1
commit
899cf87b41
33
source/scripting/EventTypes.h
Normal file
33
source/scripting/EventTypes.h
Normal file
@ -0,0 +1,33 @@
|
||||
// EventTypes.h
|
||||
// Script event declarations
|
||||
|
||||
enum EEventType
|
||||
{
|
||||
// Entity events
|
||||
EVENT_INITIALIZE = 0,
|
||||
EVENT_TICK,
|
||||
EVENT_ATTACK,
|
||||
EVENT_GATHER,
|
||||
EVENT_DAMAGE,
|
||||
EVENT_TARGET_CHANGED,
|
||||
EVENT_PREPARE_ORDER,
|
||||
EVENT_ORDER_TRANSITION,
|
||||
EVENT_LAST,
|
||||
// General events
|
||||
EVENT_GAME_START = 0,
|
||||
EVENT_GAME_TICK,
|
||||
EVENT_SELECTION_CHANGED,
|
||||
};
|
||||
|
||||
// Only used for entity events...
|
||||
static const wchar_t* EventNames[] =
|
||||
{
|
||||
/* EVENT_INITIALIZE */ L"onInitialize",
|
||||
/* EVENT_TICK */ L"onTick",
|
||||
/* EVENT_ATTACK */ L"onAttack", /* This unit is the one doing the attacking... */
|
||||
/* EVENT_GATHER */ L"onGather", /* This unit is the one doing the gathering... */
|
||||
/* EVENT_DAMAGE */ L"onTakesDamage",
|
||||
/* EVENT_TARGET_CHANGED */ L"onTargetChanged", /* If this unit is selected and the mouseover object changes */
|
||||
/* EVENT_PREPARE_ORDER */ L"onPrepareOrder", /* To check if a unit can execute a given order */
|
||||
/* EVENT_ORDER_TRANSITION */ L"onOrderTransition" /* When we change orders (sometimes...) */
|
||||
};
|
37
source/scripting/GameEvents.h
Normal file
37
source/scripting/GameEvents.h
Normal file
@ -0,0 +1,37 @@
|
||||
// GameEvents.h
|
||||
|
||||
// A class that exists to let scripts know when important things happen
|
||||
// in the game.
|
||||
|
||||
#ifndef GAME_EVENTS_INCLUDED
|
||||
#define GAME_EVENTS_INCLUDED
|
||||
|
||||
#include "DOMEvent.h"
|
||||
|
||||
class CGameEvents : public IEventTarget, public Singleton<CGameEvents>
|
||||
{
|
||||
// Game events don't really run on an object
|
||||
JSObject* GetScriptExecContext( IEventTarget* target ) { return( g_ScriptingHost.GetGlobalObject() ); }
|
||||
|
||||
// Some events
|
||||
class CEventSelectionChanged : public CScriptEvent
|
||||
{
|
||||
bool m_CausedByPlayer;
|
||||
public:
|
||||
CEventSelectionChanged( bool CausedByPlayer ) : CScriptEvent( L"selectionChanged", EVENT_SELECTION_CHANGED, false )
|
||||
{
|
||||
AddLocalProperty( L"byPlayer", &m_CausedByPlayer, true );
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
void FireSelectionChanged( bool CausedByPlayer )
|
||||
{
|
||||
CEventSelectionChanged evt( CausedByPlayer );
|
||||
DispatchEvent( &evt );
|
||||
}
|
||||
};
|
||||
|
||||
#define g_JSGameEvents CGameEvents::GetSingleton()
|
||||
|
||||
#endif
|
1036
source/scripting/ScriptableComplex.h
Normal file
1036
source/scripting/ScriptableComplex.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user