You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.8 KiB
102 lines
2.8 KiB
#ifndef __GUI_SDL_HEADER__
|
|
#define __GUI_SDL_HEADER__
|
|
|
|
#include <stdio.h>
|
|
#include <vector>
|
|
#include "../components/base/basicMutex.h"
|
|
#include "../components/base/basicThread.h"
|
|
#include "../components/base/basicLogCollection.h"
|
|
#include "../components/base/basicSettingsProvider.h"
|
|
#include <SDL.h>
|
|
#include <SDL_image.h>
|
|
#include <SDL_ttf.h>
|
|
#include "core/coreElement.h"
|
|
#include "core/coreLayout.h"
|
|
|
|
extern "C" {
|
|
FILE* __cdecl __iob_func(void);
|
|
}
|
|
|
|
class sdlJoystickWrapper;
|
|
|
|
#define SCREEN_WIDTH 800
|
|
#define SCREEN_HEIGHT 600
|
|
|
|
typedef struct {
|
|
SDL_Renderer* renderer;
|
|
SDL_Window* window;
|
|
int up;
|
|
int down;
|
|
int left;
|
|
int right;
|
|
int fire;
|
|
} App;
|
|
|
|
typedef struct {
|
|
int x;
|
|
int y;
|
|
int dx;
|
|
int dy;
|
|
SDL_Texture* texture;
|
|
int health;
|
|
} Entity;
|
|
|
|
class classGUI_SDL: public basicThread{
|
|
private:
|
|
bool m_bInitOk;
|
|
bool m_bWindowSystemOk;
|
|
bool m_bUseAltBackground;
|
|
config_setting_t * m_pSettings;
|
|
basicLogCollection * m_pLog;
|
|
|
|
SDL_Color m_sBackgroundSolidColor;
|
|
uint32_t m_aBackgroundGradientColor[4];
|
|
char m_pBackgroundFileName[256];
|
|
SDL_Texture * m_pBackgroundTexture;
|
|
uint32_t m_nBackgroundTextureWidth;
|
|
uint32_t m_nBackgroundTextureHeight;
|
|
|
|
SDL_Color m_sAltBackgroundSolidColor;
|
|
uint32_t m_aAltBackgroundGradientColor[4];
|
|
char m_pAltBackgroundFileName[256];
|
|
SDL_Texture * m_pAltBackgroundTexture;
|
|
uint32_t m_nAltBackgroundTextureWidth;
|
|
uint32_t m_nAltBackgroundTextureHeight;
|
|
|
|
SDL_Window * m_pWindow;
|
|
SDL_Renderer * m_pRenderer;
|
|
sdlJoystickWrapper * m_pJoystickWraper;
|
|
sdlCoreLayout * m_pMainLayout;
|
|
int m_nWindowMode;
|
|
int m_nBackgroundMode;
|
|
int m_nWidth;
|
|
int m_nHeight;
|
|
int m_iCursorPosX;
|
|
int m_iCursorPosY;
|
|
basicMutex * m_pProtector;
|
|
vectorGEL m_vGraphicElements;
|
|
TEXTURE_HEAP m_vTextureHeap;
|
|
//App app;
|
|
void doKeyUp(SDL_KeyboardEvent* event);
|
|
void doKeyDown(SDL_KeyboardEvent* event);
|
|
public:
|
|
static classGUI_SDL * getInstance();
|
|
SDL_Renderer * getRenderer(void) { return m_pRenderer; };
|
|
virtual void m_fThreadProc(void);
|
|
void registerGEL( sdlGraphicElement* tPtr);
|
|
void removeGEL( sdlGraphicElement* tPtr);
|
|
void registerJoystickWraper(sdlJoystickWrapper* Ptr);
|
|
bool setFullScreen( bool status );
|
|
void alterateBackground(bool b) { m_bUseAltBackground = b; };
|
|
void setLayout(sdlCoreLayout* ll);
|
|
TEXTURE_HEAP_ITEM * loadTexture(char* filename);
|
|
TEXTURE_HEAP_ITEM * createTexture(int width, int height);
|
|
TEXTURE_HEAP_ITEM * createYUV420PTexture(int width, int height, bool streaming = true);
|
|
SDL_Surface * loadSurface(CSTR path);
|
|
protected:
|
|
classGUI_SDL();
|
|
~classGUI_SDL();
|
|
static classGUI_SDL * m_pInstance;
|
|
};
|
|
|
|
#endif
|