MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / pumpScriptRequests

Function pumpScriptRequests

common/script/scriptrequestpump.cpp:29–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#include "scriptrequestpump.hpp"
28
29void pumpScriptRequests(ScriptUiBridge& bridge, ScriptRequestSink& sink)
30{
31 const std::optional<UiRequest> req = bridge.take();
32 if (!req) {
33 return;
34 }
35
36 switch (req->kind) {
37 case UiRequest::Kind::Message:
38 sink.showMessage(req->prompt);
39 break;
40 case UiRequest::Kind::Confirm:
41 sink.showConfirm(req->prompt);
42 break;
43 case UiRequest::Kind::PickOne:
44 sink.showPickOne(req->prompt, req->items);
45 break;
46 case UiRequest::Kind::PickMany:
47 sink.showPickMany(req->prompt, req->items, req->preselected);
48 break;
49 case UiRequest::Kind::Keyboard: {
50 UiResponse resp;
51 // maxChars counts the terminator; the keyboards want the room left
52 // for text, and 0 means "the platform's own default".
53 resp.text = sink.keyboard(req->prompt, req->maxChars > 0 ? (size_t)req->maxChars - 1 : 0);
54 bridge.respond(std::move(resp));
55 break;
56 }
57 case UiRequest::Kind::Numpad: {
58 UiResponse resp;
59 resp.index = sink.numpad(req->prompt, req->numMin, req->numMax);
60 bridge.respond(std::move(resp));
61 break;
62 }
63 }
64}

Callers 2

updateMethod · 0.85
updateMethod · 0.85

Calls 8

takeMethod · 0.80
respondMethod · 0.80
showMessageMethod · 0.45
showConfirmMethod · 0.45
showPickOneMethod · 0.45
showPickManyMethod · 0.45
keyboardMethod · 0.45
numpadMethod · 0.45

Tested by

no test coverage detected