General > User modifications

extension to ui script language

(1/1)

xray:
Hi,

I've been working on some modifications to the ui script language. I've added implementation for a
--- Code: ---forchildin
--- End code ---
keyword (a foreach that iterates child nodes of a given ui-node) and the
--- Code: ---break
--- End code ---
statement to exit a loop. Now the code needs a last finishing touch. Inside the iterating body I need a way to reference the child node being visited. To do so, I guess I have to change the executing context of the action and add a hidden variable (something like self) that can be referenced from the code body of the iterating block. I cannot seem to figure out how to do this? Any help is appreciated.

Regards,
xray

Mattn:
please pastebin your patch - then it's a lot easier to help you

xray:
Hi Mattn,

Ah yes, sorry. I should have thought about that. The code below is from the file ui_actions.cpp.

--- Code: --- /*
expected usage in .ufo scripts:

forchildin ( panel ) {
}
*/
case EA_FORCHILDIN:
{
uiNode_t* root;
root = UI_GetNodeFromExpression(action->d.nonTerminal.left, context, nullptr);

uiNode_t* node = root->firstChild;
int loop = 0;
while (node != root->lastChild) {
UI_ExecuteActions(action->d.nonTerminal.right, context);
if (context->breakLoop) {
context->breakLoop = false;
break;
}
if (loop > 1000) {
Com_Printf("UI_ExecuteAction: Infinite loop. Force breaking 'forchildin'\n");
break;
}
node = node->next;
loop++;
}
break;
}

--- End code ---

Somewhere in the while loop, before UI_ExecuteActions(..) I have to create a variable that can be accessed from within the script that references the current value of
--- Code: ---node
--- End code ---
. The attached 7z contains the modified files.

Regards,
xray

Navigation

[0] Message Index

Go to full version