zengine/include/ZE_ZEngine.h

161 lines
4.4 KiB
C
Raw Normal View History

2003-07-12 01:25:42 +00:00
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
Copyright (C) 2002-2004 James Turk
2003-07-12 01:25:42 +00:00
Licensed under a BSD-style license.
The maintainer of this library is James Turk (james@conceptofzero.net)
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
#ifndef __ze_zengine_h__
#define __ze_zengine_h__
#include "ZE_Defines.h"
#include "ZE_Utility.h"
#include "ZE_Includes.h"
#include "ZE_ZRandGen.h"
#include "VersionInfo.h"
namespace ZE
{
2003-09-21 03:28:53 +00:00
class ZRect;
2003-12-24 04:43:36 +00:00
enum ZErrorSeverity
{
ZERR_VERBOSE,
ZERR_DEPRECIATED,
ZERR_WARNING,
ZERR_ERROR,
2004-01-02 10:37:18 +00:00
ZERR_CRITICAL,
ZERR_NOTE
2003-12-24 04:43:36 +00:00
};
2003-11-23 19:30:26 +00:00
2003-12-24 04:43:36 +00:00
enum ZErrorLogStyle
2003-11-23 19:30:26 +00:00
{
2003-12-24 04:43:36 +00:00
ZLOG_NONE,
ZLOG_TEXT,
ZLOG_HTML
2003-11-23 19:30:26 +00:00
};
2003-07-12 01:25:42 +00:00
class ZEngine
{
public:
static VersionInfo Version;
2004-01-02 10:37:18 +00:00
private:
2003-07-12 01:25:42 +00:00
static ZEngine *sInstance;
2003-10-21 01:17:09 +00:00
SDL_Surface *mScreen;
2003-07-12 01:25:42 +00:00
bool mFullscreen;
bool mInitialized;
bool mPaused;
bool mUnpauseOnActive;
Uint32 mNextUpdate;
Uint32 mLastPause;
Uint32 mPausedTime;
Uint32 mLastTime;
double mSecPerFrame;
bool mNeedReload;
bool mActive;
bool mQuit;
Uint8 *mKeyIsPressed;
bool mKeyPress[SDLK_LAST];
int mMouseX;
int mMouseY;
Uint8 mMouseB;
2004-01-02 10:37:18 +00:00
SDL_EventFilter mEventFilter;
2003-12-24 04:43:36 +00:00
ZErrorLogStyle mLogStyle;
2004-01-02 10:37:18 +00:00
ZErrorSeverity mMinSeverity;
2003-07-12 01:25:42 +00:00
std::FILE *mErrlog;
ZRandGen mRandGen;
2003-12-24 04:43:36 +00:00
TiXmlDocument rZRF;
2004-01-02 10:37:18 +00:00
#ifdef USE_AUDIERE
audiere::AudioDevicePtr mAudiereDevice;
#endif //USE_AUDIERE
2003-07-12 01:25:42 +00:00
ZEngine();
2003-12-24 04:43:36 +00:00
TiXmlElement* FindElement(std::string type, std::string id);
2003-07-12 01:25:42 +00:00
public:
static ZEngine* GetInstance();
static void ReleaseInstance();
2004-01-02 10:37:18 +00:00
void InitErrorLog(ZErrorLogStyle logStyle=ZLOG_HTML, std::string logFile="errlog.html", ZErrorSeverity severityFilter=ZERR_VERBOSE);
bool InitSound();
bool CreateDisplay(int width, int height, int bpp, bool fullscreen, std::string title="ZEngine Application", std::string icon="");
2003-07-12 01:25:42 +00:00
void CloseDisplay();
void ToggleFullscreen();
void Update();
2004-01-02 10:37:18 +00:00
void ClearDisplay(Uint8 red=0, Uint8 green=0, Uint8 blue=0);
2003-07-12 01:25:42 +00:00
#if (GFX_BACKEND == ZE_OGL)
2003-07-12 01:25:42 +00:00
void SetGL2D();
2003-08-01 21:57:32 +00:00
#endif //GFX_BACKEND
2003-07-12 01:25:42 +00:00
void Delay(Uint32 milliseconds);
Uint32 GetTime();
void PauseTimer();
void UnpauseTimer();
bool TimerIsPaused();
2003-07-12 01:25:42 +00:00
2004-01-02 10:37:18 +00:00
double GetFrameSpeed();
2003-07-12 01:25:42 +00:00
double GetFramerate();
2003-07-12 01:25:42 +00:00
bool IsActive();
void RequestQuit();
bool QuitRequested();
2004-01-02 10:37:18 +00:00
2003-07-12 01:25:42 +00:00
void SetReloadNeed(bool state);
bool ImagesNeedReload();
void SetKeyRepeatRate(int rate);
bool KeyIsPressed(SDLKey key);
bool KeyPress(SDLKey key);
void HideCursor();
void ShowCursor();
int MouseX();
int MouseY();
bool LButtonPressed();
bool RButtonPressed();
bool MButtonPressed();
2003-12-24 04:43:36 +00:00
bool MouseInRect(const SDL_Rect &rect);
bool MouseInRect(const ZRect &rect);
2003-07-12 01:25:42 +00:00
void CheckEvents();
void SetEventFilter(SDL_EventFilter filter);
2003-12-31 21:17:11 +00:00
void ReportError(ZErrorSeverity type, std::string desc, ...);
2003-12-24 04:43:36 +00:00
void WriteLog(std::string str, ...);
2003-07-12 01:25:42 +00:00
void SeedRandGen(unsigned long seed);
unsigned int Rand(unsigned int max);
unsigned long Rand(unsigned long max);
int Rand(int min, int max);
long Rand(long min, long max);
float Rand(float min, float max);
double Rand(double min, double max);
2003-07-12 01:25:42 +00:00
double RandDouble();
2003-12-24 04:43:36 +00:00
void SetResourceFile(std::string filename);
std::string GetStringResource(std::string type, std::string id, std::string element);
int GetIntResource(std::string type, std::string id, std::string element);
2003-12-24 04:43:36 +00:00
double GetDoubleResource(std::string type, std::string id, std::string element);
2004-01-02 10:37:18 +00:00
#ifdef USE_AUDIERE
audiere::AudioDevicePtr GetSoundDevice();
#endif //USE_AUDIERE
SDL_Surface* GetDisplayPointer();
bool DisplayCreated();
2003-12-24 04:43:36 +00:00
int DisplayWidth();
int DisplayHeight();
int DisplayDepth();
2003-07-12 01:25:42 +00:00
bool IsFullscreen();
};
}
#endif //__ze_zengine_h__