mirror of
https://github.com/elasota/Aerofoil.git
synced 2026-02-05 02:53:05 +00:00
Alert skeleton
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "PLAppleEvents.h"
|
#include "PLAppleEvents.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
|
||||||
@@ -131,7 +132,7 @@ PLError_t DoPrintDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoPrintingAlert);
|
// CenterAlert(kNoPrintingAlert);
|
||||||
hitWhat = Alert(kNoPrintingAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPrintingAlert);
|
||||||
|
|
||||||
return PLErrors::kInvalidParameter;
|
return PLErrors::kInvalidParameter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "PLTimeTaggedVOSEvent.h"
|
#include "PLTimeTaggedVOSEvent.h"
|
||||||
#include "PLToolUtils.h"
|
#include "PLToolUtils.h"
|
||||||
#include "PLQDraw.h"
|
#include "PLQDraw.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
@@ -53,7 +54,7 @@ short BitchAboutColorDepth (void)
|
|||||||
short sheSaid;
|
short sheSaid;
|
||||||
|
|
||||||
// CenterAlert(kColorSwitchedAlert);
|
// CenterAlert(kColorSwitchedAlert);
|
||||||
sheSaid = Alert(kColorSwitchedAlert, nil);
|
sheSaid = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kColorSwitchedAlert);
|
||||||
|
|
||||||
return (sheSaid);
|
return (sheSaid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "PLNumberFormatting.h"
|
#include "PLNumberFormatting.h"
|
||||||
#include "PLTextUtils.h"
|
#include "PLTextUtils.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
|
|||||||
ParamText(errMessage, errNumString, fileName, PSTR(""));
|
ParamText(errMessage, errNumString, fileName, PSTR(""));
|
||||||
|
|
||||||
// CenterAlert(rFileErrorAlert);
|
// CenterAlert(rFileErrorAlert);
|
||||||
dummyInt = Alert(rFileErrorAlert, 0L);
|
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rFileErrorAlert);
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "PLStringCompare.h"
|
#include "PLStringCompare.h"
|
||||||
#include "PLTextUtils.h"
|
#include "PLTextUtils.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "FileManager.h"
|
#include "FileManager.h"
|
||||||
@@ -935,7 +936,7 @@ Boolean QuerySaveChanges (void)
|
|||||||
InitCursor();
|
InitCursor();
|
||||||
// CenterAlert(kSaveChangesAlert);
|
// CenterAlert(kSaveChangesAlert);
|
||||||
ParamText(thisHouseName, PSTR(""), PSTR(""), PSTR(""));
|
ParamText(thisHouseName, PSTR(""), PSTR(""), PSTR(""));
|
||||||
hitWhat = Alert(kSaveChangesAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveChangesAlert);
|
||||||
if (hitWhat == kSaveChanges)
|
if (hitWhat == kSaveChanges)
|
||||||
{
|
{
|
||||||
if (wasHouseVersion < kHouseVersion)
|
if (wasHouseVersion < kHouseVersion)
|
||||||
@@ -982,7 +983,7 @@ void YellowAlert (short whichAlert, short identifier)
|
|||||||
// CenterAlert(kYellowAlert);
|
// CenterAlert(kYellowAlert);
|
||||||
ParamText(errStr, errNumStr, PSTR(""), PSTR(""));
|
ParamText(errStr, errNumStr, PSTR(""), PSTR(""));
|
||||||
|
|
||||||
whoCares = Alert(kYellowAlert, nil);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kYellowAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- IsFileReadOnly
|
//-------------------------------------------------------------- IsFileReadOnly
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ Boolean WarnLockingHouse (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kLockHouseAlert);
|
// CenterAlert(kLockHouseAlert);
|
||||||
hitWhat = Alert(kLockHouseAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kLockHouseAlert);
|
||||||
|
|
||||||
return (hitWhat == 1);
|
return (hitWhat == 1);
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ void HowToZeroScores (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kZeroScoresAlert);
|
// CenterAlert(kZeroScoresAlert);
|
||||||
hitWhat = Alert(kZeroScoresAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kZeroScoresAlert);
|
||||||
|
|
||||||
switch (hitWhat)
|
switch (hitWhat)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "PLToolUtils.h"
|
#include "PLToolUtils.h"
|
||||||
#include "PLDialogs.h"
|
#include "PLDialogs.h"
|
||||||
#include "PLKeyEncoding.h"
|
#include "PLKeyEncoding.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
@@ -468,7 +469,7 @@ Boolean QuerySaveGame (void)
|
|||||||
InitCursor();
|
InitCursor();
|
||||||
FlushEvents(everyEvent, 0);
|
FlushEvents(everyEvent, 0);
|
||||||
// CenterAlert(kSaveGameAlert);
|
// CenterAlert(kSaveGameAlert);
|
||||||
hitWhat = Alert(kSaveGameAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert);
|
||||||
if (hitWhat == kYesSaveGameButton)
|
if (hitWhat == kYesSaveGameButton)
|
||||||
return (true);
|
return (true);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "PLResources.h"
|
#include "PLResources.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLStandardColors.h"
|
#include "PLStandardColors.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
@@ -726,7 +727,7 @@ Boolean QueryNewRoom (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNewRoomAlert);
|
// CenterAlert(kNewRoomAlert);
|
||||||
hitWhat = Alert(kNewRoomAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewRoomAlert);
|
||||||
if (hitWhat == kYesDoNewRoom)
|
if (hitWhat == kYesDoNewRoom)
|
||||||
return (true);
|
return (true);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ void DoNotInDemo (void)
|
|||||||
short whoCares;
|
short whoCares;
|
||||||
|
|
||||||
// CenterAlert(kNotInDemoAlert);
|
// CenterAlert(kNotInDemoAlert);
|
||||||
whoCares = Alert(kNotInDemoAlert, nil);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNotInDemoAlert);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -786,7 +786,7 @@ void HeyYourPissingAHighScore (void)
|
|||||||
|
|
||||||
// CenterAlert(kNoHighScoreAlert);
|
// CenterAlert(kNoHighScoreAlert);
|
||||||
|
|
||||||
whoCares = Alert(kNoHighScoreAlert, nil);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoHighScoreAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- OpenCloseEditWindows
|
//-------------------------------------------------------------- OpenCloseEditWindows
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Music.c
|
// Music.c
|
||||||
@@ -9,6 +7,7 @@
|
|||||||
|
|
||||||
#include "PLResources.h"
|
#include "PLResources.h"
|
||||||
#include "PLSound.h"
|
#include "PLSound.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "SoundSync.h"
|
#include "SoundSync.h"
|
||||||
@@ -388,6 +387,6 @@ void TellHerNoMusic (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoMemForMusicAlert);
|
// CenterAlert(kNoMemForMusicAlert);
|
||||||
hitWhat = Alert(kNoMemForMusicAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForMusicAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "PLToolUtils.h"
|
#include "PLToolUtils.h"
|
||||||
#include "PLKeyEncoding.h"
|
#include "PLKeyEncoding.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
@@ -874,7 +875,7 @@ void ShoutNoMoreObjects (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoMoreObjectsAlert);
|
// CenterAlert(kNoMoreObjectsAlert);
|
||||||
hitWhat = Alert(kNoMoreObjectsAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreObjectsAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- HowManyCandleObjects
|
//-------------------------------------------------------------- HowManyCandleObjects
|
||||||
@@ -1071,7 +1072,7 @@ void ShoutNoMoreSpecialObjects (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoMoreSpecialAlert);
|
// CenterAlert(kNoMoreSpecialAlert);
|
||||||
hitWhat = Alert(kNoMoreSpecialAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMoreSpecialAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "FileManager.h"
|
#include "FileManager.h"
|
||||||
@@ -183,6 +184,6 @@ void BringUpDeletePrefsAlert (void)
|
|||||||
|
|
||||||
InitCursor();
|
InitCursor();
|
||||||
// CenterAlert(kNewPrefsAlertID);
|
// CenterAlert(kNewPrefsAlertID);
|
||||||
whoCares = Alert(kNewPrefsAlertID, nil);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewPrefsAlertID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLStandardColors.h"
|
#include "PLStandardColors.h"
|
||||||
#include "BitmapImage.h"
|
#include "BitmapImage.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "FontFamily.h"
|
#include "FontFamily.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
@@ -477,7 +478,7 @@ Boolean QueryDeleteRoom (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kDeleteRoomAlert);
|
// CenterAlert(kDeleteRoomAlert);
|
||||||
hitWhat = Alert(kDeleteRoomAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kDeleteRoomAlert);
|
||||||
if (hitWhat == kYesDoDeleteRoom)
|
if (hitWhat == kYesDoDeleteRoom)
|
||||||
return (true);
|
return (true);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -930,7 +930,7 @@ void BitchAboutPICTNotFound (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoPICTFoundAlert);
|
// CenterAlert(kNoPICTFoundAlert);
|
||||||
hitWhat = Alert(kNoPICTFoundAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoPICTFoundAlert);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "PLStringCompare.h"
|
#include "PLStringCompare.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "FileManager.h"
|
#include "FileManager.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
@@ -165,7 +166,7 @@ void SavedGameMismatchError (StringPtr gameName)
|
|||||||
// CenterAlert(kSavedGameErrorAlert);
|
// CenterAlert(kSavedGameErrorAlert);
|
||||||
ParamText(gameName, thisHouseName, PSTR(""), PSTR(""));
|
ParamText(gameName, thisHouseName, PSTR(""), PSTR(""));
|
||||||
|
|
||||||
whoCares = Alert(kSavedGameErrorAlert, nil);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSavedGameErrorAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- OpenSavedGame
|
//-------------------------------------------------------------- OpenSavedGame
|
||||||
|
|||||||
@@ -1373,6 +1373,6 @@ void BitchAboutChanges (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kChangesEffectAlert);
|
// CenterAlert(kChangesEffectAlert);
|
||||||
hitWhat = Alert(kChangesEffectAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kChangesEffectAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "PLResources.h"
|
#include "PLResources.h"
|
||||||
#include "PLSound.h"
|
#include "PLSound.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "MemoryManager.h"
|
#include "MemoryManager.h"
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
@@ -395,7 +396,7 @@ void TellHerNoSounds (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoMemForSoundsAlert);
|
// CenterAlert(kNoMemForSoundsAlert);
|
||||||
hitWhat = Alert(kNoMemForSoundsAlert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- BitchAboutSM3
|
//-------------------------------------------------------------- BitchAboutSM3
|
||||||
@@ -406,7 +407,7 @@ void BitchAboutSM3 (void)
|
|||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoSoundManager3Alert);
|
// CenterAlert(kNoSoundManager3Alert);
|
||||||
hitWhat = Alert(kNoSoundManager3Alert, nil);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoSoundManager3Alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "PLTimeTaggedVOSEvent.h"
|
#include "PLTimeTaggedVOSEvent.h"
|
||||||
#include "QDPixMap.h"
|
#include "QDPixMap.h"
|
||||||
#include "BitmapImage.h"
|
#include "BitmapImage.h"
|
||||||
|
#include "DialogManager.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "IconLoader.h"
|
#include "IconLoader.h"
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
@@ -108,7 +109,7 @@ void RedAlert (short errorNumber)
|
|||||||
ParamText(errTitle, errMessage, errNumberString, PSTR(""));
|
ParamText(errTitle, errMessage, errNumberString, PSTR(""));
|
||||||
// CenterAlert(rDeathAlertID);
|
// CenterAlert(rDeathAlertID);
|
||||||
|
|
||||||
dummyInt = Alert(rDeathAlertID, nil);
|
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID);
|
||||||
ExitToShell();
|
ExitToShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -392,11 +392,15 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Dialog *LoadDialog(int16_t resID, Window *behindWindow) override;
|
Dialog *LoadDialog(int16_t resID, Window *behindWindow) override;
|
||||||
|
int16_t DisplayAlert(int16_t alertResID) override;
|
||||||
|
|
||||||
DialogTemplate *LoadDialogTemplate(int16_t resID);
|
DialogTemplate *LoadDialogTemplate(int16_t resID);
|
||||||
|
|
||||||
static DialogManagerImpl *GetInstance();
|
static DialogManagerImpl *GetInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void PositionWindow(Window *window, const Rect &rect);
|
||||||
|
|
||||||
static DialogManagerImpl ms_instance;
|
static DialogManagerImpl ms_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -444,33 +448,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
wm->PutWindowBehind(window, behindWindow);
|
wm->PutWindowBehind(window, behindWindow);
|
||||||
|
|
||||||
unsigned int displayWidth, displayHeight;
|
PositionWindow(window, rect);
|
||||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight, nullptr);
|
|
||||||
|
|
||||||
const unsigned int halfDisplayHeight = displayHeight / 2;
|
|
||||||
const unsigned int quarterDisplayWidth = displayHeight / 4;
|
|
||||||
const unsigned int halfDisplayWidth = displayWidth;
|
|
||||||
|
|
||||||
const uint16_t dialogWidth = rect.Width();
|
|
||||||
const uint16_t dialogHeight = rect.Height();
|
|
||||||
|
|
||||||
window->m_wmX = (static_cast<int32_t>(displayWidth) - static_cast<int32_t>(dialogWidth)) / 2;
|
|
||||||
|
|
||||||
// We center dialogs vertically in one of 3 ways in this priority:
|
|
||||||
// - Centered at 1/3 until the top edge is at the 1/4 mark
|
|
||||||
// - Top edge aligned to 1/4 mark until bottom edge is at 3/4 mark
|
|
||||||
// - Centered on screen
|
|
||||||
|
|
||||||
//if (displayHeight / 3 - dialogHeight / 2 >= displayHeight / 4)
|
|
||||||
if (displayHeight * 4 - dialogHeight * 6 >= displayHeight * 3)
|
|
||||||
{
|
|
||||||
//window->m_wmY = displayHeight / 3 - dialogHeight / 2;
|
|
||||||
window->m_wmY = (static_cast<int32_t>(displayHeight * 2) - static_cast<int32_t>(dialogHeight * 3)) / 6;
|
|
||||||
}
|
|
||||||
else if (dialogHeight * 2U <= displayHeight)
|
|
||||||
window->m_wmY = displayHeight / 4;
|
|
||||||
else
|
|
||||||
window->m_wmY = (static_cast<int32_t>(displayHeight) - static_cast<int32_t>(dialogHeight)) / 2;
|
|
||||||
|
|
||||||
DialogImpl *dialog = DialogImpl::Create(window, numItems);
|
DialogImpl *dialog = DialogImpl::Create(window, numItems);
|
||||||
|
|
||||||
@@ -495,6 +473,61 @@ namespace PortabilityLayer
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t DialogManagerImpl::DisplayAlert(int16_t alertResID)
|
||||||
|
{
|
||||||
|
enum AlertStageBits
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AlertResourceData
|
||||||
|
{
|
||||||
|
BERect m_rect;
|
||||||
|
BEInt16_t m_dialogTemplateResID;
|
||||||
|
|
||||||
|
// Stages are supposed to correspond to how to behave when the alert is displayed multiple times.
|
||||||
|
// We just treat all alerts as stage 1.
|
||||||
|
BEUInt16_t m_stageData;
|
||||||
|
};
|
||||||
|
|
||||||
|
BEUInt16_t autoPosition;
|
||||||
|
autoPosition = static_cast<uint16_t>(0);
|
||||||
|
|
||||||
|
THandle<void> alertResource = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('ALRT', alertResID);
|
||||||
|
if (!alertResource)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
GP_STATIC_ASSERT(sizeof(AlertResourceData) == 12);
|
||||||
|
|
||||||
|
const size_t resSize = alertResource.MMBlock()->m_rmSelfRef->m_size;
|
||||||
|
if (resSize < 12)
|
||||||
|
{
|
||||||
|
alertResource.Dispose();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertResourceData alertResData;
|
||||||
|
memcpy(&alertResData, *alertResource, 12);
|
||||||
|
|
||||||
|
if (resSize == 14)
|
||||||
|
memcpy(&autoPosition, static_cast<const uint8_t*>(*alertResource) + 12, 2);
|
||||||
|
|
||||||
|
const uint16_t stageData = alertResData.m_stageData;
|
||||||
|
uint8_t boldIndexes[4];
|
||||||
|
uint8_t soundIndexes[4];
|
||||||
|
bool isVisible[4];
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
boldIndexes[i] = static_cast<uint8_t>((stageData >> (i * 4)) & 0x1);
|
||||||
|
isVisible[i] = (((stageData >> (i * 4)) & 0x3) != 0);
|
||||||
|
soundIndexes[i] = static_cast<uint8_t>((stageData >> (i * 4 + 2)) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If sound index is 0, play no sound
|
||||||
|
|
||||||
|
PL_NotYetImplemented();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DialogTemplate *DialogManagerImpl::LoadDialogTemplate(int16_t resID)
|
DialogTemplate *DialogManagerImpl::LoadDialogTemplate(int16_t resID)
|
||||||
{
|
{
|
||||||
ResourceManager *rm = ResourceManager::GetInstance();
|
ResourceManager *rm = ResourceManager::GetInstance();
|
||||||
@@ -535,6 +568,37 @@ namespace PortabilityLayer
|
|||||||
return dtemplate;
|
return dtemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogManagerImpl::PositionWindow(Window *window, const Rect &rect)
|
||||||
|
{
|
||||||
|
unsigned int displayWidth, displayHeight;
|
||||||
|
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight, nullptr);
|
||||||
|
|
||||||
|
const unsigned int halfDisplayHeight = displayHeight / 2;
|
||||||
|
const unsigned int quarterDisplayWidth = displayHeight / 4;
|
||||||
|
const unsigned int halfDisplayWidth = displayWidth;
|
||||||
|
|
||||||
|
const uint16_t dialogWidth = rect.Width();
|
||||||
|
const uint16_t dialogHeight = rect.Height();
|
||||||
|
|
||||||
|
window->m_wmX = (static_cast<int32_t>(displayWidth) - static_cast<int32_t>(dialogWidth)) / 2;
|
||||||
|
|
||||||
|
// We center dialogs vertically in one of 3 ways in this priority:
|
||||||
|
// - Centered at 1/3 until the top edge is at the 1/4 mark
|
||||||
|
// - Top edge aligned to 1/4 mark until bottom edge is at 3/4 mark
|
||||||
|
// - Centered on screen
|
||||||
|
|
||||||
|
//if (displayHeight / 3 - dialogHeight / 2 >= displayHeight / 4)
|
||||||
|
if (displayHeight * 4 - dialogHeight * 6 >= displayHeight * 3)
|
||||||
|
{
|
||||||
|
//window->m_wmY = displayHeight / 3 - dialogHeight / 2;
|
||||||
|
window->m_wmY = (static_cast<int32_t>(displayHeight * 2) - static_cast<int32_t>(dialogHeight * 3)) / 6;
|
||||||
|
}
|
||||||
|
else if (dialogHeight * 2U <= displayHeight)
|
||||||
|
window->m_wmY = displayHeight / 4;
|
||||||
|
else
|
||||||
|
window->m_wmY = (static_cast<int32_t>(displayHeight) - static_cast<int32_t>(dialogHeight)) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
DialogManagerImpl *DialogManagerImpl::GetInstance()
|
DialogManagerImpl *DialogManagerImpl::GetInstance()
|
||||||
{
|
{
|
||||||
return &ms_instance;
|
return &ms_instance;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Dialog *LoadDialog(int16_t resID, Window *behindWindow) = 0;
|
virtual Dialog *LoadDialog(int16_t resID, Window *behindWindow) = 0;
|
||||||
|
virtual int16_t DisplayAlert(int16_t alertResID) = 0;
|
||||||
|
|
||||||
static DialogManager *GetInstance();
|
static DialogManager *GetInstance();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,12 +113,6 @@ void Delay(int ticks, UInt32 *endTickCount)
|
|||||||
*endTickCount = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount();
|
*endTickCount = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
short Alert(int dialogID, void *unknown)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
short FindWindow(Point point, WindowPtr *window)
|
short FindWindow(Point point, WindowPtr *window)
|
||||||
{
|
{
|
||||||
short part = 0;
|
short part = 0;
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ void SetCursor(CursPtr cursor);
|
|||||||
void SetBuiltinCursor(int builtinCursor);
|
void SetBuiltinCursor(int builtinCursor);
|
||||||
|
|
||||||
void Delay(int ticks, UInt32 *endTickCount);
|
void Delay(int ticks, UInt32 *endTickCount);
|
||||||
short Alert(int dialogID, void *unknown);
|
|
||||||
|
|
||||||
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
|
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
|
||||||
void DragWindow(WindowPtr window, Point start, Rect *bounds); // Drags the window (probably not implemented)
|
void DragWindow(WindowPtr window, Point start, Rect *bounds); // Drags the window (probably not implemented)
|
||||||
|
|||||||
Reference in New Issue
Block a user