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