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