1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-08 17:42:05 +00:00

Major include refactor; changes to pretty much everything

This untangles some of the gigantic kitchen sink headers
in an attempt to split things into smaller files.
Also don't include gl.h, glext.h, windows.h,
and other such nonsense *everywhere*.

Lots of cleanups on the way too. More dead/unused code removal.

Remove incrFlag(), decrFlag() Lua functions.
This commit is contained in:
fgenesis 2016-07-09 04:18:40 +02:00
parent d1778a97b8
commit 8472718fb7
141 changed files with 2993 additions and 3708 deletions

View file

@ -18,10 +18,13 @@ 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.
*/
#include "States.h"
#include "AnimationEditor.h"
#include "DSQ.h"
#include "AquariaMenuItem.h"
#include "../BBGE/Gradient.h"
#include "../BBGE/DebugFont.h"
#include "RenderBase.h"
#include "Game.h"
@ -505,7 +508,9 @@ void AnimationEditor::undo()
{
if (undoEntry >= 0 && undoEntry < undoHistory.size())
{
editSprite->animations = undoHistory[undoEntry].animations;
std::list<SkeletalSprite>::iterator it = undoHistory.begin();
std::advance(it, undoEntry);
editSprite->animations = it->animations;
undoEntry--;
if (undoEntry<0) undoEntry = 0;
}
@ -521,8 +526,9 @@ void AnimationEditor::redo()
undoEntry++;
if (undoEntry >= 0 && undoEntry < undoHistory.size())
{
editSprite->animations = undoHistory[undoEntry].animations;
std::list<SkeletalSprite>::iterator it = undoHistory.begin();
std::advance(it, undoEntry);
editSprite->animations = it->animations;
}
else
{

153
Aquaria/AnimationEditor.h Normal file
View file

@ -0,0 +1,153 @@
#ifndef ANIMATION_EDITOR_H
#define ANIMATION_EDITOR_H
#include "../BBGE/SkeletalSprite.h"
#include "StateManager.h"
#include <list>
class DebugFont;
class BitmapText;
class KeyframeWidget : public Quad
{
public:
KeyframeWidget(int key);
float t;
int key;
static KeyframeWidget *movingWidget;
BitmapText *b;
void shiftLeft();
void shiftRight();
protected:
void onUpdate(float dt);
};
class AnimationEditor : public StateObject
{
public:
AnimationEditor();
void applyState();
void removeState();
void update(float dt);
void prevKey();
void nextKey();
void newKey();
void deleteKey();
void animate();
void stop();
void animateOrStop();
void newAnim();
void lmbu();
void lmbd();
void rmbu();
void rmbd();
void mmbd();
void constrainMouse();
void reorderKeys();
void saveFile();
void loadFile();
void copyKey();
void pasteKey();
void nextAnim();
void prevAnim();
void quit();
void load();
void loadSkin();
void copy();
void paste();
void cloneBoneAhead();
void zoomIn();
void zoomOut();
void resetScaleOrSave();
void clearRot();
void clearPos();
void flipRot();
void cycleLerpType();
void toggleHideBone();
void undo();
void redo();
void pushUndo();
void clearUndoHistory();
void applyTranslation();
void applyRotation();
void moveNextWidgets(float dt);
std::list<SkeletalSprite> undoHistory;
int undoEntry;
int currentKey;
int rotOffset;
SkeletalSprite *editSprite;
Bone *editingBone;
int boneEdit;
DebugFont *text, *text2;
void goToTitle();
SkeletalKeyframe copyBuffer;
std::string editingFile;
std::vector<KeyframeWidget*> keyframeWidgets;
void action(int id, int state, int source);
void rebuildKeyframeWidgets();
Vector cursorOffset;
void moveBoneStripPoint(const Vector &mov);
void editStripKey();
void toggleMouseSelection();
void selectPrevBone();
void selectNextBone();
bool mouseSelection;
SkeletalKeyframe buffer;
bool editingStrip;
int selectedStripPoint;
void reverseAnim();
void toggleRenderBorders();
void updateRenderBorders();
bool renderBorders;
void updateEditingBone();
void showAllBones();
void incrTimelineUnit();
void decrTimelineUnit();
void updateTimelineUnit();
void incrTimelineGrid();
void decrTimelineGrid();
void updateTimelineGrid();
DebugFont *gridsize, *unitsize;
};
#endif

View file

@ -260,7 +260,7 @@ void AquariaComboBox::close(float t)
}
if (t>0)
dsq->main(t);
dsq->run(t);
for(int i = 0; i < shownItems.size(); i++)
{

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "DSQ.h"
#include "Game.h"
#include "ActionInput.h"
#include "InGameMenu.h"
float AquariaGuiElement::guiMoveTimer = 0;
AquariaGuiElement::GuiElements AquariaGuiElement::guiElements;
@ -638,7 +639,7 @@ void AquariaKeyConfig::onUpdate(float dt)
while (dsq->game->getKeyState(i))
{
dsq->main(0.1);
dsq->run(0.1);
}
toggleEnterKey(0);
@ -666,7 +667,7 @@ void AquariaKeyConfig::onUpdate(float dt)
while (dsq->game->getKeyState(i))
{
dsq->main(0.1);
dsq->run(0.1);
}
toggleEnterKey(0);
@ -698,7 +699,7 @@ void AquariaKeyConfig::onUpdate(float dt)
while (dsq->game->getKeyState(i))
{
dsq->main(0.1);
dsq->run(0.1);
}
toggleEnterKey(0);
@ -855,9 +856,9 @@ void AquariaMenuItem::useGlow(const std::string &tex, int w, int h)
void AquariaMenuItem::onClick()
{
if (hasInput() && highlighted && dsq->menuSelectDelay == 0)
if (hasInput() && highlighted && game->getInGameMenu()->menuSelectDelay == 0)
{
dsq->menuSelectDelay = MENUSELECTDELAY;
game->getInGameMenu()->menuSelectDelay = MENUSELECTDELAY;
if (!useSfx.empty())
dsq->sound->playSfx(useSfx);
@ -865,9 +866,6 @@ void AquariaMenuItem::onClick()
dsq->playMenuSelectSfx();
event.call();
}
}

View file

@ -227,7 +227,7 @@ void AquariaSaveSlot::onUpdate(float dt)
screen->position.interpolateTo(Vector(400-position.x, 300-position.y), 1.0, 0, 0, 1);
dsq->tfader->alpha.interpolateTo(1, 1);
dsq->toggleCursor(false);
core->main(1);
core->run(1);
}

View file

@ -1,289 +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.
*/
#include "AutoMap.h"
#include "DSQ.h"
#include "Game.h"
#include "Avatar.h"
#define AUTOMAP_GRIDTILE 512
AutoMap::AutoMap() : RenderObject(), ActionMapper()
{
followCamera = 1;
scale = Vector(0.4, 0.4);
position = Vector(400,300);
alpha = 0;
vis = false;
blip = Vector(1,1);
blip.interpolateTo(Vector(4,4), 0.75, -1, 1, 1);
initedGrid = false;
setTexture("particles/glow");
paintColor = Vector(1,1,1);
autoMapMode = 0;
addAction(MakeFunctionEvent(AutoMap, lmb), ActionMapper::MOUSE_BUTTON_LEFT);
shadowTex = 0;
}
void AutoMap::destroy()
{
RenderObject::destroy();
if (shadowTex)
{
shadowTex->destroy();
delete shadowTex;
shadowTex = 0;
}
}
bool AutoMap::isOn()
{
return vis;
}
void AutoMap::toggle(bool on)
{
const float t = 0.2;
if (on)
{
autoMapMode = 0;
dsq->game->togglePause(true);
dsq->fade(1, t);
dsq->main(t);
core->overrideStartLayer = LR_AFTER_EFFECTS;
core->overrideEndLayer = LR_MAX;
vis = true;
alpha = 1;
dsq->fade(0, t);
dsq->main(t);
}
else
{
dsq->fade(1, t);
dsq->main(t);
core->overrideStartLayer = 0;
core->overrideEndLayer = 0;
vis = false;
alpha.interpolateTo(0, 0.5);
alpha = 0;
dsq->game->togglePause(false);
dsq->fade(0, t);
dsq->main(t);
}
}
void AutoMap::setGridFromWorld(Vector worldPos, int gridValue)
{
int gx = worldPos.x / AUTOMAP_GRIDTILE;
int gy = worldPos.y / AUTOMAP_GRIDTILE;
if (gx<0 || gy<0 || gx >= MAX_AUTOMAP_GRID || gy >= MAX_AUTOMAP_GRID)
{
std::ostringstream os;
os << "AutoMap::setGridFromWorld - exceeded grid size";
os << "(" << gx <<", " << gy << ")";
debugLog(os.str());
return;
}
grid[gx][gy] = gridValue;
}
void AutoMap::initGrid()
{
for (int x=0;x<MAX_AUTOMAP_GRID;x++)
{
for (int y=0;y<MAX_AUTOMAP_GRID;y++)
{
grid[x][y] = 1;
}
}
initedGrid = true;
}
void AutoMap::paint(const Vector &pos)
{
Quad *q = new Quad("particles/WhiteGlow", pos);
q->setLife(1);
q->setDecayRate(0.5);
q->color = paintColor;
q->followCamera = 1;
q->setWidthHeight(8,8);
dsq->game->addRenderObject(q, this->layer);
}
void AutoMap::onUpdate(float dt)
{
RenderObject::onUpdate(dt);
if (!initedGrid)
{
initGrid();
}
if (dsq->game->avatar)
{
setGridFromWorld(dsq->game->avatar->position, 0);
}
if (vis && alpha.x == 1)
{
const float maxScale=1.25, minScale=0.5;
blip.update(dt);
Vector sTarget=scale;
float spd = 0.5;
if (core->mouse.scrollWheelChange < 0)
{
scale -= Vector(spd*0.05f,spd*0.05f);
}
else if (core->mouse.scrollWheelChange > 0)
{
scale += Vector(spd*0.05f,spd*0.05f);
}
if (scale.x < minScale)
scale = Vector(minScale, minScale);
if (scale.x > maxScale)
scale = Vector(maxScale, maxScale);
if (core->mouse.buttons.middle)
{
offset += core->mouse.change*scale;
}
}
}
void AutoMap::lmb()
{
if (autoMapMode == 0)
autoMapMode = 1;
else
autoMapMode = 0;
}
void AutoMap::onRender()
{
if (alpha.x == 0) return;
glBindTexture(GL_TEXTURE_2D, 0);
RenderObject::lastTextureApplied = 0;
float alphaValue = alpha.x;
int ysz = dsq->game->cameraMax.y/TILE_SIZE;
int xsz = dsq->game->cameraMax.x/TILE_SIZE;
TileVector t(Vector(dsq->game->cameraMax.x/2, dsq->game->cameraMax.y/2));
int skip = 4;
glLineWidth(skip);
if (alphaValue > 0)
{
for (int y = 0; y < ysz; y += skip)
{
float f = float(y)/float(ysz);
f = 0.8f-(f*0.5f);
glColor4f(0.5f*f, 0.75f*f, 1*f, alphaValue);
glBegin(GL_LINES);
int rowStart = -1;
int x = 0;
for (x = 0; x < xsz; x++)
{
if (dsq->game->getGrid(TileVector(x,y))!=OT_BLACK)
{
if (rowStart == -1)
{
rowStart = x;
}
}
else
{
if (rowStart != -1)
{
glVertex3f((rowStart-t.x), (y-t.y),0);
glVertex3f((x-t.x), (y-t.y),0);
rowStart = -1;
}
}
}
if (rowStart != -1)
{
glVertex3f((rowStart-t.x), (y-t.y),0);
glVertex3f((x-t.x), (y-t.y),0);
}
glEnd();
}
}
TileVector nt(dsq->game->avatar->position);
glTranslatef(nt.x - t.x, nt.y - t.y,0);
glColor4f(0.5,0.7,1, alphaValue);
glPointSize(4);
glBegin(GL_POINTS);
glVertex2f(0,0);
glEnd();
glColor4f(0.5,0.75,1, alphaValue*0.5f);
drawCircle(blip.x*16, 8);
}

View file

@ -1,52 +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.
*/
#ifndef AUTOMAP_H
#define AUTOMAP_H
#include "../BBGE/ActionMapper.h"
#include "../BBGE/RenderObject.h"
#define MAX_AUTOMAP_GRID 64
class AutoMap : public RenderObject, public ActionMapper
{
public:
AutoMap();
void destroy();
void toggle(bool on);
bool isOn();
void setGridFromWorld(Vector worldPos, int gridValue);
void initGrid();
Texture *shadowTex;
void paint(const Vector &pos);
void lmb();
protected:
int autoMapMode;
Vector paintColor;
bool initedGrid;
int grid[MAX_AUTOMAP_GRID][MAX_AUTOMAP_GRID];
InterpolatedVector blip;
bool vis;
void onUpdate(float dt);
void onRender();
};
#endif

View file

@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Shot.h"
#include "GridRender.h"
#include "Web.h"
#include "Hair.h"
const float MULT_DMG_CRABCOSTUME = 0.75;
@ -1837,7 +1839,7 @@ void Avatar::setSongIconPositions()
const int chkDist = 2500*2500;
Target Avatar::getNearestTarget(const Vector &checkPos, const Vector &distPos, Entity *source, DamageType dt, bool override, std::vector<Target> *ignore, /*FIXME:unused*/ EntityList *entityList)
Target Avatar::getNearestTarget(const Vector &checkPos, const Vector &distPos, Entity *source, DamageType dt, bool override, std::vector<Target> *ignore)
{
BBGE_PROF(Avatar_getNearestTarget);
Target t;
@ -2875,25 +2877,13 @@ int Avatar::getNumShots()
void Avatar::doShock(const std::string &shotName)
{
int c = 0;
//int maxHit = 2 + dsq->continuity.getSpellLevel(SPELL_SHOCK)*2;
//int maxHit = 4;
std::vector <Entity*> entitiesToHit;
std::vector <Target> localTargets;
bool clearTargets = true;
int thits = getNumShots();
/*
if (skeletalSprite.getAnimationLayer(ANIMLAYER_FLOURISH)->getCurrentAnimation())
{
thits = maxTendrilHits;
}
*/
if (!targets.empty() && targets[0].e != 0)
{
clearTargets = false;
@ -2904,24 +2894,11 @@ void Avatar::doShock(const std::string &shotName)
}
else
{
//std::vector <Target> localTargets;
localTargets.clear();
int range = 800;
EntityList entityList;
FOR_ENTITIES(i)
{
Entity *e = *i;
if (e != this && e->isPresent() && e->isDamageTarget(DT_AVATAR_SHOCK) && (e->position - position).isLength2DIn(range))
{
entityList.push_back(e);
}
}
while (c < thits)
{
Target t = getNearestTarget(position, position, this, DT_AVATAR_SHOCK, true, &localTargets, &entityList);
Target t = getNearestTarget(position, position, this, DT_AVATAR_SHOCK, true, &localTargets);
if (t.e)
{
localTargets.push_back(t);
@ -2956,7 +2933,6 @@ void Avatar::doShock(const std::string &shotName)
int sz = entitiesToHit.size();
if (sz == 0)
{
for (int i = 0; i < thits; i++)
@ -2984,33 +2960,9 @@ void Avatar::doShock(const std::string &shotName)
s->targetPt = targets[j].targetPt;
}
}
/*
else if (!localTargets.empty())
{
for (int j = 0; j < localTargets.size(); j++)
{
if (localTargets[j].e == e)
s->targetPt = localTargets[j].targetPt;
}
}
*/
Vector d = e->position - position;
/*
float a = float(float(i)/float(sz))*PI*2;
Vector aim(sinf(a), cosf(a));
swizzleTendrilAimVector(aim);
*/
s->setAimVector(getTendrilAimVector(i, thits));
checkUpgradeForShot(s);
/*
float ang = 0;
MathFunctions::calculateAngleBetweenVectorsInRadians(Vector(0,-1), d, ang);
float a = i-(sz/2);
Vector adjust = a*spread + ang;
d.normalize2D();
s->setAimVector((d + adjust)/2);
*/
}
}
}
@ -4266,17 +4218,20 @@ Vector Avatar::getFakeCursorPosition()
}
if (dsq->inputMode == INPUT_JOYSTICK)
{
const float axisInput = core->joystick.position.getLength2D();
if (axisInput < JOYSTICK_LOW_THRESHOLD)
{
return Vector(0,0,0);
}
else
{
float axisInput = 0;
Joystick *j = 0;
for(size_t i = 0; i < core->joysticks.size(); ++i)
if( ((j = core->joysticks[i])) )
if(j->isEnabled())
{
axisInput = j->position.getLength2D();
if(axisInput >= JOYSTICK_LOW_THRESHOLD)
break;
}
const float axisMult = (maxMouse - minMouse) / (JOYSTICK_HIGH_THRESHOLD - JOYSTICK_LOW_THRESHOLD);
const float distance = minMouse + ((axisInput - JOYSTICK_LOW_THRESHOLD) * axisMult);
return (core->joystick.position * (distance / axisInput));
}
return (j->position * (distance / axisInput));
}
return Vector(0,0,0);
}
@ -5586,12 +5541,12 @@ void Avatar::onUpdate(float dt)
//dsq->sound->setMusicFader(0.5, 0.5);
core->sound->playSfx("NaijaGasp");
core->main(0.75);
core->run(0.75);
dsq->voiceOnce("Naija_VeilCrossing");
core->main(10*0.1f);
core->run(10*0.1f);
dsq->gameSpeed.interpolateTo(1, 0.2);

View file

@ -23,14 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/Particles.h"
#include "DSQ.h"
#include "Hair.h"
#include "Entity.h"
#include "Web.h"
class TileVector;
class SongIcon;
class Web;
class Hair;
struct Target
{
@ -267,7 +265,7 @@ public:
typedef std::list<Entity*> BittenEntities;
BittenEntities bittenEntities;
Target getNearestTarget(const Vector &checkPos, const Vector &distPos, Entity *source, DamageType dt, bool override=false, std::vector<Target> *ignore=0, EntityList *entityList=0);
Target getNearestTarget(const Vector &checkPos, const Vector &distPos, Entity *source, DamageType dt, bool override=false, std::vector<Target> *ignore=0);
void toggleCape(bool on);
void updateLookAt(float dt);

View file

@ -18,9 +18,10 @@ 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.
*/
#include "Shot.h"
#include "Beam.h"
#include "Game.h"
#include "Avatar.h"
#include "RenderBase.h"
#include "../BBGE/MathFunctions.h"
@ -114,14 +115,6 @@ void Beam::trace()
}
void Beam::render()
{
Quad::render();
}
void Beam::onRender()
{

35
Aquaria/Beam.h Normal file
View file

@ -0,0 +1,35 @@
#ifndef AQUARIA_BEAM_H
#define AQUARIA_BEAM_H
#include "Quad.h"
#include "Damage.h"
#include <list>
class Entity;
class Beam : public Quad
{
public:
Beam(Vector pos, float angle);
typedef std::list<Beam*> Beams;
static Beams beams;
static void killAllBeams();
float angle;
void trace();
Vector endPos;
DamageData damageData;
void setDamage(float dmg);
void setFirer(Entity *e);
void setBeamWidth(float w);
protected:
float beamWidth;
void onRender();
void onEndOfLife();
void onUpdate(float dt);
};
#endif

View file

@ -30,7 +30,7 @@ BitBlotLogo::BitBlotLogo() : StateObject()
bool BitBlotLogo::watchQuit(float time)
{
core->main(time);
core->run(time);
return false;
}
@ -55,10 +55,10 @@ void BitBlotLogo::doShortBitBlot()
logo->scale = Vector(0.6,0.6);
addRenderObject(logo, LR_HUD);
core->main(1.5);
core->run(1.5);
dsq->overlay2->alpha.interpolateTo(1, 0.5);
core->main(0.5);
core->run(0.5);
}
void BitBlotLogo::skipLogo()

View file

@ -22,9 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Avatar.h"
#include "ScriptedEntity.h"
#include "AutoMap.h"
#include "GridRender.h"
#include "DeflateCompressor.h"
#include "ttvfs_stdio.h"
#include "ReadXML.h"
#include "Web.h"
#include "tinyxml2.h"
using namespace tinyxml2;
@ -203,56 +205,6 @@ int Continuity::getIngredientHeldSize() const
return (int)ingredients.size();
}
Recipe::Recipe()
{
known = false;
index = -1;
}
void Recipe::clear()
{
types.clear();
names.clear();
result = "";
resultDisplayName = "";
known = false;
}
void Recipe::learn()
{
known = true;
}
void Recipe::addName(const std::string &name)
{
int i = 0;
for (; i < names.size(); i++)
{
if (names[i].name == name)
{
names[i].amount++;
break;
}
}
if (i == names.size())
names.push_back(RecipeName(name));
}
void Recipe::addType(IngredientType type, const std::string &typeName)
{
int i = 0;
for (; i < types.size(); i++)
{
if (types[i].type == type)
{
types[i].amount++;
break;
}
}
if (i == types.size())
types.push_back(RecipeType(type, typeName));
}
void Continuity::initFoodSort()
{
// move to init
@ -937,7 +889,6 @@ void Continuity::loadIngredientData()
}
clearIngredientData();
ingredientDescriptions.clear();
ingredientDisplayNames.clear();
recipes.clear();
@ -1564,10 +1515,10 @@ void Continuity::castSong(int num)
dsq->overlay->color = Vector(1,1,1);
dsq->fade(1, 0.3);
dsq->main(0.3);
dsq->run(0.3);
warpLiToAvatar();
dsq->fade(0, 0.3);
dsq->main(0.3);
dsq->run(0.3);
dsq->overlay->color = 0;
}
@ -2637,7 +2588,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
doc.InsertEndChild(startData);
std::string fn = core->adjustFilenameCase(getSaveFileName(slot, "aqs"));
std::string fn = adjustFilenameCase(getSaveFileName(slot, "aqs"));
FILE *fh = fopen(fn.c_str(), "wb");
if(!fh)
{

308
Aquaria/Continuity.h Normal file
View file

@ -0,0 +1,308 @@
#ifndef CONTINUITY_H
#define CONTINUITY_H
#include <map>
#include <vector>
#include <string>
#include "StatsAndAchievements.h"
#include "GameEnums.h"
#include "WorldMap.h"
#include "StringBank.h"
namespace tinyxml2 { class XMLDocument; }
class Avatar;
class IngredientData;
class Path;
typedef std::map<int, TreasureDataEntry> TreasureData;
class Continuity
{
public:
Continuity();
~Continuity() { clearIngredientData(); }
void init();
void shutdown();
void initAvatar(Avatar *a);
void refreshAvatarData(Avatar *a);
void reset();
bool hasItem(int type);
void pickup(int type, int amount=1);
void drop(int type);
void entityDied(Entity *eDead);
void achieve(const std::string &achievement);
void initFoodSort();
void sortFood();
bool isIngredientFull(IngredientData *data);
void setCostume(const std::string &c);
void shortenSong(Song &song, int size);
void warpLiToAvatar();
void flingMonkey(Entity *e);
void upgradeHealth();
int getFlag(std::string flag);
void setFlag(std::string flag, int v);
int getFlag(int flag);
void setFlag(int flag, int v);
int getEntityFlag(const std::string &sceneName, int id);
void setEntityFlag(const std::string &sceneName, int id, int v);
void setPathFlag(Path *p, int v);
int getPathFlag(Path *p);
std::string getStringFlag(std::string flag);
void setStringFlag(std::string flag, std::string v);
void saveFile(int slot, Vector position=Vector(0,0,0), unsigned char *scrShotData=0, int scrShotWidth=0, int scrShotHeight=0);
void loadFileData(int slot, tinyxml2::XMLDocument &doc);
void loadFile(int slot);
void castSong(int num);
bool hasLi();
std::string getDescriptionForSongSlot(int songSlot);
std::string getVoxForSongSlot(int songSlot);
std::string getIEString(IngredientData *data, int i);
std::string getAllIEString(IngredientData *data);
std::string getInternalFormName();
std::string getSaveFileName(int slot, const std::string &pfix);
float maxHealth;
float health;
bool hudVisible;
unsigned int exp;
void clearTempFlags();
void getHoursMinutesSeconds(int *hours, int *minutes, int *seconds);
float seconds;
void update(float dt);
void setItemSlot(int slot, int itemType);
std::vector<int> itemSlots;
bool isItemPlantable(int item);
float getCurrentTime(){return seconds;}
//GardenData gardenData;
Vector zoom;
std::string getIngredientGfx(const std::string &name);
WorldType getWorldType() { return worldType; }
void shiftWorlds();
void applyWorldEffects(WorldType type, bool transition, bool affectMusic);
//void setActivePet(int flag);
bool isStory(float v);
float getStory();
void setStory(float v);
float getSpeedType(int speedType);
void setNaijaModel(std::string model);
std::string naijaModel;
FormType form;
void learnFormUpgrade(FormUpgradeType form);
bool hasFormUpgrade(FormUpgradeType form);
typedef std::map<FormUpgradeType, bool> FormUpgrades;
FormUpgrades formUpgrades;
void loadSongBank();
void loadIntoSongBank(const std::string &file);
int checkSong(const Song &song);
int checkSongAssisted(const Song &song);
typedef std::map<int, Song> SongMap;
SongMap songBank;
Song *getSongByIndex(int idx);
bool hasSong(int song);
int getSongTypeBySlot(int slot);
int getSongSlotByType(int type);
void learnSong(int song);
void unlearnSong(int song);
std::map<int, bool> knowsSong;
std::map<int, int> songSlotsToType;
std::map<int, int> songTypesToSlot;
std::map<int, std::string> songSlotDescriptions;
std::map<int, std::string> songSlotNames;
std::map<int, std::string> songSlotVox;
typedef std::map<std::string, int> EntityFlags;
EntityFlags entityFlags;
bool toggleMoveMode;
typedef std::list<GemData> Gems;
Gems gems;
typedef std::list<BeaconData> Beacons;
Beacons beacons;
GemData *pickupGem(std::string name, bool effects = true);
void removeGemData(GemData *gemData);
typedef std::vector<std::string> VoiceOversPlayed;
VoiceOversPlayed voiceOversPlayed;
std::string costume;
AuraType auraType;
float auraTimer;
EatData *getEatData(const std::string &name);
void loadEatBank();
bool isSongTypeForm(SongType s);
std::string getSongNameBySlot(int slot);
void toggleLiCombat(bool t);
void pickupIngredient(IngredientData *i, int amount, bool effects=true, bool learn=true);
int indexOfIngredientData(const IngredientData* data) const;
IngredientData *getIngredientHeldByName(const std::string &name) const; // an ingredient that the player actually has; in the ingredients list
IngredientData *getIngredientDataByName(const std::string &name); // an ingredient in the general data list; ingredientData
IngredientData *getIngredientHeldByIndex(int idx) const;
IngredientData *getIngredientDataByIndex(int idx);
int getIngredientDataSize() const;
int getIngredientHeldSize() const;
bool applyIngredientEffects(IngredientData *data);
void loadIngredientData();
void loadIngredientData(const std::string &file);
void loadIngredientDisplayNames(const std::string& file);
bool hasIngredients() const { return !ingredients.empty(); }
IngredientDatas::size_type ingredientCount() const { return ingredients.size(); }
IngredientType getIngredientTypeFromName(const std::string &name) const;
std::string getIngredientDisplayName(const std::string& name) const;
void removeEmptyIngredients();
void spawnAllIngredients(const Vector &position);
std::vector<std::string> unsortedOrder;
typedef std::vector<Recipe> Recipes;
Recipes recipes;
void setSpeedMultiplier(float s, float t);
void setBiteMultiplier(float m, float t);
void setFishPoison(float m, float t);
void setDefenseMultiplier(float s, float t);
void setRegen(float t);
void setTrip(float t);
void setInvincible(float t);
void setEnergy(float m, float t);
void setPoison(float m, float t);
void setWeb(float t);
void setLight(float m, float t);
void setPetPower(float m, float t);
void setLiPower(float m, float t);
void cureAllStatus();
float speedMult, biteMult, fishPoison, defenseMult, energyMult, poison, light, petPower, liPower;
Timer speedMultTimer, biteMultTimer, fishPoisonTimer, defenseMultTimer, liPowerTimer;
Timer invincibleTimer;
Timer regenTimer, tripTimer;
Timer energyTimer, poisonTimer, poisonBitTimer;
Timer webTimer, webBitTimer, lightTimer, petPowerTimer;
float speedMult2;
void eatBeast(const EatData &eatData);
void removeNaijaEat(int idx);
void removeLastNaijaEat();
EatData *getLastNaijaEat();
bool isNaijaEatsEmpty();
void loadPetData();
PetData *getPetData(int idx);
std::vector<EatData> naijaEats;
std::vector<PetData> petData;
std::string getIngredientAffectsString(IngredientData *data);
WorldMap worldMap;
StringBank stringBank;
TreasureData treasureData;
void loadTreasureData();
void learnRecipe(Recipe *r, bool effects=true);
void learnRecipe(const std::string &result, bool effects=true);
float poisonBitTime, poisonBitTimeAvatar;
enum { DUALFORM_NAIJA = 0, DUALFORM_LI = 1 };
int dualFormMode, dualFormCharge;
BeaconData *getBeaconByIndex(int index);
void setBeacon(int index, bool v, Vector pos=Vector(0,0,0), Vector color=Vector(1,1,1));
int foodSortType;
std::vector<FoodSortOrder> sortByType, sortByHeal, sortByIngredients, sortByUnsort;
StatsAndAchievements *statsAndAchievements;
protected:
std::vector<EatData> eats;
std::vector<float> speedTypes;
float story;
WorldType worldType;
std::vector<int> items;
std::vector<int> spells;
typedef std::map<std::string,int> Flags;
Flags flags;
int intFlags[MAX_FLAGS];
typedef std::map<std::string,std::string> StringFlags;
StringFlags stringFlags;
private:
void clearIngredientData();
IngredientDatas ingredients; // held ingredients
IngredientDatas ingredientData; // all possible ingredients
typedef std::map<std::string,std::string> IngredientNameMap;
IngredientNameMap ingredientDisplayNames;
};
#endif

View file

@ -49,7 +49,7 @@ namespace AQCredits
q->scale.data->path.addPathNode(Vector(1.4, 1.4), 1);
q->scale.startPath(t);
core->main(t);
core->run(t);
}
void cred(Quad *cred, bool show)
@ -137,16 +137,16 @@ void Credits::applyState()
}
// start:
core->main(1);
core->run(1);
dsq->sound->playMusic("losttothewaves", SLT_NONE, SFT_CROSS, 1);
dsq->overlay->alpha.interpolateTo(0, 12);
dsq->overlay2->alpha.interpolateTo(0, 12);
core->main(12);
core->run(12);
core->main(6);
core->run(6);
cred(derek, true);
@ -179,11 +179,11 @@ void Credits::applyState()
watchSlide(15);
dsq->overlay->alpha.interpolateTo(1, 6);
core->main(6);
core->run(6);
while (dsq->sound->isPlayingMusic() && !dsq->isSkippingCutscene())
{
core->main(1);
core->run(1);
}
dsq->setCutscene(0);

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "GridRender.h"
#include "RenderBase.h"
#include "../BBGE/AfterEffect.h"

View file

@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/DebugFont.h"
#include "../ExternalLibs/glpng.h"
#include "../BBGE/AfterEffect.h"
#include "../BBGE/ProfRender.h"
#include "DSQ.h"
#include "States.h"
@ -32,15 +31,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Avatar.h"
#include "Shot.h"
#include "GridRender.h"
#include "AutoMap.h"
#include "AnimationEditor.h"
#include "Intro.h"
#include "RoundedRect.h"
#include "TTFFont.h"
#include "ModSelector.h"
#include "Network.h"
#include "ttvfs_stdio.h"
#include "GLLoad.h"
#include "RenderBase.h"
#include <sys/stat.h>
#include <sys/stat.h>
#ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
@ -192,7 +194,6 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir)
inModSelector = false;
subtext = 0;
subbox = 0;
menuSelectDelay = 0;
modSelectorScr = 0;
blackout = 0;
inputMode = INPUT_MOUSE;
@ -271,8 +272,9 @@ void DSQ::forceInputGrabOff()
void DSQ::rumble(float leftMotor, float rightMotor, float time)
{
if (this->inputMode == INPUT_JOYSTICK)
core->joystick.rumble(leftMotor, rightMotor, time);
//if (this->inputMode == INPUT_JOYSTICK)
// core->joystick.rumble(leftMotor, rightMotor, time);
assert(false); // FIXME
}
void DSQ::newGame()
@ -572,7 +574,7 @@ void DSQ::debugMenu()
else if (c == '6')
{
while (core->getKeyState(KEY_RETURN))
core->main(0.1);
core->run(0.1);
dsq->setStory();
}
else if (c == '8')
@ -848,11 +850,11 @@ This build is not yet final, and as such there are a couple things lacking. They
std::string fn;
fn = getPreferencesFolder() + "/" + userSettingsFilename;
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase(userSettingsFilename).c_str(), core->adjustFilenameCase(fn).c_str());
Linux_CopyTree(adjustFilenameCase(userSettingsFilename).c_str(), adjustFilenameCase(fn).c_str());
fn = getUserDataFolder() + "/_mods";
if (!exists(fn))
Linux_CopyTree(core->adjustFilenameCase("_mods").c_str(), core->adjustFilenameCase(fn).c_str());
Linux_CopyTree(adjustFilenameCase("_mods").c_str(), adjustFilenameCase(fn).c_str());
#endif
createDir(getUserDataFolder());
@ -878,12 +880,7 @@ This build is not yet final, and as such there are a couple things lacking. They
this->setBaseTextureDirectory("gfx/");
bool mipmapsEnabled=true;
bool fullscreen = true;
int joystickMode = 0;
int dsq_filter = 0;
voiceOversEnabled = true;
@ -903,8 +900,6 @@ This build is not yet final, and as such there are a couple things lacking. They
exit_error(os.str());
}
setFilter(dsq_filter);
useFrameBuffer = user.video.fbuffer;
if (isDeveloperKeys())
@ -912,13 +907,6 @@ This build is not yet final, and as such there are a couple things lacking. They
maxPages = 600/saveSlotPageSize;
}
if (mipmapsEnabled)
debugLog("Mipmaps Enabled");
else
debugLog("Mipmaps Disabled");
Texture::useMipMaps = mipmapsEnabled;
if (isDeveloperKeys())
debugLog("DeveloperKeys Enabled");
else
@ -974,9 +962,7 @@ This build is not yet final, and as such there are a couple things lacking. They
initInputLibrary();
debugLog("OK");
joystickMode = user.control.joystickEnabled;
if (joystickMode)
if (user.control.joystickEnabled)
{
debugLog("Init Joystick Library...");
initJoystickLibrary();
@ -1320,15 +1306,6 @@ This build is not yet final, and as such there are a couple things lacking. They
debugLog("9");
profRender = 0;
#ifdef Prof_ENABLED
profRender = new ProfRender();
profRender->alpha = 0;
addRenderObject(profRender, LR_DEBUG_TEXT);
#endif
fpsText = new DebugFont;
{
fpsText->color = Vector(1,1,1);
@ -1409,7 +1386,7 @@ This build is not yet final, and as such there are a couple things lacking. They
{
float trans = 0.5;
overlay->alpha.interpolateTo(1, trans);
core->main(trans);
core->run(trans);
}
removeRenderObject(loading);
@ -1622,19 +1599,6 @@ int DSQ::getEntityLayerToLayer(int lcode)
return 0;
}
void DSQ::setFilter(int ds)
{
dsq_filter = ds;
if (dsq_filter == 0)
{
Texture::filter = GL_LINEAR;
}
else if (dsq_filter == 2)
{
Texture::filter = GL_NEAREST;
}
}
void DSQ::setStory()
{
std::string flagString = getUserInputString(dsq->continuity.stringBank.get(2014), "0");
@ -1642,7 +1606,7 @@ void DSQ::setStory()
std::istringstream is(flagString);
is >> flag;
core->main(0.2);
core->run(0.2);
std::ostringstream os;
os << dsq->continuity.getFlag(flag);
flagString = getUserInputString(dsq->continuity.stringBank.get(2015), os.str());
@ -1825,8 +1789,6 @@ void DSQ::toggleConsole()
console->alpha.interpolateTo(1, 0.1);
cmDebug->alpha.interpolateTo(1, 0.1);
fpsText->alpha.interpolateTo(1, 0.1);
if (profRender)
profRender->alpha.interpolateTo(1, 0.1);
RenderObject::renderPaths = true;
}
else if (console->alpha == 1)
@ -1834,8 +1796,6 @@ void DSQ::toggleConsole()
console->alpha.interpolateTo(0, 0.1);
cmDebug->alpha.interpolateTo(0, 0.1);
fpsText->alpha.interpolateTo(0, 0.1);
if (profRender)
profRender->alpha.interpolateTo(0, 0.1);
RenderObject::renderPaths = false;
}
}
@ -1972,11 +1932,11 @@ void DSQ::applyPatches()
loadMods();
for (std::set<std::string>::iterator it = activePatches.begin(); it != activePatches.end(); ++it)
for (std::vector<std::string>::iterator it = activePatches.begin(); it != activePatches.end(); ++it)
for(int i = 0; i < modEntries.size(); ++i)
if(modEntries[i].type == MODTYPE_PATCH)
if(!nocasecmp(modEntries[i].path.c_str(), it->c_str()))
applyPatch(modEntries[i].path);
_applyPatch(modEntries[i].path);
#endif
#endif
}
@ -1993,14 +1953,14 @@ static void refr_pushback(ttvfs::DirBase *vd, void *user)
static void refr_insert(VFILE *vf, void *user)
{
// texture names are like: "naija/naija2-frontleg3" - no .png extension, and no gfx/ path
std::set<std::string>*files = (std::set<std::string>*)user;
std::vector<std::string>*files = (std::vector<std::string>*)user;
std::string t = vf->fullname();
size_t dotpos = t.rfind('.');
size_t pathstart = t.find("gfx/");
if(dotpos == std::string::npos || pathstart == std::string::npos || dotpos < pathstart)
return; // whoops
files->insert(t.substr(pathstart + 4, dotpos - (pathstart + 4)));
files->push_back(t.substr(pathstart + 4, dotpos - (pathstart + 4)));
}
@ -2010,7 +1970,7 @@ static void refr_insert(VFILE *vf, void *user)
void DSQ::refreshResourcesForPatch(const std::string& name)
{
std::list<std::string> left;
std::set<std::string> files;
std::vector<std::string> files;
left.push_back(mod.getBaseModPath() + name + "/gfx");
ttvfs::DirView view;
do
@ -2025,6 +1985,10 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
}
while(left.size());
std::sort(files.begin(), files.end());
std::vector<std::string>::iterator newend = unique(files.begin(), files.end());
files.erase(newend, files.end());
std::ostringstream os;
os << "refreshResourcesForPatch - " << files.size() << " to refresh";
debugLog(os.str());
@ -2035,8 +1999,14 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
for(int i = 0; i < dsq->resources.size(); ++i)
{
Texture *r = dsq->resources[i];
if(files.find(r->name) != files.end())
r->reload();
bool found = false;
for(size_t i = 0; i < files.size(); ++i)
if(files[i] == r->name)
{
++reloaded;
r->reload();
break;
}
}
}
os.str("");
@ -2047,7 +2017,13 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
void DSQ::refreshResourcesForPatch(const std::string& name) {}
#endif
void DSQ::applyPatch(const std::string& name)
void DSQ::activatePatch(const std::string& name)
{
_applyPatch(name);
activePatches.push_back(name);
}
void DSQ::_applyPatch(const std::string& name)
{
#ifdef BBGE_BUILD_VFS
#ifdef AQUARIA_DEMO
@ -2058,13 +2034,11 @@ void DSQ::applyPatch(const std::string& name)
src += name;
debugLog("Apply patch: " + src);
vfs.Mount(src.c_str(), "");
activePatches.insert(name);
refreshResourcesForPatch(name);
#endif
}
void DSQ::unapplyPatch(const std::string& name)
void DSQ::disablePatch(const std::string& name)
{
#ifdef BBGE_BUILD_VFS
std::string src = mod.getBaseModPath();
@ -2072,11 +2046,22 @@ void DSQ::unapplyPatch(const std::string& name)
debugLog("Unapply patch: " + src);
vfs.Unmount(src.c_str(), "");
activePatches.erase(name);
// preserve order
std::vector<std::string>::iterator it = std::remove(activePatches.begin(), activePatches.end(), name);
activePatches.erase(it, activePatches.end());
refreshResourcesForPatch(name);
#endif
}
bool DSQ::isPatchActive(const std::string& name)
{
for(size_t i = 0; i < activePatches.size(); ++i)
if(activePatches[i] == name)
return true;
return false;
}
void DSQ::playMenuSelectSfx()
{
core->sound->playSfx("MenuSelect");
@ -2177,9 +2162,6 @@ void DSQ::shutdown()
removeRenderObject(versionLabel);
versionLabel = 0;
if (profRender)
removeRenderObject(profRender);
if (screenTransition)
{
screenTransition->destroy();
@ -2191,7 +2173,7 @@ void DSQ::shutdown()
screenTransition = 0;
core->main(0.1);
core->run(0.1);
overlay = 0;
overlay2 = 0;
overlay3 = 0;
@ -2395,7 +2377,7 @@ void DSQ::doSavePoint(const Vector &position)
dsq->game->avatar->skeletalSprite.animate("save", 0, 3);
dsq->game->clearControlHint();
dsq->main(2);
dsq->run(2);
dsq->game->avatar->enableInput();
dsq->game->avatar->revive();
dsq->game->togglePause(1);
@ -2512,7 +2494,7 @@ void DSQ::doModSelect()
inModSelector = true;
main(-1);
run(-1);
clearModSelector();
@ -2767,7 +2749,7 @@ void DSQ::title(bool fade)
dsq->sound->fadeMusic(SFT_OUT, 1);
}
main(1);
run(1);
resetTimer();
@ -2996,7 +2978,7 @@ void DSQ::doSaveSlotMenu(SaveSlotMode ssm, const Vector &position)
resetTimer();
core->main(-1);
core->run(-1);
@ -3126,7 +3108,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl
AquariaGuiElement::currentGuiInputLevel = GUILEVEL_CONFIRM;
dsq->main(t);
dsq->run(t);
float t2 = 0.05;
@ -3197,11 +3179,11 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl
txt->alpha.interpolateTo(1, t2);
addRenderObject(txt, LR_CONFIRM);
dsq->main(t2);
dsq->run(t2);
while (!confirmDone)
{
dsq->main(FRAME_TIME);
dsq->run(FRAME_TIME);
if (countdown > 0) {
countdown -= FRAME_TIME;
if (countdown < 0)
@ -3214,11 +3196,11 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl
txt->alpha.interpolateTo(0, t2);
if (yes) yes->alpha.interpolateTo(0, t2);
if (no) no->alpha.interpolateTo(0, t2);
dsq->main(t2);
dsq->run(t2);
bgLabel->alpha.interpolateTo(0, t);
bgLabel->scale.interpolateTo(Vector(0.5, 0.5), t);
dsq->main(t);
dsq->run(t);
bgLabel->safeKill();
txt->safeKill();
@ -3274,7 +3256,7 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a
bg->show();
main(trans);
run(trans);
std::string text = t;
@ -3383,7 +3365,7 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a
break;
}
inputText->setText(text);
core->main(dt);
core->run(dt);
}
if (blink && !text.empty() && (text[text.size()-1] == '|'))
@ -3394,7 +3376,7 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a
bg->hide();
main(0.2);
run(0.2);
inputText->alpha = 0;
label->alpha = 0;
@ -3499,65 +3481,6 @@ Entity *DSQ::getNextEntity()
return *(iter++);
}
Vector DSQ::getUserInputDirection(std::string labelText)
{
BitmapText *label = new BitmapText(&dsq->font);
label->setFontSize(16);
label->position = Vector(400,200);
label->followCamera = 1;
label->setText(labelText);
addRenderObject(label, LR_HUD);
while (core->getKeyState(KEY_RETURN))
{
core->main(1.0f/30.0f);
}
Vector v;
while (1)
{
v.x = v.y = 0;
if (core->getKeyState(KEY_LEFT)) v.x = -1;
if (core->getKeyState(KEY_RIGHT)) v.x = 1;
if (core->getKeyState(KEY_UP)) v.y = -1;
if (core->getKeyState(KEY_DOWN)) v.y = 1;
if (core->getKeyState(KEY_RETURN))
break;
core->main(1.0f/30.0f);
}
label->alpha = 0;
label->safeKill();
return v;
}
std::string DSQ::getDialogueFilename(const std::string &f)
{
return "dialogue/" + languagePack + "/" + f + ".txt";
}
void DSQ::jumpToSection(InStream &inFile, const std::string &section)
{
if (section.empty()) return;
std::string file = dsq->getDialogueFilename(dialogueFile);
if (!exists(file))
{
debugLog("Could not find dialogue [" + file + "]");
return;
}
inFile.open(core->adjustFilenameCase(file).c_str());
std::string s;
while (std::getline(inFile, s))
{
if (!s.empty())
{
if (s.find("[")!=std::string::npos && s.find(section) != std::string::npos)
{
return;
}
}
}
debugLog("could not find section [" + section + "]");
}
bool DSQ::runScript(const std::string &name, const std::string &function, bool ignoremissing /* = false */)
{
if (!scriptInterface.runScript(name, function, ignoremissing))
@ -3668,7 +3591,7 @@ void DSQ::vision(std::string folder, int num, bool ignoreMusic)
dsq->game->miniMapRender->toggle(0);
fade(1, t);
main(t);
run(t);
// load images
typedef std::list<Quad*> QuadList;
@ -3697,12 +3620,12 @@ void DSQ::vision(std::string folder, int num, bool ignoreMusic)
(*i)->scale.interpolateTo(Vector(1.1,1.1), 0.4);
fade(0, t);
main(t);
run(t);
main(0.1);
run(0.1);
fade(1, t);
main(t);
run(t);
(*i)->alpha = 0;
}
@ -3713,7 +3636,7 @@ void DSQ::vision(std::string folder, int num, bool ignoreMusic)
sound->playSfx("memory-flash");
fade(0, t);
main(t);
run(t);
for (QuadList::iterator i = images.begin(); i != images.end(); i++)
{
@ -3779,7 +3702,7 @@ void DSQ::watch(float t, int canQuit)
}
if (t != 0.0f)
core->main(t);
core->run(t);
else
errorLog("Called Watch with time == 0");
@ -3917,15 +3840,6 @@ void DSQ::onUpdate(float dt)
versionLabel->position = Vector(10 - core->getVirtualOffX(), 575);
}
if (menuSelectDelay > 0)
{
menuSelectDelay -= dt;
if (menuSelectDelay <= 0)
{
menuSelectDelay = 0;
}
}
if (noEffectTimer > 0)
{
noEffectTimer -=dt;
@ -3969,17 +3883,20 @@ void DSQ::onUpdate(float dt)
{
const float thresh = 0.6;
if (core->joystick.anyButton() || !core->joystick.position.isLength2DIn(thresh) || !core->joystick.rightStick.isLength2DIn(thresh))
{
//debugLog("setting joystick input mode");
dsq->setInputMode(INPUT_JOYSTICK);
}
for(size_t i = 0; i < joysticks.size(); ++i)
if(Joystick *j = joysticks[i])
if(j && j->isEnabled())
if (j->anyButton() || !j->position.isLength2DIn(thresh) || !j->rightStick.isLength2DIn(thresh))
{
//debugLog("setting joystick input mode");
dsq->setInputMode(INPUT_JOYSTICK);
}
}
else if (dsq->inputMode != INPUT_MOUSE)
{
if ((!core->mouse.change.isLength2DIn(5) || (core->getMouseButtonState(0) || core->getMouseButtonState(1))) && !core->joystick.anyButton())
if ((!core->mouse.change.isLength2DIn(5) || (core->getMouseButtonState(0) || core->getMouseButtonState(1))) /*&& !core->joystick.anyButton()*/)
{
//debugLog("setting mouse input mode");
dsq->setInputMode(INPUT_MOUSE);
@ -4071,7 +3988,7 @@ void DSQ::onUpdate(float dt)
os << std::endl;
os << "globalScale: " << core->globalScale.x << std::endl;
os << "mousePos:(" << core->mouse.position.x << ", " << core->mouse.position.y << ") mouseChange:(" << core->mouse.change.x << ", " << core->mouse.change.y << ")\n";
os << "joyStick:(" << core->joystick.position.x << ", " << core->joystick.position.y << ")\n";
//os << "joyStick:(" << core->joystick.position.x << ", " << core->joystick.position.y << ")\n";
os << "altState: " << core->getKeyState(KEY_LALT) << " | " << core->getKeyState(KEY_RALT) << std::endl;
os << "PMFree: " << particleManager->getFree() << " Active: " << particleManager->getNumActive() << std::endl;
os << "cameraPos: (" << dsq->cameraPos.x << ", " << dsq->cameraPos.y << ")" << std::endl;
@ -4092,7 +4009,7 @@ void DSQ::onUpdate(float dt)
if (isDeveloperKeys() && fpsText && cmDebug && cmDebug->alpha == 1)
{
std::ostringstream os;
os << "FPS: " << core->fps << " | ROC: " << core->renderObjectCount << " | RC: " << Core::dbg_numRenderCalls << " | RES: " << core->resources.size();
os << "FPS: " << core->fps << " | ROC: " << core->renderObjectCount << " | RC: " << g_dbg_numRenderCalls << " | RES: " << core->resources.size();
os << " | p: " << core->processedRenderObjectCount << " | t: " << core->totalRenderObjectCount;
os << " | s: " << dsq->continuity.seconds;
os << " | sndQ: " << core->dbg_numThreadDecoders;
@ -4195,7 +4112,7 @@ bool DSQ::isScriptRunning()
void DSQ::delay(float dt)
{
core->main(dt);
core->run(dt);
}
void DSQ::fade(float alpha, float time)

File diff suppressed because it is too large Load diff

91
Aquaria/Damage.h Normal file
View file

@ -0,0 +1,91 @@
#ifndef AQUARIA_DAMAGE_H
#define AQUARIA_DAMAGE_H
#include "Vector.h"
class Shot;
class Bone;
class Entity;
enum FormType;
enum DamageType
{
DT_NONE = -1,
DT_ENEMY = 0,
DT_ENEMY_ENERGYBLAST = 1,
DT_ENEMY_SHOCK = 2,
DT_ENEMY_BITE = 3,
DT_ENEMY_TRAP = 4,
DT_ENEMY_WEB = 5,
DT_ENEMY_BEAM = 6,
DT_ENEMY_GAS = 7,
DT_ENEMY_INK = 8,
DT_ENEMY_POISON = 9,
DT_ENEMY_ACTIVEPOISON = 10,
DT_ENEMY_CREATOR = 11,
DT_ENEMY_MANTISBOMB = 12,
DT_ENEMY_REALMAX ,
DT_ENEMY_MAX = 13,
DT_AVATAR = 1000,
DT_AVATAR_ENERGYBLAST = 1001,
DT_AVATAR_SHOCK = 1002,
DT_AVATAR_BITE = 1003,
DT_AVATAR_VOMIT = 1004,
DT_AVATAR_ACID = 1005,
DT_AVATAR_SPORECHILD = 1006,
DT_AVATAR_LIZAP = 1007,
DT_AVATAR_NATURE = 1008,
DT_AVATAR_ENERGYROLL = 1009,
DT_AVATAR_VINE = 1010,
DT_AVATAR_EAT = 1011,
DT_AVATAR_EAT_BASICSHOT = 1011,
DT_AVATAR_EAT_MAX = 1012,
DT_AVATAR_LANCEATTACH = 1013,
DT_AVATAR_LANCE = 1014,
DT_AVATAR_CREATORSHOT = 1015,
DT_AVATAR_DUALFORMLI = 1016,
DT_AVATAR_DUALFORMNAIJA = 1017,
DT_AVATAR_BUBBLE = 1018,
DT_AVATAR_SEED = 1019,
DT_AVATAR_PET = 1020,
DT_AVATAR_PETNAUTILUS = 1021,
DT_AVATAR_PETBITE = 1022,
DT_AVATAR_REALMAX ,
DT_AVATAR_MAX = 1030,
DT_TOUCH = 1031,
DT_CRUSH = 1032,
DT_SPIKES = 1033,
DT_STEAM = 1034,
DT_WALLHURT = 1035,
DT_REALMAX
};
struct DamageData
{
DamageData()
{
damage = 0;
attacker = 0;
bone = 0;
damageType = DT_TOUCH;
form = (FormType)0;
shot = 0;
effectTime = 0;
useTimer = true;
}
FormType form;
DamageType damageType;
Entity *attacker;
Bone *bone;
float damage;
Vector hitPos;
Shot *shot;
float effectTime;
bool useTimer;
};
#endif

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DSQ.h"
#include "Game.h"
#include "ttvfs_stdio.h"
Emote::Emote()
{

View file

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ScriptedEntity.h"
#include "Shot.h"
#include "PathFinding.h"
#include "Hair.h"
void Entity::stopPull()
@ -1411,17 +1411,25 @@ void Entity::moveOutOfWall()
}
}
void Entity::clearDamageTargets()
{
disabledDamageTypes.clear();
}
void Entity::setDamageTarget(DamageType dt, bool v)
{
if (v)
disabledDamageTypes.erase(dt);
{
for(size_t i = 0; i < disabledDamageTypes.size(); ++i)
{
if(disabledDamageTypes[i] == dt)
{
disabledDamageTypes[i] = disabledDamageTypes.back();
disabledDamageTypes.pop_back();
break;
}
}
}
else
disabledDamageTypes.insert(dt);
{
if(isDamageTarget(dt))
disabledDamageTypes.push_back(dt);
}
}
void Entity::setEatType(EatType et, const std::string &file)
@ -1437,22 +1445,25 @@ void Entity::setEatType(EatType et, const std::string &file)
void Entity::setAllDamageTargets(bool v)
{
if (v)
clearDamageTargets(); // clear all disabled -> all allowed now
else
disabledDamageTypes.clear();
if(!v)
{
for (int i = DT_ENEMY; i < DT_ENEMY_REALMAX; i++)
disabledDamageTypes.insert(DamageType(i));
disabledDamageTypes.push_back(DamageType(i));
for (int i = DT_AVATAR; i < DT_AVATAR_REALMAX; i++)
disabledDamageTypes.insert(DamageType(i));
disabledDamageTypes.push_back(DamageType(i));
for (int i = DT_AVATAR_MAX; i < DT_REALMAX; i++)
disabledDamageTypes.insert(DamageType(i));
disabledDamageTypes.push_back(DamageType(i));
}
}
bool Entity::isDamageTarget(DamageType dt)
{
return disabledDamageTypes.find(dt) == disabledDamageTypes.end();
const size_t sz = disabledDamageTypes.size();
for(size_t i = 0; i < sz; ++i)
if(disabledDamageTypes[i] == dt)
return false;
return true;
}
float Entity::getHealthPerc()
@ -2790,3 +2801,8 @@ MinimapIcon *Entity::ensureMinimapIcon()
minimapIcon = new MinimapIcon;
return minimapIcon;
}
bool Entity::isNormalLayer() const
{
return layer == LR_ENTITIES || layer == LR_ENTITIES0 || layer == LR_ENTITIES2 || layer == LR_ENTITIES_MINUS2 || layer == LR_ENTITIES_MINUS3;
}

View file

@ -24,18 +24,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/StateMachine.h"
#include "../BBGE/SkeletalSprite.h"
#include "../BBGE/ScriptObject.h"
#include "SoundManager.h"
#include "DSQ.h"
#include "Path.h"
#include "Hair.h"
#include "TileVector.h"
#include "tinyxml2.h"
using namespace tinyxml2;
#include "Damage.h"
#include "GameStructs.h"
class ManaBall;
class Path;
struct MinimapIcon;
class Hair;
class Entity;
struct lua_State;
struct BoneLock
{
@ -49,156 +49,6 @@ struct BoneLock
int collisionMaskIndex;
};
enum EV
{
EV_WALLOUT = 0,
EV_WALLTRANS = 1,
EV_CLAMPING = 2,
EV_SWITCHCLAMP = 3,
EV_CLAMPTRANSF = 4,
EV_MOVEMENT = 5,
EV_COLLIDE = 6,
EV_TOUCHDMG = 7,
EV_FRICTION = 8,
EV_LOOKAT = 9,
EV_CRAWLING = 10,
EV_ENTITYDIED = 11,
EV_TYPEID = 12,
EV_COLLIDELEVEL = 13,
EV_BONELOCKED = 14,
EV_FLIPTOPATH = 15,
EV_NOINPUTNOVEL = 16,
EV_VINEPUSH = 17,
EV_BEASTBURST = 18, // if 1: will not collide with beast on touchAvatarDamage, if 0: will
EV_MINIMAP = 19, // should the entity show up on the minimap?
EV_SOULSCREAMRADIUS = 20, // 0-n: size of radius for naija's dual form scream attack, -1: always hit
EV_WEBSLOW = 21, // 100 by default, multiplied by dt and then divided into vel
EV_NOAVOID = 22, // if 1: doEntityAvoidance() will ignore this entity
EV_MAX = 23
};
enum DamageType
{
DT_NONE = -1,
DT_ENEMY = 0,
DT_ENEMY_ENERGYBLAST = 1,
DT_ENEMY_SHOCK = 2,
DT_ENEMY_BITE = 3,
DT_ENEMY_TRAP = 4,
DT_ENEMY_WEB = 5,
DT_ENEMY_BEAM = 6,
DT_ENEMY_GAS = 7,
DT_ENEMY_INK = 8,
DT_ENEMY_POISON = 9,
DT_ENEMY_ACTIVEPOISON = 10,
DT_ENEMY_CREATOR = 11,
DT_ENEMY_MANTISBOMB = 12,
DT_ENEMY_REALMAX ,
DT_ENEMY_MAX = 13,
DT_AVATAR = 1000,
DT_AVATAR_ENERGYBLAST = 1001,
DT_AVATAR_SHOCK = 1002,
DT_AVATAR_BITE = 1003,
DT_AVATAR_VOMIT = 1004,
DT_AVATAR_ACID = 1005,
DT_AVATAR_SPORECHILD = 1006,
DT_AVATAR_LIZAP = 1007,
DT_AVATAR_NATURE = 1008,
DT_AVATAR_ENERGYROLL = 1009,
DT_AVATAR_VINE = 1010,
DT_AVATAR_EAT = 1011,
DT_AVATAR_EAT_BASICSHOT = 1011,
DT_AVATAR_EAT_MAX = 1012,
DT_AVATAR_LANCEATTACH = 1013,
DT_AVATAR_LANCE = 1014,
DT_AVATAR_CREATORSHOT = 1015,
DT_AVATAR_DUALFORMLI = 1016,
DT_AVATAR_DUALFORMNAIJA = 1017,
DT_AVATAR_BUBBLE = 1018,
DT_AVATAR_SEED = 1019,
DT_AVATAR_PET = 1020,
DT_AVATAR_PETNAUTILUS = 1021,
DT_AVATAR_PETBITE = 1022,
DT_AVATAR_REALMAX ,
DT_AVATAR_MAX = 1030,
DT_TOUCH = 1031,
DT_CRUSH = 1032,
DT_SPIKES = 1033,
DT_STEAM = 1034,
DT_WALLHURT = 1035,
DT_REALMAX
};
enum EatType
{
EAT_NONE = -1,
EAT_DEFAULT = 0,
EAT_FILE = 1,
EAT_MAX
};
enum ObsCheck
{
OBSCHECK_RANGE = 0,
OBSCHECK_4DIR = 1,
OBSCHECK_DOWN = 2,
OBSCHECK_8DIR = 3
};
class Shot;
struct DamageData
{
DamageData()
{
damage = 0;
attacker = 0;
bone = 0;
damageType = DT_TOUCH;
form = (FormType)0;
shot = 0;
effectTime = 0;
useTimer = true;
}
FormType form;
DamageType damageType;
Entity *attacker;
Bone *bone;
float damage;
Vector hitPos;
Shot *shot;
float effectTime;
bool useTimer;
};
enum EntityType
{
ET_NOTYPE =-1,
ET_AVATAR =0,
ET_ENEMY =1,
ET_PET =2,
ET_FLOCK =3,
ET_NEUTRAL =4,
ET_INGREDIENT =5
};
enum EntityProperty
{
EP_SOLID =0,
EP_MOVABLE =1,
EP_BATTERY =2,
EP_BLOCKER =3,
EP_MAX =4
};
enum BounceType
{
BOUNCE_NONE = -1,
BOUNCE_SIMPLE = 0,
BOUNCE_REAL = 1
};
class Entity : public Quad, public StateMachine, public SoundHolder
{
public:
@ -271,8 +121,6 @@ public:
Entity *followEntity;
Entity *ridingOnEntity;
bool canBeTargetedByAvatar;
virtual void saveExtraData(XMLElement *xml){}
virtual void loadExtraData(XMLElement *xml){}
Vector startPos;
void getEXP(unsigned int exp);
void rotateToVec(Vector addVec, float time, float offsetAngle=0);
@ -361,10 +209,7 @@ public:
void doFriction(float dt);
void doFriction(float dt, float len);
bool isNormalLayer() const
{
return layer == LR_ENTITIES || layer == LR_ENTITIES0 || layer == LR_ENTITIES2 || layer == LR_ENTITIES_MINUS2 || layer == LR_ENTITIES_MINUS3;
}
bool isNormalLayer() const;
void watchEntity(Entity *e);
void idle();
int followPos;
@ -400,12 +245,11 @@ public:
std::string deathSound;
virtual std::string getIdleAnimName();
void clearDamageTargets();
void setAllDamageTargets(bool v);
void setDamageTarget(DamageType dt, bool v);
bool isDamageTarget(DamageType dt);
typedef std::set<DamageType> DisabledDamageTypes;
typedef std::vector<DamageType> DisabledDamageTypes;
int targetRange;
int getTargetRange() { return targetRange; }

View file

@ -26,11 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/RoundedRect.h"
#include "../BBGE/SimpleIStringStream.h"
#include "ttvfs_stdio.h"
#include "ReadXML.h"
#include "RenderBase.h"
#include "Game.h"
#include "GridRender.h"
#include "WaterSurfaceRender.h"
#include "ScriptedEntity.h"
#include "AutoMap.h"
#include "FlockEntity.h"
#include "SchoolFish.h"
#include "Avatar.h"
@ -38,6 +41,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Web.h"
#include "StatsAndAchievements.h"
#include "InGameMenu.h"
#include "ManaBall.h"
#include "Spore.h"
#include "Ingredient.h"
#include "Beam.h"
#include "Hair.h"
static const float MENUPAGETRANSTIME = 0.2;
@ -3167,7 +3176,7 @@ void Game::applyState()
core->resetTimer();
avatar->disableInput();
core->main(0.5);
core->run(0.5);
avatar->enableInput();
core->resetTimer();
}
@ -3181,10 +3190,10 @@ void Game::applyState()
dsq->transitionSaveSlots();
dsq->overlay->alpha = 0;
dsq->main(0.5);
dsq->run(0.5);
dsq->toggleCursor(true);
dsq->tfader->alpha.interpolateTo(0, 0.2);
dsq->main(0.21);
dsq->run(0.21);
dsq->clearSaveSlots(false);
}
@ -5010,7 +5019,7 @@ void Game::removeState()
dsq->overlay->color = 0;
dsq->overlay->alpha.interpolateTo(1, fadeTime);
dsq->main(fadeTime);
dsq->run(fadeTime);
dsq->rumble(0,0,0);
@ -5248,14 +5257,30 @@ void Game::learnedRecipe(Recipe *r, bool effects)
void Game::setIgnoreAction(AquariaActions ac, bool ignore)
{
if (ignore)
ignoredActions.insert(ac);
{
if(!isIgnoreAction(ac))
ignoredActions.push_back(ac);
}
else
ignoredActions.erase(ac);
{
for(size_t i = 0; i < ignoredActions.size(); ++i)
{
if(ignoredActions[i] == ac)
{
ignoredActions[i] = ignoredActions.back();
ignoredActions.pop_back();
break;
}
}
}
}
bool Game::isIgnoreAction(AquariaActions ac) const
{
return ignoredActions.find(ac) != ignoredActions.end();
for(size_t i = 0; i < ignoredActions.size(); ++i)
if(ignoredActions[i] == ac)
return true;
return false;
}
void Game::onContinuityReset()

View file

@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "AquariaMenuItem.h"
#include "ScriptedEntity.h"
#include "TileVector.h"
#include "Shot.h"
#include "AquariaProgressBar.h"
#include "tinyxml2.h"
@ -43,6 +42,7 @@ class SongLineRender;
class AutoMap;
class DebugButton;
class WorldMapRender;
class Shot;
class InGameMenu;
// FIXME: this should be made dynamic, or at least a power of 2
@ -65,6 +65,9 @@ class GridRender;
class MiniMapRender;
class WaterSurfaceRender;
class ToolTip;
class Ingredient;
class ManaBall;
class Beam;
#include "Path.h"
@ -109,39 +112,6 @@ struct MinimapIcon
static const Vector defaultSize;
};
class ManaBall : public Quad
{
public:
ManaBall(Vector pos, float a);
void destroy();
bool isUsed();
void use(Entity *entity);
ParticleEffect healEmitter;
protected:
float lifeSpan;
bool used;
float amount;
void onUpdate(float dt);
};
class Ingredient : public Entity
{
public:
Ingredient(const Vector &pos, IngredientData *data, int amount=1);
void destroy();
IngredientData *getIngredientData();
void eat(Entity *e);
bool hasIET(IngredientEffectType iet);
protected:
bool isRotKind();
IngredientData *data;
bool used, gone;
float lifeSpan;
int amount;
void onUpdate(float dt);
};
typedef std::list<Ingredient*> Ingredients;
class ElementTemplate
@ -825,7 +795,7 @@ protected:
void warpCameraTo(Vector position);
std::set<int> ignoredActions;
std::vector<int> ignoredActions;
private:
Ingredients ingredients;

468
Aquaria/GameEnums.h Normal file
View file

@ -0,0 +1,468 @@
#ifndef GAMEENUMS_H
#define GAMEENUMS_H
enum WorldMapRevealMethod
{
REVEAL_UNSPECIFIED = -1,
REVEAL_DEFAULT = 0,
REVEAL_PARTIAL = 1 // Not visited areas have zero alpha (invisible)
};
enum CursorType
{
CURSOR_NONE = -1,
CURSOR_NORMAL = 0,
CURSOR_SWIM = 1,
CURSOR_BURST = 2,
CURSOR_SING = 3,
CURSOR_LOOK = 4
};
enum AquariaActions
{
ACTION_PRIMARY =0,
ACTION_SECONDARY =1,
ACTION_ESC =2,
ACTION_TOGGLESCENEEDITOR =3,
ACTION_TOGGLEWORLDMAP =4,
ACTION_TOGGLEGRID =5,
ACTION_MENULEFT =6,
ACTION_MENURIGHT =7,
ACTION_MENUUP =8,
ACTION_MENUDOWN =9,
ACTION_PREVPAGE,
ACTION_NEXTPAGE,
ACTION_COOKFOOD,
ACTION_FOODLEFT,
ACTION_FOODRIGHT,
ACTION_FOODDROP,
ACTION_TOGGLEMENU,
ACTION_SWIMUP = 100,
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, // currently unused
ACTION_REVERT,
ACTION_ZOOMIN = 200,
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,
};
enum AuraType
{
AURA_NONE = -1,
AURA_SHIELD = 0,
AURA_THING = 1,
AURA_HEAL = 2
};
enum SongType
{
SONG_NONE = -1,
SONG_HEAL = 0,
SONG_ENERGYFORM = 1,
SONG_SONGDOOR1 = 2,
SONG_SPIRITFORM = 3,
SONG_BIND = 4,
SONG_NATUREFORM = 5,
SONG_BEASTFORM = 6,
SONG_SHIELDAURA = 7,
SONG_SONGDOOR2 = 8,
SONG_DUALFORM = 9,
SONG_FISHFORM = 10,
SONG_SUNFORM = 11,
SONG_LI = 12,
SONG_TIME = 13,
SONG_LANCE = 14,
SONG_MAP = 15,
SONG_ANIMA = 16,
SONG_MAX
};
const int numForms = 7;
enum FormType
{
FORM_NONE = -1,
FORM_NORMAL = 0,
FORM_ENERGY ,
FORM_BEAST ,
FORM_NATURE ,
FORM_SPIRIT ,
FORM_DUAL ,
FORM_FISH ,
FORM_SUN ,
FORM_MAX
};
enum FormUpgradeType
{
FORMUPGRADE_ENERGY1 =0,
FORMUPGRADE_ENERGY2 ,
FORMUPGRADE_BEAST ,
FORMUPGRADE_MAX
};
// defined by windows includes
#undef INPUT_MOUSE
#undef INPUT_KEYBOARD
enum InputMode
{
INPUT_MOUSE = 0,
INPUT_JOYSTICK = 1,
INPUT_KEYBOARD = 2
};
enum EFXType
{
EFX_NONE =-1,
EFX_SEGS =0,
EFX_ALPHA ,
EFX_WAVY ,
EFX_MAX
};
enum EmoteType
{
EMOTE_NAIJAEVILLAUGH = 0,
EMOTE_NAIJAGIGGLE = 1,
EMOTE_NAIJALAUGH = 2,
EMOTE_NAIJASADSIGH = 3,
EMOTE_NAIJASIGH = 4,
EMOTE_NAIJAWOW = 5,
EMOTE_NAIJAUGH = 6,
EMOTE_NAIJALOW = 7,
EMOTE_NAIJALI = 8
};
enum WorldType
{
WT_NONE = -1,
WT_NORMAL = 0,
WT_SPIRIT = 1
};
enum VisualEffectsType
{
VFX_NONE = -1,
VFX_SHOCK = 0,
VFX_RIPPLE = 1,
VFX_SHOCKHIT = 2,
VFX_MAX = 3
};
enum Layers
{
// GAME WILL CLEAR THESE
LR_ZERO = 0,
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 ,
LR_MAX
};
enum IngredientType
{
IT_NONE = -1,
IT_LEAF = 0,
IT_MEAT ,
IT_EGG ,
IT_OIL ,
IT_BERRY ,
IT_MUSHROOM ,
IT_BULB ,
IT_TENTACLE ,
IT_ICECHUNK ,
IT_PART ,
IT_SHELL ,
IT_BONE ,
IT_INGREDIENTSEND ,
IT_FOOD = 100,
IT_SOUP = 101,
IT_CAKE = 103,
IT_ICECREAM = 105,
IT_LOAF = 107,
IT_PEROGI = 108,
IT_POULTICE = 109,
IT_ROLL = 110,
IT_ANYTHING = 200,
IT_MAX
};
enum IngredientEffectType
{
IET_NONE = -1,
IET_HP = 0,
IET_DEFENSE = 1,
IET_SPEED = 2,
IET_RANDOM = 3,
IET_MAXHP = 4,
IET_INVINCIBLE = 5,
IET_TRIP = 6,
IET_REGEN = 7,
IET_LI = 8,
IET_FISHPOISON = 9,
IET_BITE = 10,
IET_EAT = 11,
IET_LIGHT = 12,
IET_YUM = 13,
IET_PETPOWER = 14,
IET_WEB = 15,
IET_ENERGY = 16,
IET_POISON = 17,
IET_BLIND = 18,
IET_ALLSTATUS = 19,
IET_SCRIPT = 20,
IET_MAX
};
enum FoodSortType
{
FOODSORT_BYTYPE = 0,
FOODSORT_BYHEAL = 1,
FOODSORT_BYINGREDIENT = 2,
MAX_FOODSORT
};
enum GameSaveFlags
{
FLAG_LI = 1000,
FLAG_LICOMBAT = 1001,
FLAG_COOKS = 21,
FLAG_PET_ACTIVE = 600,
FLAG_PET_NAMESTART = 601,
FLAG_UPGRADE_WOK = 620,
FLAG_SEALOAFANNOYANCE = 801,
FLAG_SECRET01 = 234,
FLAG_SECRET02 = 235,
FLAG_SECRET03 = 236,
FLAG_COLLECTIBLE_START = 500,
FLAG_COLLECTIBLE_END = 600,
MAX_FLAGS = 1024
};
enum EV
{
EV_WALLOUT = 0,
EV_WALLTRANS = 1,
EV_CLAMPING = 2,
EV_SWITCHCLAMP = 3,
EV_CLAMPTRANSF = 4,
EV_MOVEMENT = 5,
EV_COLLIDE = 6,
EV_TOUCHDMG = 7,
EV_FRICTION = 8,
EV_LOOKAT = 9,
EV_CRAWLING = 10,
EV_ENTITYDIED = 11,
EV_TYPEID = 12,
EV_COLLIDELEVEL = 13,
EV_BONELOCKED = 14,
EV_FLIPTOPATH = 15,
EV_NOINPUTNOVEL = 16,
EV_VINEPUSH = 17,
EV_BEASTBURST = 18, // if 1: will not collide with beast on touchAvatarDamage, if 0: will
EV_MINIMAP = 19, // should the entity show up on the minimap?
EV_SOULSCREAMRADIUS = 20, // 0-n: size of radius for naija's dual form scream attack, -1: always hit
EV_WEBSLOW = 21, // 100 by default, multiplied by dt and then divided into vel
EV_NOAVOID = 22, // if 1: doEntityAvoidance() will ignore this entity
EV_MAX = 23
};
enum EatType
{
EAT_NONE = -1,
EAT_DEFAULT = 0,
EAT_FILE = 1,
EAT_MAX
};
enum ObsCheck
{
OBSCHECK_RANGE = 0,
OBSCHECK_4DIR = 1,
OBSCHECK_DOWN = 2,
OBSCHECK_8DIR = 3
};
enum EntityType
{
ET_NOTYPE =-1,
ET_AVATAR =0,
ET_ENEMY =1,
ET_PET =2,
ET_FLOCK =3,
ET_NEUTRAL =4,
ET_INGREDIENT =5
};
enum EntityProperty
{
EP_SOLID =0,
EP_MOVABLE =1,
EP_BATTERY =2,
EP_BLOCKER =3,
EP_MAX =4
};
enum BounceType
{
BOUNCE_NONE = -1,
BOUNCE_SIMPLE = 0,
BOUNCE_REAL = 1
};
#endif

54
Aquaria/GameStructs.cpp Normal file
View file

@ -0,0 +1,54 @@
#include "Base.h"
#include "GameStructs.h"
Recipe::Recipe()
{
known = false;
index = -1;
}
void Recipe::clear()
{
types.clear();
names.clear();
result = "";
resultDisplayName = "";
known = false;
}
void Recipe::learn()
{
known = true;
}
void Recipe::addName(const std::string &name)
{
int i = 0;
for (; i < names.size(); i++)
{
if (names[i].name == name)
{
names[i].amount++;
break;
}
}
if (i == names.size())
names.push_back(RecipeName(name));
}
void Recipe::addType(IngredientType type, const std::string &typeName)
{
int i = 0;
for (; i < types.size(); i++)
{
if (types[i].type == type)
{
types[i].amount++;
break;
}
}
if (i == types.size())
types.push_back(RecipeType(type, typeName));
}

195
Aquaria/GameStructs.h Normal file
View file

@ -0,0 +1,195 @@
#ifndef GAMESTRUCTS_H
#define GAMESTRUCTS_H
#include <vector>
#include <string>
#include "Vector.h"
#include "GameEnums.h"
struct ElementEffect
{
public:
int type;
int segsx, segsy;
float segs_dgox, segs_dgoy, segs_dgmx, segs_dgmy, segs_dgtm, segs_dgo;
float wavy_radius, wavy_min, wavy_max;
bool wavy_flip;
InterpolatedVector alpha;
InterpolatedVector color;
int blendType;
};
struct EmoteData
{
EmoteData()
{
index = -1; variations = 0;
}
int index;
std::string name;
int variations;
};
struct GemData
{
GemData() { canMove=false; blink = false; }
std::string name;
std::string userString;
std::string mapName;
Vector pos;
bool canMove;
bool blink; // not saved
};
struct BeaconData
{
BeaconData(){ index=-1; on=0; }
int index;
Vector pos,color;
bool on;
};
struct PetData
{
std::string namePart;
};
struct TreasureDataEntry
{
TreasureDataEntry() { sz = 1; use = 0;}
std::string gfx;
float sz;
int use;
};
struct FoodSortOrder
{
FoodSortOrder(IngredientType t, IngredientEffectType et = IET_NONE, std::string name="", int effectAmount=0)
{ type = t; effectType = et; this->name = name; this->effectAmount=effectAmount;}
FoodSortOrder() { type = IT_NONE; effectType = IET_NONE; }
std::string name;
IngredientType type;
IngredientEffectType effectType;
int effectAmount;
};
struct EatData
{
EatData() { ammoUnitSize=getUnits=1; health=0; ammo=1;}
std::string name, shot;
int ammoUnitSize, getUnits, ammo;
float health;
};
struct PECue
{
PECue(std::string name, Vector pos, float rot, float t)
: name(name), pos(pos), rot(rot), t(t) {}
std::string name;
Vector pos;
float rot;
float t;
};
struct RecipeType
{
RecipeType(IngredientType type, const std::string &typeName) : type(type), amount(1) { this->typeName = typeName; }
RecipeType() { amount = 1; type = IT_NONE; }
IngredientType type;
int amount;
std::string typeName;
};
struct RecipeName
{
RecipeName(const std::string &name) : name(name), amount(1) {}
RecipeName() : amount(1) {}
std::string name;
int amount;
};
class Recipe
{
public:
Recipe();
std::vector<RecipeType> types;
std::vector<RecipeName> names;
std::string result;
std::string resultDisplayName;
int index;
void addName(const std::string &name);
void addType(IngredientType type, const std::string &typeName);
void clear();
void learn();
bool isKnown() { return known; }
protected:
bool known;
};
typedef std::vector<int> SongNotes;
struct Song
{
Song() { index=0; script=0; }
int index;
SongNotes notes;
int script;
};
class Emote
{
public:
Emote();
void load(const std::string &file);
void playSfx(int index);
void update(float dt);
float emoteTimer;
int lastVariation;
typedef std::vector<EmoteData> Emotes;
Emotes emotes;
};
struct IngredientEffect
{
IngredientEffect() : type(IET_NONE), magnitude(0) {}
float magnitude;
IngredientEffectType type;
std::string string;
};
class IngredientData
{
public:
IngredientData(const std::string &name, const std::string &gfx, IngredientType type);
int getIndex() const;
const std::string name, gfx;
std::string displayName;
const IngredientType type;
int amount;
int maxAmount;
int held;
int marked;
bool sorted;
bool rotKind;
bool hasIET(IngredientEffectType iet);
typedef std::vector<IngredientEffect> IngredientEffects;
IngredientEffects effects;
private:
// ensure that IngredientData instances are never copied:
IngredientData(const IngredientData&);
const IngredientData& operator=(const IngredientData&);
};
typedef std::vector<IngredientData*> IngredientDatas;
#endif

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DSQ.h"
#include "ttvfs_stdio.h"
GameplayVariables *vars = 0;

View file

@ -18,7 +18,9 @@ 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.
*/
#include "Shot.h"
#include "GasCloud.h"
#include "Particles.h"
#include "Game.h"
const float pSpawnRate = 1.0;
@ -48,7 +50,7 @@ GasCloud::GasCloud(Entity *source, const Vector &position, const std::string &pa
emitter->setDie(true);
dsq->game->addRenderObject(emitter, LR_PARTICLES);
game->addRenderObject(emitter, LR_PARTICLES);
setEntityType(ET_NEUTRAL);

21
Aquaria/GasCloud.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef GASCLOUD_H
#define GASCLOUD_H
#include "Entity.h"
class GasCloud : public Entity
{
public:
GasCloud(Entity *source, const Vector &position, const std::string &particles, const Vector &color, int radius, float life, float damage=0, bool isMoney=false, float poisonTime=0);
protected:
ParticleEffect *emitter;
std::string gfx, particles;
int radius;
float damage;
float pTimer;
void onUpdate(float dt);
float poisonTime;
Entity *sourceEntity;
};
#endif

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "GridRender.h"
#include "Game.h"
#include "RenderBase.h"
GridRender::GridRender(ObsType obsType) : RenderObject()
{

View file

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Hair.h"
#include "DSQ.h"
#include "RenderBase.h"
Hair::Hair(int nodes, float segmentLength, float hairWidth) : RenderObject()

View file

@ -14,7 +14,6 @@ static InGameMenu *themenu = 0;
std::vector<FoodHolder*> foodHolders;
std::vector<PetSlot*> petSlots;
// ---------------- Constants ----------------------------
static const float MENUPAGETRANSTIME = 0.2;
@ -260,7 +259,7 @@ void FoodHolder::animateLid(bool down, bool longAnim)
{
dsq->sound->playSfx("bubble-lid");
lid->alpha.interpolateTo(1, t);
dsq->main(t);
dsq->run(t);
}
else
{
@ -558,7 +557,7 @@ void FoodSlot::onUpdate(float dt)
Vector wp = getWorldPosition();
if ((themenu->lips->getWorldPosition() - wp).isLength2DIn(32))
{
dsq->menuSelectDelay = 0.5;
themenu->menuSelectDelay = 0.5;
eatMe();
}
@ -599,7 +598,7 @@ void FoodSlot::onUpdate(float dt)
{
if (doubleClickDelay > 0)
{
dsq->menuSelectDelay = 0.5;
themenu->menuSelectDelay = 0.5;
doubleClickDelay = 0;
eatMe();
@ -895,6 +894,7 @@ InGameMenu::InGameMenu()
blurEffectsCheck = 0;
ripplesCheck = 0;
menu_blackout = 0;
menuSelectDelay = 0;
}
InGameMenu::~InGameMenu()
@ -926,6 +926,7 @@ void InGameMenu::reset()
inGameMenuExitState = 0;
optsfxdly = 0;
playingSongInMenu = -1;
menuSelectDelay = 0;
dropIngrNames.clear();
@ -988,17 +989,17 @@ void InGameMenu::action(int id, int state, int source)
{
if (!state && !dsq->isNested())
{
if (dsq->menuSelectDelay == 0)
if (themenu->menuSelectDelay == 0)
{
if (id == ACTION_PREVPAGE)
{
dsq->menuSelectDelay = MENUSELECTDELAY;
themenu->menuSelectDelay = MENUSELECTDELAY;
onPrevTreasurePage();
//menu[5]->setFocus(true);
}
if (id == ACTION_NEXTPAGE)
{
dsq->menuSelectDelay = MENUSELECTDELAY;
themenu->menuSelectDelay = MENUSELECTDELAY;
onNextTreasurePage();
//menu[5]->setFocus(true);
}
@ -1009,11 +1010,11 @@ void InGameMenu::action(int id, int state, int source)
{
if (!state && !dsq->isNested())
{
if (dsq->menuSelectDelay == 0)
if (themenu->menuSelectDelay == 0)
{
if (id == ACTION_PREVPAGE)
{
dsq->menuSelectDelay = MENUSELECTDELAY;
themenu->menuSelectDelay = MENUSELECTDELAY;
if (recipeMenu.on)
recipeMenu.goPrevPage();
else
@ -1021,7 +1022,7 @@ void InGameMenu::action(int id, int state, int source)
}
if (id == ACTION_NEXTPAGE)
{
dsq->menuSelectDelay = MENUSELECTDELAY;
themenu->menuSelectDelay = MENUSELECTDELAY;
if (recipeMenu.on)
recipeMenu.goNextPage();
else
@ -1280,7 +1281,7 @@ void InGameMenu::show(bool ignoreInput, bool optionsOnly, MenuPage menuPage)
toggleMainMenu(false);
dsq->main(t);
dsq->run(t);
dsq->screenTransition->capture();
@ -1353,7 +1354,7 @@ void InGameMenu::show(bool ignoreInput, bool optionsOnly, MenuPage menuPage)
dsq->screenTransition->transition(MENUPAGETRANSTIME);
if (optionsOnly)
dsq->main(-1);
dsq->run(-1);
}
}
@ -1430,7 +1431,7 @@ void InGameMenu::hide(bool effects, bool cancel)
}
if (effects)
core->main(t);
core->run(t);
if (menu_blackout)
{
@ -2882,19 +2883,19 @@ void InGameMenu::onCook()
note3.name = game->getNoteName(3);
handle = dsq->sound->playSfx(note1);
dsq->main(nt2);
dsq->run(nt2);
dsq->sound->fadeSfx(handle, SFT_OUT, ft);
dsq->main(nt);
dsq->run(nt);
handle = dsq->sound->playSfx(note2);
dsq->main(nt2);
dsq->run(nt2);
dsq->sound->fadeSfx(handle, SFT_OUT, ft);
dsq->main(nt);
dsq->run(nt);
handle = dsq->sound->playSfx(note3);
dsq->main(nt2);
dsq->run(nt2);
dsq->sound->fadeSfx(handle, SFT_OUT, ft);
dsq->main(nt);
dsq->run(nt);
}
dsq->sound->playSfx("boil");
@ -2906,9 +2907,9 @@ void InGameMenu::onCook()
}
if (longAnim)
dsq->main(0.5);
dsq->run(0.5);
else
dsq->main(0.2);
dsq->run(0.2);
bool haveLeftovers = true;
for (int i = 0; i < foodHolders.size(); i++)
@ -2945,9 +2946,9 @@ void InGameMenu::onCook()
dsq->spawnParticleEffect("cook-food", Vector(575,250), 0, 0, LR_HUD3, 1);
if (longAnim)
dsq->main(0.5);
dsq->run(0.5);
else
dsq->main(0.2);
dsq->run(0.2);
if (data)
{
@ -2971,7 +2972,7 @@ void InGameMenu::onCook()
dsq->continuity.removeEmptyIngredients();
dsq->main(0.5);
dsq->run(0.5);
dsq->continuity.setFlag(FLAG_COOKS, dsq->continuity.getFlag(FLAG_COOKS)+1);
@ -3869,6 +3870,15 @@ void InGameMenu::updateOptionsMenu(float dt)
void InGameMenu::update(float dt)
{
if (menuSelectDelay > 0)
{
menuSelectDelay -= dt;
if (menuSelectDelay <= 0)
{
menuSelectDelay = 0;
}
}
if (enqueuedPreviewRecipe)
{
updatePreviewRecipe();
@ -3979,7 +3989,7 @@ void InGameMenu::onDebugSave()
{
themenu->hide();
game->clearControlHint();
core->main(0.5);
core->run(0.5);
dsq->game->togglePause(true);
dsq->doSaveSlotMenu(SSM_SAVE);
dsq->game->togglePause(false);

View file

@ -86,9 +86,11 @@ public:
virtual void action(int actionID, int state, int source);
void refreshFoodSlots(bool effects);
RecipeMenu recipeMenu;
float menuSelectDelay;
private:
void updateOptionsMenu(float dt);

View file

@ -18,6 +18,8 @@ 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.
*/
#include "Ingredient.h"
#include "Game.h"
#include "Avatar.h"

25
Aquaria/Ingredient.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef INGREDIENT_H
#define INGREDIENT_H
#include "Entity.h"
class Ingredient : public Entity
{
public:
Ingredient(const Vector &pos, IngredientData *data, int amount=1);
void destroy();
IngredientData *getIngredientData();
void eat(Entity *e);
bool hasIET(IngredientEffectType iet);
protected:
bool isRotKind();
IngredientData *data;
bool used, gone;
float lifeSpan;
int amount;
void onUpdate(float dt);
};
#endif

View file

@ -18,9 +18,12 @@ 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.
*/
#include "States.h"
#include "Intro.h"
#include "../BBGE/AfterEffect.h"
#include "Gradient.h"
#include "DSQ.h"
#include "SkeletalSprite.h"
//class Mappy;
@ -111,7 +114,7 @@ void Intro::endIntro()
dsq->overlay2->color = Vector(1,1,1);
dsq->overlay2->alpha.interpolateTo(1, 1);
dsq->main(1);
dsq->run(1);
dsq->overlay->color = Vector(0,0,0);
dsq->overlay->alpha = 0;
@ -131,7 +134,7 @@ void Intro::endIntro()
bool Intro::waitQuit(float t)
{
dsq->main(t);
dsq->run(t);
return false;
/*
@ -314,7 +317,7 @@ void Intro::update(float dt)
play2.vol = 0.9;
void *windLoop = dsq->sound->playSfx(play2);
dsq->main(3);
dsq->run(3);
dsq->setClearColor(Vector(0.2,0.2,0.21));

31
Aquaria/Intro.h Normal file
View file

@ -0,0 +1,31 @@
#ifndef AQUARIA_INTRO_H
#define AQUARIA_INTRO_H
#include "StateManager.h"
#include "Precacher.h"
class Quad;
class Intro : public StateObject
{
public:
Intro();
void applyState();
void removeState();
void update(float dt);
void endIntro();
bool waitQuit(float t);
protected:
void createMeteor(int layer, Vector pos, Vector off, Vector sz);
void clearMeteors();
std::vector<Quad*>meteors;
bool done;
Precacher cachy;
};
#endif

View file

@ -20,9 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DSQ.h"
#include <fstream>
#ifdef BBGE_BUILD_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#endif
@ -94,7 +97,7 @@ static void CheckConfig(void)
{
DSQ dsql(dsqParam, extraDataDir);
dsql.init();
dsql.main();
dsql.run();
dsql.shutdown();
}

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Game.h"
#include "Avatar.h"
#include "ManaBall.h"
const float MULT_MANABALL_EASY = 1.5;

21
Aquaria/ManaBall.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef MANABALL_H
#define MANABALL_H
#include "Quad.h"
class ManaBall : public Quad
{
public:
ManaBall(Vector pos, float a);
void destroy();
bool isUsed();
void use(Entity *entity);
ParticleEffect healEmitter;
protected:
float lifeSpan;
bool used;
float amount;
void onUpdate(float dt);
};
#endif

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GridRender.h"
#include "Game.h"
#include "Avatar.h"
#include "RenderBase.h"
namespace MiniMapRenderSpace
{

View file

@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DSQ.h"
#include "Game.h"
#include "ReadXML.h"
#include "Shot.h"
static std::string baseModPath = "./_mods/";
@ -170,7 +172,7 @@ void Mod::recache()
if(fname[fname.length() - 1] != '/')
fname += '/';
fname += "precache.txt";
fname = core->adjustFilenameCase(fname);
fname = adjustFilenameCase(fname);
if (exists(fname))
{
modcache.precacheList(fname);
@ -201,7 +203,7 @@ void Mod::start()
dsq->overlay->alpha.interpolateTo(1, t);
core->sound->fadeMusic(SFT_OUT, t*0.9f);
core->main(t);
core->run(t);
core->sound->stopMusic();
@ -272,8 +274,6 @@ void Mod::setActive(bool a)
Shot::loadShotBank(dsq->shotBank1, dsq->shotBank2);
particleManager->loadParticleBank(dsq->particleBank1, dsq->particleBank2);
dsq->setFilter(dsq->dsq_filter);
recache();
}
dsq->game->loadEntityTypeList();

79
Aquaria/Mod.h Normal file
View file

@ -0,0 +1,79 @@
#ifndef AQUARIA_MOD_H
#define AQUARIA_MOD_H
#include "GameEnums.h"
#include "Precacher.h"
namespace tinyxml2
{
class XMLDocument;
class XMLElement;
}
enum ModType
{
MODTYPE_MOD,
MODTYPE_PATCH,
};
struct ModEntry
{
unsigned int id; // index in vector
ModType type;
std::string path;
};
class ModSelectorScreen;
class Mod
{
public:
Mod();
~Mod();
void clear();
void setActive(bool v);
void start();
void stop();
void load(const std::string &path);
void update(float dt);
void recache();
const std::string& getBaseModPath() const;
bool isActive();
bool isDebugMenu();
bool hasWorldMap();
bool isEditorBlocked();
const std::string& getPath() const;
const std::string& getName() const;
void shutdown();
bool isShuttingDown();
static bool loadModXML(tinyxml2::XMLDocument *d, std::string modName);
static ModType getTypeFromXML(tinyxml2::XMLElement *xml);
WorldMapRevealMethod mapRevealMethod;
protected:
bool shuttingDown;
bool active;
bool hasMap;
bool blockEditor;
int doRecache;
int debugMenu;
int enqueueModStart;
void applyStart();
std::string name;
std::string path;
Precacher modcache;
};
#endif

View file

@ -8,7 +8,7 @@
#include "Network.h"
#include "ttvfs.h"
#include "tinyxml2.h"
#include "ReadXML.h"
using namespace tinyxml2;
using Network::NetEvent;

View file

@ -435,7 +435,7 @@ void BasicIcon::onUpdate(float dt)
dsq->modSelectorScr->move(5, true);
else
dsq->modSelectorScr->move(-5, true);
core->main(FRAME_TIME); // HACK: this is necessary to correctly position the mouse on the object after moving the panel
core->run(FRAME_TIME); // HACK: this is necessary to correctly position the mouse on the object after moving the panel
setFocus(true); // re-position mouse
}
}
@ -519,16 +519,23 @@ void ModIcon::onClick()
break;
#endif
std::set<std::string>::iterator it = dsq->activePatches.find(fname);
if(it != dsq->activePatches.end())
bool on = false;
for(size_t i = 0; i < dsq->activePatches.size(); ++i)
if(dsq->activePatches[i] == fname)
{
on = true;
break;
}
if(on)
{
dsq->sound->playSfx("pet-off");
dsq->unapplyPatch(fname);
dsq->disablePatch(fname);
}
else
{
dsq->sound->playSfx("pet-on");
dsq->applyPatch(fname);
dsq->activatePatch(fname);
}
updateStatus();
break;

View file

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/Particles.h"
#include "../BBGE/ScriptObject.h"
#include "ScriptInterface.h"
#include "Rect.h"
#undef PATH_MAX // May be set by a system header.

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "GridRender.h"
#include "RenderBase.h"
PathRender::PathRender() : RenderObject()
{

View file

@ -338,7 +338,7 @@ void RecipeMenu::toggle(bool on, bool watch)
dsq->sound->playSfx("recipemenu-open");
if (watch)
dsq->main(t);
dsq->run(t);
if (!dsq->game->isInGameMenu())
{
@ -371,7 +371,7 @@ void RecipeMenu::toggle(bool on, bool watch)
prevPage->alpha = 0;
if (watch)
dsq->main(t);
dsq->run(t);
}
this->on = on;

View file

@ -27,12 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "DSQ.h"
#include "Avatar.h"
#include "GridRender.h"
#include "Shot.h"
#ifdef AQUARIA_BUILD_SCENEEDITOR // Through end of file
#ifdef BBGE_BUILD_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#endif
@ -404,7 +407,7 @@ void SceneEditor::openMainMenu()
while (core->mouse.buttons.left)
{
core->main(FRAME_TIME);
core->run(FRAME_TIME);
}
addMainMenuItem("LOAD LEVEL... (SHIFT-F1)", 100);
@ -432,7 +435,7 @@ void SceneEditor::openMainMenu()
while (1 && !core->getKeyState(KEY_TAB))
{
core->main(FRAME_TIME);
core->run(FRAME_TIME);
if (execID != -1)
break;
}
@ -2244,7 +2247,7 @@ void SceneEditor::selectEntityFromGroups()
prevEntityPage();
}
core->main(FRAME_TIME);
core->run(FRAME_TIME);
}
destroyEntityPage();

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "SDL.h"
#include "ScriptInterface.h"
#include "../BBGE/ScriptObject.h"
extern "C"
@ -27,6 +28,9 @@ extern "C"
#include "lauxlib.h"
#include "lualib.h"
}
#include "ReadXML.h"
#include "DSQ.h"
#include "Game.h"
#include "Avatar.h"
@ -40,6 +44,12 @@ extern "C"
#include <algorithm>
#include "Gradient.h"
#include "InGameMenu.h"
#include "GasCloud.h"
#include "Ingredient.h"
#include "Beam.h"
#include "Hair.h"
#include "Spore.h"
#include "../BBGE/MathFunctions.h"
@ -812,12 +822,12 @@ static bool findFile_helper(const char *rawname, std::string &fname)
fname += '/';
fname += rawname;
fname = localisePath(fname, dsq->mod.getPath());
fname = core->adjustFilenameCase(fname);
fname = adjustFilenameCase(fname);
if (exists(fname))
return true;
}
fname = localisePath(rawname);
fname = core->adjustFilenameCase(fname);
fname = adjustFilenameCase(fname);
return exists(fname);
}
@ -4118,7 +4128,7 @@ luaFunc(entity_waitForPath)
Entity *e = entity(L);
while (e && e->isFollowingPath())
{
core->main(FRAME_TIME);
core->run(FRAME_TIME);
}
luaReturnNil();
}
@ -4141,7 +4151,7 @@ luaFunc(entity_watchForPath)
Entity *e = entity(L);
while (e && e->isFollowingPath())
{
core->main(FRAME_TIME);
core->run(FRAME_TIME);
}
dsq->game->avatar->enableInput();
@ -4997,26 +5007,6 @@ luaFunc(getWallNormal)
luaReturnVec2(n.x, n.y);
}
luaFunc(incrFlag)
{
std::string f = getString(L, 1);
int v = 1;
if (lua_isnumber(L, 2))
v = lua_tointeger(L, 2);
dsq->continuity.setFlag(f, dsq->continuity.getFlag(f)+v);
luaReturnNil();
}
luaFunc(decrFlag)
{
std::string f = getString(L, 1);
int v = 1;
if (lua_isnumber(L, 2))
v = lua_tointeger(L, 2);
dsq->continuity.setFlag(f, dsq->continuity.getFlag(f)-v);
luaReturnNil();
}
luaFunc(setFlag)
{
@ -6392,11 +6382,11 @@ luaFunc(bedEffects)
{
dsq->overlay->alpha.interpolateTo(1, 2);
dsq->sound->fadeMusic(SFT_OUT, 1);
core->main(1);
core->run(1);
// music goes here
dsq->sound->fadeMusic(SFT_CROSS, 1);
dsq->sound->playMusic("Sleep");
core->main(6);
core->run(6);
Vector bedPosition(lua_tointeger(L, 1), lua_tointeger(L, 2));
if (bedPosition.x == 0 && bedPosition.y == 0)
{
@ -7063,7 +7053,7 @@ luaFunc(watch)
luaFunc(wait)
{
core->main(lua_tonumber(L, 1));
core->run(lua_tonumber(L, 1));
luaReturnNil();
}
@ -7073,13 +7063,13 @@ luaFunc(warpNaijaToEntity)
if (e)
{
dsq->overlay->alpha.interpolateTo(1, 1);
core->main(1);
core->run(1);
Vector offset(lua_tointeger(L, 2), lua_tointeger(L, 3));
dsq->game->avatar->position = e->position + offset;
dsq->overlay->alpha.interpolateTo(0, 1);
core->main(1);
core->run(1);
}
luaReturnNil();
}
@ -8235,13 +8225,15 @@ luaFunc(getInputMode)
luaFunc(getJoystickAxisLeft)
{
Vector v = core->joystick.position;
Vector v;// = core->joystick.position;
assert(false); // FIXME
luaReturnVec2(v.x, v.y);
}
luaFunc(getJoystickAxisRight)
{
Vector v = core->joystick.rightStick;
Vector v;// = core->joystick.rightStick;
assert(false); // FIXME
luaReturnVec2(v.x, v.y);
}
@ -9997,8 +9989,6 @@ static const struct {
luaRegister(setNaijaHeadTexture),
luaRegister(incrFlag),
luaRegister(decrFlag),
luaRegister(setFlag),
luaRegister(getFlag),
luaRegister(setStringFlag),
@ -11525,7 +11515,7 @@ void ScriptInterface::shutdown()
Script *ScriptInterface::openScript(const std::string &file, bool ignoremissing /* = false */)
{
std::string realFile = localisePathInternalModpath(file);
realFile = core->adjustFilenameCase(realFile);
realFile = adjustFilenameCase(realFile);
bool loadedScript = false;
lua_getglobal(baseState, "_scriptvars");

View file

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Avatar.h"
#include "Shot.h"
#include "ScriptInterface.h"
bool ScriptedEntity::runningActivation = false;

View file

@ -23,8 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "CollideEntity.h"
#include "Segmented.h"
#include "Hair.h"
#include "Particles.h"
struct lua_State;
class Script;
class ScriptedEntity : public CollideEntity, public Segmented
{

View file

@ -25,9 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/MathFunctions.h"
typedef std::map<std::string, ShotData> ShotBank;
static ShotBank shotBank;
Shot::Shots Shot::shots;
Shot::Shots Shot::deleteShots;
Shot::ShotBank Shot::shotBank;
unsigned int Shot::shotsIter = 0;
std::string Shot::shotBankPath = "";
@ -99,7 +101,7 @@ void ShotData::bankLoad(const std::string &file, const std::string &path)
stringToLower(this->name);
debugLog(usef);
char *data = readFile(core->adjustFilenameCase(usef).c_str());
char *data = readFile(adjustFilenameCase(usef).c_str());
if (!data)
return;
SimpleIStringStream inf(data, SimpleIStringStream::TAKE_OVER);
@ -304,7 +306,7 @@ void loadShotCallback(const std::string &filename, intptr_t param)
stringToLower(ident);
debugLog(ident);
shotData.bankLoad(ident, Shot::shotBankPath);
Shot::shotBank[ident] = shotData;
shotBank[ident] = shotData;
}
void Shot::loadShotBank(const std::string &bank1, const std::string &bank2)

View file

@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "CollideEntity.h"
#include "Segmented.h"
#include "../BBGE/Particles.h"
#include "../BBGE/ScriptObject.h"
class ParticleEffect;
struct ShotData
{
@ -101,10 +101,6 @@ public:
void rotateToVec(Vector addVec, float time, int offsetAngle);
void doHitEffects();
typedef std::map<std::string, ShotData> ShotBank;
static ShotBank shotBank;
static void loadShotBank(const std::string &bank1, const std::string &bank2);
static void clearShotBank();
static ShotData* getShotData(const std::string &ident);
@ -150,59 +146,4 @@ private:
unsigned int shotIdx;
};
class Beam : public Quad
{
public:
Beam(Vector pos, float angle);
typedef std::list<Beam*> Beams;
static Beams beams;
static void killAllBeams();
float angle;
void trace();
Vector endPos;
void render();
DamageData damageData;
void setDamage(float dmg);
void setFirer(Entity *e);
void setBeamWidth(float w);
protected:
float beamWidth;
void onRender();
void onEndOfLife();
void onUpdate(float dt);
};
class GasCloud : public Entity
{
public:
GasCloud(Entity *source, const Vector &position, const std::string &particles, const Vector &color, int radius, float life, float damage=0, bool isMoney=false, float poisonTime=0);
protected:
ParticleEffect *emitter;
std::string gfx, particles;
int radius;
float damage;
float pTimer;
void onUpdate(float dt);
float poisonTime;
Entity *sourceEntity;
};
class Spore : public CollideEntity
{
public:
Spore(const Vector &position);
typedef std::list<Spore*> Spores;
static Spores spores;
static void killAllSpores();
static bool isPositionClear(const Vector &position);
void destroy();
protected:
void onEnterState(int state);
void onUpdate(float dt);
void onEndOfLife();
};
#endif

View file

@ -18,10 +18,13 @@ 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.
*/
#include "Spore.h"
#include "Shot.h"
#include "Game.h"
#include "Avatar.h"
Spore::Spores Spore::spores;
Spore::Spore (const Vector &position) : CollideEntity()

23
Aquaria/Spore.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef SPORE_H
#define SPORE_H
#include "CollideEntity.h"
#include <list>
class Spore : public CollideEntity
{
public:
Spore(const Vector &position);
typedef std::list<Spore*> Spores;
static Spores spores;
static void killAllSpores();
static bool isPositionClear(const Vector &position);
void destroy();
protected:
void onEnterState(int state);
void onUpdate(float dt);
void onEndOfLife();
};
#endif

View file

@ -25,24 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/DebugFont.h"
#include "../BBGE/AfterEffect.h"
Bubble::Bubble() : Quad()
{
setTexture("particles/bubble");
this->alpha = 0.5f;
this->speed = rand()%10+20;
this->width = 32;
this->height = 32;
}
void Bubble::onUpdate(float dt)
{
Quad::onUpdate(dt);
this->position -= Vector(0, speed)*dt;
if (position.y < -32)
position.y = position.y + 600+64;
}
Intro2::Intro2() : StateObject()
{
@ -71,7 +53,7 @@ void Intro2::applyState()
dsq->setCutscene(1,1);
core->main(1);
core->run(1);
dsq->overlay->alpha.interpolateTo(0, 40);
dsq->toggleCursor(0);
@ -108,22 +90,22 @@ void Intro2::applyState()
while (dsq->sound->isPlayingVoice())
dsq->main(FRAME_TIME);
dsq->run(FRAME_TIME);
emitter->stop();
emitter2->start();
core->main(0.5);
core->run(0.5);
core->sound->playSfx("NormalForm");
dsq->overlay->color = Vector(1,1,1);
dsq->overlay->alpha = 0;
dsq->fade(1, 1);
core->main(1);
core->run(1);
frame4->alpha = 0;
dsq->overlay->color.interpolateTo(0, 1);
core->main(1);
core->run(1);
dsq->overlay->color = 0;
dsq->overlay->alpha = 1;
@ -223,7 +205,7 @@ void GameOver::applyState()
}
addRenderObject(shockLines, LR_BACKGROUND);
core->main(0.033);
core->run(0.033);
if (core->afterEffectManager)
{
core->afterEffectManager->clear();
@ -235,20 +217,20 @@ void GameOver::applyState()
core->main(GO_ANIM_TIME);
core->run(GO_ANIM_TIME);
frame4->alpha.interpolateTo(0, GO_ANIM_TIME);
core->main(GO_ANIM_TIME);
core->run(GO_ANIM_TIME);
frame3->alpha.interpolateTo(0, GO_ANIM_TIME);
core->main(GO_ANIM_TIME);
core->run(GO_ANIM_TIME);
frame2->alpha.interpolateTo(0, GO_ANIM_TIME);
core->main(GO_ANIM_TIME);
core->run(GO_ANIM_TIME);
frame1->alpha.interpolateTo(0, GO_ANIM_TIME);
core->main(GO_ANIM_TIME);
core->run(GO_ANIM_TIME);
core->main(1.5);
core->run(1.5);
@ -409,7 +391,7 @@ void Nag::applyState()
dsq->toggleCursor(1, 0.5);
dsq->fade(0, 1);
dsq->main(1);
dsq->run(1);
dsq->sound->playMusic("openwaters3", SLT_NORMAL, SFT_IN, 2);
}
@ -419,7 +401,7 @@ void Nag::removeState()
dsq->toggleCursor(0);
dsq->fade(1, 1);
dsq->main(1);
dsq->run(1);
dsq->cursor->color = Vector(1,1,1);
@ -481,14 +463,14 @@ void Nag::onBuy()
if (core->isFullscreen())
{
core->toggleScreenMode(0);
dsq->main(0.6);
dsq->run(0.6);
}
std::ostringstream os;
os << "naijagiggle" << randRange(1, 5);
dsq->sound->playSfx(os.str());
dsq->main(0.5);
dsq->run(0.5);
click = 1;

View file

@ -21,19 +21,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __title__
#define __title__
#include "DSQ.h"
#include "../BBGE/SkeletalSprite.h"
#include "StateManager.h"
class ParticleEffect;
class Bubble : public Quad
{
public:
Bubble();
protected:
void onUpdate(float dt);
int speed;
};
class Quad;
class GameOver : public StateObject
{
@ -49,28 +41,6 @@ public:
float timer;
};
class Intro : public StateObject
{
public:
Intro();
void applyState();
void removeState();
void update(float dt);
void endIntro();
bool waitQuit(float t);
protected:
void createMeteor(int layer, Vector pos, Vector off, Vector sz);
void clearMeteors();
std::vector<Quad*>meteors;
bool done;
Precacher cachy;
};
class Intro2 : public StateObject
{
public:
@ -99,21 +69,6 @@ protected:
int logo;
};
class KeyframeWidget : public Quad
{
public:
KeyframeWidget(int key);
float t;
int key;
static KeyframeWidget *movingWidget;
BitmapText *b;
void shiftLeft();
void shiftRight();
protected:
void onUpdate(float dt);
};
class Hair;
class ParticleEditor : public StateObject
@ -136,131 +91,6 @@ protected:
std::string lastLoadedParticle;
};
class AnimationEditor : public StateObject
{
public:
AnimationEditor();
void applyState();
void removeState();
void update(float dt);
void prevKey();
void nextKey();
void newKey();
void deleteKey();
void animate();
void stop();
void animateOrStop();
void newAnim();
void lmbu();
void lmbd();
void rmbu();
void rmbd();
void mmbd();
void constrainMouse();
void reorderKeys();
void saveFile();
void loadFile();
void copyKey();
void pasteKey();
void nextAnim();
void prevAnim();
void quit();
void load();
void loadSkin();
void copy();
void paste();
void cloneBoneAhead();
void zoomIn();
void zoomOut();
void resetScaleOrSave();
void clearRot();
void clearPos();
void flipRot();
void cycleLerpType();
void toggleHideBone();
void undo();
void redo();
void pushUndo();
void clearUndoHistory();
void applyTranslation();
void applyRotation();
void moveNextWidgets(float dt);
std::deque<SkeletalSprite> undoHistory;
int undoEntry;
int currentKey;
int rotOffset;
SkeletalSprite *editSprite;
Bone *editingBone;
int boneEdit;
DebugFont *text, *text2;
void goToTitle();
SkeletalKeyframe copyBuffer;
std::string editingFile;
std::vector<KeyframeWidget*> keyframeWidgets;
void action(int id, int state, int source);
void rebuildKeyframeWidgets();
Vector cursorOffset;
void moveBoneStripPoint(const Vector &mov);
void editStripKey();
void toggleMouseSelection();
void selectPrevBone();
void selectNextBone();
bool mouseSelection;
SkeletalKeyframe buffer;
bool editingStrip;
int selectedStripPoint;
void reverseAnim();
void toggleRenderBorders();
void updateRenderBorders();
bool renderBorders;
void updateEditingBone();
void showAllBones();
void incrTimelineUnit();
void decrTimelineUnit();
void updateTimelineUnit();
void incrTimelineGrid();
void decrTimelineGrid();
void updateTimelineGrid();
DebugFont *gridsize, *unitsize;
};
class Credits : public StateObject
{
public:

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h"
#include "Avatar.h"
#include "StatsAndAchievements.h"
#include "ttvfs_stdio.h"
#ifndef ARRAYSIZE
#define ARRAYSIZE(x) (sizeof (x) / sizeof ((x)[0]))

View file

@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "GridRender.h"
#include "RenderBase.h"
#include "../BBGE/AfterEffect.h"
SteamRender::SteamRender() : RenderObject()

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Segmented.h"
#include "RenderBase.h"
Strand::Strand(const Vector &position, int segs, int dist) : RenderObject(), Segmented(dist, dist)
{

View file

@ -18,7 +18,9 @@ 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.
*/
#include "StringBank.h"
#include "DSQ.h"
#include "ttvfs_stdio.h"
StringBank::StringBank()
{

21
Aquaria/StringBank.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef STRINGBANK_H
#define STRINGBANK_H
#include <string>
#include <map>
class StringBank
{
public:
StringBank();
void load();
const std::string& get(int idx);
protected:
void _load(const std::string &file);
typedef std::map<int, std::string> StringMap;
StringMap stringMap;
};
#endif

View file

@ -18,11 +18,12 @@ 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.
*/
#include "DSQ.h"
#include "SubtitlePlayer.h"
#include "../BBGE/DebugFont.h"
#include "../BBGE/BitmapFont.h"
#include "DSQ.h"
#include "ttvfs_stdio.h"
SubtitlePlayer::SubtitlePlayer()
@ -47,7 +48,7 @@ void SubtitlePlayer::go(const std::string &subs)
{
f = dsq->mod.getPath() + "audio/" + subs + ".txt";
f = localisePath(f, dsq->mod.getPath());
f = core->adjustFilenameCase(f);
f = adjustFilenameCase(f);
if (exists(f))
checkAfter = false;
}
@ -56,7 +57,7 @@ void SubtitlePlayer::go(const std::string &subs)
{
f = "scripts/vox/" + subs + ".txt";
f = localisePath(f);
f = core->adjustFilenameCase(f);
f = adjustFilenameCase(f);
if (!exists(f))
{
debugLog("Could not find subs file [" + subs + "]");

36
Aquaria/SubtitlePlayer.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef SUBTITLEPLAYER_H
#define SUBTITLEPLAYER_H
#include <string>
#include <vector>
struct SubLine
{
SubLine() { timeStamp = 0; }
float timeStamp;
std::string line;
};
class SubtitlePlayer
{
public:
SubtitlePlayer();
void go(const std::string &subs);
void update(float dt);
void end();
void hide(float t = 0);
void show(float t = 0);
bool isVisible();
typedef std::vector<SubLine> SubLines;
SubLines subLines;
int curLine;
protected:
bool vis, hidden;
};
#endif

View file

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "DSQ.h"
#include "Game.h"
#include "Avatar.h"
#include "ReadXML.h"
void UserSettings::save()
@ -237,7 +238,7 @@ void UserSettings::save()
xml_data->SetAttribute("saveSlot", data.saveSlot);
std::ostringstream ss;
for (std::set<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it)
for (std::vector<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it)
ss << *it << " ";
xml_data->SetAttribute("activePatches", ss.str().c_str());
}
@ -503,8 +504,8 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
while(ss)
{
ss >> tmp;
if(tmp.length())
dsq->activePatches.insert(tmp);
if(tmp.length() && !dsq->isPatchActive(tmp))
dsq->activePatches.push_back(tmp);
}
}
}
@ -548,13 +549,13 @@ void UserSettings::apply()
dsq->loops.updateVolume();
// FIXME: This should be per-joystick
core->joystick.s1ax = control.s1ax;
/*core->joystick.s1ax = control.s1ax;
core->joystick.s1ay = control.s1ay;
core->joystick.s2ax = control.s2ax;
core->joystick.s2ay = control.s2ay;
core->joystick.deadZone1 = control.s1dead;
core->joystick.deadZone2 = control.s2dead;
core->joystick.deadZone2 = control.s2dead;*/
core->debugLogActive = system.debugLogOn;

View file

@ -25,50 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
const std::string userSettingsFilename = "usersettings.xml";
#ifndef AQUARIA_USERSETTINGS_DATAONLY
#include "Base.h"
#include "ActionMapper.h"
#include "Base.h"
#include "ActionMapper.h"
#else
#include <string>
#include <vector>
#include <sstream>
class ActionInput
{
public:
std::string toString()
{
return input;
}
void fromString(const std::string &str)
{
input = str;
}
std::string name, input;
};
class ActionSet
{
public:
void clearActions()
{
inputSet.clear();
}
ActionInput* addActionInput(const std::string &name)
{
ActionInput newActionInput;
newActionInput.name = name;
inputSet.push_back(newActionInput);
return &inputSet[inputSet.size()-1];
}
std::vector<ActionInput> inputSet;
};
#endif
// MAKE SURE to update this when changing the user settings
const int VERSION_USERSETTINGS = 1;

View file

@ -3,7 +3,7 @@
#include "DSQ.h"
#include "Game.h"
#include "Avatar.h"
#include "RenderBase.h"
namespace WaterSurfaceRenderStuff

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "DSQ.h"
#include "Game.h"
#include "Avatar.h"
#include "RenderBase.h"
Web::Webs Web::webs;

View file

@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AQ_WEB_H
#include "../BBGE/Quad.h"
#include "Entity.h"
class Entity;
class Web : public RenderObject
{

57
Aquaria/WorldMap.h Normal file
View file

@ -0,0 +1,57 @@
#ifndef WORLDMAP_H
#define WORLDMAP_H
#include <string>
#include "Vector.h"
#include "GameEnums.h"
#define MAPVIS_SUBDIV 64
class Quad;
struct WorldMapTile
{
WorldMapTile();
~WorldMapTile();
void markVisited(int left, int top, int right, int bottom);
void dataToString(std::ostringstream &os);
void stringToData(std::istringstream &is);
const unsigned char *getData() const {return data;}
std::string name;
Vector gridPos;
float scale, scale2;
bool revealed, prerevealed;
int layer, index;
int stringIndex;
Quad *q;
protected:
unsigned char *data;
};
struct WorldMap
{
WorldMap();
void load();
void save();
void hideMap();
void revealMap(const std::string &name);
WorldMapTile *getWorldMapTile(const std::string &name);
int getNumWorldMapTiles();
WorldMapTile *getWorldMapTile(int index);
WorldMapTile *getWorldMapTileByIndex(int index);
void revealMapIndex(int index);
int gw, gh;
typedef std::vector<WorldMapTile> WorldMapTiles;
WorldMapTiles worldMapTiles;
private:
void _load(const std::string &file);
};
#endif

View file

@ -1028,17 +1028,36 @@ void WorldMapRender::onUpdate(float dt)
{
if (isActing(ACTION_SECONDARY))
{
if (core->joystick.position.y >= 0.6f)
Vector jpos;
for(size_t i = 0; i < core->joysticks.size(); ++i)
if(Joystick *j = core->joysticks[i])
if(j && j->isEnabled())
if(fabsf(j->position.y) > 0.6f)
{
jpos = j->position;
break;
}
if (jpos.y >= 0.6f)
scale.interpolateTo(scale / 1.2f, 0.1f);
else if (core->joystick.position.y <= -0.6f)
else if (jpos.y <= -0.6f)
scale.interpolateTo(scale * 1.2f, 0.1f);
}
else
{
Vector jpos;
for(size_t i = 0; i < core->joysticks.size(); ++i)
if(Joystick *j = core->joysticks[i])
if(j && j->isEnabled())
if(!j->position.isZero())
{
jpos = j->position;
break;
}
// The negative multiplier is deliberate -- it makes the
// map scroll as though the joystick was controlling the
// cursor (which is fixed in the center of the screen).
internalOffset += core->joystick.position * (-400*dt / scale.x);
internalOffset += jpos * (-400*dt / scale.x);
}
}
}

View file

@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DSQ.h"
#include "ttvfs_stdio.h"
#include <fstream>
#if MAPVIS_SUBDIV % 8 != 0
#error MAPVIS_SUBDIV must be a multiple of 8

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ActionInput.h"
#include "ActionMapper.h"
#include "SDL.h"
#ifndef BBGE_BUILD_SDL2
#error Needs fixes for SDL 1.2, doesnt support scancodes

View file

@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class Event;
class ActionMapper;
#include <map>
#include <list>
#include "ActionSet.h"
#include "Joystick.h"

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "AfterEffect.h"
#include "RenderBase.h"
#include <assert.h>
@ -94,8 +95,7 @@ void AfterEffectManager::deleteEffects()
}
effects.clear();
numEffects=0;
while (!openSpots.empty())
openSpots.pop();
openSpots.clear();
}
void AfterEffectManager::deleteShaders()
@ -170,7 +170,7 @@ void AfterEffectManager::destroyEffect(int id)
{
delete effects[id];
effects[id] = 0;
openSpots.push(id);
openSpots.push_back(id);
}
void AfterEffectManager::render()
@ -420,11 +420,10 @@ void AfterEffectManager::reloadDevice()
void AfterEffectManager::addEffect(Effect *e)
{
if (!openSpots.empty())
{
int i = openSpots.front();
openSpots.pop();
int i = openSpots.back();
openSpots.pop_back();
effects[i] = e;
}
else
@ -435,13 +434,8 @@ void AfterEffectManager::addEffect(Effect *e)
Vector base(0,0,0);
e->position.x /= screenWidth;
e->position.y /= screenHeight;
}
@ -450,22 +444,12 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
dt *= timeMultiplier;
Effect::update(dt, drawGrid, xDivs, yDivs);
centerPoint = position;
centerPoint -= ((core->screenCenter-originalCenter)*core->globalScale.x)/core->width;
float xDist,yDist,tDist;
amplitude-=dt*rate;
currentDistance+=dt*frequency;
float distFromCamp = 4;
float adjWaveLength = waveLength/distFromCamp;
float adjAmplitude = amplitude/distFromCamp;
@ -476,21 +460,13 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
{
for (int j = 1; j < (yDivs-1); j++)
{
float xDist = (centerPoint.x - drawGrid[i][j].x)/.75;
float yDist = centerPoint.y - drawGrid[i][j].y;
xDist = (centerPoint.x - drawGrid[i][j].x)/.75;
yDist = centerPoint.y - drawGrid[i][j].y;
tDist = sqrtf(xDist*xDist+yDist*yDist);
float tDist = sqrtf(xDist*xDist+yDist*yDist);
if (tDist < currentDistance*adjWaveLength)
{
drawGrid[i][j].x += adjAmplitude*sinf(-tDist/adjWaveLength+currentDistance)*.75f;
drawGrid[i][j].y += adjAmplitude*cosf(-tDist/adjWaveLength+currentDistance);
}

View file

@ -98,7 +98,7 @@ public:
void reloadDevice();
std::vector<Effect*> effects;
std::queue<int> openSpots;
std::vector<int> openSpots;
bool active;

View file

@ -20,28 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Base.h"
#include "Core.h"
#include <algorithm>
#ifdef BBGE_BUILD_WINDOWS
#include <shellapi.h>
#endif
#ifdef _MSC_VER
# include <intrin.h>
#endif
#if defined(BBGE_BUILD_UNIX)
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
#endif
#if defined(BBGE_BUILD_MACOSX)
#include <Carbon/Carbon.h>
#endif
#include <assert.h>
#include "OSFunctions.h"
#ifdef BBGE_BUILD_VFS
# include "ttvfs.h"
@ -51,79 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ttvfs::Root vfs; // extern
#endif
Vector getDirVector(Direction dir)
{
switch(dir)
{
case DIR_DOWN:
return Vector(0, 1);
break;
case DIR_UP:
return Vector(0, -1);
break;
case DIR_LEFT:
return Vector(-1, 0);
break;
case DIR_RIGHT:
return Vector(1, 0);
break;
}
return Vector(0,0);
}
#include "ttvfs_stdio.h"
Direction getOppositeDir(Direction dir)
{
switch(dir)
{
case DIR_DOWN:
return DIR_UP;
break;
case DIR_UP:
return DIR_DOWN;
break;
case DIR_LEFT:
return DIR_RIGHT;
break;
case DIR_RIGHT:
return DIR_LEFT;
break;
}
return DIR_NONE;
}
Direction getNextDirClockwise(Direction dir)
{
switch(dir)
{
case DIR_DOWN:
return DIR_LEFT;
break;
case DIR_UP:
return DIR_RIGHT;
break;
case DIR_LEFT:
return DIR_UP;
break;
case DIR_RIGHT:
return DIR_DOWN;
break;
}
return DIR_NONE;
}
void sizePowerOf2Texture(int &v)
{
int p = 8, use=0;
do
{
use = 1 << p;
p++;
}
while(v > use);
v = use;
}
int randAngle360()
{
@ -165,7 +75,7 @@ unsigned hash(const std::string &string)
static unsigned char lowerToUpperTable[256];
static unsigned char upperToLowerTable[256];
void initCharTranslationTables(const std::map<unsigned char, unsigned char>& tab)
void initCharTranslationTables(const CharTranslationTable *ptab)
{
for (unsigned int i = 0; i < 256; ++i)
{
@ -177,20 +87,23 @@ void initCharTranslationTables(const std::map<unsigned char, unsigned char>& tab
lowerToUpperTable[i] = i - 'a' + 'A';
upperToLowerTable[i - 'a' + 'A'] = i;
}
for (std::map<unsigned char, unsigned char>::const_iterator it = tab.begin(); it != tab.end(); ++it)
{
lowerToUpperTable[it->first] = it->second;
upperToLowerTable[it->second] = it->first;
}
if(ptab)
for (unsigned int i = 0; i < 256; ++i)
{
int to = (*ptab)[i];
if(to > 0)
{
lowerToUpperTable[i] = to;
upperToLowerTable[to] = i;
}
}
}
struct TransatableStaticInit
{
TransatableStaticInit()
{
std::map<unsigned char, unsigned char> dummy;
initCharTranslationTables(dummy);
initCharTranslationTables(NULL);
}
};
static TransatableStaticInit _transtable_static_init;
@ -259,11 +172,6 @@ std::string numToZeroString(int num, int zeroes)
return os.str();
}
bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord2)
{
return (vec.x > coord1.x && vec.x < coord2.x && vec.y > coord1.y && vec.y < coord2.y);
}
void stringToUpper(std::string &s)
{
for (int i = 0; i < s.size(); i++)
@ -331,7 +239,7 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS)
#endif
if (!e)
{
std::string tmp = core->adjustFilenameCase(f);
std::string tmp = adjustFilenameCase(f);
FILE *file = fopen(tmp.c_str(), "rb");
if (file)
{
@ -348,43 +256,14 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS)
return e;
}
void drawCircle(float radius, int stepSize)
{
glBegin(GL_POLYGON);
{
for(int i=0;i < 360; i+=stepSize) {
const float degInRad = i*PI/180.0f;
glVertex3f(cosf(degInRad)*radius, sinf(degInRad)*radius,0.0);
}
}
glEnd();
}
void exit_error(const std::string &message)
{
errorLog(message);
exit(1);
}
std::string parseCommand(const std::string &line, const std::string &command)
{
int stringPos = line.find(command);
if (stringPos != std::string::npos)
{
return line.substr((command.length()), line.length());
}
return "";
}
void glColor3_256(int r, int g, int b)
{
glColor4f(float(r)/256.0f, float(g)/256.0f, float(b)/256.0f, 1.0f);
}
bool chance(int perc)
{
if (perc == 100) return true;
@ -392,15 +271,6 @@ bool chance(int perc)
return ((rand()%100) <= perc);
}
bool chancef(float p)
{
if (p >= 1) return true;
if (p <= 0) return false;
return ((rand()%100) <= p*100);
}
void errorLog(const std::string &s)
{
if (core)
@ -472,54 +342,6 @@ char *readFile(const std::string& path, unsigned long *size_ret)
return buffer;
}
tinyxml2::XMLError readXML(const std::string& fn, tinyxml2::XMLDocument& doc)
{
unsigned long sz = 0;
char *buf = readFile(fn, &sz);
tinyxml2::XMLError err = doc.Parse(buf, sz);
delete [] buf;
return err;
}
tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr /* = 0 */, bool keepEmpty /* = false */)
{
tinyxml2::XMLDocument *doc = new tinyxml2::XMLDocument();
tinyxml2::XMLError err = readXML(fn, *doc);
if(perr)
*perr = err;
if(err != tinyxml2::XML_SUCCESS && !keepEmpty)
{
delete doc;
doc = NULL;
}
return doc;
}
void doSingleFile(const std::string &path, const std::string &type, std::string filename, void callback(const std::string &filename, int param), int param)
{
if (filename.size()>4)
{
std::string search = filename;
stringToLower(search);
std::string filetype = filename.substr(search.size()-4, search.size());
debugLog("checking:" + search + " for type:" + type);
if (search.find(type)!=std::string::npos)
{
debugLog("callback");
callback(path+filename, param);
}
else
{
debugLog("not the same");
}
}
}
std::string stripEndlineForUnix(const std::string &in)
{
std::string out;
@ -533,257 +355,6 @@ std::string stripEndlineForUnix(const std::string &in)
return out;
}
#ifdef BBGE_BUILD_VFS
struct vfscallback_s
{
std::string *path;
const char *ext;
intptr_t param;
void (*callback)(const std::string &filename, intptr_t param);
};
void forEachFile_vfscallback(VFILE *vf, void *user)
{
vfscallback_s *d = (vfscallback_s*)user;
if(d->ext)
{
const char *e = strrchr(vf->name(), '.');
if(e && nocasecmp(d->ext, e))
return;
}
d->callback(*(d->path) + vf->name(), d->param);
}
#endif
void forEachFile(std::string path, std::string type, void callback(const std::string &filename, intptr_t param), intptr_t param)
{
if (path.empty()) return;
#ifdef BBGE_BUILD_VFS
ttvfs::DirView view;
if(!vfs.FillDirView(path.c_str(), view))
{
debugLog("Path '" + path + "' does not exist");
return;
}
vfscallback_s dat;
dat.path = &path;
dat.ext = type.length() ? type.c_str() : NULL;
dat.param = param;
dat.callback = callback;
view.forEachFile(forEachFile_vfscallback, &dat, true);
return;
// -------------------------------------
#endif
stringToLower(type);
path = core->adjustFilenameCase(path);
debugLog("forEachFile - path: " + path + " type: " + type);
#if defined(BBGE_BUILD_UNIX)
DIR *dir=0;
dir = opendir(path.c_str());
if (dir)
{
dirent *file=0;
while ( (file=readdir(dir)) != NULL )
{
if (file->d_name && strlen(file->d_name) > 4)
{
debugLog(file->d_name);
char *extension=strrchr(file->d_name,'.');
if (extension)
{
debugLog(extension);
if (extension!=NULL)
{
if (strcasecmp(extension,type.c_str())==0)
{
callback(path + std::string(file->d_name), param);
}
}
}
}
}
closedir(dir);
}
else
{
debugLog("FAILED TO OPEN DIR");
}
#endif
#ifdef BBGE_BUILD_WINDOWS
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
int end = path.size()-1;
if (path[end] != '/')
path[end] += '/';
// Get the proper directory path
// \\ %s\\*
if (type.find('.')==std::string::npos)
{
type = "." + type;
}
sprintf(szDir, "%s\\*", path.c_str());
stringToUpper(type);
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
debugLog("No files of type " + type + " found in path " + path);
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
std::string filename = FileData.cFileName;
if (filename.size()>4)
{
std::string filetype = filename.substr(filename.size()-4, filename.size());
stringToUpper(filetype);
if (filetype==type)
{
callback(path+filename, param);
}
}
if (!FindNextFile(hList, &FileData))
{
fFinished = TRUE;
}
}
}
FindClose(hList);
#endif
}
std::vector<std::string> getFileList(std::string path, std::string type, int param)
{
std::vector<std::string> list;
#ifdef BBGE_BUILD_WINDOWS
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
// Get the proper directory path
sprintf(szDir, "%s\\*", path.c_str());
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
printf("No files found\n\n");
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
std::string filename = FileData.cFileName;
if (filename.size()>4 && filename.substr(filename.size()-4, filename.size())==type)
{
list.push_back (filename);
}
if (!FindNextFile(hList, &FileData))
{
fFinished = TRUE;
}
}
}
FindClose(hList);
#endif
return list;
}
#if defined(BBGE_BUILD_MACOSX) && !SDL_VERSION_ATLEAST(2,0,0)
void cocoaMessageBox(const std::string &title, const std::string &msg);
#endif
void messageBox(const std::string& title, const std::string &msg)
{
#ifdef BBGE_BUILD_WINDOWS
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
#elif SDL_VERSION_ATLEAST(2,0,0)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, title.c_str(),
msg.c_str(), NULL);
#elif defined(BBGE_BUILD_MACOSX)
cocoaMessageBox(title, msg);
#elif defined(BBGE_BUILD_UNIX)
// !!! FIXME: probably don't want the whole GTK+ dependency in here...
fprintf(stderr, "%s: %s\n", title.c_str(), msg.c_str());
#else
#error Please define your platform.
#endif
}
Vector getNearestPointOnLine(Vector a, Vector b, Vector c)
{
Vector nearest;
/// Local Variables ///////////////////////////////////////////////////////////
long dot_ta,dot_tb;
///////////////////////////////////////////////////////////////////////////////
// SEE IF a IS THE NEAREST POINT - ANGLE IS OBTUSE
dot_ta = (c.x - a.x)*(b.x - a.x) + (c.y - a.y)*(b.y - a.y);
if (dot_ta <= 0) // IT IS OFF THE a VERTEX
{
nearest.x = a.x;
nearest.y = a.y;
return nearest;
}
dot_tb = (c.x - b.x)*(a.x - b.x) + (c.y - b.y)*(a.y - b.y);
// SEE IF b IS THE NEAREST POINT - ANGLE IS OBTUSE
if (dot_tb <= 0)
{
nearest.x = b.x;
nearest.y = b.y;
return nearest;
}
// FIND THE REAL NEAREST POINT ON THE LINE SEGMENT - BASED ON RATIO
nearest.x = a.x + ((b.x - a.x) * dot_ta)/(dot_ta + dot_tb);
nearest.y = a.y + ((b.y - a.y) * dot_ta)/(dot_ta + dot_tb);
return nearest;
}
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius, Vector *closestP)
{
@ -807,30 +378,6 @@ bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius,
return distsqr <= radius*radius;
}
GLuint generateEmptyTexture(int quality) // Create An Empty Texture
{
GLuint txtnumber=0; // Texture ID
unsigned char *data; // Stored Data
// Create Storage Space For Texture Data (128x128x4)
int size = (quality * quality) * 4;
data = new unsigned char[size];
memset(data, 0, size); // Clear Storage Memory
glGenTextures(1, &txtnumber); // Create 1 Texture
glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, quality, quality, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data); // Build Texture Using Information In data
delete [] data; // Release data
return txtnumber; // Return The Texture ID
}
Vector randVector(float mag)
{
float angle = (rand() / (float)RAND_MAX) * 2.0f * PI;
@ -861,197 +408,6 @@ float lerp(const float &v1, const float &v2, float dt, int lerpType)
return (v2-v1)*dt+v1;
}
#if 0
#include <zlib.h>
#include <assert.h>
#define CHUNK 16384
/* Compress from file source to file dest until EOF on source.
def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_STREAM_ERROR if an invalid compression
level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
version of the library linked do not match, or Z_ERRNO if there is
an error reading or writing the files. */
int packFile(const std::string &sourcef, const std::string &destf, int level)
{
FILE *source = fopen(core->adjustFilenameCase(sourcef).c_str(), "rb");
FILE *dest = fopen(core->adjustFilenameCase(destf).c_str(), "wb");
if (!source || !dest)
return 0;
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = in;
/* run deflate() on input until output buffer not full, finish
compression if all of source has been read in */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */
/* done when last data in file processed */
} while (flush != Z_FINISH);
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
fclose(source);
fclose(dest);
return Z_OK;
}
/* Decompress from file source to file dest until stream ends or EOF.
inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_DATA_ERROR if the deflate data is
invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
the version of the library linked do not match, or Z_ERRNO if there
is an error reading or writing the files. */
int unpackFile(const std::string &sourcef, const std::string &destf)
{
FILE *source = fopen(core->adjustFilenameCase(sourcef).c_str(), "rb");
FILE *dest = fopen(core->adjustFilenameCase(destf).c_str(), "wb");
if (!source || !dest)
return 0;
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
(void)inflateEnd(&strm);
fclose(source);
fclose(dest);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
#endif
void openURL(const std::string &url)
{
#ifdef BBGE_BUILD_WINDOWS
ShellExecute(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
#endif
#if defined(BBGE_BUILD_MACOSX)
CFStringRef str = CFStringCreateWithCString (0, url.c_str(), 0);
CFURLRef ref = CFURLCreateWithString(kCFAllocatorDefault, str, NULL);
LSOpenCFURLRef(ref, 0);
CFRelease(ref);
CFRelease(str);
#elif BBGE_BUILD_UNIX
std::string cmd("PATH=$PATH:. xdg-open '");
cmd += url;
cmd += "'";
if (system(cmd.c_str()) != 0)
debugLog("system(xdg_open '" + url + "') failed");
#endif
}
void clamp256Col(int *r)
{
if (*r > 255) *r = 255;
if (*r < 0) *r = 0;
}
Vector colorRGB(int r, int g, int b)
{
Vector c;
clamp256Col(&r);
clamp256Col(&g);
clamp256Col(&b);
c.x = float(r)/255.0f;
c.y = float(g)/255.0f;
c.z = float(b)/255.0f;
return c;
}
std::string underscoresToSpaces(const std::string &str)
{
std::string s = str;
@ -1068,48 +424,7 @@ std::string spacesToUnderscores(const std::string &str)
return s;
}
void triggerBreakpoint()
{
#ifdef _MSC_VER
__debugbreak();
#elif defined(__GNUC__) && ((__i386__) || (__x86_64__))
__asm__ __volatile__ ( "int $3\n\t" );
#else
raise(SIGTRAP);
#endif
}
bool createDir(const std::string& d)
{
bool success = false;
int err = 0;
#if defined(BBGE_BUILD_UNIX)
if (!mkdir(d.c_str(), S_IRWXU))
success = true;
else
{
err = errno;
if (err == EEXIST)
success = true;
}
#elif defined(BBGE_BUILD_WINDOWS)
if (CreateDirectoryA(d.c_str(), NULL))
success = true;
else
{
err = GetLastError();
if(err == ERROR_ALREADY_EXISTS)
success = true;
}
#endif
if (!success)
{
std::ostringstream os;
os << "Failed to create directory: [" << d << "], error code: " << err;
debugLog(os.str());
}
return success;
}
#include "DeflateCompressor.h"

View file

@ -22,13 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define BBGE_BASE_H
#ifdef BBGE_BUILD_WINDOWS
#define WIN32_LEAN_AND_MEAN
#define WIN32_NOMINMAX
#include <windows.h>
#undef min
#undef max
#define WIN32_NOMINMAX
#ifdef _MSC_VER
#define strtof (float)strtod
#define snprintf _snprintf
@ -37,28 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "BBGECompileConfig.h"
#ifdef BBGE_BUILD_WINDOWS
#define BBGE_PROF(x)
#define BBGE_PROF(x)
#else
#define BBGE_PROF(x)
#endif
#include "SDL.h"
#define GL_GLEXT_LEGACY 1
#include "gl.h"
#include "glext.h"
#define compile_assert(pred) switch(0){case 0:case (pred):;}
#ifdef _MSC_VER
@ -82,36 +57,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma warning(disable:4189) // UqqqqSEFUL: local variable is initialized but not referenced
#endif
#undef GetCharWidth
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <stack>
#include "Rect.h"
#include "math.h"
#include "ttvfs_stdio.h"
#include "tinyxml2.h"
#include "Refcounted.h"
#ifdef BBGE_BUILD_LINUX
# include <sys/types.h>
# include <stdint.h>
#endif
// dumb win32 includes/defines cleanup
#undef GetCharWidth
#include "Vector.h"
#include "OSFunctions.h"
// --- Defined in RenderBase.cpp -- Declared here to avoid pulling in gl.h via RenderBase.h --
void drawCircle(float radius, int stepSize);
unsigned generateEmptyTexture(int res);
void sizePowerOf2Texture(int &v);
// ----------------------
enum Align { ALIGN_CENTER=0, ALIGN_LEFT };
@ -129,11 +88,6 @@ enum Direction
DIR_MAX = 8
};
#include "Event.h"
#include "Vector.h"
const float SQRT2 = 1.41421356;
const float PI = 3.14159265;
@ -143,34 +97,26 @@ const float PI_HALF = 1.57079633;
#define HUGE_VALF ((float)1e38)
#endif
struct IntPair
{
IntPair(unsigned short int x, unsigned short int y) : x(x), y(y) {}
unsigned short int x, y;
};
typedef int CharTranslationTable[256]; // -1 entries are skipped
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
std::string numToZeroString(int num, int zeroes);
bool chance(int perc);
bool chancef(float p);
void initCharTranslationTables(const std::map<unsigned char, unsigned char>& tab);
void initCharTranslationTables(const CharTranslationTable *ptab);
void stringToUpper(std::string &s);
void stringToLower(std::string &s);
void stringToLowerUserData(std::string &s);
void glColor3_256(int r, int g, int b);
float sqr(float x);
bool exists(const std::string &f, bool makeFatal = false, bool skipVFS = false);
void errorLog(const std::string &s);
void debugLog(const std::string &s);
char *readFile(const std::string& path, unsigned long *size_ret = 0);
tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr = 0, bool keepEmpty = false);
tinyxml2::XMLError readXML(const std::string& fn, tinyxml2::XMLDocument& doc);
char *readCompressedFile(std::string path, unsigned long *size_ret = 0);
void forEachFile(std::string path, std::string type, void callback(const std::string &filename, intptr_t param), intptr_t param);
std::string stripEndlineForUnix(const std::string &in);
std::vector<std::string> getFileList(std::string path, std::string type, int param);
#ifdef HAVE_STRCASECMP
static inline int nocasecmp(const std::string &s1, const std::string &s2)
{ return strcasecmp(s1.c_str(), s2.c_str()); }
@ -183,24 +129,11 @@ static inline int nocasecmp(const char *s1, const char *s2)
#else
int nocasecmp(const std::string &s1, const std::string &s2);
#endif
Vector getNearestPointOnLine(Vector start, Vector end, Vector point);
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius=1, Vector* closest=0);
void sizePowerOf2Texture(int &v);
Vector getDirVector(Direction dir);
Direction getOppositeDir(Direction dir);
Direction getNextDirClockwise(Direction dir);
Vector colorRGB(int r, int g, int b);
GLuint generateEmptyTexture(int res);
void drawCircle(float radius, int steps=1);
bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord2);
std::string parseCommand(const std::string &line, const std::string &command);
void messageBox(const std::string &title, const std::string& msg);
void exit_error(const std::string &message);

View file

@ -19,12 +19,15 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "BitmapFont.h"
#include "RenderBase.h"
#include "Core.h"
#include "../ExternalLibs/glfont2/glfont2.h"
using namespace glfont;
BmpFont::BmpFont()
: font(new GLFont)
{
scale = 1;
loaded = false;
@ -35,6 +38,7 @@ BmpFont::BmpFont()
BmpFont::~BmpFont()
{
delete font;
destroy();
}
@ -42,7 +46,7 @@ void BmpFont::destroy()
{
if (loaded)
{
font.Destroy();
font->Destroy();
loaded = false;
}
@ -52,14 +56,14 @@ void BmpFont::destroy()
void BmpFont::load(const std::string &file, float scale, bool loadTexture)
{
if (loaded)
font.Destroy();
font->Destroy();
this->scale = scale;
GLuint id=0;
glGenTextures(1, &id);
if (!font.Create(file.c_str(), id, loadTexture))
if (!font->Create(file.c_str(), id, loadTexture))
return;
@ -92,23 +96,6 @@ void BitmapText::autoKern()
{
}
void BitmapText::loadSpacingMap(const std::string &file)
{
spacingMap.clear();
InStream inFile(file.c_str());
std::string line;
while (std::getline(inFile, line))
{
if (!line.empty())
{
char c = line[0];
line = line.substr(2, line.length());
std::istringstream is(line);
is >> spacingMap[c];
}
}
}
int BitmapText::getWidthOnScreen()
{
return text.size()*(fontDrawSize/2);
@ -142,13 +129,13 @@ float BitmapText::getSetWidth()
float BitmapText::getHeight()
{
float sz = bmpFont->font.GetCharHeight('A') * bmpFont->scale;
float sz = bmpFont->font->GetCharHeight('A') * bmpFont->scale;
return lines.size()*sz;
}
float BitmapText::getLineHeight()
{
return bmpFont->font.GetCharHeight('A') * bmpFont->scale;
return bmpFont->font->GetCharHeight('A') * bmpFont->scale;
}
void BitmapText::formatText()
@ -164,7 +151,7 @@ void BitmapText::formatText()
for (int i = 0; i < text.size(); i++)
{
float sz = bmpFont->font.GetCharWidth(text[i])*bmpFont->scale;
float sz = bmpFont->font->GetCharWidth(text[i])*bmpFont->scale;
currentWidth += sz;
if (currentWidth+sz >= textWidth || text[i] == '\n')
@ -301,7 +288,7 @@ void BitmapText::onRender()
bmpFont->font.Begin();
bmpFont->font->Begin();
if (fontTextureTest) fontTextureTest->apply();
@ -310,7 +297,7 @@ void BitmapText::onRender()
float y=0;
float x=0;
float adj = bmpFont->font.GetCharHeight('A') * bmpFont->scale;
float adj = bmpFont->font->GetCharHeight('A') * bmpFont->scale;
if (scrolling)
{
@ -324,13 +311,13 @@ void BitmapText::onRender()
if (align == ALIGN_CENTER)
{
std::pair<int, int> sz;
bmpFont->font.GetStringSize(lines[i], &sz);
bmpFont->font->GetStringSize(lines[i], &sz);
x = -sz.first*0.5f*bmpFont->scale;
}
float la = 1.0f-(scrollDelay/scrollSpeed);
bmpFont->font.DrawString(theLine, bmpFont->scale, x, y, top_color, bottom_color, alpha.x, la);
bmpFont->font->DrawString(theLine, bmpFont->scale, x, y, top_color, bottom_color, alpha.x, la);
y += adj;
}
}
@ -342,10 +329,10 @@ void BitmapText::onRender()
if (align == ALIGN_CENTER)
{
std::pair<int, int> sz;
bmpFont->font.GetStringSize(lines[i], &sz);
bmpFont->font->GetStringSize(lines[i], &sz);
x = -sz.first*0.5f*bmpFont->scale;
}
bmpFont->font.DrawString(lines[i], bmpFont->scale, x, y, top_color, bottom_color, alpha.x, 1);
bmpFont->font->DrawString(lines[i], bmpFont->scale, x, y, top_color, bottom_color, alpha.x, 1);
y += adj;
}
}
@ -410,7 +397,7 @@ float BitmapText::getStringWidth(const std::string& text)
if(text[i] == '\n')
{
std::pair<int, int> dim;
bmpFont->font.GetStringSize(tmp, &dim);
bmpFont->font->GetStringSize(tmp, &dim);
maxsize = std::max(maxsize, dim.first);
tmp.resize(0);
}
@ -418,7 +405,7 @@ float BitmapText::getStringWidth(const std::string& text)
tmp += text[i];
}
std::pair<int, int> dim;
bmpFont->font.GetStringSize(tmp, &dim);
bmpFont->font->GetStringSize(tmp, &dim);
maxsize = std::max(maxsize, dim.first);
return maxsize * bmpFont->scale;

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "RenderObject.h"
#include "BaseText.h"
#include "../ExternalLibs/glfont2/glfont2.h"
namespace glfont { class GLFont; }
enum BitmapFontEffect
{
@ -41,7 +41,7 @@ struct BmpFont
void load(const std::string &file, float scale=1, bool loadTexture=true);
void destroy();
glfont::GLFont font;
glfont::GLFont * const font;
float scale;
bool loaded;
@ -66,7 +66,6 @@ public:
virtual void setAlign(Align align);
std::string getText();
int getWidthOnScreen();
void loadSpacingMap(const std::string &file);
Vector getColorIndex(int i, int j);
void updateWordColoring();
void autoKern();
@ -92,8 +91,6 @@ protected:
int currentScrollChar;
Align align;
float alignWidth;
typedef std::map<char, float> SpacingMap;
SpacingMap spacingMap;
void formatText();
float fontDrawSize;
void onRender();

View file

@ -22,9 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Texture.h"
#include "AfterEffect.h"
#include "Particles.h"
#include "GLLoad.h"
#include "RenderBase.h"
#include <time.h>
#include <iostream>
#include <fstream>
#ifdef BBGE_BUILD_UNIX
#include <limits.h>
@ -40,7 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
#if BBGE_BUILD_WINDOWS
#include <shlobj.h>
#include <direct.h>
#endif
@ -61,6 +63,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Core *core = 0;
static std::ofstream _logOut;
#ifdef BBGE_BUILD_WINDOWS
HICON icon_windows = 0;
#endif
@ -489,91 +493,6 @@ std::string Core::getUserDataFolder()
return userDataFolder;
}
#if BBGE_BUILD_UNIX
#include <sys/types.h>
#include <pwd.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
// based on code I wrote for PhysicsFS: http://icculus.org/physfs/
// the zlib license on physfs allows this cut-and-pasting.
static int locateOneElement(char *buf)
{
char *ptr;
DIR *dirp;
if (access(buf, F_OK) == 0)
return(1); // quick rejection: exists in current case.
ptr = strrchr(buf, '/'); // find entry at end of path.
if (ptr == NULL)
{
dirp = opendir(".");
ptr = buf;
}
else
{
*ptr = '\0';
dirp = opendir(buf);
*ptr = '/';
ptr++; // point past dirsep to entry itself.
}
struct dirent *dent;
while ((dent = readdir(dirp)) != NULL)
{
if (strcasecmp(dent->d_name, ptr) == 0)
{
strcpy(ptr, dent->d_name); // found a match. Overwrite with this case.
closedir(dirp);
return(1);
}
}
// no match at all...
closedir(dirp);
return(0);
}
#endif
std::string Core::adjustFilenameCase(const char *_buf)
{
#ifdef BBGE_BUILD_UNIX // any case is fine if not Linux.
int rc = 1;
char *buf = (char *) alloca(strlen(_buf) + 1);
strcpy(buf, _buf);
char *ptr = buf;
while ((ptr = strchr(ptr + 1, '/')) != 0)
{
*ptr = '\0'; // block this path section off
rc = locateOneElement(buf);
*ptr = '/'; // restore path separator
if (!rc)
break; // missing element in path.
}
// check final element...
if (rc)
rc = locateOneElement(buf);
#if 0
if (strcmp(_buf, buf) != 0)
{
fprintf(stderr, "Corrected filename case: '%s' => '%s (%s)'\n",
_buf, buf, rc ? "found" : "not found");
}
#endif
return std::string(buf);
#else
return std::string(_buf);
#endif
}
Core::~Core()
{
if (particleManager)
@ -812,52 +731,6 @@ void Core::setSDLGLAttributes()
}
#ifdef GLAPIENTRY
#undef GLAPIENTRY
#endif
#ifdef BBGE_BUILD_WINDOWS
#define GLAPIENTRY APIENTRY
#else
#define GLAPIENTRY
#endif
unsigned int Core::dbg_numRenderCalls = 0;
#ifdef BBGE_BUILD_OPENGL_DYNAMIC
#define GL_FUNC(ret,fn,params,call,rt) \
extern "C" { \
static ret (GLAPIENTRY *p##fn) params = NULL; \
ret GLAPIENTRY fn params { ++Core::dbg_numRenderCalls; rt p##fn call; } \
}
#include "OpenGLStubs.h"
#undef GL_FUNC
static bool lookup_glsym(const char *funcname, void **func)
{
*func = SDL_GL_GetProcAddress(funcname);
if (*func == NULL)
{
std::ostringstream os;
os << "Failed to find OpenGL symbol \"" << funcname << "\"\n";
errorLog(os.str());
return false;
}
return true;
}
static bool lookup_all_glsyms(void)
{
bool retval = true;
#define GL_FUNC(ret,fn,params,call,rt) \
if (!lookup_glsym(#fn, (void **) &p##fn)) retval = false;
#include "OpenGLStubs.h"
#undef GL_FUNC
return retval;
}
#endif
bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync, int bpp, bool recreate)
{
static bool didOnce = false;
@ -1104,14 +977,8 @@ void Core::shutdownGraphicsLibrary(bool killVideo)
FrameBuffer::resetOpenGL();
gScreen = 0;
#if BBGE_BUILD_OPENGL_DYNAMIC
// reset all the entry points to NULL, so we know exactly what happened
// if we call a GL function after shutdown.
#define GL_FUNC(ret,fn,params,call,rt) \
p##fn = NULL;
#include "OpenGLStubs.h"
#undef GL_FUNC
unload_all_glsyms();
#endif
}
@ -1435,7 +1302,7 @@ void Core::onBackgroundUpdate()
SDL_Delay(200);
}
void Core::main(float runTime)
void Core::run(float runTime)
{
// cannot nest loops when the game is over
if (loopDone) return;
@ -1596,7 +1463,7 @@ void Core::main(float runTime)
updateCullData();
dbg_numRenderCalls = 0;
g_dbg_numRenderCalls = 0;
if (settings.renderOn)
{
@ -3077,8 +2944,11 @@ int Core::zgaSave( const char *filename,
}
#ifdef BBGE_BUILD_VFS
#include "ttvfs_zip/VFSZipArchiveLoader.h"
#include "ttvfs.h"
#include "ttvfs_stdio.h"
#endif
void Core::setupFileAccess()
{
@ -3118,13 +2988,15 @@ void Core::initLocalization()
}
std::string low, up;
std::map<unsigned char, unsigned char> trans;
CharTranslationTable trans;
memset(&trans[0], -1, sizeof(trans));
while(in)
{
in >> low >> up;
trans[low[0]] = up[0];
}
initCharTranslationTables(trans);
initCharTranslationTables(&trans);
}
void Core::onJoystickAdded(int deviceID)

View file

@ -192,7 +192,7 @@ protected:
bool isList; // True if this is a GL display list
union {
RenderObject *robj;
GLuint listID;
unsigned listID;
} u;
};
std::vector<DisplayListElement> displayList;
@ -239,14 +239,11 @@ public:
std::string getPreferencesFolder();
std::string getUserDataFolder();
std::string adjustFilenameCase(const char *buf);
std::string adjustFilenameCase(const std::string &str) { return adjustFilenameCase(str.c_str()); };
void resetCamera();
virtual void shutdown();
void main(float runTime = -1); // can use main
void run(float runTime = -1); // can use main
@ -472,7 +469,6 @@ public:
int zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
volatile int dbg_numThreadDecoders;
static unsigned int dbg_numRenderCalls;
virtual void onBackgroundUpdate();
@ -545,8 +541,6 @@ protected:
int nestedMains;
std::string baseTextureDirectory;
std::ofstream _logOut;
int nowTicks, thenTicks;
int _vsync, _bpp;

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DarkLayer.h"
#include "Core.h"
#include "RenderBase.h"
DarkLayer::DarkLayer()
{

View file

@ -47,10 +47,8 @@ protected:
int quality;
bool active;
int layer, renderLayer;
GLuint texture;
GLuint format;
unsigned texture;
unsigned format;
};
#endif

View file

@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "DebugFont.h"
#include "RenderBase.h"
#include "Core.h"
DebugFont::DebugFont(int initSz, const std::string &initText)
{

View file

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef DEBUGFONT_H
#define DEBUGFONT_H
#include "Core.h"
#include "BaseText.h"
#include "Event.h"
class DebugFont : public BaseText
{

View file

@ -18,10 +18,12 @@ 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.
*/
#include <assert.h>
#include "Effects.h"
#include "RenderBase.h"
#include "Core.h"
#include <assert.h>
PostProcessingFX::PostProcessingFX()
{

View file

@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Particles.h"
#include "RenderBase.h"
Emitter::Emitter(ParticleEffect *pe) : Quad(), pe(pe)
{

View file

@ -31,8 +31,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <signal.h>
#endif
#include "SDL.h"
#include "Base.h"
#include "Core.h"
#include "ttvfs_stdio.h"
#include "FmodOpenALBridge.h"
@ -44,10 +47,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "MT.h"
#ifndef _DEBUG
//#define _DEBUG 1
#endif
#undef min
#undef max
@ -1416,7 +1415,7 @@ FMOD_RESULT OpenALSystem::createSound(const char *name_or_data, const FMOD_MODE
strcat(fname, ".ogg");
// just in case...
VFILE *io = vfopen(core->adjustFilenameCase(fname).c_str(), "rb");
VFILE *io = vfopen(adjustFilenameCase(fname).c_str(), "rb");
if (io == NULL)
return FMOD_ERR_INTERNAL;
size_t filesize = 0;

View file

@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "FrameBuffer.h"
#include "Core.h"
#include "RenderBase.h"
#include "glext.h"
//WARNING: FrameBuffer objects have to have reloadDevice/unloadDevice called manually!
@ -76,7 +78,7 @@ float FrameBuffer::getHeightP()
return py;
}
bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
bool FrameBuffer::init(int width, int height, bool fitToScreen)
{
// !!! FIXME: check for common GMA GL_RENDERER strings on Linux, too.
#ifdef BBGE_BUILD_MACOSX
@ -201,8 +203,8 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID );
// GL_LINEAR
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
width, height,

View file

@ -29,7 +29,7 @@ class FrameBuffer
public:
FrameBuffer();
~FrameBuffer();
bool init(int width, int height, bool fitToScreen=false, GLint filter=GL_LINEAR);
bool init(int width, int height, bool fitToScreen=false);
bool isInited() { return inited; }
bool isEnabled() { return enabled; }
void setEnabled(bool e);
@ -49,9 +49,9 @@ public:
protected:
int _w, _h;
bool _fitToScreen;
GLuint g_frameBuffer;
GLuint g_depthRenderBuffer;
GLuint g_dynamicTextureID;
unsigned g_frameBuffer;
unsigned g_depthRenderBuffer;
unsigned g_dynamicTextureID;
int w,h;
bool enabled, inited;
};

69
BBGE/GLLoad.cpp Normal file
View file

@ -0,0 +1,69 @@
#include "Base.h"
#if BBGE_BUILD_OPENGL_DYNAMIC
#include "RenderBase.h"
#include "GLLoad.h"
#include <sstream>
#ifdef GLAPIENTRY
#undef GLAPIENTRY
#endif
#ifdef BBGE_BUILD_WINDOWS
#define GLAPIENTRY __stdcall
#else
#define GLAPIENTRY
#endif
unsigned g_dbg_numRenderCalls = 0; // extern
#ifdef BBGE_BUILD_OPENGL_DYNAMIC
#define GL_FUNC(ret,fn,params,call,rt) \
extern "C" { \
static ret (GLAPIENTRY *p##fn) params = NULL; \
ret GLAPIENTRY fn params { ++g_dbg_numRenderCalls; rt p##fn call; } \
}
#include "OpenGLStubs.h"
#undef GL_FUNC
static bool lookup_glsym(const char *funcname, void **func)
{
*func = SDL_GL_GetProcAddress(funcname);
if (*func == NULL)
{
std::ostringstream os;
os << "Failed to find OpenGL symbol \"" << funcname << "\"\n";
errorLog(os.str());
return false;
}
return true;
}
bool lookup_all_glsyms()
{
bool retval = true;
#define GL_FUNC(ret,fn,params,call,rt) \
if (!lookup_glsym(#fn, (void **) &p##fn)) retval = false;
#include "OpenGLStubs.h"
#undef GL_FUNC
return retval;
}
#endif
void unload_all_glsyms()
{
#if BBGE_BUILD_OPENGL_DYNAMIC
// reset all the entry points to NULL, so we know exactly what happened
// if we call a GL function after shutdown.
#define GL_FUNC(ret,fn,params,call,rt) \
p##fn = NULL;
#include "OpenGLStubs.h"
#undef GL_FUNC
#endif
}
#endif

9
BBGE/GLLoad.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef BBGE_GLLOAD_H
#define BBGE_GLLOAD_H
bool lookup_all_glsyms();
void unload_all_glsyms();
extern unsigned g_dbg_numRenderCalls;
#endif

View file

@ -1,6 +1,8 @@
#ifndef BBGE_GAME_KEYS_H
#define BBGE_GAME_KEYS_H
#include "BBGECompileConfig.h"
#ifdef BBGE_BUILD_SDL2
#include <SDL_scancode.h>

View file

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Gradient.h"
#include "Core.h"
#include "RenderBase.h"
Gradient::Gradient() : RenderObject()
{

View file

@ -1,24 +1,5 @@
#include "Localization.h"
#ifdef BBGE_BUILD_UNIX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#ifdef BBGE_BUILD_MACOSX
#include <CoreFoundation/CFLocale.h>
#include <CoreFoundation/CFString.h>
// veeery clunky.
static std::string _CFToStdString(CFStringRef cs)
{
char buf[1024];
CFStringGetCString(cs, &buf[0], 1024, kCFStringEncodingUTF8);
return &buf[0];
}
#endif
static std::string s_locale;
static std::string s_modpath;
@ -84,57 +65,4 @@ std::string localisePath(const std::string &path, const std::string& modpath /*
return path;
}
std::string getSystemLocale()
{
std::string localeStr;
#ifdef BBGE_BUILD_WINDOWS
LCID lcid = GetThreadLocale();
char buf[100];
char ctry[100];
if (GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, buf, sizeof buf) != 0)
{
localeStr = buf;
if (GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, ctry, sizeof ctry) != 0)
{
localeStr += "_";
localeStr += ctry;
}
}
#elif BBGE_BUILD_MACOSX
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringRef buf;
if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleLanguageCode)) != NULL)
{
localeStr = _CFToStdString(buf);
if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleCountryCode)) != NULL)
{
localeStr += "_";
localeStr += _CFToStdString(buf);
}
}
CFRelease(locale);
#else
const char *lang = (const char *)getenv("LANG");
if (lang && *lang)
{
localeStr = lang;
size_t found = localeStr.find('.');
if (found != std::string::npos)
localeStr.resize(found);
}
#endif
return localeStr;
}

View file

@ -1,5 +1,5 @@
#include "MT.h"
#include "Base.h"
#include "SDL.h"
// --------- Lockable ----------

View file

@ -1,23 +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.
*/
#include "MathFunctions.h"

Some files were not shown because too many files have changed in this diff Show more