MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / parseResetTimeStatement

Method parseResetTimeStatement

plugins/dm.gui/gui/GuiScript.cpp:132–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void GuiScript::parseResetTimeStatement(parser::DefTokeniser& tokeniser)
133{
134 // Prototype: resetTime [<window>] [<time>]
135 StatementPtr st(new Statement(Statement::ST_RESET_TIME));
136
137 std::string token = tokeniser.peek();
138
139 if (token != ";")
140 {
141 // Check if this is a numeric token
142 try
143 {
144 // Remove quotes from string before checking numerics
145 std::string trimmed = string::trim_copy(token, "\"");
146
147 // Try to cast the string to a number, throws
148 std::stoul(trimmed);
149
150 // Cast succeeded this is just the time for the current window
151 st->args.push_back(_owner.parseString(tokeniser));
152 }
153 catch (std::logic_error&)
154 {
155 // Not a number, must be window plus time
156 st->args.push_back(_owner.parseString(tokeniser)); // window
157 st->args.push_back(_owner.parseString(tokeniser)); // time
158 }
159
160 // Reset statement complete, check the next token, as some
161 // GUI scripts don't bother writing an ending semicolon before the closing brace
162 std::string next = tokeniser.peek();
163
164 if (next == ";" || next == "}")
165 {
166 tokeniser.nextToken(); // exhaust
167 }
168 else
169 {
170 tokeniser.assertNextToken(";");
171 }
172 }
173
174 pushStatement(st);
175}
176
177void GuiScript::parseShowCursorStatement(parser::DefTokeniser& tokeniser)
178{

Callers

nothing calls this directly

Calls 6

trim_copyFunction · 0.85
parseStringMethod · 0.80
peekMethod · 0.45
push_backMethod · 0.45
nextTokenMethod · 0.45
assertNextTokenMethod · 0.45

Tested by

no test coverage detected