MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / InputWidgetLeft

Function InputWidgetLeft

src/openrct2-ui/input/MouseInput.cpp:1034–1135  ·  view source on GitHub ↗

* * rct2: 0x006E95F9 */

Source from the content-addressed store, hash-verified

1032 * rct2: 0x006E95F9
1033 */
1034 static void InputWidgetLeft(const ScreenCoordsXY& screenCoords, WindowBase* w, WidgetIndex widgetIndex)
1035 {
1036 WindowClass windowClass = WindowClass::null;
1037 WindowNumber windowNumber = 0;
1038
1039 if (w != nullptr)
1040 {
1041 windowClass = w->classification;
1042 windowNumber = w->number;
1043 }
1044
1045 auto* windowMgr = GetWindowManager();
1046 windowMgr->CloseByClass(WindowClass::error);
1047 windowMgr->CloseByClass(WindowClass::tooltip);
1048
1049 // Window might have changed position in the list, therefore find it again
1050 w = windowMgr->FindByNumber(windowClass, windowNumber);
1051 if (w == nullptr)
1052 return;
1053
1054 w = windowMgr->BringToFront(*w);
1055 if (widgetIndex == kWidgetIndexNull)
1056 return;
1057
1058 if (windowClass != GetCurrentTextBox().window.classification || windowNumber != GetCurrentTextBox().window.number
1059 || widgetIndex != GetCurrentTextBox().widgetIndex)
1060 {
1061 WindowCancelTextbox();
1062 }
1063
1064 const auto& widget = w->widgets[widgetIndex];
1065
1066 switch (widget.type)
1067 {
1068 case WidgetType::frame:
1069 case WidgetType::resize:
1070 if (w->canBeResized()
1071 && (screenCoords.x >= w->windowPos.x + w->width - 19 && screenCoords.y >= w->windowPos.y + w->height - 19))
1072 InputWindowResizeBegin(*w, widgetIndex, screenCoords);
1073 break;
1074 case WidgetType::viewport:
1075 _inputState = InputState::viewportLeft;
1076 gInputDragLast = screenCoords;
1077 _dragWidget.windowClassification = windowClass;
1078 _dragWidget.windowNumber = windowNumber;
1079 if (gInputFlags.has(InputFlag::toolActive))
1080 {
1081 w = windowMgr->FindByNumber(gCurrentToolWidget.windowClassification, gCurrentToolWidget.windowNumber);
1082 if (w != nullptr)
1083 {
1084 gInputFlags.set(InputFlag::leftMousePressed);
1085 w->onToolDown(gCurrentToolWidget.widgetIndex, screenCoords);
1086 }
1087 }
1088 break;
1089 case WidgetType::caption:
1090 InputWindowPositionBegin(*w, widgetIndex, screenCoords);
1091 break;

Callers 1

GameHandleInputMouseFunction · 0.85

Calls 15

GetWindowManagerFunction · 0.85
WindowCancelTextboxFunction · 0.85
InputWindowResizeBeginFunction · 0.85
InputWindowPositionBeginFunction · 0.85
InputScrollBeginFunction · 0.85
widgetIsDisabledFunction · 0.85
PlayFunction · 0.85
CloseByClassMethod · 0.80
canBeResizedMethod · 0.80
midXMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected