MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / Mouse_GetOnBorderPosition

Method Mouse_GetOnBorderPosition

Source/Fodder.cpp:3280–3305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3278}
3279
3280cPosition cFodder::Mouse_GetOnBorderPosition() {
3281 cPosition BorderMouse;
3282 const cPosition WindowPos = mWindow->GetWindowPosition();
3283 const cDimension ScreenSize = mWindow->GetScreenSize();
3284 const cDimension WindowSize = mWindow->GetWindowSize();
3285 const cDimension scale = mWindow->GetScale();
3286
3287 if ((mMouseX <= MOUSE_POSITION_X_ADJUST && mMouseY <= MOUSE_POSITION_Y_ADJUST) ||
3288 (mMouseX >= ScreenSize.getWidth() + MOUSE_POSITION_X_ADJUST - 1 && mMouseY <= MOUSE_POSITION_Y_ADJUST) ||
3289 (mMouseX <= MOUSE_POSITION_X_ADJUST && mMouseY >= ScreenSize.getHeight() + MOUSE_POSITION_Y_ADJUST - 1) ||
3290 (mMouseX >= ScreenSize.getWidth() + MOUSE_POSITION_X_ADJUST - 1 && mMouseY >= ScreenSize.getHeight() + MOUSE_POSITION_Y_ADJUST - 1)) {
3291 BorderMouse.mX = mMouseX <= MOUSE_POSITION_X_ADJUST ? WindowPos.mX - 1 : WindowPos.mX + WindowSize.getWidth() + 1;
3292 BorderMouse.mY = mMouseY <= MOUSE_POSITION_Y_ADJUST ? WindowPos.mY - 1 : WindowPos.mY + WindowSize.getHeight() + 1;
3293 }
3294 // Need to check if the game cursor is near a border on X axis
3295 else if (mMouseX <= MOUSE_POSITION_X_ADJUST || mMouseX >= ScreenSize.getWidth() + MOUSE_POSITION_X_ADJUST - 1) {
3296 BorderMouse.mX = mMouseX <= MOUSE_POSITION_X_ADJUST ? WindowPos.mX - 1 : WindowPos.mX + WindowSize.getWidth() + 1;
3297 BorderMouse.mY = WindowPos.mY + (mMouseY - MOUSE_POSITION_Y_ADJUST) * scale.getHeight();
3298 } // Need to check if the game cursor is near a border Y axis
3299 else if (mMouseY <= MOUSE_POSITION_Y_ADJUST || mMouseY >= ScreenSize.getHeight() + MOUSE_POSITION_Y_ADJUST - 1) {
3300 BorderMouse.mX = WindowPos.mX + (mMouseX - MOUSE_POSITION_X_ADJUST) * scale.getWidth();
3301 BorderMouse.mY = mMouseY <= MOUSE_POSITION_Y_ADJUST ? WindowPos.mY - 1 : WindowPos.mY + WindowSize.getHeight() + 1;
3302 }
3303
3304 return BorderMouse;
3305}
3306
3307void cFodder::Mouse_Inputs_Get() {
3308

Callers

nothing calls this directly

Calls 6

GetWindowPositionMethod · 0.80
GetWindowSizeMethod · 0.80
GetScaleMethod · 0.80
GetScreenSizeMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected