PDA

View Full Version : Customising TheBox



Zeus
August 26th, 2009, 09:53
Hey all, I'm stuck and need some advice from those in the know. ;)

I have written an extension which redefines (or attempts to redefine) the starting position of TheBox from the right corner of the desktop to just right of the die under the chat window. This to speed up die drops to TheBox.

Here's the extension.xml code:



...
<base>

<panel name="thebox" modes="host,client">
<class>thebox</class>
<bounds>
<anchored>
<bottom>
<anchor>bottom</anchor>
<offset>-63</offset>
</bottom>
<left>
<anchor>left</anchor>
<offset>400</offset>
</left>
<size>
<width>60</width>
<height>40</height>
</size>
</anchored>
</bounds>
</panel>
</base>
...


Now as expected. My new TheBox renders next to the die just right of the chat window however the original TheBox also renders in the bottom-right of the desktop as well??? Both function OK, however if I disable TheBox option or Show GM rolls under Options, only my TheBox dissappears, the original remains active.

Is there anyway to override TheBox? Am I missing something in my extension, perhaps to unregister the original panel?

Whilst having two TheBoxes is no problem really and I can live with it, for completeness I'd like to resolve the final issue if possible.

If its not possible and as an alternative can I register a new keystroke during a die roll (similar to critical hit rolls in 4E_JPG) such that Alt key + die rolls results in the die rolling on TheBox ?

Thanks for any assistance?

BTW: I did post a similar request for help on FUM however the forum gobbles my code tags and so no one has/is responding.

Zeus
August 28th, 2009, 11:31
Anyone?


Thanks.

Valarian
August 28th, 2009, 11:40
I've had problems overriding items that already exist via extensions. It could well be that it's still reading the original box from the ruleset and then adding yours from the extension. When disabling / hiding the box, it's probably applying the change to the first object of that name it finds. Is it possible to unregister stuff? If so, this may be the answer.

Tenian
August 28th, 2009, 13:20
The ruleset includes an option which disables TheBox. When it's disabled, it's not visible. Maybe you could steal this code and hide the ruleset's TheBox before loading your extensions?

Zeus
August 28th, 2009, 16:48
The ruleset includes an option which disables TheBox. When it's disabled, it's not visible. Maybe you could steal this code and hide the ruleset's TheBox before loading your extensions?

It looks like the windowclass onInit() (procedure/event?) calls a registerControl() function in the script manager_thebox.lua. In turn registerControl calls a local function Activate() which checks for the existance of Show DM Rolls and Enable TheBox options in the campaign's option tree and then calls another local function, Update().

Update() then sets control.setVisible(true/false) based on what options are set.

There does not appear to be an unregister (is that a word?) function that I can call.

My question how can I uniqley identify the node in the database that represents the control object for TheBox? If it can be identofied can I then simply call the setVisible() function in a script block in extension.xml to get th original control to disappear e.g.



...
<script>
{identified control node}.control.SetVisible(false);
</script>
...

Griogre
August 28th, 2009, 16:54
Without looking at the code you are going to need to override with the extension were the box is actually defined. You need to find the place where the actual co-ordinates of the box are located. Then copy and paste the *whole* definition it is included into your extension and then change the co-ordinates. It’s very easy - once your find where the coordinates are.

I'm not exaggerating, usually the hard part is finding the place in the ruleset where his happens.

Zeus
August 28th, 2009, 17:10
Without looking at the code you are going to need to override with the extension were the box is actually defined. You need to find the place where the actual co-ordinates of the box are located. Then copy and paste the *whole* definition it is included into your extension and then change the co-ordinates. It’s very easy - once your find where the coordinates are.

I'm not exaggerating, usually the hard part is finding the place in the ruleset where his happens.

I think I have tried that. Here's exactly what I did:

Created an extension.xml whereby the base is as follows:



<base>

<includefile source="utility_thebox.xml" />

</base>



I copied the base utility_thebox.xml to the root of the extension subdir and modified the panel definition as per my 1st post with the correct offset's. Can't see x,y,w,h coordinates specified, just offsets and bounds.

I also copy the manager_thbox into a subfolder called scripts in the root dir of the extension.

As per my original post though, I still get two TheBox's, my new one and the original?

nezzir
August 29th, 2009, 04:03
I moved it, though it's been so long I don't remember what I did. Take a look at my ruleset in the link in my sig. Use the Warhammer ruleset in the FGVTT yahoo group below. I also changed to graphics. Great mod btw...

Zeus
August 29th, 2009, 09:01
I moved it, though it's been so long I don't remember what I did. Take a look at my ruleset in the link in my sig. Use the Warhammer ruleset in the FGVTT yahoo group below. I also changed to graphics. Great mod btw...

Thanks. I had a look and it looks like your pretty much taking the same approach however as you have modified the original ruleset files you do not encounter the overriding issue that I am facing when trying to achieve this via an extension.

Valarian
August 29th, 2009, 11:23
As a workaround, maybe you could try this.
1) Start the ruleset without the extension active.
2) Hide the Box (this should hopefully get rid of the old "The Box" box)
3) Exit back to the launcher
4) Restart the rulset with the extension active (this should hopefully display just your "The Box")
5) Try hiding and displaying "The Box" (hopefully this'll just affect the extension version)

Zeus
August 29th, 2009, 12:36
As a workaround, maybe you could try this.
1) Start the ruleset without the extension active.
2) Hide the Box (this should hopefully get rid of the old "The Box" box)
3) Exit back to the launcher
4) Restart the rulset with the extension active (this should hopefully display just your "The Box")
5) Try hiding and displaying "The Box" (hopefully this'll just affect the extension version)

Thanks Valarian, that does work however you have to remember to disable TheBox before you close the campaign or the same thing happens when you next load up.

As TheBox is part of a panel and therefore the windowinstance is unbound from the DB, I'm not sure how one would go about closing or hiding an existing panel thats already rendered. Based upon my understanding (limited) of FGII rulesets, if TheBox was a regular window I could use findWindow() and .Close() to close it. However panels appear to have no methods for similar tasks.

Valarian
August 29th, 2009, 13:35
Bit of a pain, but at least it's a workaround and only displays the one you want.

Griogre
September 1st, 2009, 00:53
zephp, from your description, I would suspect the box is also defined in the preferances of the ruleset. They may have had to do that to get it to "turn on" when it was checked in preferances.