mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
76db422456 | ||
|
396d107608 | ||
|
30b39c6991 | ||
|
9dafba1092 | ||
|
801408077a | ||
|
2c073937c3 | ||
|
bbd147e1ab | ||
|
66a111dd23 | ||
|
2febed5d2a | ||
|
b47813330a | ||
|
0f630a74a2 | ||
|
edc43e0bed | ||
|
2aca0b6b28 | ||
|
f9a101486c | ||
|
dbf3303145 | ||
|
a28a4cd73d | ||
|
4c6e646133 | ||
|
a13f90bd71 | ||
|
3d0e457008 | ||
|
1bded36339 |
@@ -15,8 +15,8 @@ android {
|
||||
}
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 3
|
||||
versionName "1.0.9b1"
|
||||
versionCode 4
|
||||
versionName "1.0.9b2"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=android-16"
|
||||
|
@@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
@@ -2410,6 +2410,8 @@ bool GpDisplayDriver_SDL_GL2::InitResources(uint32_t physicalWidth, uint32_t phy
|
||||
|
||||
if ((m_pixelScaleX < 2.0f && m_pixelScaleX > 1.0f) || (m_pixelScaleY < 2.0f && m_pixelScaleY > 1.0f))
|
||||
m_useUpscaleFilter = true;
|
||||
else
|
||||
m_useUpscaleFilter = false;
|
||||
|
||||
CheckGLError(m_gl, logger);
|
||||
|
||||
|
45
ApplicationResourcePatches/DITL/1041.json
Normal file
45
ApplicationResourcePatches/DITL/1041.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"items" :
|
||||
[
|
||||
{
|
||||
"name" : "Save First",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 174, 48 ],
|
||||
"size" : [ 80, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Don't Save",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 82, 48 ],
|
||||
"size" : [ 80, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Cancel",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 20, 48 ],
|
||||
"size" : [ 50, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Do you want to save the state of the game before quitting?",
|
||||
"itemType" : "Label",
|
||||
"pos" : [ 8, 8 ],
|
||||
"size" : [ 201, 32 ],
|
||||
"id" : 0,
|
||||
"enabled" : false
|
||||
},
|
||||
{
|
||||
"name" : "",
|
||||
"itemType" : "Icon",
|
||||
"pos" : [ 222, 8 ],
|
||||
"size" : [ 32, 32 ],
|
||||
"id" : 1072,
|
||||
"enabled" : false
|
||||
}
|
||||
]
|
||||
}
|
@@ -22,7 +22,7 @@
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 17, 33 ],
|
||||
"size" : [ 401, 190 ],
|
||||
"id" : 2,
|
||||
"id" : 3,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
@@ -30,9 +30,17 @@
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 418, 32 ],
|
||||
"size" : [ 16, 192 ],
|
||||
"id" : 3,
|
||||
"id" : 4,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Delete",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 228, 240 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 5,
|
||||
"enabled" : false
|
||||
},
|
||||
{
|
||||
"name" : "^0",
|
||||
"itemType" : "Label",
|
||||
|
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"name" : "Okay",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 376, 208 ],
|
||||
"pos" : [ 376, 176 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 1,
|
||||
"enabled" : true
|
||||
@@ -12,7 +12,7 @@
|
||||
{
|
||||
"name" : "Cancel",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 302, 208 ],
|
||||
"pos" : [ 302, 176 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 2,
|
||||
"enabled" : true
|
||||
@@ -21,7 +21,7 @@
|
||||
"name" : "",
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 17, 33 ],
|
||||
"size" : [ 401, 154 ],
|
||||
"size" : [ 401, 122 ],
|
||||
"id" : 2,
|
||||
"enabled" : true
|
||||
},
|
||||
@@ -29,14 +29,14 @@
|
||||
"name" : "",
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 418, 32 ],
|
||||
"size" : [ 16, 156 ],
|
||||
"size" : [ 16, 124 ],
|
||||
"id" : 3,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "",
|
||||
"itemType" : "EditBox",
|
||||
"pos" : [ 16, 208 ],
|
||||
"pos" : [ 16, 176 ],
|
||||
"size" : [ 270, 16 ],
|
||||
"id" : 4,
|
||||
"enabled" : true
|
||||
|
29
ApplicationResourcePatches/DITL/2008.json
Normal file
29
ApplicationResourcePatches/DITL/2008.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"items" :
|
||||
[
|
||||
{
|
||||
"name" : "No",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 253, 99 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 1,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Yes",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 184, 99 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 2,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Are you sure that you want to delete this file?",
|
||||
"itemType" : "Label",
|
||||
"pos" : [ 16, 16 ],
|
||||
"size" : [ 295, 74 ],
|
||||
"id" : 0,
|
||||
"enabled" : false
|
||||
}
|
||||
]
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
"add" :
|
||||
{
|
||||
"DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json",
|
||||
"DITL/1041.json" : "ApplicationResourcePatches/DITL/1041.json",
|
||||
"DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json",
|
||||
"DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json",
|
||||
"DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json",
|
||||
@@ -10,6 +11,7 @@
|
||||
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
|
||||
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
|
||||
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
|
||||
"DITL/2008.json" : "ApplicationResourcePatches/DITL/2008.json",
|
||||
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
|
||||
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
|
||||
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
|
||||
|
@@ -21,7 +21,8 @@ const D3D_SHADER_MACRO drawQuadDefs[] =
|
||||
|
||||
const D3D_SHADER_MACRO drawQuadICCProfileDefs[] =
|
||||
{
|
||||
{ "USE_ICC_PROFILE", nullptr }
|
||||
{ "USE_ICC_PROFILE", nullptr },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
const CompileJob kCompileJobs[] =
|
||||
@@ -108,7 +109,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
fprintf(stderr, "Compile failure error: %x", static_cast<int>(result));
|
||||
fprintf(stderr, "Compile failure error: %x\n", static_cast<int>(result));
|
||||
}
|
||||
|
||||
if (errorMsgs)
|
||||
|
@@ -147,8 +147,6 @@ void CenterDialog (SInt16 dialogID)
|
||||
|
||||
void GetDialogRect (Rect *bounds, short dialogID)
|
||||
{
|
||||
Byte wasState;
|
||||
|
||||
Handle dlogHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('DLOG', dialogID).StaticCast<void>();
|
||||
if (dlogHandle != nil)
|
||||
{
|
||||
@@ -343,10 +341,8 @@ void ZoomOutAlertRect (short alertID)
|
||||
|
||||
void FlashDialogButton (Dialog *theDialog, short itemNumber)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
UInt32 dummyLong;
|
||||
short itemType;
|
||||
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[itemNumber - 1].GetWidget();
|
||||
|
||||
@@ -445,9 +441,7 @@ void ToggleDialogItemValue (Dialog *theDialog, short item)
|
||||
void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
|
||||
{
|
||||
Str255 theString;
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
NumToString(theNumber, theString);
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
|
||||
@@ -570,7 +564,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
{
|
||||
ControlHandle iHandle;
|
||||
Str255 stringCopy;
|
||||
short iType, i, inset;
|
||||
short inset;
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
|
||||
@@ -622,9 +616,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
|
||||
void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
|
||||
{
|
||||
;
|
||||
Str255 stringCopy;
|
||||
short iType;
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
short BitchAboutColorDepth (void);
|
||||
void HandleMouseEvent (const GpMouseInputEvent &, uint32_t);
|
||||
void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &);
|
||||
void HandleUpdateEvent (EventRecord *);
|
||||
@@ -45,20 +44,6 @@ extern Boolean autoRoomEdit, newRoomNow, isPlayMusicIdle;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
//-------------------------------------------------------------- BitchAboutColorDepth
|
||||
// Display a dialog that alerts the user that they have switched the bit<69>
|
||||
// depth of the monitor under our noses. They must return it to previous.
|
||||
|
||||
short BitchAboutColorDepth (void)
|
||||
{
|
||||
#define kColorSwitchedAlert 1042
|
||||
short sheSaid;
|
||||
|
||||
// CenterAlert(kColorSwitchedAlert);
|
||||
sheSaid = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kColorSwitchedAlert, nullptr);
|
||||
|
||||
return (sheSaid);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HandleMouseEvent
|
||||
// Handle a mouse click event.
|
||||
|
@@ -118,7 +118,7 @@ typedef struct
|
||||
Boolean wasEscPauseKey;
|
||||
Boolean wasDoAutoDemo, wasAutoScale;
|
||||
Boolean wasDoBackground, wasHouseChecks;
|
||||
Boolean wasPrettyMap, wasBitchDialogs;
|
||||
Boolean wasPrettyMap, wasComplainDialogs;
|
||||
Boolean wasUseICCProfile;
|
||||
} prefsInfo;
|
||||
|
||||
|
@@ -425,7 +425,7 @@ void HandleBands (void); // --- RubberBands.c
|
||||
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
|
||||
void KillAllBands (void);
|
||||
|
||||
void SaveGame2 (void); // --- SavedGames.c
|
||||
Boolean SaveGame2 (void); // --- SavedGames.c
|
||||
Boolean OpenSavedGame (void);
|
||||
//void SaveGame (Boolean);
|
||||
|
||||
@@ -461,7 +461,6 @@ void DumpTriggerSound (void);
|
||||
void InitSound (void);
|
||||
void KillSound (void);
|
||||
void TellHerNoSounds (void);
|
||||
void BitchAboutSM3 (void);
|
||||
|
||||
void InitScoreboardMap (void); // --- StructuresInit.c
|
||||
void InitGliderMap (void);
|
||||
|
@@ -17,8 +17,10 @@
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "House.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PLStandardColors.h"
|
||||
@@ -27,6 +29,7 @@
|
||||
#include "RenderedFont.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "Utilities.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#define kHighScoresPictID 1994
|
||||
@@ -108,13 +111,12 @@ void DoHighScores (void)
|
||||
void DrawHighScores (DrawSurface *surface)
|
||||
{
|
||||
DrawSurface *tempMap, *tempMask;
|
||||
DrawSurface *wasCPort;
|
||||
PLError_t theErr;
|
||||
houseType *thisHousePtr;
|
||||
Rect tempRect, tempRect2;
|
||||
Str255 tempStr;
|
||||
short scoreLeft, bannerWidth, i, dropIt;
|
||||
char wasState;
|
||||
|
||||
PortabilityLayer::ResolveCachingColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
|
||||
PortabilityLayer::ResolveCachingColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255);
|
||||
PortabilityLayer::ResolveCachingColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255);
|
||||
@@ -277,7 +279,6 @@ void SortHighScores (void)
|
||||
houseType *thisHousePtr;
|
||||
long greatest;
|
||||
short i, h, which;
|
||||
char wasState;
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
@@ -313,7 +314,6 @@ void ZeroHighScores (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
short i;
|
||||
char wasState;
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
@@ -356,7 +356,6 @@ Boolean TestHighScore (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
short placing, i;
|
||||
char wasState;
|
||||
|
||||
if (resumedSavedGame)
|
||||
return (false);
|
||||
@@ -503,6 +502,19 @@ int16_t NameFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MoveDialogToTopOfScreen(Dialog *dial)
|
||||
{
|
||||
Window *window = dial->GetWindow();
|
||||
PortabilityLayer::Vec2i pos = window->GetPosition();
|
||||
|
||||
unsigned int height = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &height);
|
||||
|
||||
pos.m_y = (height - window->GetDrawSurface()->m_port.GetRect().Height()) / 8;
|
||||
|
||||
dial->GetWindow()->SetPosition(pos);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetHighScoreName
|
||||
// Brings up a dialog to get player's name (due to a high score).
|
||||
|
||||
@@ -530,6 +542,9 @@ void GetHighScoreName (short place)
|
||||
|
||||
UpdateNameDialog(theDial);
|
||||
|
||||
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
|
||||
MoveDialogToTopOfScreen(theDial);
|
||||
|
||||
Window *exclStack = theDial->GetWindow();
|
||||
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
|
||||
|
||||
@@ -640,6 +655,9 @@ void GetHighScoreBanner (void)
|
||||
|
||||
UpdateBannerDialog(theDial);
|
||||
|
||||
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
|
||||
MoveDialogToTopOfScreen(theDial);
|
||||
|
||||
Window *exclStack = theDial->GetWindow();
|
||||
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
|
||||
|
||||
|
@@ -12,7 +12,9 @@
|
||||
#include "PLSysCalls.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
#include "FileBrowserUI.h"
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "House.h"
|
||||
#include "PLStandardColors.h"
|
||||
@@ -48,6 +50,35 @@ extern Boolean houseOpen, noRoomAtAll;
|
||||
extern Boolean twoPlayerGame, wardBitSet, phoneBitSet;
|
||||
|
||||
|
||||
static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
{
|
||||
}
|
||||
|
||||
static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
|
||||
{
|
||||
}
|
||||
|
||||
static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void FBUI_FreeFileDetails(void *fileDetails)
|
||||
{
|
||||
}
|
||||
|
||||
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetHouseDetailsAPI()
|
||||
{
|
||||
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
|
||||
|
||||
api.m_drawLabelsCallback = FBUI_DrawLabels;
|
||||
api.m_drawFileDetailsCallback = FBUI_DrawFileDetails;
|
||||
api.m_loadFileDetailsCallback = FBUI_LoadFileDetails;
|
||||
api.m_freeFileDetailsCallback = FBUI_FreeFileDetails;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
//============================================================== Functions
|
||||
//-------------------------------------------------------------- CreateNewHouse
|
||||
// Called to create a new house file.
|
||||
@@ -68,7 +99,7 @@ Boolean CreateNewHouse (void)
|
||||
char savePath[sizeof(theSpec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptSaveFile(theSpec.m_dir, savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House")))
|
||||
if (!fm->PromptSaveFile(theSpec.m_dir, 'gliH', savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House"), GetHouseDetailsAPI()))
|
||||
return false;
|
||||
|
||||
assert(savePathLength < sizeof(theSpec.m_name) - 1);
|
||||
|
@@ -854,6 +854,10 @@ void YellowAlert (short whichAlert, short identifier)
|
||||
|
||||
Boolean IsFileReadOnly (const VFileSpec &spec)
|
||||
{
|
||||
// Kind of annoying, but itch.io doesn't preserve read-only flags and there doesn't seem to be any way around that.
|
||||
if (spec.m_dir == PortabilityLayer::VirtualDirectories::kApplicationData || spec.m_dir == PortabilityLayer::VirtualDirectories::kGameData)
|
||||
return true;
|
||||
|
||||
return PortabilityLayer::FileManager::GetInstance()->FileLocked(spec.m_dir, spec.m_name);
|
||||
}
|
||||
|
||||
|
@@ -602,8 +602,6 @@ Boolean KeepObjectLegal (void)
|
||||
#ifndef COMPILEDEMO
|
||||
void WrapBannerAndTrailer (void)
|
||||
{
|
||||
char wasState;
|
||||
|
||||
WrapText((*thisHouse)->banner, 40);
|
||||
WrapText((*thisHouse)->trailer, 64);
|
||||
}
|
||||
@@ -615,7 +613,6 @@ void WrapBannerAndTrailer (void)
|
||||
void ValidateNumberOfRooms (void)
|
||||
{
|
||||
long countedRooms, reportsRooms;
|
||||
char wasState;
|
||||
|
||||
reportsRooms = (long)(*thisHouse)->nRooms;
|
||||
countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) -
|
||||
@@ -637,7 +634,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
#define kRoomsTimesSuites 8192
|
||||
short i, numRooms, bitPlace;
|
||||
char *pidgeonHoles;
|
||||
char wasState;
|
||||
|
||||
pidgeonHoles = (char *)NewPtrClear(sizeof(char) * kRoomsTimesSuites);
|
||||
if (pidgeonHoles == nil)
|
||||
@@ -672,7 +668,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
void CompressHouse (void)
|
||||
{
|
||||
short wasFirstRoom, roomNumber, probe;
|
||||
char wasState;
|
||||
Boolean compressing, probing;
|
||||
|
||||
wasFirstRoom = (*thisHouse)->firstRoom;
|
||||
@@ -720,7 +715,6 @@ void LopOffExtraRooms (void)
|
||||
{
|
||||
long newSize;
|
||||
short r, count;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
count = 0;
|
||||
@@ -756,7 +750,6 @@ void LopOffExtraRooms (void)
|
||||
void ValidateRoomNumbers (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
@@ -796,7 +789,6 @@ void ValidateRoomNumbers (void)
|
||||
void CountUntitledRooms (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -814,7 +806,6 @@ void CountUntitledRooms (void)
|
||||
void CheckRoomNameLength (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -837,7 +828,6 @@ void CheckRoomNameLength (void)
|
||||
void MakeSureNumObjectsJives (void)
|
||||
{
|
||||
short i, h, numRooms, count;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -866,7 +856,6 @@ void MakeSureNumObjectsJives (void)
|
||||
void KeepAllObjectsLegal (void)
|
||||
{
|
||||
short i, h, numRooms;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
@@ -901,7 +890,6 @@ void KeepAllObjectsLegal (void)
|
||||
void CheckForStaircasePairs (void)
|
||||
{
|
||||
short i, h, g, numRooms, neighbor;
|
||||
char wasState;
|
||||
Boolean hasStairs;
|
||||
Str255 message;
|
||||
|
||||
|
@@ -42,7 +42,7 @@ void DoPause (void);
|
||||
void DoTouchScreenMenu (void);
|
||||
void DoBatteryEngaged (gliderPtr);
|
||||
void DoHeliumEngaged (gliderPtr);
|
||||
Boolean QuerySaveGame (void);
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
||||
|
||||
|
||||
demoPtr demoData;
|
||||
@@ -75,13 +75,24 @@ void DoCommandKey (void)
|
||||
|
||||
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||
{
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
if (QuerySaveGame())
|
||||
SaveGame2(); // New save game.
|
||||
Boolean wantSave = false;
|
||||
QuerySaveGame(wantSave, wantCancel);
|
||||
|
||||
if (wantSave)
|
||||
{
|
||||
// New save game.
|
||||
if (!SaveGame2())
|
||||
wantCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantCancel)
|
||||
playing = true;
|
||||
}
|
||||
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
||||
{
|
||||
@@ -326,12 +337,23 @@ void DoTouchScreenMenu(void)
|
||||
switch (highlightedItem)
|
||||
{
|
||||
case TouchScreenMenuItems::kQuit:
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
if (QuerySaveGame())
|
||||
SaveGame2(); // New save game.
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
Boolean wantSave = false;
|
||||
QuerySaveGame(wantSave, wantCancel);
|
||||
if (wantSave)
|
||||
{
|
||||
if (!SaveGame2()) // New save game.
|
||||
wantCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantCancel)
|
||||
playing = true;
|
||||
}
|
||||
break;
|
||||
case TouchScreenMenuItems::kSave:
|
||||
@@ -793,19 +815,19 @@ void GetInput (gliderPtr thisGlider)
|
||||
|
||||
//-------------------------------------------------------------- QuerySaveGame
|
||||
|
||||
Boolean QuerySaveGame (void)
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
||||
{
|
||||
#define kSaveGameAlert 1041
|
||||
#define kYesSaveGameButton 1
|
||||
#define kNoSaveGameButton 2
|
||||
#define kCancelSaveGameButton 3
|
||||
short hitWhat;
|
||||
|
||||
InitCursor();
|
||||
FlushEvents();
|
||||
// CenterAlert(kSaveGameAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
|
||||
if (hitWhat == kYesSaveGameButton)
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
save = (hitWhat == kYesSaveGameButton);
|
||||
cancel = (hitWhat == kCancelSaveGameButton);
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,6 @@ void InitializeMenus (void)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
//AppendResMenu(appleMenu, 'DRVR'); // GP: We don't support this
|
||||
AppendMenuItem(appleMenu, 0, 0, 0, 0, true, false, PSTR("About " GP_APPLICATION_NAME "\xc9"));
|
||||
AppendMenuItem(appleMenu, 0, 0, 0, 0, true, false, PSTR("Export Source Code\xc9"));
|
||||
InsertMenu(appleMenu, 0);
|
||||
|
||||
gameMenu = GetMenu(kGameMenuID);
|
||||
@@ -176,8 +175,6 @@ void RecomputeInterfaceRects (void)
|
||||
|
||||
void VariableInit (void)
|
||||
{
|
||||
short i;
|
||||
|
||||
menusUp = false;
|
||||
quitting = false;
|
||||
houseOpen = false;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "MemoryManager.h"
|
||||
#include "MenuManager.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "QDStandardPalette.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "ResourceManager.h"
|
||||
@@ -71,7 +72,7 @@ extern Boolean isMusicOn, isSoundOn, isPlayMusicIdle, isHouseChecks;
|
||||
extern Boolean houseOpen, isDoColorFade, isEscPauseKey;
|
||||
extern Boolean autoRoomEdit, doAutoDemo, doBackground;
|
||||
extern Boolean isMapOpen, isToolsOpen, isCoordOpen;
|
||||
extern Boolean doPrettyMap, doBitchDialogs;
|
||||
extern Boolean doPrettyMap, doComplainDialogs;
|
||||
//extern Boolean didValidation;
|
||||
|
||||
THandle<void> globalModulePrefs;
|
||||
@@ -159,7 +160,7 @@ void ReadInPrefs (void)
|
||||
isUseICCProfile = thePrefs.wasUseICCProfile;
|
||||
doBackground = thePrefs.wasDoBackground;
|
||||
doPrettyMap = thePrefs.wasPrettyMap;
|
||||
doBitchDialogs = thePrefs.wasBitchDialogs;
|
||||
doComplainDialogs = thePrefs.wasComplainDialogs;
|
||||
|
||||
if (modulePrefs)
|
||||
ApplyModulePrefs(&modulePrefs);
|
||||
@@ -244,7 +245,7 @@ void ReadInPrefs (void)
|
||||
isUseICCProfile = true;
|
||||
doBackground = false;
|
||||
doPrettyMap = false;
|
||||
doBitchDialogs = true;
|
||||
doComplainDialogs = true;
|
||||
|
||||
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance();
|
||||
if (!displayDriver->IsFullScreen())
|
||||
@@ -345,7 +346,7 @@ void WriteOutPrefs (void)
|
||||
thePrefs.wasUseICCProfile = isUseICCProfile;
|
||||
thePrefs.wasDoBackground = doBackground;
|
||||
thePrefs.wasPrettyMap = doPrettyMap;
|
||||
thePrefs.wasBitchDialogs = doBitchDialogs;
|
||||
thePrefs.wasComplainDialogs = doComplainDialogs;
|
||||
|
||||
THandle<void> modulePrefs;
|
||||
|
||||
@@ -380,7 +381,7 @@ void StepLoadScreen(int steps)
|
||||
{
|
||||
Rect loadScreenProgressBarFillRect = loadScreenProgressBarRect.Inset(1, 1);
|
||||
int oldProgress = loadScreenProgress;
|
||||
int loadScreenMax = 25;
|
||||
int loadScreenMax = 32;
|
||||
loadScreenProgress = loadScreenProgress + steps;
|
||||
if (loadScreenProgress > loadScreenMax)
|
||||
loadScreenProgress = loadScreenMax;
|
||||
@@ -612,7 +613,32 @@ void PreloadFonts()
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void PreloadAATables()
|
||||
{
|
||||
PortabilityLayer::StandardPalette *sp = PortabilityLayer::StandardPalette::GetInstance();
|
||||
PortabilityLayer::RGBAColor preloadColors[] =
|
||||
{
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 51, 51, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 0, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 0, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(204, 102, 51, 255),
|
||||
};
|
||||
|
||||
const size_t numPreloads = sizeof(preloadColors) / sizeof(preloadColors[0]);
|
||||
|
||||
for (size_t i = 0; i < numPreloads; i++)
|
||||
{
|
||||
sp->GetCachedPaletteAATable(preloadColors[i]);
|
||||
sp->GetCachedToneAATable(preloadColors[i].r);
|
||||
sp->GetCachedToneAATable(preloadColors[i].g);
|
||||
sp->GetCachedToneAATable(preloadColors[i].b);
|
||||
StepLoadScreen(1);
|
||||
}
|
||||
}
|
||||
|
||||
void gpAppInit()
|
||||
@@ -655,6 +681,7 @@ int gpAppMain()
|
||||
|
||||
InitLoadingWindow(); StepLoadScreen(2);
|
||||
PreloadFonts(); StepLoadScreen(2);
|
||||
PreloadAATables();
|
||||
|
||||
#if defined COMPILEDEMO
|
||||
copyGood = true;
|
||||
|
@@ -53,7 +53,7 @@ short isMapH, isMapV, mapRoomsHigh, mapRoomsWide;
|
||||
short mapLeftRoom, mapTopRoom;
|
||||
Boolean isMapOpen, doPrettyMap;
|
||||
|
||||
extern Boolean doBitchDialogs;
|
||||
extern Boolean doComplainDialogs;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
@@ -651,7 +651,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doBitchDialogs)
|
||||
if (doComplainDialogs)
|
||||
{
|
||||
if (QueryNewRoom())
|
||||
{
|
||||
|
@@ -35,7 +35,7 @@ short numberRooms, thisRoomNumber, previousRoom;
|
||||
short leftThresh, rightThresh, lastBackground;
|
||||
Boolean autoRoomEdit, newRoomNow, noRoomAtAll;
|
||||
Boolean leftOpen, rightOpen, topOpen, bottomOpen;
|
||||
Boolean doBitchDialogs;
|
||||
Boolean doComplainDialogs;
|
||||
|
||||
extern short tempTiles[];
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void UpdateOriginalArt (Dialog *);
|
||||
int16_t OriginalArtFilter (void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
Boolean PictIDExists (short);
|
||||
short GetFirstPICT (void);
|
||||
void BitchAboutPICTNotFound (void);
|
||||
void ComplainAboutPICTNotFound (void);
|
||||
|
||||
|
||||
Rect tileSrc, tileDest, tileSrcRect, editTETextBox;
|
||||
@@ -441,7 +441,7 @@ void DoRoomInfo(void)
|
||||
// SetPort((GrafPtr)tileSrcMap);
|
||||
if ((tempBack > kStars) && (!PictIDExists(tempBack)))
|
||||
{
|
||||
BitchAboutPICTNotFound();
|
||||
ComplainAboutPICTNotFound();
|
||||
tempBack = kSimpleRoom;
|
||||
}
|
||||
if ((tempBack == 2002) || (tempBack == 2011) ||
|
||||
@@ -869,10 +869,10 @@ short GetFirstPICT (void)
|
||||
return resID;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutPICTNotFound
|
||||
//-------------------------------------------------------------- ComplainAboutPICTNotFound
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
void BitchAboutPICTNotFound (void)
|
||||
void ComplainAboutPICTNotFound (void)
|
||||
{
|
||||
short hitWhat;
|
||||
|
||||
|
@@ -9,16 +9,19 @@
|
||||
#include "PLStringCompare.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Externs.h"
|
||||
#include "FileBrowserUI.h"
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "House.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "InputManager.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#define kSavedGameVersion 0x0200
|
||||
|
||||
|
||||
@@ -33,9 +36,87 @@ extern Boolean twoPlayerGame;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
|
||||
static const int kStarsOffset = 180;
|
||||
static const int kGlidersOffset = 260;
|
||||
static const int kScoreOffset = 320;
|
||||
|
||||
static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
|
||||
surface->DrawString(basePoint + Point::Create(kStarsOffset, 0), PSTR("Stars Left"), blackColor, rfont);
|
||||
surface->DrawString(basePoint + Point::Create(kGlidersOffset, 0), PSTR("Gliders"), blackColor, rfont);
|
||||
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), PSTR("Score"), blackColor, rfont);
|
||||
}
|
||||
|
||||
static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
|
||||
const game2Type *gameData = static_cast<const game2Type*>(fileDetails);
|
||||
|
||||
Str255 numStr;
|
||||
|
||||
NumToString(gameData->wasStarsLeft, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kStarsOffset, 0), numStr, blackColor, rfont);
|
||||
|
||||
NumToString(gameData->numGliders, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kGlidersOffset, 0), numStr, blackColor, rfont);
|
||||
|
||||
NumToString(gameData->score, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), numStr, blackColor, rfont);
|
||||
}
|
||||
|
||||
static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
GpIOStream *stream = nullptr;
|
||||
if (PortabilityLayer::FileManager::GetInstance()->OpenFileData(dirID, filename, PortabilityLayer::EFilePermission_Read, stream) != PLErrors::kNone)
|
||||
return nullptr;
|
||||
|
||||
const size_t kPrefixSize = sizeof(game2Type) - sizeof(savedRoom);
|
||||
|
||||
game2Type *gameData = static_cast<game2Type*>(PortabilityLayer::MemoryManager::GetInstance()->Alloc(kPrefixSize));
|
||||
if (!gameData)
|
||||
{
|
||||
stream->Close();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (stream->Read(gameData, kPrefixSize) != kPrefixSize)
|
||||
{
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(gameData);
|
||||
stream->Close();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
|
||||
return gameData;
|
||||
}
|
||||
|
||||
static void FBUI_FreeFileDetails(void *fileDetails)
|
||||
{
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(fileDetails);
|
||||
}
|
||||
|
||||
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI()
|
||||
{
|
||||
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
|
||||
|
||||
api.m_drawLabelsCallback = FBUI_DrawLabels;
|
||||
api.m_drawFileDetailsCallback = FBUI_DrawFileDetails;
|
||||
api.m_loadFileDetailsCallback = FBUI_LoadFileDetails;
|
||||
api.m_freeFileDetailsCallback = FBUI_FreeFileDetails;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SaveGame2
|
||||
|
||||
void SaveGame2 (void)
|
||||
Boolean SaveGame2 (void)
|
||||
{
|
||||
// Bringing up the save file UI can cause key/mouse events to be missed, resulting in state being stuck when this comes back.
|
||||
// To avoid that, clear all state here.
|
||||
@@ -65,7 +146,7 @@ void SaveGame2 (void)
|
||||
if (savedGame == nil)
|
||||
{
|
||||
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(savedGame, 0, byteCount);
|
||||
@@ -82,10 +163,10 @@ void SaveGame2 (void)
|
||||
char savePath[sizeof(spec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptSaveFile(spec.m_dir, savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game")))
|
||||
if (!fm->PromptSaveFile(spec.m_dir, 'gliG', savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), GetSavedGameDetailsAPI()))
|
||||
{
|
||||
mm->Release(savedGame);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||
@@ -98,7 +179,7 @@ void SaveGame2 (void)
|
||||
if (!fm->DeleteFile(spec.m_dir, spec.m_name))
|
||||
{
|
||||
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +233,8 @@ void SaveGame2 (void)
|
||||
}
|
||||
|
||||
mm->Release(savedGame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SavedGameMismatchError
|
||||
@@ -191,7 +274,7 @@ Boolean OpenSavedGame (void)
|
||||
char savePath[sizeof(spec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptOpenFile(spec.m_dir, savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game")))
|
||||
if (!fm->PromptOpenFile(spec.m_dir, 'gliG', savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game"), GetSavedGameDetailsAPI()))
|
||||
return false;
|
||||
|
||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||
|
@@ -72,7 +72,7 @@
|
||||
#define kDoBackgroundCheck 11
|
||||
#define kDoErrorCheck 12
|
||||
#define kDoPrettyMapCheck 13
|
||||
#define kDoBitchDlgsCheck 14
|
||||
#define kDoComplainDlgsCheck 14
|
||||
|
||||
|
||||
void SetBrainsToDefaults (Dialog *);
|
||||
@@ -98,7 +98,7 @@ void SetAllDefaults (void);
|
||||
void FlashSettingsButton (DrawSurface *, short);
|
||||
void UpdateSettingsMain (Dialog *);
|
||||
int16_t PrefsFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
void BitchAboutChanges (void);
|
||||
void ComplainAboutChanges (void);
|
||||
void WriteOutPrefs (void);
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
|
||||
short whichCtrl, wasDepthPref;
|
||||
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
|
||||
Boolean wasEscPauseKey, wasDemos, wasAutoScale, wasUseICCProfile, nextRestartChange, wasErrorCheck, wasFullscreenPref, needResolutionReset;
|
||||
Boolean wasPrettyMap, wasBitchDialogs;
|
||||
Boolean wasPrettyMap, wasComplainDialogs;
|
||||
|
||||
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
|
||||
extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale, isUseICCProfile;
|
||||
extern Boolean isHouseChecks, doBitchDialogs;
|
||||
extern Boolean isHouseChecks, doComplainDialogs;
|
||||
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
|
||||
extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
|
||||
extern Boolean changeLockStateOfHouse, saveHouseLocked, doPrettyMap;
|
||||
@@ -135,14 +135,14 @@ void SetBrainsToDefaults (Dialog *theDialog)
|
||||
wasBackground = false;
|
||||
wasErrorCheck = true;
|
||||
wasPrettyMap = true;
|
||||
wasBitchDialogs = true;
|
||||
wasComplainDialogs = true;
|
||||
SetDialogItemValue(theDialog, kQuickTransitCheck, (short)wasTransit);
|
||||
SetDialogItemValue(theDialog, kDoZoomsCheck, (short)wasZooms);
|
||||
SetDialogItemValue(theDialog, kDoDemoCheck, (short)wasDemos);
|
||||
SetDialogItemValue(theDialog, kDoBackgroundCheck, (short)wasBackground);
|
||||
SetDialogItemValue(theDialog, kDoErrorCheck, (short)wasErrorCheck);
|
||||
SetDialogItemValue(theDialog, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
SetDialogItemValue(theDialog, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
SetDialogItemValue(theDialog, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- UpdateSettingsBrains
|
||||
@@ -238,7 +238,7 @@ void DoBrainsPrefs (void)
|
||||
wasBackground = doBackground;
|
||||
wasErrorCheck = isHouseChecks;
|
||||
wasPrettyMap = doPrettyMap;
|
||||
wasBitchDialogs = doBitchDialogs;
|
||||
wasComplainDialogs = doComplainDialogs;
|
||||
|
||||
SetDialogItemValue(prefDlg, kQuickTransitCheck, (short)wasTransit);
|
||||
SetDialogItemValue(prefDlg, kDoZoomsCheck, (short)wasZooms);
|
||||
@@ -246,7 +246,7 @@ void DoBrainsPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kDoBackgroundCheck, (short)wasBackground);
|
||||
SetDialogItemValue(prefDlg, kDoErrorCheck, (short)wasErrorCheck);
|
||||
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
|
||||
UpdateSettingsBrains(prefDlg);
|
||||
|
||||
@@ -272,7 +272,7 @@ void DoBrainsPrefs (void)
|
||||
doBackground = wasBackground;
|
||||
isHouseChecks = wasErrorCheck;
|
||||
doPrettyMap = wasPrettyMap;
|
||||
doBitchDialogs = wasBitchDialogs;
|
||||
doComplainDialogs = wasComplainDialogs;
|
||||
leaving = true;
|
||||
break;
|
||||
|
||||
@@ -315,9 +315,9 @@ void DoBrainsPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
break;
|
||||
|
||||
case kDoBitchDlgsCheck:
|
||||
wasBitchDialogs = !wasBitchDialogs;
|
||||
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
case kDoComplainDlgsCheck:
|
||||
wasComplainDialogs = !wasComplainDialogs;
|
||||
SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1121,7 +1121,7 @@ void SetAllDefaults (void)
|
||||
doBackground = false;
|
||||
isHouseChecks = true;
|
||||
doPrettyMap = true;
|
||||
doBitchDialogs = true;
|
||||
doComplainDialogs = true;
|
||||
// Default control settings
|
||||
PasStringCopy(PSTR("lf arrow"), leftName);
|
||||
PasStringCopy(PSTR("rt arrow"), rightName);
|
||||
@@ -1340,7 +1340,7 @@ void DoSettingsMain (void)
|
||||
|
||||
if (nextRestartChange)
|
||||
{
|
||||
BitchAboutChanges();
|
||||
ComplainAboutChanges();
|
||||
nextRestartChange = false;
|
||||
}
|
||||
|
||||
@@ -1363,9 +1363,9 @@ void DoSettingsMain (void)
|
||||
WriteOutPrefs();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutChanges
|
||||
//-------------------------------------------------------------- ComplainAboutChanges
|
||||
|
||||
void BitchAboutChanges (void)
|
||||
void ComplainAboutChanges (void)
|
||||
{
|
||||
#define kChangesEffectAlert 1040
|
||||
short hitWhat;
|
||||
|
@@ -378,17 +378,6 @@ void TellHerNoSounds (void)
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert, nullptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutSM3
|
||||
|
||||
void BitchAboutSM3 (void)
|
||||
{
|
||||
#define kNoSoundManager3Alert 1030
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoSoundManager3Alert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoSoundManager3Alert, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------- ParseAndConvertSound
|
||||
|
@@ -1,10 +1,10 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 232, 177, 184, 42, 191, 44, 237, 186, 185, 1, 42,
|
||||
67, 157, 207, 200, 70, 1, 0, 0, 0, 116, 5, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 52, 1, 0, 0, 140, 1, 0, 0, 192,
|
||||
1, 0, 0, 248, 4, 0, 0, 82, 68, 69, 70, 248, 0, 0, 0,
|
||||
68, 88, 66, 67, 36, 129, 233, 7, 7, 186, 125, 28, 230, 207, 54,
|
||||
71, 251, 69, 112, 99, 1, 0, 0, 0, 144, 5, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 60, 1, 0, 0, 148, 1, 0, 0, 200,
|
||||
1, 0, 0, 20, 5, 0, 0, 82, 68, 69, 70, 0, 1, 0, 0,
|
||||
1, 0, 0, 0, 132, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 208, 0, 0, 0, 92, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 216, 0, 0, 0, 92, 0,
|
||||
0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 255,
|
||||
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 9, 0, 0, 0,
|
||||
107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -14,85 +14,86 @@ static unsigned char gs_shaderData[] = {
|
||||
101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 107, 0, 0,
|
||||
0, 1, 0, 0, 0, 156, 0, 0, 0, 16, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 180, 0, 0, 0, 0, 0, 0, 0, 16,
|
||||
0, 0, 0, 2, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0,
|
||||
100, 120, 100, 121, 95, 85, 110, 117, 115, 101, 100, 0, 1, 0, 3,
|
||||
0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 105,
|
||||
99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 76, 83,
|
||||
76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108,
|
||||
101, 114, 32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 80, 0, 0,
|
||||
0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15,
|
||||
0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95,
|
||||
80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79,
|
||||
82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0, 1,
|
||||
0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0,
|
||||
0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72,
|
||||
68, 82, 48, 3, 0, 0, 64, 0, 0, 0, 204, 0, 0, 0, 89,
|
||||
0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0,
|
||||
88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85, 85, 0,
|
||||
0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 101, 0,
|
||||
0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2, 5,
|
||||
0, 0, 0, 51, 0, 0, 11, 50, 0, 16, 0, 0, 0, 0, 0,
|
||||
70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 64, 0,
|
||||
0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 50, 0, 0, 14, 194, 0, 16, 0, 0, 0, 0, 0, 6,
|
||||
132, 32, 128, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
63, 0, 0, 0, 63, 6, 20, 16, 0, 1, 0, 0, 0, 52, 0,
|
||||
0, 10, 194, 0, 16, 0, 0, 0, 0, 0, 166, 14, 16, 0, 0,
|
||||
0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 50, 0, 16,
|
||||
0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 230, 10,
|
||||
16, 0, 0, 0, 0, 0, 65, 0, 0, 5, 194, 0, 16, 0, 0,
|
||||
0, 0, 0, 166, 14, 16, 0, 0, 0, 0, 0, 27, 0, 0, 5,
|
||||
50, 0, 16, 0, 1, 0, 0, 0, 230, 10, 16, 0, 0, 0, 0,
|
||||
0, 65, 0, 0, 5, 194, 0, 16, 0, 0, 0, 0, 0, 6, 4,
|
||||
16, 0, 0, 0, 0, 0, 0, 0, 0, 8, 50, 0, 16, 0, 0,
|
||||
0, 0, 0, 230, 10, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0,
|
||||
70, 0, 16, 0, 0, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16,
|
||||
0, 2, 0, 0, 0, 230, 10, 16, 0, 0, 0, 0, 0, 14, 32,
|
||||
0, 8, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0,
|
||||
0, 0, 0, 70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
54, 0, 0, 5, 66, 0, 16, 0, 1, 0, 0, 0, 1, 64, 0,
|
||||
0, 0, 0, 0, 0, 54, 0, 0, 5, 194, 0, 16, 0, 2, 0,
|
||||
0, 0, 86, 9, 16, 0, 1, 0, 0, 0, 45, 0, 0, 7, 242,
|
||||
0, 16, 0, 3, 0, 0, 0, 70, 15, 16, 0, 2, 0, 0, 0,
|
||||
70, 126, 16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16,
|
||||
0, 4, 0, 0, 0, 134, 15, 16, 0, 2, 0, 0, 0, 70, 126,
|
||||
16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130, 0, 16, 0, 1,
|
||||
0, 0, 0, 26, 0, 16, 0, 2, 0, 0, 0, 45, 0, 0, 7,
|
||||
242, 0, 16, 0, 2, 0, 0, 0, 198, 10, 16, 0, 1, 0, 0,
|
||||
0, 70, 126, 16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0,
|
||||
16, 0, 1, 0, 0, 0, 70, 10, 16, 0, 1, 0, 0, 0, 70,
|
||||
126, 16, 0, 0, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0,
|
||||
4, 0, 0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16,
|
||||
0, 4, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0, 3, 0,
|
||||
0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 3,
|
||||
0, 0, 0, 0, 0, 0, 11, 82, 0, 16, 0, 0, 0, 0, 0,
|
||||
6, 1, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 64, 0,
|
||||
0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0,
|
||||
0, 0, 50, 0, 0, 9, 114, 0, 16, 0, 2, 0, 0, 0, 6,
|
||||
0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0,
|
||||
70, 2, 16, 0, 3, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16,
|
||||
0, 2, 0, 0, 0, 86, 5, 16, 0, 0, 0, 0, 0, 70, 2,
|
||||
16, 0, 2, 0, 0, 0, 50, 0, 0, 9, 178, 0, 16, 0, 0,
|
||||
0, 0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 8, 16, 0,
|
||||
1, 0, 0, 0, 70, 8, 16, 0, 4, 0, 0, 0, 50, 0, 0,
|
||||
9, 114, 32, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0, 0, 0,
|
||||
0, 0, 70, 3, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 2,
|
||||
0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0, 0,
|
||||
1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84, 65,
|
||||
84, 116, 0, 0, 0, 26, 0, 0, 0, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 2, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0,
|
||||
100, 120, 100, 121, 95, 73, 110, 118, 80, 105, 120, 101, 108, 83, 99,
|
||||
97, 108, 101, 0, 171, 1, 0, 3, 0, 1, 0, 4, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116,
|
||||
32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101,
|
||||
114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49,
|
||||
0, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0,
|
||||
0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3,
|
||||
0, 0, 0, 0, 0, 0, 0, 15, 3, 0, 0, 68, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0,
|
||||
0, 3, 0, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79,
|
||||
78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79,
|
||||
83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0,
|
||||
32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 65, 82,
|
||||
71, 69, 84, 0, 171, 171, 83, 72, 68, 82, 68, 3, 0, 0, 64,
|
||||
0, 0, 0, 209, 0, 0, 0, 89, 0, 0, 4, 70, 142, 32, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 88, 24, 0, 4, 0, 112, 16,
|
||||
0, 0, 0, 0, 0, 85, 85, 0, 0, 100, 32, 0, 4, 50, 16,
|
||||
16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 101, 0, 0, 3, 242,
|
||||
32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2, 5, 0, 0, 0,
|
||||
0, 0, 0, 10, 50, 0, 16, 0, 0, 0, 0, 0, 70, 16, 16,
|
||||
0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 191, 0, 0,
|
||||
0, 191, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 8, 50,
|
||||
0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0,
|
||||
230, 138, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0,
|
||||
10, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0,
|
||||
0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 11, 194, 0, 16, 0,
|
||||
0, 0, 0, 0, 6, 132, 32, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
128, 63, 0, 0, 128, 63, 0, 0, 0, 7, 194, 0, 16, 0, 0,
|
||||
0, 0, 0, 166, 14, 16, 0, 0, 0, 0, 0, 6, 4, 16, 0,
|
||||
0, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0,
|
||||
0, 70, 0, 16, 0, 0, 0, 0, 0, 27, 0, 0, 5, 50, 0,
|
||||
16, 0, 1, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 65,
|
||||
0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 230, 10, 16, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0,
|
||||
0, 6, 4, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0, 166, 14,
|
||||
16, 0, 0, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 2,
|
||||
0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 14, 32, 0, 8,
|
||||
50, 0, 16, 0, 0, 0, 0, 0, 230, 10, 16, 0, 0, 0, 0,
|
||||
0, 70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0,
|
||||
0, 5, 66, 0, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0,
|
||||
0, 0, 0, 54, 0, 0, 5, 194, 0, 16, 0, 2, 0, 0, 0,
|
||||
86, 9, 16, 0, 1, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16,
|
||||
0, 3, 0, 0, 0, 70, 15, 16, 0, 2, 0, 0, 0, 70, 126,
|
||||
16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 4,
|
||||
0, 0, 0, 134, 15, 16, 0, 2, 0, 0, 0, 70, 126, 16, 0,
|
||||
0, 0, 0, 0, 54, 0, 0, 5, 130, 0, 16, 0, 1, 0, 0,
|
||||
0, 26, 0, 16, 0, 2, 0, 0, 0, 45, 0, 0, 7, 242, 0,
|
||||
16, 0, 2, 0, 0, 0, 198, 10, 16, 0, 1, 0, 0, 0, 70,
|
||||
126, 16, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0,
|
||||
1, 0, 0, 0, 70, 10, 16, 0, 1, 0, 0, 0, 70, 126, 16,
|
||||
0, 0, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0, 4, 0,
|
||||
0, 0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 4,
|
||||
0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0, 3, 0, 0, 0,
|
||||
6, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 11, 82, 0, 16, 0, 0, 0, 0, 0, 6, 1,
|
||||
16, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0,
|
||||
0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0,
|
||||
50, 0, 0, 9, 114, 0, 16, 0, 2, 0, 0, 0, 6, 0, 16,
|
||||
0, 0, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 2,
|
||||
16, 0, 3, 0, 0, 0, 56, 0, 0, 7, 114, 0, 16, 0, 2,
|
||||
0, 0, 0, 86, 5, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0,
|
||||
2, 0, 0, 0, 50, 0, 0, 9, 178, 0, 16, 0, 0, 0, 0,
|
||||
0, 6, 0, 16, 0, 0, 0, 0, 0, 70, 8, 16, 0, 1, 0,
|
||||
0, 0, 70, 8, 16, 0, 4, 0, 0, 0, 50, 0, 0, 9, 114,
|
||||
32, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0, 0, 0, 0, 0,
|
||||
70, 3, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0,
|
||||
0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0, 0, 1, 64,
|
||||
0, 0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84, 65, 84, 116,
|
||||
0, 0, 0, 27, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4,
|
||||
0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
|
@@ -814,10 +814,10 @@ void GpDisplayDriverD3D11::ScaleVirtualScreen()
|
||||
float fHeight = static_cast<float>(m_windowHeightVirtual) * m_pixelScaleY;
|
||||
|
||||
DrawQuadVertexConstants vConstantsData;
|
||||
vConstantsData.m_ndcOriginX = twoDivWidth - 1.0f;
|
||||
vConstantsData.m_ndcOriginY = negativeTwoDivHeight + 1.0f;
|
||||
vConstantsData.m_ndcWidth = fWidth * twoDivWidth;
|
||||
vConstantsData.m_ndcHeight = fHeight * negativeTwoDivHeight;
|
||||
vConstantsData.m_ndcOriginX = - 1.0f;
|
||||
vConstantsData.m_ndcOriginY = 1.0f;
|
||||
vConstantsData.m_ndcWidth = 2.0;
|
||||
vConstantsData.m_ndcHeight = -2.0;
|
||||
|
||||
vConstantsData.m_surfaceDimensionX = static_cast<float>(m_windowWidthVirtual);
|
||||
vConstantsData.m_surfaceDimensionY = static_cast<float>(m_windowHeightVirtual);
|
||||
@@ -832,6 +832,8 @@ void GpDisplayDriverD3D11::ScaleVirtualScreen()
|
||||
ScaleQuadPixelConstants pConstantsData;
|
||||
pConstantsData.m_dx = static_cast<float>(static_cast<double>(m_windowWidthVirtual) / static_cast<double>(m_windowWidthPhysical));
|
||||
pConstantsData.m_dy = static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical));
|
||||
pConstantsData.m_invScaleX = static_cast<float>(1.0f / m_pixelScaleX);
|
||||
pConstantsData.m_invScaleY = static_cast<float>(1.0f / m_pixelScaleY);
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mappedPConstants;
|
||||
if (m_deviceContext->Map(m_scaleQuadPixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedPConstants) == S_OK)
|
||||
@@ -1127,7 +1129,7 @@ void GpDisplayDriverD3D11::Run()
|
||||
HMENU menus = NULL;
|
||||
|
||||
// TODO: Fix the resolution here
|
||||
RECT wr = { 0, 0, m_windowWidthPhysical, m_windowHeightPhysical };
|
||||
RECT wr = { 0, 0, static_cast<DWORD>(m_windowWidthPhysical), static_cast<DWORD>(m_windowHeightPhysical) };
|
||||
AdjustWindowRect(&wr, windowStyle, menus != NULL);
|
||||
|
||||
m_osGlobals->m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W, WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
|
||||
|
@@ -99,7 +99,8 @@ private:
|
||||
{
|
||||
float m_dx;
|
||||
float m_dy;
|
||||
float m_unused[2];
|
||||
float m_invScaleX;
|
||||
float m_invScaleY;
|
||||
};
|
||||
|
||||
struct CompactedPresentHistoryItem
|
||||
|
@@ -11,14 +11,14 @@
|
||||
void GpDisplayDriverSurfaceD3D11::Upload(const void *data, size_t x, size_t y, size_t width, size_t height, size_t pitch)
|
||||
{
|
||||
D3D11_BOX box;
|
||||
box.left = x;
|
||||
box.right = x + width;
|
||||
box.top = y;
|
||||
box.bottom = y + height;
|
||||
box.left = static_cast<UINT>(x);
|
||||
box.right = static_cast<UINT>(x + width);
|
||||
box.top = static_cast<UINT>(y);
|
||||
box.bottom = static_cast<UINT>(y + height);
|
||||
box.front = 0;
|
||||
box.back = 1;
|
||||
|
||||
m_deviceContext->UpdateSubresource(m_texture, 0, &box, data, pitch, height * pitch);
|
||||
m_deviceContext->UpdateSubresource(m_texture, 0, &box, data, pitch, static_cast<UINT>(height * pitch));
|
||||
}
|
||||
|
||||
void GpDisplayDriverSurfaceD3D11::UploadEntire(const void *data, size_t pitch)
|
||||
|
@@ -1,5 +1,8 @@
|
||||
#include "AntiAliasTable.h"
|
||||
#include "RGBAColor.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "PLBigEndian.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
@@ -58,8 +61,49 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
#else
|
||||
void AntiAliasTable::GenerateForPalette(const RGBAColor &baseColorRef, const RGBAColor *colors, size_t numColors)
|
||||
bool AntiAliasTable::LoadFromCache(const char *cacheFileName)
|
||||
{
|
||||
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
BEUInt32_t cacheVersion;
|
||||
if (stream->Read(&cacheVersion, sizeof(cacheVersion)) != sizeof(cacheVersion) || cacheVersion != kCacheVersion)
|
||||
{
|
||||
stream->Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t readSize = sizeof(m_aaTranslate);
|
||||
const bool readOK = (stream->Read(m_aaTranslate, readSize) == readSize);
|
||||
stream->Close();
|
||||
|
||||
return readOK;
|
||||
}
|
||||
|
||||
void AntiAliasTable::SaveToCache(const char *cacheFileName)
|
||||
{
|
||||
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, true, GpFileCreationDispositions::kCreateOrOverwrite);
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
BEUInt32_t cacheVersion(static_cast<uint32_t>(kCacheVersion));
|
||||
stream->Write(&cacheVersion, sizeof(cacheVersion));
|
||||
|
||||
stream->Write(m_aaTranslate, sizeof(m_aaTranslate));
|
||||
stream->Close();
|
||||
}
|
||||
|
||||
void AntiAliasTable::GenerateForPalette(const RGBAColor &baseColorRef, const RGBAColor *colors, size_t numColors, bool cacheable)
|
||||
{
|
||||
char cacheFileName[256];
|
||||
if (cacheable)
|
||||
{
|
||||
sprintf(cacheFileName, "aa_p_%02x%02x%02x%02x.cache", static_cast<int>(baseColorRef.r), static_cast<int>(baseColorRef.g), static_cast<int>(baseColorRef.b), static_cast<int>(baseColorRef.a));
|
||||
if (LoadFromCache(cacheFileName))
|
||||
return;
|
||||
}
|
||||
|
||||
const RGBAColor baseColor = baseColorRef;
|
||||
|
||||
if (numColors > 256)
|
||||
@@ -118,10 +162,21 @@ namespace PortabilityLayer
|
||||
m_aaTranslate[i][b] = static_cast<uint8_t>(bestColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheable)
|
||||
SaveToCache(cacheFileName);
|
||||
}
|
||||
|
||||
void AntiAliasTable::GenerateForSimpleScale(uint8_t colorChannel)
|
||||
void AntiAliasTable::GenerateForSimpleScale(uint8_t colorChannel, bool cacheable)
|
||||
{
|
||||
char cacheFileName[256];
|
||||
if (cacheable)
|
||||
{
|
||||
sprintf(cacheFileName, "aa_t_%02x.cache", static_cast<int>(colorChannel));
|
||||
if (LoadFromCache(cacheFileName))
|
||||
return;
|
||||
}
|
||||
|
||||
const double gamma = 1.8;
|
||||
const double rcpGamma = 1.0 / gamma;
|
||||
const double rcp255 = 1.0 / 255.0;
|
||||
@@ -142,6 +197,9 @@ namespace PortabilityLayer
|
||||
m_aaTranslate[baseColor][opacity] = static_cast<uint8_t>(floor(blendedColorGammaSpace * 255.0 + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheable)
|
||||
SaveToCache(cacheFileName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -11,7 +11,13 @@ namespace PortabilityLayer
|
||||
// Striped 256x16 because constant background color is more likely than constant sample
|
||||
uint8_t m_aaTranslate[256][16];
|
||||
|
||||
void GenerateForPalette(const RGBAColor &baseColor, const RGBAColor *colors, size_t numColors);
|
||||
void GenerateForSimpleScale(uint8_t colorChannel);
|
||||
void GenerateForPalette(const RGBAColor &baseColor, const RGBAColor *colors, size_t numColors, bool cacheable);
|
||||
void GenerateForSimpleScale(uint8_t colorChannel, bool cacheable);
|
||||
|
||||
private:
|
||||
bool LoadFromCache(const char *path);
|
||||
void SaveToCache(const char *path);
|
||||
|
||||
static const unsigned int kCacheVersion = 1;
|
||||
};
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ namespace PortabilityLayer
|
||||
for (size_t i = 0; i < 256; i++)
|
||||
{
|
||||
PortabilityLayer::RGBAColor &color = m_palette[i];
|
||||
color.r = color.g = color.b = i;
|
||||
color.r = color.g = color.b = static_cast<uint8_t>(i);
|
||||
color.a = 255;
|
||||
}
|
||||
}
|
||||
|
@@ -6,12 +6,14 @@
|
||||
#include "FontFamily.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpBuildVersion.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IGpFont.h"
|
||||
#include "WindowManager.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "RenderedFont.h"
|
||||
@@ -37,11 +39,13 @@ static const int kCancelButton = 2;
|
||||
static const int kFileList = 3;
|
||||
static const int kFileListScrollBar = 4;
|
||||
static const int kFileNameEditBox = 5;
|
||||
static const int kDeleteButton = 5;
|
||||
static const int kFileBrowserUIOpenDialogTemplateID = 2001;
|
||||
static const int kFileBrowserUISaveDialogTemplateID = 2002;
|
||||
static const int kFileBrowserUIOverwriteDialogTemplateID = 2003;
|
||||
static const int kFileBrowserUIBadNameDialogTemplateID = 2004;
|
||||
static const int kFileBrowserUISaveDialogUnobstructiveTemplateID = 2007;
|
||||
static const int kFileBrowserUIDeleteDialogTemplateID = 2008;
|
||||
|
||||
|
||||
static const int kOverwriteNoButton = 1;
|
||||
@@ -52,7 +56,7 @@ namespace PortabilityLayer
|
||||
class FileBrowserUIImpl
|
||||
{
|
||||
public:
|
||||
FileBrowserUIImpl();
|
||||
explicit FileBrowserUIImpl(const FileBrowserUI_DetailsCallbackAPI &callbackAPI);
|
||||
~FileBrowserUIImpl();
|
||||
|
||||
static void PubScrollBarCallback(void *captureContext, Widget *control, int part);
|
||||
@@ -60,8 +64,9 @@ namespace PortabilityLayer
|
||||
static int16_t PubFileBrowserUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
static int16_t PubPopUpAlertUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
|
||||
bool AppendName(const char *name, size_t nameLength);
|
||||
bool AppendName(const char *name, size_t nameLength, void *details);
|
||||
void SortNames();
|
||||
void DrawHeaders();
|
||||
void DrawFileList();
|
||||
|
||||
void CaptureFileListDrag();
|
||||
@@ -72,22 +77,31 @@ namespace PortabilityLayer
|
||||
|
||||
PLPasStr GetSelectedFileName() const;
|
||||
|
||||
void RemoveSelectedFile();
|
||||
|
||||
static int16_t PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions);
|
||||
|
||||
private:
|
||||
typedef PascalStr<255> NameStr_t;
|
||||
|
||||
struct FileEntry
|
||||
{
|
||||
NameStr_t m_nameStr;
|
||||
void *m_fileDetails;
|
||||
};
|
||||
|
||||
void ScrollBarCallback(Widget *control, int part);
|
||||
int16_t FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
int16_t PopUpAlertUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
|
||||
static bool NameSortPred(const NameStr_t &a, const NameStr_t &b);
|
||||
static bool FileEntrySortPred(const FileEntry &a, const FileEntry &b);
|
||||
|
||||
int m_offset;
|
||||
int m_selectedIndex;
|
||||
int32_t m_scrollOffset;
|
||||
int32_t m_fontSpacing;
|
||||
THandle<NameStr_t> m_names;
|
||||
size_t m_numNames;
|
||||
THandle<FileEntry> m_entries;
|
||||
size_t m_numEntries;
|
||||
DrawSurface *m_surface;
|
||||
Window *m_window;
|
||||
EditboxWidget *m_editBox;
|
||||
@@ -96,9 +110,11 @@ namespace PortabilityLayer
|
||||
Point m_doubleClickPos;
|
||||
uint32_t m_doubleClickTime;
|
||||
bool m_haveFirstClick;
|
||||
|
||||
const FileBrowserUI_DetailsCallbackAPI m_api;
|
||||
};
|
||||
|
||||
FileBrowserUIImpl::FileBrowserUIImpl()
|
||||
FileBrowserUIImpl::FileBrowserUIImpl(const FileBrowserUI_DetailsCallbackAPI &callbackAPI)
|
||||
: m_offset(0)
|
||||
, m_surface(nullptr)
|
||||
, m_window(nullptr)
|
||||
@@ -107,16 +123,23 @@ namespace PortabilityLayer
|
||||
, m_selectedIndex(-1)
|
||||
, m_scrollOffset(0)
|
||||
, m_fontSpacing(1)
|
||||
, m_numNames(0)
|
||||
, m_numEntries(0)
|
||||
, m_doubleClickPos(Point::Create(0, 0))
|
||||
, m_doubleClickTime(0)
|
||||
, m_haveFirstClick(false)
|
||||
, m_api(callbackAPI)
|
||||
{
|
||||
}
|
||||
|
||||
FileBrowserUIImpl::~FileBrowserUIImpl()
|
||||
{
|
||||
m_names.Dispose();
|
||||
if (m_entries)
|
||||
{
|
||||
FileEntry *entries = *m_entries;
|
||||
for (size_t i = 0; i < m_numEntries; i++)
|
||||
m_api.m_freeFileDetailsCallback(entries[i].m_fileDetails);
|
||||
}
|
||||
m_entries.Dispose();
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::PubScrollBarCallback(void *captureContext, Widget *control, int part)
|
||||
@@ -141,39 +164,51 @@ namespace PortabilityLayer
|
||||
return HostFileSystem::GetInstance()->ValidateFilePathUnicodeChar(unicodeChar);
|
||||
}
|
||||
|
||||
bool FileBrowserUIImpl::AppendName(const char *name, size_t nameLen)
|
||||
bool FileBrowserUIImpl::AppendName(const char *name, size_t nameLen, void *details)
|
||||
{
|
||||
MemoryManager *mm = MemoryManager::GetInstance();
|
||||
if (!m_names)
|
||||
if (!m_entries)
|
||||
{
|
||||
m_names = THandle<NameStr_t>(mm->AllocHandle(0));
|
||||
if (!m_names)
|
||||
m_entries = THandle<FileEntry>(mm->AllocHandle(0));
|
||||
if (!m_entries)
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t oldSize = m_names.MMBlock()->m_size;
|
||||
size_t oldSize = m_entries.MMBlock()->m_size;
|
||||
|
||||
if (!mm->ResizeHandle(m_names.MMBlock(), oldSize + sizeof(NameStr_t)))
|
||||
if (!mm->ResizeHandle(m_entries.MMBlock(), oldSize + sizeof(FileEntry)))
|
||||
return false;
|
||||
|
||||
(*m_names)[m_numNames++] = NameStr_t(nameLen, name);
|
||||
FileEntry &entry = (*m_entries)[m_numEntries++];
|
||||
entry.m_nameStr = NameStr_t(nameLen, name);
|
||||
entry.m_fileDetails = details;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::SortNames()
|
||||
{
|
||||
if (!m_names)
|
||||
if (!m_entries)
|
||||
return;
|
||||
|
||||
NameStr_t *names = *m_names;
|
||||
FileEntry *entries = *m_entries;
|
||||
|
||||
std::sort(names, names + m_numNames, NameSortPred);
|
||||
std::sort(entries, entries + m_numEntries, FileEntrySortPred);
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::DrawHeaders()
|
||||
{
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
|
||||
ResolveCachingColor blackColor = StdColors::Black();
|
||||
|
||||
const Point basePoint = Point::Create(16, 16 + font->GetMetrics().m_ascent);
|
||||
m_api.m_drawLabelsCallback(m_surface, basePoint);
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::DrawFileList()
|
||||
{
|
||||
if (!m_names.MMBlock())
|
||||
if (!m_entries.MMBlock())
|
||||
return;
|
||||
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
@@ -192,7 +227,7 @@ namespace PortabilityLayer
|
||||
|
||||
m_surface->FillRect(m_rect, whiteColor);
|
||||
|
||||
for (size_t i = 0; i < m_numNames; i++)
|
||||
for (size_t i = 0; i < m_numEntries; i++)
|
||||
{
|
||||
if (m_selectedIndex >= 0 && static_cast<size_t>(m_selectedIndex) == i)
|
||||
{
|
||||
@@ -202,7 +237,9 @@ namespace PortabilityLayer
|
||||
}
|
||||
|
||||
Point itemStringPoint = Point::Create(itemRect.left + 2, itemRect.top + glyphOffset);
|
||||
m_surface->DrawStringConstrained(itemStringPoint, (*m_names)[i].ToShortStr(), m_rect, blackColor, font);
|
||||
m_surface->DrawStringConstrained(itemStringPoint, (*m_entries)[i].m_nameStr.ToShortStr(), m_rect, blackColor, font);
|
||||
|
||||
m_api.m_drawFileDetailsCallback(m_surface, itemStringPoint, m_rect, (*m_entries)[i].m_fileDetails);
|
||||
|
||||
itemRect.top += spacing;
|
||||
itemRect.bottom += spacing;
|
||||
@@ -224,7 +261,7 @@ namespace PortabilityLayer
|
||||
uint16_t FileBrowserUIImpl::GetScrollCapacity() const
|
||||
{
|
||||
int32_t boxHeight = m_rect.Height();
|
||||
int32_t overCapacity = (static_cast<int32_t>(m_numNames) * m_fontSpacing - boxHeight);
|
||||
int32_t overCapacity = (static_cast<int32_t>(m_numEntries) * m_fontSpacing - boxHeight);
|
||||
|
||||
if (overCapacity < 0)
|
||||
return 0;
|
||||
@@ -245,7 +282,28 @@ namespace PortabilityLayer
|
||||
if (m_selectedIndex < 0)
|
||||
return PSTR("");
|
||||
else
|
||||
return (*m_names)[m_selectedIndex].ToShortStr();
|
||||
return (*m_entries)[m_selectedIndex].m_nameStr.ToShortStr();
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::RemoveSelectedFile()
|
||||
{
|
||||
if (m_selectedIndex < 0)
|
||||
return;
|
||||
|
||||
|
||||
FileEntry *entries = *m_entries;
|
||||
|
||||
FileEntry &removedEntry = entries[m_selectedIndex];
|
||||
m_api.m_freeFileDetailsCallback(removedEntry.m_fileDetails);
|
||||
|
||||
for (size_t i = m_selectedIndex; i < m_numEntries - 1; i++)
|
||||
entries[i] = entries[i + 1];
|
||||
|
||||
m_numEntries--;
|
||||
PortabilityLayer::MemoryManager::GetInstance()->ResizeHandle(m_entries.MMBlock(), sizeof(FileEntry) * m_numEntries);
|
||||
|
||||
m_selectedIndex = -1;
|
||||
DrawFileList();
|
||||
}
|
||||
|
||||
void FileBrowserUIImpl::ScrollBarCallback(Widget *control, int part)
|
||||
@@ -273,6 +331,8 @@ namespace PortabilityLayer
|
||||
SetScrollOffset(control->GetState());
|
||||
}
|
||||
|
||||
static FileBrowserUI::Mode gs_currentFileBrowserUIMode;
|
||||
|
||||
int16_t FileBrowserUIImpl::FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt)
|
||||
{
|
||||
bool handledIt = false;
|
||||
@@ -362,7 +422,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
int32_t selection = (mousePt.v - m_rect.top + m_scrollOffset) / m_fontSpacing;
|
||||
|
||||
if (selection < 0 || static_cast<size_t>(selection) >= m_numNames)
|
||||
if (selection < 0 || static_cast<size_t>(selection) >= m_numEntries)
|
||||
selection = -1;
|
||||
|
||||
if (selection >= 0)
|
||||
@@ -373,12 +433,15 @@ namespace PortabilityLayer
|
||||
|
||||
dialog->GetItems()[kOkayButton - 1].GetWidget()->SetEnabled(selection >= 0);
|
||||
|
||||
if (gs_currentFileBrowserUIMode == FileBrowserUI::Mode_Open)
|
||||
dialog->GetItems()[kDeleteButton - 1].GetWidget()->SetEnabled(selection >= 0);
|
||||
|
||||
DrawFileList();
|
||||
}
|
||||
|
||||
if (m_editBox)
|
||||
{
|
||||
PLPasStr nameStr = (*m_names)[m_selectedIndex].ToShortStr();
|
||||
PLPasStr nameStr = (*m_entries)[m_selectedIndex].m_nameStr.ToShortStr();
|
||||
m_editBox->SetString(nameStr);
|
||||
m_editBox->SetSelection(0, nameStr.Length());
|
||||
}
|
||||
@@ -455,14 +518,14 @@ namespace PortabilityLayer
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool FileBrowserUIImpl::NameSortPred(const NameStr_t &a, const NameStr_t &b)
|
||||
bool FileBrowserUIImpl::FileEntrySortPred(const FileEntry &a, const FileEntry &b)
|
||||
{
|
||||
const size_t lenA = a.Length();
|
||||
const size_t lenB = b.Length();
|
||||
const size_t lenA = a.m_nameStr.Length();
|
||||
const size_t lenB = b.m_nameStr.Length();
|
||||
|
||||
const size_t shorterLength = std::min(lenA, lenB);
|
||||
|
||||
int comparison = memcmp(a.UnsafeCharPtr(), b.UnsafeCharPtr(), shorterLength);
|
||||
int comparison = memcmp(a.m_nameStr.UnsafeCharPtr(), b.m_nameStr.UnsafeCharPtr(), shorterLength);
|
||||
if (comparison > 0)
|
||||
return false;
|
||||
|
||||
@@ -501,7 +564,7 @@ namespace PortabilityLayer
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool FileBrowserUI::Prompt(Mode mode, VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText)
|
||||
bool FileBrowserUI::Prompt(Mode mode, VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI)
|
||||
{
|
||||
int dialogID = 0;
|
||||
bool isObstructive = false;
|
||||
@@ -513,7 +576,7 @@ namespace PortabilityLayer
|
||||
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
|
||||
{
|
||||
dialogID = kFileBrowserUISaveDialogUnobstructiveTemplateID;
|
||||
windowHeight = 240;
|
||||
windowHeight = 208;
|
||||
isObstructive = true;
|
||||
}
|
||||
else
|
||||
@@ -525,7 +588,7 @@ namespace PortabilityLayer
|
||||
return false;
|
||||
}
|
||||
|
||||
FileBrowserUIImpl uiImpl;
|
||||
FileBrowserUIImpl uiImpl(callbackAPI);
|
||||
|
||||
// Enumerate files
|
||||
PortabilityLayer::HostFileSystem *fs = PortabilityLayer::HostFileSystem::GetInstance();
|
||||
@@ -546,7 +609,28 @@ namespace PortabilityLayer
|
||||
|
||||
if (!memcmp(nameExt, ".gpf", 4))
|
||||
{
|
||||
if (!uiImpl.AppendName(fileName, nameLength - 4))
|
||||
GpIOStream *metadataStream = fs->OpenFile(dirID, fileName, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!metadataStream)
|
||||
continue;
|
||||
|
||||
MacFilePropertiesSerialized serializedMetadata;
|
||||
if (metadataStream->Read(&serializedMetadata, sizeof(serializedMetadata)) != sizeof(serializedMetadata))
|
||||
{
|
||||
metadataStream->Close();
|
||||
continue;
|
||||
}
|
||||
|
||||
metadataStream->Close();
|
||||
|
||||
MacFileProperties metadata;
|
||||
serializedMetadata.Deserialize(metadata);
|
||||
|
||||
char ftype[4];
|
||||
fileType.ExportAsChars(ftype);
|
||||
if (memcmp(metadata.m_fileType, ftype, 4))
|
||||
continue;
|
||||
|
||||
if (!uiImpl.AppendName(fileName, nameLength - 4, callbackAPI.m_loadFileDetailsCallback(dirID, PLPasStr(nameLength - 4, fileName))))
|
||||
{
|
||||
dirCursor->Destroy();
|
||||
return false;
|
||||
@@ -627,12 +711,16 @@ namespace PortabilityLayer
|
||||
|
||||
window->DrawControls();
|
||||
|
||||
uiImpl.DrawHeaders();
|
||||
|
||||
int16_t hit = 0;
|
||||
|
||||
Window *exclWindow = dialog->GetWindow();
|
||||
|
||||
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
||||
|
||||
gs_currentFileBrowserUIMode = mode;
|
||||
|
||||
do
|
||||
{
|
||||
hit = dialog->ExecuteModal(&uiImpl, FileBrowserUIImpl::PubFileBrowserUIFilter);
|
||||
@@ -664,6 +752,23 @@ namespace PortabilityLayer
|
||||
hit = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == Mode_Open && hit == kDeleteButton)
|
||||
{
|
||||
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
|
||||
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions);
|
||||
|
||||
if (subHit == kOverwriteYesButton)
|
||||
{
|
||||
PLPasStr uiFileName = uiImpl.GetSelectedFileName();
|
||||
|
||||
PortabilityLayer::FileManager::GetInstance()->DeleteFile(dirID, uiFileName);
|
||||
uiImpl.RemoveSelectedFile();
|
||||
dialog->GetItems()[kOkayButton - 1].GetWidget()->SetEnabled(false);
|
||||
dialog->GetItems()[kDeleteButton - 1].GetWidget()->SetEnabled(false);
|
||||
}
|
||||
hit = -1;
|
||||
}
|
||||
} while (hit != kOkayButton && hit != kCancelButton);
|
||||
|
||||
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
||||
|
@@ -5,18 +5,33 @@
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
class PLPasStr;
|
||||
struct DrawSurface;
|
||||
struct Point;
|
||||
struct Rect;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ResTypeID;
|
||||
|
||||
struct FileBrowserUI_DetailsCallbackAPI
|
||||
{
|
||||
void(*m_drawLabelsCallback)(DrawSurface *surface, const Point &basePoint);
|
||||
void(*m_drawFileDetailsCallback)(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails);
|
||||
|
||||
void *(*m_loadFileDetailsCallback)(VirtualDirectory_t dirID, const PLPasStr &filename);
|
||||
void(*m_freeFileDetailsCallback)(void *fileDetails);
|
||||
};
|
||||
|
||||
class FileBrowserUI
|
||||
{
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
Mode_Save,
|
||||
Mode_Open,
|
||||
};
|
||||
|
||||
static bool Prompt(Mode mode, VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText);
|
||||
static bool Prompt(Mode mode, VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI);
|
||||
};
|
||||
}
|
||||
|
@@ -35,8 +35,8 @@ namespace PortabilityLayer
|
||||
PLError_t RawOpenFileData(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) override;
|
||||
PLError_t RawOpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) override;
|
||||
|
||||
bool PromptSaveFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText) override;
|
||||
bool PromptOpenFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText) override;
|
||||
bool PromptSaveFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI) override;
|
||||
bool PromptOpenFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI) override;
|
||||
|
||||
static FileManagerImpl *GetInstance();
|
||||
|
||||
@@ -176,18 +176,18 @@ namespace PortabilityLayer
|
||||
return RawOpenFileFork(dirID, filename, ".gpa", permission, ignoreMeta, createDisposition, outStream);
|
||||
}
|
||||
|
||||
bool FileManagerImpl::PromptSaveFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText)
|
||||
bool FileManagerImpl::PromptSaveFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &detailsAPI)
|
||||
{
|
||||
ExtendedFileName_t extFN;
|
||||
if (!ConstructFilename(extFN, initialFileName, ""))
|
||||
return false;
|
||||
|
||||
return FileBrowserUI::Prompt(FileBrowserUI::Mode_Save, dirID, path, outPathLength, pathCapacity, initialFileName, promptText);
|
||||
return FileBrowserUI::Prompt(FileBrowserUI::Mode_Save, dirID, fileType, path, outPathLength, pathCapacity, initialFileName, promptText, detailsAPI);
|
||||
}
|
||||
|
||||
bool FileManagerImpl::PromptOpenFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText)
|
||||
bool FileManagerImpl::PromptOpenFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &detailsAPI)
|
||||
{
|
||||
return FileBrowserUI::Prompt(FileBrowserUI::Mode_Open, dirID, path, outPathLength, pathCapacity, PSTR(""), promptText);
|
||||
return FileBrowserUI::Prompt(FileBrowserUI::Mode_Open, dirID, fileType, path, outPathLength, pathCapacity, PSTR(""), promptText, detailsAPI);
|
||||
}
|
||||
|
||||
FileManagerImpl *FileManagerImpl::GetInstance()
|
||||
|
@@ -16,6 +16,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
class ResTypeID;
|
||||
struct MacFileProperties;
|
||||
struct FileBrowserUI_DetailsCallbackAPI;
|
||||
|
||||
class FileManager
|
||||
{
|
||||
@@ -35,8 +36,8 @@ namespace PortabilityLayer
|
||||
virtual PLError_t RawOpenFileData(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, GpFileCreationDisposition_t createDisposition, GpIOStream *&outStream) = 0;
|
||||
virtual PLError_t RawOpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, GpFileCreationDisposition_t createDisposition, GpIOStream *&outStream) = 0;
|
||||
|
||||
virtual bool PromptSaveFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText) = 0;
|
||||
virtual bool PromptOpenFile(VirtualDirectory_t dirID, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText) = 0;
|
||||
virtual bool PromptSaveFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &initialFileName, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI) = 0;
|
||||
virtual bool PromptOpenFile(VirtualDirectory_t dirID, const ResTypeID &fileType, char *path, size_t &outPathLength, size_t pathCapacity, const PLPasStr &promptText, const FileBrowserUI_DetailsCallbackAPI &callbackAPI) = 0;
|
||||
|
||||
static FileManager *GetInstance();
|
||||
};
|
||||
|
@@ -159,7 +159,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
CacheHeader header;
|
||||
header.m_cacheVersion = kRFontCacheVersion;
|
||||
header.m_glyphDataSize = this->m_dataSize;
|
||||
header.m_glyphDataSize = static_cast<uint32_t>(this->m_dataSize);
|
||||
header.m_isAA = m_isAntiAliased;
|
||||
header.m_sizeSize = sizeof(size_t);
|
||||
|
||||
|
@@ -75,8 +75,8 @@ namespace PortabilityLayer
|
||||
mb2Header[MB2FileOffsets::Protected] = fileInfo.m_properties.m_protected;
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::DataForkSize, fileInfo.m_dataForkSize);
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ResourceForkSize, fileInfo.m_resourceForkSize);
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate, fileInfo.m_properties.m_creationDate);
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate, fileInfo.m_properties.m_modifiedDate);
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate, static_cast<uint32_t>(fileInfo.m_properties.m_creationDate));
|
||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate, static_cast<uint32_t>(fileInfo.m_properties.m_modifiedDate));
|
||||
|
||||
BytePack::BigUInt16(mb2Header + MB2FileOffsets::CommentLength, fileInfo.m_commentSize);
|
||||
mb2Header[MB2FileOffsets::FinderFlagsLow] = static_cast<uint8_t>(fileInfo.m_properties.m_finderFlags & 0xff);
|
||||
|
@@ -1,178 +1,178 @@
|
||||
#include "MemoryManager.h"
|
||||
#include "MMBlock.h"
|
||||
#include "MMHandleBlock.h"
|
||||
#include "ResourceCompiledRef.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class MemoryManagerImpl final : public MemoryManager
|
||||
{
|
||||
public:
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
void *Alloc(size_t size) override;
|
||||
void *Realloc(void *buf, size_t newSize) override;
|
||||
void Release(void *buf) override;
|
||||
|
||||
MMHandleBlock *AllocHandle(size_t size) override;
|
||||
bool ResizeHandle(MMHandleBlock *hdl, size_t newSize) override;
|
||||
void ReleaseHandle(MMHandleBlock *hdl) override;
|
||||
|
||||
static MemoryManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
|
||||
static MemoryManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
void MemoryManagerImpl::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void *MemoryManagerImpl::Realloc(void *buf, size_t newSize)
|
||||
{
|
||||
assert(buf != nullptr);
|
||||
|
||||
const size_t mmBlockSize = MMBlock::AlignedSize();
|
||||
uint8_t *oldBufBytes = static_cast<uint8_t*>(buf);
|
||||
const MMBlock *oldBufMMBlock = reinterpret_cast<const MMBlock*>(oldBufBytes - MMBlock::AlignedSize());
|
||||
|
||||
const size_t oldBufOffsetFromAlignLoc = oldBufMMBlock->m_offsetFromAllocLocation;
|
||||
uint8_t *oldBufBase = oldBufBytes - MMBlock::AlignedSize() - oldBufOffsetFromAlignLoc;
|
||||
|
||||
const size_t mmBlockSizeWithMaxPadding = MMBlock::AlignedSize() + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||
if (SIZE_MAX - newSize < mmBlockSizeWithMaxPadding)
|
||||
return nullptr;
|
||||
|
||||
const size_t newBufferSize = newSize + mmBlockSizeWithMaxPadding;
|
||||
uint8_t *newBuffer = static_cast<uint8_t*>(realloc(oldBufBase, newSize + mmBlockSizeWithMaxPadding));
|
||||
if (!newBuffer)
|
||||
return nullptr;
|
||||
|
||||
const intptr_t offsetFromAlignPoint = reinterpret_cast<intptr_t>(newBuffer) & static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||
intptr_t alignPadding = 0;
|
||||
if (offsetFromAlignPoint != 0)
|
||||
alignPadding = static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT) - offsetFromAlignPoint;
|
||||
|
||||
// Check if the alignment changed, if so relocate
|
||||
if (static_cast<size_t>(alignPadding) != oldBufOffsetFromAlignLoc)
|
||||
memmove(newBuffer + alignPadding, newBuffer + oldBufOffsetFromAlignLoc, MMBlock::AlignedSize() + newSize);
|
||||
|
||||
MMBlock *newMMBlock = reinterpret_cast<MMBlock*>(newBuffer + alignPadding);
|
||||
newMMBlock->m_offsetFromAllocLocation = static_cast<SmallestUInt<GP_SYSTEM_MEMORY_ALIGNMENT>::ValueType_t>(alignPadding);
|
||||
|
||||
return newBuffer + alignPadding + MMBlock::AlignedSize();
|
||||
}
|
||||
|
||||
void *MemoryManagerImpl::Alloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return nullptr;
|
||||
|
||||
const size_t mmBlockSizeWithMaxPadding = MMBlock::AlignedSize() + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||
if (SIZE_MAX - size < mmBlockSizeWithMaxPadding)
|
||||
return nullptr;
|
||||
|
||||
uint8_t *buffer = static_cast<uint8_t*>(malloc(size + mmBlockSizeWithMaxPadding));
|
||||
if (!buffer)
|
||||
return nullptr;
|
||||
|
||||
const intptr_t offsetFromAlignPoint = reinterpret_cast<intptr_t>(buffer) & static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||
intptr_t alignPadding = 0;
|
||||
if (offsetFromAlignPoint != 0)
|
||||
alignPadding = static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT) - offsetFromAlignPoint;
|
||||
|
||||
MMBlock *mmBlock = reinterpret_cast<MMBlock*>(buffer + alignPadding);
|
||||
mmBlock->m_offsetFromAllocLocation = static_cast<SmallestUInt<GP_SYSTEM_MEMORY_ALIGNMENT>::ValueType_t>(alignPadding);
|
||||
|
||||
return buffer + alignPadding + MMBlock::AlignedSize();
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::Release(void *buf)
|
||||
{
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
const size_t mmBlockSize = MMBlock::AlignedSize();
|
||||
|
||||
uint8_t *bytes = static_cast<uint8_t*>(buf);
|
||||
const MMBlock *mmBlock = reinterpret_cast<const MMBlock*>(bytes - MMBlock::AlignedSize());
|
||||
|
||||
free(bytes - MMBlock::AlignedSize() - mmBlock->m_offsetFromAllocLocation);
|
||||
}
|
||||
|
||||
MMHandleBlock *MemoryManagerImpl::AllocHandle(size_t size)
|
||||
{
|
||||
void *contents = Alloc(size);
|
||||
MMHandleBlock *handleBlock = static_cast<MMHandleBlock*>(Alloc(sizeof(MMHandleBlock)));
|
||||
|
||||
return new (handleBlock) MMHandleBlock(contents, size);
|
||||
}
|
||||
|
||||
bool MemoryManagerImpl::ResizeHandle(MMHandleBlock *hdl, size_t newSize)
|
||||
{
|
||||
#include "MemoryManager.h"
|
||||
#include "MMBlock.h"
|
||||
#include "MMHandleBlock.h"
|
||||
#include "ResourceCompiledRef.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class MemoryManagerImpl final : public MemoryManager
|
||||
{
|
||||
public:
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
void *Alloc(size_t size) override;
|
||||
void *Realloc(void *buf, size_t newSize) override;
|
||||
void Release(void *buf) override;
|
||||
|
||||
MMHandleBlock *AllocHandle(size_t size) override;
|
||||
bool ResizeHandle(MMHandleBlock *hdl, size_t newSize) override;
|
||||
void ReleaseHandle(MMHandleBlock *hdl) override;
|
||||
|
||||
static MemoryManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
|
||||
static MemoryManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
void MemoryManagerImpl::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void *MemoryManagerImpl::Realloc(void *buf, size_t newSize)
|
||||
{
|
||||
assert(buf != nullptr);
|
||||
|
||||
const size_t mmBlockSize = MMBlock::AlignedSize();
|
||||
uint8_t *oldBufBytes = static_cast<uint8_t*>(buf);
|
||||
const MMBlock *oldBufMMBlock = reinterpret_cast<const MMBlock*>(oldBufBytes - MMBlock::AlignedSize());
|
||||
|
||||
const size_t oldBufOffsetFromAlignLoc = oldBufMMBlock->m_offsetFromAllocLocation;
|
||||
uint8_t *oldBufBase = oldBufBytes - MMBlock::AlignedSize() - oldBufOffsetFromAlignLoc;
|
||||
|
||||
const size_t mmBlockSizeWithMaxPadding = MMBlock::AlignedSize() + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||
if (SIZE_MAX - newSize < mmBlockSizeWithMaxPadding)
|
||||
return nullptr;
|
||||
|
||||
const size_t newBufferSize = newSize + mmBlockSizeWithMaxPadding;
|
||||
uint8_t *newBuffer = static_cast<uint8_t*>(realloc(oldBufBase, newSize + mmBlockSizeWithMaxPadding));
|
||||
if (!newBuffer)
|
||||
return nullptr;
|
||||
|
||||
const intptr_t offsetFromAlignPoint = reinterpret_cast<intptr_t>(newBuffer) & static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||
intptr_t alignPadding = 0;
|
||||
if (offsetFromAlignPoint != 0)
|
||||
alignPadding = static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT) - offsetFromAlignPoint;
|
||||
|
||||
// Check if the alignment changed, if so relocate
|
||||
if (static_cast<size_t>(alignPadding) != oldBufOffsetFromAlignLoc)
|
||||
memmove(newBuffer + alignPadding, newBuffer + oldBufOffsetFromAlignLoc, MMBlock::AlignedSize() + newSize);
|
||||
|
||||
MMBlock *newMMBlock = reinterpret_cast<MMBlock*>(newBuffer + alignPadding);
|
||||
newMMBlock->m_offsetFromAllocLocation = static_cast<SmallestUInt<GP_SYSTEM_MEMORY_ALIGNMENT>::ValueType_t>(alignPadding);
|
||||
|
||||
return newBuffer + alignPadding + MMBlock::AlignedSize();
|
||||
}
|
||||
|
||||
void *MemoryManagerImpl::Alloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return nullptr;
|
||||
|
||||
const size_t mmBlockSizeWithMaxPadding = MMBlock::AlignedSize() + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||
if (SIZE_MAX - size < mmBlockSizeWithMaxPadding)
|
||||
return nullptr;
|
||||
|
||||
uint8_t *buffer = static_cast<uint8_t*>(malloc(size + mmBlockSizeWithMaxPadding));
|
||||
if (!buffer)
|
||||
return nullptr;
|
||||
|
||||
const intptr_t offsetFromAlignPoint = reinterpret_cast<intptr_t>(buffer) & static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||
intptr_t alignPadding = 0;
|
||||
if (offsetFromAlignPoint != 0)
|
||||
alignPadding = static_cast<intptr_t>(GP_SYSTEM_MEMORY_ALIGNMENT) - offsetFromAlignPoint;
|
||||
|
||||
MMBlock *mmBlock = reinterpret_cast<MMBlock*>(buffer + alignPadding);
|
||||
mmBlock->m_offsetFromAllocLocation = static_cast<SmallestUInt<GP_SYSTEM_MEMORY_ALIGNMENT>::ValueType_t>(alignPadding);
|
||||
|
||||
return buffer + alignPadding + MMBlock::AlignedSize();
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::Release(void *buf)
|
||||
{
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
const size_t mmBlockSize = MMBlock::AlignedSize();
|
||||
|
||||
uint8_t *bytes = static_cast<uint8_t*>(buf);
|
||||
const MMBlock *mmBlock = reinterpret_cast<const MMBlock*>(bytes - MMBlock::AlignedSize());
|
||||
|
||||
free(bytes - MMBlock::AlignedSize() - mmBlock->m_offsetFromAllocLocation);
|
||||
}
|
||||
|
||||
MMHandleBlock *MemoryManagerImpl::AllocHandle(size_t size)
|
||||
{
|
||||
void *contents = Alloc(size);
|
||||
MMHandleBlock *handleBlock = static_cast<MMHandleBlock*>(Alloc(sizeof(MMHandleBlock)));
|
||||
|
||||
return new (handleBlock) MMHandleBlock(contents, size);
|
||||
}
|
||||
|
||||
bool MemoryManagerImpl::ResizeHandle(MMHandleBlock *hdl, size_t newSize)
|
||||
{
|
||||
if (hdl->m_contents == nullptr)
|
||||
{
|
||||
if (newSize != 0)
|
||||
{
|
||||
void *newBuf = Alloc(newSize);
|
||||
if (!newBuf)
|
||||
return false;
|
||||
|
||||
hdl->m_contents = newBuf;
|
||||
{
|
||||
void *newBuf = Alloc(newSize);
|
||||
if (!newBuf)
|
||||
return false;
|
||||
|
||||
hdl->m_contents = newBuf;
|
||||
hdl->m_size = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (newSize != hdl->m_size)
|
||||
{
|
||||
void *newBuf = Realloc(hdl->m_contents, newSize);
|
||||
if (!newBuf)
|
||||
return false;
|
||||
|
||||
hdl->m_contents = newBuf;
|
||||
hdl->m_size = newSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::ReleaseHandle(MMHandleBlock *hdl)
|
||||
{
|
||||
if (!hdl)
|
||||
return;
|
||||
|
||||
if (hdl->m_rmSelfRef)
|
||||
PortabilityLayer::ResourceManager::GetInstance()->DissociateHandle(hdl);
|
||||
|
||||
if (hdl->m_contents)
|
||||
Release(hdl->m_contents);
|
||||
|
||||
hdl->~MMHandleBlock();
|
||||
|
||||
Release(hdl);
|
||||
}
|
||||
|
||||
MemoryManagerImpl *MemoryManagerImpl::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
MemoryManagerImpl MemoryManagerImpl::ms_instance;
|
||||
|
||||
MemoryManager *MemoryManager::GetInstance()
|
||||
{
|
||||
return MemoryManagerImpl::GetInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newSize != hdl->m_size)
|
||||
{
|
||||
void *newBuf = Realloc(hdl->m_contents, newSize);
|
||||
if (!newBuf)
|
||||
return false;
|
||||
|
||||
hdl->m_contents = newBuf;
|
||||
hdl->m_size = newSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryManagerImpl::ReleaseHandle(MMHandleBlock *hdl)
|
||||
{
|
||||
if (!hdl)
|
||||
return;
|
||||
|
||||
if (hdl->m_rmSelfRef)
|
||||
PortabilityLayer::ResourceManager::GetInstance()->DissociateHandle(hdl);
|
||||
|
||||
if (hdl->m_contents)
|
||||
Release(hdl->m_contents);
|
||||
|
||||
hdl->~MMHandleBlock();
|
||||
|
||||
Release(hdl);
|
||||
}
|
||||
|
||||
MemoryManagerImpl *MemoryManagerImpl::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
MemoryManagerImpl MemoryManagerImpl::ms_instance;
|
||||
|
||||
MemoryManager *MemoryManager::GetInstance()
|
||||
{
|
||||
return MemoryManagerImpl::GetInstance();
|
||||
}
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ namespace
|
||||
|
||||
struct MenuItem
|
||||
{
|
||||
uint32_t nameOffsetInStringBlob;
|
||||
size_t nameOffsetInStringBlob;
|
||||
int8_t iconResID;
|
||||
uint8_t key;
|
||||
uint8_t submenuID;
|
||||
@@ -1055,7 +1055,7 @@ namespace PortabilityLayer
|
||||
int32_t yCoordinate = 0;
|
||||
if (!m_menuSelectionState.IsPopup())
|
||||
{
|
||||
xCoordinate = kMenuBarInitialPadding + selectedMenu->menuIndex * kMenuBarItemPadding * 2 + selectedMenu->cumulativeOffset - kMenuBarItemPadding;
|
||||
xCoordinate = static_cast<int32_t>(kMenuBarInitialPadding + selectedMenu->menuIndex * kMenuBarItemPadding * 2 + selectedMenu->cumulativeOffset - kMenuBarItemPadding);
|
||||
yCoordinate = kMenuBarHeight;
|
||||
}
|
||||
else
|
||||
@@ -1385,7 +1385,7 @@ namespace PortabilityLayer
|
||||
m_popupPosition.m_y = kMenuBarHeight;
|
||||
else
|
||||
{
|
||||
int32_t popupBottom = m_popupPosition.m_y + menu->layoutFinalHeight;
|
||||
int32_t popupBottom = static_cast<int32_t>(m_popupPosition.m_y + menu->layoutFinalHeight);
|
||||
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
|
||||
@@ -1486,18 +1486,18 @@ namespace PortabilityLayer
|
||||
ResolveCachingColor barMidColor = gs_barMidColor;
|
||||
|
||||
{
|
||||
const Rect rect = Rect::Create(0, 0, menu->layoutFinalHeight, menu->layoutWidth);
|
||||
const Rect rect = Rect::Create(0, 0, static_cast<int16_t>(menu->layoutFinalHeight), menu->layoutWidth);
|
||||
surface->FillRect(rect, barMidColor);
|
||||
|
||||
ResolveCachingColor whiteColor = StdColors::White();
|
||||
|
||||
surface->FillRect(Rect::Create(0, 0, 1, menu->layoutWidth - 1), whiteColor);
|
||||
surface->FillRect(Rect::Create(1, 0, menu->layoutFinalHeight - 1, 1), whiteColor);
|
||||
surface->FillRect(Rect::Create(0, 0, 1, static_cast<int16_t>(menu->layoutWidth - 1)), whiteColor);
|
||||
surface->FillRect(Rect::Create(1, 0, static_cast<int16_t>(menu->layoutFinalHeight - 1), 1), whiteColor);
|
||||
|
||||
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
|
||||
|
||||
surface->FillRect(Rect::Create(1, menu->layoutWidth - 1, menu->layoutFinalHeight, menu->layoutWidth), darkGrayColor);
|
||||
surface->FillRect(Rect::Create(menu->layoutFinalHeight - 1, 1, menu->layoutFinalHeight, menu->layoutWidth - 1), darkGrayColor);
|
||||
surface->FillRect(Rect::Create(1, static_cast<int16_t>(menu->layoutWidth - 1), static_cast<int16_t>(menu->layoutFinalHeight), static_cast<int16_t>(menu->layoutWidth)), darkGrayColor);
|
||||
surface->FillRect(Rect::Create(static_cast<int16_t>(menu->layoutFinalHeight - 1), 1, static_cast<int16_t>(menu->layoutFinalHeight), static_cast<int16_t>(menu->layoutWidth - 1)), darkGrayColor);
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
|
@@ -235,8 +235,7 @@ static void PlotLine(DrawSurface *surface, const PortabilityLayer::Vec2i &pointA
|
||||
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
|
||||
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
|
||||
static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character, PortabilityLayer::ResolveCachingColor &cacheColor)
|
||||
{
|
||||
assert(rect.IsValid());
|
||||
|
||||
@@ -282,28 +281,7 @@ static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, con
|
||||
const PortabilityLayer::AntiAliasTable *aaTable = nullptr;
|
||||
|
||||
if (isAA)
|
||||
{
|
||||
if (cacheColor.GetRGBAColor() == PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetBlackAATable();
|
||||
else if (cacheColor.GetRGBAColor() == PortabilityLayer::RGBAColor::Create(255, 255, 255, 255))
|
||||
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetWhiteAATable();
|
||||
else if (cachedAATable != nullptr && cacheColor.GetRGBAColor() == cachedAATableColor)
|
||||
aaTable = cachedAATable;
|
||||
else
|
||||
{
|
||||
if (!cachedAATable)
|
||||
{
|
||||
cachedAATable = static_cast<PortabilityLayer::AntiAliasTable*>(PortabilityLayer::MemoryManager::GetInstance()->Alloc(sizeof(PortabilityLayer::AntiAliasTable)));
|
||||
if (!cachedAATable)
|
||||
return;
|
||||
}
|
||||
|
||||
cachedAATableColor = cacheColor.GetRGBAColor();
|
||||
cachedAATable->GenerateForPalette(cacheColor.GetRGBAColor(), PortabilityLayer::StandardPalette::GetInstance()->GetColors(), 256);
|
||||
|
||||
aaTable = cachedAATable;
|
||||
}
|
||||
}
|
||||
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetCachedPaletteAATable(cacheColor.GetRGBAColor());
|
||||
|
||||
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
|
||||
for (uint32_t row = 0; row < numRows; row++)
|
||||
@@ -349,36 +327,9 @@ static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, con
|
||||
{
|
||||
PortabilityLayer::RGBAColor rgbaColor = cacheColor.GetRGBAColor();
|
||||
uint8_t rgbColor[3] = { rgbaColor.r, rgbaColor.g, rgbaColor.b };
|
||||
uint8_t cacheRGBColor[3] = { cachedAATableColor.r, cachedAATableColor.g, cachedAATableColor.b };
|
||||
|
||||
for (int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
if (rgbColor[ch] == 0)
|
||||
aaTables[ch] = &PortabilityLayer::StandardPalette::GetInstance()->GetBlackToneAATable();
|
||||
else if (rgbColor[ch] == 255)
|
||||
aaTables[ch] = &PortabilityLayer::StandardPalette::GetInstance()->GetWhiteToneAATable();
|
||||
else if (cachedAATable != nullptr && rgbColor[ch] == cacheRGBColor[ch])
|
||||
aaTables[ch] = &cachedAATable[ch];
|
||||
else
|
||||
{
|
||||
if (!cachedAATable)
|
||||
{
|
||||
cachedAATable = static_cast<PortabilityLayer::AntiAliasTable*>(PortabilityLayer::MemoryManager::GetInstance()->Alloc(sizeof(PortabilityLayer::AntiAliasTable) * 3));
|
||||
if (!cachedAATable)
|
||||
return;
|
||||
|
||||
cachedAATableColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
|
||||
cachedAATable[0] = cachedAATable[1] = cachedAATable[2] = PortabilityLayer::StandardPalette::GetInstance()->GetBlackToneAATable();
|
||||
}
|
||||
|
||||
cacheRGBColor[ch] = rgbColor[ch];
|
||||
|
||||
cachedAATableColor = PortabilityLayer::RGBAColor::Create(cacheRGBColor[0], cacheRGBColor[1], cacheRGBColor[2], 255);
|
||||
cachedAATable[ch].GenerateForSimpleScale(rgbColor[ch]);
|
||||
|
||||
aaTables[ch] = &cachedAATable[ch];
|
||||
}
|
||||
}
|
||||
aaTables[ch] = &PortabilityLayer::StandardPalette::GetInstance()->GetCachedToneAATable(rgbColor[ch]);
|
||||
}
|
||||
|
||||
for (uint32_t row = 0; row < numRows; row++)
|
||||
@@ -426,14 +377,13 @@ static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, con
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawText(PortabilityLayer::TextPlacer &placer, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont,
|
||||
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
|
||||
static void DrawText(PortabilityLayer::TextPlacer &placer, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont, PortabilityLayer::ResolveCachingColor &cacheColor)
|
||||
{
|
||||
PortabilityLayer::GlyphPlacementCharacteristics characteristics;
|
||||
while (placer.PlaceGlyph(characteristics))
|
||||
{
|
||||
if (characteristics.m_haveGlyph)
|
||||
DrawGlyph(pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cachedAATable, cachedAATableColor, cacheColor);
|
||||
DrawGlyph(pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cacheColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +407,7 @@ void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str,
|
||||
|
||||
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), -1, rfont, str);
|
||||
|
||||
DrawText(placer, pixMap, rect, rfont, m_cachedAATables, m_cachedAAColor, cacheColor);
|
||||
DrawText(placer, pixMap, rect, rfont, cacheColor);
|
||||
|
||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
@@ -482,7 +432,7 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
|
||||
|
||||
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), areaRect.Width(), rfont, str);
|
||||
|
||||
DrawText(placer, pixMap, limitRect, rfont, m_cachedAATables, m_cachedAAColor, cacheColor);
|
||||
DrawText(placer, pixMap, limitRect, rfont, cacheColor);
|
||||
|
||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
@@ -8,8 +8,6 @@
|
||||
|
||||
DrawSurface::~DrawSurface()
|
||||
{
|
||||
if (m_cachedAATables)
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(m_cachedAATables);
|
||||
}
|
||||
|
||||
void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver)
|
||||
|
@@ -31,16 +31,12 @@ struct DrawSurface
|
||||
DrawSurface()
|
||||
: m_port(PortabilityLayer::QDPortType_DrawSurface)
|
||||
, m_ddSurface(nullptr)
|
||||
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||
, m_cachedAATables(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
explicit DrawSurface(PortabilityLayer::QDPortType overridePortType)
|
||||
: m_port(overridePortType)
|
||||
, m_ddSurface(nullptr)
|
||||
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||
, m_cachedAATables(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,9 +81,6 @@ struct DrawSurface
|
||||
|
||||
IGpDisplayDriverSurface *m_ddSurface;
|
||||
|
||||
PortabilityLayer::AntiAliasTable *m_cachedAATables;
|
||||
PortabilityLayer::RGBAColor m_cachedAAColor;
|
||||
|
||||
PortabilityLayer::QDPort m_port;
|
||||
|
||||
private:
|
||||
|
@@ -24,6 +24,8 @@ namespace
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
StandardPalette::StandardPalette()
|
||||
: m_numCachedPaletteTables(0)
|
||||
, m_numCachedToneTables(0)
|
||||
{
|
||||
for (unsigned int rs = 0; rs < 6; rs++)
|
||||
{
|
||||
@@ -82,42 +84,6 @@ namespace PortabilityLayer
|
||||
for (unsigned int gs = 0; gs < 16; gs++)
|
||||
for (unsigned int bs = 0; bs < 16; bs++)
|
||||
m_lut[rs + (gs << 4) + (bs << 8)] = MapColorAnalyticTruncated(rs, gs, bs);
|
||||
|
||||
#if 0
|
||||
for (unsigned int i = 0; i < 256; i++)
|
||||
{
|
||||
unsigned int shortChannels[3] =
|
||||
{
|
||||
m_colors[i].r / 17,
|
||||
m_colors[i].g / 17,
|
||||
m_colors[i].b / 17
|
||||
};
|
||||
|
||||
for (unsigned int b = 0; b < 16; b++)
|
||||
{
|
||||
unsigned int whiteScale[3];
|
||||
unsigned int blackScale[3];
|
||||
|
||||
for (unsigned int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
unsigned int scaledBackground = (15 - b) * shortChannels[ch];
|
||||
unsigned int scaledWhiteForeground = 15 * b;
|
||||
|
||||
blackScale[ch] = scaledBackground / 15;
|
||||
whiteScale[ch] = (scaledBackground + scaledWhiteForeground) / 15;
|
||||
}
|
||||
|
||||
m_blackAATable.m_aaTranslate[i][b] = MapColorAnalyticTruncated(blackScale[0], blackScale[1], blackScale[2]);
|
||||
m_whiteAATable.m_aaTranslate[i][b] = MapColorAnalyticTruncated(whiteScale[0], whiteScale[1], whiteScale[2]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
m_blackAATable.GenerateForPalette(RGBAColor::Create(0, 0, 0, 255), m_colors, 256);
|
||||
m_whiteAATable.GenerateForPalette(RGBAColor::Create(255, 255, 255, 255), m_colors, 256);
|
||||
#endif
|
||||
|
||||
m_whiteToneAATable.GenerateForSimpleScale(255);
|
||||
m_blackToneAATable.GenerateForSimpleScale(0);
|
||||
}
|
||||
|
||||
const RGBAColor *StandardPalette::GetColors() const
|
||||
@@ -261,29 +227,51 @@ namespace PortabilityLayer
|
||||
return MapColorLUT(color.r, color.g, color.b);
|
||||
}
|
||||
|
||||
const StandardPalette *StandardPalette::GetInstance()
|
||||
StandardPalette *StandardPalette::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
const AntiAliasTable &StandardPalette::GetWhiteAATable() const
|
||||
const AntiAliasTable &StandardPalette::GetCachedPaletteAATable(const RGBAColor &color)
|
||||
{
|
||||
return m_whiteAATable;
|
||||
uint8_t rgb[3] = { color.r, color.g, color.b };
|
||||
|
||||
for (size_t i = 0; i < m_numCachedPaletteTables; i++)
|
||||
{
|
||||
const CachedPaletteTableEntry &entry = m_cachedPaletteTables[i];
|
||||
if (entry.m_rgb[0] == rgb[0] && entry.m_rgb[1] == rgb[1] && entry.m_rgb[2] == rgb[2])
|
||||
return entry.m_aaTable;
|
||||
}
|
||||
|
||||
if (m_numCachedPaletteTables == kMaxCachedPaletteTables)
|
||||
m_numCachedPaletteTables = 0;
|
||||
|
||||
CachedPaletteTableEntry &entry = m_cachedPaletteTables[m_numCachedPaletteTables++];
|
||||
entry.m_rgb[0] = rgb[0];
|
||||
entry.m_rgb[1] = rgb[1];
|
||||
entry.m_rgb[2] = rgb[2];
|
||||
entry.m_aaTable.GenerateForPalette(color, m_colors, 256, true);
|
||||
|
||||
return entry.m_aaTable;
|
||||
}
|
||||
|
||||
const AntiAliasTable &StandardPalette::GetBlackAATable() const
|
||||
const AntiAliasTable &StandardPalette::GetCachedToneAATable(uint8_t tone)
|
||||
{
|
||||
return m_blackAATable;
|
||||
}
|
||||
for (size_t i = 0; i < m_numCachedToneTables; i++)
|
||||
{
|
||||
const CachedToneTableEntry &entry = m_cachedToneTables[i];
|
||||
if (entry.m_tone == tone)
|
||||
return entry.m_aaTable;
|
||||
}
|
||||
|
||||
const AntiAliasTable &StandardPalette::GetWhiteToneAATable() const
|
||||
{
|
||||
return m_whiteToneAATable;
|
||||
}
|
||||
if (m_numCachedToneTables == kMaxCachedToneTables)
|
||||
m_numCachedToneTables = 0;
|
||||
|
||||
const AntiAliasTable &StandardPalette::GetBlackToneAATable() const
|
||||
{
|
||||
return m_blackToneAATable;
|
||||
CachedToneTableEntry &entry = m_cachedToneTables[m_numCachedToneTables++];
|
||||
entry.m_tone = tone;
|
||||
entry.m_aaTable.GenerateForSimpleScale(tone, true);
|
||||
|
||||
return entry.m_aaTable;
|
||||
}
|
||||
|
||||
StandardPalette StandardPalette::ms_instance;
|
||||
|
@@ -20,22 +20,38 @@ namespace PortabilityLayer
|
||||
static uint8_t MapColorAnalytic(const RGBAColor &color);
|
||||
uint8_t MapColorLUT(uint8_t r, uint8_t g, uint8_t b) const;
|
||||
uint8_t MapColorLUT(const RGBAColor &color) const;
|
||||
const AntiAliasTable &GetWhiteAATable() const;
|
||||
const AntiAliasTable &GetBlackAATable() const;
|
||||
|
||||
const AntiAliasTable &GetWhiteToneAATable() const;
|
||||
const AntiAliasTable &GetBlackToneAATable() const;
|
||||
const AntiAliasTable &GetCachedPaletteAATable(const RGBAColor &color);
|
||||
const AntiAliasTable &GetCachedToneAATable(uint8_t tone);
|
||||
|
||||
static const StandardPalette *GetInstance();
|
||||
static StandardPalette *GetInstance();
|
||||
|
||||
private:
|
||||
static StandardPalette ms_instance;
|
||||
|
||||
struct CachedPaletteTableEntry
|
||||
{
|
||||
uint8_t m_rgb[3];
|
||||
AntiAliasTable m_aaTable;
|
||||
};
|
||||
|
||||
struct CachedToneTableEntry
|
||||
{
|
||||
uint8_t m_tone;
|
||||
AntiAliasTable m_aaTable;
|
||||
};
|
||||
|
||||
static const size_t kMaxCachedPaletteTables = 16;
|
||||
static const size_t kMaxCachedToneTables = 16;
|
||||
|
||||
CachedPaletteTableEntry m_cachedPaletteTables[kMaxCachedPaletteTables];
|
||||
size_t m_numCachedPaletteTables;
|
||||
|
||||
CachedToneTableEntry m_cachedToneTables[kMaxCachedToneTables];
|
||||
size_t m_numCachedToneTables;
|
||||
|
||||
RGBAColor m_colors[kSize];
|
||||
AntiAliasTable m_whiteAATable;
|
||||
AntiAliasTable m_blackAATable;
|
||||
AntiAliasTable m_whiteToneAATable;
|
||||
AntiAliasTable m_blackToneAATable;
|
||||
|
||||
uint8_t m_lut[16 * 16 * 16];
|
||||
};
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ Texture2D<float3> surfaceTexture : register(t0);
|
||||
|
||||
cbuffer SScaleQuadPixelConstants : register(b0)
|
||||
{
|
||||
float4 dxdy_Unused;
|
||||
float4 dxdy_InvPixelScale;
|
||||
};
|
||||
|
||||
struct SDrawQuadPixelOutput
|
||||
@@ -20,10 +20,10 @@ float3 SamplePixel(int2 coord)
|
||||
|
||||
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
|
||||
{
|
||||
float dx = dxdy_Unused.x;
|
||||
float dy = dxdy_Unused.y;
|
||||
float dx = dxdy_InvPixelScale.x;
|
||||
float dy = dxdy_InvPixelScale.y;
|
||||
|
||||
float2 pixelTopLeftCoord = max(0.0, input.texCoord.xy - float2(dx, dy) * 0.5);
|
||||
float2 pixelTopLeftCoord = max(0.0, (input.pos.xy - float2(0.5, 0.5)) * dxdy_InvPixelScale.zw);
|
||||
float2 pixelBottomRightCoord = pixelTopLeftCoord + min(float2(1.0, 1.0), float2(dx, dy));
|
||||
|
||||
int2 topLeftCoordInteger = int2(floor(pixelTopLeftCoord));
|
||||
|
@@ -1,71 +1,71 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
Copyright 2019 Eric Lasota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "CFileStream.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "BinHex4.h"
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace PortabilityLayer;
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr, "Usage: hqx2gp <input.hqx> <input.ts> <output>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *f = nullptr;
|
||||
if (fopen_s(&f, argv[1], "rb"))
|
||||
f = nullptr;
|
||||
#else
|
||||
FILE *f = fopen(argv[1], "rb");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "Could not open input file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *tsF = nullptr;
|
||||
if (fopen_s(&tsF, argv[2], "rb"))
|
||||
tsF = nullptr;
|
||||
#else
|
||||
FILE *tsF = fopen(argv[2], "rb");
|
||||
#endif
|
||||
|
||||
if (!tsF)
|
||||
{
|
||||
fprintf(stderr, "Could not open timestamp file");
|
||||
return -1;
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
Copyright 2019 Eric Lasota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "CFileStream.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "BinHex4.h"
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace PortabilityLayer;
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr, "Usage: hqx2gp <input.hqx> <input.ts> <output>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *f = nullptr;
|
||||
if (fopen_s(&f, argv[1], "rb"))
|
||||
f = nullptr;
|
||||
#else
|
||||
FILE *f = fopen(argv[1], "rb");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "Could not open input file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *tsF = nullptr;
|
||||
if (fopen_s(&tsF, argv[2], "rb"))
|
||||
tsF = nullptr;
|
||||
#else
|
||||
FILE *tsF = fopen(argv[2], "rb");
|
||||
#endif
|
||||
|
||||
if (!tsF)
|
||||
{
|
||||
fprintf(stderr, "Could not open timestamp file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t timestamp = 0;
|
||||
@@ -81,70 +81,70 @@ int main(int argc, const char **argv)
|
||||
for (int i = 0; i < 8; i++)
|
||||
timestamp |= static_cast<int64_t>(encodedTimestamp[i]) << (i * 8);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fclose(tsF);
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs);
|
||||
|
||||
fs.Close();
|
||||
|
||||
std::string fname = argv[3];
|
||||
|
||||
fclose(tsF);
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs);
|
||||
|
||||
fs.Close();
|
||||
|
||||
std::string fname = argv[3];
|
||||
|
||||
const char* extensions[] = { ".gpf", ".gpr", ".gpd", ".gpc" };
|
||||
|
||||
MacFileProperties mfp = memFile->FileInfo().m_properties;
|
||||
mfp.m_creationDate = mfp.m_modifiedDate = timestamp;
|
||||
|
||||
MacFilePropertiesSerialized sp;
|
||||
sp.Serialize(mfp);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const void *bufferToWrite = nullptr;
|
||||
size_t sizeToWrite = 0;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bufferToWrite = sp.m_data;
|
||||
sizeToWrite = sp.kSize;
|
||||
break;
|
||||
case 1:
|
||||
bufferToWrite = memFile->ResourceFork();
|
||||
sizeToWrite = memFile->FileInfo().m_resourceForkSize;
|
||||
break;
|
||||
case 2:
|
||||
bufferToWrite = memFile->DataFork();
|
||||
sizeToWrite = memFile->FileInfo().m_dataForkSize;
|
||||
break;
|
||||
case 3:
|
||||
bufferToWrite = memFile->Comment();
|
||||
sizeToWrite = memFile->FileInfo().m_commentSize;
|
||||
break;
|
||||
};
|
||||
|
||||
if (sizeToWrite == 0)
|
||||
continue;
|
||||
|
||||
std::string path = fname + extensions[i];
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *outF = nullptr;
|
||||
if (fopen_s(&outF, path.c_str(), "wb"))
|
||||
outF = nullptr;
|
||||
#else
|
||||
FILE *outF = fopen(path.c_str(), "wb");
|
||||
#endif
|
||||
|
||||
if (!outF)
|
||||
continue;
|
||||
|
||||
fwrite(bufferToWrite, 1, sizeToWrite, outF);
|
||||
fclose(outF);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
mfp.m_creationDate = mfp.m_modifiedDate = timestamp;
|
||||
|
||||
MacFilePropertiesSerialized sp;
|
||||
sp.Serialize(mfp);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const void *bufferToWrite = nullptr;
|
||||
size_t sizeToWrite = 0;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bufferToWrite = sp.m_data;
|
||||
sizeToWrite = sp.kSize;
|
||||
break;
|
||||
case 1:
|
||||
bufferToWrite = memFile->ResourceFork();
|
||||
sizeToWrite = memFile->FileInfo().m_resourceForkSize;
|
||||
break;
|
||||
case 2:
|
||||
bufferToWrite = memFile->DataFork();
|
||||
sizeToWrite = memFile->FileInfo().m_dataForkSize;
|
||||
break;
|
||||
case 3:
|
||||
bufferToWrite = memFile->Comment();
|
||||
sizeToWrite = memFile->FileInfo().m_commentSize;
|
||||
break;
|
||||
};
|
||||
|
||||
if (sizeToWrite == 0)
|
||||
continue;
|
||||
|
||||
std::string path = fname + extensions[i];
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *outF = nullptr;
|
||||
if (fopen_s(&outF, path.c_str(), "wb"))
|
||||
outF = nullptr;
|
||||
#else
|
||||
FILE *outF = fopen(path.c_str(), "wb");
|
||||
#endif
|
||||
|
||||
if (!outF)
|
||||
continue;
|
||||
|
||||
fwrite(bufferToWrite, 1, sizeToWrite, outF);
|
||||
fclose(outF);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ bool LZWDecompressor::ReadBytes(void *dest, size_t numBytes)
|
||||
symbolcounter++;
|
||||
if (symbol == 256 && blockmode)
|
||||
{
|
||||
// Skip garbage data after a clear. God damn, this is dumb.
|
||||
// Skip garbage data after a clear.
|
||||
int symbolsize = LZWSuggestedSymbolSize(lzw);
|
||||
if (symbolcounter % 8)
|
||||
{
|
||||
|
@@ -5,8 +5,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <crtdbg.h>
|
||||
|
||||
|
||||
|
||||
static const uint16_t RandomizationTable[] =
|
||||
|
Reference in New Issue
Block a user