DICE PACKS BUNDLE
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    Button states in template

    I press the button and the action happens opening the thing but I noticed unlike another cog I use (different icons) pressing it doesn't result in a graphic change.
    So then I tried the state/pressed combo - same thing nothing changed. Of course this is just a minor visual thing, was curious however.
    Code:
    	<template name="button_charabiltiesdetail">
    		<buttoncontrol>
    			<anchored width="20"/>
    			<!-- <state icon="details_white" pressed="details_down" /> -->
    			<state>
    				<icon>details_white</icon>
    			</state>
    			<pressed>
    				<icon>details_down</icon>
    			</pressed>
    			<script>
    				function onButtonPress()
    					Interface.openWindow("charsheet_abilities_details", window.getDatabaseNode());
    				end
    			</script>
    		</buttoncontrol>
    	</template>

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Have you 100% confirmed that "details_down" is a valid icon resource?

    If so, try the <icon> property: <icon normal="details_white" pressed="details_down" />
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    "button_details" and "button_details_down" are the names of the default icons for the "button_details" template button in CorRPG.

    Regards,
    JPG

  4. #4
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Quote Originally Posted by Trenloe View Post
    Have you 100% confirmed that "details_down" is a valid icon resource?

    If so, try the <icon> property: <icon normal="details_white" pressed="details_down" />
    Thanks Trenloe, that worked precisely. Below is my slight modification of 2E's template based on your instructions (I was trying various combos from looking up controls on Wiki before trying to replicate in RW):
    The commented out line is the original code - like mine, it "worked", you could press it and it opened a panel but it didn't animate until your correction.
    Code:
    	<template name="button_charabiltiesdetail">
    		<buttoncontrol>
    			<anchored width="20"/>
    			<!-- <state icon="details_white" pressed="details_down" /> -->
    			<icon normal="details_white" pressed="details_down" />
    			<script>
    				function onButtonPress()
    					Interface.openWindow("charsheet_abilities_details", window.getDatabaseNode());
    				end
    			</script>
    		</buttoncontrol>
    	</template>
    EDIT, forgot the / in code.

    PS - Changing those 2 lines should fix all or most of the Charsheet buttons in 2E Ruleset that don't "press" unless it was intended for them to stay white-cog when pressed.
    Last edited by Varsuuk; June 10th, 2023 at 04:08.

  5. #5
    Why not just use the button_toggledetails template, that uses button_details and button_details_down?

    If the color is wrong, why not just replace button_details icon?

    JPG

  6. #6
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Quote Originally Posted by Moon Wizard View Post
    Why not just use the button_toggledetails template, that uses button_details and button_details_down?

    If the color is wrong, why not just replace button_details icon?

    JPG
    Mainly cos right now, been adding the minimal gui elements I need for the sheet and using a lot of 2E for guide for the first draft since it's 1E-based. So, what I do there is create a normal coreRPG.xml file for things that appear to be overrides of coreRPG stuff and a coreRPG_add.xml file (coreRPG represents whatever that file is called in coreRPG, like tempate_char.xml and template_char_add.xml) since the source 2E often mixes these, I search for exact name matches in Core in order to delineate it. I also carry over now (after spending WAAAAY to long making my first 4 graphic elements on my own) the 2E graphics and append "_2E" to them so I know which to replace and rearrange when done later that aren't mine or from coreRPG.

    So I didn't see this existing template. I guess he made his own before it existed or he missed it.
    That said, I am ALL FOR reuse so I went to do just that (but intending to test to see if could simply override the <icon...> part because the detail button is only going to be "white" in certain situations (contrast with element it is on) and then I saw that both this detail template above and the original one you mention rely on scripts. I haven't yet re-gone over the wiki (cos... I need to dive in or will never get to it) so I do not know if there is a mechanism for a CONTROL (vs file) script to call a parent control script. I'll just try it without calling anything to see if it work magicalifically.

    EDIT: I see now the CoreRPG one is a multi-state control, which is not what Cel's is, that one is a toggle switch.
    That said, I found I could merge="replace" the first one but if put both it onl;y keeps the last (prob rules on that when there are multiple of same xml tag, but not gonna look for it to read since what I got works for me atm fine enough. But appreciate knowing about that template for when it will apply.

    EDIT2: Since I tend to obsessively try to trace things, I initially avoided thinking about how window.toggleDetail worked. Unfortunately upon editing back my code, I felt I needed to know and yup, this is how I get distracted Anyhow, it seems this button is very tightly coupled with record_power_item and that is the only place in CoreRPG it is used and it expects the enclosing window to have a toggleDetails method (which we could override to do what the above control does but at this point, it seems safer to just roll your own like Cel did since it is a matter of trying to shoehorn one purpose control for another. It isn't written to be overridden easily (I think) )

    EDIT3: Grrr (see above...obsessive) - so I trped the words "overriden easily" and thought, yeah between the name and other stuff the one I am using would only work once on a page and yet, it COULD be reusable if I knew what to do. So two tries later, I found target[1] was the right syntax and modified Cel's version to:
    Code:
    	<template name="button_toggledetails">
    		<buttoncontrol>
    			<anchored width="20"/>
    			<icon normal="details_white" pressed="details_down" />
    			<target>charsheet_abilities_details</target>
    			<script>
    				function onButtonPress()
    					Interface.openWindow(target[1], window.getDatabaseNode());
    				end
    			</script>
    		</buttoncontrol>
    	</template>
    The next step would be to making a REAL toggle were onButtonPress checks a state and either opens or closes the window. But I don't need that yet and don't want to continue down rabbit holes I just want the minimal UI up so I can start coding the functionality. But the above I am thinking is a good start for a control that can open different windows if you redefine "<target>" in a consitant way. And you can update the button icons in the normal xml manner as well.
    Last edited by Varsuuk; June 11th, 2023 at 01:36.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in