mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-09 07:51:28 +00:00
Script interface improvements & extensions.
- Pointer typechecks are now enabled by default. - enabled all script warnings for non-FULL or DEMO builds by default - Added generic obj_* functions that operate on any type of RenderObject. These give quite low-level control about the renderer, and are quite dangerous too. Subsequently, many functions sharing the same code (*_setPosition, for example) could be removed, and simply call the generic functions after a type check. - Added interface function deathNotify(). The original logic of death notifiers was never used, so i thought i'd make use of it. This is useful in scripts to safely drop dangling pointers. - removed sendEntityMessage, entity_setCollideWithAvatar, entity_setTouchDamage, which were essentially no-ops. - Replaced all unnecessary luaReturnNum(0) and luaReturnInt(0), now it does only push a return value on the stack if the function is actually supposed to have a retun value. - Allow variadic calling of entity_msg(). Now any parameters can be passed to the function, and the target entity will receive all of them. Any values returned from the entity's msg() callback will be returned by entity_msg() to the original caller. This allows nice RPC-like entity communication. - fixed possible crash in debugLog, bone_update, entity_debugText - added an override function for loadfile() that is case-insensitive like dofile() - entity_createEntity returns the created entity now - spawnParticleEffect returns the associated RenderObject - Added some text rendering functions - Added beam_setFirer() - removed the underflow check in avatar_decrLeaches() I added earlier - added a panic function for Lua. - added the Lua debug library - fixed a stupid typo in ScriptObject::isType() that made the type checks a lot less accurate - misc stuff I forgot
This commit is contained in:
parent
f2d112b693
commit
7ff0caaed8
28 changed files with 1564 additions and 1674 deletions
18
BBGE/BaseText.h
Normal file
18
BBGE/BaseText.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef BASETEXT_H
|
||||
#define BASETEXT_H
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
|
||||
class BaseText : public RenderObject
|
||||
{
|
||||
public:
|
||||
BaseText() { addType(SCO_TEXT); }
|
||||
virtual ~BaseText() {}
|
||||
virtual void setText(const std::string& text) = 0;
|
||||
virtual void setWidth(int width) = 0;
|
||||
virtual void setFontSize(int sz) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -72,7 +72,7 @@ void BmpFont::load(const std::string &file, float scale, bool loadTexture)
|
|||
}
|
||||
|
||||
Texture *fontTextureTest = 0;
|
||||
BitmapText::BitmapText(BmpFont *bmpFont) : RenderObject()
|
||||
BitmapText::BitmapText(BmpFont *bmpFont)
|
||||
{
|
||||
this->bmpFont = bmpFont;
|
||||
bfePass =0;
|
||||
|
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
//#include "DrawText.h"
|
||||
#include "RenderObject.h"
|
||||
#include "BaseText.h"
|
||||
|
||||
#include "../ExternalLibs/glfont2/glfont2.h"
|
||||
|
||||
|
@ -49,7 +50,7 @@ struct BmpFont
|
|||
Texture *overrideTexture;
|
||||
};
|
||||
|
||||
class BitmapText : public RenderObject
|
||||
class BitmapText : public BaseText
|
||||
{
|
||||
public:
|
||||
BitmapText(BmpFont *bmpFont);
|
||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
#include "DebugFont.h"
|
||||
|
||||
DebugFont::DebugFont(int initSz, const std::string &initText) : RenderObject()
|
||||
DebugFont::DebugFont(int initSz, const std::string &initText)
|
||||
{
|
||||
align = ALIGN_LEFT;
|
||||
followCamera = 1;
|
||||
|
|
|
@ -21,8 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
#include "BaseText.h"
|
||||
|
||||
class DebugFont : public RenderObject
|
||||
class DebugFont : public BaseText
|
||||
{
|
||||
public:
|
||||
DebugFont(int initFontSize=0, const std::string &initText="");
|
||||
|
|
|
@ -30,6 +30,7 @@ class Event
|
|||
{
|
||||
public:
|
||||
Event() { data = 0; }
|
||||
virtual ~Event() {}
|
||||
virtual void act()=0;
|
||||
void *data;
|
||||
};
|
||||
|
|
|
@ -290,6 +290,7 @@ void Quad::initQuad()
|
|||
|
||||
Quad::Quad() : RenderObject()
|
||||
{
|
||||
addType(SCO_QUAD);
|
||||
borderAlpha = 0.5;
|
||||
//debugLog("Quad::Quad()");
|
||||
initQuad();
|
||||
|
@ -889,7 +890,7 @@ void Quad::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
void Quad::setWidthHeight(int w, int h)
|
||||
void Quad::setWidthHeight(float w, float h)
|
||||
{
|
||||
if (h == -1)
|
||||
height = w;
|
||||
|
@ -898,12 +899,12 @@ void Quad::setWidthHeight(int w, int h)
|
|||
width = w;
|
||||
}
|
||||
|
||||
void Quad::setWidth(int w)
|
||||
void Quad::setWidth(float w)
|
||||
{
|
||||
width = w;
|
||||
}
|
||||
|
||||
void Quad::setHeight(int h)
|
||||
void Quad::setHeight(float h)
|
||||
{
|
||||
height = h;
|
||||
}
|
||||
|
@ -921,7 +922,6 @@ void Quad::onSetTexture()
|
|||
|
||||
PauseQuad::PauseQuad() : Quad(), pauseLevel(0)
|
||||
{
|
||||
addType(SCO_PAUSEQUAD);
|
||||
}
|
||||
|
||||
void PauseQuad::onUpdate(float dt)
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define __quad__
|
||||
|
||||
#include "RenderObject.h"
|
||||
#include "ScriptObject.h"
|
||||
|
||||
class QuadLight
|
||||
{
|
||||
|
@ -70,9 +69,9 @@ public:
|
|||
void spawnChildClone(float t);
|
||||
void burn();
|
||||
void unburn();
|
||||
void setWidthHeight(int w, int h=-1);
|
||||
void setWidth(int w);
|
||||
void setHeight(int h);
|
||||
void setWidthHeight(float w, float h=-1);
|
||||
void setWidth(float w);
|
||||
void setHeight(float h);
|
||||
int getWidth() const {return int(width);}
|
||||
int getHeight() const {return int(height);}
|
||||
|
||||
|
@ -150,7 +149,7 @@ private:
|
|||
void initQuad();
|
||||
};
|
||||
|
||||
class PauseQuad : public ScriptObject, public Quad
|
||||
class PauseQuad : public Quad
|
||||
{
|
||||
public:
|
||||
PauseQuad();
|
||||
|
|
|
@ -156,6 +156,7 @@ void RenderObject::clearColorMult()
|
|||
|
||||
RenderObject::RenderObject()
|
||||
{
|
||||
addType(SCO_RENDEROBJECT);
|
||||
useOldDT = false;
|
||||
|
||||
updateAfterParent = false;
|
||||
|
@ -1005,13 +1006,6 @@ void RenderObject::renderCollision()
|
|||
}
|
||||
|
||||
void RenderObject::addDeathNotify(RenderObject *r)
|
||||
{
|
||||
deathNotifications.remove(r);
|
||||
deathNotifications.push_back(r);
|
||||
r->addDeathNotifyInternal(this);
|
||||
}
|
||||
|
||||
void RenderObject::addDeathNotifyInternal(RenderObject *r)
|
||||
{
|
||||
deathNotifications.remove(r);
|
||||
deathNotifications.push_back(r);
|
||||
|
@ -1387,7 +1381,7 @@ void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParen
|
|||
if (r->parent)
|
||||
{
|
||||
errorLog("Engine does not support multiple parents");
|
||||
exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (order == CHILD_BACK)
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "Base.h"
|
||||
#include "Texture.h"
|
||||
#include "Flags.h"
|
||||
#include "ScriptObject.h"
|
||||
|
||||
class Core;
|
||||
class StateData;
|
||||
|
@ -72,7 +73,7 @@ typedef std::vector<RectShape> CollideRects;
|
|||
|
||||
class RenderObjectLayer;
|
||||
|
||||
class RenderObject
|
||||
class RenderObject : public ScriptObject
|
||||
{
|
||||
public:
|
||||
friend class Core;
|
||||
|
@ -315,7 +316,6 @@ protected:
|
|||
virtual void deathNotify(RenderObject *r);
|
||||
virtual void onEndOfLife() {}
|
||||
|
||||
void addDeathNotifyInternal(RenderObject *r);
|
||||
// spread parentManagedStatic flag to the entire child tree
|
||||
void propogateParentManagedStatic();
|
||||
void propogateAlpha();
|
||||
|
|
|
@ -25,16 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static const char *scriptObjTypeNames[] =
|
||||
{
|
||||
/* (1 << 0) */ "Entity",
|
||||
/* (1 << 1) */ "Ingredient",
|
||||
/* (1 << 2) */ "CollideEntity",
|
||||
/* (1 << 3) */ "ScriptedEntity",
|
||||
/* (1 << 4) */ "Beam",
|
||||
/* (1 << 5) */ "Shot",
|
||||
/* (1 << 6) */ "Web",
|
||||
/* (1 << 7) */ "Bone",
|
||||
/* (1 << 8) */ "Path/Node",
|
||||
/* (1 << 9) */ "PauseQuad",
|
||||
/* (1 << 0) */ "RenderObject",
|
||||
/* (1 << 1) */ "Entity",
|
||||
/* (1 << 2) */ "Ingredient",
|
||||
/* (1 << 3) */ "CollideEntity",
|
||||
/* (1 << 4) */ "ScriptedEntity",
|
||||
/* (1 << 5) */ "Beam",
|
||||
/* (1 << 6) */ "Shot",
|
||||
/* (1 << 7) */ "Web",
|
||||
/* (1 << 8) */ "Bone",
|
||||
/* (1 << 9) */ "Path/Node",
|
||||
/* (1 <<10) */ "Quad",
|
||||
/* (1 <<11) */ "Text",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -26,16 +26,18 @@ enum ScriptObjectType
|
|||
|
||||
// If you change this enum, do not forget to adjust the string array in the cpp,
|
||||
// and to add additional compile time assertions to ScriptInterface.cpp as necessary!
|
||||
SCO_ENTITY = 0x0001,
|
||||
SCO_INGREDIENT = 0x0002,
|
||||
SCO_COLLIDE_ENTITY = 0x0004,
|
||||
SCO_SCRIPTED_ENTITY = 0x0008,
|
||||
SCO_BEAM = 0x0010,
|
||||
SCO_SHOT = 0x0020,
|
||||
SCO_WEB = 0x0040,
|
||||
SCO_BONE = 0x0080,
|
||||
SCO_PATH = 0x0100,
|
||||
SCO_PAUSEQUAD = 0x0200,
|
||||
SCO_RENDEROBJECT = 0x0001,
|
||||
SCO_ENTITY = 0x0002,
|
||||
SCO_INGREDIENT = 0x0004,
|
||||
SCO_COLLIDE_ENTITY = 0x0008,
|
||||
SCO_SCRIPTED_ENTITY = 0x0010,
|
||||
SCO_BEAM = 0x0020,
|
||||
SCO_SHOT = 0x0040,
|
||||
SCO_WEB = 0x0080,
|
||||
SCO_BONE = 0x0100,
|
||||
SCO_PATH = 0x0200,
|
||||
SCO_QUAD = 0x0400,
|
||||
SCO_TEXT = 0x0800,
|
||||
|
||||
SCO_FORCE_32BIT = 0xFFFFFFFF
|
||||
};
|
||||
|
@ -59,7 +61,12 @@ public:
|
|||
|
||||
inline bool isType(ScriptObjectType bt) const
|
||||
{
|
||||
return (_objtype & bt) != 0;
|
||||
return (_objtype & bt) == bt;
|
||||
}
|
||||
|
||||
inline bool isExactType(ScriptObjectType bt) const
|
||||
{
|
||||
return _objtype == bt;
|
||||
}
|
||||
|
||||
inline std::string getTypeString() const
|
||||
|
|
|
@ -37,7 +37,7 @@ enum AnimationCommand
|
|||
class ParticleEffect;
|
||||
class SkeletalSprite;
|
||||
|
||||
class Bone : public ScriptObject, public Quad
|
||||
class Bone : public Quad
|
||||
{
|
||||
public:
|
||||
Bone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue