[script-command, dynmultichoice] early expand placeholders
This commit is contained in:
parent
4fad6b3e12
commit
bfc6619c03
1 changed files with 6 additions and 5 deletions
11
src/scrcmd.c
11
src/scrcmd.c
|
@ -1414,11 +1414,8 @@ bool8 ScrCmd_dynmultichoice(struct ScriptContext *ctx)
|
||||||
items = AllocZeroed(sizeof(struct ListMenuItem) * argc);
|
items = AllocZeroed(sizeof(struct ListMenuItem) * argc);
|
||||||
for (i = 0; i < argc; ++i)
|
for (i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
u8 *nameBuffer = Alloc(100);
|
|
||||||
struct ListMenuItem *currentItem = MultichoiceDynamic_PeekElementAt(i);
|
struct ListMenuItem *currentItem = MultichoiceDynamic_PeekElementAt(i);
|
||||||
StringExpandPlaceholders(nameBuffer, currentItem->name);
|
items[i] = *currentItem;
|
||||||
items[i].name = nameBuffer;
|
|
||||||
items[i].id = currentItem->id;
|
|
||||||
if (currentItem->id == initialSelected)
|
if (currentItem->id == initialSelected)
|
||||||
initialRow = i;
|
initialRow = i;
|
||||||
}
|
}
|
||||||
|
@ -1440,9 +1437,13 @@ bool8 ScrCmd_dynmultichoice(struct ScriptContext *ctx)
|
||||||
|
|
||||||
bool8 ScrCmd_dynmultipush(struct ScriptContext *ctx)
|
bool8 ScrCmd_dynmultipush(struct ScriptContext *ctx)
|
||||||
{
|
{
|
||||||
|
u8 *nameBuffer = Alloc(100);
|
||||||
const u8 *name = (const u8*) ScriptReadWord(ctx);
|
const u8 *name = (const u8*) ScriptReadWord(ctx);
|
||||||
u32 id = VarGet(ScriptReadHalfword(ctx));
|
u32 id = VarGet(ScriptReadHalfword(ctx));
|
||||||
struct ListMenuItem item = {.name = name, .id = id};
|
struct ListMenuItem item;
|
||||||
|
StringExpandPlaceholders(nameBuffer, name);
|
||||||
|
item.name = nameBuffer;
|
||||||
|
item.id = id;
|
||||||
MultichoiceDynamic_PushElement(item);
|
MultichoiceDynamic_PushElement(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue