mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Keep level editor windows in screen bounds
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "House.h"
|
||||
#include "InputManager.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "Rect2i.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
@@ -30,6 +31,7 @@ void HandleIdleTask (void);
|
||||
void IncrementMode (void);
|
||||
|
||||
|
||||
|
||||
long lastUp, incrementModeTime;
|
||||
UInt32 doubleTime;
|
||||
Point lastWhere;
|
||||
@@ -440,6 +442,22 @@ void HandleSplashResolutionChange(void)
|
||||
//DumpScreenOn(&justRoomsRect);
|
||||
}
|
||||
|
||||
void KeepWindowInBounds(Window *window)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
PortabilityLayer::Rect2i windowRect = PortabilityLayer::WindowManager::GetInstance()->GetWindowFullRect(window);
|
||||
|
||||
int32_t topNudge = std::max<int32_t>(kScoreboardTall - windowRect.Top(), 0);
|
||||
int32_t bottomNudge = std::min<int32_t>(thisMac.fullScreen.bottom - windowRect.Bottom(), 0);
|
||||
int32_t leftNudge = std::max<int32_t>(-windowRect.Left(), 0);
|
||||
int32_t rightNudge = std::min<int32_t>(thisMac.fullScreen.right - windowRect.Right(), 0);
|
||||
|
||||
window->m_wmX += leftNudge + rightNudge;
|
||||
window->m_wmY += topNudge + bottomNudge;
|
||||
}
|
||||
|
||||
void HandleEditorResolutionChange(void)
|
||||
{
|
||||
FlushResolutionChange();
|
||||
@@ -461,6 +479,10 @@ void HandleEditorResolutionChange(void)
|
||||
|
||||
if (mapWindow)
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(mapWindow, PortabilityLayer::WindowManager::GetInstance()->GetPutInFrontSentinel());
|
||||
|
||||
KeepWindowInBounds(mainWindow);
|
||||
KeepWindowInBounds(toolsWindow);
|
||||
KeepWindowInBounds(mapWindow);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HandleIdleTask
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
void DrawOnSplash (DrawSurface *surface);
|
||||
void SetPaletteToGrays (void);
|
||||
void HardDrawMainWindow (void);
|
||||
|
||||
void KeepWindowInBounds(Window *window);
|
||||
|
||||
CTabHandle theCTab;
|
||||
PixMapHandle thePMap;
|
||||
@@ -207,6 +207,8 @@ void OpenMainWindow (void)
|
||||
whichRoom = GetFirstRoomNumber();
|
||||
CopyRoomToThisRoom(whichRoom);
|
||||
ReflectCurrentRoom(false);
|
||||
|
||||
KeepWindowInBounds(mainWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ void LiveVScrollAction (ControlHandle, short);
|
||||
Boolean QueryNewRoom (void);
|
||||
void CreateNailOffscreen (void);
|
||||
void KillNailOffscreen (void);
|
||||
void KeepWindowInBounds (Window *window);
|
||||
|
||||
Rect nailSrcRect, activeRoomRect, wasActiveRoomRect;
|
||||
Rect mapHScrollRect, mapVScrollRect, mapCenterRect;
|
||||
@@ -430,6 +431,8 @@ void OpenMapWindow (void)
|
||||
CenterMapOnRoom(thisRoom->suite, thisRoom->floor);
|
||||
|
||||
UpdateMapWindow();
|
||||
|
||||
KeepWindowInBounds(mapWindow);
|
||||
}
|
||||
|
||||
UpdateMapCheckmark(true);
|
||||
|
||||
@@ -61,6 +61,7 @@ void FrameSelectedTool (DrawSurface *);
|
||||
void DrawToolName (DrawSurface *);
|
||||
void DrawToolTiles (DrawSurface *);
|
||||
void SwitchToolModes (short);
|
||||
void KeepWindowInBounds (Window *window);
|
||||
|
||||
|
||||
Rect toolsWindowRect, toolSrcRect, toolTextRect;
|
||||
@@ -350,6 +351,8 @@ void OpenToolsWindow (void)
|
||||
|
||||
SwitchToolModes(toolMode);
|
||||
toolSelected = kSelectTool;
|
||||
|
||||
KeepWindowInBounds(toolsWindow);
|
||||
}
|
||||
|
||||
UpdateToolsCheckmark(true);
|
||||
|
||||
Reference in New Issue
Block a user