Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
fox
Beginner


Joined: 31 May 2022
Posts: 11

PostPosted: Sat Jun 11, 2022 10:19 pm   

Dynamic button and gauge locations
 
Does CMUD support locations when creating buttons/gauges on the fly? The XML contains attributes like width, height, autopos, left, top, toolbar. Can those be specified when creating #BUTTON or #GAUGE from a prompt or within an alias?

I'd like to create X buttons per player on-the-fly i.e. through an alias and control their placement in a particular window. The use case here is multiplay with different run squads. So if I have dozens of characters, squad-1-player-3 isn't statically placed super far down the window. The spacing could conceivably be controlled with a known height of the set of buttons, so each "add" alias the creates buttons will add to the height var, and a "remove" alias would subtract from the height.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun Jun 12, 2022 1:34 am   
 
It -can- be done on the fly, if you know what you are doing (#HELP #BUTTON), but there are so many potential parameters for buttons that most people are encouraged to use the GUI instead.

#BUTTON id|number Off-caption On-command On-caption Off-command Value-expression Variable-name Bitmap-filename AutoSize Width Height AutoPos Top Left Off-color On-color Button-Kind Bitmap-margin Classname Options ToolTip ID PanelNum

And entering the wrong data in the wrong field leads to unexpected results.

However, nothing says that all known buttons need to be visible all the time.
The best-case scenario would be to make all the potential buttons you might need in advance, and then just enable/disable them as needed.
_________________
Discord: Shalimarwildcat
Reply with quote
fox
Beginner


Joined: 31 May 2022
Posts: 11

PostPosted: Sun Jun 12, 2022 12:17 pm   
 
A question and a remark:
Q: My question asked about gauges too, but #HELP #GAUGE doesnt show quite as many parameters, but I would need control over their positioning as well. Are the same params supported in #GAUGE's created on the fly?
R: I did think about creating all the necessary buttons/gauges in advance, but they would have static positioning. If I simply disabled characters 2, 5, and 7 for example, there would be big gaps between sets of buttons. My goal is putting them all together, and their positioning makes more UX sense if theyre positioned a certain way e.g. for each character, it would be useful to appear like this (btw, im using panel 3 in a separate window, so these would be vertically stacked "templates" of buttons and gauges)

row 1: hp gauge, quaff 1, quaff 5
row 2: mana gauge, quaff 1, quaff 5
row 3: various auto fight buttons
...next character buttons
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun Jun 12, 2022 5:19 pm   
 
If you leave autoposition checked, they should compress to fill less space in the given window/panel you have them displayed on.

As for if gauges accept the extra parameters... uncertain, I always make them via the GUI myself. Pretty sure you could use gauge as the button-kind argument though.
_________________
Discord: Shalimarwildcat
Reply with quote
fox
Beginner


Joined: 31 May 2022
Posts: 11

PostPosted: Sun Jun 12, 2022 5:57 pm   
 
If I use auto position, how can I achieve the layout I described above? It won't be useful to just stack a bunch of arbitrary buttons
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun Jun 12, 2022 6:47 pm   
 
The whole point of autoposition is to avoid stacking buttons, which you can force with manual data.
You turn it off long enough to set the toolbar and justification, then turn it back on.
It -should- use priority or creation order to determine the display order.
_________________
Discord: Shalimarwildcat
Reply with quote
fox
Beginner


Joined: 31 May 2022
Posts: 11

PostPosted: Sun Jun 12, 2022 6:51 pm   
 
I'm not sure I follow that last comment, but can you help me with the syntax? I've tried a few things close to the below with no luck yet. This is an attempt at a gauge. It's not multistate but I was trying to stub in dummy commands etc. This is a hit point gauge tracking a couple hp variables in a session named "playername". I'm guessing some strings shouldn't be strings and vice versa, but where could I find documentation on this?
Code:

#BUTTON test "player hp" "#ECHO on" "its on?" "#ECHO off" "@//playername/hp" "playername-btn-var" "" false 200 25 false 200 0 "#00CCFF" "#FF0000" "Gauge"|"#00CCFF"|"red"|"@//playername/maxhp"|"@//playername/maxhp/5" "" testclassname "" "helpful tooltip" playername-hp-test 3


where the desired output XML (created through GUI) is:

Code:
<button type="Gauge" autosize="false" width="200" height="25" autopos="false" top="0" toolbar="3" inset="true" toolstyle="true" color="#00CCFF" gaugelowcol="red" gaugebackcol="silver" priority="15" id="3">
  <caption>player hp</caption>
  <value>@hp</value>
  <expr>@//playername/hp</expr>
  <gaugemax>@//playername/maxhp</gaugemax>
  <gaugelow>@//playername/maxhp/5</gaugelow>
</button>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun Jun 12, 2022 7:11 pm   
 
One of the major issues I recall in creating buttons by command rather than through the GUI is that variables tend to be evaluated in the button's creation rather than keep their status as a pointer.

Typically you would want to use {} for each expected parameter, and just leave those with no value, empty.
_________________
Discord: Shalimarwildcat
Reply with quote
fox
Beginner


Joined: 31 May 2022
Posts: 11

PostPosted: Sun Jun 12, 2022 11:39 pm   
 
Making progress! my alias "add" now looks like below (intended use is "add playername")

But I can't seem to make the concatenated variable names evaluate correctly e.g. "add bob" should use @//bob/hp and @//bob/maxhp and @//bob/maxhp/5. I've tried a few permutations of "@" placement, but no luck yet. The button style and placement are working though!

Code:
#VAR caption %concat(%1, "-hp")
#VAR hp %concat("@//", %1, "/hp")
#VAR maxhp %concat("@//", %1, "/maxhp")
#BUTTON {@caption} {@caption} {} {} {} {@{@hp}} {} {} {false} {200} {25} {false} {200} {0} {#00CCFF} {} {Gauge|#00CCFF|#FF0000|@{@maxhp}|@{@maxhp}/5} {} {%1} {} {helpful tooltip} {} {3}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net