SAGA2: Clear some WindowDecoration global constructor warnings

This commit is contained in:
a/ 2021-06-30 07:12:08 +09:00 committed by Eugene Sandulenko
parent c308387589
commit 7fe3baf184
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
4 changed files with 77 additions and 14 deletions

View File

@ -142,10 +142,10 @@ static const StaticRect scrollBtnRect = {
};
WindowDecoration autoMapDecorations[numAutoMapPanels] = {
{ WindowDecoration(*autoMapPanelRects[0], autoMapTopPanelResID) },
{ WindowDecoration(*autoMapPanelRects[1], autoMapMidPanelResID) },
{ WindowDecoration(*autoMapPanelRects[2], autoMapBotPanelResID) }
StaticWindow autoMapDecorations[numAutoMapPanels] = {
{*autoMapPanelRects[0], nullptr, autoMapTopPanelResID},
{*autoMapPanelRects[1], nullptr, autoMapMidPanelResID},
{*autoMapPanelRects[2], nullptr, autoMapBotPanelResID}
};

View File

@ -122,16 +122,22 @@ void DecoratedWindow::setDecorations(
hResContext *con) {
int16 i;
decorations = dec;
numDecorations = count;
if (decorations)
delete[] decorations;
decorations = new WindowDecoration[numDecorations];
// For each "decorative panel" within the frame of the window
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the imageCache
// request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con,
MKTAG('B', 'R', 'D', dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
decorations[i].imageNumber = dec->imageNumber;
}
}
@ -142,14 +148,21 @@ void DecoratedWindow::setDecorations(
hResID id_) {
int16 i;
decorations = dec;
numDecorations = count;
if (decorations)
delete[] decorations;
decorations = new WindowDecoration[numDecorations];
// For each "decorative panel" within the frame of the window
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
decorations[i].imageNumber = dec->imageNumber;
}
}
@ -161,6 +174,40 @@ void DecoratedWindow::setDecorations(
setDecorations(dec, count, con, MKTAG(a, b, c, 0));
}
void DecoratedWindow::setDecorations(
StaticWindow *dec,
int16 count,
hResContext *con,
hResID id_) {
int16 i;
numDecorations = count;
if (decorations)
delete[] decorations;
decorations = new WindowDecoration[numDecorations];
// For each "decorative panel" within the frame of the window
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
decorations[i].imageNumber = dec->imageNumber;
}
}
void DecoratedWindow::setDecorations(
StaticWindow *dec,
int16 count,
hResContext *con,
char a, char b, char c) {
setDecorations(dec, count, con, MKTAG(a, b, c, 0));
}
// Free the decorations from the memory pool
void DecoratedWindow::removeDecorations(void) {
@ -172,7 +219,8 @@ void DecoratedWindow::removeDecorations(void) {
ImageCache.releaseImage(dec->image);
}
decorations = NULL;
if (decorations)
delete[] decorations;
numDecorations = 0;
}

View File

@ -53,6 +53,12 @@ class GameObject;
// artwork, this class provides a linked list of all the "artwork
// panels" which cover the borders of the image.
struct StaticWindow {
StaticRect extent;
void *image;
int16 imageNumber;
};
struct WindowDecoration {
Rect16 extent; // area that image covers
void *image; // pointer to image data
@ -70,6 +76,12 @@ struct WindowDecoration {
imageNumber = num;
}
WindowDecoration(StaticWindow s) {
extent = s.extent;
image = s.image;
imageNumber = s.imageNumber;
}
// this sets the decorations ( for use with the default constructor
void set(const Rect16 &r, int16 num) {
extent = r, image = NULL, imageNumber = num;
@ -224,6 +236,9 @@ public:
void setDecorations(WindowDecoration *, int16, hResContext *, hResID);
void setDecorations(WindowDecoration *, int16, hResContext *, char, char, char);
void setDecorations(StaticWindow *, int16, hResContext *, hResID);
void setDecorations(StaticWindow *, int16, hResContext *, char, char, char);
// Free up memory used by decorative panels
void removeDecorations(void);

View File

@ -230,10 +230,10 @@ static const StaticRect *saveLoadTextRects[kNumSaveLoadTexts] = {
// save/load dialog window decorations
WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] = {
{ WindowDecoration(*saveLoadPanelRects[0], SLTopPanelResID) },
{ WindowDecoration(*saveLoadPanelRects[1], SLMidPanelResID) },
{ WindowDecoration(*saveLoadPanelRects[2], SLBotPanelResID) }
StaticWindow saveWindowDecorations[kNumSaveLoadPanels] = {
{*saveLoadPanelRects[0], nullptr, SLTopPanelResID},
{*saveLoadPanelRects[1], nullptr, SLMidPanelResID},
{*saveLoadPanelRects[2], nullptr, SLBotPanelResID}
};