...
 
Commits (4)
    https://gitcode.net/GGELUA/GGELUA2/-/commit/f3dcf592c2652f46127f25b0c7ed38e24d6305e3 优化 2022-02-15T09:24:37+08:00 baidwwy baidwwy@vip.qq.com https://gitcode.net/GGELUA/GGELUA2/-/commit/4604849ec4e17355689607125c27aa8c5b6399b3 SDL_QUIT 2022-02-16T15:00:32+08:00 baidwwy baidwwy@vip.qq.com 注册事件 拖放文件 https://gitcode.net/GGELUA/GGELUA2/-/commit/c940c88c8d784985fc1042f675a9d5fe5105e3f0 修复 TGA 2022-02-21T04:20:58+08:00 baidwwy baidwwy@vip.qq.com 完善 IMGUI https://gitcode.net/GGELUA/GGELUA2/-/commit/18f20b486aa574c78dbd9649cb2a9f491c3d28a7 imgui 添加禁止 2022-02-22T14:03:33+08:00 baidwwy baidwwy@vip.qq.com
无法预览此类型文件
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2022-01-25 22:14:50 -- @Date : 2022-01-25 22:14:50
-- @Last Modified by : GGELUA -- @Last Modified by : baidwwy
-- @Last Modified time : 2022-02-13 15:06:20 -- @Last Modified time : 2022-02-15 09:23:28
require('build/base') require('build/base')
pcall(require, 'ggerun') pcall(require, 'ggerun')
编译目录('ggelua')
编译目录('./lua')
写出脚本('./.ggelua/ggelua')
local lfs = require('lfs')
list = 判断文件('./.ggelua/assetslist.lua') and require('assetslist') or {}
if type(list) ~= 'table' then
list = {}
end
if arg[1] == 'windows' then if arg[1] == 'windows' then
执行('%s/GGELUAc.exe %s', 引擎目录, 项目目录) 执行('%s/GGELUAc.exe %s', 引擎目录, 项目目录)
else else
编译目录('ggelua')
编译目录('./lua')
写出脚本('./.ggelua/ggelua')
local lfs = require('lfs')
list = 判断文件('./.ggelua/assetslist.lua') and require('assetslist') or {}
if type(list) ~= 'table' then
list = {}
end
--adb shell pm dump com.GGELUA.game | findstr "versionName" --adb shell pm dump com.GGELUA.game | findstr "versionName"
local r = 执行('adb shell pm list packages | findstr "com.GGELUA.game"') local r = 执行('adb shell pm list packages | findstr "com.GGELUA.game"')
if not r then if not r then
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-17 08:26:43 -- @Date : 2021-09-17 08:26:43
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-08 12:04:56 -- @Last Modified time : 2022-02-16 14:55:37
local adler32 = require('zlib').adler32 local adler32 = require('zlib').adler32
local m_pack = require('cmsgpack').pack local m_pack = require('cmsgpack').pack
...@@ -23,17 +23,20 @@ local _CBK = setmetatable({}, {__mode = 'k'}) ...@@ -23,17 +23,20 @@ local _CBK = setmetatable({}, {__mode = 'k'})
function RPCClient:RPCClient(mcall) function RPCClient:RPCClient(mcall)
if mcall and 引擎 then --用主线程回调数据 if mcall and 引擎 then --用主线程回调数据
self._mdata = {} self._mdata = {}
self._mreg =
引擎:注册事件 { 引擎:注册事件(
更新事件 = function() self,
if next(self._mdata) then {
for _, v in ipairs(self._mdata) do 更新事件 = function()
self:_接收事件(v, true) if next(self._mdata) then
for _, v in ipairs(self._mdata) do
self:_接收事件(v, true)
end
self._mdata = {}
end end
self._mdata = {}
end end
end }
} )
end end
PackClient.PackClient(self) --初始化父类 PackClient.PackClient(self) --初始化父类
local reg = {} local reg = {}
......
-- @Author: baidwwy -- @Author: baidwwy
-- @Date: 2021-07-10 16:32:33 -- @Date: 2021-07-10 16:32:33
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-17 01:16:48 -- @Last Modified time : 2022-02-16 14:56:32
local SDL = require 'SDL' local SDL = require 'SDL'
local GUI = class('GUI') local GUI = class('GUI')
...@@ -28,42 +28,44 @@ function GUI:初始化(窗口, 文字) ...@@ -28,42 +28,44 @@ function GUI:初始化(窗口, 文字)
self._modal = {} self._modal = {}
self._msg = {} self._msg = {}
self._mcb = self._win:注册事件(
self._win:注册事件 { self,
键盘事件 = function(...) {
if not self._msg.键盘 then 键盘事件 = function(...)
self._msg.键盘 = {} if not self._msg.键盘 then
end self._msg.键盘 = {}
table.insert(self._msg.键盘, select(select('#', ...), ...)) end
end, table.insert(self._msg.键盘, select(select('#', ...), ...))
输入事件 = function(...) end,
if not self._msg.输入 then 输入事件 = function(...)
self._msg.输入 = {} if not self._msg.输入 then
end self._msg.输入 = {}
table.insert(self._msg.输入, select(select('#', ...), ...)) end
end, table.insert(self._msg.输入, select(select('#', ...), ...))
输入法事件 = function(...) end,
if not self._msg.输入法 then 输入法事件 = function(...)
self._msg.输入法 = {} if not self._msg.输入法 then
end self._msg.输入法 = {}
table.insert(self._msg.输入法, select(select('#', ...), ...)) end
end, table.insert(self._msg.输入法, select(select('#', ...), ...))
鼠标事件 = function(...) end,
if not self._msg.鼠标 then 鼠标事件 = function(...)
self._msg.鼠标 = {} if not self._msg.鼠标 then
end self._msg.鼠标 = {}
table.insert(self._msg.鼠标, select(select('#', ...), ...)) end
end, table.insert(self._msg.鼠标, select(select('#', ...), ...))
用户事件 = function(...) end,
if not self._msg.用户 then 用户事件 = function(...)
self._msg.用户 = {} if not self._msg.用户 then
self._msg.用户 = {}
end
table.insert(self._msg.用户, select(select('#', ...), ...))
end end
table.insert(self._msg.用户, select(select('#', ...), ...)) -- 窗口事件 = function(...)
end -- table.insert(self._msg.窗口, select(select('#', ...), ...))
-- 窗口事件 = function(...) -- end
-- table.insert(self._msg.窗口, select(select('#', ...), ...)) }
-- end )
}
end end
function GUI:更新(dt, x, y) function GUI:更新(dt, x, y)
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 23:01:12 -- @Last Modified time : 2022-02-20 08:43:50
local gge = require('ggelua') local gge = require('ggelua')
local SDL = require('SDL') local SDL = require('SDL')
...@@ -21,9 +21,9 @@ require('IMGUI.提示') ...@@ -21,9 +21,9 @@ require('IMGUI.提示')
require('IMGUI.文本') require('IMGUI.文本')
require('IMGUI.纹理') require('IMGUI.纹理')
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
local init --引用一下,不然会释放 local init --引用一下,不然会释放
local IMGUI = class('IMGUI',IM控件) local IMGUI = class('IMGUI', IM控件)
function IMGUI:初始化(file, size) function IMGUI:初始化(file, size)
if not init then if not init then
...@@ -50,12 +50,12 @@ function IMGUI:初始化(file, size) ...@@ -50,12 +50,12 @@ function IMGUI:初始化(file, size)
end end
end end
function IMGUI:更新() function IMGUI:更新(dt)
im.NewFrame() im.NewFrame()
if self._demo[1] then if self._demo[1] then
im.ShowDemoWindow(self._demo) im.ShowDemoWindow(self._demo)
end end
IM控件.更新(self) IM控件._更新(self, dt)
im.EndFrame() im.EndFrame()
end end
...@@ -71,5 +71,4 @@ end ...@@ -71,5 +71,4 @@ end
function IMGUI:添加文字() function IMGUI:添加文字()
end end
return IMGUI return IMGUI
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:09:04 -- @Last Modified time : 2022-02-21 03:45:41
local im = require"gimgui" local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
local IM列表 = class('IM列表',IM控件) local IM列表 = class('IM列表', IM控件)
function IM列表:初始化() function IM列表:初始化()
self[1] = true self._list = {}
end
function IM列表:_更新(dt)
if im.ListBox(self.名称, self, self._list) then
self.当前选中 = self[1]
self:发送消息('选中事件', self[1])
end
end end
function IM列表:更新() function IM列表:添加(v)
table.insert(self._list, tostring(v))
end
function IM列表:删除(i)
table.remove(self._list, i)
end
function IM列表:置列表(v)
if type(v) == 'table' then
self._list = v
end
end
--==============================================================================
function IM控件:创建列表(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM列表(name, ...)
table.insert(self._子控件, self[name])
self[name]._tp = 2
return self[name]
end end
return IM列表 return IM列表
\ No newline at end of file
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:09:09 -- @Last Modified time : 2022-02-21 03:33:01
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,19 +9,19 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,19 +9,19 @@ local IM控件 = require 'IMGUI.控件'
local IM区域 = class('IM区域', IM控件) local IM区域 = class('IM区域', IM控件)
function IM区域:初始化() function IM区域:初始化()
self[1] = true self._name = tostring(self)
--self._frame = true --self._frame = true
end end
function IM区域:更新() function IM区域:_更新(dt)
--不需要if --不需要if
if self._frame then if self._frame then
im.BeginChildFrame(self.名称, self.宽度, self.高度, self._flag) im.BeginChildFrame(self._name, self.宽度, self.高度, self._flag)
else else
im.BeginChild(self.名称, self.宽度, self.高度, self._border, self._flag) im.BeginChild(self._name, self.宽度, self.高度, self._border, self._flag)
end end
IM控件.更新(self) IM控件._更新(self, dt)
if self._auto then if self._auto then
if im.GetScrollY() >= im.GetScrollMaxY() then if im.GetScrollY() >= im.GetScrollMaxY() then
im.SetScrollHereY(1) im.SetScrollHereY(1)
...@@ -43,8 +43,9 @@ function IM区域:置边框(b) ...@@ -43,8 +43,9 @@ function IM区域:置边框(b)
self._border = b self._border = b
return self return self
end end
--==============================================================================
function IM控件:创建区域(name, ...) function IM控件:创建区域(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM区域(name, ...) self[name] = IM区域(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:15:46 -- @Last Modified time : 2022-02-21 03:32:34
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -10,9 +10,10 @@ local IM弹出 = class('IM弹出', IM控件) ...@@ -10,9 +10,10 @@ local IM弹出 = class('IM弹出', IM控件)
function IM弹出:初始化() function IM弹出:初始化()
self._tp = 2 self._tp = 2
self.是否可见 = false
end end
function IM弹出:更新(...) function IM弹出:_更新(dt)
local r local r
if self._tp == 1 then if self._tp == 1 then
r = im.BeginPopup(self.名称, 0) r = im.BeginPopup(self.名称, 0)
...@@ -23,7 +24,7 @@ function IM弹出:更新(...) ...@@ -23,7 +24,7 @@ function IM弹出:更新(...)
end end
if r then if r then
IM控件.更新(self,...) IM控件._更新(self, dt)
im.EndPopup() im.EndPopup()
return true return true
end end
...@@ -34,8 +35,9 @@ function IM弹出:置可见(b) ...@@ -34,8 +35,9 @@ function IM弹出:置可见(b)
im.CloseCurrentPopup() im.CloseCurrentPopup()
end end
end end
--==============================================================================
function IM控件:创建弹出(name, ...) function IM控件:创建弹出(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM弹出(name, ...) self[name] = IM弹出(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
self[name]._tp = 1 self[name]._tp = 1
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:49:10 -- @Last Modified time : 2022-02-21 03:28:36
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,53 +9,52 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,53 +9,52 @@ local IM控件 = require 'IMGUI.控件'
local IM按钮 = class('IM按钮', IM控件) local IM按钮 = class('IM按钮', IM控件)
function IM按钮:初始化() function IM按钮:初始化()
self[1] = true
self._sel = {}
self._tp = 1 self._tp = 1
end end
function IM按钮:更新() function IM按钮:_更新(dt)
local r local r
if self._tp == 1 then if self._tp == 1 then
if im.Button(self.名称, self._w, self._h) then if im.Button(self.名称, self._w, self._h) then
self:发送消息('点击事件') self:发送消息('左键事件')
end end
elseif self._tp == 2 then elseif self._tp == 2 then
if im.RadioButton(self.名称, self._sel) then if im.RadioButton(self.名称, self) then
self:发送消息('选中事件', self._sel[1]) self.是否选中 = self[1]
self:发送消息('选中事件', self[1])
end end
elseif self._tp == 3 then elseif self._tp == 3 then
if im.Checkbox(self.名称, self._sel) then if im.Checkbox(self.名称, self) then
self:发送消息('选中事件', self._sel[1]) self.是否选中 = self[1]
self:发送消息('选中事件', self[1])
end end
elseif self._tp == 4 then elseif self._tp == 4 then
--r=im.ImageButton(ptr) --r=im.ImageButton(ptr)
end end
IM控件.更新_(self) IM控件._检查鼠标(self)
end end
function IM按钮:置选中(v) function IM按钮:置选中(v)
self._sel = {v==true} self[1] = v == true
return self return self
end end
--==============================================================================
function IM控件:创建按钮(name, ...) function IM控件:创建按钮(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM按钮(name, ...) self[name] = IM按钮(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
end end
function IM控件:创建单选按钮(name, ...) function IM控件:创建单选按钮(name, ...)
self[name] = IM按钮(name, ...) local r = self:创建按钮(name, ...)
table.insert(self._子控件, self[name]) r._tp = 2
self[name]._tp = 2 return r
return self[name]
end end
function IM控件:创建多选按钮(name, ...) function IM控件:创建多选按钮(name, ...)
self[name] = IM按钮(name, ...) local r = self:创建按钮(name, ...)
table.insert(self._子控件, self[name]) r._tp = 3
self[name]._tp = 3 return r
return self[name]
end end
return IM按钮 return IM按钮
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-12-11 01:01:03 -- @Date : 2021-12-11 01:01:03
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:54:47 -- @Last Modified time : 2022-02-21 17:22:04
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = class('IM控件') local IM控件 = class('IM控件')
function IM控件:初始化(name, w, h, x, y) function IM控件:初始化(name, x, y, w, h)
self.名称 = name and tostring(name) or nil self.名称 = name and tostring(name) or nil
self.x = math.floor(tonumber(x) or 0) self.x = math.floor(tonumber(x) or 0)
self.y = math.floor(tonumber(y) or 0) self.y = math.floor(tonumber(y) or 0)
...@@ -14,39 +14,50 @@ function IM控件:初始化(name, w, h, x, y) ...@@ -14,39 +14,50 @@ function IM控件:初始化(name, w, h, x, y)
self.高度 = h self.高度 = h
self._子控件 = {} self._子控件 = {}
self.是否可见 = true
end end
function IM控件:__index(k) function IM控件:_更新(...)
if k == '是否可见' then
return self[1]
end
end
function IM控件:更新(...)
for _, v in ipairs(self._子控件) do for _, v in ipairs(self._子控件) do
if v[1] then if v.是否可见 then
v:更新(...) if v.是否禁止 then
im.BeginDisabled(true)
end
v:_更新(...)
if v.是否禁止 then
im.EndDisabled()
end
if v.更新 then
v:更新(...)
end
end
end
for i, v in ipairs(self._子控件) do
if not v.是否可见 and v._temp then
table.remove(self._子控件, i)
break
end end
end end
end end
function IM控件:_更新() function IM控件:_检查鼠标()
if self._iswin then if im.IsItemHovered() then
else if self._tip then
end im.SetTooltip(self._tip)
-- if self._nw then end
-- im.SetNextItemWidth(self._nw) self:发送消息('焦点事件')
-- self._nw = nil end
-- end if im.IsItemClicked() then
-- if self._open then self:发送消息('左键事件')
-- self._open = nil if im.IsMouseDoubleClicked() then
-- im.SetNextItemOpen(true) self:发送消息('左键双击事件')
-- end end
end end
if im.IsItemClicked(1) then
function IM控件:更新_() self:发送消息('右键事件')
if self._tip and im.IsItemHovered() then if im.IsMouseDoubleClicked(1) then
im.SetTooltip(self._tip) self:发送消息('右键双击事件')
end
end end
end end
...@@ -55,14 +66,14 @@ function IM控件:置可见(val, sub) ...@@ -55,14 +66,14 @@ function IM控件:置可见(val, sub)
return self return self
end end
if self._lock then if self._lock then
self[1] = val == true self.是否可见 = val == true
return return
end end
self._lock = true self._lock = true
if self:发送消息('可见事件', val) == false then if self:发送消息('可见事件', val) == false then
return self return self
end end
self[1] = val == true self.是否可见 = val == true
if not self.是否实例 and val then if not self.是否实例 and val then
if rawget(self, '初始化') then if rawget(self, '初始化') then
...@@ -94,8 +105,8 @@ function IM控件:发送消息(name, ...) ...@@ -94,8 +105,8 @@ function IM控件:发送消息(name, ...)
end end
local 同行 = { local 同行 = {
[1] = true, 是否可见 = true,
更新 = function() _更新 = function()
im.SameLine() im.SameLine()
end end
} }
...@@ -105,8 +116,8 @@ function IM控件:同行() ...@@ -105,8 +116,8 @@ function IM控件:同行()
end end
local 对齐 = { local 对齐 = {
[1] = true, 是否可见 = true,
更新 = function() _更新 = function()
im.AlignTextToFramePadding() im.AlignTextToFramePadding()
end end
} }
...@@ -116,8 +127,8 @@ function IM控件:对齐() ...@@ -116,8 +127,8 @@ function IM控件:对齐()
end end
local 分隔线 = { local 分隔线 = {
[1] = true, 是否可见 = true,
更新 = function() _更新 = function()
im.Separator() im.Separator()
end end
} }
...@@ -131,34 +142,49 @@ function IM控件:置提示(v) ...@@ -131,34 +142,49 @@ function IM控件:置提示(v)
end end
function IM控件:创建控件(name, ...) function IM控件:创建控件(name, ...)
assert(not self[name], name .. ':此控件已存在,不能重复创建.') assert(self[name] == nil, name .. '->已经存在')
self[name] = IM控件(name, ...) self[name] = IM控件(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
end end
local IM选项 = class('IM选项',IM控件) function IM控件:删除控件(name)
function IM选项:初始化() for i, v in ipairs(self._子控件) do
self._flag = 2|4 if v == self[name] then
self.是否选中 = false table.remove(self._子控件, i)
self[1] = true self[name] = nil
end return true
function IM选项:更新()
if im.Selectable(self.名称,self.是否选中,self._flag) then
self:发送消息('选中事件',self.是否选中)
if im.IsMouseDoubleClicked() then --ImGuiMouseButton_Left flag = 4
self:发送消息('双击事件')
end end
end end
IM控件.更新(self)
end end
function IM选项:置选中(b) function IM控件:清空控件()
self.是否选中 = b==true
end end
--==============================================================================
local IM选项 = class('IM选项', IM控件)
do
function IM选项:初始化()
self._flag = 2 | 4
self.是否选中 = false
end
function IM选项:_更新()
if im.Selectable(self.名称, self.是否选中, self._flag) then
self:发送消息('选中事件', self.是否选中)
if im.IsMouseDoubleClicked() then --ImGuiMouseButton_Left flag = 4
self:发送消息('双击事件')
end
end
IM控件._更新(self)
end
function IM选项:置选中(b)
self.是否选中 = b == true
end
end
--==============================================================================
function IM控件:创建选项(name, ...) function IM控件:创建选项(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM选项(name, ...) self[name] = IM选项(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 17:24:13 -- @Last Modified time : 2022-02-21 03:36:08
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,15 +9,17 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,15 +9,17 @@ local IM控件 = require 'IMGUI.控件'
local IM提示 = class('IM提示', IM控件) local IM提示 = class('IM提示', IM控件)
function IM提示:初始化() function IM提示:初始化()
self.是否可见 = false
end end
function IM提示:更新() function IM提示:_更新()
im.BeginTooltip() im.BeginTooltip()
IM控件.更新(self) IM控件._更新(self)
im.EndTooltip() im.EndTooltip()
end end
--==============================================================================
function IM控件:创建提示(name, ...) function IM控件:创建提示(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM提示(name, ...) self[name] = IM提示(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:53:47 -- @Last Modified time : 2022-02-21 03:36:26
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,18 +9,17 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,18 +9,17 @@ local IM控件 = require 'IMGUI.控件'
local IM文本 = class('IM文本', IM控件) local IM文本 = class('IM文本', IM控件)
function IM文本:初始化() function IM文本:初始化()
self[1] = true
end end
function IM文本:更新() function IM文本:_更新()
if self._cr then if self._cr then
im.TextColored(self.名称, self._cr, self._cg, self._cb, self._ca) im.TextColored(self.str or self.名称, self._cr, self._cg, self._cb, self._ca)
elseif self.是否禁止 then elseif self.是否禁止 then
im.TextDisabled(self.名称) im.TextDisabled(self.str or self.名称)
else else
im.TextUnformatted(self.名称) im.TextUnformatted(self.str or self.名称)
end end
IM控件.更新_(self) IM控件._检查鼠标(self)
end end
function IM文本:置颜色(r, g, b, a) function IM文本:置颜色(r, g, b, a)
...@@ -30,7 +29,12 @@ function IM文本:置颜色(r, g, b, a) ...@@ -30,7 +29,12 @@ function IM文本:置颜色(r, g, b, a)
self._ca = a and (a / 255) or 1 self._ca = a and (a / 255) or 1
end end
function IM文本:置文本(t)
self.str = t
end
--==============================================================================
function IM控件:创建文本(name, ...) function IM控件:创建文本(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM文本(name, ...) self[name] = IM文本(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:08:41 -- @Last Modified time : 2022-02-21 03:29:08
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
local IM标签选项 = class('IM标签选项', IM控件) local IM标签选项 = class('IM标签选项', IM控件)
function IM标签选项:初始化() function IM标签选项:初始化()
self[1] = true
end end
function IM标签选项:更新() function IM标签选项:_更新(dt)
if im.BeginTabItem(self.名称) then if im.BeginTabItem(self.名称) then
IM控件.更新(self) IM控件._更新(self)
im.EndTabItem() im.EndTabItem()
end end
end end
...@@ -24,9 +23,9 @@ local IM标签 = class('IM标签', IM控件) ...@@ -24,9 +23,9 @@ local IM标签 = class('IM标签', IM控件)
function IM标签:初始化() function IM标签:初始化()
end end
function IM标签:更新() function IM标签:_更新(dt)
if im.BeginTabBar(self.名称) then if im.BeginTabBar(self.名称) then
IM控件.更新(self) IM控件._更新(self)
im.EndTabBar() im.EndTabBar()
end end
--ImGuiTabBarFlags_NoTooltip --ImGuiTabBarFlags_NoTooltip
...@@ -37,8 +36,9 @@ function IM标签:添加(name) ...@@ -37,8 +36,9 @@ function IM标签:添加(name)
table.insert(self._子控件, obj) table.insert(self._子控件, obj)
return obj return obj
end end
--==============================================================================
function IM控件:创建标签(name, ...) function IM控件:创建标签(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM标签(name, ...) self[name] = IM标签(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:09:20 -- @Last Modified time : 2022-02-21 03:35:47
local GGF = require('GGE.函数')
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
local IM = class('IM树', IM控件) local IM = class('IM树', IM控件)
function IM:初始化(name) function IM:初始化(name)
self[1] = true self._name = name .. '##' .. tostring(self) --避免重复
self._name = name self._tp = 1
end
function IM:_更新()
if self._tp == 1 then
if self._open ~= nil then
im.SetNextItemOpen(self._open)
self._open = nil
end
if im.TreeNode(self._name) then
IM控件._更新(self)
im.TreePop()
end
elseif self._tp == 2 then
im.TreeNodeEx(self._name, 8 | 256 | 512) --ImGuiTreeNodeFlags_NoTreePushOnOpen|ImGuiTreeNodeFlags_Leaf|ImGuiTreeNodeFlags_Bullet
IM控件._检查鼠标(self)
end
end end
function IM:开始(name) function IM:添加(path)
return im.TreeNode(name or self._name) local list = GGF.分割文本(path:gsub('\\', '/'), '/')
local file = table.remove(list)
local tree = self
for _, v in ipairs(list) do
if tree[v] then
tree = tree[v]
else
tree = tree:创建树(v)
end
end
local leaf = tree:创建树叶(file)
leaf._path = path
return leaf
end end
function IM:结束() IM.清空 = IM.清空控件
im.TreePop()
function IM:展开(v)
self._open = v == true
return self
end
--==============================================================================
function IM控件:创建树(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM(name, ...)
table.insert(self._子控件, self[name])
return self[name]
end end
function IM:树叶(name) function IM控件:创建树叶(name, ...)
im.TreeNodeEx(name,256|8)--ImGuiTreeNodeFlags_Leaf local r = IM(name, ...)
return im.IsItemClicked() r._tp = 2
table.insert(self._子控件, r)
return r
end end
return IM return IM
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:55:27 -- @Last Modified time : 2022-02-21 03:55:23
local ggf = require('GGE.函数') local ggf = require('GGE.函数')
local im = require 'gimgui' local im = require 'gimgui'
...@@ -10,9 +10,18 @@ local IM控件 = require 'IMGUI.控件' ...@@ -10,9 +10,18 @@ local IM控件 = require 'IMGUI.控件'
local IM窗口 = class('IM窗口', IM控件) local IM窗口 = class('IM窗口', IM控件)
function IM窗口:初始化(name, x, y, w, h) function IM窗口:初始化(name, x, y, w, h)
--self._name = name .. '##' .. tostring(self) self._name = name .. '##' .. tostring(self)
self._iswin = true self._iswin = true
self._flag = 64 self._flag = 64
self.是否可见 = false
if x and y then
self._x = x
self._y = y
end
if w and h then
self._w = w
self._h = h
end
end end
local flag = local flag =
...@@ -39,27 +48,28 @@ function IM窗口:__newindex(k, v) ...@@ -39,27 +48,28 @@ function IM窗口:__newindex(k, v)
rawset(self, k, v) rawset(self, k, v)
end end
function IM窗口:更新() function IM窗口:_更新(dt)
if self[1] then if self.是否可见 then
if self._x then if self._x then
im.SetNextWindowPos(self._x, self._y) im.SetNextWindowPos(self._x, self._y)
self._x = nil self._x = nil
self._y = nil self._y = nil
end end
if self._w then if self._w and self._h then
im.SetNextWindowSize(self._w, self._h) im.SetNextWindowSize(self._w, self._h)
self._w = nil self._w = nil
self._h = nil self._h = nil
end end
if im.Begin(self.名称, self, self._flag) then if im.Begin(self._name, self, self._flag) then
IM控件.更新(self) self.是否可见 = self[1]
IM控件._更新(self, dt)
im.End() im.End()
end end
end end
end end
function IM窗口:置可见(v, s) function IM窗口:置可见(v, s)
self[1] = true self[1] = v == true
IM控件.置可见(self, v, s or not self.是否实例) IM控件.置可见(self, v, s or not self.是否实例)
return self return self
end end
...@@ -95,13 +105,21 @@ end ...@@ -95,13 +105,21 @@ end
function IM窗口:取窗口高度() function IM窗口:取窗口高度()
return im.GetWindowHeight() return im.GetWindowHeight()
end end
--==============================================================================
function IM控件:创建窗口(name, ...) function IM控件:创建窗口(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM窗口(name, ...) self[name] = IM窗口(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
end end
--=====================================================
function IM控件:创建临时窗口(name, ...) --关闭将被删除
local r = IM窗口(name, ...)
table.insert(self._子控件, r)
r._temp = true
return r
end
--==============================================================================
local IM模态窗口 = class('IM模态窗口', IM控件) local IM模态窗口 = class('IM模态窗口', IM控件)
function IM模态窗口:初始化(name) function IM模态窗口:初始化(name)
...@@ -109,19 +127,17 @@ function IM模态窗口:初始化(name) ...@@ -109,19 +127,17 @@ function IM模态窗口:初始化(name)
self._flag = 64 | 256 self._flag = 64 | 256
end end
function IM模态窗口:更新() function IM模态窗口:_更新()
-- return im.BeginPopupModal(self._name,self,self._flag) -- return im.BeginPopupModal(self._name,self,self._flag)
-- return im.EndPopup() -- return im.EndPopup()
end end
--在开始 结束 之间使用 --在开始 结束 之间使用
-- function IM模态窗口:关闭() -- function IM模态窗口:关闭()
-- self[1] = false
-- return im.CloseCurrentPopup() -- return im.CloseCurrentPopup()
-- end -- end
-- function IM模态窗口:打开() -- function IM模态窗口:打开()
-- self[1] = true
-- return im.OpenPopup(self._name) -- return im.OpenPopup(self._name)
-- end -- end
return IM窗口 return IM窗口
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:54:00 -- @Last Modified time : 2022-02-21 03:57:39
local im = require"gimgui" local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
local IM纹理 = class('IM纹理',IM控件) local IM纹理 = class('IM纹理', IM控件)
function IM纹理:初始化(t) function IM纹理:初始化()
self[1] = true
self._tex = t
end end
function IM纹理:更新() function IM纹理:_更新(dt)
im.Image(ptr) if self._tex then
IM控件.更新_(self) im.Image(self._tex:取对象())
IM控件._检查鼠标(self)
end
end end
return IM纹理 function IM纹理:置纹理(tex)
\ No newline at end of file self._tex = tex
return self
end
--==============================================================================
function IM控件:创建纹理(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM纹理(name, ...)
table.insert(self._子控件, self[name])
return self[name]
end
return IM纹理
-- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09
-- @Last Modified by : baidwwy
-- @Last Modified time : 2022-02-21 03:50:47
local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件'
local IM列表 = class('IM列表', IM控件)
function IM列表:初始化()
self._list = {}
end
function IM列表:_更新(dt)
if im.Combo(self.名称, self, self._list) then
self.当前选中 = self[1]
self:发送消息('选中事件', self[1])
end
end
function IM列表:添加(v)
table.insert(self._list, tostring(v))
end
function IM列表:删除(i)
table.remove(self._list, i)
end
function IM列表:置列表(v)
if type(v) == 'table' then
self._list = v
end
end
--==============================================================================
function IM控件:创建列表(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM列表(name, ...)
table.insert(self._子控件, self[name])
self[name]._tp = 2
return self[name]
end
return IM列表
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:15:34 -- @Last Modified time : 2022-02-21 03:30:01
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -10,58 +10,62 @@ local IM菜单 = class('IM菜单', IM控件) ...@@ -10,58 +10,62 @@ local IM菜单 = class('IM菜单', IM控件)
function IM菜单:初始化() function IM菜单:初始化()
self._tp = 1 self._tp = 1
self[1] = true
end end
function IM菜单:更新(...) function IM菜单:_更新(dt)
if self._tp == 1 then if self._tp == 1 then
if im.BeginMainMenuBar() then if im.BeginMainMenuBar() then
IM控件.更新(self) IM控件._更新(self, dt)
im.EndMainMenuBar() im.EndMainMenuBar()
end end
elseif self._tp == 2 then elseif self._tp == 2 then
if im.BeginMenuBar() then if im.BeginMenuBar() then
IM控件.更新(self) IM控件._更新(self, dt)
im.EndMenuBar() im.EndMenuBar()
end end
elseif self._tp == 3 then elseif self._tp == 3 then
if im.BeginMenu(self.名称, self.是否禁止) then if im.BeginMenu(self.名称, self.是否禁止) then
IM控件.更新(self) IM控件._更新(self, dt)
im.EndMenu() im.EndMenu()
end end
elseif self._tp == 4 then elseif self._tp == 4 then
if im.MenuItem(self.名称, self._shortcut, self._sel, self.是否禁止) then if im.MenuItem(self.名称, self._shortcut, self, self.是否禁止) then
self:发送消息('点击事件',...) self.是否选中 = self[1]
self:发送消息('左键事件')
end end
end end
end end
function IM菜单:置选中(v) function IM菜单:置选中(v)
self._sel = {v == true} self[1] = v == true
return self return self
end end
--==============================================================================
function IM控件:创建主菜单栏(name, ...) function IM控件:创建主菜单栏(name, ...) --BeginMainMenuBar
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM菜单(name, ...) self[name] = IM菜单(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
end end
function IM控件:创建菜单栏(name, ...) function IM控件:创建菜单栏(name, ...) --BeginMenuBar
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM菜单(name, ...) self[name] = IM菜单(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
self[name]._tp = 2 self[name]._tp = 2
return self[name] return self[name]
end end
function IM控件:创建菜单(name, ...) function IM控件:创建菜单(name, ...) --BeginMenu
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM菜单(name, ...) self[name] = IM菜单(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
self[name]._tp = 3 self[name]._tp = 3
return self[name] return self[name]
end end
function IM控件:创建菜单项(name, ...) function IM控件:创建菜单项(name, ...) --MenuItem
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM菜单(name, ...) self[name] = IM菜单(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
self[name]._tp = 4 self[name]._tp = 4
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-11 22:27:53 -- @Last Modified time : 2022-02-21 03:29:48
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,7 +9,6 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,7 +9,6 @@ local IM控件 = require 'IMGUI.控件'
local IM表格 = class('IM表格', IM控件) local IM表格 = class('IM表格', IM控件)
function IM表格:初始化(name) function IM表格:初始化(name)
self[1] = true
self._list = {} self._list = {}
self._data = {} self._data = {}
self._sel = {} self._sel = {}
...@@ -24,7 +23,7 @@ end ...@@ -24,7 +23,7 @@ end
-- return self -- return self
-- end -- end
function IM表格:更新() function IM表格:_更新(dt)
if im.BeginTable(self.名称, #self._list, self._flag) then if im.BeginTable(self.名称, #self._list, self._flag) then
if not self._head then if not self._head then
for i, v in ipairs(self._list) do for i, v in ipairs(self._list) do
...@@ -35,11 +34,12 @@ function IM表格:更新() ...@@ -35,11 +34,12 @@ function IM表格:更新()
for h, v in ipairs(self._data) do for h, v in ipairs(self._data) do
im.TableNextRow() im.TableNextRow()
self._sel[h].行号 = h self._sel[h].行号 = h
self.当前行 = h
for l, v in ipairs(v) do for l, v in ipairs(v) do
im.TableNextColumn() --im.TableSetColumnIndex(i) im.TableNextColumn() --im.TableSetColumnIndex(i)
v:更新() v:_更新(dt)
if self._pop and l == 1 then if self._pop and l == 1 then
if self._pop:更新(h) then if self._pop:_更新(dt) then
self._sel[h]:选中事件() self._sel[h]:选中事件()
end end
end end
...@@ -103,8 +103,9 @@ function IM表格:创建弹出() ...@@ -103,8 +103,9 @@ function IM表格:创建弹出()
self._pop = require('IMGUI.弹出')() self._pop = require('IMGUI.弹出')()
return self._pop return self._pop
end end
--==============================================================================
function IM控件:创建表格(name, ...) function IM控件:创建表格(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM表格(name, ...) self[name] = IM表格(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-09-01 21:04:09 -- @Date : 2021-09-01 21:04:09
-- @Last Modified by: baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time: 2021-12-13 22:53:20 -- @Last Modified time : 2022-02-21 03:34:44
local im = require 'gimgui' local im = require 'gimgui'
local IM控件 = require 'IMGUI.控件' local IM控件 = require 'IMGUI.控件'
...@@ -9,14 +9,13 @@ local IM控件 = require 'IMGUI.控件' ...@@ -9,14 +9,13 @@ local IM控件 = require 'IMGUI.控件'
local IM输入 = class('IM输入', IM控件) local IM输入 = class('IM输入', IM控件)
function IM输入:初始化() function IM输入:初始化()
self[1] = true
--self._flag = 0 --self._flag = 0
self._tp = 1 self._tp = 1
self._len = 128 self._len = 128
self._buf = {'', self._len} self._buf = {'', self._len}
end end
function IM输入:更新() function IM输入:_更新()
local r local r
if self._tp == 1 then if self._tp == 1 then
r = im.InputText(self.名称, self._buf) r = im.InputText(self.名称, self._buf)
...@@ -27,9 +26,9 @@ function IM输入:更新() ...@@ -27,9 +26,9 @@ function IM输入:更新()
elseif self._tp == 4 then elseif self._tp == 4 then
r = im.InputInt(self.名称, self._buf) r = im.InputInt(self.名称, self._buf)
end end
IM控件.更新_(self) IM控件._检查鼠标(self)
if r then if r then
self:发送消息('输入事件',self._buf[1]) self:发送消息('输入事件', self._buf[1])
end end
end end
...@@ -43,15 +42,16 @@ function IM输入:置最大输入(v) ...@@ -43,15 +42,16 @@ function IM输入:置最大输入(v)
return self return self
end end
function IM输入:置文本模式() function IM输入:置文本模式(v)
self._tp = 1 self._tp = 1
self._len = v or 512
self._buf = {'', self._len} self._buf = {'', self._len}
return self return self
end end
function IM输入:置多行模式() function IM输入:置多行模式(v)
self._tp = 2 self._tp = 2
self._len = 512 self._len = v or 512
self._buf = {'', self._len} self._buf = {'', self._len}
return self return self
end end
...@@ -67,27 +67,30 @@ function IM输入:置整数模式() ...@@ -67,27 +67,30 @@ function IM输入:置整数模式()
self._buf = {0} self._buf = {0}
return self return self
end end
--==============================================================================
function IM控件:创建输入(name, ...) function IM控件:创建输入(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM输入(name, ...) self[name] = IM输入(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name] return self[name]
end end
function IM控件:创建多行输入(name, ...) function IM控件:创建多行输入(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM输入(name, ...) self[name] = IM输入(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name]:置多行模式() return self[name]:置多行模式()
end end
function IM控件:创建整数输入(name, ...) function IM控件:创建整数输入(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM输入(name, ...) self[name] = IM输入(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name]:置整数模式() return self[name]:置整数模式()
end end
function IM控件:创建数值输入(name, ...) function IM控件:创建数值输入(name, ...)
assert(self[name] == nil, name .. '->已经存在')
self[name] = IM输入(name, ...) self[name] = IM输入(name, ...)
table.insert(self._子控件, self[name]) table.insert(self._子控件, self[name])
return self[name]:置数值模式() return self[name]:置数值模式()
......
-- @Author : GGELUA -- @Author : GGELUA
-- @Date : 2021-12-15 23:37:41 -- @Date : 2021-12-15 23:37:41
-- @Last Modified by : baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time : 2022-02-09 08:29:01 -- @Last Modified time : 2022-02-16 14:37:04
local _ENV = setmetatable(require('gsdl2'), {__index = _G}) local _ENV = setmetatable(require('gsdl2'), {__index = _G})
SDL = _ENV SDL = _ENV
...@@ -630,7 +630,7 @@ WINDOWEVENT_HIT_TEST = 16 -- /**< Window had a hit test that wasn't SDL_H ...@@ -630,7 +630,7 @@ WINDOWEVENT_HIT_TEST = 16 -- /**< Window had a hit test that wasn't SDL_H
-- 窗口_获得焦点 = 12 --WINDOWEVENT_FOCUS_GAINED -- 窗口_获得焦点 = 12 --WINDOWEVENT_FOCUS_GAINED
-- 窗口_失去焦点 = 13 --WINDOWEVENT_FOCUS_LOST -- 窗口_失去焦点 = 13 --WINDOWEVENT_FOCUS_LOST
-- 窗口_关闭 = 14 --WINDOWEVENT_CLOSE -- 窗口_关闭 = 14 --WINDOWEVENT_CLOSE
-- 窗口_拖放文件 = 0x1000 WINDOWEVENT_DROPFILE = 0x1000 --拖放文件
-- 状态_按下 = 1--SDL_PRESSED -- 状态_按下 = 1--SDL_PRESSED
-- 状态_弹起 = 0--SDL_RELEASED -- 状态_弹起 = 0--SDL_RELEASED
......
-- @Author: GGELUA -- @Author: GGELUA
-- @Date: 2021-09-19 06:42:20 -- @Date: 2021-09-19 06:42:20
-- @Last Modified by : baidwwy -- @Last Modified by : baidwwy
-- @Last Modified time : 2022-02-11 12:55:43 -- @Last Modified time : 2022-02-16 14:53:01
local SDL = require('SDL') local SDL = require('SDL')
local gge = require('ggelua') local gge = require('ggelua')
...@@ -112,7 +112,7 @@ function SDL窗口:SDL窗口(t) ...@@ -112,7 +112,7 @@ function SDL窗口:SDL窗口(t)
self:渲染清除(0, 0, 0) self:渲染清除(0, 0, 0)
self:渲染结束() self:渲染结束()
self._reg = setmetatable({}, {__mode = 'v'}) --注册消息 self._reg = setmetatable({}, {__mode = 'k'}) --注册消息
self._tick = {} self._tick = {}
self._timer = {} --定时器 self._timer = {} --定时器
end end
...@@ -222,6 +222,8 @@ function SDL窗口:_Event(t, ...) ...@@ -222,6 +222,8 @@ function SDL窗口:_Event(t, ...)
ggexpcall(self.初始化, self) ggexpcall(self.初始化, self)
self._inited = true self._inited = true
end end
elseif t == 0x100 then --SDL_QUIT
self:_Event(0x200, SDL.WINDOWEVENT_CLOSE)
elseif t == 0x200 or t == 0x1000 then --SDL_WINDOWEVENT|SDL_DROPFILE|SDL_DROPTEXT elseif t == 0x200 or t == 0x1000 then --SDL_WINDOWEVENT|SDL_DROPFILE|SDL_DROPTEXT
if t == 0x200 then --SDL_WINDOWEVENT if t == 0x200 then --SDL_WINDOWEVENT
local event, t = ... local event, t = ...
...@@ -291,10 +293,14 @@ function SDL窗口:_Event(t, ...) ...@@ -291,10 +293,14 @@ function SDL窗口:_Event(t, ...)
end end
end end
function SDL窗口:注册事件(t) function SDL窗口:注册事件(k, t)
if t == nil then
t = k
k = {}
end
if type(t) == 'table' then if type(t) == 'table' then
table.insert(self._reg, t) self._reg[k] = t
return t return k, t
end end
end end
--SDL.AddTimer是线程回调 --SDL.AddTimer是线程回调
......
无法预览此类型文件