mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Get scoreboard bar working
This commit is contained in:
@@ -50,7 +50,7 @@ extern Rect backSrcRect;
|
||||
extern Rect mainWindowRect, houseRect;
|
||||
extern houseHand thisHouse;
|
||||
extern roomPtr thisRoom;
|
||||
extern WindowPtr mainWindow, coordWindow;
|
||||
extern WindowPtr mainWindow, coordWindow, boardWindow;
|
||||
extern long theScore;
|
||||
extern short playOriginH, playOriginV;
|
||||
extern short thisRoomNumber, theMode, batteryTotal, bandsTotal;
|
||||
|
||||
@@ -176,6 +176,7 @@ void VariableInit (void)
|
||||
|
||||
mirrorRgn = nil;
|
||||
mainWindow = nil;
|
||||
boardWindow = nil;
|
||||
mapWindow = nil;
|
||||
toolsWindow = nil;
|
||||
linkWindow = nil;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "House.h"
|
||||
#include "RectUtils.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "WindowDef.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
#define kMainWindowID 128
|
||||
@@ -37,7 +39,7 @@ Cursor diagCursor;
|
||||
Rect workSrcRect;
|
||||
GWorldPtr workSrcMap;
|
||||
Rect mainWindowRect;
|
||||
WindowPtr mainWindow, menuWindow;
|
||||
WindowPtr mainWindow, menuWindow, boardWindow;
|
||||
short isEditH, isEditV;
|
||||
short playOriginH, playOriginV;
|
||||
short splashOriginH, splashOriginV;
|
||||
@@ -221,6 +223,20 @@ void OpenMainWindow (void)
|
||||
thisMac.screen.top, true);
|
||||
ShowWindow(menuWindow);
|
||||
}
|
||||
if (boardWindow == nil)
|
||||
{
|
||||
PortabilityLayer::WindowManager *windowManager = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
Rect scorebarRect = thisMac.screen;
|
||||
scorebarRect.bottom = scorebarRect.top + kScoreboardTall;
|
||||
|
||||
PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, 0, true, false, 0, 0, PSTR("Scoreboard"));
|
||||
boardWindow = windowManager->CreateWindow(windowDef);
|
||||
if (boardWindow != nil)
|
||||
windowManager->PutWindowBehind(boardWindow, PL_GetPutInFrontWindowPtr());
|
||||
else
|
||||
PL_NotYetImplemented_TODO("Errors");
|
||||
}
|
||||
mainWindowRect = thisMac.screen;
|
||||
ZeroRectCorner(&mainWindowRect);
|
||||
mainWindowRect.bottom -= 20; // thisMac.menuHigh
|
||||
@@ -271,6 +287,10 @@ void CloseMainWindow (void)
|
||||
if (mainWindow != nil)
|
||||
DisposeWindow(mainWindow);
|
||||
mainWindow = nil;
|
||||
|
||||
if (boardWindow != nil)
|
||||
DisposeWindow(boardWindow);
|
||||
boardWindow = nil;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ZoomBetweenWindows
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "PLPasStr.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "MenuManager.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
|
||||
@@ -53,12 +54,12 @@ extern Boolean evenFrame, onePlayerLeft;
|
||||
|
||||
void MarkScoreboardPortDirty(void)
|
||||
{
|
||||
GetWindowPort(mainWindow)->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
GetWindowPort(boardWindow)->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RefreshScoreboard
|
||||
|
||||
void RefreshScoreboard (short mode)
|
||||
void RefreshScoreboard (SInt16 mode)
|
||||
{
|
||||
doRollScore = true;
|
||||
|
||||
@@ -67,7 +68,7 @@ void RefreshScoreboard (short mode)
|
||||
RefreshPoints();
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&boardSrcRect, &boardDestRect, srcCopy, 0L);
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
@@ -75,6 +76,8 @@ void RefreshScoreboard (short mode)
|
||||
QuickBatteryRefresh(false);
|
||||
QuickBandsRefresh(false);
|
||||
QuickFoilRefresh(false);
|
||||
|
||||
PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(false);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HandleDynamicScoreboard
|
||||
@@ -195,8 +198,6 @@ void RefreshRoomTitle (short mode)
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardTSrcMap),
|
||||
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||
&boardTSrcRect, &boardTDestRect, srcCopy, nil);
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RefreshNumGliders
|
||||
@@ -236,8 +237,6 @@ void RefreshNumGliders (void)
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
||||
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||
&boardGSrcRect, &boardGDestRect, srcCopy, nil);
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RefreshPoints
|
||||
@@ -275,8 +274,6 @@ void RefreshPoints (void)
|
||||
&boardPSrcRect, &boardPDestRect, srcCopy, nil);
|
||||
|
||||
displayedScore = theScore;
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- QuickGlidersRefresh
|
||||
@@ -310,7 +307,7 @@ void QuickGlidersRefresh (void)
|
||||
ForeColor(blackColor);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&boardGSrcRect, &boardGQDestRect, srcCopy, nil);
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
@@ -347,7 +344,7 @@ void QuickScoreRefresh (void)
|
||||
ForeColor(blackColor);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&boardPSrcRect, &boardPQDestRect, srcCopy, nil);
|
||||
|
||||
MarkScoreboardPortDirty();
|
||||
@@ -360,7 +357,7 @@ void QuickBatteryRefresh (Boolean flash)
|
||||
if ((batteryTotal > 0) && (!flash))
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBadgesRects[kBatteryBadge],
|
||||
&badgesDestRects[kBatteryBadge],
|
||||
srcCopy, nil);
|
||||
@@ -368,7 +365,7 @@ void QuickBatteryRefresh (Boolean flash)
|
||||
else if ((batteryTotal < 0) && (!flash))
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBadgesRects[kHeliumBadge],
|
||||
&badgesDestRects[kHeliumBadge],
|
||||
srcCopy, nil);
|
||||
@@ -376,7 +373,7 @@ void QuickBatteryRefresh (Boolean flash)
|
||||
else
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBlankRects[kBatteryBadge],
|
||||
&badgesDestRects[kBatteryBadge],
|
||||
srcCopy, nil);
|
||||
@@ -392,7 +389,7 @@ void QuickBandsRefresh (Boolean flash)
|
||||
if ((bandsTotal > 0) && (!flash))
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBadgesRects[kBandsBadge],
|
||||
&badgesDestRects[kBandsBadge],
|
||||
srcCopy, nil);
|
||||
@@ -400,7 +397,7 @@ void QuickBandsRefresh (Boolean flash)
|
||||
else
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBlankRects[kBandsBadge],
|
||||
&badgesDestRects[kBandsBadge],
|
||||
srcCopy, nil);
|
||||
@@ -416,7 +413,7 @@ void QuickFoilRefresh (Boolean flash)
|
||||
if ((foilTotal > 0) && (!flash))
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBadgesRects[kFoilBadge],
|
||||
&badgesDestRects[kFoilBadge],
|
||||
srcCopy, nil);
|
||||
@@ -424,7 +421,7 @@ void QuickFoilRefresh (Boolean flash)
|
||||
else
|
||||
{
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||
&badgesBlankRects[kFoilBadge],
|
||||
&badgesDestRects[kFoilBadge],
|
||||
srcCopy, nil);
|
||||
|
||||
@@ -129,6 +129,7 @@ namespace PortabilityLayer
|
||||
void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) override;
|
||||
|
||||
void DrawMenuBar() override;
|
||||
void SetMenuVisible(bool isVisible) override;
|
||||
|
||||
void RenderFrame(IGpDisplayDriver *displayDriver) override;
|
||||
|
||||
@@ -189,6 +190,7 @@ namespace PortabilityLayer
|
||||
Menu **m_lastMenu;
|
||||
bool m_haveMenuBarLayout;
|
||||
bool m_haveIcon;
|
||||
bool m_menuBarVisible;
|
||||
|
||||
uint8_t m_iconColors[16 * 16];
|
||||
uint8_t m_iconMask[32];
|
||||
@@ -207,6 +209,7 @@ namespace PortabilityLayer
|
||||
, m_haveMenuBarLayout(false)
|
||||
, m_haveIcon(false)
|
||||
, m_iconGraphic(nullptr)
|
||||
, m_menuBarVisible(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -707,8 +710,16 @@ namespace PortabilityLayer
|
||||
m_menuBarGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
void MenuManagerImpl::SetMenuVisible(bool isVisible)
|
||||
{
|
||||
m_menuBarVisible = isVisible;
|
||||
}
|
||||
|
||||
void MenuManagerImpl::RenderFrame(IGpDisplayDriver *displayDriver)
|
||||
{
|
||||
if (!m_menuBarVisible)
|
||||
return;
|
||||
|
||||
if (m_menuBarGraf)
|
||||
{
|
||||
m_menuBarGraf->PushToDDSurface(displayDriver);
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace PortabilityLayer
|
||||
virtual void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) = 0;
|
||||
|
||||
virtual void DrawMenuBar() = 0;
|
||||
virtual void SetMenuVisible(bool isVisible) = 0;
|
||||
|
||||
virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0;
|
||||
|
||||
|
||||
@@ -897,7 +897,11 @@ short StringWidth(const PLPasStr &str)
|
||||
if (!rfont)
|
||||
return 0;
|
||||
|
||||
return rfont->MeasureString(str.UChars(), str.Length());
|
||||
const size_t width = rfont->MeasureString(str.UChars(), str.Length());
|
||||
if (width > SHRT_MAX)
|
||||
return SHRT_MAX;
|
||||
|
||||
return static_cast<short>(width);
|
||||
}
|
||||
|
||||
void GetMouse(Point *point)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "WindowDef.h"
|
||||
#include "IOStream.h"
|
||||
#include "CoreDefs.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
{
|
||||
bool WindowDef::Deserialize(IOStream *stream)
|
||||
{
|
||||
struct WindowDefPart1
|
||||
@@ -40,4 +43,21 @@ namespace PortabilityLayer
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
WindowDef WindowDef::Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title)
|
||||
{
|
||||
WindowDef wdef;
|
||||
wdef.m_initialRect = initialRect;
|
||||
wdef.m_wdefResID = wdefID;
|
||||
wdef.m_visibilityStatus = isVisible ? 1 : 0;
|
||||
wdef.m_hasCloseBox = hasCloseBox ? 1 : 0;
|
||||
wdef.m_referenceConstant = refConstant;
|
||||
wdef.m_positionSpec = positionSpec;
|
||||
|
||||
const uint8_t titleLength = static_cast<uint8_t>(std::max<size_t>(255, title.Length()));
|
||||
wdef.m_title[0] = titleLength;
|
||||
memcpy(wdef.m_title + 1, title.UChars(), titleLength);
|
||||
|
||||
return wdef;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "SharedTypes.h"
|
||||
#include "PascalStr.h"
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class IOStream;
|
||||
@@ -18,5 +20,7 @@ namespace PortabilityLayer
|
||||
uint8_t m_title[256];
|
||||
|
||||
bool Deserialize(IOStream *stream);
|
||||
|
||||
static WindowDef Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user