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
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Wed Feb 08, 2017 11:26 pm   

Menu-type Button?
 
How do I configure the menu-type button? Haven't been able to find anything in the helpfiles for adding selections to a menu-type button.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Feb 09, 2017 1:34 pm   
 
It is in in the help, but a little buried. The Introduction to Buttons mentions how to do it. Anyhow, here is an example.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="submenu" submenu="true" copy="yes">
    <menu priority="10" copy="yes">
      <caption>abc</caption>
    </menu>
    <menu priority="20" copy="yes">
      <caption>def</caption>
    </menu>
  </class>
  <button type="Menu" priority="30" copy="yes">
    <caption>menu</caption>
    <value>submenu</value>
  </button>
</cmud>
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Sat Feb 11, 2017 12:08 am   
 
Thank you. Is there a function or command I can use to dynamically add sub menu items?

Slightly OT, but is there also a function or command to set button positions? I'm trying to dynamically generate gauges for another part of my script of friendlies and enemies.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Feb 11, 2017 4:25 am   
 
On the submenus, from the settings editor, there is a new button with a menu arrow on it. So long as you have the button in question selected, it should be as simple as choosing new button state.


As for positioning the buttons, you can either to it numerically via the options tab (uncheck autoposition and autosize to edit).
Or...
Under the layout menu of the main cmud window you can uncheck lock buttons, at which point you can click and drag them where you want. Just remember to lock it again afterwards.
_________________
Discord: Shalimarwildcat
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Feb 11, 2017 10:19 pm   
 
If you are looking to make dynamic buttons I always recommend making multiple nearly identical buttons. The buttons should each have a unique number that corresponds to their position/order, and that same number is used in multiple places. Captions on buttons are automatically dynamic and can use that unique number to decide what to display. The script should also contain the same number and can use that to determine how to execute. After that everything is held in a record variable.

You can use the #MENU command to add menu items. Deleting the menu items might be a little bit trickier.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Mon Feb 13, 2017 3:29 pm   
 
shalimar wrote:
On the submenus, from the settings editor, there is a new button with a menu arrow on it. So long as you have the button in question selected, it should be as simple as choosing new button state.


As for positioning the buttons, you can either to it numerically via the options tab (uncheck autoposition and autosize to edit).
Or...
Under the layout menu of the main cmud window you can uncheck lock buttons, at which point you can click and drag them where you want. Just remember to lock it again afterwards.


Thank you. But I'm looking to dynamically create the gauges and stack them vertically in a second window. I didn't know if there is a command that I can do something like "ypos = (@GaugeCount * @Button Height) + 1".
Reply with quote
shalimar
GURU


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

PostPosted: Tue Feb 14, 2017 2:02 pm   
 
I would do as Vij suggested.
If there is a maximum party size just go ahead and make that many buttons, and then just toggle the ones currently in use with #T+/-
_________________
Discord: Shalimarwildcat
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Tue Feb 14, 2017 7:10 pm   
 
shalimar wrote:
I would do as Vij suggested.
If there is a maximum party size just go ahead and make that many buttons, and then just toggle the ones currently in use with #T+/-


Fair enough. Max size is 64 - I'm actually tracking the status of various starfighters within my ships squadrons. To get enough real estate, I may just have to expand onto my second monitor.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Feb 15, 2017 2:05 am   
 
You can make it do pages by having other buttons increment a page number variable. A single bar on one side with 10-15 gauges and page control buttons should not be hard. With a little bit of work you can also have the data displayed constantly be sorted so that page 1 is where most of the information you need gets routinely displayed.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Feb 15, 2017 8:48 am   
 
Since the technique for doing this really complex I decided to mock up an example for you.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="ButtonExample" copy="yes">
    <var name="ButtonPaging" type="Integer" usedef="true" copy="yes">
      <value>0</value>
      <default>0</default>
    </var>
    <button name="LeftPageBtn" autosize="false" width="35" height="23" autopos="false" left="0" top="0" toolbar="4" image="ARROWL" priority="30" copy="yes">
      <value>#IF (@ButtonPaging) {#ADD ButtonPaging -1}</value>
    </button>
    <button name="RightPageBtn" autosize="false" width="35" height="23" autopos="false" left="40" top="0" toolbar="4" image="ARROWR" priority="40" copy="yes">
      <value>#IF (%numitems(@ButtonExampleData)-%eval(10*@ButtonPaging)>10) {#ADD ButtonPaging 1}</value>
    </button>
    <var name="ButtonExampleData" type="Record" usedef="true" copy="yes">
      <value>bob="10|0|50"</value>
      <json>{"bob":[10,0,50]}</json>
      <notes>Value is arranged as current|gauge low point|max</notes>
    </var>
    <button name="ButtonExample1" type="Gauge" autosize="false" width="74" height="15" autopos="false" left="0" top="25" toolbar="4" color="green" gaugelowcol="red" gaugebackcol="#ECE9D8" priority="62" copy="yes">
      <caption>%if(%item(%dbkeys(@ButtonExampleData),%eval(1+10*@ButtonPaging)),%item(%dbkeys(@ButtonExampleData),%eval(1+10*@ButtonPaging))%if(%btnenable(ButtonExample1,1),,),%if(%btnenable(ButtonExample1,0),,))</caption>
      <value>#CALL {heal %item(%dbkeys(@ButtonExampleData), 1)}</value>
      <expr>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),1)),1)</expr>
      <gaugemax>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),1)),3)</gaugemax>
      <gaugelow>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),1)),2)</gaugelow>
    </button>
    <button name="ButtonExample2" type="Gauge" autosize="false" width="74" height="15" autopos="false" left="0" top="42" toolbar="4" btnenabled="false" color="green" gaugelowcol="red" gaugebackcol="#ECE9D8" priority="61" copy="yes">
      <caption>%if(%item(%dbkeys(@ButtonExampleData),%eval(2+10*@ButtonPaging)),%item(%dbkeys(@ButtonExampleData),%eval(2+10*@ButtonPaging))%if(%btnenable(ButtonExample2,1),,),%if(%btnenable(ButtonExample2,0),,))</caption>
      <value>#CALL {heal %item(%dbkeys(@ButtonExampleData), 2)}</value>
      <expr>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),2)),1)</expr>
      <gaugemax>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),2)),3)</gaugemax>
      <gaugelow>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),2)),2)</gaugelow>
    </button>
    <button name="ButtonExample3" type="Gauge" autosize="false" width="74" height="15" autopos="false" left="0" top="59" toolbar="4" btnenabled="false" color="green" gaugelowcol="red" gaugebackcol="#ECE9D8" priority="60" copy="yes">
      <caption>%if(%item(%dbkeys(@ButtonExampleData),%eval(3+10*@ButtonPaging)),%item(%dbkeys(@ButtonExampleData),%eval(3+10*@ButtonPaging))%if(%btnenable(ButtonExample3,1),,),%if(%btnenable(ButtonExample3,0),,))</caption>
      <value>#CALL {heal %item(%dbkeys(@ButtonExampleData), 3)}</value>
      <expr>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),3)),1)</expr>
      <gaugemax>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),3)),3)</gaugemax>
      <gaugelow>%item(%db(@ButtonExampleData,%item(%dbkeys(@ButtonExampleData),3)),2)</gaugelow>
    </button>
  </class>
</cmud>
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Thu Feb 16, 2017 4:46 pm   
 
Fantastic! Thank you.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Feb 16, 2017 6:29 pm   
 
You can make it a little simpler by putting the repeated expressions into functions. Using that method you can simplify the caption ones by using #RETURN "" to make the blank caption instead of the messy %if(action,,) that I have.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: Sun Apr 23, 2017 10:38 am   
 
Quick, hopefully easy, question:

Is there a way to sort the submenu items in the menu?
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