PDA

View Full Version : Strange stringcontrol quirk



heliopolix
June 3rd, 2006, 09:16
I am currently editing the d20_adventure.xml to be more to my liking. The new file is part of a larger ruleset, and I have been shifting pieces around between the "npc_description", "npc_combat", and "npc_other" frames so that they are situated nicely. One such block of items are several groups that deal with weapons and their associated statistics. These statistics are irrelevant, except to note that they are a mixture of stringcontrol and numbercontrol blocks.

A short explanation for the following block of code, which is the new "npc_combat" pane for my ruleset. The first three tags under Sheetdata are directly from the original d20_adventure, with the <tabtarget>'s stripped out. The group "weapon_label" displays a several short words across near the top of the pane, underneath the "name" field. The group "npc_weapon_1" holds the actual text fields to be editied, and is displayed across, just under "weapon_label". In the actual sheet, there are several more groups of "npc_weapon_X", but I have ommitted them, since they display the same unusual behavior, and only serve to clutter the example.


<windowclass name="npc_combat">
<datasource name="npc" />
<frame name="npcbox_combat" />
<defaultsize width="270" height="400" />
<sheetdata>
<windowopencontrol>
<icon normal="button_dragtarget" />
<bounds rect="10,10,20,20" />
<class name="npc" />
<altclass name="npc" />
<description field="name" />
</windowopencontrol>
<stringcontrol name="name">
<bounds rect="45,12,-52,20" />
<empty value="&laquo; Empty Monster Data &raquo;" />
<createidentity />
</stringcontrol>
<identityactivation>
<bounds rect="-49,10,23,22" />
<icon normal="button_identityactivate" pressed="button_identityactivate_down" />
<sourcefield name="name" />
<tooltip text="Use as identity" />
</identityactivation>

<group id="weapon_label">
<stringcontrol>
<bounds hpos="9,45" vmargin="15,0" />
<font name="chatfont" />
<static value="Weapon" />
</stringcontrol>
<stringcontrol>
<bounds hpos="59,23" vmargin="15,0" />
<font name="chatfont" />
<static value="Rank" />
</stringcontrol>
<stringcontrol>
<bounds hpos="84,23" vmargin="15,0" />
<font name="chatfont" />
<static value="IV" />
<center />
</stringcontrol>
<stringcontrol>
<bounds hpos="109,23" vmargin="15,0" />
<font name="chatfont" />
<static value="SC" />
<center />
</stringcontrol>
<stringcontrol>
<bounds hpos="134,23" vmargin="15,0" />
<font name="chatfont" />
<static value="DM" />
<center />
</stringcontrol>
<stringcontrol>
<bounds hpos="159,23" vmargin="15,0" />
<font name="chatfont" />
<static value="CL" />
<center />
</stringcontrol>
<stringcontrol>
<bounds hpos="184,23" vmargin="15,0" />
<font name="chatfont" />
<static value="RG" />
<center />
</stringcontrol>
<stringcontrol>
<bounds hpos="209,23" vmargin="15,0" />
<font name="chatfont" />
<static value="USE" />
<center />
</stringcontrol>
</group>

<group id="npc_weapon_1">
<stringcontrol name="npc_weapon_1_Name">
<bounds hpos="9,48" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</stringcontrol>
<numbercontrol name="npc_weapon_1_Rank">
<bounds hpos="59,23" vmargin="2,1" />
<nodrop />
<noreset />
<hideonvalue value="0" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</numbercontrol>
<numbercontrol name="npc_weapon_1_IV">
<bounds hpos="84,23" vmargin="2,1" />
<nodrop />
<noreset />
<hideonvalue value="0" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</numbercontrol>
<numbercontrol name="npc_weapon_1_SC">
<bounds hpos="109,23" vmargin="2,1" />
<nodrop />
<noreset />
<hideonvalue value="0" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</numbercontrol>
<numbercontrol name="npc_weapon_1_DM">
<bounds hpos="134,23" vmargin="2,1" />
<nodrop />
<noreset />
<hideonvalue value="0" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</numbercontrol>
<stringcontrol name="npc_weapon_1_CL">
<bounds hpos="159,23" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
<center />
</stringcontrol>
<numbercontrol name="npc_weapon_1_RG">
<bounds hpos="184,23" vmargin="2,1" />
<nodrop />
<noreset />
<hideonvalue value="0" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</numbercontrol>
<stringcontrol name="npc_weapon_1_USE">
<bounds hpos="209,23" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
<center />
</stringcontrol>
</group>

<staticgraphic>
<bounds hpos="1,-1" vmargin="0,15" />
</staticgraphic>
</sheetdata>
</windowclass>



Now, the strange behavior happens here, in the first field of "npc_weapon_1". While all the other stringcontrols work as expected, this one displays the controlarea properly, but is entirely un-editable. Clicking anywhere within its bounds does not activate a cursor there. Worse yet, starting a new campaign, starting a new NPC, exiting FG, manually adding a value to db.xml, and re-starting FG has no lasting effect. The stringcontrol is empty.


<stringcontrol name="npc_weapon_1_Name">
<bounds hpos="9,48" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
</stringcontrol>


I tried several different methods to try to make it editable. Firstly, making the feild <center />'ed works. Unfortunately. I would prefer this field to be left-justified, so I kept working.


<stringcontrol name="npc_weapon_1_Name">
<bounds hpos="9,48" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="controlarea" offset="0,0,0,0" />
<center />
</stringcontrol>


Another thing I tried was setting the frame which controlled it to something different, like "dropfocus". That too worked, and was left-justified, but still wasn't what I wanted.



<stringcontrol name="npc_weapon_1_Name">
<bounds hpos="9,48" vmargin="2,1" />
<font name="smallcontrol" />
<frame name="dropfocus" offset="0,0,0,0" />
</stringcontrol>


What I was truly trying to determine was why the basic form of the field was not working, when it was, as far as I can tell, syntactically correct. It occured to me that perhaps the <static value="..."> from the previous field in the previos group was somehow still affecting it, but none of my meddling could get it to work without resorting to either of the aforementioned fixes. In fact, commenting out the first group did nothing to make the npc_weapon_1_Name field work, so I could rule out interference from it.

The puzzling thing is, that the next two stringcontrols, "npc_weapon_1_CL" & "npc_weapon_1_USE" both function fine, and if gut them, and stick thier guts into npc_weapon_1_Name, it functions properly, until I try to edit the hpos to "9,48" to make it take up the correct number of pixels horizontally. 23 pixels is enough for a few letters, but not for the weapons entire name.

My primary suspicion as to why it doesnt work lies with the strangeness with the <center /> tag, which leads me to believe that perhaps there is some parsing glitch in my code, as I experimented a bit further and was unable to duplicate the error with any other fields. Secondary to that is the "controlarea" frame, although I can't pinpoint why.

Any of you other code monkeys encountered something similar? Any ideas on how to fix it?

Till next time,
heliopolix

realistik
June 4th, 2006, 03:06
I didn't have the same problem as you, though there were a couple quirky stringcontrol problems. While I was touching up/tweaking our ruleset, one of the last things I did, just yesterday, in fact, was to move the "new" buttons on the Story, NPC, Item and Image lists. At first, I just made a new square button, which worked fine...until I started moving it. I wanted to square it up to the bottom and side of the underlying form, and while I was moving it around experimenting (usually no more than 3-4 pixels in either direction), it quickly got to the point where the only way the button would work (if at all) was if I clicked the bottom few pixels of the far right side. I finally got sick of this completely unexplainable behavior, made the button round, smaller, and put it above the search icon. Works great.

heliopolix
June 4th, 2006, 04:09
After working some more, I discovered that the name of the stringcontrol that I was using, "Weapon_1_Rank", was part of the problem. Shortening it to "wpn1name" made it work without any issues. This still doesn't explain why it worked with the long name and <center />, but that is another issue to be explored. In the mean time, mind the lengths of your name's and id's. Perhaps that is a reason the default d20 groups were named "a", "b", etc.