feat: 添加LGUI库和测试程序

添加一个简单的GUI库(lgui.lua)用于CC Tweaked,包含窗口、按钮、标签和文本框等基础组件
同时添加测试程序(test_lgui.lua)用于演示库的功能
更新安装器版本号至0.3.8 Beta 3 Alpha 2
This commit is contained in:
2025-09-03 13:46:15 +08:00
parent 640be70beb
commit c9c98f6ba7
4 changed files with 722 additions and 2870 deletions

View File

@@ -0,0 +1,66 @@
-- test_lgui.lua - Test script for lgui library
-- Load the GUI library
local lgui = require("lgui")
-- Create a main window
local mainWindow = lgui.createWindow(2, 2, 40, 15, "LGUI Test")
-- Add a label
local titleLabel = lgui.Label:new(2, 2, "LGUI Test Application", 36)
titleLabel:setAlignment("center")
titleLabel:setColors(lgui.colors.YELLOW, lgui.colors.BLACK)
mainWindow:addChild(titleLabel)
-- Add a text field
local textField = lgui.TextField:new(5, 4, 30)
textField:setText("Enter your name...")
textField:setColors(lgui.colors.WHITE, lgui.colors.BLACK)
mainWindow:addChild(textField)
-- Add a button that shows the text from the text field
local showButton = lgui.Button:new(5, 6, 15, 3, "Show Text")
showButton:setColors(lgui.colors.WHITE, lgui.colors.BLUE)
showButton:setOnClick(function()
local text = textField:getText()
if text and text ~= "" then
resultLabel:setText("You entered: " .. text)
else
resultLabel:setText("Please enter some text first")
end
end)
mainWindow:addChild(showButton)
-- Add a button that changes the background color
local colorButton = lgui.Button:new(22, 6, 15, 3, "Change Color")
colorButton:setColors(lgui.colors.WHITE, lgui.colors.GREEN)
local colors = {lgui.colors.RED, lgui.colors.GREEN, lgui.colors.BLUE, lgui.colors.YELLOW}
local currentColor = 1
colorButton:setOnClick(function()
currentColor = currentColor % #colors + 1
mainWindow:setColors(lgui.colors.WHITE, colors[currentColor])
mainWindow:requestRedraw()
end)
mainWindow:addChild(colorButton)
-- Add a result label
local resultLabel = lgui.Label:new(5, 10, "", 30)
resultLabel:setColors(lgui.colors.CYAN, lgui.colors.BLACK)
mainWindow:addChild(resultLabel)
-- Add an exit button
local exitButton = lgui.Button:new(15, 12, 12, 3, "Exit")
exitButton:setColors(lgui.colors.WHITE, lgui.colors.RED)
exitButton:setOnClick(function()
lgui.stop()
end)
mainWindow:addChild(exitButton)
-- Start the GUI
print("Starting LGUI test application...")
print("Click and drag the window title bar to move the window.")
print("Type in the text field and click 'Show Text' to see what you entered.")
print("Click 'Change Color' to change the window background color.")
print("Click 'Exit' to quit the application.")
lgui.start()
print("LGUI test application closed.")