Difference between revisions of "Dynamic Windows Tutorial Part 2"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
(TestTool.Lua)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
back to [[Project_Phoenix#Video_List]]<br><br>
+
back to [[Project_Phoenix#Video_List|Video Tutorials]]<br><br>
 
==Dynamic Windows Test Tools==
 
==Dynamic Windows Test Tools==
  
 
===Video===
 
===Video===
<youtube></youtube>
+
<youtube>8URdpx7rmhs</youtube>
 +
next video [[Dynamic_Windows_Tutorial_Part_3|Part 3]]
  
===TestTool.Lua===
+
back to [[Project_Phoenix#Dynamic_Windows|Video Tutorials]]<br><br>
*In your favorite lua editor, create a file testtool.lua and put it into your scripts directory
 
*Then copy the lua code below into your file and feel free to format it how you want
 
function ShowTestWindow(user,controlobject)
 
    local dynamicWindow = DynamicWindow("DynamicWindowHandler","",300,300,-150,-150,"TransparentDraggable","Center")
 
    dynamicWindow:AddImage(1,1,"HueSwatch",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
 
        --your test code here
 
    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===
 
*in your favorite xml editor, create a file testtool.xml and put it into your scripts direcotry
 
<ObjectTemplate>
 
    <Name>Test Window</Name>
 
    <ClientId>2</ClientId>
 
    <SharedStateEntry name="Weight" type="int" value="1"/>
 
    <ScriptEngineComponent>
 
        <LuaModule Name="testtool"/>
 
    </ScriptEngineComponent>
 
</ObjectTemplate>
 
back to [[Project_Phoenix#Video_List]]<br><br>
 

Latest revision as of 14:53, 12 April 2019

back to Video Tutorials

Dynamic Windows Test Tools

Video

next video Part 3

back to Video Tutorials