Kromster80 / kam_remake

"KaM Remake" is an RTS game remake written in Delphi from scratch.

Home Page:http://www.kamremake.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MessageBox with custom buttons instantiated from dynamic script

lolslayer opened this issue · comments

This will be my last issue that I was planning to add, so don't worry. :P

For scripting, it could be extremely useful if it's possible to have a function where you can make a message box popup. Where you can add in custom buttons (custom in a way that they have a custom text in them and clicking them will run your custom code).

This could look like this in code:

Actions.Buttonbox(Player,"Text in the message box");
     Buttons.AddOption("Text in the button'){
          //Code
     }
     Buttons.AddOption("Text in the button'){
          //Code
     }
     Buttons.AddOption("Text in the button'){
          //Code
     }

So when pulling of the action Actions.Buttonbox(), all upcoming Buttons.AddOption() that were called in the same tick will be added into the message box with the buttons.

A great example what you can do with this, in combination with my issue where you have keys reserved for scripting, is that you canmake an ingame Alliance system. With a dedicated key you call in a buttonbox with the name of every player in the game. When clicking on them you can send an Alliance request. When doing that, the player that gets the request will get a button box where he can accept or deny the Alliance request.

The code to create it would probably be:

dialog_id := Actions.ButtonBox(Player, "Text in the message box", "button1 text", "button2 text", "button3 text");

and corresponding event where dialog_id will be needed:

OnButtonBoxClick(aDialogId, aButtonId);

Note that unless we have a modal mode dialogs (which is not viable in MP yet), the events could never be fired, if player decides to ignore the dialog.

Yeah, that sounds great.

But that's the idea, right? That when the player decides not to click on any button, the button events will never fire. Or did I understand it wrong?