mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Move Enum out to single files.
This commit is contained in:
parent
c86b52ef19
commit
4c774ca9ec
8
SDLWrapper/_BlendMode.h
Normal file
8
SDLWrapper/_BlendMode.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
enum class BlendMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Blend,
|
||||||
|
Add,
|
||||||
|
Mod
|
||||||
|
};
|
7
SDLWrapper/_FlipMode.h
Normal file
7
SDLWrapper/_FlipMode.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
enum class FlipMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Horizontal,
|
||||||
|
Vertical
|
||||||
|
};
|
9
SDLWrapper/_FontHint.h
Normal file
9
SDLWrapper/_FontHint.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
enum class FontHint
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Light,
|
||||||
|
Mono,
|
||||||
|
None,
|
||||||
|
Error
|
||||||
|
};
|
9
SDLWrapper/_FontStyle.h
Normal file
9
SDLWrapper/_FontStyle.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
enum class FontStyle
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Bold,
|
||||||
|
Italic,
|
||||||
|
UnderLine,
|
||||||
|
StrikeThrough
|
||||||
|
};
|
7
SDLWrapper/_MessageBoxType.h
Normal file
7
SDLWrapper/_MessageBoxType.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
enum class MessageBoxType
|
||||||
|
{
|
||||||
|
Error,
|
||||||
|
Warning,
|
||||||
|
Information
|
||||||
|
};
|
10
SDLWrapper/_Platform.h
Normal file
10
SDLWrapper/_Platform.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
enum class Platform
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Windows,
|
||||||
|
MacOS,
|
||||||
|
Linux,
|
||||||
|
iOS,
|
||||||
|
Android
|
||||||
|
};
|
9
SDLWrapper/_PowerState.h
Normal file
9
SDLWrapper/_PowerState.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
enum class PowerState
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
OnBattery,
|
||||||
|
NoBattery,
|
||||||
|
Charging,
|
||||||
|
Charged
|
||||||
|
};
|
8
SDLWrapper/_RendererType.h
Normal file
8
SDLWrapper/_RendererType.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
enum class RendererType
|
||||||
|
{
|
||||||
|
Software,
|
||||||
|
Accelerated,
|
||||||
|
PresentSync,
|
||||||
|
TargetTexture
|
||||||
|
};
|
8
SDLWrapper/_SystemCursorType.h
Normal file
8
SDLWrapper/_SystemCursorType.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
enum class SystemCursorType
|
||||||
|
{
|
||||||
|
Arrow, Ibeam, CrossHair,
|
||||||
|
Wait, WaitArrow,
|
||||||
|
SizeNWSE, SizeNESW, SizeWE, SizeNS, SizeAll,
|
||||||
|
No, Hand
|
||||||
|
};
|
10
SDLWrapper/_WindowType.h
Normal file
10
SDLWrapper/_WindowType.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
enum class WindowType
|
||||||
|
{
|
||||||
|
FullScreen, OpenGL, Shown, Hidden,
|
||||||
|
Borderless, Resizable, Minimized, Maximized,
|
||||||
|
InputGrabbed, InputFocus, MouseFocus,
|
||||||
|
FullScreenDesktop, Foreign, AllowHighDPI,
|
||||||
|
MouseCapture, AlwaysOnTop, SkipTaskBar,
|
||||||
|
Utility, ToolTip, PopUpMenu
|
||||||
|
};
|
219
SDLWrapper/_caster.cpp
Normal file
219
SDLWrapper/_caster.cpp
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
#include "_caster.h"
|
||||||
|
#include "begin_code.h"
|
||||||
|
namespace _internal
|
||||||
|
{
|
||||||
|
BlendMode getBlendModeFromSDLBlendMode(SDL_BlendMode mode)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case SDL_BLENDMODE_ADD:
|
||||||
|
return BlendMode::Add;
|
||||||
|
case SDL_BLENDMODE_BLEND:
|
||||||
|
return BlendMode::Blend;
|
||||||
|
case SDL_BLENDMODE_MOD:
|
||||||
|
return BlendMode::Mod;
|
||||||
|
case SDL_BLENDMODE_NONE:
|
||||||
|
default:/// return BlendMode::None on default.
|
||||||
|
return BlendMode::None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_BlendMode getSDLBlendModeFromBlendMode(BlendMode mode)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case BlendMode::Add:
|
||||||
|
return SDL_BLENDMODE_ADD;
|
||||||
|
case BlendMode::Blend:
|
||||||
|
return SDL_BLENDMODE_BLEND;
|
||||||
|
case BlendMode::Mod:
|
||||||
|
return SDL_BLENDMODE_MOD;
|
||||||
|
case BlendMode::None:
|
||||||
|
default:/// return SDL_BLENDMODE_NONE on default.
|
||||||
|
return SDL_BLENDMODE_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FIXME: return SDL_WindowFlags or Uint32 ?
|
||||||
|
Uint32 getSDLWindowFlagsFromWindowType(WindowType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case WindowType::FullScreen:
|
||||||
|
return SDL_WINDOW_FULLSCREEN;
|
||||||
|
case WindowType::OpenGL:
|
||||||
|
return SDL_WINDOW_OPENGL;
|
||||||
|
case WindowType::Shown:
|
||||||
|
return SDL_WINDOW_SHOWN;
|
||||||
|
case WindowType::Hidden:
|
||||||
|
return SDL_WINDOW_HIDDEN;
|
||||||
|
case WindowType::Borderless:
|
||||||
|
return SDL_WINDOW_BORDERLESS;
|
||||||
|
case WindowType::Resizable:
|
||||||
|
return SDL_WINDOW_RESIZABLE;
|
||||||
|
case WindowType::Minimized:
|
||||||
|
return SDL_WINDOW_MINIMIZED;
|
||||||
|
case WindowType::Maximized:
|
||||||
|
return SDL_WINDOW_MAXIMIZED;
|
||||||
|
case WindowType::InputGrabbed:
|
||||||
|
return SDL_WINDOW_INPUT_GRABBED;
|
||||||
|
case WindowType::InputFocus:
|
||||||
|
return SDL_WINDOW_INPUT_FOCUS;
|
||||||
|
case WindowType::MouseFocus:
|
||||||
|
return SDL_WINDOW_MOUSE_FOCUS;
|
||||||
|
case WindowType::FullScreenDesktop:
|
||||||
|
return SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
|
case WindowType::Foreign:
|
||||||
|
return SDL_WINDOW_FOREIGN;
|
||||||
|
case WindowType::AllowHighDPI:
|
||||||
|
return SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
case WindowType::MouseCapture:
|
||||||
|
return SDL_WINDOW_MOUSE_CAPTURE;
|
||||||
|
|
||||||
|
#if _MINIENGINE_SDL_VERSION_ATLEAST(2,0,5) /// SDL 2.0.5 Required
|
||||||
|
case WindowType::AlwaysOnTop:
|
||||||
|
return SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
|
case WindowType::SkipTaskBar:
|
||||||
|
return SDL_WINDOW_SKIP_TASKBAR;
|
||||||
|
case WindowType::Utility:
|
||||||
|
return SDL_WINDOW_UTILITY;
|
||||||
|
case WindowType::ToolTip:
|
||||||
|
return SDL_WINDOW_TOOLTIP;
|
||||||
|
case WindowType::PopUpMenu:
|
||||||
|
return SDL_WINDOW_POPUP_MENU;
|
||||||
|
#endif // End of SDL2.0.5 Require
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;/// Return 0 on default.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemCursorType getCursorTypeFromSDLSystemCursor(SDL_SystemCursor id)
|
||||||
|
{
|
||||||
|
switch(id)
|
||||||
|
{
|
||||||
|
case SDL_SYSTEM_CURSOR_ARROW:
|
||||||
|
return SystemCursorType::Arrow;
|
||||||
|
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||||
|
return SystemCursorType::CrossHair;
|
||||||
|
case SDL_SYSTEM_CURSOR_HAND:
|
||||||
|
return SystemCursorType::Hand;
|
||||||
|
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||||
|
return SystemCursorType::Ibeam;
|
||||||
|
case SDL_SYSTEM_CURSOR_NO:
|
||||||
|
return SystemCursorType::No;
|
||||||
|
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||||
|
return SystemCursorType::SizeAll;
|
||||||
|
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||||
|
return SystemCursorType::SizeNESW;
|
||||||
|
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||||
|
return SystemCursorType::SizeNS;
|
||||||
|
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||||
|
return SystemCursorType::SizeNWSE;
|
||||||
|
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||||
|
return SystemCursorType::SizeWE;
|
||||||
|
case SDL_SYSTEM_CURSOR_WAIT:
|
||||||
|
return SystemCursorType::Wait;
|
||||||
|
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||||
|
return SystemCursorType::WaitArrow;
|
||||||
|
default:/// return SystemCursorType::Arrow on default.
|
||||||
|
return SystemCursorType::Arrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SystemCursor getSDLSystemCursorFromSystemCursorType(SystemCursorType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case SystemCursorType::Arrow:
|
||||||
|
return SDL_SYSTEM_CURSOR_ARROW;
|
||||||
|
case SystemCursorType::CrossHair:
|
||||||
|
return SDL_SYSTEM_CURSOR_CROSSHAIR;
|
||||||
|
case SystemCursorType::Hand:
|
||||||
|
return SDL_SYSTEM_CURSOR_HAND;
|
||||||
|
case SystemCursorType::Ibeam:
|
||||||
|
return SDL_SYSTEM_CURSOR_IBEAM;
|
||||||
|
case SystemCursorType::No:
|
||||||
|
return SDL_SYSTEM_CURSOR_NO;
|
||||||
|
case SystemCursorType::SizeAll:
|
||||||
|
return SDL_SYSTEM_CURSOR_SIZEALL;
|
||||||
|
case SystemCursorType::SizeNESW:
|
||||||
|
return SDL_SYSTEM_CURSOR_SIZENESW;
|
||||||
|
case SystemCursorType::SizeNS:
|
||||||
|
return SDL_SYSTEM_CURSOR_SIZENS;
|
||||||
|
case SystemCursorType::SizeNWSE:
|
||||||
|
return SDL_SYSTEM_CURSOR_SIZENWSE;
|
||||||
|
case SystemCursorType::SizeWE:
|
||||||
|
return SDL_SYSTEM_CURSOR_SIZEWE;
|
||||||
|
case SystemCursorType::Wait:
|
||||||
|
return SDL_SYSTEM_CURSOR_WAIT;
|
||||||
|
case SystemCursorType::WaitArrow:
|
||||||
|
return SDL_SYSTEM_CURSOR_WAITARROW;
|
||||||
|
default:/// return SDL_SYSTEM_CURSOR_ARROW on default.
|
||||||
|
return SDL_SYSTEM_CURSOR_ARROW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getTTFFontStyleFromFontStyle(FontStyle style)
|
||||||
|
{
|
||||||
|
switch(style)
|
||||||
|
{
|
||||||
|
case FontStyle::Bold:
|
||||||
|
return TTF_STYLE_BOLD;
|
||||||
|
case FontStyle::Italic:
|
||||||
|
return TTF_STYLE_ITALIC;
|
||||||
|
case FontStyle::Normal:
|
||||||
|
return TTF_STYLE_NORMAL;
|
||||||
|
case FontStyle::StrikeThrough:
|
||||||
|
return TTF_STYLE_STRIKETHROUGH;
|
||||||
|
case FontStyle::UnderLine:
|
||||||
|
return TTF_STYLE_UNDERLINE;
|
||||||
|
default:
|
||||||
|
return TTF_STYLE_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<FontStyle> getFontStyleVecFromMixedTTFFontStyle(int Mixed_TTF_Font_Style)
|
||||||
|
{
|
||||||
|
std::vector<FontStyle> vec;
|
||||||
|
if(Mixed_TTF_Font_Style&TTF_STYLE_BOLD)
|
||||||
|
{
|
||||||
|
vec.push_back(FontStyle::Bold);
|
||||||
|
}
|
||||||
|
if(Mixed_TTF_Font_Style&TTF_STYLE_ITALIC)
|
||||||
|
{
|
||||||
|
vec.push_back(FontStyle::Italic);
|
||||||
|
}
|
||||||
|
if(Mixed_TTF_Font_Style&TTF_STYLE_STRIKETHROUGH)
|
||||||
|
{
|
||||||
|
vec.push_back(FontStyle::StrikeThrough);
|
||||||
|
}
|
||||||
|
if(Mixed_TTF_Font_Style&TTF_STYLE_UNDERLINE)
|
||||||
|
{
|
||||||
|
vec.push_back(FontStyle::UnderLine);
|
||||||
|
}
|
||||||
|
if(vec.empty())
|
||||||
|
{
|
||||||
|
vec.push_back(FontStyle::Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RendererFlip getSDLRendererFlipFromFlipMode(FlipMode mode)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case FlipMode::None:
|
||||||
|
return SDL_FLIP_NONE;
|
||||||
|
case FlipMode::Horizontal:
|
||||||
|
return SDL_FLIP_HORIZONTAL;
|
||||||
|
case FlipMode::Vertical:
|
||||||
|
return SDL_FLIP_VERTICAL;
|
||||||
|
default:
|
||||||
|
/// return non-flip mode on default.
|
||||||
|
return SDL_FLIP_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/// End of namespace _internal
|
||||||
|
#include "end_code.h"
|
22
SDLWrapper/_caster.h
Normal file
22
SDLWrapper/_caster.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
#include "include.h"
|
||||||
|
#include "_BlendMode.h"
|
||||||
|
#include "_WindowType.h"
|
||||||
|
#include "_SystemCursorType.h"
|
||||||
|
#include "_FontStyle.h"
|
||||||
|
#include "_FlipMode.h"
|
||||||
|
#include <vector>
|
||||||
|
#include "begin_code.h"
|
||||||
|
namespace _internal
|
||||||
|
{
|
||||||
|
BlendMode getBlendModeFromSDLBlendMode(SDL_BlendMode mode);
|
||||||
|
SDL_BlendMode getSDLBlendModeFromBlendMode(BlendMode mode);
|
||||||
|
/// FIXME: return SDL_WindowFlags or Uint32 ?
|
||||||
|
Uint32 getSDLWindowFlagsFromWindowType(WindowType type);
|
||||||
|
SystemCursorType getCursorTypeFromSDLSystemCursor(SDL_SystemCursor id);
|
||||||
|
SDL_SystemCursor getSDLSystemCursorFromSystemCursorType(SystemCursorType type);
|
||||||
|
int getTTFFontStyleFromFontStyle(FontStyle style);
|
||||||
|
std::vector<FontStyle> getFontStyleVecFromMixedTTFFontStyle(int Mixed_TTF_Font_Style);
|
||||||
|
SDL_RendererFlip getSDLRendererFlipFromFlipMode(FlipMode mode);
|
||||||
|
}/// End of namespace _internal
|
||||||
|
#include "end_code.h"
|
Loading…
Reference in New Issue
Block a user