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
21namespace dl
22{
30
38
41{
42 std::string _strTitle;
44 FullScreenMode _fullScreenMode; //0.窗口 1.全屏 2.全屏窗口
46
48 _strTitle{ "C++ drawing library" },
49 _size{ 800,600 },
51 _bHideTitle{ false }
52 {}
53};
54
63
64class SystemImp;
66class System
67{
68public:
69 using Func = void (*)(void);
72
78 void Start(std::string_view json_window,
79 std::string_view json_path = "");
80
84 void Start(const ParamWindow& param = {});
88 void Exit();
92 void SetFuncInit(Func func) { _funcInit = func; }
96 void SetFuncRun(Func func) { _funcRun = func; }
97
104
116 void SetWindowPoint(const Point& xy);
117
125 void SetWindowTitle(std::string_view str);
130
134
138 void ScreenShot(std::string_view path_name);
139
140 enum class CursorMode
141 {
145 };
146
151
155 void SetClipboardString(std::string_view str);
159 std::string GetClipboardString();
160
165 {
166 _vecDropFile.clear();
167 }
168
171 const std::vector<std::string>& GetDropFile()
172 {
173 return _vecDropFile;
174 }
175
180 void ShowMessageBox(std::string_view title, std::string_view text);
181
183 void SetFullScreen(FullScreenMode mode, const Size& size = {});
184
186 void SetWindowSize(const Size& size);
187
189 {
190 _dir = dir;
191 }
192
195
197 SystemStep GetStep() { return _step; }
198
200 std::string GetHardwareId();
201
203 std::string GetUsername();
204
206 void _add_drop_file(std::string_view str)
207 {
208 _vecDropFile.push_back(std::string{ str });
209 }
210
211 SystemImp* GetImp() { return _imp; }
212
213 // 提前初始化,以便使用glfw的一些接口,例如显示器相关
216
217 // 触发窗口大小变更(用户请勿调用)
218 void _resize();
219 // 设置屏幕方向(用户请勿调用)
220 void _set_dir(WindowDirection dir) { _dir = dir; }
221 // 屏幕方向处理glfw输入坐标
224 //--------------------------lua----------------------------
225 void lua_SetFuncUpdate(std::string_view str);
226private:
227 SystemImp* _imp;
228 Func _funcInit;
229 Func _funcRun;
230 SystemStep _step;
231
232 CursorMode _cursorMode;
233 bool _bCursorModeChange;
234
235 void* _nativeWindow;
236
237 std::vector<std::string> _vecDropFile;
238 FullScreenMode _fullScreenMode;
239 Size _desktopSize;// 仅用于恢复全屏到窗口全屏使用
240 WindowDirection _dir;
241
242 struct
243 {
244 std::string _funcUpdate;
245 }_lua;
246
247 bool _start_init(const ParamWindow& param);
248 void _start_loop();
249};
250extern System* g_system;
251}
252
253#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()
返回用户名
std::string _funcUpdate
const RenderInfo2D & GetRenderInfo2D()
返回上一帧绘图信息
void _resize()
void SetWindowCenter()
设置窗口居中(以工作区大小)
SystemImp * GetImp()
void SetWindowSize(const Size &size)
设置窗口大小
void ClearDropFile()
清空拖入文件列表
void Exit()
创建窗口 并进入 游戏循环
void SetClipboardString(std::string_view str)
设置剪贴板
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)
void lua_SetFuncUpdate(std::string_view str)
Size GetWorkArea()
获取桌面大小,不包含任务栏
void(*)(void) Func
通用类型
常用类型
SystemStep
运行步骤
WindowDirection
屏幕方向
System * g_system
FullScreenMode
全屏模式
PointU Size
Point2 Point
创建窗口参数
std::string _strTitle
FullScreenMode _fullScreenMode