MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ParseScript

Method ParseScript

neo/ui/Window.cpp:1686–1769  ·  view source on GitHub ↗

================ idWindow::ParseScript ================ */

Source from the content-addressed store, hash-verified

1684================
1685*/
1686bool idWindow::ParseScript(idParser *src, idGuiScriptList &list, int *timeParm, bool elseBlock ) {
1687
1688 bool ifElseBlock = false;
1689
1690 idToken token;
1691
1692 // scripts start with { ( unless parm is true ) and have ; separated command lists.. commands are command,
1693 // arg.. basically we want everything between the { } as it will be interpreted at
1694 // run time
1695
1696 if ( elseBlock ) {
1697 src->ReadToken ( &token );
1698
1699 if ( !token.Icmp ( "if" ) ) {
1700 ifElseBlock = true;
1701 }
1702
1703 src->UnreadToken ( &token );
1704
1705 if ( !ifElseBlock && !src->ExpectTokenString( "{" ) ) {
1706 return false;
1707 }
1708 }
1709 else if ( !src->ExpectTokenString( "{" ) ) {
1710 return false;
1711 }
1712
1713 int nest = 0;
1714
1715 while (1) {
1716 if ( !src->ReadToken(&token) ) {
1717 src->Error( "Unexpected end of file" );
1718 return false;
1719 }
1720
1721 if ( token == "{" ) {
1722 nest++;
1723 }
1724
1725 if ( token == "}" ) {
1726 if (nest-- <= 0) {
1727 return true;
1728 }
1729 }
1730
1731 idGuiScript *gs = new idGuiScript();
1732 if (token.Icmp("if") == 0) {
1733 gs->conditionReg = ParseExpression(src);
1734 gs->ifList = new idGuiScriptList();
1735 ParseScript(src, *gs->ifList, NULL);
1736 if (src->ReadToken(&token)) {
1737 if (token == "else") {
1738 gs->elseList = new idGuiScriptList();
1739 // pass true to indicate we are parsing an else condition
1740 ParseScript(src, *gs->elseList, NULL, true );
1741 } else {
1742 src->UnreadToken(&token);
1743 }

Callers

nothing calls this directly

Calls 7

IcmpMethod · 0.60
ReadTokenMethod · 0.45
UnreadTokenMethod · 0.45
ExpectTokenStringMethod · 0.45
ErrorMethod · 0.45
AppendMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected