Dynamic Windows Tutorial Part 2

From Legends of Aria Admin and Modding Wiki
Revision as of 04:31, 12 March 2019 by Gizmo (talk | contribs) (Created page with "==TestTool.Lua== function ShowTestWindow(user,controlobject) local dynamicWindow = DynamicWindow("DynamicWindowHandler","",300,300,-150,-150,"TransparentDraggable","Cent...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

TestTool.Lua

function ShowTestWindow(user,controlobject)
    local dynamicWindow = DynamicWindow("DynamicWindowHandler","",300,300,-150,-150,"TransparentDraggable","Center")
    dynamicWindow:AddImage(1,1,"Blank",300,300,"Simple","252525")
    DrawCloseButton(271,5,dynamicWindow)
    --test dynamic window code here
    user:OpenDynamicWindow(dynamicWindow,controlobject)
end	
function DrawCloseButton(x,y,dynamicwindow)
    dynamicwindow:AddImage(x,y,"Blank",24,24,"Sliced","AA0000")
    dynamicwindow:AddImage(x+2,y+2,"Blank",20,20,"Sliced","770000")
    dynamicwindow:AddButton(x,y,"CloseButton","",24,24,"[FF7700]Close\n[FFFF00]closes this dynamic window.","",true,"Invisible")
end
RegisterEventHandler(EventType.DynamicWindowResponse,"DynamicWindowHandler",
function (user,buttonId,fieldData)
--add button click checks here
end)
RegisterEventHandler(EventType.Message, "UseObject", 
function(user, usedType) 
    if(usedType=="Open Window") then
        ShowTestWindow(user,this)
    end
    if(usedType=="Refresh Modules") then
        ReloadModule(GetCurrentModule())
    end
    if(usedType=="Test Code") then
        TestCodeFunction()
    end
end)
RegisterEventHandler(EventType.ModuleAttached, GetCurrentModule(), function() 
    AddUseCase(this,"Open Window",true)
    AddUseCase(this,"Refresh Modules",false)
    AddUseCase(this,"Test Code",false)
end)

TestTool.Xml