mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
Added optional prompt argument to MENUDEF's SafeCommand
This commit is contained in:
parent
3d9591229e
commit
58a6d7df1f
2 changed files with 28 additions and 3 deletions
|
@ -781,7 +781,15 @@ static void ParseOptionMenuBody(FScanner &sc, FOptionMenuDescriptor *desc)
|
|||
FString label = sc.String;
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetString();
|
||||
FOptionMenuItem *it = new FOptionMenuItemSafeCommand(label, sc.String);
|
||||
FString command = sc.String;
|
||||
FString prompt;
|
||||
// Check for optional custom prompt
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
sc.MustGetString();
|
||||
prompt = sc.String;
|
||||
}
|
||||
FOptionMenuItem *it = new FOptionMenuItemSafeCommand(label, command, prompt);
|
||||
desc->mItems.Push(it);
|
||||
}
|
||||
else if (sc.Compare("Control") || sc.Compare("MapControl"))
|
||||
|
|
|
@ -103,10 +103,23 @@ public:
|
|||
class FOptionMenuItemSafeCommand : public FOptionMenuItemCommand
|
||||
{
|
||||
// action is a CCMD
|
||||
protected:
|
||||
char *mPrompt;
|
||||
|
||||
public:
|
||||
FOptionMenuItemSafeCommand(const char *label, const char *menu)
|
||||
FOptionMenuItemSafeCommand(const char *label, const char *menu, const char *prompt)
|
||||
: FOptionMenuItemCommand(label, menu)
|
||||
, mPrompt(nullptr)
|
||||
{
|
||||
if (prompt && *prompt)
|
||||
{
|
||||
mPrompt = copystring(prompt);
|
||||
}
|
||||
}
|
||||
|
||||
~FOptionMenuItemSafeCommand()
|
||||
{
|
||||
if (mPrompt != NULL) delete[] mPrompt;
|
||||
}
|
||||
|
||||
bool MenuEvent (int mkey, bool fromcontroller)
|
||||
|
@ -121,7 +134,11 @@ public:
|
|||
|
||||
bool Activate()
|
||||
{
|
||||
const char *msg = GStrings("SAFEMESSAGE");
|
||||
const char *msg = mPrompt ? mPrompt : "$SAFEMESSAGE";
|
||||
if (*msg == '$')
|
||||
{
|
||||
msg = GStrings(msg + 1);
|
||||
}
|
||||
|
||||
const char *actionLabel = mLabel;
|
||||
if (actionLabel != NULL)
|
||||
|
|
Loading…
Reference in a new issue