Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/GUIManager.cpp
Show First 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
// We want scripts to have access to the raw input events, so they can do complex | // We want scripts to have access to the raw input events, so they can do complex | ||||
// processing when necessary (e.g. for unit selection and camera movement). | // processing when necessary (e.g. for unit selection and camera movement). | ||||
// Sometimes they'll want to be layered behind the GUI widgets (e.g. to detect mousedowns on the | // Sometimes they'll want to be layered behind the GUI widgets (e.g. to detect mousedowns on the | ||||
// visible game area), sometimes they'll want to intercepts events before the GUI (e.g. | // visible game area), sometimes they'll want to intercepts events before the GUI (e.g. | ||||
// to capture all mouse events until a mouseup after dragging). | // to capture all mouse events until a mouseup after dragging). | ||||
// So we call two separate handler functions: | // So we call two separate handler functions: | ||||
bool handled; | bool handled = false; | ||||
{ | { | ||||
PROFILE("handleInputBeforeGui"); | PROFILE("handleInputBeforeGui"); | ||||
JSContext* cx = top()->GetScriptInterface()->GetContext(); | JSContext* cx = top()->GetScriptInterface()->GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::RootedValue global(cx, top()->GetGlobalObject()); | JS::RootedValue global(cx, top()->GetGlobalObject()); | ||||
if (top()->GetScriptInterface()->CallFunction(global, "handleInputBeforeGui", handled, *ev, top()->FindObjectUnderMouse())) | if (top()->GetScriptInterface()->CallFunction(global, "handleInputBeforeGui", handled, *ev, top()->FindObjectUnderMouse())) | ||||
if (handled) | if (handled) | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator