zengine/include/ZE_ZEngine.h

160 lines
4.2 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_NOTE,
ZERR_VERBOSE,
ZERR_DEPRECIATED,
ZERR_WARNING,
ZERR_ERROR,
ZERR_CRITICAL
};
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;
private:
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;
2003-12-24 04:43:36 +00:00
ZErrorLogStyle mLogStyle;
2003-07-12 01:25:42 +00:00
std::FILE *mErrlog;
SDL_EventFilter mEventFilter;
ZRandGen mRandGen;
2003-12-24 04:43:36 +00:00
TiXmlDocument rZRF;
2003-07-12 01:25:42 +00:00
#ifdef USE_SDL_MIXER
2003-10-24 21:20:08 +00:00
bool mSoundInitialized;
int mSoundRate;
2003-07-12 01:25:42 +00:00
bool mStereo;
#endif
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();
2003-12-24 04:43:36 +00:00
bool CreateDisplay(int width, int height, int bpp, bool fullscreen, std::string title="ZEngine Application",
2003-10-21 01:17:09 +00:00
int soundRate=22050, bool stereo=false, std::string icon="");
2003-07-12 01:25:42 +00:00
void CloseDisplay();
void ToggleFullscreen();
SDL_Surface* Display();
2003-07-12 01:25:42 +00:00
void Update();
2003-08-01 21:57:32 +00:00
void Clear(Uint8 red=0, Uint8 green=0, Uint8 blue=0, Uint8 alpha=255);
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
double GetFrameTime();
double GetFramerate();
2003-07-12 01:25:42 +00:00
bool IsActive();
void RequestQuit();
bool QuitRequested();
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-24 04:43:36 +00:00
void SetErrorLog(ZErrorLogStyle logStyle, std::string logFile);
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);
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__