2011-08-03 20:05:33 +00:00
|
|
|
/*
|
|
|
|
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 __core__
|
|
|
|
#define __core__
|
|
|
|
|
|
|
|
/*
|
|
|
|
valid BUILD_ flags
|
|
|
|
WIN32/BUILD_WIN32
|
|
|
|
BUILD_MACOSX
|
|
|
|
BUILD_X360
|
|
|
|
BUILD_LINUX
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Base.h"
|
|
|
|
#include "RenderObject.h"
|
|
|
|
#include "SoundManager.h"
|
|
|
|
#include "ActionMapper.h"
|
|
|
|
#include "Event.h"
|
|
|
|
#include "StateManager.h"
|
|
|
|
#include "Effects.h"
|
2012-07-10 20:16:48 +00:00
|
|
|
#include "Localization.h"
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
#include "DarkLayer.h"
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
#include "FrameBuffer.h"
|
|
|
|
#include "Shader.h"
|
|
|
|
|
|
|
|
class ParticleEffect;
|
|
|
|
|
|
|
|
class ParticleManager;
|
|
|
|
|
|
|
|
void initInputCodeMap();
|
|
|
|
void clearInputCodeMap();
|
|
|
|
std::string getInputCodeToString(int key);
|
|
|
|
std::string getInputCodeToUserString(int key);
|
|
|
|
int getStringToInputCode(const std::string &string);
|
|
|
|
|
|
|
|
struct ScreenMode
|
|
|
|
{
|
2015-07-12 18:25:46 +00:00
|
|
|
ScreenMode() { idx = x = y = hz = 0; }
|
|
|
|
ScreenMode(int i, int x, int y, int hz) : idx(i), x(x), y(y), hz(hz) {}
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2015-07-12 18:25:46 +00:00
|
|
|
int idx, x, y, hz;
|
2011-08-03 20:05:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CoreSettings
|
|
|
|
{
|
2012-05-27 02:46:36 +00:00
|
|
|
CoreSettings() { renderOn = true; updateOn = true; runInBackground = false; prebufferSounds = false; }
|
2011-08-03 20:05:33 +00:00
|
|
|
bool renderOn;
|
|
|
|
bool runInBackground;
|
|
|
|
bool updateOn; // NOT IMPLEMENTED YET
|
2012-05-27 02:46:36 +00:00
|
|
|
bool prebufferSounds;
|
2011-08-03 20:05:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum CoreFlags
|
|
|
|
{
|
|
|
|
CF_CLEARBUFFERS = 0x00000001,
|
|
|
|
CF_SORTENABLED = 0x00000010
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CoreLayers
|
|
|
|
{
|
|
|
|
LR_NONE = -1
|
|
|
|
};
|
|
|
|
|
|
|
|
const int NO_FOLLOW_CAMERA = -999;
|
|
|
|
|
|
|
|
class AfterEffectManager;
|
|
|
|
|
|
|
|
class Texture;
|
|
|
|
|
|
|
|
const int baseVirtualWidth = 800;
|
|
|
|
const int baseVirtualHeight = 600;
|
|
|
|
|
|
|
|
enum GameKeys
|
|
|
|
{
|
2016-05-05 17:40:28 +00:00
|
|
|
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2013-07-18 21:29:55 +00:00
|
|
|
KEY_LSUPER,
|
|
|
|
KEY_RSUPER,
|
|
|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N };
|
|
|
|
|
|
|
|
struct MouseButtons
|
|
|
|
{
|
|
|
|
MouseButtons ()
|
|
|
|
{
|
|
|
|
left = UP;
|
|
|
|
right = UP;
|
|
|
|
middle = UP;
|
|
|
|
}
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
ButtonState left, right, middle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Mouse
|
|
|
|
{
|
|
|
|
Mouse()
|
|
|
|
{
|
|
|
|
scrollWheel = scrollWheelChange = lastScrollWheel = 0;
|
|
|
|
buttonsEnabled = true;
|
|
|
|
movementEnabled = true;
|
|
|
|
}
|
|
|
|
Vector position, lastPosition;
|
|
|
|
MouseButtons buttons;
|
|
|
|
MouseButtons pure_buttons;
|
|
|
|
Vector change;
|
|
|
|
|
|
|
|
|
|
|
|
// movementEnabled is not implemented yet
|
|
|
|
bool buttonsEnabled, movementEnabled;
|
|
|
|
|
|
|
|
int scrollWheel, scrollWheelChange, lastScrollWheel;
|
|
|
|
};
|
|
|
|
|
|
|
|
const int maxJoyBtns = 64;
|
|
|
|
|
|
|
|
class Joystick
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Joystick();
|
|
|
|
void init(int stick=0);
|
|
|
|
void shutdown();
|
|
|
|
//Ranges from 0 to 65535 (full speed).
|
|
|
|
void rumble(float leftMotor, float rightMotor, float time);
|
|
|
|
void update(float dt);
|
|
|
|
Vector position, lastPosition;
|
|
|
|
ButtonState buttons[maxJoyBtns];
|
|
|
|
float deadZone1, deadZone2;
|
|
|
|
float clearRumbleTime;
|
|
|
|
|
|
|
|
void callibrate(Vector &vec, float dead);
|
|
|
|
|
|
|
|
float leftTrigger, rightTrigger;
|
|
|
|
bool leftThumb, rightThumb, leftShoulder, rightShoulder, dpadLeft, dpadRight, dpadUp, dpadDown;
|
|
|
|
bool btnStart, btnSelect;
|
|
|
|
Vector rightStick;
|
|
|
|
bool inited, xinited;
|
|
|
|
bool anyButton();
|
2013-07-18 21:29:55 +00:00
|
|
|
# ifdef BBGE_BUILD_SDL2
|
|
|
|
SDL_GameController *sdl_controller;
|
|
|
|
SDL_Haptic *sdl_haptic;
|
|
|
|
# endif
|
2011-08-03 20:05:33 +00:00
|
|
|
SDL_Joystick *sdl_joy;
|
2013-07-18 21:29:55 +00:00
|
|
|
#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2)
|
2011-08-03 20:05:33 +00:00
|
|
|
int eventfd;
|
|
|
|
int16_t effectid;
|
|
|
|
#endif
|
|
|
|
int stickIndex;
|
|
|
|
|
|
|
|
int s1ax, s1ay, s2ax, s2ay;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FollowCameraLock
|
|
|
|
{
|
|
|
|
FCL_NONE = 0,
|
|
|
|
FCL_HORZ = 1,
|
|
|
|
FCL_VERT = 2
|
|
|
|
};
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define RLT_FIXED
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
typedef std::vector <RenderObject*> RenderObjects;
|
|
|
|
typedef std::list <RenderObject*> RenderObjectList;
|
|
|
|
typedef std::map <intptr_t, RenderObject*> RenderObjectMap;
|
|
|
|
|
|
|
|
class RenderObjectLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RenderObjectLayer();
|
|
|
|
~RenderObjectLayer();
|
|
|
|
void add(RenderObject* r);
|
|
|
|
void remove(RenderObject* r);
|
|
|
|
void moveToFront(RenderObject *r);
|
|
|
|
void moveToBack(RenderObject *r);
|
|
|
|
void setCull(bool cull);
|
|
|
|
void setOptimizeStatic(bool opt);
|
|
|
|
void sort();
|
|
|
|
void renderPass(int pass);
|
|
|
|
void reloadDevice();
|
|
|
|
|
|
|
|
inline bool empty()
|
|
|
|
{
|
|
|
|
return objectCount == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline RenderObject *getFirst()
|
|
|
|
{
|
|
|
|
iter = 0;
|
|
|
|
return getNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderObject *getNext()
|
|
|
|
{
|
|
|
|
const int size = renderObjects.size();
|
|
|
|
int i;
|
|
|
|
for (i = iter; i < size; i++)
|
|
|
|
{
|
|
|
|
if (renderObjects[i] != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < size)
|
|
|
|
{
|
|
|
|
iter = i+1;
|
|
|
|
return renderObjects[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iter = i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//inclusive
|
|
|
|
int startPass, endPass;
|
|
|
|
bool visible;
|
|
|
|
float followCamera;
|
|
|
|
|
|
|
|
int followCameraLock;
|
|
|
|
bool cull;
|
|
|
|
bool update;
|
|
|
|
|
|
|
|
int mode;
|
|
|
|
|
|
|
|
Vector color;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void clearDisplayList();
|
|
|
|
void generateDisplayList();
|
|
|
|
inline void renderOneObject(RenderObject *robj);
|
|
|
|
|
|
|
|
bool optimizeStatic;
|
|
|
|
bool displayListValid;
|
|
|
|
int displayListGeneration;
|
|
|
|
struct DisplayListElement {
|
|
|
|
DisplayListElement() {isList = false; u.robj = 0;}
|
|
|
|
bool isList; // True if this is a GL display list
|
|
|
|
union {
|
|
|
|
RenderObject *robj;
|
|
|
|
GLuint listID;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
std::vector<DisplayListElement> displayList;
|
|
|
|
|
|
|
|
RenderObjects renderObjects;
|
2017-01-14 17:10:20 +00:00
|
|
|
size_t objectCount;
|
|
|
|
size_t firstFreeIdx;
|
|
|
|
size_t iter;
|
2011-08-03 20:05:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Core : public ActionMapper, public StateManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// init
|
2013-06-19 00:08:24 +00:00
|
|
|
Core(const std::string &filesystem, const std::string& extraDataDir, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder="");
|
2011-08-03 20:05:33 +00:00
|
|
|
void initPlatform(const std::string &filesystem);
|
|
|
|
~Core();
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
|
|
|
|
void initRenderObjectLayers(int num);
|
|
|
|
|
|
|
|
void applyState(const std::string &state);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle="");
|
2016-05-05 17:40:28 +00:00
|
|
|
|
|
|
|
void clearBuffers();
|
2011-08-03 20:05:33 +00:00
|
|
|
void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true);
|
|
|
|
void showBuffer();
|
|
|
|
void quit();
|
|
|
|
bool isShuttingDown();
|
|
|
|
bool isWindowFocus();
|
|
|
|
|
|
|
|
void instantQuit();
|
|
|
|
|
|
|
|
void cacheRender();
|
|
|
|
|
|
|
|
void setSDLGLAttributes();
|
|
|
|
|
|
|
|
void reloadResources();
|
|
|
|
void unloadResources();
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
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();
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
void main(float runTime = -1); // can use main
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
// state functions
|
|
|
|
|
|
|
|
std::string getTextureLoadName(const std::string &texture);
|
|
|
|
|
|
|
|
void setMousePosition(const Vector &p);
|
|
|
|
|
|
|
|
void toggleScreenMode(int t=0);
|
|
|
|
|
|
|
|
void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false);
|
2017-01-14 17:10:20 +00:00
|
|
|
void addRenderObject(RenderObject *o, size_t layer=0);
|
2011-08-03 20:05:33 +00:00
|
|
|
void switchRenderObjectLayer(RenderObject *o, int toLayer);
|
2015-03-23 23:06:51 +00:00
|
|
|
void addTexture(Texture *r);
|
|
|
|
CountedPtr<Texture> findTexture(const std::string &name);
|
|
|
|
void removeTexture(Texture *res);
|
|
|
|
void clearResources();
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2016-03-13 00:37:43 +00:00
|
|
|
CountedPtr<Texture> addTexture(const std::string &texture);
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
PostProcessingFX postProcessingFx;
|
|
|
|
|
|
|
|
enum RemoveRenderObjectFlag { DESTROY_RENDER_OBJECT=0, DO_NOT_DESTROY_RENDER_OBJECT };
|
|
|
|
void removeRenderObject(RenderObject *r, RemoveRenderObjectFlag flag = DESTROY_RENDER_OBJECT);
|
|
|
|
|
|
|
|
void setMouseConstraint(bool on);
|
2014-03-10 01:26:01 +00:00
|
|
|
void setMouseConstraintCircle(const Vector& pos, float mouseCircle);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void setReentryInputGrab(int on);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void action(int id, int state){}
|
|
|
|
|
|
|
|
bool exists(const std::string &file);
|
|
|
|
|
|
|
|
void enqueueRenderObjectDeletion(RenderObject *object);
|
|
|
|
void clearGarbage();
|
|
|
|
|
|
|
|
|
|
|
|
bool isNested() { return nestedMains > 1; }
|
|
|
|
int getNestedMains() { return nestedMains; }
|
|
|
|
void quitNestedMain();
|
|
|
|
|
|
|
|
int getWindowWidth() { return width; }
|
|
|
|
int getWindowHeight() { return height; }
|
|
|
|
|
|
|
|
void updateCursorFromJoystick(float dt, int spd);
|
|
|
|
|
2016-05-05 18:05:38 +00:00
|
|
|
unsigned getTicks();
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
float stopWatch(int d);
|
|
|
|
|
|
|
|
|
|
|
|
float stopWatchStartTime;
|
|
|
|
|
|
|
|
|
|
|
|
void resetGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setDockIcon(const std::string &ident);
|
|
|
|
|
|
|
|
Vector getGameCursorPosition();
|
|
|
|
Vector getGamePosition(const Vector &v);
|
|
|
|
|
|
|
|
Vector joystickPosition;
|
|
|
|
|
|
|
|
bool coreVerboseDebug;
|
|
|
|
|
|
|
|
|
|
|
|
Vector screenCenter;
|
|
|
|
|
|
|
|
void print(int x, int y, const char *str, float sz=1);
|
|
|
|
|
|
|
|
// windows variables
|
|
|
|
#ifdef BBGE_BUILD_WINDOWS
|
|
|
|
HDC hDC; // Private GDI Device Context
|
|
|
|
HGLRC hRC; // Permanent Rendering Context
|
|
|
|
HWND hWnd; // Holds Our Window Handle
|
|
|
|
HINSTANCE hInstance; // Holds The Instance Of The Application
|
|
|
|
#endif
|
|
|
|
|
2015-03-23 23:06:51 +00:00
|
|
|
std::vector<Texture*> resources;
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
RenderObjectLayer *getRenderObjectLayer(int i);
|
|
|
|
std::vector <int> renderObjectLayerOrder;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
typedef std::vector<RenderObjectLayer> RenderObjectLayers;
|
|
|
|
RenderObjectLayers renderObjectLayers;
|
|
|
|
|
|
|
|
RenderObjectList garbage;
|
|
|
|
|
|
|
|
SoundManager *sound;
|
|
|
|
|
|
|
|
float aspect;
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
enum Modes { MODE_NONE=-1, MODE_3D=0, MODE_2D };
|
|
|
|
|
|
|
|
InterpolatedVector globalScale;
|
|
|
|
Vector globalResolutionScale;
|
|
|
|
Vector screenCapScale;
|
|
|
|
|
|
|
|
virtual void onResetScene(){}
|
|
|
|
|
|
|
|
virtual void onPlayedVoice(const std::string &name){}
|
|
|
|
|
2014-03-07 16:59:36 +00:00
|
|
|
Vector cameraPos;
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
int fps;
|
|
|
|
bool loopDone;
|
|
|
|
|
|
|
|
Mouse mouse;
|
|
|
|
|
|
|
|
AfterEffectManager *afterEffectManager;
|
|
|
|
|
|
|
|
ParticleManager *particleManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setBaseTextureDirectory(const std::string &baseTextureDirectory)
|
|
|
|
{ this->baseTextureDirectory = baseTextureDirectory; }
|
|
|
|
std::string getBaseTextureDirectory()
|
|
|
|
{
|
|
|
|
return baseTextureDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool canChangeState();
|
|
|
|
void resetTimer();
|
|
|
|
|
|
|
|
inline int getVirtualWidth()
|
|
|
|
{
|
|
|
|
return virtualWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int getVirtualHeight()
|
|
|
|
{
|
|
|
|
return virtualHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char *grabScreenshot(int x, int y, int w, int h);
|
|
|
|
unsigned char *grabCenteredScreenshot(int w, int h);
|
|
|
|
int saveScreenshotTGA(const std::string &filename);
|
|
|
|
void save64x64ScreenshotTGA(const std::string &filename);
|
|
|
|
void saveSizedScreenshotTGA(const std::string &filename, int sz, int crop34);
|
|
|
|
void saveCenteredScreenshotTGA(const std::string &filename, int sz);
|
|
|
|
|
|
|
|
bool minimized;
|
|
|
|
std::string getEnqueuedJumpState();
|
2014-03-07 16:59:36 +00:00
|
|
|
float cullRadius;
|
2011-08-03 20:05:33 +00:00
|
|
|
float cullRadiusSqr;
|
|
|
|
Vector cullCenter;
|
|
|
|
unsigned int renderObjectCount, processedRenderObjectCount, totalRenderObjectCount;
|
|
|
|
float invGlobalScale, invGlobalScaleSqr;
|
|
|
|
|
2014-03-07 16:59:36 +00:00
|
|
|
void globalScaleChanged();
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void screenshot();
|
|
|
|
|
|
|
|
void clearRenderObjects();
|
|
|
|
|
|
|
|
void applyMatrixStackToWorld();
|
|
|
|
void translateMatrixStack(float x, float y, float z=0);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void rotateMatrixStack(float x, float y, float z);
|
|
|
|
void scaleMatrixStack(float x, float y, float z=1);
|
|
|
|
void rotateMatrixStack(float z);
|
|
|
|
void setColor(float r, float g, float b, float a);
|
|
|
|
|
|
|
|
void bindTexture(int stage, unsigned int handle);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
bool getKeyState(int k);
|
|
|
|
bool getMouseButtonState(int m);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
int currentLayerPass;
|
|
|
|
int keys[KEY_MAXARRAY];
|
|
|
|
virtual void debugLog(const std::string &s);
|
|
|
|
virtual void errorLog(const std::string &s);
|
|
|
|
void messageBox(const std::string &title, const std::string &msg);
|
|
|
|
bool getShiftState();
|
|
|
|
bool getAltState();
|
|
|
|
bool getCtrlState();
|
|
|
|
bool getMetaState();
|
|
|
|
|
|
|
|
virtual void generateCollisionMask(RenderObject *r){}
|
|
|
|
|
|
|
|
DarkLayer darkLayer;
|
|
|
|
|
|
|
|
int redBits, greenBits, blueBits, alphaBits;
|
|
|
|
|
|
|
|
void setupRenderPositionAndScale();
|
|
|
|
void setupGlobalResolutionScale();
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
int particlesPaused;
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
bool joystickEnabled;
|
|
|
|
bool joystickOverrideMouse;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
bool debugLogTextures;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
Joystick joystick;
|
|
|
|
void setClearColor(const Vector &c);
|
|
|
|
Vector getClearColor();
|
|
|
|
int flipMouseButtons;
|
|
|
|
void initFrameBuffer();
|
|
|
|
FrameBuffer frameBuffer;
|
|
|
|
void updateRenderObjects(float dt);
|
|
|
|
bool joystickAsMouse;
|
|
|
|
virtual void prepScreen(bool t){}
|
|
|
|
|
|
|
|
bool updateMouse;
|
|
|
|
bool frameOutputMode;
|
|
|
|
|
|
|
|
int overrideStartLayer, overrideEndLayer;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void setWindowCaption(const std::string &caption, const std::string &icon);
|
|
|
|
|
|
|
|
ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0);
|
|
|
|
|
|
|
|
std::string secondaryTexturePath;
|
|
|
|
|
|
|
|
bool hasFocus();
|
|
|
|
|
|
|
|
EventQueue eventQueue;
|
|
|
|
|
|
|
|
float aspectX, aspectY;
|
|
|
|
|
|
|
|
float get_old_dt() { return old_dt; }
|
2013-07-15 01:22:41 +00:00
|
|
|
float get_current_dt() { return current_dt; }
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
bool debugLogActive;
|
|
|
|
|
|
|
|
void setInputGrab(bool on);
|
|
|
|
|
|
|
|
bool isFullscreen();
|
|
|
|
|
|
|
|
int viewOffX, viewOffY;
|
|
|
|
|
|
|
|
int getVirtualOffX();
|
|
|
|
int getVirtualOffY();
|
|
|
|
|
|
|
|
void centerMouse();
|
|
|
|
|
|
|
|
int vw2, vh2;
|
|
|
|
Vector center;
|
|
|
|
|
|
|
|
void enable2DWide(int rx, int ry);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void enumerateScreenModes();
|
|
|
|
|
|
|
|
std::vector<ScreenMode> screenModes;
|
|
|
|
|
|
|
|
void pollEvents();
|
|
|
|
|
|
|
|
CoreSettings settings;
|
2011-11-20 21:58:36 +00:00
|
|
|
|
2017-01-14 17:10:20 +00:00
|
|
|
int tgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
|
|
|
|
int zgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
|
2011-11-20 21:58:36 +00:00
|
|
|
|
2012-05-27 02:46:36 +00:00
|
|
|
volatile int dbg_numThreadDecoders;
|
2013-04-22 21:36:31 +00:00
|
|
|
static unsigned int dbg_numRenderCalls;
|
2012-05-27 02:46:36 +00:00
|
|
|
|
2013-06-24 01:39:48 +00:00
|
|
|
virtual void onBackgroundUpdate();
|
|
|
|
|
2013-11-14 16:58:33 +00:00
|
|
|
void initLocalization();
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void updateCullData();
|
|
|
|
|
|
|
|
std::string userDataFolder;
|
|
|
|
|
|
|
|
int grabInputOnReentry;
|
|
|
|
|
|
|
|
int virtualOffX, virtualOffY;
|
|
|
|
|
|
|
|
void initIcon();
|
|
|
|
|
|
|
|
float old_dt;
|
2013-07-15 01:22:41 +00:00
|
|
|
float current_dt;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
std::string debugLogPath;
|
|
|
|
|
|
|
|
virtual void onReloadResources();
|
|
|
|
|
2016-03-13 00:37:43 +00:00
|
|
|
CountedPtr<Texture> doTextureAdd(const std::string &texture, const std::string &name, std::string internalTextureName);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void deleteRenderObjectMemory(RenderObject *r);
|
|
|
|
bool _hasFocus;
|
|
|
|
bool lib_graphics, lib_sound, lib_input;
|
|
|
|
Vector clearColor;
|
|
|
|
bool updateCursorFromMouse;
|
|
|
|
virtual void unloadDevice();
|
|
|
|
virtual void reloadDevice();
|
|
|
|
|
|
|
|
std::string appName;
|
|
|
|
bool mouseConstraint;
|
2014-03-07 16:59:36 +00:00
|
|
|
float mouseCircle;
|
2014-03-10 01:26:01 +00:00
|
|
|
Vector mouseConstraintCenter;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
bool doMouseConstraint();
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
virtual void onMouseInput(){}
|
|
|
|
bool doScreenshot;
|
2014-03-07 16:59:36 +00:00
|
|
|
float baseCullRadius;
|
2011-08-03 20:05:33 +00:00
|
|
|
bool initSoundLibrary(const std::string &defaultDevice);
|
|
|
|
bool initInputLibrary();
|
|
|
|
bool initJoystickLibrary(int numSticks=1);
|
|
|
|
bool initGraphicsLibrary(int w, int h, bool fullscreen, int vsync, int bpp, bool recreate=true);
|
|
|
|
void shutdownInputLibrary();
|
|
|
|
void shutdownJoystickLibrary();
|
|
|
|
void shutdownGraphicsLibrary(bool kill=true);
|
|
|
|
void shutdownSoundLibrary();
|
|
|
|
|
|
|
|
int afterEffectManagerLayer;
|
|
|
|
Vector cameraOffset;
|
|
|
|
std::vector<float> avgFPS;
|
|
|
|
virtual void modifyDt(float &dt){}
|
|
|
|
void setPixelScale(int pixelScaleX, int pixelScaleY);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
int virtualHeight, virtualWidth;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
bool shuttingDown;
|
|
|
|
bool quitNestedMainFlag;
|
|
|
|
bool clearedGarbageFlag;
|
|
|
|
int nestedMains;
|
|
|
|
std::string baseTextureDirectory;
|
|
|
|
|
2011-08-11 00:26:46 +00:00
|
|
|
std::ofstream _logOut;
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
int nowTicks, thenTicks;
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
int _vsync, _bpp;
|
|
|
|
bool _fullscreen;
|
|
|
|
|
|
|
|
int numSavedScreenshots;
|
|
|
|
|
2015-03-23 23:06:51 +00:00
|
|
|
CountedPtr<Texture> texError;
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
|
|
|
virtual void onUpdate(float dt);
|
|
|
|
virtual void onRender(){}
|
[vfs, #3] All file reading code goes through the VFS now, new mod downloader & mod selector in place. Also a bunch of other stuff. (...)
- HTTP networking support, mods can be downloaded via the builtin downloader.
All network activity runs in a seperate thread, which is started
as soon as any network activity is requested.
- The master server is hard-coded to fg.wzff.de/aqmods/ if not specified otherwise;
this setting can be overridden in the config file.
- The mod selector screen is now a grid-view for much better navigation;
also works with joystick.
- VFS code is functionally similar to the old molebox-packed release
for win32. The game could also have its data shipped in a Zip file
or any other kind of archive.
- It is still possible to build without VFS support, but then the mod
downloader and soft-patching will not be available.
The full commit history can be found here:
https://github.com/fgenesis/Aquaria_clean/compare/master...vfs
The most important commit messages follow:
[...]
This replaces all std::ifstream with InStream, and fopen(), ... with vfopen(), ...
Some code is #ifdef'd for better performance and less memory-copying.
VFILE is defined to whatever type of file is in use:
- FILE if BBGE_BUILD_VFS is not defined
- tttvfs::VFSFile if it is.
Other changes:
- [un]packFile() is now unused and obsolete. That code has not been adjusted to use VFILE.
- glpng can now load from a memory buffer.
- TinyXML uses the VFS for reading operations now.
- The rather clunky binary stream loading of glfont2 got replaced with ByteBuffer,
which gets its data in one block (necessary to use the VFS without implementing
a somewhat STL-compliant std::ifstream replacement.)
-------------
Implement loading mods from zip files.
-------------
Implement soft-patching game data files. (Replacing textures/audio/... on the fly)
-------------
Misc bits:
- Extended GUI focus handling a bit
- Fixed weirdness in texture loading... not sure but this seems more correct to me.
Actually, considering that the texture will have its native size after restarting the game,
the lines removed with this commit seem pretty useless.
2012-06-01 15:52:19 +00:00
|
|
|
|
|
|
|
void setupFileAccess();
|
2013-06-19 00:08:24 +00:00
|
|
|
std::string _extraDataDir;
|
2011-08-03 20:05:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Core *core;
|
|
|
|
|
|
|
|
#include "RenderObject_inline.h"
|
|
|
|
|
|
|
|
#endif
|