mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 07:32:28 +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;
|
FString label = sc.String;
|
||||||
sc.MustGetStringName(",");
|
sc.MustGetStringName(",");
|
||||||
sc.MustGetString();
|
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);
|
desc->mItems.Push(it);
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Control") || sc.Compare("MapControl"))
|
else if (sc.Compare("Control") || sc.Compare("MapControl"))
|
||||||
|
|
|
@ -103,10 +103,23 @@ public:
|
||||||
class FOptionMenuItemSafeCommand : public FOptionMenuItemCommand
|
class FOptionMenuItemSafeCommand : public FOptionMenuItemCommand
|
||||||
{
|
{
|
||||||
// action is a CCMD
|
// action is a CCMD
|
||||||
|
protected:
|
||||||
|
char *mPrompt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FOptionMenuItemSafeCommand(const char *label, const char *menu)
|
FOptionMenuItemSafeCommand(const char *label, const char *menu, const char *prompt)
|
||||||
: FOptionMenuItemCommand(label, menu)
|
: FOptionMenuItemCommand(label, menu)
|
||||||
|
, mPrompt(nullptr)
|
||||||
{
|
{
|
||||||
|
if (prompt && *prompt)
|
||||||
|
{
|
||||||
|
mPrompt = copystring(prompt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~FOptionMenuItemSafeCommand()
|
||||||
|
{
|
||||||
|
if (mPrompt != NULL) delete[] mPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuEvent (int mkey, bool fromcontroller)
|
bool MenuEvent (int mkey, bool fromcontroller)
|
||||||
|
@ -121,7 +134,11 @@ public:
|
||||||
|
|
||||||
bool Activate()
|
bool Activate()
|
||||||
{
|
{
|
||||||
const char *msg = GStrings("SAFEMESSAGE");
|
const char *msg = mPrompt ? mPrompt : "$SAFEMESSAGE";
|
||||||
|
if (*msg == '$')
|
||||||
|
{
|
||||||
|
msg = GStrings(msg + 1);
|
||||||
|
}
|
||||||
|
|
||||||
const char *actionLabel = mLabel;
|
const char *actionLabel = mLabel;
|
||||||
if (actionLabel != NULL)
|
if (actionLabel != NULL)
|
||||||
|
|
Loading…
Reference in a new issue