Update doxygen

This commit is contained in:
Nomango 2019-12-20 17:49:16 +08:00
parent b53f77af05
commit 1c923ca76d
22 changed files with 643 additions and 235 deletions

2
.gitignore vendored
View File

@ -27,3 +27,5 @@ packages/
# Resources bin # Resources bin
*.aps *.aps
docs/

86
Doxyfile Normal file
View File

@ -0,0 +1,86 @@
# Doxyfile 1.8.16
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Kiwano Engine"
PROJECT_NUMBER = v1.0.0
PROJECT_BRIEF =
PROJECT_LOGO = logo/logo_square_tiny.png
DOXYFILE_ENCODING = UTF-8
CREATE_SUBDIRS = YES
OUTPUT_LANGUAGE = Chinese
OUTPUT_DIRECTORY = docs/
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = NO
SHOW_INCLUDE_FILES = YES
SHOW_USED_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = YES
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = src/
INPUT_ENCODING = gb2312
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
RECURSIVE = YES
EXCLUDE = src/3rd-party
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
PREDEFINED = KGE_API=
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by the
# preprocessor.
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
GENERATE_TREEVIEW = YES
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# Configuration options related to the LATEX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO

BIN
logo/logo_square_tiny.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -31,7 +31,7 @@ private:
pointer_type prev_; pointer_type prev_;
pointer_type next_; pointer_type next_;
friend class intrusive_list<_Ty>; friend class intrusive_list<_Ty, _PTy>;
}; };

View File

@ -33,7 +33,7 @@ namespace kiwano
: public Singleton<AudioEngine> : public Singleton<AudioEngine>
, public ComponentBase , public ComponentBase
{ {
OC_DECLARE_SINGLETON(AudioEngine); friend Singleton<AudioEngine>;
public: public:
// 开启设备 // 开启设备

View File

@ -32,7 +32,7 @@ namespace kiwano
, public UpdateComponent , public UpdateComponent
, public EventComponent , public EventComponent
{ {
OC_DECLARE_SINGLETON(ImGuiModule); friend Singleton<ImGuiModule>;
private: private:
void Init(HWND hwnd); void Init(HWND hwnd);

View File

@ -32,7 +32,7 @@ namespace kiwano
: public Singleton<HttpClient> : public Singleton<HttpClient>
, public ComponentBase , public ComponentBase
{ {
OC_DECLARE_SINGLETON(HttpClient); friend Singleton<HttpClient>;
public: public:
void Send(HttpRequestPtr request); void Send(HttpRequestPtr request);

View File

@ -27,11 +27,19 @@ namespace kiwano
class RenderTarget; class RenderTarget;
class Event; class Event;
// 基础组件 /**
* \~chinese
* @brief
*/
class KGE_API ComponentBase class KGE_API ComponentBase
{ {
public: public:
/// \~chinese
/// @brief 启动组件
virtual void SetupComponent() = 0; virtual void SetupComponent() = 0;
/// \~chinese
/// @brief 销毁组件
virtual void DestroyComponent() = 0; virtual void DestroyComponent() = 0;
bool Check(const int flag); bool Check(const int flag);
@ -44,15 +52,25 @@ namespace kiwano
}; };
// 渲染支持组件 /**
* \~chinese
* @brief
*/
class KGE_API RenderComponent class KGE_API RenderComponent
: public virtual ComponentBase : public virtual ComponentBase
{ {
public: public:
/// \~chinese
/// @brief 渲染前
virtual void BeforeRender() {} virtual void BeforeRender() {}
virtual void OnRender(RenderTarget*) {} /// \~chinese
/// @brief 渲染时
/// @param rt 渲染目标
virtual void OnRender(RenderTarget* rt) {}
/// \~chinese
/// @brief 渲染后
virtual void AfterRender() {} virtual void AfterRender() {}
public: public:
@ -62,15 +80,25 @@ namespace kiwano
}; };
// 更新支持组件 /**
* \~chinese
* @brief
*/
class KGE_API UpdateComponent class KGE_API UpdateComponent
: public virtual ComponentBase : public virtual ComponentBase
{ {
public: public:
/// \~chinese
/// @brief 更新前
virtual void BeforeUpdate() {} virtual void BeforeUpdate() {}
virtual void OnUpdate(Duration) {} /// \~chinese
/// @brief 更新时
/// @param dt 间隔时间
virtual void OnUpdate(Duration dt) {}
/// \~chinese
/// @brief 更新后
virtual void AfterUpdate() {} virtual void AfterUpdate() {}
public: public:
@ -80,13 +108,21 @@ namespace kiwano
}; };
// 事件支持组件 /**
* \~chinese
* @brief
*/
class KGE_API EventComponent class KGE_API EventComponent
: public virtual ComponentBase : public virtual ComponentBase
{ {
public: public:
virtual void HandleEvent(Event&) {} /// \~chinese
/// @brief 事件处理
/// @param evt 事件
virtual void HandleEvent(Event& evt) {}
/// \~chinese
/// @brief Windows 消息处理
virtual void HandleMessage(HWND, UINT32, WPARAM, LPARAM) {} virtual void HandleMessage(HWND, UINT32, WPARAM, LPARAM) {}
public: public:

View File

@ -55,7 +55,7 @@ namespace kiwano
class KGE_API Logger class KGE_API Logger
: public Singleton<Logger> : public Singleton<Logger>
{ {
OC_DECLARE_SINGLETON(Logger); friend Singleton<Logger>;
public: public:
// 显示或关闭控制台 // 显示或关闭控制台

View File

@ -23,103 +23,105 @@
namespace kiwano namespace kiwano
{ {
// 報炎梓囚 /// \~chinese
/// @brief 鼠标按键
struct MouseButton struct MouseButton
{ {
typedef int Value; typedef int Value;
enum : Value enum : Value
{ {
Left = VK_LBUTTON, // 報炎恣囚 Left = VK_LBUTTON, ///< 鼠标左键
Right = VK_RBUTTON, // 報炎嘔囚 Right = VK_RBUTTON, ///< 鼠标右键
Middle = VK_MBUTTON // 報炎嶄囚 Middle = VK_MBUTTON ///< 鼠标中键
}; };
}; };
// 梓囚囚峙 /// \~chinese
/// @brief 按键键值
struct KeyCode struct KeyCode
{ {
typedef int Value; typedef int Value;
enum : Value enum : Value
{ {
Unknown = 0, Unknown = 0, ///< 未知
Up = VK_UP, Up = VK_UP, ///< 上键
Left = VK_LEFT, Left = VK_LEFT, ///< 左键
Right = VK_RIGHT, Right = VK_RIGHT, ///< 右键
Down = VK_DOWN, Down = VK_DOWN, ///< 下键
Enter = VK_RETURN, Enter = VK_RETURN, ///< 回车键
Space = VK_SPACE, Space = VK_SPACE, ///< 空格键
Esc = VK_ESCAPE, Esc = VK_ESCAPE, ///< 退出键
Ctrl = VK_CONTROL, Ctrl = VK_CONTROL, ///< CTRL键
Shift = VK_SHIFT, Shift = VK_SHIFT, ///< SHIFT键
Alt = VK_MENU, Alt = VK_MENU, ///< ALT键
Tab = VK_TAB, Tab = VK_TAB, ///< TAB键
Delete = VK_DELETE, Delete = VK_DELETE, ///< 删除键
Back = VK_BACK, Back = VK_BACK, ///< 退格键
A = 0x41, A = 0x41, ///< A键
B, B, ///< B键
C, C, ///< C键
D, D, ///< D键
E, E, ///< E键
F, F, ///< F键
G, G, ///< G键
H, H, ///< H键
I, I, ///< I键
J, J, ///< J键
K, K, ///< K键
L, L, ///< L键
M, M, ///< M键
N, N, ///< N键
O, O, ///< O键
P, P, ///< P键
Q, Q, ///< Q键
R, R, ///< R键
S, S, ///< S键
T, T, ///< T键
U, U, ///< U键
V, V, ///< V键
W, W, ///< W键
X, X, ///< X键
Y, Y, ///< Y键
Z, Z, ///< Z键
Num0 = 0x30, Num0 = 0x30, ///< 数字0键
Num1, Num1, ///< 数字1键
Num2, Num2, ///< 数字2键
Num3, Num3, ///< 数字3键
Num4, Num4, ///< 数字4键
Num5, Num5, ///< 数字5键
Num6, Num6, ///< 数字6键
Num7, Num7, ///< 数字7键
Num8, Num8, ///< 数字8键
Num9, Num9, ///< 数字9键
Numpad0 = VK_NUMPAD0, Numpad0 = VK_NUMPAD0, ///< 数字小键盘0键
Numpad1, Numpad1, ///< 数字小键盘1键
Numpad2, Numpad2, ///< 数字小键盘2键
Numpad3, Numpad3, ///< 数字小键盘3键
Numpad4, Numpad4, ///< 数字小键盘4键
Numpad5, Numpad5, ///< 数字小键盘5键
Numpad6, Numpad6, ///< 数字小键盘6键
Numpad7, Numpad7, ///< 数字小键盘7键
Numpad8, Numpad8, ///< 数字小键盘8键
Numpad9, Numpad9, ///< 数字小键盘9键
F1 = VK_F1, F1 = VK_F1, ///< F1键
F2, F2, ///< F2键
F3, F3, ///< F3键
F4, F4, ///< F4键
F5, F5, ///< F5键
F6, F6, ///< F6键
F7, F7, ///< F7键
F8, F8, ///< F8键
F9, F9, ///< F9键
F10, F10, ///< F10键
F11, F11, ///< F11键
F12, F12, ///< F12键
}; };
}; };
} }

View File

@ -354,25 +354,24 @@ namespace kiwano
return dur * val; return dur * val;
} }
Duration Duration::Parse(const String& str) Duration Duration::Parse(const String& format)
{ {
bool negative = false; bool negative = false;
size_t len = str.length(); size_t len = format.length();
size_t pos = 0; size_t pos = 0;
Duration ret; Duration ret;
if (!std::regex_match(str.c_str(), duration_regex)) if (!std::regex_match(format.c_str(), duration_regex))
{ {
KGE_ERROR(L"Duration::Parse failed, invalid duration"); throw std::runtime_error("Duration::Parse failed, invalid duration");
return ret;
} }
if (str.empty() || str == L"0") { return ret; } if (format.empty() || format == L"0") { return ret; }
// ·ûºÅλ // ·ûºÅλ
if (str[0] == L'-' || str[0] == L'+') if (format[0] == L'-' || format[0] == L'+')
{ {
negative = (str[0] == L'-'); negative = (format[0] == L'-');
pos++; pos++;
} }
@ -382,32 +381,34 @@ namespace kiwano
size_t i = pos; size_t i = pos;
for (; i < len; ++i) for (; i < len; ++i)
{ {
wchar_t ch = str[i]; wchar_t ch = format[i];
if (!(ch == L'.' || L'0' <= ch && ch <= L'9')) if (!(ch == L'.' || L'0' <= ch && ch <= L'9'))
{ {
break; break;
} }
} }
String num_str = str.substr(pos, i - pos); String num_str = format.substr(pos, i - pos);
pos = i; pos = i;
KGE_ASSERT(!(num_str.empty() || num_str == L".") && "Duration::Parse failed, invalid duration"); if (num_str.empty() || num_str == L".")
throw std::runtime_error("Duration::Parse failed, invalid duration");
// µ¥Î» // µ¥Î»
for (; i < len; ++i) for (; i < len; ++i)
{ {
wchar_t ch = str[i]; wchar_t ch = format[i];
if (ch == L'.' || L'0' <= ch && ch <= L'9') if (ch == L'.' || L'0' <= ch && ch <= L'9')
{ {
break; break;
} }
} }
String unit_str = str.substr(pos, i - pos); String unit_str = format.substr(pos, i - pos);
pos = i; pos = i;
KGE_ASSERT(unit_map.find(unit_str) != unit_map.end() && "Duration::Parse failed, invalid duration"); if (unit_map.find(unit_str) == unit_map.end())
throw std::runtime_error("Duration::Parse failed, invalid duration");
double num = std::wcstod(num_str.c_str(), nullptr); double num = std::wcstod(num_str.c_str(), nullptr);
Duration unit = unit_map.at(unit_str); Duration unit = unit_map.at(unit_str);

View File

@ -24,51 +24,98 @@
namespace kiwano namespace kiwano
{ {
// 时间段 /**
// * \~chinese
// 时间段表示法: * @brief
// 5 秒: time::Second * 5 * @details
// 1.5 小时: time::Hour * 1.5 * :
// 3 小时 45 分 15 秒: time::Hour * 3 + time::Minute * 45 + time::Second * 15 * 5 : time::Second * 5
// 在 VS2015 及更高版本可以使用 time literals: * 1.5 : time::Hour * 1.5
// 5 秒: 5_s * 3 45 15 : time::Hour * 3 + time::Minute * 45 + time::Second * 15
// 1.5 小时: 1.5_h * VS2015 使 time literals:
// 3 小时 45 分 15 秒: 3_h + 45_m + 15_s * 5 : 5_s
// * 1.5 : 1.5_h
* 3 45 15 : 3_h + 45_m + 15_s
*/
struct KGE_API Duration struct KGE_API Duration
{ {
/// \~chinese
/// @brief 构造时间段
Duration(); Duration();
/// \~chinese
/// @brief 构造时间段
/// @param milliseconds 毫秒数
Duration( Duration(
long milliseconds long milliseconds
); );
// 转化为毫秒 /// \~chinese
/// @brief 获取毫秒数
/// @return 毫秒数
long Milliseconds() const; long Milliseconds() const;
// 转化为秒 /// \~chinese
/// @brief 获取秒数
/// @return 秒数
float Seconds() const; float Seconds() const;
// 转化为分钟 /// \~chinese
/// @brief 获取分钟数
/// @return 分钟数
float Minutes() const; float Minutes() const;
// 转化为小时 /// \~chinese
/// @brief 获取小时数
/// @return 小时数
float Hours() const; float Hours() const;
// 时长是否是零 /// \~chinese
/// @brief 时长是否是零
/// @return 若时长是零返回true
bool IsZero() const; bool IsZero() const;
/// \~chinese
/// @brief 设置毫秒数
/// @param ms 毫秒数
void SetMilliseconds(long ms); void SetMilliseconds(long ms);
/// \~chinese
/// @brief 设置秒数
/// @param seconds 秒数
void SetSeconds(float seconds); void SetSeconds(float seconds);
/// \~chinese
/// @brief 设置分钟数
/// @param minutes 分钟数
void SetMinutes(float minutes); void SetMinutes(float minutes);
/// \~chinese
/// @brief 设置小时数
/// @param hours 小时数
void SetHours(float hours); void SetHours(float hours);
// 转为字符串 /// \~chinese
/// @brief 转为字符串
/// @return 格式化后的字符串
String ToString() const; String ToString() const;
/// \~chinese
/// @brief 时间段格式化
/// @param format 格式
/// @details
/// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
/// 例如: "300ms", "-1.5h", "2h45m"
/// 允许的时间单位有 "ms", "s", "m", "h"
/// @return 解析出的时间段
/// @throw std::runtime_error 传入了一个不合法的格式
static Duration Parse(const String& str);
static const Duration Ms; ///< 毫秒
static const Duration Second; ///< 秒
static const Duration Minute; ///< 分钟
static const Duration Hour; ///< 小时
bool operator== (const Duration &) const; bool operator== (const Duration &) const;
bool operator!= (const Duration &) const; bool operator!= (const Duration &) const;
bool operator> (const Duration &) const; bool operator> (const Duration &) const;
@ -107,37 +154,38 @@ namespace kiwano
friend const Duration operator/ (float, const Duration &); friend const Duration operator/ (float, const Duration &);
friend const Duration operator/ (double, const Duration &); friend const Duration operator/ (double, const Duration &);
// 时间段格式化
//
// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
// 例如: "300ms", "-1.5h", "2h45m"
// 允许的时间单位有 "ms", "s", "m", "h"
static Duration Parse(const String& parse_str);
static const Duration Ms; // 毫秒
static const Duration Second; // 秒
static const Duration Minute; // 分钟
static const Duration Hour; // 小时
private: private:
long milliseconds_; long milliseconds_;
}; };
// 时间 /**
// * \~chinese
// 获取当前时间: Time now = Time::Now(); * @brief
// 两时间相减, 得到一个 Duration 对象, 例如: * @par
// Time t1, t2; * @code
// int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数 * // 两时间相减, 可得到一个 Duration 对象
// * Time t1 = Time::Now();
* // 等待一段时间后
* Time t2 = Time::Now();
* int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
* @endcode
* @note
*/
struct KGE_API Time struct KGE_API Time
{ {
Time(); Time();
// 是否是零时 /// \~chinese
/// @brief 是否是零时
/// @return 若是零时返回true
bool IsZero() const; bool IsZero() const;
/// \~chinese
/// @brief 获取当前时间
/// @return 当前时间
static Time Now() noexcept;
const Duration operator -(const Time&) const; const Duration operator -(const Time&) const;
const Time operator +(const Duration &) const; const Time operator +(const Duration &) const;
@ -146,11 +194,6 @@ namespace kiwano
Time& operator +=(const Duration &); Time& operator +=(const Duration &);
Time& operator -=(const Duration &); Time& operator -=(const Duration &);
// 获取当前时间
// 由于该时间点基于系统启动时间开始计算, 所以无法格式化该时间,
// 也无法获得该时间的 Unix 时间戳
static Time Now() noexcept;
private: private:
Time(long ms); Time(long ms);

View File

@ -262,10 +262,10 @@ namespace kiwano
} }
} }
void Application::PreformInMainThread(Function<void()> Function) void Application::PreformInMainThread(Function<void()> func)
{ {
std::lock_guard<std::mutex> lock(perform_mutex_); std::lock_guard<std::mutex> lock(perform_mutex_);
functions_to_perform_.push(Function); functions_to_perform_.push(func);
} }
LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam) LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam)

View File

@ -28,12 +28,24 @@
namespace kiwano namespace kiwano
{ {
/**
* \~chinese
* @brief
* @details Kiwano
*/
struct Config struct Config
{ {
WindowConfig window; // 窗口设置 WindowConfig window; ///< 窗口配
RenderConfig render; // 渲染设置 RenderConfig render; ///< 渲染配
bool debug; // 调试模式 bool debug; ///< 启用调试模式
/**
* \~chinese
* @param title
* @param width
* @param height
* @param icon ID
*/
Config( Config(
String const& title = L"Kiwano Game", String const& title = L"Kiwano Game",
uint32_t width = 640, uint32_t width = 640,
@ -41,6 +53,11 @@ namespace kiwano
uint32_t icon = 0 uint32_t icon = 0
); );
/**
* \~chinese
* @param wnd_config
* @param render_config
*/
Config( Config(
WindowConfig const& wnd_config, WindowConfig const& wnd_config,
RenderConfig const& render_config = RenderConfig() RenderConfig const& render_config = RenderConfig()
@ -48,7 +65,10 @@ namespace kiwano
}; };
// 应用 /**
* \~chinese
* @brief
*/
class KGE_API Application class KGE_API Application
: protected Noncopyable : protected Noncopyable
{ {
@ -57,46 +77,94 @@ namespace kiwano
virtual ~Application(); virtual ~Application();
// 初始化 /**
* \~chinese
* @brief
* @details OnReady
* @param config
* @attention 使
*/
void Init( void Init(
Config const& config = Config() Config const& config = Config()
); );
// 初始化成功时 /**
* \~chinese
* @brief
* @details
*/
virtual void OnReady() {} virtual void OnReady() {}
// 窗口关闭时 /**
* \~chinese
* @brief
* @details
* @return true
*/
virtual bool OnClosing() { return true; } virtual bool OnClosing() { return true; }
// 销毁时 /**
* \~chinese
* @brief
* @details
*/
virtual void OnDestroy() {} virtual void OnDestroy() {}
// 运行 /**
* \~chinese
* @brief
* @note
*/
void Run(); void Run();
// 结束 /**
* \~chinese
* @brief
*/
void Quit(); void Quit();
// 销毁 /**
* \~chinese
* @brief
*/
void Destroy(); void Destroy();
// 添加组件 /**
* \~chinese
* @brief
* @param[in] component
*/
void Use( void Use(
ComponentBase* component ComponentBase* component
); );
// 设置时间缩放因子 /**
* \~chinese
* @brief
* @details
* @param scale_factor
* @warning
*/
void SetTimeScale( void SetTimeScale(
float scale_factor float scale_factor
); );
// 分发事件 /**
* \~chinese
* @brief
* @details
* @param evt
*/
void DispatchEvent(Event& evt); void DispatchEvent(Event& evt);
// 在 Kiwano 主线程中执行函数 /**
// 当在其他线程调用 Kiwano 函数时使用 * \~chinese
* @brief 线
* @details 线 Kiwano
* @param func
*/
static void PreformInMainThread( static void PreformInMainThread(
Function<void()> Function Function<void()> func
); );
protected: protected:

View File

@ -24,43 +24,75 @@
namespace kiwano namespace kiwano
{ {
// 导演 /**
* \~chinese
* @brief
*/
class KGE_API Director class KGE_API Director
: public Singleton<Director> : public Singleton<Director>
, public UpdateComponent , public UpdateComponent
, public RenderComponent , public RenderComponent
, public EventComponent , public EventComponent
{ {
OC_DECLARE_SINGLETON(Director); friend Singleton<Director>;
public: public:
// 切换舞台 /**
* \~chinese
* @brief
* @param[in] stage
* @param[in] transition
*/
void EnterStage( void EnterStage(
StagePtr stage, /* 舞台 */ StagePtr stage,
TransitionPtr transition = nullptr /* 过渡动画 */ TransitionPtr transition = nullptr
); );
// 舞台压栈 /**
* \~chinese
* @brief
* @param[in] stage
* @param[in] transition
*/
void PushStage( void PushStage(
StagePtr stage, /* 舞台 */ StagePtr stage,
TransitionPtr transition = nullptr /* 过渡动画 */ TransitionPtr transition = nullptr
); );
// 舞台出栈 /**
* \~chinese
* @brief 退
* @param[in] transition
*/
void PopStage( void PopStage(
TransitionPtr transition = nullptr /* 过渡动画 */ TransitionPtr transition = nullptr
); );
// 获取当前舞台 /**
* \~chinese
* @brief
* @return
*/
StagePtr GetCurrentStage(); StagePtr GetCurrentStage();
// 启用或禁用角色边界渲染功能 /**
* \~chinese
* @brief
* @param enabled
*/
void SetRenderBorderEnabled(bool enabled); void SetRenderBorderEnabled(bool enabled);
// 显示调试信息 /**
* \~chinese
* @brief
* @param show
*/
void ShowDebugInfo(bool show = true); void ShowDebugInfo(bool show = true);
// 清空舞台 /**
* \~chinese
* @brief 退
*/
void ClearStages(); void ClearStages();
public: public:

View File

@ -23,41 +23,87 @@
namespace kiwano namespace kiwano
{ {
// 文件 /**
* \~chinese
* @brief
*/
class KGE_API FileSystem class KGE_API FileSystem
: public Singleton<FileSystem> : public Singleton<FileSystem>
{ {
OC_DECLARE_SINGLETON(FileSystem); friend Singleton<FileSystem>;
public: public:
// 添加文件搜索路径 /**
* \~chinese
* @brief
* @param path
*/
void AddSearchPath(String const& path); void AddSearchPath(String const& path);
// 设置文件搜索路径 /**
* \~chinese
* @brief
* @param paths
*/
void SetSearchPaths(Vector<String> const& paths); void SetSearchPaths(Vector<String> const& paths);
// 获取文件的完整路径 /**
* \~chinese
* @brief
* @param file
* @return
*/
String GetFullPathForFile(String const& file) const; String GetFullPathForFile(String const& file) const;
// 添加文件路径查找字典规则 /**
* \~chinese
* @brief
* @param key
* @param file_path
*/
void AddFileLookupRule(String const& key, String const& file_path); void AddFileLookupRule(String const& key, String const& file_path);
// 设置文件路径查找字典 /**
* \~chinese
* @brief
* @param dict
*/
void SetFileLookupDictionary(UnorderedMap<String, String> const& dict); void SetFileLookupDictionary(UnorderedMap<String, String> const& dict);
// 文件是否存在 /**
* \~chinese
* @brief
* @param file_path
* @return true
*/
bool IsFileExists(String const& file_path) const; bool IsFileExists(String const& file_path) const;
// 判断路径是否是绝对路径 /**
* \~chinese
* @brief
* @param path
* @return true
*/
bool IsAbsolutePath(String const& path) const; bool IsAbsolutePath(String const& path) const;
// 删除文件 /**
* \~chinese
* @brief
* @param path
* @return
*/
bool RemoveFile(String const& file_path) const; bool RemoveFile(String const& file_path) const;
// 释放二进制资源到临时文件目录 /**
* \~chinese
* @brief
* @param res
* @param dest_file_name
* @return
*/
bool ExtractResourceToFile( bool ExtractResourceToFile(
Resource const& res, /* 资源 */ Resource const& res,
String const& dest_file_name /* 目标文件名 */ String const& dest_file_name
) const; ) const;
private: private:

View File

@ -27,36 +27,70 @@
namespace kiwano namespace kiwano
{ {
/**
* \~chinese
* @brief
*/
class KGE_API Input class KGE_API Input
: public Singleton<Input> : public Singleton<Input>
, public UpdateComponent , public UpdateComponent
, public EventComponent , public EventComponent
{ {
OC_DECLARE_SINGLETON(Input); friend Singleton<Input>;
public: public:
// 检测键盘或鼠标按键是否正被按下 /**
* \~chinese
* @brief
* @param key_or_btn
* @return
* @see kiwano::KeyCode kiwano::MouseButton
*/
bool IsDown( bool IsDown(
int key_or_btn int key_or_btn
); );
// 检测键盘或鼠标按键是否刚被点击 /**
* \~chinese
* @brief
* @param key_or_btn
* @return
* @see kiwano::KeyCode kiwano::MouseButton
*/
bool WasPressed( bool WasPressed(
int key_or_btn int key_or_btn
); );
// 检测键盘或鼠标按键是否刚抬起 /**
* \~chinese
* @brief
* @param key_or_btn
* @return
* @see kiwano::KeyCode kiwano::MouseButton
*/
bool WasReleased( bool WasReleased(
int key_or_btn int key_or_btn
); );
// 获得鼠标 x 坐标 /**
* \~chinese
* @brief x
* @return x
*/
float GetMouseX(); float GetMouseX();
// 获得鼠标 y 坐标 /**
* \~chinese
* @brief y
* @return y
*/
float GetMouseY(); float GetMouseY();
// 获得鼠标坐标 /**
* \~chinese
* @brief
* @return
*/
Point GetMousePos(); Point GetMousePos();
public: public:

View File

@ -25,29 +25,45 @@
namespace kiwano namespace kiwano
{ {
// 鼠标指针类型 /**
* \~chinese
* @brief
*/
enum class CursorType enum class CursorType
{ {
Arrow, /* 指针 */ Arrow, ///< 指针
TextInput, /* 文本 */ TextInput, ///< 文本
Hand, /* 手指 */ Hand, ///< 手
SizeAll, SizeAll, ///< 指向四个方向的箭头
SizeNESW, SizeWE, ///< 指向左右方向的箭头
SizeNS, SizeNS, ///< 指向上下方向的箭头
SizeNWSE, SizeNESW, ///< 指向左下到右上方向的箭头
SizeWE, SizeNWSE, ///< 指向左上到右下方向的箭头
}; };
// 窗口设置 /**
* \~chinese
* @brief
*/
struct WindowConfig struct WindowConfig
{ {
String title; // 标题 String title; ///< 标题
uint32_t width; // 宽度 uint32_t width; ///< 宽度
uint32_t height; // 高度 uint32_t height; ///< 高度
uint32_t icon; // 图标资源 ID uint32_t icon; ///< 图标资源 ID
bool resizable; // 窗口大小可拉伸 bool resizable; ///< 窗口大小可拉伸
bool fullscreen; // 全屏模式 bool fullscreen; ///< 全屏模式
/**
* \~chinese
* @brief
* @param title
* @param width
* @param height
* @param icon ID
* @param resizable
* @param fullscreen
*/
WindowConfig( WindowConfig(
String const& title = L"Kiwano Game", String const& title = L"Kiwano Game",
uint32_t width = 640, uint32_t width = 640,
@ -59,38 +75,80 @@ namespace kiwano
}; };
// 窗口 /**
* \~chinese
* @brief
*/
class KGE_API Window class KGE_API Window
: public Singleton<Window> : public Singleton<Window>
{ {
OC_DECLARE_SINGLETON(Window); friend Singleton<Window>;
public: public:
// 获取标题 /**
* \~chinese
* @brief
* @return
*/
String GetTitle() const; String GetTitle() const;
// 获取窗口大小 /**
* \~chinese
* @brief
* @return
*/
Size GetSize() const; Size GetSize() const;
// 获取窗口宽度 /**
* \~chinese
* @brief
* @return
*/
float GetWidth() const; float GetWidth() const;
// 获取窗口高度 /**
* \~chinese
* @brief
* @return
*/
float GetHeight() const; float GetHeight() const;
// 设置标题 /**
* \~chinese
* @brief
* @param title
*/
void SetTitle(String const& title); void SetTitle(String const& title);
// 设置窗口图标 /**
* \~chinese
* @brief
* @param icon_resource ID
*/
void SetIcon(uint32_t icon_resource); void SetIcon(uint32_t icon_resource);
// 重设窗口大小 /**
* \~chinese
* @brief
* @param width
* @param height
*/
void Resize(int width, int height); void Resize(int width, int height);
// 设置全屏模式 /**
* \~chinese
* @brief
* @param fullscreen
* @param width
* @param height
*/
void SetFullscreen(bool fullscreen, int width, int height); void SetFullscreen(bool fullscreen, int width, int height);
// 设置鼠标指针类型 /**
* \~chinese
* @brief
* @param cursor
*/
void SetCursor(CursorType cursor); void SetCursor(CursorType cursor);
public: public:

View File

@ -59,7 +59,7 @@ namespace kiwano
, public EventComponent , public EventComponent
, public RenderTarget , public RenderTarget
{ {
OC_DECLARE_SINGLETON(Renderer); friend Singleton<Renderer>;
public: public:
// <20>零헌팁奈<ED8C81> // <20>零헌팁奈<ED8C81>

View File

@ -27,7 +27,7 @@ namespace kiwano
class KGE_API TextureCache class KGE_API TextureCache
: public Singleton<TextureCache> : public Singleton<TextureCache>
{ {
OC_DECLARE_SINGLETON(TextureCache); friend Singleton<TextureCache>;
public: public:
Texture AddOrGetTexture(String const& file_path); Texture AddOrGetTexture(String const& file_path);

View File

@ -30,7 +30,7 @@ namespace kiwano
class KGE_API ResourceCache class KGE_API ResourceCache
: public Singleton<ResourceCache> : public Singleton<ResourceCache>
{ {
OC_DECLARE_SINGLETON(ResourceCache); friend Singleton<ResourceCache>;
public: public:
// 从 JSON 文件加载资源信息 // 从 JSON 文件加载资源信息

View File

@ -27,7 +27,7 @@ namespace kiwano
class KGE_API UserData class KGE_API UserData
: public Singleton<UserData> : public Singleton<UserData>
{ {
OC_DECLARE_SINGLETON(UserData); friend Singleton<UserData>;
public: public:
using DataMap = UnorderedMap<String, Any>; using DataMap = UnorderedMap<String, Any>;