1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#pragma once
#include <MyGUI.h>
#include "InputManager.h"
#include "PointerManager.h"
#include <SDL.h>
namespace base
{
class SdlBaseManager : public input::InputManager, public input::PointerManager
{
public:
SdlBaseManager(bool _isOpenGlWindow);
// Block of virtual functions for specific platform implementations
virtual bool createRender(int _width, int _height, bool _windowed) = 0;
virtual void destroyRender() = 0;
virtual void createGuiPlatform() = 0;
virtual void destroyGuiPlatform() = 0;
virtual void drawOneFrame() = 0;
virtual void resizeRender(int _width, int _height) = 0;
virtual void addResourceLocation(const std::string& _name, bool _recursive = false) = 0;
virtual void makeScreenShot()
{
MYGUI_LOG(Warning, "makeScreenShot not implemented");
}
bool create(int _width = 1024, int _height = 768);
void destroy();
void run();
void quit();
void setWindowCaption(const std::wstring& _text);
const std::string& getRootMedia() const;
void setResourceFilename(std::string_view _flename);
/*internal:*/
void _windowResized(int w, int h);
virtual void prepare()
{
}
virtual MyGUI::MapString getStatistic();
protected:
virtual void createScene()
{
}
virtual void destroyScene()
{
}
virtual void setupResources();
void injectMouseMove(int _absx, int _absy, int _absz) override;
void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id) override;
void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id) override;
void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) override;
void injectKeyRelease(MyGUI::KeyCode _key) override;
virtual void createGui();
virtual void destroyGui();
virtual void setWindowMaximized(bool _value);
virtual bool getWindowMaximized() const;
virtual void setWindowCoord(const MyGUI::IntCoord& _value);
virtual MyGUI::IntCoord getWindowCoord() const;
void* convertPixelData(SDL_Surface* _image, MyGUI::PixelFormat& _myGuiPixelFormat);
protected:
SDL_Window* mSdlWindow = nullptr;
bool mEnableVSync = false;
private:
MyGUI::Gui* mGUI = nullptr;
bool mIsOpenGlWindow = false;
bool mPlatformReady = false;
bool mExit = false;
SDL_Event mEvent;
std::string mRootMedia;
std::string mResourceFileName = "MyGUI_Core.xml";
bool mWindowOn = false;
SDL_Keycode mKeyCode;
int mFpsCounter = 0;
};
}
|