2017-02-25 09:29:34 +08:00
|
|
|
#pragma once
|
2017-05-16 16:27:35 +08:00
|
|
|
#include "MiniEngine_Config.h"
|
2017-02-25 09:29:34 +08:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
2017-03-23 12:22:02 +08:00
|
|
|
#include <functional>
|
2017-05-16 16:23:40 +08:00
|
|
|
#include <vector>
|
2017-02-25 09:29:34 +08:00
|
|
|
|
2017-06-01 22:50:17 +08:00
|
|
|
#define _MINIENGINE_SDL_VERSION_ATLEAST(X,Y,Z) SDL_VERSION_ATLEAST(X,Y,Z)
|
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
namespace MiniEngine
|
|
|
|
{
|
2017-06-18 17:36:13 +08:00
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
|
|
|
|
class NonCopyable
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
NonCopyable() = default;
|
|
|
|
~NonCopyable() = default;
|
|
|
|
NonCopyable(const NonCopyable&) = delete;
|
|
|
|
NonCopyable& operator = (const NonCopyable&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ErrorViewer : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void fetch();
|
2017-06-05 20:43:33 +08:00
|
|
|
std::string getError() const;
|
2017-02-25 09:29:34 +08:00
|
|
|
const char* what() const throw() override;
|
|
|
|
private:
|
|
|
|
std::string str;
|
|
|
|
};
|
|
|
|
|
2017-04-10 15:27:24 +08:00
|
|
|
class RWOP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RWOP(FILE* fp,bool autoclose);
|
|
|
|
RWOP(const std::string& filename,const std::string& openmode);
|
|
|
|
RWOP(const void* mem,int size);
|
|
|
|
RWOP(void* mem,int size);
|
|
|
|
RWOP()=default;
|
|
|
|
~RWOP()=default;
|
2017-05-18 18:14:29 +08:00
|
|
|
|
|
|
|
void release();
|
2017-04-10 15:27:24 +08:00
|
|
|
private:
|
2017-04-12 08:40:12 +08:00
|
|
|
std::shared_ptr<SDL_RWops> _op;
|
2017-05-23 13:05:09 +08:00
|
|
|
SDL_RWops* _get() const;
|
2017-04-12 08:40:12 +08:00
|
|
|
void _clear();
|
|
|
|
void _set(SDL_RWops*);
|
2017-05-23 13:05:09 +08:00
|
|
|
friend class Surface;
|
2017-04-12 08:40:12 +08:00
|
|
|
friend class Renderer;
|
2017-04-10 15:27:24 +08:00
|
|
|
};
|
|
|
|
|
2017-04-12 09:22:15 +08:00
|
|
|
enum class BlendMode { None,Blend,Add,Mod };
|
2017-02-25 09:29:34 +08:00
|
|
|
|
2017-03-02 13:11:50 +08:00
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
|
2017-04-21 11:25:08 +08:00
|
|
|
enum class SystemCursorType
|
|
|
|
{
|
|
|
|
Arrow, Ibeam, CrossHair,
|
|
|
|
Wait, WaitArrow,
|
|
|
|
SizeNWSE, SizeNESW, SizeWE, SizeNS, SizeAll,
|
|
|
|
No, Hand
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-04-12 09:22:15 +08:00
|
|
|
enum class MessageBoxType { Error, Warning, Information };
|
2017-03-21 13:58:48 +08:00
|
|
|
|
2017-05-16 22:33:21 +08:00
|
|
|
enum class WindowType
|
|
|
|
{
|
|
|
|
FullScreen, OpenGL, Shown, Hidden,
|
|
|
|
Borderless, Resizable, Minimized, Maximized,
|
|
|
|
InputGrabbed, InputFocus, MouseFocus,
|
|
|
|
FullScreenDesktop, Foreign, AllowHighDPI,
|
|
|
|
MouseCapture, AlwaysOnTop, SkipTaskBar,
|
|
|
|
Utility, ToolTip, PopUpMenu
|
|
|
|
};
|
|
|
|
|
2017-06-12 13:01:28 +08:00
|
|
|
class WindowMessageBoxButton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WindowMessageBoxButton();
|
|
|
|
WindowMessageBoxButton(const std::string& ButtonText,const std::function<void()>& CallbackFunc=[](){});
|
|
|
|
|
|
|
|
std::string text;
|
|
|
|
std::function<void()> callback;
|
|
|
|
|
|
|
|
/// Default: no hit option set.
|
|
|
|
void setHitAsReturn(bool);
|
|
|
|
void setHitAsEscape(bool);
|
|
|
|
|
|
|
|
bool isHitAsReturn() const;
|
|
|
|
bool isHitAsEscape() const;
|
|
|
|
private:
|
|
|
|
int _hitoption;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WindowMessageBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WindowMessageBox();
|
|
|
|
WindowMessageBox(const std::string& Title,const std::string& Text,MessageBoxType BoxType=MessageBoxType::Information,const std::function<void()>& DefaultCallback=[](){});
|
|
|
|
|
|
|
|
MessageBoxType boxtype;
|
|
|
|
std::string title;
|
|
|
|
std::string text;
|
|
|
|
std::function<void()> defaultcallback;
|
|
|
|
|
|
|
|
void addButton(const WindowMessageBoxButton& button);
|
|
|
|
int getButtonNum() const;
|
|
|
|
WindowMessageBoxButton& getButton(int index);
|
|
|
|
const WindowMessageBoxButton& getButtonConst(int index) const;
|
|
|
|
private:
|
|
|
|
std::vector<WindowMessageBoxButton> _vec;
|
|
|
|
};
|
|
|
|
|
2017-03-21 13:58:48 +08:00
|
|
|
|
2017-06-15 13:53:04 +08:00
|
|
|
|
|
|
|
enum class RendererType { Software, Accelerated, PresentSync, TargetTexture };
|
|
|
|
|
|
|
|
enum class FlipMode { None, Horizontal, Vertical };
|
|
|
|
|
2017-04-12 08:40:12 +08:00
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
|
2017-06-05 14:07:57 +08:00
|
|
|
enum class FontStyle { Normal, Bold, Italic, UnderLine, StrikeThrough };
|
2017-06-06 13:24:43 +08:00
|
|
|
enum class FontHint { Normal, Light, Mono, None , Error };
|
2017-06-05 14:07:57 +08:00
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
|
2017-03-09 18:00:19 +08:00
|
|
|
enum class Platform { Unknown,Windows,MacOS,Linux,iOS,Android };
|
2017-03-21 12:30:29 +08:00
|
|
|
enum class PowerState { Unknown,OnBattery,NoBattery,Charging,Charged };
|
2017-03-09 18:00:19 +08:00
|
|
|
|
2017-03-24 13:50:48 +08:00
|
|
|
class LogSystem
|
|
|
|
{
|
|
|
|
static void v(const char* fmt,...);/// Verbose
|
|
|
|
static void d(const char* fmt,...);/// Debug
|
|
|
|
static void i(const char* fmt,...);/// Information
|
|
|
|
static void w(const char* fmt,...);/// Warning
|
|
|
|
static void e(const char* fmt,...);/// Error
|
|
|
|
static void critical(const char* fmt,...);/// Critical
|
|
|
|
};
|
|
|
|
|
2017-05-11 11:53:26 +08:00
|
|
|
class SharedLibrary
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SharedLibrary();
|
|
|
|
SharedLibrary(const std::string& Filename);
|
2017-06-05 22:01:15 +08:00
|
|
|
~SharedLibrary()=default;
|
2017-05-11 11:53:26 +08:00
|
|
|
int load(const std::string& Filename);
|
|
|
|
int unload();
|
2017-05-31 22:30:10 +08:00
|
|
|
|
|
|
|
template<typename ReturnType,typename... Arguments>
|
|
|
|
std::function<ReturnType(Arguments...)> get(const std::string& FunctionName)
|
|
|
|
{
|
|
|
|
return std::function<ReturnType(Arguments...)>(reinterpret_cast<ReturnType(*)(Arguments...)>(get(FunctionName)));
|
|
|
|
}
|
|
|
|
|
2017-06-05 22:01:15 +08:00
|
|
|
void* get(const std::string& FunctionName) const;
|
2017-05-18 17:58:10 +08:00
|
|
|
void release();
|
2017-05-11 11:53:26 +08:00
|
|
|
private:
|
2017-06-05 22:01:15 +08:00
|
|
|
void* _get() const;
|
2017-05-18 17:58:10 +08:00
|
|
|
void _set(void*);
|
2017-05-18 18:14:29 +08:00
|
|
|
void _clear();
|
2017-05-18 17:58:10 +08:00
|
|
|
std::shared_ptr<void> _obj;
|
2017-05-11 11:53:26 +08:00
|
|
|
};
|
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
class SDLSystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int SDLInit();
|
|
|
|
static void SDLQuit();
|
|
|
|
static int IMGInit();
|
|
|
|
static void IMGQuit();
|
|
|
|
static int TTFInit();
|
|
|
|
static void TTFQuit();
|
|
|
|
static int MixInit();
|
|
|
|
static void MixQuit();
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
static void Quit();
|
|
|
|
|
|
|
|
static void Delay(int ms);
|
2017-03-09 18:00:19 +08:00
|
|
|
|
2017-03-21 12:30:29 +08:00
|
|
|
static PowerState GetPowerState();
|
2017-04-12 09:26:03 +08:00
|
|
|
static int GetPowerLifeLeft();
|
|
|
|
static int GetPowerPrecentageLeft();
|
2017-03-21 12:30:29 +08:00
|
|
|
|
2017-03-09 18:00:19 +08:00
|
|
|
static Platform GetPlatform();
|
|
|
|
|
2017-03-24 11:07:27 +08:00
|
|
|
static void StartTextInput();
|
2017-05-22 18:47:28 +08:00
|
|
|
static bool IsTextInputActive();
|
2017-03-24 11:07:27 +08:00
|
|
|
static void StopTextInput();
|
|
|
|
|
2017-06-01 22:50:17 +08:00
|
|
|
static bool HasScreenKeyboardSupport();
|
|
|
|
|
2017-06-06 22:56:07 +08:00
|
|
|
static std::tuple<int,int,int> GetSDLCompileVersion();
|
|
|
|
static std::tuple<int,int,int> GetSDLLinkedVersion();
|
|
|
|
|
|
|
|
static std::tuple<int,int,int> GetIMGCompileVersion();
|
|
|
|
static std::tuple<int,int,int> GetIMGLinkedVersion();
|
|
|
|
|
|
|
|
static std::tuple<int,int,int> GetMixCompileVersion();
|
|
|
|
static std::tuple<int,int,int> GetMixLinkedVersion();
|
|
|
|
|
|
|
|
static std::tuple<int,int,int> GetTTFCompileVersion();
|
|
|
|
static std::tuple<int,int,int> GetTTFLinkedVersion();
|
2017-05-22 18:47:28 +08:00
|
|
|
|
2017-06-07 20:37:54 +08:00
|
|
|
static int GetCPUCount();
|
|
|
|
static int GetCPUCacheLineSize();
|
|
|
|
/// RAM is calculated in MB.
|
|
|
|
static int GetSystemRAM();
|
|
|
|
|
2017-03-09 18:00:19 +08:00
|
|
|
class Android
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static std::string GetInternal();
|
|
|
|
static bool ExternalAvaliable();
|
|
|
|
static bool CanReadExternal();
|
|
|
|
static bool CanWriteExternal();
|
|
|
|
static std::string GetExternal();
|
|
|
|
static void* GetJNIEnv();
|
|
|
|
};
|
2017-02-25 09:29:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-09 18:52:57 +08:00
|
|
|
class StringEngine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StringEngine(std::string StringFile,std::string LanguageTag);
|
|
|
|
|
|
|
|
StringEngine(StringEngine& )=delete;
|
|
|
|
StringEngine& operator = (StringEngine& )=delete;
|
|
|
|
|
|
|
|
int useLanaguage(std::string LanguageTag);
|
|
|
|
bool ready();
|
|
|
|
std::string getString(std::string Tag);
|
|
|
|
~StringEngine();
|
|
|
|
private:
|
|
|
|
struct impl;
|
|
|
|
impl* pimpl;
|
|
|
|
};
|
|
|
|
|
2017-05-22 18:27:56 +08:00
|
|
|
int SetClipboardText(const std::string& str);
|
|
|
|
std::string GetClipboardText();
|
|
|
|
bool HasClipboardText();
|
|
|
|
|
2017-05-22 18:47:28 +08:00
|
|
|
/// Experimental - For Experts: Use SDL ScanCode
|
|
|
|
bool GetScanKeyState(SDL_Scancode);
|
|
|
|
|
2017-02-25 09:29:34 +08:00
|
|
|
}/// End of namespace MiniEngine
|
|
|
|
|
2017-02-25 22:40:48 +08:00
|
|
|
std::string UTF8ToGBK(std::string UTF8String);
|
|
|
|
std::string GBKToUTF8(std::string GBKString);
|
2017-03-09 18:52:57 +08:00
|
|
|
bool canread(std::string Path);
|
|
|
|
bool canwrite(std::string Path);
|
|
|
|
bool isexist(std::string Path);
|
|
|
|
bool canexecute(std::string Path);
|
2017-02-25 09:29:34 +08:00
|
|
|
|
|
|
|
/// Your Program Should Start Here
|
|
|
|
int AppMain();
|
|
|
|
|
2017-02-25 22:40:48 +08:00
|
|
|
/// MiniEngine Provides main
|
|
|
|
int main(int argc,char* argv[]);
|
2017-03-30 11:16:57 +08:00
|
|
|
|
|
|
|
/// MiniEngine Provided API: Get Start Parameters
|
|
|
|
int GetArgc();
|
|
|
|
char** GetArgv();
|