mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
More editor progress
This commit is contained in:
@@ -41,4 +41,6 @@ struct __GpStaticAssertHelper<true>
|
|||||||
|
|
||||||
static const size_t GP_SYSTEM_MEMORY_ALIGNMENT = 16;
|
static const size_t GP_SYSTEM_MEMORY_ALIGNMENT = 16;
|
||||||
|
|
||||||
|
#if !defined(NDEBUG)
|
||||||
#define GP_DEBUG_CONFIG 1
|
#define GP_DEBUG_CONFIG 1
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -176,8 +176,8 @@ Boolean HouseFilter (Dialog *dial, EventRecord *event, short *item)
|
|||||||
default:
|
default:
|
||||||
mouseIs = event->where;
|
mouseIs = event->where;
|
||||||
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
||||||
if ((PtInRect(mouseIs, &houseEditText1)) ||
|
if ((houseEditText1.Contains(mouseIs)) ||
|
||||||
(PtInRect(mouseIs, &houseEditText2)))
|
(houseEditText2.Contains(mouseIs)))
|
||||||
{
|
{
|
||||||
if (houseCursorIs != kBeamCursor)
|
if (houseCursorIs != kBeamCursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ Boolean MarqueeHasHandles (short *direction, short *dist)
|
|||||||
|
|
||||||
Boolean PtInMarqueeHandle (Point where)
|
Boolean PtInMarqueeHandle (Point where)
|
||||||
{
|
{
|
||||||
return (PtInRect(where, &theMarquee.handle));
|
return theMarquee.handle.Contains(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- DrawGliderMarquee
|
//-------------------------------------------------------------- DrawGliderMarquee
|
||||||
|
|||||||
@@ -53,16 +53,16 @@ short FindObjectSelected (Point where)
|
|||||||
|
|
||||||
found = kNoObjectSelected;
|
found = kNoObjectSelected;
|
||||||
|
|
||||||
if (PtInRect(where, &initialGliderRect))
|
if (initialGliderRect.Contains(where))
|
||||||
return (kInitialGliderSelected);
|
return (kInitialGliderSelected);
|
||||||
else if (PtInRect(where, &leftStartGliderDest))
|
else if (leftStartGliderDest.Contains(where))
|
||||||
return (kLeftGliderSelected);
|
return (kLeftGliderSelected);
|
||||||
else if (PtInRect(where, &rightStartGliderDest))
|
else if (rightStartGliderDest.Contains(where))
|
||||||
return (kRightGliderSelected);
|
return (kRightGliderSelected);
|
||||||
|
|
||||||
for (i = kMaxRoomObs - 1; i >= 0; i--)
|
for (i = kMaxRoomObs - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (PtInRect(where, &roomObjectRects[i]))
|
if (roomObjectRects[i].Contains(where))
|
||||||
{
|
{
|
||||||
found = i;
|
found = i;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void DragMiniTile (DrawSurface *surface, Point mouseIs, short *newTileOver)
|
|||||||
QOffsetRect(&dragRect, mouseIs.h - mouseWas.h, 0);
|
QOffsetRect(&dragRect, mouseIs.h - mouseWas.h, 0);
|
||||||
surface->InvertFrameRect(dragRect, pattern);
|
surface->InvertFrameRect(dragRect, pattern);
|
||||||
|
|
||||||
if (PtInRect(mouseIs, &tileDest)) // is cursor in the drop rect
|
if (tileDest.Contains(mouseIs)) // is cursor in the drop rect
|
||||||
{
|
{
|
||||||
*newTileOver = (mouseIs.h - tileDest.left) / kMiniTileWide;
|
*newTileOver = (mouseIs.h - tileDest.left) / kMiniTileWide;
|
||||||
if (*newTileOver != wasTileOver)
|
if (*newTileOver != wasTileOver)
|
||||||
@@ -259,7 +259,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
|
|||||||
{
|
{
|
||||||
short newTileOver;
|
short newTileOver;
|
||||||
|
|
||||||
if (PtInRect(mouseIs, &tileSrc))
|
if (tileSrc.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
if (cursorIs != kHandCursor)
|
if (cursorIs != kHandCursor)
|
||||||
{
|
{
|
||||||
@@ -323,7 +323,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
|
|||||||
tileOver = -1;
|
tileOver = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PtInRect(mouseIs, &editTETextBox))
|
if (editTETextBox.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
if (cursorIs != kBeamCursor)
|
if (cursorIs != kBeamCursor)
|
||||||
{
|
{
|
||||||
@@ -384,7 +384,7 @@ Boolean RoomFilter (Dialog *dial, EventRecord *event, short *item)
|
|||||||
case mouseDown:
|
case mouseDown:
|
||||||
mouseIs = event->where;
|
mouseIs = event->where;
|
||||||
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
||||||
if (PtInRect(mouseIs, &tileSrc))
|
if (tileSrc.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
if (StillDown())
|
if (StillDown())
|
||||||
{
|
{
|
||||||
@@ -694,22 +694,22 @@ Boolean OriginalArtFilter (Dialog *dial, EventRecord *event, short *item)
|
|||||||
case mouseDown:
|
case mouseDown:
|
||||||
mouseIs = event->where;
|
mouseIs = event->where;
|
||||||
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
mouseIs -= dial->GetWindow()->TopLeftCoord();
|
||||||
if (PtInRect(mouseIs, &leftBound))
|
if (leftBound.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
*item = 7;
|
*item = 7;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
else if (PtInRect(mouseIs, &topBound))
|
else if (topBound.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
*item = 8;
|
*item = 8;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
else if (PtInRect(mouseIs, &rightBound))
|
else if (rightBound.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
*item = 9;
|
*item = 9;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
else if (PtInRect(mouseIs, &bottomBound))
|
else if (bottomBound.Contains(mouseIs))
|
||||||
{
|
{
|
||||||
*item = 10;
|
*item = 10;
|
||||||
return(true);
|
return(true);
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ void DrawToolTiles (DrawSurface *surface)
|
|||||||
void EraseSelectedTool (void)
|
void EraseSelectedTool (void)
|
||||||
{
|
{
|
||||||
#ifndef COMPILEDEMO
|
#ifndef COMPILEDEMO
|
||||||
DrawSurface *surface = mainWindow->GetDrawSurface();
|
DrawSurface *surface = toolsWindow->GetDrawSurface();
|
||||||
Rect theRect;
|
Rect theRect;
|
||||||
short toolIcon;
|
short toolIcon;
|
||||||
|
|
||||||
@@ -269,7 +269,6 @@ void UpdateToolsWindow (void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
DrawSurface *surface = toolsWindow->GetDrawSurface();
|
DrawSurface *surface = toolsWindow->GetDrawSurface();
|
||||||
DrawControls(toolsWindow);
|
|
||||||
|
|
||||||
DkGrayForeColor(surface);
|
DkGrayForeColor(surface);
|
||||||
surface->DrawLine(Point::Create(4, 25), Point::Create(112, 25));
|
surface->DrawLine(Point::Create(4, 25), Point::Create(112, 25));
|
||||||
@@ -353,6 +352,8 @@ void OpenToolsWindow (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateToolsCheckmark(true);
|
UpdateToolsCheckmark(true);
|
||||||
|
|
||||||
|
UpdateToolsWindow();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,7 +461,7 @@ void SwitchToolModes (short newMode)
|
|||||||
void HandleToolsClick (Point wherePt)
|
void HandleToolsClick (Point wherePt)
|
||||||
{
|
{
|
||||||
#ifndef COMPILEDEMO
|
#ifndef COMPILEDEMO
|
||||||
ControlHandle theControl;
|
PortabilityLayer::Widget *theControl;
|
||||||
short i, part, newMode, toolIcon;
|
short i, part, newMode, toolIcon;
|
||||||
|
|
||||||
if (toolsWindow == nil)
|
if (toolsWindow == nil)
|
||||||
@@ -472,10 +473,10 @@ void HandleToolsClick (Point wherePt)
|
|||||||
part = FindControl(wherePt, toolsWindow, &theControl);
|
part = FindControl(wherePt, toolsWindow, &theControl);
|
||||||
if ((theControl != nil) && (part != 0))
|
if ((theControl != nil) && (part != 0))
|
||||||
{
|
{
|
||||||
part = TrackControl(theControl, wherePt, (ControlActionUPP)-1L);
|
part = TrackControl(theControl, wherePt, nullptr);
|
||||||
if (part != 0)
|
if (part != 0)
|
||||||
{
|
{
|
||||||
newMode = GetControlValue(theControl);
|
newMode = theControl->GetState();
|
||||||
if (newMode != toolMode)
|
if (newMode != toolMode)
|
||||||
{
|
{
|
||||||
EraseSelectedTool();
|
EraseSelectedTool();
|
||||||
@@ -486,7 +487,7 @@ void HandleToolsClick (Point wherePt)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < kTotalTools; i++)
|
for (i = 0; i < kTotalTools; i++)
|
||||||
if ((PtInRect(wherePt, &toolRects[i])) && (i <= lastTool))
|
if ((toolRects[i].Contains(wherePt)) && (i <= lastTool))
|
||||||
{
|
{
|
||||||
EraseSelectedTool();
|
EraseSelectedTool();
|
||||||
toolIcon = i;
|
toolIcon = i;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public:
|
|||||||
size_t Count() const;
|
size_t Count() const;
|
||||||
const T &operator[](size_t index) const;
|
const T &operator[](size_t index) const;
|
||||||
|
|
||||||
ArrayViewIterator<T> begin() const;
|
ArrayViewIterator<const T> begin() const;
|
||||||
ArrayViewIterator<T> end() const;
|
ArrayViewIterator<const T> end() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const T *m_items;
|
const T *m_items;
|
||||||
@@ -51,7 +51,7 @@ inline size_t ArrayView<T>::Count() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T &ArrayView<T>::operator[](size_t index) const
|
inline const T &ArrayView<T>::operator[](size_t index) const
|
||||||
{
|
{
|
||||||
#if GP_DEBUG_CONFIG
|
#if GP_DEBUG_CONFIG
|
||||||
assert(index < m_count);
|
assert(index < m_count);
|
||||||
@@ -61,21 +61,21 @@ const T &ArrayView<T>::operator[](size_t index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline ArrayViewIterator<T> ArrayView<T>::begin() const
|
inline ArrayViewIterator<const T> ArrayView<T>::begin() const
|
||||||
{
|
{
|
||||||
#if GP_DEBUG_CONFIG
|
#if GP_DEBUG_CONFIG
|
||||||
return ArrayViewIterator<T>(m_items, m_count, 0);
|
return ArrayViewIterator<const T>(this->m_items, this->m_count, 0);
|
||||||
#else
|
#else
|
||||||
return ArrayViewIterator<T>(m_items);
|
return ArrayViewIterator<const T>(this->m_items);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline ArrayViewIterator<T> ArrayView<T>::end() const
|
inline ArrayViewIterator<const T> ArrayView<T>::end() const
|
||||||
{
|
{
|
||||||
#if GP_DEBUG_CONFIG
|
#if GP_DEBUG_CONFIG
|
||||||
return ArrayViewIterator<T>(m_items, m_count, m_count);
|
return ArrayViewIterator<const T>(m_items, m_count, m_count);
|
||||||
#else
|
#else
|
||||||
return ArrayViewIterator<T>(m_items + m_count);
|
return ArrayViewIterator<const T>(m_items + m_count);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "PLControlDefinitions.h"
|
#include "PLControlDefinitions.h"
|
||||||
|
#include "PLArrayView.h"
|
||||||
|
#include "PLArrayViewIterator.h"
|
||||||
|
#include "PLWidgets.h"
|
||||||
|
|
||||||
int FindControl(Point point, WindowPtr window, ControlHandle *outControl)
|
int FindControl(Point point, WindowPtr window, ControlHandle *outControl)
|
||||||
{
|
{
|
||||||
@@ -9,7 +11,21 @@ int FindControl(Point point, WindowPtr window, ControlHandle *outControl)
|
|||||||
|
|
||||||
int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outControl)
|
int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outControl)
|
||||||
{
|
{
|
||||||
PL_NotYetImplemented();
|
// Returns clicked part
|
||||||
|
ArrayView<PortabilityLayer::Widget*> widgets = window->GetWidgets();
|
||||||
|
|
||||||
|
for (ArrayViewIterator<PortabilityLayer::Widget*const> it = widgets.begin(), itEnd = widgets.end(); it != itEnd; ++it)
|
||||||
|
{
|
||||||
|
PortabilityLayer::Widget *widget = *it;
|
||||||
|
const Rect widgetRect = widget->GetRect();
|
||||||
|
if (widgetRect.Contains(point))
|
||||||
|
{
|
||||||
|
*outControl = widget;
|
||||||
|
return kControlButtonPart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*outControl = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "PLCore.h"
|
#include "PLCore.h"
|
||||||
|
|
||||||
|
#include "PLArrayView.h"
|
||||||
#include "PLApplication.h"
|
#include "PLApplication.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLKeyEncoding.h"
|
#include "PLKeyEncoding.h"
|
||||||
@@ -822,3 +824,8 @@ void Window::OnTick()
|
|||||||
for (size_t i = 0; i < m_numWidgets; i++)
|
for (size_t i = 0; i < m_numWidgets; i++)
|
||||||
m_widgets[i]->OnTick();
|
m_widgets[i]->OnTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayView<PortabilityLayer::Widget*> Window::GetWidgets() const
|
||||||
|
{
|
||||||
|
return ArrayView< PortabilityLayer::Widget*>(m_widgets, m_numWidgets);
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,11 +13,14 @@
|
|||||||
#pragma warning(error:4311) // Pointer truncation to int
|
#pragma warning(error:4311) // Pointer truncation to int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class ArrayView;
|
||||||
struct IGpColorCursor;
|
struct IGpColorCursor;
|
||||||
struct GpVOSEvent;
|
struct GpVOSEvent;
|
||||||
struct GpMouseInputEvent;
|
struct GpMouseInputEvent;
|
||||||
struct TimeTaggedVOSEvent;
|
struct TimeTaggedVOSEvent;
|
||||||
|
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
struct MMHandleBlock;
|
struct MMHandleBlock;
|
||||||
@@ -90,6 +93,8 @@ struct Window
|
|||||||
|
|
||||||
void OnTick();
|
void OnTick();
|
||||||
|
|
||||||
|
ArrayView<PortabilityLayer::Widget*> GetWidgets() const;
|
||||||
|
|
||||||
DrawSurface m_surface; // Must be the first item until the immediate mode draw API is completely removed
|
DrawSurface m_surface; // Must be the first item until the immediate mode draw API is completely removed
|
||||||
|
|
||||||
// The port is always at 0,0
|
// The port is always at 0,0
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ bool IsHighScoreDisabled()
|
|||||||
|
|
||||||
bool IsRoomEditorDisabled()
|
bool IsRoomEditorDisabled()
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsHighScoreForceTop()
|
bool IsHighScoreForceTop()
|
||||||
|
|||||||
@@ -1655,13 +1655,6 @@ Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Boolean PtInRect(Point point, const Rect *rect)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RestoreDeviceClut(void *unknown)
|
void RestoreDeviceClut(void *unknown)
|
||||||
{
|
{
|
||||||
PL_NotYetImplemented();
|
PL_NotYetImplemented();
|
||||||
|
|||||||
@@ -146,8 +146,6 @@ void SubPt(Point srcPoint, Point *destPoint);
|
|||||||
|
|
||||||
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection);
|
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection);
|
||||||
|
|
||||||
Boolean PtInRect(Point point, const Rect *rect);
|
|
||||||
|
|
||||||
void RestoreDeviceClut(void *unknown);
|
void RestoreDeviceClut(void *unknown);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user