hengyang_client/lua_probject/base_project/FairyGUI.lua

142 lines
3.4 KiB
Lua
Raw Normal View History

2025-04-15 14:59:43 +08:00
EventContext = FairyGUI.EventContext
EventListener = FairyGUI.EventListener
2025-04-01 10:48:36 +08:00
EventDispatcher = FairyGUI.EventDispatcher
2025-04-15 14:59:43 +08:00
InputEvent = FairyGUI.InputEvent
NTexture = FairyGUI.NTexture
Container = FairyGUI.Container
Image = FairyGUI.Image
Stage = FairyGUI.Stage
Controller = FairyGUI.Controller
GObject = FairyGUI.GObject
GGraph = FairyGUI.GGraph
GGroup = FairyGUI.GGroup
GImage = FairyGUI.GImage
GLoader = FairyGUI.GLoader
GMovieClip = FairyGUI.GMovieClip
TextFormat = FairyGUI.TextFormat
GTextField = FairyGUI.GTextField
GRichTextField = FairyGUI.GRichTextField
GTextInput = FairyGUI.GTextInput
GComponent = FairyGUI.GComponent
GList = FairyGUI.GList
GRoot = FairyGUI.GRoot
GLabel = FairyGUI.GLabel
GButton = FairyGUI.GButton
GComboBox = FairyGUI.GComboBox
GProgressBar = FairyGUI.GProgressBar
GSlider = FairyGUI.GSlider
PopupMenu = FairyGUI.PopupMenu
ScrollPane = FairyGUI.ScrollPane
Transition = FairyGUI.Transition
UIPackage = FairyGUI.UIPackage
Window = FairyGUI.Window
GObjectPool = FairyGUI.GObjectPool
Relations = FairyGUI.Relations
RelationType = FairyGUI.RelationType
UIPanel = FairyGUI.UIPanel
UIPainter = FairyGUI.UIPainter
TypingEffect = FairyGUI.TypingEffect
GTween = FairyGUI.GTween
GTweener = FairyGUI.GTweener
EaseType = FairyGUI.EaseType
fgui = {}
2025-04-01 10:48:36 +08:00
--[[
FairyGUIWindowWindowWindow
OnInitDoHideAnimationDoShowAnimationOnShownOnHide
MyWinClass = fgui.window_class()
function MyWinClass:ctor()
2025-04-15 14:59:43 +08:00
print('MyWinClass-ctor')
2025-04-01 10:48:36 +08:00
self.contentPane = UIPackage.CreateObject("Basics", "WindowA")
end
function MyWinClass:OnShown()
2025-04-15 14:59:43 +08:00
print('MyWinClass-onShown')
2025-04-01 10:48:36 +08:00
end
local win = MyWinClass.New()
win:Show()
]]
function fgui.window_class(base)
local o = {}
local base = base or FairyGUI.Window
setmetatable(o, base)
o.__index = o
o.base = base
o.New = function(...)
local t = {}
setmetatable(t, o)
local ins = FairyGUI.Window.New()
tolua.setpeer(ins, t)
ins:SetLuaPeer(t)
if t.ctor then
2025-04-15 14:59:43 +08:00
t.ctor(ins,...)
2025-04-01 10:48:36 +08:00
end
return ins
end
return o
end
--[[
FairyGUI
MyButton = fgui.extension_class(GButton)
fgui.register_extension("ui://包名/我的按钮", MyButton)
function MyButton:ctor() --当组件构建完成时此方法被调用
2025-04-15 14:59:43 +08:00
print(self:GetChild("n1"))
2025-04-01 10:48:36 +08:00
end
--添加自定义的方法和字段
function MyButton:Test()
2025-04-15 14:59:43 +08:00
print('test')
2025-04-01 10:48:36 +08:00
end
local get = tolua.initget(MyButton)
local set = tolua.initset(MyButton)
get.myProp = function(self)
return self._myProp
end
set.myProp = function(self, value)
self._myProp = value
self:GetChild('n1').text = value
end
local myButton = someComponent:GetChild("myButton") --这个myButton的资源是“我的按钮”
myButton:Test()
myButton.myProp = 'hello'
local myButton2 = UIPackage.CreateObject("包名","我的按钮")
myButton2:Test()
myButton2.myProp = 'world'
]]
function fgui.register_extension(url, extension)
FairyGUI.UIObjectFactory.SetExtension(url, typeof(extension.base), extension.Extend)
end
function fgui.extension_class(base)
local o = {}
o.__index = o
o.base = base or GComponent
o.Extend = function(ins)
local t = {}
setmetatable(t, o)
2025-04-15 14:59:43 +08:00
tolua.setpeer(ins,t)
2025-04-01 10:48:36 +08:00
return t
end
return o
end