Files
dl_old/dl/system/dl_system.h
T
2023-12-26 20:46:08 +08:00

122 lines
2.0 KiB
C++

/**
* @file dl_system.h
* @brief 引擎主系统
*
*
* @version 1.0
* @author lveyou
* @date 23-06-23
*
* @note
*/
#pragma once
#include <string_view>
#include "dl_type.h"
#include "base/dl_type_user.h"
namespace dl
{
struct ParamWindow
{
std::string _strTitle;
Size _size;
ParamWindow() :
_strTitle{ "C++ drawing library" },
_size{ 800,600 }
{}
};
class SystemImp;
class System
{
public:
using Func = void (*)(void);
System();
~System();
/**
* @brief 进入 游戏循环
* @param[in] json_window 窗口配置
* @param[in] json_path 资源路径配置
*/
void Start(std::string_view json_window,
std::string_view json_path = "");
/**
* @brief 创建窗口 并进入 游戏循环
*/
void Start(const ParamWindow& param = {});
/**
* @brief 设置 初始化函数
*/
void SetFuncInit(Func func) { _funcInit = func; }
/**
* @brief 设置 帧函数
*/
void SetFuncRun(Func func) { _funcRun = func; }
/**
* @brief 设置鼠标位置,不用此来实现摄像机
* @param[in] xy 位置
* @note 使用g_input获得鼠标位置
*/
void SetCursorPosition(Point xy);
/**
* @brief 返回窗口大小
*/
Size GetWindowSize();
/**
* @brief 获取桌面大小,不包含任务栏
*/
Size GetWorkArea();
/**
* @brief 设置窗口位置
*/
void SetWindowPoint(const Point& xy);
/**
* @brief 设置窗口居中(以工作区大小)
*/
void SetWindowCenter();
/**
* @brief 设置窗口标题
*/
void SetWindowTitle(std::string_view str);
//! 返回上一帧绘图信息
const RenderInfo2D& GetRenderInfo2D();
const RenderInfo3D& GetRenderInfo3D();
/**
* @brief 截屏
*/
void ScreenShot(std::string_view path_name);
enum class CursorMode
{
NORMAL,
HIDE,
DISABLE
};
/**
* @brief 设置光标模式
* @note 调用后,会触发光标移动事件,会强制鼠标两帧间隔归0s
*/
void SetCursorMode(CursorMode mode);
SystemImp* GetImp() { return _imp; }
private:
SystemImp* _imp;
Func _funcInit;
Func _funcRun;
CursorMode _cursorMode;
bool _bCursorModeChange;
};
extern System* g_system;
}