mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Make all LR_* and ACTION_* enum values available to Lua
This commit is contained in:
parent
fc920b3040
commit
67149a5b35
5 changed files with 225 additions and 36 deletions
|
@ -32,6 +32,7 @@ SET(AQUARIA_SRCS
|
||||||
FlockEntity.h
|
FlockEntity.h
|
||||||
Game.cpp
|
Game.cpp
|
||||||
Game.h
|
Game.h
|
||||||
|
GameEnums.cpp
|
||||||
GameEnums.h
|
GameEnums.h
|
||||||
GameplayVariables.cpp
|
GameplayVariables.cpp
|
||||||
GameStructs.cpp
|
GameStructs.cpp
|
||||||
|
@ -60,7 +61,6 @@ SET(AQUARIA_SRCS
|
||||||
ModSelector.h
|
ModSelector.h
|
||||||
Network.cpp
|
Network.cpp
|
||||||
Network.h
|
Network.h
|
||||||
NotEntities.h
|
|
||||||
ParticleEditor.cpp
|
ParticleEditor.cpp
|
||||||
Path.cpp
|
Path.cpp
|
||||||
Path.h
|
Path.h
|
||||||
|
|
189
Aquaria/GameEnums.cpp
Normal file
189
Aquaria/GameEnums.cpp
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
#include "GameEnums.h"
|
||||||
|
#include "Base.h"
|
||||||
|
|
||||||
|
// keep in sync with enum Layers
|
||||||
|
static const char *s_LayerNames[LR_MAX] =
|
||||||
|
{
|
||||||
|
"LR_ZERO",
|
||||||
|
"LR_BACKDROP",
|
||||||
|
"LR_BACKGROUND",
|
||||||
|
"LR_SCENEBACKGROUNDIMAGE",
|
||||||
|
"LR_BACKDROP_ELEMENTS1",
|
||||||
|
"LR_BACKDROP_ELEMENTS2",
|
||||||
|
"LR_ENTITIES_MINUS4_PLACEHOLDER",
|
||||||
|
"LR_BACKDROP_ELEMENTS3",
|
||||||
|
"LR_BACKDROP_ELEMENTS4",
|
||||||
|
"LR_BACKDROP_ELEMENTS5",
|
||||||
|
"LR_BACKDROP_ELEMENTS6",
|
||||||
|
"LR_BACKGROUND_ELEMENTS1",
|
||||||
|
"LR_BACKGROUND_ELEMENTS2",
|
||||||
|
"LR_ENTITIES_MINUS3_PLACEHOLDER",
|
||||||
|
"LR_BACKGROUND_ELEMENTS3",
|
||||||
|
"LR_ENTITIES_MINUS2_PLACEHOLDER",
|
||||||
|
"LR_BLACKGROUND",
|
||||||
|
"LR_UPDATE_ELEMENTS_BG",
|
||||||
|
"LR_ELEMENTS1",
|
||||||
|
"LR_ELEMENTS2",
|
||||||
|
"LR_ELEMENTS3",
|
||||||
|
"LR_ELEMENTS4",
|
||||||
|
"LR_ELEMENTS5",
|
||||||
|
"LR_ELEMENTS6",
|
||||||
|
"LR_ELEMENTS7",
|
||||||
|
"LR_ELEMENTS8",
|
||||||
|
"LR_ELEMENTS9",
|
||||||
|
"LR_ELEMENTS10",
|
||||||
|
"LR_ELEMENTS11",
|
||||||
|
"LR_ELEMENTS12",
|
||||||
|
"LR_ELEMENTS13",
|
||||||
|
"LR_ELEMENTS14",
|
||||||
|
"LR_ELEMENTS15",
|
||||||
|
"LR_ELEMENTS16",
|
||||||
|
"LR_UPDATE_ELEMENTS_FG",
|
||||||
|
"LR_ENTITIES_MINUS4",
|
||||||
|
"LR_ENTITIES_MINUS3",
|
||||||
|
"LR_ENTITIES_MINUS2",
|
||||||
|
"LR_ENTITIES00",
|
||||||
|
"LR_ENTITIES0",
|
||||||
|
"LR_ENTITIES",
|
||||||
|
"LR_ENTITIES2",
|
||||||
|
"LR_WATERSURFACE",
|
||||||
|
"LR_WATERSURFACE2",
|
||||||
|
"LR_DARK_LAYER",
|
||||||
|
"LR_PROJECTILES",
|
||||||
|
"LR_LIGHTING",
|
||||||
|
"LR_PARTICLES",
|
||||||
|
"LR_PARTICLES2",
|
||||||
|
"LR_FOREGROUND_ELEMENTS1",
|
||||||
|
"LR_FOREGROUND_ELEMENTS2",
|
||||||
|
"LR_PARTICLES_TOP",
|
||||||
|
"LR_AFTER_EFFECTS",
|
||||||
|
"LR_SCENE_COLOR",
|
||||||
|
"LR_MENU",
|
||||||
|
"LR_MENU2",
|
||||||
|
"LR_HUD",
|
||||||
|
"LR_HUD2",
|
||||||
|
"LR_HUD3",
|
||||||
|
"LR_HUDUNDERLAY",
|
||||||
|
"LR_MINIMAP",
|
||||||
|
"LR_RECIPES",
|
||||||
|
"LR_WORLDMAP",
|
||||||
|
"LR_WORLDMAPHUD",
|
||||||
|
"LR_REGISTER_TEXT",
|
||||||
|
"LR_DAMAGESPRITE",
|
||||||
|
"LR_HELP",
|
||||||
|
"LR_TRANSITION",
|
||||||
|
"LR_OVERLAY",
|
||||||
|
"LR_FILEMENU",
|
||||||
|
"LR_CONFIRM",
|
||||||
|
"LR_CURSOR",
|
||||||
|
"LR_SUBTITLES",
|
||||||
|
"LR_PROGRESS",
|
||||||
|
"LR_DEBUG_TEXT",
|
||||||
|
"LR_BLACKBARS"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *EnumName(Layers lr)
|
||||||
|
{
|
||||||
|
compile_assert(Countof(s_LayerNames) == LR_MAX);
|
||||||
|
|
||||||
|
return lr < LR_MAX ? s_LayerNames[lr] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *s_AquariaActionNames_0[ACTION_MAX] =
|
||||||
|
{
|
||||||
|
"ACTION_PRIMARY",
|
||||||
|
"ACTION_SECONDARY",
|
||||||
|
"ACTION_ESC",
|
||||||
|
"ACTION_TOGGLESCENEEDITO",
|
||||||
|
"ACTION_TOGGLEWORLDMAP",
|
||||||
|
"ACTION_TOGGLEGRID",
|
||||||
|
"ACTION_MENULEFT",
|
||||||
|
"ACTION_MENURIGHT",
|
||||||
|
"ACTION_MENUUP",
|
||||||
|
"ACTION_MENUDOWN",
|
||||||
|
"ACTION_PREVPAGE",
|
||||||
|
"ACTION_NEXTPAGE",
|
||||||
|
"ACTION_COOKFOOD",
|
||||||
|
"ACTION_FOODLEFT",
|
||||||
|
"ACTION_FOODRIGHT",
|
||||||
|
"ACTION_FOODDROP",
|
||||||
|
"ACTION_TOGGLEMENU"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *s_AquariaActionNames_100[ACTION_MAX] =
|
||||||
|
{
|
||||||
|
"ACTION_SWIMUP",
|
||||||
|
"ACTION_SWIMDOWN",
|
||||||
|
"ACTION_SWIMLEFT",
|
||||||
|
"ACTION_SWIMRIGHT",
|
||||||
|
"ACTION_SINGUP",
|
||||||
|
"ACTION_SINGDOWN",
|
||||||
|
"ACTION_SINGLEFT",
|
||||||
|
"ACTION_SINGRIGHT",
|
||||||
|
"ACTION_SONGSLOT1",
|
||||||
|
"ACTION_SONGSLOT2",
|
||||||
|
"ACTION_SONGSLOT3",
|
||||||
|
"ACTION_SONGSLOT4",
|
||||||
|
"ACTION_SONGSLOT5",
|
||||||
|
"ACTION_SONGSLOT6",
|
||||||
|
"ACTION_SONGSLOT7",
|
||||||
|
"ACTION_SONGSLOT8",
|
||||||
|
"ACTION_SONGSLOT9",
|
||||||
|
"ACTION_SONGSLOT10",
|
||||||
|
"ACTION_SONGSLOTEND",
|
||||||
|
"ACTION_ROLL",
|
||||||
|
"ACTION_SLOW",
|
||||||
|
"ACTION_REVERT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *s_AquariaActionNames_200[ACTION_MAX] =
|
||||||
|
{
|
||||||
|
"ACTION_ZOOMIN",
|
||||||
|
"ACTION_ZOOMOUT",
|
||||||
|
"ACTION_CAMLEFT",
|
||||||
|
"ACTION_CAMRIGHT",
|
||||||
|
"ACTION_CAMUP",
|
||||||
|
"ACTION_CAMDOWN",
|
||||||
|
"ACTION_BONELEFT",
|
||||||
|
"ACTION_BONERIGHT",
|
||||||
|
"ACTION_BONEUP",
|
||||||
|
"ACTION_BONEDOWN",
|
||||||
|
"ACTION_BGLAYER1",
|
||||||
|
"ACTION_BGLAYER2",
|
||||||
|
"ACTION_BGLAYER3",
|
||||||
|
"ACTION_BGLAYER4",
|
||||||
|
"ACTION_BGLAYER5",
|
||||||
|
"ACTION_BGLAYER6",
|
||||||
|
"ACTION_BGLAYER7",
|
||||||
|
"ACTION_BGLAYER8",
|
||||||
|
"ACTION_BGLAYER9",
|
||||||
|
"ACTION_BGLAYER10",
|
||||||
|
"ACTION_BGLAYER11",
|
||||||
|
"ACTION_BGLAYER12",
|
||||||
|
"ACTION_BGLAYER13",
|
||||||
|
"ACTION_BGLAYER14",
|
||||||
|
"ACTION_BGLAYER15",
|
||||||
|
"ACTION_BGLAYER16",
|
||||||
|
"ACTION_BGLAYEREND",
|
||||||
|
"ACTION_MULTISELECT",
|
||||||
|
"ACTION_TOGGLEWORLDMAPEDITOR",
|
||||||
|
"ACTION_LOOK",
|
||||||
|
"ACTION_TOGGLEHELPSCREEN",
|
||||||
|
"ACTION_PLACE_AVATAR",
|
||||||
|
"ACTION_SCREENSHOT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *EnumName(AquariaActions a)
|
||||||
|
{
|
||||||
|
unsigned i = a;
|
||||||
|
if(i < Countof(s_AquariaActionNames_0))
|
||||||
|
return s_AquariaActionNames_0[i];
|
||||||
|
i -= 100; // no problem if this underflows
|
||||||
|
if(i < Countof(s_AquariaActionNames_100))
|
||||||
|
return s_AquariaActionNames_100[i];
|
||||||
|
i -= 100;
|
||||||
|
if(i < Countof(s_AquariaActionNames_200))
|
||||||
|
return s_AquariaActionNames_200[i];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -52,21 +52,21 @@ enum CursorType
|
||||||
CURSOR_LOOK = 4
|
CURSOR_LOOK = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AquariaActions
|
enum AquariaActions // Keep in sync with GameEnums.cpp
|
||||||
{
|
{
|
||||||
ACTION_PRIMARY =0,
|
ACTION_PRIMARY,
|
||||||
ACTION_SECONDARY =1,
|
ACTION_SECONDARY,
|
||||||
ACTION_ESC =2,
|
ACTION_ESC,
|
||||||
ACTION_TOGGLESCENEEDITOR =3,
|
ACTION_TOGGLESCENEEDITOR,
|
||||||
ACTION_TOGGLEWORLDMAP =4,
|
ACTION_TOGGLEWORLDMAP,
|
||||||
|
|
||||||
ACTION_TOGGLEGRID =5,
|
ACTION_TOGGLEGRID,
|
||||||
|
|
||||||
// Automatically sent on either ACTION_SWIM* or sufficient analog controller input
|
// Automatically sent on either ACTION_SWIM* or sufficient analog controller input
|
||||||
ACTION_MENULEFT =6,
|
ACTION_MENULEFT,
|
||||||
ACTION_MENURIGHT =7,
|
ACTION_MENURIGHT,
|
||||||
ACTION_MENUUP =8,
|
ACTION_MENUUP,
|
||||||
ACTION_MENUDOWN =9,
|
ACTION_MENUDOWN,
|
||||||
|
|
||||||
ACTION_PREVPAGE,
|
ACTION_PREVPAGE,
|
||||||
ACTION_NEXTPAGE,
|
ACTION_NEXTPAGE,
|
||||||
|
@ -78,7 +78,7 @@ enum AquariaActions
|
||||||
ACTION_TOGGLEMENU,
|
ACTION_TOGGLEMENU,
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
ACTION_SWIMUP = 100,
|
ACTION_SWIMUP = 100,
|
||||||
ACTION_SWIMDOWN,
|
ACTION_SWIMDOWN,
|
||||||
ACTION_SWIMLEFT,
|
ACTION_SWIMLEFT,
|
||||||
|
@ -106,6 +106,7 @@ enum AquariaActions
|
||||||
ACTION_SLOW, // currently unused
|
ACTION_SLOW, // currently unused
|
||||||
ACTION_REVERT,
|
ACTION_REVERT,
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
ACTION_ZOOMIN = 200,
|
ACTION_ZOOMIN = 200,
|
||||||
ACTION_ZOOMOUT,
|
ACTION_ZOOMOUT,
|
||||||
|
|
||||||
|
@ -144,8 +145,11 @@ enum AquariaActions
|
||||||
ACTION_LOOK ,
|
ACTION_LOOK ,
|
||||||
ACTION_TOGGLEHELPSCREEN,
|
ACTION_TOGGLEHELPSCREEN,
|
||||||
ACTION_PLACE_AVATAR,
|
ACTION_PLACE_AVATAR,
|
||||||
ACTION_SCREENSHOT
|
ACTION_SCREENSHOT,
|
||||||
|
|
||||||
|
ACTION_MAX
|
||||||
};
|
};
|
||||||
|
const char *EnumName(AquariaActions a);
|
||||||
|
|
||||||
enum AuraType
|
enum AuraType
|
||||||
{
|
{
|
||||||
|
@ -232,7 +236,7 @@ enum VisualEffectsType
|
||||||
VFX_MAX = 3
|
VFX_MAX = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Layers
|
enum Layers // keep in sync with GameEnums.cpp
|
||||||
{
|
{
|
||||||
// GAME WILL CLEAR THESE
|
// GAME WILL CLEAR THESE
|
||||||
LR_ZERO = 0,
|
LR_ZERO = 0,
|
||||||
|
@ -313,6 +317,7 @@ enum Layers
|
||||||
LR_BLACKBARS ,
|
LR_BLACKBARS ,
|
||||||
LR_MAX
|
LR_MAX
|
||||||
};
|
};
|
||||||
|
const char *EnumName(Layers lr);
|
||||||
|
|
||||||
|
|
||||||
enum IngredientType
|
enum IngredientType
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2007, 2010 - Bit-Blot
|
|
||||||
|
|
||||||
This file is part of Aquaria.
|
|
||||||
|
|
||||||
Aquaria is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
|
@ -11740,6 +11740,20 @@ static const struct {
|
||||||
luaConstant(PATHSHAPE_CIRCLE),
|
luaConstant(PATHSHAPE_CIRCLE),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static void luaRegisterEnums(lua_State *L, T first, T last)
|
||||||
|
{
|
||||||
|
assert(first <= last);
|
||||||
|
for(T i = first; i <= last; i = T(i + 1))
|
||||||
|
{
|
||||||
|
if(const char *name = EnumName(i))
|
||||||
|
{
|
||||||
|
lua_pushinteger(L, i);
|
||||||
|
lua_setglobal(L, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
// F U N C T I O N S
|
// F U N C T I O N S
|
||||||
//============================================================================================
|
//============================================================================================
|
||||||
|
@ -11828,6 +11842,8 @@ lua_State *ScriptInterface::createLuaVM()
|
||||||
lua_pushnumber(state, luaConstantTable[i].value);
|
lua_pushnumber(state, luaConstantTable[i].value);
|
||||||
lua_setglobal(state, luaConstantTable[i].name);
|
lua_setglobal(state, luaConstantTable[i].name);
|
||||||
}
|
}
|
||||||
|
luaRegisterEnums(state, LR_ZERO, LR_MAX);
|
||||||
|
luaRegisterEnums(state, ACTION_PRIMARY, ACTION_MAX);
|
||||||
|
|
||||||
// Add hooks to monitor global get/set operations if requested.
|
// Add hooks to monitor global get/set operations if requested.
|
||||||
if (complainOnGlobalVar)
|
if (complainOnGlobalVar)
|
||||||
|
|
Loading…
Reference in a new issue