MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / stateWidgetPressed

Function stateWidgetPressed

src/OpenLoco/src/Input/MouseInput.cpp:925–1113  ·  view source on GitHub ↗

0x004C7AE7

Source from the content-addressed store, hash-verified

923
924 // 0x004C7AE7
925 static void stateWidgetPressed(MouseButton button, int32_t x, int32_t y, Ui::Window* window, Ui::Widget* widget, Ui::WidgetIndex_t widgetIndex)
926 {
927 _cursorPressed = { x, y };
928
929 auto pressedWindow = WindowManager::find(_pressedWindowType, _pressedWindowNumber);
930 if (pressedWindow == nullptr)
931 {
932 Input::state(State::reset);
933 return;
934 }
935
936 if (Input::state() == State::dropdownActive)
937 {
938 if (Ui::Dropdown::hasFlags(Ui::Dropdown::Flags::unk1))
939 {
940 if (widgetIndex == -1 || _pressedWindowType != window->type || _pressedWindowNumber != window->number || _pressedWidgetIndex != widgetIndex)
941 {
942 if (widgetIndex == -1 || window->type != Ui::WindowType::dropdown)
943 {
944 WindowManager::close(Ui::WindowType::dropdown, 0);
945
946 if (_pressedWindowType != Ui::WindowType::undefined)
947 {
948 WindowManager::invalidateWidget(_pressedWindowType, _pressedWindowNumber, _pressedWidgetIndex);
949 }
950
951 _pressedWindowType = Ui::WindowType::undefined;
952 Input::resetFlag(Flags::widgetPressed);
953 Input::state(State::reset);
954 return;
955 }
956 }
957 }
958 }
959
960 bool doShared = false;
961 switch (button)
962 {
963 case MouseButton::released: // 0
964 {
965 if (window == nullptr)
966 {
967 break;
968 }
969
970 if (window->type == _pressedWindowType && window->number == _pressedWindowNumber && widgetIndex == _pressedWidgetIndex)
971 {
972 if (!window->isDisabled(widgetIndex))
973 {
974 if (_clickRepeatTicks != 0)
975 {
976 _clickRepeatTicks++;
977 }
978
979 // Handle click repeat
980 if (window->isHoldable(widgetIndex) && _clickRepeatTicks >= 16 && (_clickRepeatTicks % 4) == 0)
981 {
982 window->callOnMouseDown(widgetIndex, window->widgets[widgetIndex].id);

Callers 1

handleMouseFunction · 0.85

Calls 15

findFunction · 0.85
invalidateWidgetFunction · 0.85
playSoundFunction · 0.85
dropdownIndexFromPointFunction · 0.85
setTooltipTimeoutFunction · 0.85
setWidgetIndexFunction · 0.85
setWindowTypeFunction · 0.85
setWindowNumberFunction · 0.85
setHighlightedItemFunction · 0.85
isDisabledMethod · 0.80
isHoldableMethod · 0.80

Tested by

no test coverage detected