mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
Merge branch 'experimental' into tile-optimization
# Conflicts: # Aquaria/ScriptInterface.cpp # BBGE/AfterEffect.cpp # BBGE/RenderGrid.cpp # BBGE/SkeletalSprite.cpp
This commit is contained in:
commit
d33e8f9116
17 changed files with 458 additions and 199 deletions
|
@ -209,6 +209,18 @@ void AnimationEditor::resetScaleOrSave()
|
|||
|
||||
if (core->getCtrlState())
|
||||
saveFile();
|
||||
else if(core->getAltState() && editingBone)
|
||||
{
|
||||
Vector scale(1,1);
|
||||
Bone *b = editingBone;
|
||||
do
|
||||
scale *= b->scale;
|
||||
while( (b = dynamic_cast<Bone*>(b->getParent())) ); // don't want to get entity scale; that's what the anim editor uses for zooming
|
||||
std::ostringstream os;
|
||||
os << scale.x;
|
||||
if(!SDL_SetClipboardText(os.str().c_str()))
|
||||
dsq->screenMessage("Scale copied to clipboard");
|
||||
}
|
||||
else
|
||||
editSprite->scale = Vector(1,1);
|
||||
}
|
||||
|
@ -739,11 +751,17 @@ void AnimationEditor::update(float dt)
|
|||
float spd = 1.0f;
|
||||
if (core->mouse.scrollWheelChange < 0)
|
||||
{
|
||||
ctrlSprite->scale.x /= 1.12f;
|
||||
if(splinegrid && core->getShiftState())
|
||||
splinegrid->setPointScale(std::max(splinegrid->getPointScale() / 1.12f, 0.05f));
|
||||
else
|
||||
ctrlSprite->scale.x /= 1.12f;
|
||||
}
|
||||
else if (core->mouse.scrollWheelChange > 0)
|
||||
{
|
||||
ctrlSprite->scale.x *= 1.12f;
|
||||
if(splinegrid && core->getShiftState())
|
||||
splinegrid->setPointScale(splinegrid->getPointScale() * 1.12f);
|
||||
else
|
||||
ctrlSprite->scale.x *= 1.12f;
|
||||
}
|
||||
if (core->getKeyState(KEY_PGDN) && core->getShiftState())
|
||||
{
|
||||
|
@ -768,6 +786,21 @@ void AnimationEditor::update(float dt)
|
|||
|
||||
}
|
||||
}
|
||||
if (editingBone)
|
||||
{
|
||||
float m = 0.2f;
|
||||
if(core->getKeyState(KEY_NUMPADSLASH))
|
||||
{
|
||||
editingBone->originalScale /= (1 + m*dt);
|
||||
editingBone->scale = editingBone->originalScale;
|
||||
}
|
||||
if(core->getKeyState(KEY_NUMPADSTAR))
|
||||
{
|
||||
editingBone->originalScale *= (1 + m*dt);
|
||||
editingBone->scale = editingBone->originalScale;
|
||||
}
|
||||
}
|
||||
|
||||
if (editingBone && boneEdit == 1 && !splinegrid)
|
||||
{
|
||||
Vector add = core->mouse.change;
|
||||
|
|
|
@ -3063,11 +3063,6 @@ void Avatar::setBlockSinging(bool v)
|
|||
}
|
||||
}
|
||||
|
||||
bool Avatar::canSetBoneLock()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Avatar::onSetBoneLock()
|
||||
{
|
||||
Entity::onSetBoneLock();
|
||||
|
|
|
@ -300,8 +300,6 @@ public:
|
|||
Web *web;
|
||||
float rollDelay;
|
||||
|
||||
bool canSetBoneLock() OVERRIDE;
|
||||
|
||||
void revert();
|
||||
void doBindSong();
|
||||
void doShieldSong();
|
||||
|
|
|
@ -29,6 +29,7 @@ SET(AQUARIA_SRCS
|
|||
FlockEntity.h
|
||||
Game.cpp
|
||||
Game.h
|
||||
GameEnums.cpp
|
||||
GameEnums.h
|
||||
GameplayVariables.cpp
|
||||
GameStructs.cpp
|
||||
|
@ -57,7 +58,6 @@ SET(AQUARIA_SRCS
|
|||
ModSelector.h
|
||||
Network.cpp
|
||||
Network.h
|
||||
NotEntities.h
|
||||
ParticleEditor.cpp
|
||||
Path.cpp
|
||||
Path.h
|
||||
|
|
|
@ -61,17 +61,18 @@ void Entity::setIngredientData(const std::string &name)
|
|||
void Entity::entityDied(Entity *e)
|
||||
{
|
||||
for (size_t i = 0; i < targets.size(); i++)
|
||||
{
|
||||
targets[i] = 0;
|
||||
}
|
||||
if(targets[i] == e)
|
||||
targets[i] = NULL;
|
||||
|
||||
if (boneLock.on)
|
||||
if (boneLock.on && boneLock.entity == e)
|
||||
{
|
||||
if (boneLock.entity == e)
|
||||
{
|
||||
setBoneLock(BoneLock());
|
||||
}
|
||||
setBoneLock(BoneLock(), true);
|
||||
}
|
||||
|
||||
if(riding == e)
|
||||
riding = NULL;
|
||||
if(ridingOnEntity == e)
|
||||
ridingOnEntity = NULL;
|
||||
}
|
||||
|
||||
void Entity::setBounceType(BounceType bt)
|
||||
|
@ -84,7 +85,7 @@ BounceType Entity::getBounceType()
|
|||
return bounceType;
|
||||
}
|
||||
|
||||
void Entity::generateCollisionMask(int ovrCollideRadius)
|
||||
void Entity::generateCollisionMask(float ovrCollideRadius)
|
||||
{
|
||||
if (this->skeletalSprite.isLoaded())
|
||||
{
|
||||
|
@ -98,14 +99,13 @@ void Entity::generateCollisionMask(int ovrCollideRadius)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Entity::setBoneLock(const BoneLock &bl)
|
||||
bool Entity::setBoneLock(const BoneLock &bl, bool force)
|
||||
{
|
||||
if (!canSetBoneLock()) return false;
|
||||
|
||||
if (bl.on && boneLockDelay > 0) return false;
|
||||
if (boneLock.on && bl.on) return false;
|
||||
if(!force)
|
||||
{
|
||||
if (bl.on && boneLockDelay > 0) return false;
|
||||
if (boneLock.on && bl.on) return false;
|
||||
}
|
||||
|
||||
if (boneLock.on && !bl.on)
|
||||
{
|
||||
|
@ -138,11 +138,6 @@ bool Entity::setBoneLock(const BoneLock &bl)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Entity::canSetBoneLock()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Entity::Entity()
|
||||
{
|
||||
addType(SCO_ENTITY);
|
||||
|
@ -211,7 +206,6 @@ Entity::Entity()
|
|||
multColor = Vector(1,1,1);
|
||||
collideRadius = 24;
|
||||
entityType = EntityType(0);
|
||||
targets.resize(10);
|
||||
|
||||
frozenTimer = 0;
|
||||
canBeTargetedByAvatar = false;
|
||||
|
@ -494,11 +488,8 @@ void Entity::stopFollowingPath()
|
|||
position.stopPath();
|
||||
}
|
||||
|
||||
void Entity::flipToTarget(Vector pos)
|
||||
void Entity::flipToPos(Vector pos)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (pos.x > position.x)
|
||||
{
|
||||
if (!isfh())
|
||||
|
@ -511,19 +502,25 @@ void Entity::flipToTarget(Vector pos)
|
|||
}
|
||||
}
|
||||
|
||||
Entity* Entity::getTargetEntity(int t)
|
||||
Entity* Entity::getTargetEntity(size_t t) const
|
||||
{
|
||||
return targets[t];
|
||||
return t < targets.size() ? targets[t] : NULL;
|
||||
}
|
||||
|
||||
void Entity::setTargetEntity(Entity *e, int t)
|
||||
void Entity::setTargetEntity(Entity *e, size_t t)
|
||||
{
|
||||
targets[t] = e;
|
||||
}
|
||||
if(t < targets.size())
|
||||
{
|
||||
targets[t] = e;
|
||||
return;
|
||||
}
|
||||
|
||||
bool Entity::hasTarget(int t)
|
||||
{
|
||||
return (targets[t]!=0);
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
if(targets.size() <= t)
|
||||
targets.resize(t + 1);
|
||||
targets[t] = e;
|
||||
}
|
||||
|
||||
void Entity::destroy()
|
||||
|
@ -1571,7 +1568,6 @@ void Entity::onUpdate(float dt)
|
|||
Quad::onUpdate(dt);
|
||||
|
||||
Vector v = position - lastPos;
|
||||
lastMove = v;
|
||||
if (position.isFollowingPath() && swimPath)
|
||||
{
|
||||
movementDetails(v);
|
||||
|
@ -1866,25 +1862,21 @@ EntityType Entity::getEntityType()
|
|||
return entityType;
|
||||
}
|
||||
|
||||
/* types:
|
||||
|
||||
*/
|
||||
Entity *Entity::findTarget(int dist, int type, int t)
|
||||
Entity *Entity::findTarget(int dist, int type, size_t t)
|
||||
{
|
||||
targets[t] = 0;
|
||||
Entity *target = NULL;
|
||||
|
||||
if (type == ET_AVATAR)
|
||||
{
|
||||
Vector d = game->avatar->position - this->position;
|
||||
if (d.getSquaredLength2D() < sqr(dist))
|
||||
{
|
||||
targets[t] = game->avatar;
|
||||
target = game->avatar;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int closestDist = -1;
|
||||
Entity *target = 0;
|
||||
FOR_ENTITIES(i)
|
||||
{
|
||||
Entity *e = *i;
|
||||
|
@ -1898,12 +1890,10 @@ Entity *Entity::findTarget(int dist, int type, int t)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (target)
|
||||
{
|
||||
targets[t] = target;
|
||||
}
|
||||
}
|
||||
return targets[t];
|
||||
setTargetEntity(target, t);
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
void Entity::moveTowards(Vector p, float dt, int spd)
|
||||
|
@ -1936,15 +1926,15 @@ void Entity::moveAroundAngle(int angle, float dt, int spd, int dir)
|
|||
moveAround(p, dt, spd, dir);
|
||||
}
|
||||
|
||||
void Entity::moveTowardsTarget(float dt, int spd, int t)
|
||||
void Entity::moveTowardsTarget(float dt, int spd, size_t t)
|
||||
{
|
||||
if (!targets[t]) return;
|
||||
if (t >= targets.size() || !targets[t]) return;
|
||||
moveTowards(targets[t]->position, dt, spd);
|
||||
}
|
||||
|
||||
void Entity::moveAroundTarget(float dt, int spd, int dir, int t)
|
||||
void Entity::moveAroundTarget(float dt, int spd, int dir, size_t t)
|
||||
{
|
||||
if (!targets[t]) return;
|
||||
if (t >= targets.size() || !targets[t]) return;
|
||||
moveAround(targets[t]->position, dt, spd, dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
float health;
|
||||
float maxHealth;
|
||||
|
||||
bool setBoneLock(const BoneLock &boneLock);
|
||||
bool setBoneLock(const BoneLock &boneLock, bool force = false);
|
||||
|
||||
void heal(float a, int type=0);
|
||||
|
||||
|
@ -134,7 +134,6 @@ public:
|
|||
Entity *ridingOnEntity;
|
||||
Vector startPos;
|
||||
void rotateToVec(Vector addVec, float time, float offsetAngle=0);
|
||||
virtual void applyVariation(int variation){}
|
||||
|
||||
void popBubble();
|
||||
void sound(const std::string &sound, float freq=1, float fadeOut=0);
|
||||
|
@ -167,7 +166,6 @@ public:
|
|||
STATE_FOLLOW =23,
|
||||
STATE_TITLE =24
|
||||
};
|
||||
virtual void onNotify(Entity *notify){}
|
||||
|
||||
float followPath(Path *p, float speed, int dir, bool deleteOnEnd = false);
|
||||
bool touchAvatarDamage(int radius, float dmg, const Vector &override=Vector(-1,-1,-1), float speed=0, float pushTime = 0, Vector collidePos = Vector(0,0,0));
|
||||
|
@ -178,8 +176,8 @@ public:
|
|||
void moveTowardsAngle(int angle, float dt, int spd);
|
||||
void moveAroundAngle(int angle, float dt, int spd, int dir);
|
||||
|
||||
void moveTowardsTarget(float dt, int spd, int t=0);
|
||||
void moveAroundTarget(float dt, int spd, int d, int t=0);
|
||||
void moveTowardsTarget(float dt, int spd, size_t t=0);
|
||||
void moveAroundTarget(float dt, int spd, int d, size_t t=0);
|
||||
void moveAroundEntity(float dt, int spd, int d, Entity *e);
|
||||
void moveTowardsGroupCenter(float dt, int spd);
|
||||
void moveTowardsGroupHeading(float dt, int spd);
|
||||
|
@ -187,13 +185,12 @@ public:
|
|||
void doSpellAvoidance(float dt, int range, float mod);
|
||||
void doEntityAvoidance(float dt, int range, float mod, Entity *ignore =0);
|
||||
void setMaxSpeed(float ms);
|
||||
Entity *findTarget(int dist, int type, int t=0);
|
||||
Entity *findTarget(int dist, int type, size_t t=0);
|
||||
|
||||
bool hasTarget(int t=0);
|
||||
bool isTargetInRange(int range, size_t t=0);
|
||||
void doGlint(const Vector &position, const Vector &scale=Vector(2,2), const std::string &tex="Glint", BlendType bt=BLEND_DEFAULT);
|
||||
Entity *getTargetEntity(int t=0);
|
||||
void setTargetEntity(Entity *e, int t=0);
|
||||
Entity *getTargetEntity(size_t t=0) const;
|
||||
void setTargetEntity(Entity *e, size_t t=0);
|
||||
|
||||
virtual void activate(Entity *by, int source){}
|
||||
|
||||
|
@ -201,11 +198,10 @@ public:
|
|||
|
||||
void setEntityType(EntityType et);
|
||||
EntityType getEntityType();
|
||||
void flipToTarget(Vector pos);
|
||||
void flipToPos(Vector pos);
|
||||
bool isFollowingPath();
|
||||
void stopFollowingPath();
|
||||
void overideMaxSpeed(int ms, float time);
|
||||
void disableOverideMaxSpeed();
|
||||
int currentEntityTarget;
|
||||
float moveToPos(Vector pos, float speed, int dieOnPathEnd=0, bool swim = false);
|
||||
bool isHit();
|
||||
|
@ -220,7 +216,6 @@ public:
|
|||
void idle();
|
||||
void slowToStopPath(float t);
|
||||
bool isSlowingToStopPath();
|
||||
Vector lastMove;
|
||||
float damageTime;
|
||||
|
||||
void setEntityProperty(EntityProperty ep, bool value=true);
|
||||
|
@ -286,7 +281,7 @@ public:
|
|||
float getHealthPerc();
|
||||
void setDeathScene(bool v);
|
||||
bool isDeathScene() const { return deathScene; }
|
||||
void generateCollisionMask(int ovrCollideRadius=0);
|
||||
void generateCollisionMask(float ovrCollideRadius=0);
|
||||
DamageData lastDamage;
|
||||
bool checkSplash(const Vector &override=Vector(0,0,0));
|
||||
EatData eatData;
|
||||
|
@ -330,8 +325,6 @@ public:
|
|||
void setPoison(float m, float t);
|
||||
inline float getPoison() const { return poison; }
|
||||
|
||||
virtual bool canSetBoneLock();
|
||||
|
||||
void initHair(int numSegments, float segmentLength, float width, const std::string &tex);
|
||||
void updateHair(float dt);
|
||||
void setHairHeadPosition(const Vector &pos);
|
||||
|
|
|
@ -2283,10 +2283,7 @@ void Game::entityDied(Entity *eDead)
|
|||
FOR_ENTITIES(i)
|
||||
{
|
||||
e = *i;
|
||||
if (e != eDead && e->isv(EV_ENTITYDIED,1))
|
||||
{
|
||||
e->entityDied(eDead);
|
||||
}
|
||||
e->entityDied(eDead);
|
||||
}
|
||||
|
||||
dsq->continuity.entityDied(eDead);
|
||||
|
|
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 < Countof(s_LayerNames) ? 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
|
||||
};
|
||||
|
||||
enum AquariaActions
|
||||
enum AquariaActions // Keep in sync with GameEnums.cpp
|
||||
{
|
||||
ACTION_PRIMARY =0,
|
||||
ACTION_SECONDARY =1,
|
||||
ACTION_ESC =2,
|
||||
ACTION_TOGGLESCENEEDITOR =3,
|
||||
ACTION_TOGGLEWORLDMAP =4,
|
||||
ACTION_PRIMARY,
|
||||
ACTION_SECONDARY,
|
||||
ACTION_ESC,
|
||||
ACTION_TOGGLESCENEEDITOR,
|
||||
ACTION_TOGGLEWORLDMAP,
|
||||
|
||||
ACTION_TOGGLEGRID =5,
|
||||
ACTION_TOGGLEGRID,
|
||||
|
||||
// Automatically sent on either ACTION_SWIM* or sufficient analog controller input
|
||||
ACTION_MENULEFT =6,
|
||||
ACTION_MENURIGHT =7,
|
||||
ACTION_MENUUP =8,
|
||||
ACTION_MENUDOWN =9,
|
||||
ACTION_MENULEFT,
|
||||
ACTION_MENURIGHT,
|
||||
ACTION_MENUUP,
|
||||
ACTION_MENUDOWN,
|
||||
|
||||
ACTION_PREVPAGE,
|
||||
ACTION_NEXTPAGE,
|
||||
|
@ -78,7 +78,7 @@ enum AquariaActions
|
|||
ACTION_TOGGLEMENU,
|
||||
|
||||
|
||||
|
||||
// ------------------------
|
||||
ACTION_SWIMUP = 100,
|
||||
ACTION_SWIMDOWN,
|
||||
ACTION_SWIMLEFT,
|
||||
|
@ -106,6 +106,7 @@ enum AquariaActions
|
|||
ACTION_SLOW, // currently unused
|
||||
ACTION_REVERT,
|
||||
|
||||
// ------------------------
|
||||
ACTION_ZOOMIN = 200,
|
||||
ACTION_ZOOMOUT,
|
||||
|
||||
|
@ -144,8 +145,11 @@ enum AquariaActions
|
|||
ACTION_LOOK ,
|
||||
ACTION_TOGGLEHELPSCREEN,
|
||||
ACTION_PLACE_AVATAR,
|
||||
ACTION_SCREENSHOT
|
||||
ACTION_SCREENSHOT,
|
||||
|
||||
ACTION_MAX
|
||||
};
|
||||
const char *EnumName(AquariaActions a);
|
||||
|
||||
enum AuraType
|
||||
{
|
||||
|
@ -232,7 +236,7 @@ enum VisualEffectsType
|
|||
VFX_MAX = 3
|
||||
};
|
||||
|
||||
enum Layers
|
||||
enum Layers // keep in sync with GameEnums.cpp
|
||||
{
|
||||
// GAME WILL CLEAR THESE
|
||||
LR_ZERO = 0,
|
||||
|
@ -313,6 +317,7 @@ enum Layers
|
|||
LR_BLACKBARS ,
|
||||
LR_MAX
|
||||
};
|
||||
const char *EnumName(Layers lr);
|
||||
|
||||
|
||||
enum IngredientType
|
||||
|
|
|
@ -29,6 +29,7 @@ Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject()
|
|||
{
|
||||
this->segmentLength = segmentLength;
|
||||
this->hairWidth = hairWidth;
|
||||
this->_hairfh = false;
|
||||
|
||||
cull = false;
|
||||
|
||||
|
@ -41,22 +42,12 @@ Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject()
|
|||
if (perc < 0)
|
||||
perc = 0;
|
||||
hairNodes[i].percent = 1.0f-perc;
|
||||
hairNodes[i].position = hairNodes[i].originalPosition = hairNodes[i].defaultPosition = Vector(0, i*segmentLength, 0);
|
||||
Vector p(0, i*segmentLength, 0);
|
||||
hairNodes[i].position = p;
|
||||
hairNodes[i].defaultPosition = p;
|
||||
}
|
||||
}
|
||||
|
||||
void Hair::exertWave(float dt)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hair::exertGravityWave(float dt)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hair::setHeadPosition(const Vector &vec)
|
||||
{
|
||||
hairNodes[0].position = vec;
|
||||
|
@ -75,46 +66,29 @@ HairNode *Hair::getHairNode(int idx)
|
|||
|
||||
void Hair::onRender(const RenderState& rs) const
|
||||
{
|
||||
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
float texBits = 1.0f / (hairNodes.size()-1);
|
||||
const float texBits = 1.0f / (hairNodes.size()-1);
|
||||
const Vector mul = !_hairfh ? Vector(1, 1) : Vector(-1, -1);
|
||||
|
||||
Vector pl, pr;
|
||||
for (size_t i = 0; i < hairNodes.size(); i++)
|
||||
{
|
||||
|
||||
|
||||
if (i != hairNodes.size()-1)
|
||||
{
|
||||
Vector diffVec = hairNodes[i+1].position - hairNodes[i].position;
|
||||
diffVec.setLength2D(hairWidth);
|
||||
pl = diffVec.getPerpendicularLeft();
|
||||
pr = diffVec.getPerpendicularRight();
|
||||
pl = diffVec.getPerpendicularLeft() * mul;
|
||||
pr = diffVec.getPerpendicularRight() * mul;
|
||||
}
|
||||
|
||||
|
||||
Vector p = hairNodes[i].position;
|
||||
|
||||
glTexCoord2f(0, texBits*i);
|
||||
glVertex3f(hairNodes[i].position.x + pl.x, hairNodes[i].position.y + pl.y, 0);
|
||||
glVertex3f(p.x + pl.x, p.y + pl.y, 0);
|
||||
glTexCoord2f(1, texBits*i);
|
||||
glVertex3f( hairNodes[i].position.x + pr.x, hairNodes[i].position.y + pr.y, 0);
|
||||
|
||||
|
||||
|
||||
glVertex3f(p.x + pr.x, p.y + pr.y, 0);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hair::onUpdate(float dt)
|
||||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hair::updatePositions()
|
||||
|
@ -137,11 +111,7 @@ void Hair::updatePositions()
|
|||
hairNodes[i].position = hairNodes[i-1].position + diff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hair::returnToDefaultPositions(float dt)
|
||||
|
@ -162,23 +132,44 @@ void Hair::returnToDefaultPositions(float dt)
|
|||
|
||||
void Hair::exertForce(const Vector &force, float dt, int usePerc)
|
||||
{
|
||||
|
||||
const Vector f = force * dt;
|
||||
for (int i = hairNodes.size()-1; i >= 1; i--)
|
||||
{
|
||||
switch (usePerc)
|
||||
{
|
||||
case 0:
|
||||
hairNodes[i].position += force*dt*hairNodes[i].percent;
|
||||
hairNodes[i].position += f * hairNodes[i].percent;
|
||||
break;
|
||||
case 1:
|
||||
hairNodes[i].position += force*dt*(1.0f-hairNodes[i].percent);
|
||||
hairNodes[i].position += f * (1.0f-hairNodes[i].percent);
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
hairNodes[i].position += force*dt;
|
||||
hairNodes[i].position += f;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Hair::exertNodeForce(size_t i, const Vector& force, float dt, int usePerc)
|
||||
{
|
||||
const Vector f = force * dt;
|
||||
if(i >= hairNodes.size())
|
||||
return;
|
||||
|
||||
switch (usePerc)
|
||||
{
|
||||
case 0:
|
||||
hairNodes[i].position += f * hairNodes[i].percent;
|
||||
break;
|
||||
case 1:
|
||||
hairNodes[i].position += f * (1.0f-hairNodes[i].percent);
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
hairNodes[i].position += f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
struct HairNode
|
||||
{
|
||||
HairNode() : percent(0), problem(false), angleDiff(0)
|
||||
HairNode() : percent(0)
|
||||
{}
|
||||
float percent; // percent of how much force is affected on this node
|
||||
Vector position; // position of the hair node
|
||||
Vector defaultPosition; // default position of the hair node
|
||||
Vector originalPosition;
|
||||
bool problem;
|
||||
float angleDiff;
|
||||
};
|
||||
|
||||
class Hair : public RenderObject
|
||||
|
@ -41,8 +38,10 @@ public:
|
|||
Hair(int nodes=40, float segmentLength=3, float width=18);
|
||||
|
||||
void exertForce(const Vector &force, float dt, int usePerc=0);
|
||||
void exertNodeForce(size_t idx, const Vector &force, float dt, int usePerc=0);
|
||||
void updatePositions();
|
||||
void returnToDefaultPositions(float dt);
|
||||
void setTextureFlip(bool flip) { _hairfh = flip; }
|
||||
|
||||
float hairWidth;
|
||||
|
||||
|
@ -55,8 +54,8 @@ public:
|
|||
HairNode *getHairNode(int idx);
|
||||
protected:
|
||||
float segmentLength;
|
||||
void onUpdate(float dt) OVERRIDE;
|
||||
void onRender(const RenderState& rs) const OVERRIDE;
|
||||
bool _hairfh;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
@ -1633,6 +1633,15 @@ luaFunc(obj_setRenderPass)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(obj_getRenderPass)
|
||||
{
|
||||
RenderObject *r = robj(L);
|
||||
int pass = 0;
|
||||
if (r)
|
||||
pass = r->getRenderPass();
|
||||
luaReturnInt(pass);
|
||||
}
|
||||
|
||||
luaFunc(obj_fh)
|
||||
{
|
||||
RenderObject *r = robj(L);
|
||||
|
@ -2060,6 +2069,7 @@ luaFunc(quad_getBorderAlpha)
|
|||
RO_FUNC(getter, prefix, setUpdateCull ) \
|
||||
RO_FUNC(getter, prefix, getUpdateCull ) \
|
||||
RO_FUNC(getter, prefix, setRenderPass ) \
|
||||
RO_FUNC(getter, prefix, getRenderPass ) \
|
||||
RO_FUNC(getter, prefix, setPositionX ) \
|
||||
RO_FUNC(getter, prefix, setPositionY ) \
|
||||
RO_FUNC(getter, prefix, enableMotionBlur ) \
|
||||
|
@ -5993,7 +6003,7 @@ luaFunc(entity_flipToEntity)
|
|||
Entity *e2 = entity(L, 2);
|
||||
if (e && e2)
|
||||
{
|
||||
e->flipToTarget(e2->position);
|
||||
e->flipToPos(e2->position);
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
@ -6005,7 +6015,7 @@ luaFunc(entity_flipToNode)
|
|||
PathNode *n = &p->nodes[0];
|
||||
if (e && n)
|
||||
{
|
||||
e->flipToTarget(n->position);
|
||||
e->flipToPos(n->position);
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
@ -7416,22 +7426,20 @@ luaFunc(entity_setActivationType)
|
|||
luaFunc(entity_hasTarget)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
if (e)
|
||||
luaReturnBool(e->hasTarget(e->currentEntityTarget));
|
||||
else
|
||||
luaReturnBool(false);
|
||||
luaReturnBool(e && e->getTargetEntity(e->currentEntityTarget));
|
||||
}
|
||||
|
||||
luaFunc(entity_hurtTarget)
|
||||
{
|
||||
Entity *e = entity(L);
|
||||
if (e && e->getTargetEntity())
|
||||
{
|
||||
DamageData d;
|
||||
d.attacker = e;
|
||||
d.damage = lua_tointeger(L, 2);
|
||||
e->getTargetEntity(e->currentEntityTarget)->damage(d);
|
||||
}
|
||||
if (e)
|
||||
if(Entity *t = e->getTargetEntity(e->currentEntityTarget))
|
||||
{
|
||||
DamageData d;
|
||||
d.attacker = e;
|
||||
d.damage = lua_tointeger(L, 2);
|
||||
t->damage(d);
|
||||
}
|
||||
|
||||
luaReturnNil();
|
||||
}
|
||||
|
@ -7665,12 +7673,32 @@ luaFunc(node_setElementsInLayerActive)
|
|||
|
||||
static int pushTileData(lua_State *L, const TileData& t, unsigned layer)
|
||||
{
|
||||
lua_pushinteger(L, t.et->idx);
|
||||
lua_pushstring(L, t.et->tex->name.c_str());
|
||||
lua_pushboolean(L, t.isVisible());
|
||||
lua_pushinteger(L, layer);
|
||||
lua_pushinteger(L, t.tag);
|
||||
return 5;
|
||||
/* 1 */ lua_pushinteger(L, t.et->idx);
|
||||
/* 2 */ lua_pushstring(L, t.et->gfx.c_str());
|
||||
/* 3 */ lua_pushboolean(L, t.isVisible());
|
||||
/* 4 */ lua_pushinteger(L, layer);
|
||||
/* 5 */ lua_pushinteger(L, t.tag);
|
||||
/* 6 */ lua_pushnumber(L, t.x);
|
||||
/* 7 */ lua_pushnumber(L, t.y);
|
||||
/* 8 */ lua_pushnumber(L, t.scalex);
|
||||
/* 9 */ lua_pushnumber(L, t.scaley);
|
||||
/* 10 */ lua_pushnumber(L, t.rotation);
|
||||
/* 11 */ lua_pushboolean(L, !!(t.flags & TILEFLAG_FH));
|
||||
/* 12 */ lua_pushboolean(L, !!(t.flags & TILEFLAG_FV));
|
||||
|
||||
// 13, 14
|
||||
if((t.flags & TILEFLAG_REPEAT) && t.rep)
|
||||
{
|
||||
lua_pushnumber(L, t.rep->texscaleX);
|
||||
lua_pushnumber(L, t.rep->texscaleY);
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
return 14;
|
||||
}
|
||||
|
||||
// (layer, func)
|
||||
|
@ -8349,6 +8377,34 @@ luaFunc(entity_exertHairForce)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
// entity idx x y dt
|
||||
luaFunc(entity_exertHairSegmentForce)
|
||||
{
|
||||
ScriptedEntity *se = scriptedEntity(L);
|
||||
if (se)
|
||||
{
|
||||
if (se->hair)
|
||||
se->hair->exertNodeForce(lua_tointeger(L, 2), Vector(lua_tonumber(L, 3), lua_tonumber(L, 4)), lua_tonumber(L, 5), lua_tonumber(L, 6));
|
||||
}
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setHairTextureFlip)
|
||||
{
|
||||
ScriptedEntity *se = scriptedEntity(L);
|
||||
if (se && se->hair)
|
||||
se->hair->setTextureFlip(getBool(L, 2));
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_setHairWidth)
|
||||
{
|
||||
ScriptedEntity *se = scriptedEntity(L);
|
||||
if (se && se->hair)
|
||||
se->hair->hairWidth = lua_tonumber(L, 2);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(entity_initPart)
|
||||
{
|
||||
std::string partName(getString(L, 2));
|
||||
|
@ -10719,6 +10775,9 @@ static const struct {
|
|||
luaRegister(entity_setHairHeadPosition),
|
||||
luaRegister(entity_updateHair),
|
||||
luaRegister(entity_exertHairForce),
|
||||
luaRegister(entity_exertHairSegmentForce),
|
||||
luaRegister(entity_setHairTextureFlip),
|
||||
luaRegister(entity_setHairWidth),
|
||||
|
||||
luaRegister(entity_setName),
|
||||
|
||||
|
@ -11738,6 +11797,20 @@ static const struct {
|
|||
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
|
||||
//============================================================================================
|
||||
|
@ -11826,6 +11899,8 @@ lua_State *ScriptInterface::createLuaVM()
|
|||
lua_pushnumber(state, luaConstantTable[i].value);
|
||||
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.
|
||||
if (complainOnGlobalVar)
|
||||
|
|
|
@ -688,7 +688,7 @@ void ScriptedEntity::entityDied(Entity *e)
|
|||
{
|
||||
CollideEntity::entityDied(e);
|
||||
|
||||
if (script)
|
||||
if (script && e != this && isv(EV_ENTITYDIED,1))
|
||||
{
|
||||
script->call("entityDied", this, e);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "StatsAndAchievements.h"
|
||||
#include "ttvfs_stdio.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(x) (sizeof (x) / sizeof ((x)[0]))
|
||||
#endif
|
||||
|
||||
#define _ACH_ID( id, name ) { id, #id, name, "", 0, 0 }
|
||||
|
||||
static Achievement g_rgAchievements[] =
|
||||
|
@ -153,7 +149,7 @@ void StatsAndAchievements::RunFrame()
|
|||
{
|
||||
requestedStats = true;
|
||||
|
||||
const size_t max_achievements = ARRAYSIZE(g_rgAchievements);
|
||||
const size_t max_achievements = Countof(g_rgAchievements);
|
||||
VFILE *io = NULL;
|
||||
|
||||
// Get generic achievement data...
|
||||
|
@ -229,7 +225,7 @@ void StatsAndAchievements::RunFrame()
|
|||
// but only if we're not in a mod
|
||||
if (!dsq->mod.isActive())
|
||||
{
|
||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
||||
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||
{
|
||||
EvaluateAchievement( g_rgAchievements[iAch] );
|
||||
}
|
||||
|
@ -252,7 +248,7 @@ void StatsAndAchievements::appendStringData(std::string &data)
|
|||
|
||||
count = 0;
|
||||
data += "Unlocked:\n\n";
|
||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
||||
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||
{
|
||||
const Achievement &ach = g_rgAchievements[iAch];
|
||||
if (!ach.achieved)
|
||||
|
@ -271,7 +267,7 @@ void StatsAndAchievements::appendStringData(std::string &data)
|
|||
|
||||
count = 0;
|
||||
data += "Locked:\n\n";
|
||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
||||
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||
{
|
||||
const Achievement &ach = g_rgAchievements[iAch];
|
||||
if (ach.achieved)
|
||||
|
@ -812,7 +808,7 @@ void StatsAndAchievements::StoreStatsIfNecessary()
|
|||
if (io == NULL)
|
||||
return;
|
||||
|
||||
const size_t max_achievements = ARRAYSIZE(g_rgAchievements);
|
||||
const size_t max_achievements = Countof(g_rgAchievements);
|
||||
unsigned char *buf = new unsigned char[max_achievements];
|
||||
|
||||
for (size_t i = 0; i < max_achievements; i++)
|
||||
|
@ -828,7 +824,7 @@ void StatsAndAchievements::StoreStatsIfNecessary()
|
|||
char cruft[101];
|
||||
for (size_t i = 0; i < sizeof (cruft); i++)
|
||||
cruft[i] = (char) rand();
|
||||
if (fwrite(cruft, sizeof (cruft[0]), ARRAYSIZE(cruft), io) != ARRAYSIZE(cruft))
|
||||
if (fwrite(cruft, sizeof (cruft[0]), Countof(cruft), io) != Countof(cruft))
|
||||
debugLog("Failed to write achievements 2");
|
||||
|
||||
fclose(io);
|
||||
|
|
|
@ -8,7 +8,11 @@ SplineGridCtrlPoint *SplineGridCtrlPoint::movingPoint;
|
|||
SplineGridCtrlPoint::SplineGridCtrlPoint()
|
||||
{
|
||||
setTexture("gui/open-menu");
|
||||
setWidthHeight(16, 16);
|
||||
setWidthHeight(8, 8);
|
||||
}
|
||||
|
||||
SplineGridCtrlPoint::~SplineGridCtrlPoint()
|
||||
{
|
||||
}
|
||||
|
||||
Vector SplineGridCtrlPoint::getSplinePosition() const
|
||||
|
@ -70,7 +74,7 @@ void SplineGridCtrlPoint::onUpdate(float dt)
|
|||
}
|
||||
|
||||
SplineGrid::SplineGrid()
|
||||
: wasModified(false), deg(0)
|
||||
: wasModified(false), deg(0), pointscale(1)
|
||||
{
|
||||
setWidthHeight(128, 128);
|
||||
renderQuad = true;
|
||||
|
@ -165,6 +169,8 @@ SplineGridCtrlPoint* SplineGrid::createControlPoint(size_t x, size_t y)
|
|||
const Vector pos01(float(x) / float(cpx-1), float(y) / float(cpy-1));
|
||||
SplineGridCtrlPoint *cp = new SplineGridCtrlPoint();
|
||||
cp->position = (pos01 - Vector(0.5f, 0.5f)) * wh;
|
||||
cp->scale.x = pointscale;
|
||||
cp->scale.y = pointscale;
|
||||
this->addChild(cp, PM_POINTER);
|
||||
return cp;
|
||||
}
|
||||
|
@ -214,4 +220,12 @@ void SplineGrid::onRender(const RenderState& rs) const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void SplineGrid::setPointScale(const float scale)
|
||||
{
|
||||
pointscale = scale;
|
||||
for(size_t i = 0; i < ctrlp.size(); ++i)
|
||||
{
|
||||
ctrlp[i]->scale.x = scale;
|
||||
ctrlp[i]->scale.y = scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ class SplineGridCtrlPoint : public Quad
|
|||
{
|
||||
public:
|
||||
SplineGridCtrlPoint();
|
||||
virtual ~SplineGridCtrlPoint();
|
||||
virtual void onUpdate(float dt) OVERRIDE;
|
||||
Vector getSplinePosition() const;
|
||||
void setSplinePosition(Vector pos);
|
||||
|
@ -30,7 +31,7 @@ public:
|
|||
typedef Vector value_type;
|
||||
|
||||
SplineGrid();
|
||||
~SplineGrid();
|
||||
virtual ~SplineGrid();
|
||||
|
||||
// # of control points on each axis
|
||||
DynamicRenderGrid *resize(size_t w, size_t h, size_t xres, size_t yres, unsigned degx, unsigned degy);
|
||||
|
@ -39,6 +40,9 @@ public:
|
|||
void importControlPoints(const Vector *controlpoints);
|
||||
void resetControlPoints();
|
||||
|
||||
void setPointScale(const float scale);
|
||||
float getPointScale() const { return pointscale; }
|
||||
|
||||
|
||||
virtual void onRender(const RenderState& rs) const OVERRIDE;
|
||||
virtual void onUpdate(float dt) OVERRIDE;
|
||||
|
@ -55,6 +59,7 @@ private:
|
|||
std::vector<SplineGridCtrlPoint*> ctrlp;
|
||||
unsigned deg;
|
||||
BSpline2DWithPoints bsp;
|
||||
float pointscale;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue