EQ2Interface.com
Search Downloads


Go Back   EQ2Interface > Developer Discussion > XML Modification Help & Info

Reply
Thread Tools Search this Thread Display Modes
  #1  
Unread 01-30-2006, 09:41 PM
maddbomber83's Avatar
maddbomber83 maddbomber83 is offline
A Fallen Diplomat
Interface Author - Click to view interfaces
 
Join Date: Dec 2004
Server: Oggok
Posts: 52
Default Saving Settings

I have made a mod to the Bag Window. I followed the stay put instructions (for having bag save location) and it works! The only problem is due to the way my bag is designed it immediatly breaks in game.

http://www.eq2interface.com/download...fo.php?id=4171

I am looking for ideas on how to fix this. When my bag gets posted by the mod you can see exactly what I am talking about, so let me explain the basics on how my bag works. I am using a lot of new things I havn't seen "done" before but have been explained in these forums.

Inside the bag there is a Data File that stores variables that I allow the user to modify in game. Then the bag will change its shape and size based off the variables the user sets. The Variables are. . .

Area.Base (Used to Calculate page.y)
Cell.Num (Set by how many cells are visible)
CellSize (Set by user, defualt is 40)
Colums (Set by user, default is 4)

condition (used in if statments)
page.x (Size of Window)
page.y (Size of Window
pixels.y (used to calculate page.y)
rows.base (used to calculate page.y)
rows.round (used to calculate page.y)


Now there are two sets of cells, the ones you see and the dummy array (using a volume page). What basicaly happens is when the user changes the size of a cell, or the number of colums, they are actualy changing the volume pages info.
Then I calculate the new size of the window (based off how many colums, how many cells, and how big each cell is) and resize the whole bag window accordingly (including the volume page). Once resized, the volume page will automaticaly reposition all the dummy cells to fit perfectly. I then set the size/location of all the real cells to the dummy cells. The result, the user can change the size/shape of bags in game.

So that is the basics behind the mechanics of my mod. It works great in game.

The problem is when you exit the game, the UI will (because of the stay put code) save the location and size of the bag. When you log back in the bag will be in the location and the same size as you left it.
However, the cells default back to 40x40 and the colums are back to 4. As soon as you make any adjustments it pops the way it should be (based off defaults) but not the way you set it up last.

If I could do math with the size it would be great, but because its in the (100,50) format I can't. I havn't figured out how to seperate the , from the equation. So I am stuck with the file.

The only thing I can think of to do, is to make a seperate file that the user can modify. This would be my data file. Use the Include to put it in my code. This way the user could set the defualt size and colum number out of game, and it will load that in game (where they can edit it further). However that kinda defeats the purpose of in game modifable bags (although it does give the end user much more flexibility than the current multi format bags).

The basics of my problem are above and I hope to get some good ideas. Below I am going to make a post with some code babble about how I used math and conditional operators and such so that in the future people who are looking to do stuff like this can see what I did. (because thats how I learned to do any of this, looking at other's work and posts).
__________________

Last edited by maddbomber83 : 01-31-2006 at 10:35 AM.
Reply With Quote
  #2  
Unread 01-30-2006, 10:19 PM
maddbomber83's Avatar
maddbomber83 maddbomber83 is offline
A Fallen Diplomat
Interface Author - Click to view interfaces
 
Join Date: Dec 2004
Server: Oggok
Posts: 52
Default

I will ommit all the parent.parent.parents to get to right level. for this example.

First off, All Variables are stored in the data file. The user clicks on buttons in game that will increase or decrease either the Cell Size or the Number of Colums. Each Cell has an OnShow property that tells the Data File its number when shown.
We will use a 3 slot bag as an example (due to its odd number).

So when the game loads up we know 3 things.
CellSize (User Sets) default = 40
Colums (User Sets) default = 4
CellNum (Game Tells Us) default = 4

User says he wants 2 Colums, Cell size 40.

Our goal is to set the Windows X and Y to a value that fits these 3 cells. The arrangment will be handled by the volume page so we do not need to worry about location.

The X value is easy to figure out.
Code:
Page.X = (CellSize)*(Colums)
Page.X=(40)*(2)
So Page.X = 80

Now the Y value is a bit more involved.
First we figure out the area that we need
Code:
Area=(CellNum)*(CellSize)*(CellSize)
Area=(3)*(40)*(40)
Area = 4800
Next figure out how many y pixels are needed.
Code:
Pixel.Y=(Area)/(Page.X)
Pixel.Y=(4800)/(80)
Pixel.Y = 60
Now to figure out how many rows that is (so no rows are cut in half)
Code:
Rows.Base=(Pixel.Y)/(CellSize)
Rows.Base=(60)/(40)
Rows.Base = 1.5
Well we can't have 1.5 rows, so lets round up to nearest number.
First we set minimum rows as 1
Code:
Rows.Round=1
Now if there are more than 1 rows then we need at least 2 rows.
Code:
Conditional = (Rows.Base) '>' (1)
Rows.Round = (conditional ? '2' : (Rows.Round))
Conditional=True => Rows.Round=2

Same thing, if there are more than 2 rows then we need at least 3 rows.
Code:
Conditional = (Rows.Base) '>' (2)
Rows.Round = (conditional ? '3' : (Rows.Round))
Conditional=False => Rows.Round stays at 2.
This would continue for all 36 cells, end result, we just need 2.

Now to figure out what our Y setting should be
Code:
Page.Y = (Rows.Round)*(CellSize)
Page.Y=(2)*(40)
Page.Y=80

So X is 80, Y is 80, now to combine them into a size.

So last tricky bit of code. We need to set the size of the page to Page.x, Page.y

Code:
bag.size=(page.x) ## ',' ## (page.y)
bag.size=(80),(80)
bag.size=80,80

Done!

I also used conditional operators to prevent the user from setting colums to 0 or to a number higher than the number of cells.

Now I also have the data file update the volume page cell size. Now that the window has been resized and the cells in the volume page have been resized the volum page will put cells 0 and 1 on the first row, cell 2 on the 2nd row.
I set each real cells location equal to the dummy volumes location and now our cells are shaped in a 2x2 grid.
__________________

Last edited by maddbomber83 : 01-30-2006 at 10:23 PM.
Reply With Quote
Reply



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


All times are GMT -5. The time now is 05:03 AM.


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