LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Saving window position (https://www.lotrointerface.com/forums/showthread.php?t=1089)

Olenn 09-26-2010 06:58 PM

Wow, thanks. The only thing left is where to put;

Code:

Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", Data );
I know it goes in here somewhere;

Code:

        self.PositionChanged=function(sender,args)
                Data.x,Data.y=self:GetPosition()
        end

..and thanks for the help everyone, its much appreciated.

Digital_Utopia 09-26-2010 07:12 PM

I'm going to help you cheat a bit here - but only because the original code that this was based off of was given to me by Pengoros

put this in your Main.lua script:

Code:

pluginName="myPluginsName";
window = Turbine.UI.Window();
window:SetWantsUpdates(true);
window.Update = function(sender,args)
        if (Plugins[pluginName] ~= nil) then
                Plugins[pluginName].Unload = function(self,sender,args)
                        UnloadPlugin();
                end
                window:SetWantsUpdates(false);
        end
end

This will call a function called "UnloadPlugin()" when the plugin is being unloaded. This function would be a great place to put that PluginData.Save() line.

Olenn 09-26-2010 09:20 PM

Thanks for all of the help. I did what you said and its not giving me an error but it isn't working either.

The end goal is that you could drag the window where ever you want it and when you start the game back up later it remembers its position. I really thought this would be as easy an writing to a file when you stopped dragging the window, but its definitely been an all day project trying to get this to work.

I believe that my problem now is simply getting the plugin to save the lwindows location data. Everything else seems to be working fine.

Here is the main.lua I have thus far.

Code:

import "Turbine.UI";
import "Turbine.UI.Lotro";
import "Turbine.Debug";

import "Olenn.Satchel";

satchelWindow = Olenn.Satchel.SatchelWindow();
satchelWindow:SetVisible( true );

settingsWindow = Olenn.Satchel.SettingsWindow();
settingsWindow:SetVisible( true );

Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack1, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack2, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack3, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack4, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack5, false );

satchelCommand = Turbine.ShellCommand();

function satchelCommand:Execute(cmd, args)
        if ( args == "show" ) then
                SatchelWindow:SetVisible( true );
        elseif ( args == "hide" ) then
                SatchelWindow:SetVisible( false );
        elseif ( args == "toggle" ) then
                SatchelWindow:SetVisible( not SatchelWindow:IsVisible() );
        elseif ( args ~= nil ) then
                satchelCommand:GetHelp();
        end
       
        pluginName="Satchel";
        window = Turbine.UI.Window();
        window:SetWantsUpdates(true);
        window.Update = function(sender,args)
        if (Plugins[pluginName] ~= nil) then
                Plugins[pluginName].Unload = function(self,sender,args)
                        UnloadPlugin();
                        Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", Data );
                end
                window:SetWantsUpdates(false);
        end
end
end


function satchelCommand:GetHelp()
        Turbine.Shell.WriteLine( "------------Satchel Commands------------");
        Turbine.Shell.WriteLine( "/satchel show: Display Satchel Window");
        Turbine.Shell.WriteLine( "/satchel hide: Hide Satchel Window");
        Turbine.Shell.WriteLine( "/satchel toggle: Toggle Satchel Window");
end

Turbine.Shell.AddCommand( "satchel", satchelCommand );


Kragenwar 09-27-2010 06:52 AM

I don't know if you did as Digitial Utopia suggested and declared Data in your satchel class as self.Data (since you only posted your main and didnt repost your Satchel class). But if you did, then when saving your data variable from your main you may need to go
Code:

Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", SatchelWindow.Data );
Alternatively you could also put the save line in the code where you write the position to data

Code:

----SAVE WINDOW POSITION----
        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
        end

I haven't played with the unload code Digital Utopia posted, but I am going to take a guess that maybe your call to save needs to come before UnloadPlugin(); Just a guess tho
Code:

Plugins[pluginName].Unload = function(self,sender,args)
      Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", SatchelWindow.Data );                       
      UnloadPlugin();
end

Also I noticed in your class code you posted earlier you also allow changing of size, which means you might want to save the size as well.

Olenn 09-27-2010 11:17 AM

1 Attachment(s)
You guys are awesome, but I think I am starting to get all of your advice mixed up. I am going to post both Lua scripts and see what you think. I am getting an error;

attempt to index Data a nil value

main.lua

Code:



import "Turbine.UI";
import "Turbine.UI.Lotro";
import "Turbine.Debug";

import "Olenn.Satchel";

satchelWindow = Olenn.Satchel.SatchelWindow();
satchelWindow:SetVisible( true );

settingsWindow = Olenn.Satchel.SettingsWindow();
settingsWindow:SetVisible( false );

Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack1, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack2, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack3, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack4, false );
Turbine.UI.Lotro.LotroUI.SetEnabled( Turbine.UI.Lotro.LotroUIElement.Backpack5, false );

satchelCommand = Turbine.ShellCommand();

function satchelCommand:Execute(cmd, args)
        if ( args == "show" ) then
                SatchelWindow:SetVisible( true );
        elseif ( args == "hide" ) then
                SatchelWindow:SetVisible( false );
        elseif ( args == "toggle" ) then
                SatchelWindow:SetVisible( not SatchelWindow:IsVisible() );
        elseif ( args ~= nil ) then
                satchelCommand:GetHelp();
        end
       
        pluginName="Satchel";
        window = Turbine.UI.Window();
        window:SetWantsUpdates(true);
        window.Update = function(sender,args)
        if (Plugins[pluginName] ~= nil) then
                Plugins[pluginName].Unload = function(self,sender,args)
                        UnloadPlugin();
                        Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", Data );
                end
                window:SetWantsUpdates(false);
        end
end
end




function satchelCommand:GetHelp()
        Turbine.Shell.WriteLine( "------------Satchel Commands------------");
        Turbine.Shell.WriteLine( "/satchel show: Display Satchel Window");
        Turbine.Shell.WriteLine( "/satchel hide: Hide Satchel Window");
        Turbine.Shell.WriteLine( "/satchel toggle: Toggle Satchel Window");
end

Turbine.Shell.AddCommand( "satchel", satchelCommand );

SatchelWindow.lua

Code:


import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"

SatchelWindow = class( Turbine.UI.Window );

function SatchelWindow:Constructor()
----CREATE THE WINDOW----
        Turbine.UI.Lotro.Window.Constructor( self );
        self:SetText("Satchel");
        self:SetSize( 325, 300 );
----LOAD PRIOR POSITION----
        self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character,  "SatchelData")
    if (self.Data==nil)then
                self:SetPosition(100 , 100);
    else
                self:SetPosition(self.Data.x,self.Data.y)
    end
----SAVE CURENT POSITION WHEN MOVED---
        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
        end
----SATCHEL CLOSES WHEN ESC IS PRESSED----
        self:SetWantsKeyEvents( true );
        self.KeyDown = function( sender, args )
                if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
                        sender:SetVisible( false )
                end
               
----MAKE BAG BUTTONS ON THE TOOLBAR OPEN SATCHEL----
                if ( args.Action == Turbine.UI.Lotro.Action.ToggleBags or
                    args.Action == Turbine.UI.Lotro.Action.ToggleBag1 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag2 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag3 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag4 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag5 )
                then
                        sender:SetVisible( not sender:IsVisible() )
                end
        end
       
        local satchel = self;
        local mainWindow = self;
       
        self.itemListBoxScrollBar = Turbine.UI.Lotro.ScrollBar();
        self.itemListBoxScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
        self.itemListBoxScrollBar:SetParent( self );

        self.itemListBox = Turbine.UI.ListBox();
        self.itemListBox:SetParent( self );
        self.itemListBox:SetOrientation( Turbine.UI.Orientation.Horizontal );
        self.itemListBox:SetVerticalScrollBar( self.itemListBoxScrollBar );
        self.itemListBox:SetAllowDrop( true );
       
        self.itemListBox.DragDrop = function( sender, args )
                local shortcut = args.DragDropInfo:GetShortcut();
                if ( shortcut ~= nil ) then
                  local destinationItemControl = self.itemListBox:GetItemAt( args.X, args.Y );
                  local destinationIndex = self.itemListBox:IndexOfItem( destinationItemControl );
                  self.backpack:PerformShortcutDrop( shortcut, destinationIndex, Turbine.UI.Control.IsShiftKeyDown() );
                end
        end
----MAKE WINDOW RESIZABLE----
        self.resizeHandle = Turbine.UI.Control();
        self.resizeHandle:SetParent( self );
        self.resizeHandle:SetZOrder( 100 );
        self.resizeHandle:SetSize( 20, 20 );
        self.resizeHandle:SetPosition( self:GetWidth() - self.resizeHandle:GetWidth(), self:GetHeight() - self.resizeHandle:GetHeight() );

        self.resizeHandle.MouseDown = function( sender, args )
                sender.dragStartX = args.X;
                sender.dragStartY = args.Y;
                sender.dragging = true;
        end

        self.resizeHandle.MouseMove = function( sender, args )
                local width, height = mainWindow:GetSize();

                if ( sender.dragging ) then
                        mainWindow:SetSize( width + ( args.X - sender.dragStartX ), height + ( args.Y - sender.dragStartY ) );
                        sender:SetPosition( mainWindow:GetWidth() - sender:GetWidth(), mainWindow:GetHeight() - sender:GetHeight() )
                        satchel:PerformLayout()
                end
        end

        self.resizeHandle.MouseUp = function( sender, args )
                sender.dragging = false;
        end
----CREATE CONAINER FOR ITEMS----
        self.items = { };

        local player = Turbine.Gameplay.LocalPlayer();
        self.backpack = player:GetBackpack();

        self.backpack.SizeChanged = function( sender, args )
                satchel:Refresh();
        end

        self.backpack.ItemAdded = function( sender, args )
                satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
        end

        self.backpack.ItemRemoved = function( sender, args )
                satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
        end

        self.backpack.ItemMoved = function( sender, args )
                satchel.items[args.OldIndex]:SetItem( satchel.backpack:GetItem( args.OldIndex ) );
                satchel.items[args.NewIndex]:SetItem( satchel.backpack:GetItem( args.NewIndex ) );
        end

        self:Refresh();
       
----CREATE SETTINGS BUTTON----
        self.settingsButton = Turbine.UI.Lotro.Button();
        self.settingsButton:SetParent( self );

        self.settingsButton:SetSize(70,30);
        self.settingsButton:SetPosition(34, 37);
        self.settingsButton:SetFont(Turbine.UI.Lotro.Font.Verdana14);
        self.settingsButton:SetText("Settings");       
        self.settingsButton.Click = function(sender, args)
                settingsWindow:SetVisible( not SettingsWindow:IsVisible() );
        end
       
end

----FUNCTION TO REFRESH BAG CONTENTS----
function SatchelWindow:Refresh()
        local backpackSize = self.backpack:GetSize();

        for i = 1, backpackSize, 1 do
                if ( self.items[i] ) then
                        self.items[i]:SetParent( nil );
                end
               
                self.items[i] = Turbine.UI.Lotro.ItemControl( self.backpack:GetItem( i ) );
                self.itemListBox:AddItem( self.items[i] );
        end

        self:PerformLayout();
end

function SatchelWindow:PerformLayout()
        self:Layout( { } )
end

function SatchelWindow:Layout( args )
        local width, height = self:GetSize();
       
        local itemWidth = 40;
       
        if ( self.items[1] ~= nil ) then
                itemWidth = self.items[1]:GetWidth()
        end

        local listWidth = width - 40;
        local listHeight = height - 75;
        local itemsPerRow = listWidth / itemWidth;

        self.itemListBox:SetPosition( 15, 60 );
        self.itemListBox:SetSize( listWidth, listHeight );
        self.itemListBox:SetMaxItemsPerLine( itemsPerRow );
       
        self.itemListBoxScrollBar:SetPosition( width - 25, 55 );
        self.itemListBoxScrollBar:SetSize( 10, listHeight );

end

Thanks for all of you help guys!

I have attached the plugin in its current state for Lua help only, it is not advised for use by the common user.

Kragenwar 09-27-2010 01:02 PM

Quote:

Originally Posted by Olenn (Post 4920)
You guys are awesome, but I think I am starting to get all of your advice mixed up. I am going to post both Lua scripts and see what you think. I am getting an error;

attempt to index Data a nil value

I see 2 potential problems, did the error mention what line was causing the issue? Off the top of my head the issue could be:

Here:
Code:

if (Plugins[pluginName] ~= nil) then
                Plugins[pluginName].Unload = function(self,sender,args)
                        UnloadPlugin();
                        Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", Data );
                end
                window:SetWantsUpdates(false);
        end

When referencing your Data variable from outside of the class you shoud be doing so via SatchelWindow.Data
Code:

Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", SatchelWindow.Data );


or the issue could possibly be here:
Code:

----SAVE CURENT POSITION WHEN MOVED---
        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );

You haven't declared data as a table. Not sure if that would make a difference or not (I am fairly new to lua). But you could try:

Code:

----LOAD PRIOR POSITION----
        self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character,  "SatchelData")
    if (self.Data==nil)then
                self.Data = { };
                self.Data.x = 100;
                self.Data.y = 100;
                self:SetPosition(100 , 100);

    else
                self:SetPosition(self.Data.x,self.Data.y)
    end

Like I said, im fairly new to LUA so there may be a better place to declare Data as a table. But I am guessing the issue is because when first load it self.Data never gets declared as a table, so you get an error when you try to write to self.Data.x and self.Data.y.

Olenn 09-27-2010 01:22 PM

AWESOME!

That gives me tons to work with. It is now saving the position to the file, but when I click reload it still resets it to 100 x 100.

But at least I have something to work for.

Much appreciated everyone!

Kragenwar 09-27-2010 01:35 PM

Quote:

Originally Posted by Olenn (Post 4925)
AWESOME!

That gives me tons to work with. It is now saving the position to the file, but when I click reload it still resets it to 100 x 100.

But at least I have something to work for.

Much appreciated everyone!

Thats fantastic. I have a feeling PositionChanged is not firing. You could try getting rid of
Code:

----SAVE CURENT POSITION WHEN MOVED---
        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
        end

and then do this in your MouseUp Handler instead
Code:

self.resizeHandle.MouseUp = function( sender, args )
              if (sender.dragging) then
                    self.Data.x,self.Data.y=self:GetPosition();
              end       
              sender.dragging = false;
        end

That way you will be writing the new position to Data whenever the user releases the mouse after dragging, and saving the position to the settings file on unload.

Olenn 09-27-2010 02:13 PM

I tried to put that in place of

Code:


        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
        end

but I keep getting this error;

...Rings Online\Plugins\Olenn\Satchel\SatchelWindow.lua:33: attempt to index field 'resizeHandle' (a nil value)

the odd part is that line 33 is just "end"

Kragenwar 09-27-2010 02:45 PM

Quote:

Originally Posted by Olenn (Post 4928)
I tried to put that in place of

Code:


        self.PositionChanged=function(sender,args)
                self.Data.x,self.Data.y=self:GetPosition()
                Turbine.PluginData.Save( Turbine.DataScope.Character, "Satchel", self.Data );
        end

but I keep getting this error;

...Rings Online\Plugins\Olenn\Satchel\SatchelWindow.lua:33: attempt to index field 'resizeHandle' (a nil value)

the odd part is that line 33 is just "end"

Yeah you shouldn't be replacing the self.PositionChanged part with the self.resizeHandle.MouseUp function. All you need to do is completlely remove the self.PositionChanged function. Then change your already existing self.resizeHandle.MouseUp by adding the line to set Data.x and Data.y. Here is the whole class with the change.

Code:

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "Olenn.Satchel"

SatchelWindow = class( Turbine.UI.Window );

function SatchelWindow:Constructor()
----CREATE THE WINDOW----
        Turbine.UI.Lotro.Window.Constructor( self );
        self:SetText("Satchel");
        self:SetSize( 325, 300 );
----LOAD PRIOR POSITION----
        self.Data = Turbine.PluginData.Load( Turbine.DataScope.Character,  "SatchelData")
    if (self.Data==nil)then
                self.Data = { };
                self.Data.x = 100;
                self.Data.y = 100;
                self:SetPosition(100 , 100);
    else
                self:SetPosition(self.Data.x,self.Data.y)
    end

----SATCHEL CLOSES WHEN ESC IS PRESSED----
        self:SetWantsKeyEvents( true );
        self.KeyDown = function( sender, args )
                if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
                        sender:SetVisible( false )
                end
               
----MAKE BAG BUTTONS ON THE TOOLBAR OPEN SATCHEL----
                if ( args.Action == Turbine.UI.Lotro.Action.ToggleBags or
                    args.Action == Turbine.UI.Lotro.Action.ToggleBag1 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag2 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag3 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag4 or
                        args.Action == Turbine.UI.Lotro.Action.ToggleBag5 )
                then
                        sender:SetVisible( not sender:IsVisible() )
                end
        end
       
        local satchel = self;
        local mainWindow = self;
       
        self.itemListBoxScrollBar = Turbine.UI.Lotro.ScrollBar();
        self.itemListBoxScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
        self.itemListBoxScrollBar:SetParent( self );

        self.itemListBox = Turbine.UI.ListBox();
        self.itemListBox:SetParent( self );
        self.itemListBox:SetOrientation( Turbine.UI.Orientation.Horizontal );
        self.itemListBox:SetVerticalScrollBar( self.itemListBoxScrollBar );
        self.itemListBox:SetAllowDrop( true );
       
        self.itemListBox.DragDrop = function( sender, args )
                local shortcut = args.DragDropInfo:GetShortcut();
                if ( shortcut ~= nil ) then
                  local destinationItemControl = self.itemListBox:GetItemAt( args.X, args.Y );
                  local destinationIndex = self.itemListBox:IndexOfItem( destinationItemControl );
                  self.backpack:PerformShortcutDrop( shortcut, destinationIndex, Turbine.UI.Control.IsShiftKeyDown() );
                end
        end
----MAKE WINDOW RESIZABLE----
        self.resizeHandle = Turbine.UI.Control();
        self.resizeHandle:SetParent( self );
        self.resizeHandle:SetZOrder( 100 );
        self.resizeHandle:SetSize( 20, 20 );
        self.resizeHandle:SetPosition( self:GetWidth() - self.resizeHandle:GetWidth(), self:GetHeight() - self.resizeHandle:GetHeight() );

        self.resizeHandle.MouseDown = function( sender, args )
                sender.dragStartX = args.X;
                sender.dragStartY = args.Y;
                sender.dragging = true;
        end

        self.resizeHandle.MouseMove = function( sender, args )
                local width, height = mainWindow:GetSize();

                if ( sender.dragging ) then
                        mainWindow:SetSize( width + ( args.X - sender.dragStartX ), height + ( args.Y - sender.dragStartY ) );
                        sender:SetPosition( mainWindow:GetWidth() - sender:GetWidth(), mainWindow:GetHeight() - sender:GetHeight() )
                        satchel:PerformLayout()
                end
        end

        self.resizeHandle.MouseUp = function( sender, args )
                if (sender.dragging) then
                        self.Data.x, self.Data.y = self:GetPosition();
                end
                sender.dragging = false;
        end
----CREATE CONAINER FOR ITEMS----
        self.items = { };

        local player = Turbine.Gameplay.LocalPlayer();
        self.backpack = player:GetBackpack();

        self.backpack.SizeChanged = function( sender, args )
                satchel:Refresh();
        end

        self.backpack.ItemAdded = function( sender, args )
                satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
        end

        self.backpack.ItemRemoved = function( sender, args )
                satchel.items[args.Index]:SetItem( satchel.backpack:GetItem( args.Index ) );
        end

        self.backpack.ItemMoved = function( sender, args )
                satchel.items[args.OldIndex]:SetItem( satchel.backpack:GetItem( args.OldIndex ) );
                satchel.items[args.NewIndex]:SetItem( satchel.backpack:GetItem( args.NewIndex ) );
        end

        self:Refresh();
       
----CREATE SETTINGS BUTTON----
        self.settingsButton = Turbine.UI.Lotro.Button();
        self.settingsButton:SetParent( self );

        self.settingsButton:SetSize(70,30);
        self.settingsButton:SetPosition(34, 37);
        self.settingsButton:SetFont(Turbine.UI.Lotro.Font.Verdana14);
        self.settingsButton:SetText("Settings");       
        self.settingsButton.Click = function(sender, args)
                settingsWindow:SetVisible( not SettingsWindow:IsVisible() );
        end
       
end

----FUNCTION TO REFRESH BAG CONTENTS----
function SatchelWindow:Refresh()
        local backpackSize = self.backpack:GetSize();

        for i = 1, backpackSize, 1 do
                if ( self.items[i] ) then
                        self.items[i]:SetParent( nil );
                end
               
                self.items[i] = Turbine.UI.Lotro.ItemControl( self.backpack:GetItem( i ) );
                self.itemListBox:AddItem( self.items[i] );
        end

        self:PerformLayout();
end

function SatchelWindow:PerformLayout()
        self:Layout( { } )
end

function SatchelWindow:Layout( args )
        local width, height = self:GetSize();
       
        local itemWidth = 40;
       
        if ( self.items[1] ~= nil ) then
                itemWidth = self.items[1]:GetWidth()
        end

        local listWidth = width - 40;
        local listHeight = height - 75;
        local itemsPerRow = listWidth / itemWidth;

        self.itemListBox:SetPosition( 15, 60 );
        self.itemListBox:SetSize( listWidth, listHeight );
        self.itemListBox:SetMaxItemsPerLine( itemsPerRow );
       
        self.itemListBoxScrollBar:SetPosition( width - 25, 55 );
        self.itemListBoxScrollBar:SetSize( 10, listHeight );

end

This should work unless I'm totally misunderstanding your code or what you are trying to do with it.


All times are GMT -5. The time now is 10:15 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI