file 2 scripting questions, Button Types and keeping saved prefs.

  • theMarble
  • theMarble's Avatar Topic Author
  • Offline
  • Beginner Marbler
  • Beginner Marbler
  • Quality rather than quantity!
  • Posts: 48
  • Thank you received: 1
06 Dec 2021 06:00 #1
Hi guys,

As a part of Mercury's UI rewrite, I am in need of dropdown menus. I notice that PQ and Platinum 1.50 use these in the PlayMissionGui. Would this be controlled by the ButtonType control or is the "closed dropdown = dropdwn_n, open = dropdwn_h" etc... I want to be able to click and select items in the dropdown.

Secondly, how would I make the Menu backgrounds the last played level? Would these be these a "link" to prefs.cs?

Thanks,

- theMarble

Please Log in or Create an account to join the conversation.

  • HiGuy
  • HiGuy's Avatar
  • Offline
  • Lead Developer
  • Lead Developer
  • PQ Developer Emeritus
  • Posts: 1334
  • Thank you received: 605
06 Dec 2021 09:14 - 06 Dec 2021 09:23 #2
The dropdown menus in MBP/PQ are a little fancier than a normal gui control, and you can do something similar with a little scripting. The general idea is:

* The menu itself is a separate gui element (usually a GuiBitmapCtrl containing a GuiTextListCtrl), and is normally not visible
* When you click the button it shows the menu with YourMenuName.setVisible(true);
* When you choose an option in the menu, it hides the menu with YourMenuName.setVisible(false);

If scripting that is too much, you can instead make a new dialog for each dropdown, and just show it with Canvas.pushDialog(YourNewDialog); and hide it with Canvas.popDialog(YourNewDialog); You can copy one of the built-in dialogs like ExitGameDlg as a starting point.


For menu backgrounds you have to change the bitmap on every gui in their onWake functions. e.g. In MainMenuGui::onWake(), you would need something like MainMenuGui.setBitmap("marble/data/missions/beginner/movement.jpg"); You would also need to save the last played level to a variable when you change levels. I would recommend doing that in PM_setSelected in PlayMissionGui. If your variable starts with $pref:: it will be saved in prefs.cs and loaded when the game starts up. Also check out what PM_preview does, as it's the preview image and you'll want to do something similar with the menu backgrounds.

Best of luck with the scripting, hopefully this helps!

This signature is real code
Code:
function clientcmd12dothepq() { commandToClient(LocalClientConnection, '34onthedancefloor'); }
Last edit: 06 Dec 2021 09:23 by HiGuy. Reason: prefs.cs

Please Log in or Create an account to join the conversation.

Moderators: Doomblah
Time to create page: 1.516 seconds
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.