Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Popup menu implementation

Popup menu implementation

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Khripunoff   (3 posts)  Bio
Date Thu 07 May 2020 03:36 PM (UTC)

Amended on Thu 07 May 2020 06:08 PM (UTC) by Khripunoff

Message
I play Discworld MUD and I decided to make a plugin that will enhance the item lists in shops.

This is an example snippet of a shop list:

The following items are for sale:
   A: a large watermelon for DjToon 25.00 (five left).
   B: a medium watermelon for DjToon 17.50 (four left).
   C: a small watermelon for DjToon 10.00 (seven left).
   D: an overripe plum for DjToon 1.87 (four left).
   E: a succulent pineapple for DjToon 6.00 (six left).
   F: a juicy peach for DjToon 5.00 (five left).
   G: an orange for DjToon 3.00 (seven left).
   H: a juicy nectarine for DjToon 5.00 (three left).
   I: a musk melon for DjToon 18.00 (five left).
   J: a small lemon for DjToon 2.50 (four left).

I made a regex that captures the item name, the currency and the price (the last two may be used later for other purpose) like this:
^   [A-Z]{1,2}: ?a?n? (?<Item>.*) for (?<Currency>\w+) (?<Price>[\d.]+) \(\w+ left\)\.$

My idea is to make every item entry a clickable link that can be right-clicked for a pop-up menu with command options such as |buy <Item>|browse <Item>|case <Item>|shoplift <Item>| etc.
I have some basic scripting knowledge but I would like some advise on what would be the best approach for realizing this? mxp? hyperlink? Is there a function dedicated to creating such thing?

Help and advice will be highly appreciated.

[EDIT] The currency and the price are captured in this case, but there are some currencies in the MUD with different formatting. I will have to come up with a better idea for capturing them properly, but for now this is far less important.
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #1 on Fri 08 May 2020 05:28 PM (UTC)

Amended on Fri 08 May 2020 05:39 PM (UTC) by Fiendish

Message
Quote:
the best approach


There are no best approaches, only ones that work and ones that don't.

Quote:
right-clicked for a pop-up menu

I don't know much about MXP, but the only function I know of in MUSHclient for that is WindowMenu. It requires creating a temporary miniwindow first, though I'm not sure why that is. But anyway you can make a hyperlink that calls a function that creates a miniwindow and then calls WindowMenu in that miniwindow. You can use the same miniwindow over and over, so you only have to create one once.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 10 May 2020 06:56 AM (UTC)

Amended on Sun 10 May 2020 06:57 AM (UTC) by Nick Gammon

Message

Using MXP (from the server) you can make hyperlinks that have a menu. See Creating a popup menu in this link.

You could conceivably pretend MXP arrived by using the Simulate function — although it was not designed for that — and make a menu that way.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 10 May 2020 07:00 AM (UTC)

Amended on Sun 10 May 2020 07:02 AM (UTC) by Nick Gammon

Message

Another approach would be to make a hyperlink and inside that call a function (see that link). That function could pop up a miniwindow — I think you can find out where the mouse currently is* — and make a menu of things you want to do in that.

* See GetInfo selectors 283 and 284.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,235 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.