mirror of
https://github.com/elasota/Aerofoil.git
synced 2026-02-04 10:38:52 +00:00
Various improvements toward getting high scores working again.
This commit is contained in:
@@ -46,8 +46,11 @@ size_t GpFileStream_Win32::Write(const void *bytes, size_t size)
|
||||
DWORD numWritten = 0;
|
||||
|
||||
BOOL writeSucceeded = WriteFile(m_handle, bytes, chunkSizeToWrite, &numWritten, nullptr);
|
||||
if (!writeSucceeded)
|
||||
return totalWritten;
|
||||
if (!writeSucceeded)
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
return totalWritten;
|
||||
}
|
||||
|
||||
totalWritten += static_cast<size_t>(numWritten);
|
||||
size -= static_cast<size_t>(numWritten);
|
||||
|
||||
@@ -277,7 +277,7 @@ static bool IdentifyVKey(const WPARAM &wparam, const LPARAM &lparam, GpKeyIDSubs
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PostKeyboardEvent(IGpVOSEventQueue *eventQueue, GpKeyboardInputEventType_t eventType, GpKeyIDSubset_t subset, const GpKeyboardInputEvent::KeyUnion &key)
|
||||
static void PostKeyboardEvent(IGpVOSEventQueue *eventQueue, GpKeyboardInputEventType_t eventType, GpKeyIDSubset_t subset, const GpKeyboardInputEvent::KeyUnion &key, uint32_t repeatCount)
|
||||
{
|
||||
if (GpVOSEvent *evt = eventQueue->QueueEvent())
|
||||
{
|
||||
@@ -287,6 +287,7 @@ static void PostKeyboardEvent(IGpVOSEventQueue *eventQueue, GpKeyboardInputEvent
|
||||
mEvent.m_key = key;
|
||||
mEvent.m_eventType = eventType;
|
||||
mEvent.m_keyIDSubset = subset;
|
||||
mEvent.m_repeatCount = repeatCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,8 +339,12 @@ static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue
|
||||
{
|
||||
GpKeyIDSubset_t subset;
|
||||
GpKeyboardInputEvent::KeyUnion key;
|
||||
if (IdentifyVKey(wParam, lParam, subset, key))
|
||||
PostKeyboardEvent(eventQueue, GpKeyboardInputEventTypes::kDown, subset, key);
|
||||
bool isRepeat = ((lParam & 0x40000000) != 0);
|
||||
const GpKeyboardInputEventType_t keyEventType = isRepeat ? GpKeyboardInputEventTypes::kAuto : GpKeyboardInputEventTypes::kDown;
|
||||
if (!isRepeat && IdentifyVKey(wParam, lParam, subset, key))
|
||||
PostKeyboardEvent(eventQueue, keyEventType, subset, key, static_cast<uint32_t>(lParam & 0xffff));
|
||||
|
||||
(void)TranslateMessage(msg);
|
||||
}
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
@@ -348,10 +353,26 @@ static void TranslateWindowsMessage(const MSG *msg, IGpVOSEventQueue *eventQueue
|
||||
GpKeyIDSubset_t subset;
|
||||
GpKeyboardInputEvent::KeyUnion key;
|
||||
if (IdentifyVKey(wParam, lParam, subset, key))
|
||||
PostKeyboardEvent(eventQueue, GpKeyboardInputEventTypes::kUp, subset, key);
|
||||
PostKeyboardEvent(eventQueue, GpKeyboardInputEventTypes::kUp, subset, key, (lParam & 0xffff));
|
||||
}
|
||||
break;
|
||||
case WM_CHAR:
|
||||
{
|
||||
bool isRepeat = ((lParam & 0x4000000) != 0);
|
||||
const GpKeyboardInputEventType_t keyEventType = isRepeat ? GpKeyboardInputEventTypes::kAutoChar : GpKeyboardInputEventTypes::kDownChar;
|
||||
GpKeyboardInputEvent::KeyUnion key;
|
||||
key.m_asciiChar = static_cast<char>(wParam);
|
||||
PostKeyboardEvent(eventQueue, keyEventType, GpKeyIDSubsets::kASCII, key, (lParam & 0xffff));
|
||||
}
|
||||
break;
|
||||
case WM_UNICHAR:
|
||||
{
|
||||
bool isRepeat = ((lParam & 0x4000000) != 0);
|
||||
const GpKeyboardInputEventType_t keyEventType = isRepeat ? GpKeyboardInputEventTypes::kAutoChar : GpKeyboardInputEventTypes::kDownChar;
|
||||
GpKeyboardInputEvent::KeyUnion key;
|
||||
key.m_unicodeChar = static_cast<uint32_t>(wParam);
|
||||
PostKeyboardEvent(eventQueue, keyEventType, GpKeyIDSubsets::kUnicode, key, (lParam & 0xffff));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -52,7 +52,7 @@ void DoAbout (void)
|
||||
ControlHandle itemHandle;
|
||||
short hit;
|
||||
|
||||
aboutDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kAboutDialogID, PL_GetPutInFrontWindowPtr());
|
||||
aboutDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kAboutDialogID, PL_GetPutInFrontWindowPtr(), nullptr);
|
||||
// if (aboutDialog == nil)
|
||||
// RedAlert(kErrDialogDidntLoad);
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ PLError_t DoPrintDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoPrintingAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPrintingAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPrintingAlert, nullptr);
|
||||
|
||||
return PLErrors::kInvalidParameter;
|
||||
}
|
||||
|
||||
@@ -84,16 +84,17 @@ void DrawBanner (Point *topLeft)
|
||||
short CountStarsInHouse (void)
|
||||
{
|
||||
short i, h, numRooms, numStars;
|
||||
housePtr housePtr = *thisHouse;
|
||||
|
||||
numStars = 0;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
numRooms = housePtr->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
if ((*thisHouse)->rooms[i].suite != kRoomIsEmpty)
|
||||
if (housePtr->rooms[i].suite != kRoomIsEmpty)
|
||||
for (h = 0; h < kMaxRoomObs; h++)
|
||||
{
|
||||
if ((*thisHouse)->rooms[i].objects[h].what == kStar)
|
||||
if (housePtr->rooms[i].objects[h].what == kStar)
|
||||
numStars++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "FontFamily.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define kActive 0
|
||||
#define kInactive 255
|
||||
|
||||
@@ -26,9 +28,9 @@
|
||||
// Given a dialog pointer and a resource ID, this function brings it upÉ
|
||||
// centered, visible, and with the default button outlined.
|
||||
|
||||
void BringUpDialog (Dialog **theDialog, short dialogID)
|
||||
void BringUpDialog (Dialog **theDialog, short dialogID, const DialogTextSubstitutions *substitutions)
|
||||
{
|
||||
*theDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(dialogID, kPutInFront);
|
||||
*theDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(dialogID, kPutInFront, substitutions);
|
||||
|
||||
// CenterDialog(dialogID);
|
||||
if (*theDialog == nil)
|
||||
@@ -381,12 +383,13 @@ void DrawDefaultButton (Dialog *theDialog)
|
||||
|
||||
void GetDialogString (Dialog *theDialog, short item, StringPtr theString)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
GetDialogItemText(itemHandle, theString);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
const PLPasStr str = itemRef.GetWidget()->GetString();
|
||||
|
||||
const uint8_t length = static_cast<uint8_t>(std::min<size_t>(255, str.Length()));
|
||||
|
||||
theString[0] = length;
|
||||
memcpy(theString + 1, str.UChars(), length);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetDialogString
|
||||
@@ -402,14 +405,8 @@ void SetDialogString (Dialog *theDialog, short item, const PLPasStr &theString)
|
||||
|
||||
short GetDialogStringLen (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
Str255 theString;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
GetDialogItemText(itemHandle, theString);
|
||||
return (theString[0]);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
return itemRef.GetWidget()->GetString().Length();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetDialogItemValue
|
||||
@@ -418,12 +415,8 @@ short GetDialogStringLen (Dialog *theDialog, short item)
|
||||
|
||||
void GetDialogItemValue (Dialog *theDialog, short item, short *theState)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
*theState = GetControlValue(itemHandle);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
*theState = itemRef.GetWidget()->GetState();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetDialogItemValue
|
||||
@@ -442,10 +435,11 @@ void ToggleDialogItemValue (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType, theState;
|
||||
int16_t itemType, theState;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
theState = GetControlValue(itemHandle);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
|
||||
theState = itemRef.GetWidget()->GetState();
|
||||
if (theState == 0)
|
||||
theState = 1;
|
||||
else
|
||||
@@ -465,7 +459,9 @@ void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
|
||||
short itemType;
|
||||
|
||||
NumToString(theNumber, theString);
|
||||
theDialog->GetItems()[item - 1].GetWidget()->SetString(theString);
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
|
||||
widget->SetString(theString);
|
||||
widget->DrawControl(theDialog->GetWindow()->GetDrawSurface());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetDialogNumFromStr
|
||||
@@ -475,12 +471,7 @@ void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
|
||||
void GetDialogNumFromStr (Dialog *theDialog, short item, long *theNumber)
|
||||
{
|
||||
Str255 theString;
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
GetDialogItemText(itemHandle, theString);
|
||||
GetDialogString(theDialog, item, theString);
|
||||
StringToNum(theString, theNumber);
|
||||
}
|
||||
|
||||
@@ -498,13 +489,10 @@ void GetDialogItemRect (Dialog *theDialog, short item, Rect *theRect)
|
||||
|
||||
void SetDialogItemRect (Dialog *theDialog, short item, Rect *theRect)
|
||||
{
|
||||
Rect oldRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
|
||||
OffsetRect(&oldRect, theRect->left - oldRect.left, theRect->top - oldRect.top);
|
||||
SetDialogItem(theDialog, item, itemType, itemHandle, &oldRect);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
widget->SetPosition(Point::Create(theRect->left, theRect->top));
|
||||
widget->Resize(theRect->Width(), theRect->Height());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- OffsetDialogItemRect
|
||||
@@ -512,13 +500,11 @@ void SetDialogItemRect (Dialog *theDialog, short item, Rect *theRect)
|
||||
|
||||
void OffsetDialogItemRect (Dialog *theDialog, short item, short h, short v)
|
||||
{
|
||||
Rect oldRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
|
||||
OffsetRect(&oldRect, h, v);
|
||||
SetDialogItem(theDialog, item, itemType, itemHandle, &oldRect);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
|
||||
const Rect oldRect = widget->GetRect();
|
||||
widget->SetPosition(Point::Create(oldRect.left + h, oldRect.top + v));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SelectFromRadioGroup
|
||||
@@ -553,12 +539,7 @@ void AddMenuToPopUp (Dialog *theDialog, short whichItem, MenuHandle theMenu)
|
||||
|
||||
void GetPopUpMenuValue (Dialog *theDialog, short whichItem, short *value)
|
||||
{
|
||||
Rect iRect;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
*value = GetControlValue(iHandle);
|
||||
GetDialogItemValue(theDialog, whichItem, value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetPopUpMenuValue
|
||||
@@ -566,12 +547,7 @@ void GetPopUpMenuValue (Dialog *theDialog, short whichItem, short *value)
|
||||
|
||||
void SetPopUpMenuValue (Dialog *theDialog, short whichItem, short value)
|
||||
{
|
||||
Rect iRect;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
SetControlValue(iHandle, value);
|
||||
SetDialogItemValue(theDialog, whichItem, value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- MyEnableControl
|
||||
@@ -579,12 +555,9 @@ void SetPopUpMenuValue (Dialog *theDialog, short whichItem, short value)
|
||||
|
||||
void MyEnableControl (Dialog *theDialog, short whichItem)
|
||||
{
|
||||
Rect iRect;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
|
||||
HiliteControl(iHandle, kActive);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[whichItem - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
widget->SetEnabled(true);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- MyDisableControl
|
||||
@@ -592,11 +565,9 @@ void MyEnableControl (Dialog *theDialog, short whichItem)
|
||||
|
||||
void MyDisableControl (Dialog *theDialog, short whichItem)
|
||||
{
|
||||
Rect iRect;
|
||||
ControlHandle iHandle;
|
||||
short iType;
|
||||
|
||||
theDialog->GetItems()[whichItem - 1].GetWidget()->SetEnabled(false);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[whichItem - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
widget->SetEnabled(false);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawDialogUserText
|
||||
@@ -621,13 +592,8 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
|
||||
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
|
||||
|
||||
OffsetRect(&iRect, 0, 1);
|
||||
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(iRect);
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
|
||||
OffsetRect(&iRect, 0, -1);
|
||||
|
||||
short strWidth = surface->MeasureString(stringCopy);
|
||||
inset = ((iRect.right - iRect.left) - (strWidth + 2)) / 2;
|
||||
@@ -703,13 +669,12 @@ void LoadDialogPICT (Dialog *theDialog, short item, short theID)
|
||||
|
||||
void FrameDialogItem (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
surface->FrameRect(itemRect);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
|
||||
const Rect itemRect = widget->GetRect();
|
||||
|
||||
theDialog->GetWindow()->GetDrawSurface()->FrameRect(itemRect);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- FrameDialogItemC
|
||||
@@ -731,11 +696,10 @@ void FrameDialogItemC (Dialog *theDialog, short item, long color)
|
||||
|
||||
void FrameOvalDialogItem (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
|
||||
const Rect itemRect = widget->GetRect();
|
||||
|
||||
theDialog->GetWindow()->GetDrawSurface()->FrameEllipse(itemRect);
|
||||
}
|
||||
@@ -746,16 +710,14 @@ void FrameOvalDialogItem (Dialog *theDialog, short item)
|
||||
|
||||
void BorderDialogItem (Dialog *theDialog, short item, short sides)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
// 1 = left
|
||||
// 2 = top
|
||||
// 4 = bottom
|
||||
// 8 = right ... so 6 = top & bottom, 15 = all 4 sides
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
const Rect itemRect = widget->GetRect();
|
||||
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
|
||||
@@ -793,13 +755,10 @@ void BorderDialogItem (Dialog *theDialog, short item, short sides)
|
||||
|
||||
void ShadowDialogItem (Dialog *theDialog, short item, short thickness)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
const Rect itemRect = itemRef.GetWidget()->GetRect();
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
const Point bottomLeftCorner = Point::Create(itemRect.left + thickness, itemRect.bottom);
|
||||
@@ -815,11 +774,10 @@ void ShadowDialogItem (Dialog *theDialog, short item, short thickness)
|
||||
|
||||
void EraseDialogItem (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
PortabilityLayer::Widget *widget = itemRef.GetWidget();
|
||||
|
||||
const Rect itemRect = widget->GetRect();
|
||||
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
surface->SetForeColor(StdColors::White());
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#include "PLDialogs.h"
|
||||
|
||||
struct DialogTextSubstitutions;
|
||||
|
||||
void BringUpDialog (Dialog **theDialog, short dialogID);
|
||||
void BringUpDialog (Dialog **theDialog, short dialogID, const DialogTextSubstitutions *);
|
||||
//void GetPutDialogCorner (Point *);
|
||||
//void GetGetDialogCorner (Point *);
|
||||
//void CenterDialog (short);
|
||||
|
||||
@@ -54,7 +54,7 @@ short BitchAboutColorDepth (void)
|
||||
short sheSaid;
|
||||
|
||||
// CenterAlert(kColorSwitchedAlert);
|
||||
sheSaid = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kColorSwitchedAlert);
|
||||
sheSaid = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kColorSwitchedAlert, nullptr);
|
||||
|
||||
return (sheSaid);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLTextUtils.h"
|
||||
#include "PLPasStr.h"
|
||||
@@ -57,10 +57,11 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
|
||||
|
||||
GetIndString(errMessage, rFileErrorStrings, stringIndex);
|
||||
NumToString((long)resultCode, errNumString);
|
||||
ParamText(errMessage, errNumString, fileName, PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(errMessage, errNumString, fileName);
|
||||
|
||||
// CenterAlert(rFileErrorAlert);
|
||||
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rFileErrorAlert);
|
||||
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rFileErrorAlert, &substitutions);
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ void KillAllBands (void);
|
||||
|
||||
void SaveGame2 (void); // --- SavedGames.c
|
||||
Boolean OpenSavedGame (void);
|
||||
void SaveGame (Boolean);
|
||||
//void SaveGame (Boolean);
|
||||
|
||||
void RefreshScoreboard (SInt16); // --- Scoreboard.c
|
||||
void HandleDynamicScoreboard (void);
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "House.h"
|
||||
#include "IOStream.h"
|
||||
#include "MainWindow.h"
|
||||
#include "RectUtils.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
@@ -391,6 +393,12 @@ Boolean TestHighScore (void)
|
||||
|
||||
if (placing != -1)
|
||||
{
|
||||
int64_t scoreTimestamp = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
|
||||
if (scoreTimestamp < 0)
|
||||
scoreTimestamp = 0;
|
||||
else if (scoreTimestamp > 0xffffffff)
|
||||
scoreTimestamp = 0xffffffff;
|
||||
|
||||
FlushEvents(everyEvent, 0);
|
||||
GetHighScoreName(placing + 1);
|
||||
PasStringCopy(highName, thisHousePtr->highScores.names[kMaxScores - 1]);
|
||||
@@ -400,7 +408,7 @@ Boolean TestHighScore (void)
|
||||
PasStringCopy(highBanner, thisHousePtr->highScores.banner);
|
||||
}
|
||||
thisHousePtr->highScores.scores[kMaxScores - 1] = theScore;
|
||||
GetDateTime(&thisHousePtr->highScores.timeStamps[kMaxScores - 1]);
|
||||
thisHousePtr->highScores.timeStamps[kMaxScores - 1] = static_cast<uint32_t>(scoreTimestamp);
|
||||
thisHousePtr->highScores.levels[kMaxScores - 1] = CountRoomsVisited();
|
||||
SortHighScores();
|
||||
gameDirty = true;
|
||||
@@ -422,7 +430,6 @@ void UpdateNameDialog (Dialog *theDialog)
|
||||
{
|
||||
short nChars;
|
||||
|
||||
DrawDialog(theDialog);
|
||||
DrawDefaultButton(theDialog);
|
||||
|
||||
nChars = GetDialogStringLen(theDialog, kHighNameItem);
|
||||
@@ -432,53 +439,46 @@ void UpdateNameDialog (Dialog *theDialog)
|
||||
//-------------------------------------------------------------- NameFilter
|
||||
// Dialog filter for the "Enter High Score Name" dialog.
|
||||
|
||||
Boolean NameFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
int16_t NameFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
short nChars;
|
||||
|
||||
|
||||
if (keyStroke)
|
||||
{
|
||||
nChars = GetDialogStringLen(dial, kHighNameItem);
|
||||
SetDialogNumToStr(dial, kNameNCharsItem, (long)nChars);
|
||||
keyStroke = false;
|
||||
}
|
||||
|
||||
switch (event->what)
|
||||
|
||||
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
|
||||
{
|
||||
case keyDown:
|
||||
keyStroke = true;
|
||||
switch (event->message)
|
||||
const GpKeyboardInputEvent &kbEvent = evt.m_vosEvent.m_event.m_keyboardInputEvent;
|
||||
|
||||
if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDownChar || kbEvent.m_eventType == GpKeyboardInputEventTypes::kAutoChar)
|
||||
{
|
||||
PlayPrioritySound(kTypingSound, kTypingPriority);
|
||||
return -1; // Don't capture, need this to forward to the editbox
|
||||
}
|
||||
else if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDown)
|
||||
{
|
||||
const intptr_t keyCode = PackVOSKeyCode(kbEvent);
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case PL_KEY_SPECIAL(kEnter):
|
||||
case PL_KEY_NUMPAD_SPECIAL(kEnter):
|
||||
PlayPrioritySound(kCarriageSound, kCarriagePriority);
|
||||
FlashDialogButton(dial, kOkayButton);
|
||||
*item = kOkayButton;
|
||||
return(true);
|
||||
break;
|
||||
|
||||
PlayPrioritySound(kCarriageSound, kCarriagePriority);
|
||||
FlashDialogButton(dial, kOkayButton);
|
||||
return kOkayButton;
|
||||
|
||||
case PL_KEY_SPECIAL(kTab):
|
||||
SelectDialogItemText(dial, kHighNameItem, 0, 1024);
|
||||
return(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
PlayPrioritySound(kTypingSound, kTypingPriority);
|
||||
return(false);
|
||||
SelectDialogItemText(dial, kHighNameItem, 0, 1024);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
UpdateNameDialog(dial);
|
||||
EndUpdate(dial->GetWindow());
|
||||
event->what = nullEvent;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetHighScoreName
|
||||
@@ -494,17 +494,21 @@ void GetHighScoreName (short place)
|
||||
InitCursor();
|
||||
NumToString(theScore, scoreStr);
|
||||
NumToString((long)place, placeStr);
|
||||
ParamText(scoreStr, placeStr, thisHouseName, PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(scoreStr, placeStr, thisHouseName);
|
||||
|
||||
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
|
||||
BringUpDialog(&theDial, kHighNameDialogID);
|
||||
BringUpDialog(&theDial, kHighNameDialogID, &substitutions);
|
||||
FlushEvents(everyEvent, 0);
|
||||
SetDialogString(theDial, kHighNameItem, highName);
|
||||
SelectDialogItemText(theDial, kHighNameItem, 0, 1024);
|
||||
leaving = false;
|
||||
|
||||
|
||||
UpdateNameDialog(theDial);
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
ModalDialog(NameFilter, &item);
|
||||
item = theDial->ExecuteModal(NameFilter);
|
||||
|
||||
if (item == kOkayButton)
|
||||
{
|
||||
@@ -597,7 +601,7 @@ void GetHighScoreBanner (void)
|
||||
Boolean leaving;
|
||||
|
||||
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
|
||||
BringUpDialog(&theDial, kHighBannerDialogID);
|
||||
BringUpDialog(&theDial, kHighBannerDialogID, nullptr);
|
||||
SetDialogString(theDial, kHighBannerItem, highBanner);
|
||||
SelectDialogItemText(theDial, kHighBannerItem, 0, 1024);
|
||||
leaving = false;
|
||||
|
||||
@@ -653,7 +653,7 @@ Boolean GoToFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
short item, roomToGoTo;
|
||||
Boolean leaving, canceled;
|
||||
|
||||
BringUpDialog(&theDialog, kGoToDialogID);
|
||||
BringUpDialog(&theDialog, kGoToDialogID, nullptr);
|
||||
|
||||
if (GetFirstRoomNumber() == thisRoomNumber)
|
||||
MyDisableControl(theDialog, kGoToFirstButt);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLMovies.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLStringCompare.h"
|
||||
@@ -436,11 +436,19 @@ void ByteSwapClutter(clutterType *clutter)
|
||||
PortabilityLayer::ByteSwap::BigInt16(clutter->pict);
|
||||
}
|
||||
|
||||
void ByteSwapObject(objectType *obj)
|
||||
void ByteSwapObject(objectType *obj, bool isSwappedAfter)
|
||||
{
|
||||
int16_t objWhat = 0;
|
||||
|
||||
if (isSwappedAfter)
|
||||
objWhat = obj->what;
|
||||
|
||||
PortabilityLayer::ByteSwap::BigInt16(obj->what);
|
||||
|
||||
switch (obj->what)
|
||||
if (!isSwappedAfter)
|
||||
objWhat = obj->what;
|
||||
|
||||
switch (objWhat)
|
||||
{
|
||||
case kFloorVent:
|
||||
case kCeilingVent:
|
||||
@@ -590,7 +598,7 @@ void ByteSwapObject(objectType *obj)
|
||||
};
|
||||
}
|
||||
|
||||
void ByteSwapRoom(roomType *room)
|
||||
void ByteSwapRoom(roomType *room, bool isSwappedAfter)
|
||||
{
|
||||
SanitizePascalStr(room->name);
|
||||
|
||||
@@ -606,11 +614,16 @@ void ByteSwapRoom(roomType *room)
|
||||
PortabilityLayer::ByteSwap::BigInt16(room->openings);
|
||||
PortabilityLayer::ByteSwap::BigInt16(room->numObjects);
|
||||
for (int i = 0; i < kMaxRoomObs; i++)
|
||||
ByteSwapObject(room->objects + i);
|
||||
ByteSwapObject(room->objects + i, isSwappedAfter);
|
||||
}
|
||||
|
||||
bool ByteSwapHouse(housePtr house, size_t sizeInBytes)
|
||||
bool ByteSwapHouse(housePtr house, size_t sizeInBytes, bool isSwappedAfter)
|
||||
{
|
||||
size_t nRooms = 0;
|
||||
|
||||
if (isSwappedAfter)
|
||||
nRooms = house->nRooms;
|
||||
|
||||
PortabilityLayer::ByteSwap::BigInt16(house->version);
|
||||
PortabilityLayer::ByteSwap::BigInt16(house->unusedShort);
|
||||
PortabilityLayer::ByteSwap::BigInt32(house->timeStamp);
|
||||
@@ -623,13 +636,15 @@ bool ByteSwapHouse(housePtr house, size_t sizeInBytes)
|
||||
PortabilityLayer::ByteSwap::BigInt16(house->firstRoom);
|
||||
PortabilityLayer::ByteSwap::BigInt16(house->nRooms);
|
||||
|
||||
if (!isSwappedAfter)
|
||||
nRooms = house->nRooms;
|
||||
|
||||
const size_t roomDataSize = sizeInBytes - houseType::kBinaryDataSize;
|
||||
if (house->nRooms < 0 || roomDataSize / sizeof(roomType) < static_cast<size_t>(house->nRooms))
|
||||
if (nRooms < 0 || roomDataSize / sizeof(roomType) < nRooms)
|
||||
return false;
|
||||
|
||||
const size_t nRooms = static_cast<size_t>(house->nRooms);
|
||||
for (size_t i = 0; i < nRooms; i++)
|
||||
ByteSwapRoom(house->rooms + i);
|
||||
ByteSwapRoom(house->rooms + i, isSwappedAfter);
|
||||
|
||||
house->padding = 0;
|
||||
|
||||
@@ -707,7 +722,7 @@ Boolean ReadHouse (void)
|
||||
memmove((*thisHouse)->rooms, houseDataBytes + houseType::kBinaryDataSize, roomDataSize);
|
||||
}
|
||||
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
|
||||
numberRooms = (*thisHouse)->nRooms;
|
||||
#ifdef COMPILEDEMO
|
||||
@@ -815,26 +830,26 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
(*thisHouse)->version = wasHouseVersion;
|
||||
}
|
||||
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
|
||||
long headerSize = houseType::kBinaryDataSize;
|
||||
long roomsSize = sizeof(roomType) * (*thisHouse)->nRooms;
|
||||
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), true);
|
||||
|
||||
if (houseStream->Write(*thisHouse, headerSize) != headerSize)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (houseStream->Write((*thisHouse)->rooms, roomsSize) != roomsSize)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
return(false);
|
||||
}
|
||||
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
|
||||
if (!houseStream->Truncate(byteCount))
|
||||
{
|
||||
@@ -935,8 +950,8 @@ Boolean QuerySaveChanges (void)
|
||||
|
||||
InitCursor();
|
||||
// CenterAlert(kSaveChangesAlert);
|
||||
ParamText(thisHouseName, PSTR(""), PSTR(""), PSTR(""));
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveChangesAlert);
|
||||
DialogTextSubstitutions substitutions(thisHouseName);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveChangesAlert, &substitutions);
|
||||
if (hitWhat == kSaveChanges)
|
||||
{
|
||||
if (wasHouseVersion < kHouseVersion)
|
||||
@@ -981,9 +996,9 @@ void YellowAlert (short whichAlert, short identifier)
|
||||
NumToString((long)identifier, errNumStr);
|
||||
|
||||
// CenterAlert(kYellowAlert);
|
||||
ParamText(errStr, errNumStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(errStr, errNumStr);
|
||||
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kYellowAlert);
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kYellowAlert, &substitutions);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- IsFileReadOnly
|
||||
|
||||
@@ -224,11 +224,11 @@ void DoHouseInfo (void)
|
||||
NumToString((long)version >> 8, versStr); // Convert version to two stringsÉ
|
||||
NumToString((long)version % 0x0100, loVers); // the 1's and 1/10th's part.
|
||||
NumToString((long)numRooms, nRoomsStr); // Number of rooms -> string.
|
||||
|
||||
ParamText(versStr, loVers, nRoomsStr, PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(versStr, loVers, nRoomsStr);
|
||||
|
||||
// CenterDialog(kHouseInfoDialogID);
|
||||
houseInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kHouseInfoDialogID, kPutInFront);
|
||||
houseInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kHouseInfoDialogID, kPutInFront, &substitutions);
|
||||
if (houseInfoDialog == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetPort((GrafPtr)houseInfoDialog);
|
||||
@@ -297,7 +297,7 @@ Boolean WarnLockingHouse (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kLockHouseAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kLockHouseAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kLockHouseAlert, nullptr);
|
||||
|
||||
return (hitWhat == 1);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ void HowToZeroScores (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kZeroScoresAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kZeroScoresAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kZeroScoresAlert, nullptr);
|
||||
|
||||
switch (hitWhat)
|
||||
{
|
||||
|
||||
@@ -469,7 +469,7 @@ Boolean QuerySaveGame (void)
|
||||
InitCursor();
|
||||
FlushEvents(everyEvent, 0);
|
||||
// CenterAlert(kSaveGameAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
|
||||
if (hitWhat == kYesSaveGameButton)
|
||||
return (true);
|
||||
else
|
||||
|
||||
@@ -727,7 +727,7 @@ Boolean QueryNewRoom (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNewRoomAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewRoomAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewRoomAlert, nullptr);
|
||||
if (hitWhat == kYesDoNewRoom)
|
||||
return (true);
|
||||
else
|
||||
|
||||
@@ -733,13 +733,15 @@ short QueryResumeGame (void)
|
||||
hadGliders = thisHousePtr->savedGame.numGliders;
|
||||
NumToString(hadPoints, scoreStr); // param text strings
|
||||
NumToString((long)hadGliders, glidStr);
|
||||
|
||||
DialogTextSubstitutions substitutions;
|
||||
if (hadGliders == 1)
|
||||
ParamText(glidStr, PSTR(""), scoreStr, PSTR(""));
|
||||
substitutions = DialogTextSubstitutions(glidStr, PSTR(""), scoreStr);
|
||||
else
|
||||
ParamText(glidStr, PSTR("s"), scoreStr, PSTR(""));
|
||||
substitutions = DialogTextSubstitutions(glidStr, PSTR("s"), scoreStr);
|
||||
|
||||
// CenterDialog(kResumeGameDial);
|
||||
theDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kResumeGameDial, kPutInFront);
|
||||
theDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kResumeGameDial, kPutInFront, &substitutions);
|
||||
if (theDial == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetPort((GrafPtr)theDial);
|
||||
@@ -786,7 +788,7 @@ void HeyYourPissingAHighScore (void)
|
||||
|
||||
// CenterAlert(kNoHighScoreAlert);
|
||||
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoHighScoreAlert);
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoHighScoreAlert, nullptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- OpenCloseEditWindows
|
||||
|
||||
@@ -387,6 +387,6 @@ void TellHerNoMusic (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoMemForMusicAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForMusicAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForMusicAlert, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -875,7 +875,7 @@ void ShoutNoMoreObjects (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoMoreObjectsAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreObjectsAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreObjectsAlert, nullptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HowManyCandleObjects
|
||||
@@ -1072,7 +1072,7 @@ void ShoutNoMoreSpecialObjects (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoMoreSpecialAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreSpecialAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreSpecialAlert, nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -940,10 +940,11 @@ void DoBlowerObjectInfo (short what)
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
NumToString(thisRoom->objects[objActive].data.a.distance, distStr);
|
||||
ParamText(numberStr, kindStr, distStr, PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr, distStr);
|
||||
|
||||
// CenterDialog(kBlowerInfoDialogID);
|
||||
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kBlowerInfoDialogID, kPutInFront);
|
||||
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kBlowerInfoDialogID, kPutInFront, &substitutions);
|
||||
if (infoDial == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetPort((GrafPtr)infoDial);
|
||||
@@ -1126,9 +1127,10 @@ void DoFurnitureObjectInfo (void)
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
}
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kFurnitureInfoDialogID);
|
||||
BringUpDialog(&infoDial, kFurnitureInfoDialogID, &substitutions);
|
||||
|
||||
if ((objActive < 0) || (retroLinkList[objActive].room == -1))
|
||||
HideDialogItem(infoDial, 6);
|
||||
@@ -1170,12 +1172,15 @@ void DoCustPictObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
|
||||
DialogTextSubstitutions substitutions;
|
||||
|
||||
if (thisRoom->objects[objActive].what == kCustomPict)
|
||||
ParamText(numberStr, kindStr, PSTR("PICT"), PSTR("10000"));
|
||||
substitutions = DialogTextSubstitutions(numberStr, kindStr, PSTR("PICT"), PSTR("10000"));
|
||||
else
|
||||
ParamText(numberStr, kindStr, PSTR("Sound"), PSTR("3000"));
|
||||
substitutions = DialogTextSubstitutions(numberStr, kindStr, PSTR("Sound"), PSTR("3000"));
|
||||
|
||||
BringUpDialog(&infoDial, kCustPictInfoDialogID);
|
||||
BringUpDialog(&infoDial, kCustPictInfoDialogID, &substitutions);
|
||||
if (thisRoom->objects[objActive].what == kCustomPict)
|
||||
{
|
||||
wasPict = (long)(thisRoom->objects[objActive].data.g.height);
|
||||
@@ -1277,11 +1282,11 @@ void DoSwitchObjectInfo (void)
|
||||
PasStringCopy(PSTR("none"), objStr);
|
||||
else
|
||||
NumToString((long)thisRoom->objects[objActive].data.e.who + 1, objStr);
|
||||
|
||||
ParamText(numberStr, kindStr, roomStr, objStr);
|
||||
|
||||
newType = thisRoom->objects[objActive].data.e.type;
|
||||
|
||||
BringUpDialog(&infoDial, kSwitchInfoDialogID);
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr, roomStr, objStr);
|
||||
BringUpDialog(&infoDial, kSwitchInfoDialogID, &substitutions);
|
||||
leaving = false;
|
||||
doLink = false;
|
||||
doGoTo = false;
|
||||
@@ -1396,11 +1401,11 @@ void DoTriggerObjectInfo (void)
|
||||
PasStringCopy(PSTR("none"), objStr);
|
||||
else
|
||||
NumToString((long)thisRoom->objects[objActive].data.e.who + 1, objStr);
|
||||
|
||||
ParamText(numberStr, kindStr, roomStr, objStr);
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr, roomStr, objStr);
|
||||
newType = thisRoom->objects[objActive].data.e.type;
|
||||
|
||||
BringUpDialog(&infoDial, kTriggerInfoDialogID);
|
||||
BringUpDialog(&infoDial, kTriggerInfoDialogID, &substitutions);
|
||||
leaving = false;
|
||||
doLink = false;
|
||||
doGoTo = false;
|
||||
@@ -1532,10 +1537,11 @@ void DoLightObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
// CenterDialog(kLightInfoDialogID);
|
||||
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kLightInfoDialogID, kPutInFront);
|
||||
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kLightInfoDialogID, kPutInFront, &substitutions);
|
||||
if (infoDial == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetPort((GrafPtr)infoDial);
|
||||
@@ -1615,9 +1621,9 @@ void DoApplianceObjectInfo (short what)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kApplianceInfoDialogID);
|
||||
BringUpDialog(&infoDial, kApplianceInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 10);
|
||||
@@ -1726,9 +1732,9 @@ void DoMicrowaveObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kMicrowaveInfoDialogID);
|
||||
BringUpDialog(&infoDial, kMicrowaveInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 11);
|
||||
@@ -1846,9 +1852,9 @@ void DoGreaseObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kGreaseInfoDialogID);
|
||||
BringUpDialog(&infoDial, kGreaseInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 8);
|
||||
@@ -1916,7 +1922,7 @@ void DoInvisBonusObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
switch (thisRoom->objects[objActive].data.c.points)
|
||||
{
|
||||
@@ -1933,7 +1939,7 @@ void DoInvisBonusObjectInfo (void)
|
||||
break;
|
||||
}
|
||||
|
||||
BringUpDialog(&infoDial, kInvisBonusInfoDialogID);
|
||||
BringUpDialog(&infoDial, kInvisBonusInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 9);
|
||||
@@ -2040,10 +2046,10 @@ void DoTransObjectInfo (short what)
|
||||
PasStringCopy(PSTR("none"), objStr);
|
||||
else
|
||||
NumToString((long)thisRoom->objects[objActive].data.d.who + 1, objStr);
|
||||
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr, roomStr, objStr);
|
||||
|
||||
ParamText(numberStr, kindStr, roomStr, objStr);
|
||||
|
||||
BringUpDialog(&infoDial, kTransInfoDialogID);
|
||||
BringUpDialog(&infoDial, kTransInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 12);
|
||||
@@ -2145,9 +2151,9 @@ void DoEnemyObjectInfo (short what)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kEnemyInfoDialogID);
|
||||
BringUpDialog(&infoDial, kEnemyInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 11);
|
||||
@@ -2250,9 +2256,9 @@ void DoFlowerObjectInfo (void)
|
||||
|
||||
NumToString(objActive + 1, numberStr);
|
||||
GetIndString(kindStr, kObjectNameStrings, thisRoom->objects[objActive].what);
|
||||
ParamText(numberStr, kindStr, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(numberStr, kindStr);
|
||||
|
||||
BringUpDialog(&infoDial, kFlowerInfoDialogID);
|
||||
BringUpDialog(&infoDial, kFlowerInfoDialogID, &substitutions);
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 13);
|
||||
|
||||
@@ -184,6 +184,6 @@ void BringUpDeletePrefsAlert (void)
|
||||
|
||||
InitCursor();
|
||||
// CenterAlert(kNewPrefsAlertID);
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewPrefsAlertID);
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewPrefsAlertID, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ Boolean QueryDeleteRoom (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kDeleteRoomAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kDeleteRoomAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kDeleteRoomAlert, nullptr);
|
||||
if (hitWhat == kYesDoDeleteRoom)
|
||||
return (true);
|
||||
else
|
||||
|
||||
@@ -447,7 +447,7 @@ void DoRoomInfo (void)
|
||||
NumToString(thisRoom->floor, floorStr);
|
||||
NumToString(thisRoom->suite, suiteStr);
|
||||
NumToString(thisRoom->numObjects, objectsStr);
|
||||
ParamText(floorStr, suiteStr, objectsStr, PSTR(""));
|
||||
DialogTextSubstitutions substitutions(floorStr, suiteStr, objectsStr);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tileSrcMap, &tileSrcRect, kPreferredPixelFormat);
|
||||
// CreateOffScreenPixMap(&tileSrcRect, &tileSrcMap);
|
||||
@@ -467,7 +467,7 @@ void DoRoomInfo (void)
|
||||
tempTiles[i] = thisRoom->tiles[i];
|
||||
|
||||
// CenterDialog(kRoomInfoDialogID);
|
||||
roomInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kRoomInfoDialogID, kPutInFront);
|
||||
roomInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kRoomInfoDialogID, kPutInFront, &substitutions);
|
||||
if (roomInfoDialog == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetPort((GrafPtr)roomInfoDialog);
|
||||
@@ -751,7 +751,7 @@ short ChooseOriginalArt (short was)
|
||||
was = kUserBackground;
|
||||
|
||||
InitCursor();
|
||||
BringUpDialog(&theDialog, kOriginalArtDialogID);
|
||||
BringUpDialog(&theDialog, kOriginalArtDialogID, nullptr);
|
||||
if (was >= kOriginalArtworkItem)
|
||||
{
|
||||
newPictID = was;
|
||||
@@ -930,7 +930,7 @@ void BitchAboutPICTNotFound (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoPICTFoundAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPICTFoundAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPICTFoundAlert, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLStringCompare.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Externs.h"
|
||||
@@ -164,9 +164,9 @@ void SavedGameMismatchError (StringPtr gameName)
|
||||
InitCursor();
|
||||
|
||||
// CenterAlert(kSavedGameErrorAlert);
|
||||
ParamText(gameName, thisHouseName, PSTR(""), PSTR(""));
|
||||
DialogTextSubstitutions substitutions(gameName, thisHouseName, PSTR(""), PSTR(""));
|
||||
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSavedGameErrorAlert);
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSavedGameErrorAlert, &substitutions);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- OpenSavedGame
|
||||
@@ -305,7 +305,7 @@ Boolean OpenSavedGame (void)
|
||||
|
||||
// This is probably about 3 days away from becoming the "old" functionÉ
|
||||
// for saving games.
|
||||
|
||||
#if 0
|
||||
void SaveGame (Boolean doSave)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
@@ -351,4 +351,4 @@ void SaveGame (Boolean doSave)
|
||||
YellowAlert(kYellowFailedWrite, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -349,7 +349,7 @@ void DoLoadHouse (void)
|
||||
short i, wasIndex, screenCount;
|
||||
Boolean leaving, whoCares;
|
||||
|
||||
BringUpDialog(&theDial, kLoadHouseDialogID);
|
||||
BringUpDialog(&theDial, kLoadHouseDialogID, nullptr);
|
||||
|
||||
DrawSurface *surface = theDial->GetWindow()->GetDrawSurface();
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "PLArrayView.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTextUtils.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "PLWidgets.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
@@ -62,12 +64,12 @@
|
||||
|
||||
void SetBrainsToDefaults (Dialog *);
|
||||
void UpdateSettingsBrains (Dialog *);
|
||||
Boolean BrainsFilter (Dialog *, EventRecord *, short *);
|
||||
int16_t BrainsFilter (Dialog *, const TimeTaggedVOSEvent &);
|
||||
void DoBrainsPrefs (void);
|
||||
void SetControlsToDefaults (Dialog *);
|
||||
void UpdateControlKeyName (Dialog *);
|
||||
void UpdateSettingsControl (Dialog *);
|
||||
Boolean ControlFilter (Dialog *, EventRecord *, short *);
|
||||
int16_t ControlFilter (Dialog *, const TimeTaggedVOSEvent &);
|
||||
void DoControlPrefs (void);
|
||||
void SoundDefaults (Dialog *);
|
||||
void UpdateSettingsSound (Dialog *);
|
||||
@@ -133,7 +135,6 @@ void SetBrainsToDefaults (Dialog *theDialog)
|
||||
|
||||
void UpdateSettingsBrains (Dialog *theDialog)
|
||||
{
|
||||
DrawDialog(theDialog);
|
||||
DrawDefaultButton(theDialog);
|
||||
|
||||
SetDialogNumToStr(theDialog, kMaxFilesItem, (long)willMaxFiles);
|
||||
@@ -144,78 +145,48 @@ void UpdateSettingsBrains (Dialog *theDialog)
|
||||
|
||||
//-------------------------------------------------------------- BrainsFilter
|
||||
|
||||
Boolean BrainsFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
int16_t BrainsFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
switch (event->what)
|
||||
if (evt.IsKeyDownEvent())
|
||||
{
|
||||
case keyDown:
|
||||
switch (event->message)
|
||||
intptr_t keyCode = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case PL_KEY_SPECIAL(kEnter):
|
||||
case PL_KEY_NUMPAD_SPECIAL(kEnter):
|
||||
case PL_KEY_SPECIAL(kEnter):
|
||||
case PL_KEY_NUMPAD_SPECIAL(kEnter):
|
||||
FlashDialogButton(dial, kOkayButton);
|
||||
*item = kOkayButton;
|
||||
return(true);
|
||||
break;
|
||||
return kOkayButton;
|
||||
|
||||
case PL_KEY_SPECIAL(kEscape):
|
||||
case PL_KEY_SPECIAL(kEscape):
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
break;
|
||||
return kCancelButton;
|
||||
|
||||
case PL_KEY_ASCII('A'):
|
||||
*item = kDoDemoCheck;
|
||||
return(true);
|
||||
break;
|
||||
case PL_KEY_ASCII('A'):
|
||||
return kDoDemoCheck;
|
||||
|
||||
case PL_KEY_ASCII('B'):
|
||||
*item = kDoBackgroundCheck;
|
||||
return(true);
|
||||
break;
|
||||
case PL_KEY_ASCII('B'):
|
||||
return kDoBackgroundCheck;
|
||||
|
||||
case PL_KEY_ASCII('D'):
|
||||
*item = kBrainsDefault;
|
||||
case PL_KEY_ASCII('D'):
|
||||
FlashDialogButton(dial, kBrainsDefault);
|
||||
return(true);
|
||||
break;
|
||||
return kBrainsDefault;
|
||||
|
||||
case PL_KEY_ASCII('E'):
|
||||
*item = kDoErrorCheck;
|
||||
return(true);
|
||||
break;
|
||||
case PL_KEY_ASCII('E'):
|
||||
return kDoErrorCheck;
|
||||
|
||||
case PL_KEY_ASCII('Q'):
|
||||
*item = kQuickTransitCheck;
|
||||
return(true);
|
||||
break;
|
||||
case PL_KEY_ASCII('Q'):
|
||||
return kQuickTransitCheck;
|
||||
|
||||
case PL_KEY_ASCII('Z'):
|
||||
return kDoZoomsCheck;
|
||||
|
||||
case PL_KEY_ASCII('Z'):
|
||||
*item = kDoZoomsCheck;
|
||||
return(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case mouseDown:
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
SetPortDialogPort(dial);
|
||||
UpdateSettingsBrains(dial);
|
||||
EndUpdate(dial->GetWindow());
|
||||
event->what = nullEvent;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DoBrainsPrefs
|
||||
@@ -227,7 +198,7 @@ void DoBrainsPrefs (void)
|
||||
short itemHit, wasMaxFiles;
|
||||
Boolean leaving;
|
||||
|
||||
BringUpDialog(&prefDlg, kBrainsPrefsDialID);
|
||||
BringUpDialog(&prefDlg, kBrainsPrefsDialID, nullptr);
|
||||
leaving = false;
|
||||
wasMaxFiles = willMaxFiles;
|
||||
|
||||
@@ -246,10 +217,12 @@ void DoBrainsPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kDoErrorCheck, (short)wasErrorCheck);
|
||||
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
|
||||
|
||||
UpdateSettingsBrains(prefDlg);
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
ModalDialog(BrainsFilter, &itemHit);
|
||||
itemHit = prefDlg->ExecuteModal(BrainsFilter);
|
||||
switch (itemHit)
|
||||
{
|
||||
case kOkayButton:
|
||||
@@ -354,8 +327,6 @@ void UpdateSettingsControl (Dialog *theDialog)
|
||||
short i;
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
|
||||
DrawDialog(theDialog);
|
||||
|
||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -382,123 +353,108 @@ void UpdateSettingsControl (Dialog *theDialog)
|
||||
|
||||
//-------------------------------------------------------------- ControlFilter
|
||||
|
||||
Boolean ControlFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
int16_t ControlFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
intptr_t wasKeyMap;
|
||||
|
||||
switch (event->what)
|
||||
|
||||
if (evt.IsKeyDownEvent())
|
||||
{
|
||||
case keyDown:
|
||||
switch (whichCtrl)
|
||||
GpKeyIDSubset_t subset = evt.m_vosEvent.m_event.m_keyboardInputEvent.m_keyIDSubset;
|
||||
|
||||
// Ignore Unicode (for now) and gamepad buttons
|
||||
if (subset == GpKeyIDSubsets::kASCII || subset == GpKeyIDSubsets::kSpecial || subset == GpKeyIDSubsets::kNumPadNumber || subset == GpKeyIDSubsets::kNumPadSpecial || subset == GpKeyIDSubsets::kFKey)
|
||||
{
|
||||
wasKeyMap = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
|
||||
|
||||
switch (whichCtrl)
|
||||
{
|
||||
case 0:
|
||||
wasKeyMap = event->message;
|
||||
if ((wasKeyMap == tempLeftMap) || (wasKeyMap == tempBattMap) ||
|
||||
(wasKeyMap == tempBandMap) || (wasKeyMap == PL_KEY_SPECIAL(kTab)) ||
|
||||
if ((wasKeyMap == tempLeftMap) || (wasKeyMap == tempBattMap) ||
|
||||
(wasKeyMap == tempBandMap) || (wasKeyMap == PL_KEY_SPECIAL(kTab)) ||
|
||||
(wasKeyMap == PL_KEY_SPECIAL(kEscape)) || (wasKeyMap == PL_KEY_SPECIAL(kDelete)))
|
||||
{
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
return kCancelButton;
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetKeyName(event->message, tempRightStr);
|
||||
tempRightMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
{
|
||||
GetKeyName(wasKeyMap, tempRightStr);
|
||||
tempRightMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
wasKeyMap = event->message;
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempBattMap) ||
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempBattMap) ||
|
||||
(wasKeyMap == tempBandMap) || (wasKeyMap == PL_KEY_SPECIAL(kTab)) ||
|
||||
(wasKeyMap == PL_KEY_SPECIAL(kEscape)) || (wasKeyMap == PL_KEY_SPECIAL(kDelete)))
|
||||
{
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
return kCancelButton;
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetKeyName(event->message, tempLeftStr);
|
||||
tempLeftMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
{
|
||||
GetKeyName(wasKeyMap, tempLeftStr);
|
||||
tempLeftMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
wasKeyMap = event->message;
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempLeftMap) ||
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempLeftMap) ||
|
||||
(wasKeyMap == tempBandMap) || (wasKeyMap == PL_KEY_SPECIAL(kTab)) ||
|
||||
(wasKeyMap == PL_KEY_SPECIAL(kEscape)) || (wasKeyMap == PL_KEY_SPECIAL(kDelete)))
|
||||
{
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
return kCancelButton;
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetKeyName(event->message, tempBattStr);
|
||||
tempBattMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
{
|
||||
GetKeyName(wasKeyMap, tempBattStr);
|
||||
tempBattMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
wasKeyMap = event->message;
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempLeftMap) ||
|
||||
if ((wasKeyMap == tempRightMap) || (wasKeyMap == tempLeftMap) ||
|
||||
(wasKeyMap == tempBattMap) || (wasKeyMap == PL_KEY_SPECIAL(kTab)) ||
|
||||
(wasKeyMap == PL_KEY_SPECIAL(kEscape)) || (wasKeyMap == PL_KEY_SPECIAL(kDelete)))
|
||||
{
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
if (wasKeyMap == PL_KEY_SPECIAL(kEscape))
|
||||
{
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
return kCancelButton;
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
}
|
||||
else
|
||||
SysBeep(1);
|
||||
{
|
||||
GetKeyName(wasKeyMap, tempBandStr);
|
||||
tempBandMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetKeyName(event->message, tempBandStr);
|
||||
tempBandMap = wasKeyMap;
|
||||
}
|
||||
break;
|
||||
UpdateControlKeyName(dial);
|
||||
return -1;
|
||||
}
|
||||
UpdateControlKeyName(dial);
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case mouseDown:
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
SetPortDialogPort(dial);
|
||||
UpdateSettingsControl(dial);
|
||||
EndUpdate(dial->GetWindow());
|
||||
event->what = nullEvent;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DoControlPrefs
|
||||
@@ -510,7 +466,7 @@ void DoControlPrefs (void)
|
||||
Boolean leaving;
|
||||
|
||||
// CenterDialog(kControlPrefsDialID);
|
||||
prefDlg = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kControlPrefsDialID, kPutInFront);
|
||||
prefDlg = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kControlPrefsDialID, kPutInFront, nullptr);
|
||||
if (prefDlg == nil)
|
||||
RedAlert(kErrDialogDidntLoad);
|
||||
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
|
||||
@@ -542,10 +498,12 @@ void DoControlPrefs (void)
|
||||
kESCPausesRadio, kTABPausesRadio);
|
||||
|
||||
DrawSurface *surface = prefDlg->GetWindow()->GetDrawSurface();
|
||||
|
||||
UpdateSettingsControl(prefDlg);
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
ModalDialog(ControlFilter, &itemHit);
|
||||
itemHit = prefDlg->ExecuteModal(ControlFilter);
|
||||
switch (itemHit)
|
||||
{
|
||||
case kOkayButton:
|
||||
@@ -741,7 +699,7 @@ void DoSoundPrefs (void)
|
||||
short itemHit;
|
||||
Boolean leaving;
|
||||
|
||||
BringUpDialog(&prefDlg, kSoundPrefsDialID);
|
||||
BringUpDialog(&prefDlg, kSoundPrefsDialID, nullptr);
|
||||
|
||||
DrawSurface *surface = prefDlg->GetWindow()->GetDrawSurface();
|
||||
|
||||
@@ -754,10 +712,11 @@ void DoSoundPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kIdleMusicItem, (short)wasIdle);
|
||||
SetDialogItemValue(prefDlg, kPlayMusicItem, (short)wasPlay);
|
||||
leaving = false;
|
||||
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
itemHit = prefDlg->ExecuteModal(SoundFilter);
|
||||
|
||||
switch (itemHit)
|
||||
{
|
||||
case kOkayButton:
|
||||
@@ -801,8 +760,8 @@ void DoSoundPrefs (void)
|
||||
SetDialogNumToStr(prefDlg, kVolNumberItem, (long)tempVolume);
|
||||
UnivSetSoundVolume(tempVolume, thisMac.hasSM3);
|
||||
HandleSoundMusicChange(tempVolume, true);
|
||||
//InvalWindowRect(prefDlg->GetWindow(), &tempRect);
|
||||
DelayTicks(8);
|
||||
prefDlg->GetItems()[kSofterItem - 1].GetWidget()->DrawControl(surface);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -819,8 +778,10 @@ void DoSoundPrefs (void)
|
||||
SetDialogNumToStr(prefDlg, kVolNumberItem, tempVolume);
|
||||
UnivSetSoundVolume(tempVolume, thisMac.hasSM3);
|
||||
HandleSoundMusicChange(tempVolume, true);
|
||||
//InvalWindowRect(prefDlg->GetWindow(), &tempRect);
|
||||
|
||||
DelayTicks(8);
|
||||
|
||||
prefDlg->GetItems()[kLouderItem - 1].GetWidget()->DrawControl(surface);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1045,9 +1006,7 @@ void DoDisplayPrefs (void)
|
||||
short wasNeighbors;
|
||||
Boolean leaving;
|
||||
|
||||
BringUpDialog(&prefDlg, kDisplayPrefsDialID);
|
||||
|
||||
DisplayUpdate(prefDlg);
|
||||
BringUpDialog(&prefDlg, kDisplayPrefsDialID, nullptr);
|
||||
|
||||
if (!thisMac.can8Bit)
|
||||
{
|
||||
@@ -1063,6 +1022,8 @@ void DoDisplayPrefs (void)
|
||||
wasDepthPref = isDepthPref;
|
||||
wasScreen2 = isUseSecondScreen;
|
||||
leaving = false;
|
||||
|
||||
DisplayUpdate(prefDlg);
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
@@ -1294,7 +1255,7 @@ void DoSettingsMain (void)
|
||||
int16_t itemHit;
|
||||
Boolean leaving;
|
||||
|
||||
BringUpDialog(&prefDlg, kMainPrefsDialID);
|
||||
BringUpDialog(&prefDlg, kMainPrefsDialID, nullptr);
|
||||
|
||||
DrawSurface *surface = prefDlg->GetWindow()->GetDrawSurface();
|
||||
|
||||
@@ -1373,6 +1334,6 @@ void BitchAboutChanges (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kChangesEffectAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kChangesEffectAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kChangesEffectAlert, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ void TellHerNoSounds (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoMemForSoundsAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert, nullptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutSM3
|
||||
@@ -407,7 +407,7 @@ void BitchAboutSM3 (void)
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoSoundManager3Alert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoSoundManager3Alert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoSoundManager3Alert, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLEventQueue.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLQDraw.h"
|
||||
@@ -15,11 +16,14 @@
|
||||
#include "BitmapImage.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Externs.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IconLoader.h"
|
||||
#include "InputManager.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
UInt32 theSeed;
|
||||
|
||||
@@ -106,10 +110,10 @@ void RedAlert (short errorNumber)
|
||||
GetIndString(errMessage, rErrMssgID, 1);
|
||||
}
|
||||
NumToString((long)errorNumber, errNumberString);
|
||||
ParamText(errTitle, errMessage, errNumberString, PSTR(""));
|
||||
DialogTextSubstitutions substitutions(errTitle, errMessage, errNumberString, PSTR(""));
|
||||
// CenterAlert(rDeathAlertID);
|
||||
|
||||
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID);
|
||||
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions);
|
||||
ExitToShell();
|
||||
}
|
||||
|
||||
@@ -488,11 +492,111 @@ char KeyMapOffsetFromRawKey (char rawKeyCode)
|
||||
// Given a keyDown event (it's message field), this function returnsÉ
|
||||
// a string with that key's name (so we get "Shift" and "Esc", etc.).
|
||||
|
||||
static const char *gs_specialKeyNames[GpKeySpecials::kCount] =
|
||||
{
|
||||
"tab",
|
||||
"esc",
|
||||
"prnt scrn",
|
||||
"scrl lock",
|
||||
"pause",
|
||||
"insert",
|
||||
"home",
|
||||
"page up",
|
||||
"page dn",
|
||||
"delete",
|
||||
"end",
|
||||
"backspace",
|
||||
"caps lock",
|
||||
"enter",
|
||||
"lf shift",
|
||||
"rt shift",
|
||||
"lf ctrl",
|
||||
"rt ctrl",
|
||||
"lf alt",
|
||||
"rt alt",
|
||||
"num lock",
|
||||
"lf arrow",
|
||||
"up arrow",
|
||||
"dn arrow",
|
||||
"rt arrow"
|
||||
};
|
||||
|
||||
static const char *gs_numPadSpecialKeyNames[GpNumPadSpecials::kCount] =
|
||||
{
|
||||
"numpad /",
|
||||
"numpad *",
|
||||
"numpad -",
|
||||
"numpad +"
|
||||
};
|
||||
|
||||
void GetKeyName (intptr_t message, StringPtr theName)
|
||||
{
|
||||
PasStringCopy(PSTR("TODO"), theName);
|
||||
KeyEventType eventType = PL_KEY_GET_EVENT_TYPE(message);
|
||||
const int eventValue = PL_KEY_GET_VALUE(message);
|
||||
const char *name1 = nullptr;
|
||||
const char *name2 = nullptr;
|
||||
|
||||
PL_NotYetImplemented_TODO("KeyNames");
|
||||
char asciiNameBuffer[2];
|
||||
char fkeyNameBuffer[5];
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case KeyEventType_Special:
|
||||
name1 = gs_specialKeyNames[eventValue];
|
||||
break;
|
||||
case KeyEventType_ASCII:
|
||||
asciiNameBuffer[0] = static_cast<char>(eventValue);
|
||||
asciiNameBuffer[1] = '\0';
|
||||
name1 = asciiNameBuffer;
|
||||
|
||||
if (eventValue == ' ')
|
||||
name1 = "space";
|
||||
break;
|
||||
case KeyEventType_MacRoman:
|
||||
PL_NotYetImplemented_TODO("UnicodeNames");
|
||||
break;
|
||||
case KeyEventType_NumPadNumber:
|
||||
asciiNameBuffer[0] = static_cast<char>('0' + eventValue);
|
||||
asciiNameBuffer[1] = '\0';
|
||||
name1 = "NumPad ";
|
||||
name2 = asciiNameBuffer;
|
||||
break;
|
||||
case KeyEventType_NumPadSpecial:
|
||||
name1 = "NumPad ";
|
||||
name2 = gs_numPadSpecialKeyNames[eventValue];
|
||||
break;
|
||||
case KeyEventType_FKey:
|
||||
fkeyNameBuffer[0] = 'F';
|
||||
if (eventValue >= 10)
|
||||
{
|
||||
fkeyNameBuffer[1] = static_cast<char>('0' + eventValue / 10);
|
||||
fkeyNameBuffer[2] = static_cast<char>('0' + eventValue % 10);
|
||||
fkeyNameBuffer[3] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
fkeyNameBuffer[1] = static_cast<char>('0' + eventValue);
|
||||
fkeyNameBuffer[2] = '\0';
|
||||
}
|
||||
|
||||
name1 = fkeyNameBuffer;
|
||||
case KeyEventType_GamepadButton:
|
||||
// This should never happen
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
const size_t name1Length = (name1 == nullptr) ? 0 : strlen(name1);
|
||||
const size_t name2Length = (name2 == nullptr) ? 0 : strlen(name2);
|
||||
|
||||
const size_t combinedLength = name1Length + name2Length;
|
||||
assert(combinedLength <= 255);
|
||||
|
||||
theName[0] = static_cast<uint8_t>(combinedLength);
|
||||
if (name1Length)
|
||||
memcpy(theName + 1, name1, name1Length);
|
||||
if (name2Length)
|
||||
memcpy(theName + 1 + name1Length, name2, name2Length);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- OptionKeyDown
|
||||
|
||||
@@ -136,6 +136,9 @@ namespace GpKeyboardInputEventTypes
|
||||
kDown,
|
||||
kUp,
|
||||
kAuto,
|
||||
|
||||
kDownChar,
|
||||
kAutoChar,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -173,6 +176,7 @@ struct GpKeyboardInputEvent
|
||||
GpKeyboardInputEventType_t m_eventType;
|
||||
GpKeyIDSubset_t m_keyIDSubset;
|
||||
KeyUnion m_key;
|
||||
uint32_t m_repeatCount; // For down and auto events, number of types to repeat this keystroke (if multiple auto-repeated events get compacted)
|
||||
};
|
||||
|
||||
struct GpGamepadAnalogAxisEvent
|
||||
|
||||
@@ -563,8 +563,6 @@ void GpDisplayDriverD3D11::Run()
|
||||
{
|
||||
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
|
||||
DispatchMessage(&msg);
|
||||
|
||||
if (msg.message == WM_QUIT)
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace PortabilityLayer
|
||||
|
||||
int16_t ExecuteModal(DialogFilterFunc_t filterFunc) override;
|
||||
|
||||
bool Populate(DialogTemplate *tmpl);
|
||||
bool Populate(DialogTemplate *tmpl, const DialogTextSubstitutions *substitutions);
|
||||
|
||||
void DrawControls(bool redraw);
|
||||
|
||||
@@ -97,6 +97,8 @@ namespace PortabilityLayer
|
||||
explicit DialogImpl(Window *window, DialogItem *items, size_t numItems);
|
||||
~DialogImpl();
|
||||
|
||||
static void MakeStringSubstitutions(uint8_t *outStr, const uint8_t *inStr, const DialogTextSubstitutions *substitutions);
|
||||
|
||||
Window *m_window;
|
||||
DialogItem *m_items;
|
||||
size_t m_numItems;
|
||||
@@ -268,7 +270,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
bool DialogImpl::Populate(DialogTemplate *tmpl)
|
||||
bool DialogImpl::Populate(DialogTemplate *tmpl, const DialogTextSubstitutions *substitutions)
|
||||
{
|
||||
Window *window = this->GetWindow();
|
||||
|
||||
@@ -282,10 +284,13 @@ namespace PortabilityLayer
|
||||
|
||||
Widget *widget = nullptr;
|
||||
|
||||
Str255 substitutedStr;
|
||||
MakeStringSubstitutions(substitutedStr, templateItem.m_name, substitutions);
|
||||
|
||||
WidgetBasicState basicState;
|
||||
basicState.m_enabled = templateItem.m_enabled;
|
||||
basicState.m_resID = templateItem.m_id;
|
||||
basicState.m_text = PascalStr<255>(PLPasStr(templateItem.m_name));
|
||||
basicState.m_text = PascalStr<255>(PLPasStr(substitutedStr));
|
||||
basicState.m_rect = templateItem.m_rect;
|
||||
basicState.m_window = window;
|
||||
|
||||
@@ -304,8 +309,8 @@ namespace PortabilityLayer
|
||||
widget = ImageWidget::Create(basicState);
|
||||
break;
|
||||
case SerializedDialogItemTypeCodes::kCheckBox:
|
||||
//widget = CheckboxWidget::Create(basicState);
|
||||
//break;
|
||||
widget = CheckboxWidget::Create(basicState);
|
||||
break;
|
||||
case SerializedDialogItemTypeCodes::kRadioButton:
|
||||
widget = RadioButtonWidget::Create(basicState);
|
||||
break;
|
||||
@@ -338,6 +343,49 @@ namespace PortabilityLayer
|
||||
return Point::Create(x, y);
|
||||
}
|
||||
|
||||
void DialogImpl::MakeStringSubstitutions(uint8_t *outStr, const uint8_t *inStr, const DialogTextSubstitutions *substitutions)
|
||||
{
|
||||
if (substitutions == nullptr)
|
||||
{
|
||||
memcpy(outStr, inStr, inStr[0] + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t inStrLen = inStr[0];
|
||||
const uint8_t *inStrChar = inStr + 1;
|
||||
|
||||
uint8_t *outStrChar = outStr + 1;
|
||||
|
||||
uint8_t outStrRemaining = 255;
|
||||
uint8_t inStrRemaining = inStr[0];
|
||||
while (outStrRemaining > 0 && inStrRemaining > 0)
|
||||
{
|
||||
if ((*inStrChar) != '^' || inStrRemaining < 2 || inStrChar[1] < static_cast<uint8_t>('0') || inStrChar[1] > static_cast<uint8_t>('3'))
|
||||
{
|
||||
*outStrChar++ = *inStrChar++;
|
||||
inStrRemaining--;
|
||||
outStrRemaining--;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int subIndex = inStrChar[1] - '0';
|
||||
inStrChar += 2;
|
||||
inStrRemaining -= 2;
|
||||
|
||||
const uint8_t *substitution = substitutions->m_strings[subIndex];
|
||||
const uint8_t substitutionLength = substitution[0];
|
||||
const uint8_t *substitutionChars = substitution + 1;
|
||||
|
||||
const uint8_t copyLength = (substitutionLength < outStrRemaining) ? substitutionLength : outStrRemaining;
|
||||
memcpy(outStrChar, substitutionChars, copyLength);
|
||||
outStrChar += copyLength;
|
||||
outStrRemaining -= copyLength;
|
||||
}
|
||||
}
|
||||
|
||||
outStr[0] = static_cast<uint8_t>(outStrChar - (outStr + 1));
|
||||
}
|
||||
|
||||
DialogImpl *DialogImpl::Create(Window *window, size_t numItems)
|
||||
{
|
||||
size_t alignedSize = sizeof(DialogImpl) + GP_SYSTEM_MEMORY_ALIGNMENT + 1;
|
||||
@@ -391,8 +439,8 @@ namespace PortabilityLayer
|
||||
class DialogManagerImpl final : public DialogManager
|
||||
{
|
||||
public:
|
||||
Dialog *LoadDialog(int16_t resID, Window *behindWindow) override;
|
||||
int16_t DisplayAlert(int16_t alertResID) override;
|
||||
Dialog *LoadDialog(int16_t resID, Window *behindWindow, const DialogTextSubstitutions *substitutions) override;
|
||||
int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) override;
|
||||
|
||||
DialogTemplate *LoadDialogTemplate(int16_t resID);
|
||||
|
||||
@@ -404,7 +452,7 @@ namespace PortabilityLayer
|
||||
static DialogManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
Dialog *DialogManagerImpl::LoadDialog(int16_t resID, Window *behindWindow)
|
||||
Dialog *DialogManagerImpl::LoadDialog(int16_t resID, Window *behindWindow, const DialogTextSubstitutions *substitutions)
|
||||
{
|
||||
ResourceManager *rm = ResourceManager::GetInstance();
|
||||
|
||||
@@ -459,7 +507,7 @@ namespace PortabilityLayer
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!dialog->Populate(dtemplate))
|
||||
if (!dialog->Populate(dtemplate, substitutions))
|
||||
{
|
||||
dialog->Destroy();
|
||||
dtemplate->Destroy();
|
||||
@@ -473,12 +521,8 @@ namespace PortabilityLayer
|
||||
return dialog;
|
||||
}
|
||||
|
||||
int16_t DialogManagerImpl::DisplayAlert(int16_t alertResID)
|
||||
int16_t DialogManagerImpl::DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions)
|
||||
{
|
||||
enum AlertStageBits
|
||||
{
|
||||
};
|
||||
|
||||
struct AlertResourceData
|
||||
{
|
||||
BERect m_rect;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
struct Dialog;
|
||||
struct DialogTextSubstitutions;
|
||||
struct Window;
|
||||
struct TimeTaggedVOSEvent;
|
||||
|
||||
@@ -13,8 +14,8 @@ namespace PortabilityLayer
|
||||
class DialogManager
|
||||
{
|
||||
public:
|
||||
virtual Dialog *LoadDialog(int16_t resID, Window *behindWindow) = 0;
|
||||
virtual int16_t DisplayAlert(int16_t alertResID) = 0;
|
||||
virtual Dialog *LoadDialog(int16_t resID, Window *behindWindow, const DialogTextSubstitutions *substitutions) = 0;
|
||||
virtual int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) = 0;
|
||||
|
||||
static DialogManager *GetInstance();
|
||||
};
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#include "PLCheckboxWidget.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "FontFamily.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
CheckboxWidget::CheckboxWidget(const WidgetBasicState &state)
|
||||
: WidgetSpec<CheckboxWidget>(state)
|
||||
, m_text(state.m_text)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,4 +22,51 @@ namespace PortabilityLayer
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckboxWidget::DrawControl(DrawSurface *surface)
|
||||
{
|
||||
if (!m_rect.IsValid())
|
||||
return;
|
||||
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(m_rect);
|
||||
|
||||
uint16_t checkFrameSize = std::min<uint16_t>(12, std::min(m_rect.Width(), m_rect.Height()));
|
||||
int16_t top = (m_rect.top + m_rect.bottom - static_cast<int16_t>(checkFrameSize)) / 2;
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
const Rect checkRect = Rect::Create(top, m_rect.left, top + static_cast<int16_t>(checkFrameSize), m_rect.left + static_cast<int16_t>(checkFrameSize));
|
||||
surface->FillRect(checkRect);
|
||||
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(checkRect.Inset(1, 1));
|
||||
|
||||
if (m_state)
|
||||
{
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
surface->DrawLine(Point::Create(checkRect.left + 1, checkRect.top + 1), Point::Create(checkRect.right - 2, checkRect.bottom - 2));
|
||||
surface->DrawLine(Point::Create(checkRect.right - 2, checkRect.top + 1), Point::Create(checkRect.left + 1, checkRect.bottom - 2));
|
||||
}
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
surface->SetSystemFont(12, FontFamilyFlag_Bold);
|
||||
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
|
||||
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true);
|
||||
}
|
||||
|
||||
void CheckboxWidget::SetString(const PLPasStr &str)
|
||||
{
|
||||
m_text = PascalStr<255>(str);
|
||||
}
|
||||
|
||||
PLPasStr CheckboxWidget::GetString() const
|
||||
{
|
||||
return m_text.ToShortStr();
|
||||
}
|
||||
|
||||
void CheckboxWidget::OnStateChanged()
|
||||
{
|
||||
if (m_window)
|
||||
DrawControl(&m_window->m_surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "PascalStr.h"
|
||||
#include "PLWidgets.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
@@ -11,5 +12,14 @@ namespace PortabilityLayer
|
||||
~CheckboxWidget();
|
||||
|
||||
bool Init(const WidgetBasicState &state) override;
|
||||
|
||||
void DrawControl(DrawSurface *surface) override;
|
||||
void SetString(const PLPasStr &str) override;
|
||||
PLPasStr GetString() const override;
|
||||
|
||||
void OnStateChanged() override;
|
||||
|
||||
private:
|
||||
PascalStr<255> m_text;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -328,11 +328,6 @@ void NumToString(long number, unsigned char *str)
|
||||
str[0] = static_cast<uint8_t>(strLength);
|
||||
}
|
||||
|
||||
void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, const PLPasStr &c)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
PLError_t AEProcessAppleEvent(EventRecord *evt)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
@@ -553,11 +548,6 @@ short Random()
|
||||
return static_cast<short>(static_cast<int32_t>(rWord) - 0x8000);
|
||||
}
|
||||
|
||||
void GetDateTime(UInt32 *dateTime)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void GetTime(DateTimeRec *dateTime)
|
||||
{
|
||||
unsigned int year;
|
||||
|
||||
@@ -57,34 +57,6 @@ struct FinderInfoBlock
|
||||
Int32 fdCreator;
|
||||
};
|
||||
|
||||
struct FileInfoBlock
|
||||
{
|
||||
void *ioCompletion;
|
||||
short ioVRefNum; // Volume ref num
|
||||
StringPtr ioNamePtr;
|
||||
int ioFDirIndex; // Index: If >0, Nth directory in ioVRefNum. If 0, lookup by name. If <0, do behavior that we don't support.
|
||||
long ioDirID; // Input: Directory ID Output: File ID
|
||||
int ioFlAttrib; // File attributes
|
||||
FinderInfoBlock ioFlFndrInfo;
|
||||
long ioFlParID;
|
||||
};
|
||||
|
||||
struct DirInfoBlock
|
||||
{
|
||||
void *ioCompletion;
|
||||
short ioVRefNum;
|
||||
long ioDrDirID;
|
||||
unsigned char *ioNamePtr;
|
||||
short ioFDirIndex;
|
||||
int ioFlAttrib;
|
||||
};
|
||||
|
||||
struct CInfoPBRec
|
||||
{
|
||||
FileInfoBlock hFileInfo;
|
||||
DirInfoBlock dirInfo;
|
||||
};
|
||||
|
||||
struct DirectoryFileListEntry
|
||||
{
|
||||
FinderInfoBlock finderInfo;
|
||||
@@ -182,7 +154,6 @@ struct EventRecord
|
||||
typedef Window *WindowPtr;
|
||||
typedef Cursor *CursPtr;
|
||||
typedef Menu *MenuPtr;
|
||||
typedef CInfoPBRec *CInfoPBPtr;
|
||||
typedef VersionRecord *VersRecPtr;
|
||||
|
||||
typedef THandle<Cursor> CursHandle;
|
||||
@@ -274,7 +245,6 @@ short LoWord(Int32 v);
|
||||
short HiWord(Int32 v);
|
||||
|
||||
void NumToString(long number, unsigned char *str);
|
||||
void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, const PLPasStr &c);
|
||||
|
||||
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
||||
|
||||
@@ -293,7 +263,6 @@ Boolean StillDown();
|
||||
Boolean WaitMouseUp();
|
||||
|
||||
short Random();
|
||||
void GetDateTime(UInt32 *dateTime);
|
||||
void GetTime(DateTimeRec *dateTime);
|
||||
UInt32 GetDblTime();
|
||||
|
||||
|
||||
@@ -1,4 +1,48 @@
|
||||
#include "PLDialogs.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
|
||||
DialogTextSubstitutions::DialogTextSubstitutions()
|
||||
{
|
||||
Init(0, nullptr);
|
||||
}
|
||||
|
||||
DialogTextSubstitutions::DialogTextSubstitutions(const PLPasStr& str0)
|
||||
{
|
||||
Init(1, &str0);
|
||||
}
|
||||
|
||||
DialogTextSubstitutions::DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1)
|
||||
{
|
||||
PLPasStr strs[] = { str0, str1 };
|
||||
Init(2, strs);
|
||||
}
|
||||
|
||||
DialogTextSubstitutions::DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1, const PLPasStr& str2)
|
||||
{
|
||||
PLPasStr strs[] = { str0, str1, str2 };
|
||||
Init(3, strs);
|
||||
}
|
||||
|
||||
DialogTextSubstitutions::DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1, const PLPasStr& str2, const PLPasStr& str3)
|
||||
{
|
||||
PLPasStr strs[] = { str0, str1, str2, str3 };
|
||||
Init(4, strs);
|
||||
}
|
||||
|
||||
void DialogTextSubstitutions::Init(size_t numItems, const PLPasStr *items)
|
||||
{
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const uint8_t len = items[i].Length();
|
||||
m_strings[i][0] = len;
|
||||
if (len)
|
||||
memcpy(m_strings[i] + 1, items[i].UChars(), len);
|
||||
}
|
||||
|
||||
for (size_t i = numItems; i < 4; i++)
|
||||
m_strings[i][0] = 0;
|
||||
}
|
||||
|
||||
void DrawDialog(Dialog *dialog)
|
||||
{
|
||||
@@ -17,11 +61,6 @@ DrawSurface *GetDialogPort(Dialog *dialog)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GetDialogItem(Dialog *dialog, int index, short *itemType, THandle<Control> *itemHandle, Rect *itemRect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void GetDialogItemText(THandle<Control> handle, StringPtr str)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
@@ -39,7 +78,7 @@ void SetDialogItemText(THandle<Control> handle, const PLPasStr &str)
|
||||
|
||||
void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSelCharExclusive)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PL_NotYetImplemented_TODO("TextBox_Critical");
|
||||
}
|
||||
|
||||
ModalFilterUPP NewModalFilterUPP(ModalFilterUPP func)
|
||||
|
||||
@@ -16,6 +16,20 @@ struct Dialog;
|
||||
|
||||
typedef int16_t(*DialogFilterFunc_t)(Dialog *dialog, const TimeTaggedVOSEvent &evt);
|
||||
|
||||
struct DialogTextSubstitutions
|
||||
{
|
||||
Str255 m_strings[4];
|
||||
|
||||
DialogTextSubstitutions();
|
||||
explicit DialogTextSubstitutions(const PLPasStr& str0);
|
||||
DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1);
|
||||
DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1, const PLPasStr& str2);
|
||||
DialogTextSubstitutions(const PLPasStr& str0, const PLPasStr& str1, const PLPasStr& str2, const PLPasStr& str3);
|
||||
|
||||
private:
|
||||
void Init(size_t numItems, const PLPasStr *items);
|
||||
};
|
||||
|
||||
struct Dialog
|
||||
{
|
||||
virtual void Destroy() = 0;
|
||||
@@ -33,7 +47,6 @@ typedef Boolean(*ModalFilterUPP)(Dialog *dial, EventRecord *event, short *item);
|
||||
void DrawDialog(Dialog *dialog);
|
||||
DrawSurface *GetDialogPort(Dialog *dialog);
|
||||
|
||||
void GetDialogItem(Dialog *dialog, int index, short *itemType, THandle<Control> *itemHandle, Rect *itemRect);
|
||||
void GetDialogItemText(THandle<Control> handle, StringPtr str);
|
||||
|
||||
void SetDialogItem(Dialog *dialog, int index, short itemType, THandle<Control> itemHandle, const Rect *itemRect);
|
||||
|
||||
@@ -13,5 +13,5 @@ bool IsMacPlusSoundBanned()
|
||||
// High scores disabled until dialogs work
|
||||
bool IsHighScoreDisabled()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ namespace KeyEventEitherSpecialCategories
|
||||
intptr_t PackVOSKeyCode(const GpKeyboardInputEvent &evt);
|
||||
|
||||
struct KeyDownStates
|
||||
{
|
||||
GpBitfield<GpKeySpecials::kCount> m_special;
|
||||
GpBitfield<128> m_ascii;
|
||||
GpBitfield<128> m_macRoman;
|
||||
GpBitfield<10> m_numPadNumber;
|
||||
{
|
||||
GpBitfield<GpKeySpecials::kCount> m_special;
|
||||
GpBitfield<128> m_ascii;
|
||||
GpBitfield<128> m_macRoman;
|
||||
GpBitfield<10> m_numPadNumber;
|
||||
GpBitfield<GpNumPadSpecials::kCount> m_numPadSpecial;
|
||||
GpBitfield<GpFKeyMaximumInclusive> m_fKey;
|
||||
GpBitfield<GpFKeyMaximumInclusive> m_fKey;
|
||||
GpBitfield<GpGamepadButtons::kCount> m_gamepadButtons[PL_INPUT_MAX_PLAYERS];
|
||||
|
||||
bool IsSet(intptr_t packedVOSCode) const;
|
||||
|
||||
@@ -19,8 +19,22 @@ namespace PortabilityLayer
|
||||
return true;
|
||||
}
|
||||
|
||||
void LabelWidget::SetString(const PLPasStr &str)
|
||||
{
|
||||
m_text.Set(str.Length(), str.Chars());
|
||||
}
|
||||
|
||||
PLPasStr LabelWidget::GetString() const
|
||||
{
|
||||
return m_text.ToShortStr();
|
||||
}
|
||||
|
||||
void LabelWidget::DrawControl(DrawSurface *surface)
|
||||
{
|
||||
// FIXME: This is kind of bad
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(m_rect);
|
||||
|
||||
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace PortabilityLayer
|
||||
|
||||
bool Init(const WidgetBasicState &state) override;
|
||||
|
||||
void SetString(const PLPasStr &str) override;
|
||||
PLPasStr GetString() const override;
|
||||
|
||||
void DrawControl(DrawSurface *surface) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -820,9 +820,9 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
||||
const uint8_t srcHigh = currentSourceRow[srcColIndex * 2 + 1];
|
||||
|
||||
const unsigned int combinedValue = srcLow | (srcHigh << 8);
|
||||
const unsigned int b = (srcLow & 0x1f);
|
||||
const unsigned int g = ((srcLow >> 5) & 0x1f);
|
||||
const unsigned int r = ((srcLow >> 10) & 0x1f);
|
||||
const unsigned int b = (combinedValue & 0x1f);
|
||||
const unsigned int g = ((combinedValue >> 5) & 0x1f);
|
||||
const unsigned int r = ((combinedValue >> 10) & 0x1f);
|
||||
|
||||
if (r + g + b > 46)
|
||||
currentDestRow[destColIndex] = 0;
|
||||
@@ -866,9 +866,9 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
|
||||
const uint8_t srcHigh = currentSourceRow[srcColIndex * 2 + 1];
|
||||
|
||||
const unsigned int combinedValue = srcLow | (srcHigh << 8);
|
||||
const unsigned int b = (srcLow & 0x1f);
|
||||
const unsigned int g = ((srcLow >> 5) & 0x1f);
|
||||
const unsigned int r = ((srcLow >> 10) & 0x1f);
|
||||
const unsigned int b = (combinedValue & 0x1f);
|
||||
const unsigned int g = ((combinedValue >> 5) & 0x1f);
|
||||
const unsigned int r = ((combinedValue >> 10) & 0x1f);
|
||||
|
||||
if (r + g + b > 46)
|
||||
currentDestRow[destColIndex] = 0;
|
||||
|
||||
@@ -28,16 +28,23 @@ namespace PortabilityLayer
|
||||
if (!m_rect.IsValid())
|
||||
return;
|
||||
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect(m_rect);
|
||||
|
||||
uint16_t radioFrameSize = std::min<uint16_t>(12, std::min(m_rect.Width(), m_rect.Height()));
|
||||
int16_t top = (m_rect.top + m_rect.bottom - static_cast<int16_t>(radioFrameSize)) / 2;
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
const Rect radioRect = Rect::Create(top, m_rect.left, top + static_cast<int16_t>(radioFrameSize), m_rect.left + static_cast<int16_t>(radioFrameSize));
|
||||
surface->FillEllipse(radioRect);
|
||||
if (!m_state)
|
||||
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillEllipse(radioRect.Inset(1, 1));
|
||||
|
||||
if (m_state)
|
||||
{
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillEllipse(radioRect.Inset(1, 1));
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
surface->FillEllipse(radioRect.Inset(3, 3));
|
||||
}
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
@@ -51,4 +58,14 @@ namespace PortabilityLayer
|
||||
m_text = PascalStr<255>(str);
|
||||
}
|
||||
|
||||
PLPasStr RadioButtonWidget::GetString() const
|
||||
{
|
||||
return m_text.ToShortStr();
|
||||
}
|
||||
|
||||
void RadioButtonWidget::OnStateChanged()
|
||||
{
|
||||
if (m_window)
|
||||
DrawControl(&m_window->m_surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace PortabilityLayer
|
||||
|
||||
void DrawControl(DrawSurface *surface) override;
|
||||
void SetString(const PLPasStr &str) override;
|
||||
PLPasStr GetString() const override;
|
||||
|
||||
void OnStateChanged() override;
|
||||
|
||||
private:
|
||||
PascalStr<255> m_text;
|
||||
|
||||
@@ -10,7 +10,7 @@ struct TimeTaggedVOSEvent
|
||||
static TimeTaggedVOSEvent Create(const GpVOSEvent &vosEvent, uint32_t timestamp);
|
||||
|
||||
// Helpers for common cases
|
||||
bool IsKeyDownEvent() const;
|
||||
bool IsKeyDownEvent() const; // Only returns true for untranslated keydown events
|
||||
bool IsLMouseDownEvent() const;
|
||||
bool IsLMouseUpEvent() const;
|
||||
};
|
||||
|
||||
@@ -89,6 +89,11 @@ namespace PortabilityLayer
|
||||
(void)str;
|
||||
}
|
||||
|
||||
PLPasStr Widget::GetString() const
|
||||
{
|
||||
return PSTR("");
|
||||
}
|
||||
|
||||
const Rect &Widget::GetRect() const
|
||||
{
|
||||
return m_rect;
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace PortabilityLayer
|
||||
bool IsVisible() const;
|
||||
|
||||
virtual void SetString(const PLPasStr &str);
|
||||
virtual PLPasStr GetString() const;
|
||||
|
||||
virtual void SetHighlightStyle(int16_t style);
|
||||
|
||||
const Rect &GetRect() const;
|
||||
|
||||
Reference in New Issue
Block a user