EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   UI Developer Discussion (https://www.eq2interface.com/forums/forumdisplay.php?f=3)
-   -   The "Custom options" explanation (https://www.eq2interface.com/forums/showthread.php?t=13631)

Drumstix42 12-07-2009 02:36 PM

The "Custom options" explanation
 
Landiin sent me a PM and I figured I'd share my response to all:

Quote:

Originally Posted by Landiin
So the only way to get the game to save a windows setting in the Custom Mod is to unlock change via script and lock it back? Is that how I am reading you code?

Well, that's part of it. It won't just save any setting of any window. Basically here's the deal:

It'll save a custom window's location and it's size. Size is the important one because in-game we can directly get the window's Width and Height. And these are 2 single numbered properties that we can change, and then save. The unlock/lock is to make sure the change is updated in the XML layout because the size is being changed via script, rather than normally by your mouse.

So you make a new tiny window for each setting you want to save. The code is set up to read like a true/false between each new window, reading if the Width is 1 or 2 depending on how the Settings changed. I also used Height.

For my stat bar I used the Width properties of 50 new tiny windows for the top bar, and the Height properties of the windows for the second bottom bar. This saved some extra coding for windows.

I haven't noticed any performance hits from all the new windows. They're placed way off screen and are only 1-2 pixels in size, plus they're not styled.

The one trick to getting the code to read the windows is the big part. If you try to use "OnShow" to check the size, the UI script tries to read it the instant the game loads, and it seems that is too soon.
So..... I attached a script to dynamic data for "NorrathTime" and used "OnTextChanged". This is a number that changes every few seconds, and I figured it would not cause any lag because it would not be a continuous loop. So every time this number changes it checks for the Width/Height of my custom tiny windows and then sets up those options accordingly.

I didn't want that script to execute forever, because that would cause problems, and it probably decreases performance constantly executing. So I used some logic and made it execute about 30 times (30 times that NorrathTime changes)... which gives the average user enough time to load into the game the first time and have all the settings load correctly.


I know it's a lot, but it seems to work well :)

Samejima did the same kind of "load script" but did an OnTextChanged for GameData.Self.Name and I feel that this only gets one chance to execute and depending on how fast your computer loads, it may load too quickly.

Hope that explains it in enough detail!

Cheers,
-Drum

Drumstix42 12-07-2009 02:44 PM

So in the XML UIsettings file, you get lines like this:

Code:

<Window Name="StatBar_AAXP" alignment="4" alignment_offset="98324,99002" locked="true" size="1,2" />
And if you're interested how I made my execution script loop only so many times, it was fairly easy.

- Text element, set to visible.
- DynamicData="/GameData.General.Time" (this is norrath time, EarthTime is the local time just FYI)
- have a value called "changed" set to "0"

Code:

OnTextChanged="do initialization code
changed=changed + 1
COND=(changed < 35)
Visible=COND"

Code:

OnHide="OnTextChanged=' '"
So after it gets executed 35 times, it'll hide itself and then changes the OnTextChanged to do nothing.

Hope this helps out anyone interested about having custom options and such :)
Hopefully the devs will just allow some more UI customization soon and this method will be outdated and an easier on will come forth.

Landiin 12-07-2009 04:13 PM

I seen a savessetting=true in one of the default windows but it didn't to jack that I could tell. Its been so long since I've really modded getting use to jumping through hoops is annoying. Now that I've started updating some of my old code I'm starting to remember why I stopped in the 1st place..

And remember is called a thingy-ma-bopper...


All times are GMT -5. The time now is 08:28 PM.

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