anyone have any pointers for dealing with nested windows? basicly what I am trying to do is get a window to create a new copy of itself then be able to share information with the child. I tried creating a holding place in the class but the parents data doesnt seam to update with the childs...
so:
window1 creates window2
window2 creates window3
change information in window3
window3 updates information for window2
then window2 updates window1
I have most of it togeather and figured out but I cant get them to recursivly update...
here is my window sorry it is a little long, figured all information is better then not enough:
Code:
import "SandBox.Crafters"
AddItemWindow = class( Turbine.UI.Window )
function AddItemWindow:Constructor()
Turbine.UI.Lotro.Window.Constructor( self )
self:SetText("Add item to recipe")
self:SetPosition( 530, 150 )
self:SetSize(300, 300)
self:SetVisible(false)
self.uppernode = nil
namelabel = Turbine.UI.Label()
namelabel:SetText("Subcombine Name: ")
namelabel:SetPosition(25, 45)
namelabel:SetSize(115, 20)
namelabel:SetParent(self)
namelabel:SetForeColor(Turbine.UI.Color( 1, .8, .6 ))
self.namebox = Turbine.UI.Lotro.TextBox()
self.namebox:SetSize(120, 20 )
self.namebox:SetPosition(140, 40)
self.namebox:SetParent(self)
self.namebox:SetText("New Item")
self.namebox:SetFont( Turbine.UI.Lotro.Font.Verdana12 )
inglabel = Turbine.UI.Label()
inglabel:SetText("Ingredients:")
inglabel:SetSize(115, 20)
inglabel:SetPosition(25, 60)
inglabel:SetParent(self)
inglabel:SetForeColor(Turbine.UI.Color( 1, .8, .6 ))
ingtreeview = Turbine.UI.TreeView()
ingtreeview:SetParent(self)
ingtreeview:SetSize(250, 100)
ingtreeview:SetPosition(25, 150)
ingtreeview:SetIndentationWidth( 15 )
ingtreeview:SetBackColor( Turbine.UI.Color(.1,.1,.1))
treescroll = Turbine.UI.Lotro.ScrollBar()
treescroll:SetOrientation( Turbine.UI.Orientation.Vertical )
treescroll:SetParent( self )
treescroll:SetPosition( 275, 150 )
treescroll:SetSize( 10, 120 )
ingtreeview:SetVerticalScrollBar(treescroll)
self.nodes = ingtreeview:GetNodes()
addrecbut = Turbine.UI.Lotro.Button()
addrecbut:SetParent(self)
addrecbut:SetSize(125, 20)
addrecbut:SetPosition(25, 80)
addrecbut:SetText("Add Recipe")
addrecbut.Click = function(sender, args)
Turbine.Shell.WriteLine("Clicked Add Recipe Button")
self:spawnrec(self.nodes)
end
clrbut = Turbine.UI.Lotro.Button()
clrbut:SetPosition(155, 250)
clrbut:SetSize(120, 20)
clrbut:SetParent(self)
clrbut:SetText("Cancel")
clrbut.Click = function(Sender, args)
Turbine.Shell.WriteLine("Clicked Cancel Button")
self:Clear()
end
self.ingtext = Turbine.UI.Lotro.TextBox()
self.ingtext:SetParent(self)
self.ingtext:SetSize(150, 20)
self.ingtext:SetPosition(25,100)
self.ingtext:SetFont( Turbine.UI.Lotro.Font.Verdana12 )
self.ingtext:SetText("Ingredient")
self.ingqty = Turbine.UI.Lotro.TextBox()
self.ingqty:SetParent(self)
self.ingqty:SetSize(50, 20)
self.ingqty:SetPosition(175,100)
self.ingqty:SetFont( Turbine.UI.Lotro.Font.Verdana12 )
self.ingqty:SetText("Qty")
additembut = Turbine.UI.Lotro.Button()
additembut:SetParent(self)
additembut:SetSize( 50, 20 )
additembut:SetPosition(225,100)
additembut:SetText("Add")
additembut.Click = function(sender, args)
Turbine.Shell.WriteLine("Clicked Add Item Button")
self:spawnitem()
self.ingtext:SetText("Ingredient")
self.ingqty:SetText("Qty")
end
treeheadering = Turbine.UI.Label()
treeheadering:SetParent(self)
treeheadering:SetSize(220,20)
treeheadering:SetPosition(25, 130)
treeheadering:SetFont( Turbine.UI.Lotro.Font.Verdana12 )
treeheadering:SetForeColor(Turbine.UI.Color( 1, .8, .6 ))
treeheadering:SetBackColor( Turbine.UI.Color(.1,.1,.1))
treeheadering:SetText("Ingredient")
treeheaderqty = Turbine.UI.Label()
treeheaderqty:SetParent(self)
treeheaderqty:SetSize(25,20)
treeheaderqty:SetPosition(250,130)
treeheaderqty:SetFont( Turbine.UI.Lotro.Font.Verdana12 )
treeheaderqty:SetForeColor(Turbine.UI.Color( 1, .8, .6 ))
treeheaderqty:SetBackColor( Turbine.UI.Color(.1,.1,.1))
treeheaderqty:SetText("Qty")
self.okbutton = Turbine.UI.Lotro.Button()
self.okbutton:SetParent(self)
self.okbutton:SetSize(125,20)
self.okbutton:SetPosition(25,250)
self.okbutton:SetText("Okay")
end
--I creates new window and populates the container for parent data
function AddItemWindow:spawnrec()
Turbine.Shell.WriteLine("Spawning new add window")
nestwin = AddItemWindow()
nestwin:SetVisible(true)
nestwin.uppernode = self.nodes
ox,oy = self:GetPosition()
nx = ox + 15
ny = oy + 15
nestwin:SetPosition(nx,ny)
Turbine.Shell.WriteLine(type(nestwin.uppernode))
nestwin.okbutton.Click = function(sender, args)
Turbine.Shell.WriteLine("AddItemWindow.okbutton.Click: Clicked ok button")
self.nodes:Add(nestwin:elevate())
nestwin:Clear()
end
end
--I packages inputed data into node and displays in current window
function AddItemWindow:spawnitem()
ingredant = self.ingtext:GetText()
quantity = self.ingqty:GetText()
node = Turbine.UI.TreeNode()
node:SetSize(250,20)
list = Turbine.UI.ListBox()
list:SetSize(200, 20)
list:SetParent(node)
list:SetOrientation( Turbine.UI.Orientation.Horizontal )
inglabel = Turbine.UI.Label()
inglabel:SetSize(100, 20)
inglabel:SetText(ingredant)
list:AddItem(inglabel)
qtylabel = Turbine.UI.Label()
qtylabel:SetSize(50, 20)
qtylabel:SetText(quantity)
list:AddItem(qtylabel)
self.nodes:Add(node)
end
--I Packages data into tree node for parent window
function AddItemWindow:elevate()
tempnode = Turbine.UI.TreeNode()
tempname = Turbine.UI.Label()
tempname:SetParent(tempnode)
tempname:SetText(self.ingtext:GetText())
tempqty = Turbine.UI.Label()
tempqty:SetParent(tempnode)
tempqty:SetPosition(0,100)
tempqty:SetText(self.ingqty:GetText())
tempnodes = tempnode:GetChildNodes()
tempnodes:Add(self.nodes)
return tempnodes
end
--I Clears and hides window
function AddItemWindow:Clear()
Turbine.Shell.WriteLine("AddItemWindow.Clear: Clearing Add Item Window" )
self.nodes = nil
self:SetVisible(false)
end
idealy the window/window functions should be self contained in order to have a near unlimited number of steps.
I also havent built in any error control and still needs some clean up but just wanted to get the idea working first.
at first I figured the tree nodes were not updating correctly so that is when I rebuilt the "spawnrec" and "elevate" functions to interact with the child directly...
any pointers would be awesome, I am not a very good programmer but I am persistant and good and finding work arounds but this one has me stumped...