Quantcast Saving window position - LoTROInterface
lotrointerface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
 
Thread Tools Display Modes
  #1  
Unread 09-26-2010, 08:45 AM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
Saving window position

I am trying to figure out how to save window position so that it is persistent through a reload.

I think that I should have it write its coordinates to a save file when it is being dragged and the mouse button is released, but I can not for the life of me figure out how to write that code.

Any help is greatly appreciated.
Reply With Quote
  #2  
Unread 09-26-2010, 10:14 AM
Wicked Mouse's Avatar
Wicked Mouse Wicked Mouse is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2008
Location: The Netherlands
Posts: 183
Isn't that what the "layout system" has brought into action for?

http://lorebook.lotro.com/wiki/Relea...ook_8_Official
# The client now has a /ui command that can be used to save the current layout of windows to an xml file and then load this layout.
# To save a ui layout type: /ui layout save <name>
# To load a previously saved layout: /ui layout load <name>
# In both cases the name is optional and if not specified it will just save to a file called Default_ appended with your current game window resolution. (e.q running in 800 x 600 results inDefault_800_600.layout)

Or were you talking about something else?
__________________
Author of: "Delving Hills"
Reply With Quote
  #3  
Unread 09-26-2010, 10:33 AM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
(Bear with me, still learning Lua)

When you press "Ctrl + \" it doesn't give a handle to set the Lua window position. I tried writing a function that basically says if the window changes position to save the coordinates to a file and when the window is recalled to load those coordinates .

I just haven't been successful as of yet.
Reply With Quote
  #4  
Unread 09-26-2010, 10:52 AM
MrJackdaw's Avatar
MrJackdaw MrJackdaw is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2009
Location: Lancaster, England
Posts: 249
Assuming the window is called "Window" and the place you want to store the data is a table called "Data";

Code:
Window.PositionChanged=function(sender,args)
	Data.x,Data.y=Window:GetPosition()
end
Will store the window position to the Data table whenever the window is moved.

Then, when you load the data - just use the Data.x and Data.y to load in the position.

Assumption: You are saving the data at some point with;

Code:
Turbine.PluginData.Save( Turbine.DataScope.Character, "The Name of Your Plugin", Data );
And loading it with;

Code:
Data=Turbine.PluginData.Load( Turbine.DataScope.Character, "The Name of Your Plugin")
or similar!
__________________
************************************************** ************************************************** **
"Our ideals may never be realised, But they indicate what we are trying to do." Dick Tahta
Reply With Quote
  #5  
Unread 09-26-2010, 12:37 PM
Olenn's Avatar
Olenn Olenn is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 47
Thanks, but I am still a little lost. What I have been trying to add is a code that looks to see if the data file exists and if it does use that position. If it doesn't then it uses a default set of values. I am still not sure where all of this goes.

I tried to start simple...this is what I have been trying (without the checking to see if the file exists or not)

Code:
SatchelWindow = class( Turbine.UI.Window );
Data = Turbine.PluginData.Load( Turbine.DataScope.Character, "SatchelData")

function SatchelWindow:Constructor()
----CREATE THE WINDOW----
	Turbine.UI.Lotro.Window.Constructor( self );
	self:SetText("Satchel");
	self:SetSize( 325, 275 );
	self:SetPosition( Data.x , Data.y );
----SAVE WINDOW POSITION----
	Window.PositionChanged=function(sender,args)
		Data.x,Data.y=Window:GetPosition()
	end
That is as far as I have (unsuccessfully) gotten. Does the file save on logoff or does it save when the code runs?


I guess its off to borders to find an Lua book...

Last edited by Olenn : 09-26-2010 at 12:39 PM.
Reply With Quote
  #6  
Unread 09-26-2010, 01:01 PM
MrJackdaw's Avatar
MrJackdaw MrJackdaw is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2009
Location: Lancaster, England
Posts: 249
Thinking on my feet but change the "Window" lines to "self" as "self" is the window. And don't waste money in Borders - I worked my way through the Turbine sample stuff stealing where I could, especially the combat bar on. Just as with learing the xml modification stuff, look at other peoples work and rip it apart... *grin* The excellent lessons on http://www.lua.org/pil/ helped me get a bit better!

I still wouldn't call myself any good - but the stuff works well enough for me!
__________________
************************************************** ************************************************** **
"Our ideals may never be realised, But they indicate what we are trying to do." Dick Tahta
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Plugins Not Saving Settings Valdacil Interface Help (L) 13 09-10-2010 10:43 PM
Help me to position my xp bar please or to hide it Eili Interface Help (L) 6 06-29-2010 05:36 PM
position toolbar problems Bazzard XML modification help (L) 7 07-11-2007 02:08 AM
Saving UI Layout... Sythix Interface Help (L) 1 07-05-2007 11:15 PM
chat window not saving position... AstroCat Interface Help (L) 1 07-01-2007 11:12 AM


All times are GMT -5. The time now is 04:30 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui