MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / runSlice

Method runSlice

source/util/player.cpp:158–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void Player::runSlice() {
159 // at least 10 ms between mouse moves
160 if (this->nextCommand == "MODIFIERS") {
161 currentInputModifiers = atoi(nextValue.c_str());
162 instance->readCommand();
163 } else if (this->nextCommand == "WHILEWAITING") {
164 std::vector<BString> items;
165 this->nextValue.split(',', items);
166 timerWhileWaiting = atoi(items[0].c_str());
167 if (items.size() > 1) {
168 waitCommand = items[1];
169 }
170 if (waitCommand == "LBUTTON") {
171 if (items.size() > 3) {
172 waitMouseX = atoi(items[2].c_str());
173 waitMouseY = atoi(items[3].c_str());
174 } else {
175 waitMouseX = 1;
176 waitMouseY = 1;
177 }
178 } else if (waitCommand == "KEY") {
179 waitKey = atoi(items[2].c_str());
180 }
181 nextWaitTime = KSystem::getMilliesSinceStart() + timerWhileWaiting * 1000;
182 instance->readCommand();
183 }
184
185 if (KSystem::getMicroCounter()<this->lastCommandTime+10000)
186 return;
187
188 KNativeScreenPtr screen = KNativeSystem::getScreen();
189 KNativeInputPtr input = KNativeSystem::getCurrentInput();
190
191 if (this->nextCommand=="MOVETO") {
192 std::vector<BString> items;
193 this->nextValue.split(',', items);
194 if (items.size()!=2) {
195 klog_fmt("script: %s MOVETO should have 2 values: %s", this->directory.c_str(), this->nextValue.c_str());
196 exit(99);
197 }
198 input->mouseMove(atoi(items[0].c_str()), atoi(items[1].c_str()), false);
199 instance->readCommand();
200 return;
201 }
202 // 1000 ms between all other commands
203 if (KSystem::getMicroCounter()<this->lastCommandTime+1000000 && this->nextCommand!="MOUSEUP" && this->nextCommand!="KEYUP" && this->nextCommand != "SCREENSHOT" && !processWaitCommand)
204 return;
205 // at least 100 ms between mouse or key down/up
206 if (KSystem::getMicroCounter()<this->lastCommandTime+100000)
207 return;
208
209 // process before any other command so that button up/down and key up/down stays balanced
210 if (processWaitCommand) {
211 if (waitCommand == "LBUTTON") {
212 processWaitCommand = false;
213 this->lastCommandTime = KSystem::getMicroCounter();
214 input->mouseButton(0, 0, waitMouseX, waitMouseY);
215 klog("script WHILEWAITING LBUTTON");

Callers 1

Calls 15

klog_fmtFunction · 0.85
klogFunction · 0.85
stbi_loadFunction · 0.85
flipRGBBitmapFunction · 0.85
BFunction · 0.85
readCommandMethod · 0.80
toInt64Method · 0.80
screenShotMethod · 0.80
saveBmpMethod · 0.80
quitFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected