dl
dl_system.h
浏览该文件的文档.
1
12#pragma once
13
14#ifndef DL_DISABLE_RENDER
15#include <string_view>
16#include <vector>
17
18#include "dl_type.h"
19#include "base/dl_type_user.h"
20#include "script/dl_lua.h"
21
22namespace dl
23{
31
39
42{
43 std::string _strTitle;
45 FullScreenMode _fullScreenMode; //0.窗口 1.全屏 2.全屏窗口
47
49 _strTitle{ "C++ drawing library" },
50 _size{ 800,600 },
52 _bHideTitle{ false }
53 {}
54};
55
64
65class SystemImp;
67class System
68{
69public:
70 using Func = void (*)(void);
73
79 void Start(std::string_view json_window,
80 std::string_view json_path = "");
81
85 void Start(const ParamWindow& param = {});
89 void Exit();
93 void SetFuncInit(Func func) { _funcInit = func; }
97 void SetFuncRun(Func func) { _funcRun = func; }
98
105
117 void SetWindowPoint(const Point& xy);
118
126 void SetWindowTitle(std::string_view str);
131
135
139 void ScreenShot(std::string_view path_name);
140
141 enum class CursorMode
142 {
146 };
147
152
156 void SetClipboardString(std::string_view str);
160 std::string GetClipboardString();
161
166 {
167 _vecDropFile.clear();
168 }
169
172 const std::vector<std::string>& GetDropFile()
173 {
174 return _vecDropFile;
175 }
176
181 void ShowMessageBox(std::string_view title, std::string_view text);
182
184 void SetFullScreen(FullScreenMode mode, const Size& size = {});
185
187 void SetWindowSize(const Size& size);
188
189 // todo(可能不再支持)
191 {
192 _dir = dir;
193 }
194
197
199 SystemStep GetStep() { return _step; }
200
202 std::string GetHardwareId();
203
205 std::string GetUsername();
206
208 void _add_drop_file(std::string_view str)
209 {
210 _vecDropFile.push_back(std::string{ str });
211 }
212
213 SystemImp* GetImp() { return _imp; }
214
215 // 提前初始化,以便使用glfw的一些接口,例如显示器相关
218
219 // 触发窗口大小变更(用户请勿调用)
220 void _resize();
221 // 设置屏幕方向(用户请勿调用)
222 void _set_dir(WindowDirection dir) { _dir = dir; }
223 // 屏幕方向处理glfw输入坐标
226 //--------------------------lua----------------------------
227 void lua_SetFuncInit(luabridge::LuaRef func);
228 void lua_SetFuncRun(luabridge::LuaRef func);
229private:
230 SystemImp* _imp;
231 Func _funcInit;
232 Func _funcRun;
233 SystemStep _step;
234
235 CursorMode _cursorMode;
236 bool _bCursorModeChange;
237
238 void* _nativeWindow;
239
240 std::vector<std::string> _vecDropFile;
241 FullScreenMode _fullScreenMode;
242 Size _desktopSize;// 仅用于恢复全屏到窗口全屏使用
243 WindowDirection _dir;
244
245 struct
246 {
247 luabridge::LuaRef _funcInit{ g_lua->GetL() };
248 luabridge::LuaRef _funcRun{ g_lua->GetL() };
249 }_lua;
250
251 bool _start_init(const ParamWindow& param);
252 void _start_loop();
253};
254extern System* g_system;
255}
256
257#endif
void SetWindowDirection(WindowDirection dir)
void _convert_system_to_glfw(Point &xy)
void SetFuncInit(Func func)
设置 初始化函数
void SetFullScreen(FullScreenMode mode, const Size &size={})
设置全屏
const std::vector< std::string > & GetDropFile()
返回拖入文件列表
void Start(const ParamWindow &param={})
创建窗口 并进入 游戏循环
void _init_glfw()
void SetWindowTitle(std::string_view str)
设置窗口标题
void SetFuncRun(Func func)
设置 帧函数
SystemStep GetStep()
返回引擎运行状态
void _delete_glfw()
void ScreenShot(std::string_view path_name)
截屏
std::string GetClipboardString()
返回剪贴板
Size GetWindowSize()
返回窗口大小
void _convert_glfw_to_system(Point &xy)
std::string GetHardwareId()
硬件码(md5 长度32)
void SetWindowPoint(const Point &xy)
设置窗口位置
void _add_drop_file(std::string_view str)
内部调用
bool IsWindowExist()
窗口是否存在
std::string GetUsername()
返回用户名
const RenderInfo2D & GetRenderInfo2D()
返回上一帧绘图信息
void _resize()
void SetWindowCenter()
设置窗口居中(以工作区大小)
SystemImp * GetImp()
void SetWindowSize(const Size &size)
设置窗口大小
void ClearDropFile()
清空拖入文件列表
void lua_SetFuncInit(luabridge::LuaRef func)
void Exit()
创建窗口 并进入 游戏循环
void SetClipboardString(std::string_view str)
设置剪贴板
void lua_SetFuncRun(luabridge::LuaRef func)
void SetCursorMode(CursorMode mode)
设置光标模式
void SetCursorPosition(Point xy)
设置鼠标位置,不用此来实现摄像机
const RenderInfo3D & GetRenderInfo3D()
WindowDirection GetWindowDirection()
返回屏幕方向
void Start(std::string_view json_window, std::string_view json_path="")
进入 游戏循环
void ShowMessageBox(std::string_view title, std::string_view text)
系统框提示
void _set_dir(WindowDirection dir)
Size GetWorkArea()
获取桌面大小,不包含任务栏
void(*)(void) Func
lua封装
通用类型
常用类型
SystemStep
运行步骤
WindowDirection
屏幕方向
System * g_system
LuaScript * g_lua
FullScreenMode
全屏模式
PointU Size
Point2 Point
创建窗口参数
std::string _strTitle
FullScreenMode _fullScreenMode