mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- started work on load/save menus.
This commit is contained in:
parent
943cb64eda
commit
0cedad6390
14 changed files with 108 additions and 54 deletions
|
@ -213,6 +213,9 @@ struct GameInterface
|
|||
virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; }
|
||||
virtual bool DrawSpecialScreen(const DVector2 &origin, int tilenum) { return false; }
|
||||
virtual void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) {}
|
||||
virtual void DrawMenuCaption(const DVector2& origin, const char* text) {}
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern GameInterface* gi;
|
||||
|
|
|
@ -205,13 +205,13 @@ public:
|
|||
if (scale == 1)
|
||||
{
|
||||
DrawChar(&twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', TAG_DONE);
|
||||
DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
|
||||
DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y,
|
||||
&Text[StartPos], TAG_DONE);
|
||||
|
||||
if (cursor)
|
||||
{
|
||||
DrawChar(&twod, CurrentConsoleFont, CR_YELLOW,
|
||||
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb),
|
||||
x + CurrentConsoleFont->CharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->CharWidth(0xb),
|
||||
y, '\xb', TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public:
|
|||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||
DTA_KeepRatio, true, TAG_DONE);
|
||||
|
||||
DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
|
||||
DrawText(&twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->CharWidth(0x1c), y,
|
||||
&Text[StartPos],
|
||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
if (cursor)
|
||||
{
|
||||
DrawChar(&twod, CurrentConsoleFont, CR_YELLOW,
|
||||
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb),
|
||||
x + CurrentConsoleFont->CharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->CharWidth(0xb),
|
||||
y, '\xb',
|
||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||
|
@ -614,7 +614,7 @@ void C_InitConsole (int width, int height, bool ingame)
|
|||
vidactive = ingame;
|
||||
if (CurrentConsoleFont != NULL)
|
||||
{
|
||||
cwidth = CurrentConsoleFont->GetCharWidth ('M');
|
||||
cwidth = CurrentConsoleFont->CharWidth ('M');
|
||||
cheight = CurrentConsoleFont->GetHeight();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -576,11 +576,11 @@ FTexture *FFont::GetChar (int code, int translation, int *const width, bool *red
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// FFont :: GetCharWidth
|
||||
// FFont :: CharWidth
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int FFont::GetCharWidth (int code) const
|
||||
int FFont::CharWidth (int code) const
|
||||
{
|
||||
code = GetCharCode(code, true);
|
||||
if (code >= 0) return Chars[code - FirstChar].XMove;
|
||||
|
@ -684,7 +684,7 @@ int FFont::StringWidth(const uint8_t *string) const
|
|||
}
|
||||
else
|
||||
{
|
||||
w += GetCharWidth(chr) + GlobalKerning;
|
||||
w += NewSmallFont->CharWidth(chr) + GlobalKerning;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
virtual ~FFont ();
|
||||
|
||||
virtual FTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const;
|
||||
virtual int GetCharWidth (int code) const;
|
||||
virtual int CharWidth (int code) const;
|
||||
int GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const;
|
||||
int GetSpaceWidth () const { return SpaceWidth; }
|
||||
int GetHeight () const { return FontHeight; }
|
||||
|
|
|
@ -114,7 +114,7 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
|||
lastWasSpace = false;
|
||||
}
|
||||
|
||||
nw = font->GetCharWidth (c);
|
||||
nw = font->CharWidth (c);
|
||||
|
||||
if ((w > 0 && w + nw > maxwidth) || c == '\n')
|
||||
{ // Time to break the line
|
||||
|
|
|
@ -266,6 +266,14 @@ void DListMenu::Ticker ()
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void DListMenu::PreDraw()
|
||||
{
|
||||
if (mDesc->mCaption.IsNotEmpty())
|
||||
{
|
||||
gi->DrawMenuCaption(origin, mDesc->mCaption);
|
||||
}
|
||||
}
|
||||
|
||||
void DListMenu::Drawer ()
|
||||
{
|
||||
PreDraw();
|
||||
|
|
|
@ -92,12 +92,13 @@ protected:
|
|||
static void ReadSaveStrings ();
|
||||
|
||||
|
||||
FTexture *SavePic;
|
||||
FTexture *SavePic = nullptr;
|
||||
TArray<FBrokenLines> SaveComment;
|
||||
bool mEntering;
|
||||
FString savegamestring;
|
||||
|
||||
DLoadSaveMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
|
||||
void Init(DMenu* parent, FListMenuDescriptor* desc) override;
|
||||
void Destroy();
|
||||
|
||||
int RemoveSaveSlot (int index);
|
||||
|
@ -314,20 +315,27 @@ void M_NotifyNewSave (const char *file, const char *title, bool okForQuicksave)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
DLoadSaveMenu::DLoadSaveMenu(DMenu *parent, FListMenuDescriptor *desc)
|
||||
: DListMenu(parent, desc)
|
||||
DLoadSaveMenu::DLoadSaveMenu(DMenu* parent, FListMenuDescriptor* desc)
|
||||
: DListMenu(parent, desc)
|
||||
{
|
||||
ReadSaveStrings();
|
||||
}
|
||||
|
||||
savepicLeft = 10;
|
||||
savepicTop = 54*CleanYfac;
|
||||
savepicWidth = 216*screen->GetWidth()/640;
|
||||
savepicHeight = 135*screen->GetHeight()/400;
|
||||
void DLoadSaveMenu::Init(DMenu* parent, FListMenuDescriptor* desc)
|
||||
{
|
||||
Super::Init(parent, desc);
|
||||
int Width43 = screen->GetHeight() * 4 / 3;
|
||||
int Left43 = (screen->GetWidth() - Width43) / 2;
|
||||
float wScale = Width43 / 640.;
|
||||
savepicLeft = Left43 + int(20 * wScale);
|
||||
savepicTop = mDesc->mYpos * screen->GetHeight() / 200 ;
|
||||
savepicWidth = int(240 * wScale);
|
||||
savepicHeight = int(180 * wScale);
|
||||
|
||||
rowHeight = (SmallFont->GetHeight() + 1) * CleanYfac;
|
||||
listboxLeft = savepicLeft + savepicWidth + 14;
|
||||
rowHeight = (NewConsoleFont->GetHeight() + 1) * CleanYfac;
|
||||
listboxLeft = savepicLeft + savepicWidth + int(20 * wScale);
|
||||
listboxTop = savepicTop;
|
||||
listboxWidth = screen->GetWidth() - listboxLeft - 10;
|
||||
listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale);
|
||||
int listboxHeight1 = screen->GetHeight() - listboxTop - 10;
|
||||
listboxRows = (listboxHeight1 - 1) / rowHeight;
|
||||
listboxHeight = listboxRows * rowHeight + 1;
|
||||
|
@ -335,7 +343,7 @@ DLoadSaveMenu::DLoadSaveMenu(DMenu *parent, FListMenuDescriptor *desc)
|
|||
listboxBottom = listboxTop + listboxHeight;
|
||||
|
||||
commentLeft = savepicLeft;
|
||||
commentTop = savepicTop + savepicHeight + 16;
|
||||
commentTop = savepicTop + savepicHeight + int(16 * wScale);
|
||||
commentWidth = savepicWidth;
|
||||
commentHeight = (51+(screen->GetHeight()>200?10:0))*CleanYfac;
|
||||
commentRight = commentLeft + commentWidth;
|
||||
|
@ -437,16 +445,16 @@ void DLoadSaveMenu::Drawer ()
|
|||
}
|
||||
else
|
||||
{
|
||||
twod.AddColorOnlyQuad(savepicLeft, savepicTop, savepicLeft+savepicWidth, savepicTop+savepicHeight, 0xff000000);
|
||||
twod.AddColorOnlyQuad(savepicLeft, savepicTop, savepicWidth, savepicHeight, 0x80000000);
|
||||
|
||||
if (SaveGames.Size() > 0)
|
||||
{
|
||||
const char *text =
|
||||
(Selected == -1 || !SaveGames[Selected]->bOldVersion)
|
||||
? GStrings("MNU_NOPICTURE") : GStrings("MNU_DIFFVERSION");
|
||||
const int textlen = SmallFont->StringWidth (text)*CleanXfac;
|
||||
const int textlen = NewConsoleFont->StringWidth (text)*CleanXfac;
|
||||
|
||||
DrawText (&twod, SmallFont, CR_GOLD, savepicLeft+(savepicWidth-textlen)/2,
|
||||
DrawText (&twod, NewConsoleFont, CR_GOLD, savepicLeft+(savepicWidth-textlen)/2,
|
||||
savepicTop+(savepicHeight-rowHeight)/2, text,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
|
@ -454,7 +462,7 @@ void DLoadSaveMenu::Drawer ()
|
|||
|
||||
// Draw comment area
|
||||
//V_DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
||||
twod.AddColorOnlyQuad(commentLeft, commentTop, commentRight, commentBottom, 0xff000000);
|
||||
twod.AddColorOnlyQuad(commentLeft, commentTop, commentWidth, commentHeight, 0x80000000);
|
||||
if (SaveComment.Size())
|
||||
{
|
||||
// I'm not sure why SaveComment would go NULL in this loop, but I got
|
||||
|
@ -462,22 +470,22 @@ void DLoadSaveMenu::Drawer ()
|
|||
// for that.
|
||||
for (i = 0; i < SaveComment.Size() && SaveComment[i].Width >= 0 && i < 6; ++i)
|
||||
{
|
||||
DrawText (&twod, SmallFont, CR_GOLD, commentLeft, commentTop
|
||||
+ SmallFont->GetHeight()*i*CleanYfac, SaveComment[i].Text,
|
||||
DrawText (&twod, NewConsoleFont, CR_GOLD, commentLeft, commentTop
|
||||
+ NewConsoleFont->GetHeight()*i*CleanYfac, SaveComment[i].Text,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw file area
|
||||
//V_DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||
twod.AddColorOnlyQuad(listboxLeft, listboxTop, listboxRight, listboxBottom, 0xff000000);
|
||||
twod.AddColorOnlyQuad(listboxLeft, listboxTop, listboxWidth, listboxHeight, 0x80000000);
|
||||
|
||||
if (SaveGames.Size() == 0)
|
||||
{
|
||||
const char * text = GStrings("MNU_NOFILES");
|
||||
const int textlen = SmallFont->StringWidth (text)*CleanXfac;
|
||||
const int textlen = NewConsoleFont->StringWidth (text)*CleanXfac;
|
||||
|
||||
DrawText (&twod, SmallFont, CR_GOLD, listboxLeft+(listboxWidth-textlen)/2,
|
||||
DrawText (&twod, NewConsoleFont, CR_GOLD, listboxLeft+(listboxWidth-textlen)/2,
|
||||
listboxTop+(listboxHeight-rowHeight)/2, text,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
return;
|
||||
|
@ -510,19 +518,19 @@ void DLoadSaveMenu::Drawer ()
|
|||
didSeeSelected = true;
|
||||
if (!mEntering)
|
||||
{
|
||||
DrawText(&twod, SmallFont, color,
|
||||
DrawText(&twod, NewConsoleFont, color,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->Title,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(&twod, SmallFont, CR_WHITE,
|
||||
DrawText(&twod, NewConsoleFont, CR_WHITE,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, savegamestring,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
|
||||
char curs[2] = { SmallFont->GetCursor(), 0 };
|
||||
DrawText(&twod, SmallFont, CR_WHITE,
|
||||
listboxLeft+1+SmallFont->StringWidth (savegamestring)*CleanXfac,
|
||||
char curs[2] = { NewConsoleFont->GetCursor(), 0 };
|
||||
DrawText(&twod, NewConsoleFont, CR_WHITE,
|
||||
listboxLeft+1+NewConsoleFont->StringWidth (savegamestring)*CleanXfac,
|
||||
listboxTop+rowHeight*i+CleanYfac,
|
||||
curs,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
|
@ -530,7 +538,7 @@ void DLoadSaveMenu::Drawer ()
|
|||
}
|
||||
else
|
||||
{
|
||||
DrawText(&twod, SmallFont, color,
|
||||
DrawText(&twod, NewConsoleFont, color,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->Title,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
|
@ -692,7 +700,7 @@ bool DLoadSaveMenu::Responder (event_t *ev)
|
|||
if (!SaveGames[Selected]->Filename.IsEmpty())
|
||||
{
|
||||
FStringf workbuf("File on disk:\n%s", SaveGames[Selected]->Filename.GetChars());
|
||||
SaveComment = V_BreakLines (SmallFont, 216*screen->GetWidth()/640/CleanXfac, workbuf);
|
||||
SaveComment = V_BreakLines (NewConsoleFont, 216*screen->GetWidth()/640/CleanXfac, workbuf);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -960,7 +968,7 @@ bool DLoadMenu::MenuEvent (int mkey, bool fromcontroller)
|
|||
static TMenuClassDescriptor<DLoadMenu> _lm("LoadMenu");
|
||||
static TMenuClassDescriptor<DSaveMenu> _sm("SaveMenu");
|
||||
|
||||
void RegisterRedneckMenus()
|
||||
void RegisterLoadsaveMenus()
|
||||
{
|
||||
menuClasses.Push(&_sm);
|
||||
menuClasses.Push(&_lm);
|
||||
|
|
|
@ -102,7 +102,7 @@ bool MenuTransition::StartTransition(DMenu *from, DMenu *to, MenuTransitionType
|
|||
else
|
||||
{
|
||||
start = (int32_t) totalclock;
|
||||
length = 300;
|
||||
length = 30;
|
||||
dir = animtype == MA_Advance? 1 : -1;
|
||||
previous = from;
|
||||
current = to;
|
||||
|
@ -331,6 +331,7 @@ void DMenu::Drawer ()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool DMenu::DimAllowed()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -537,6 +537,7 @@ public:
|
|||
bool MouseEvent(int type, int x, int y) override;
|
||||
void Ticker () override;
|
||||
void Drawer () override;
|
||||
void PreDraw() override;
|
||||
virtual void SelectionChanged() {}
|
||||
void SetFocus(FListMenuItem *fc)
|
||||
{
|
||||
|
|
|
@ -373,11 +373,7 @@ protected:
|
|||
void PreDraw() override
|
||||
{
|
||||
CallScript(CurrentMenu == this ? EVENT_DISPLAYMENU : EVENT_DISPLAYMENUREST, true);
|
||||
if (mDesc->mCaption.IsNotEmpty())
|
||||
{
|
||||
Menu_DrawTopBar(origin);
|
||||
Menu_DrawTopBarCaption(mDesc->mCaption, origin);
|
||||
}
|
||||
Super::PreDraw();
|
||||
}
|
||||
|
||||
void PostDraw() override
|
||||
|
@ -515,6 +511,13 @@ FSavegameInfo GameInterface::GetSaveSig()
|
|||
return { SAVESIG_DN3D, MINSAVEVER_DN3D, SAVEVER_DN3D };
|
||||
}
|
||||
|
||||
|
||||
void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
||||
{
|
||||
Menu_DrawTopBar(origin);
|
||||
Menu_DrawTopBarCaption(text, origin);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
|
|
@ -166,6 +166,7 @@ struct GameInterface : ::GameInterface
|
|||
FSavegameInfo GetSaveSig() override;
|
||||
bool DrawSpecialScreen(const DVector2 &origin, int tilenum) override;
|
||||
void DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position) override;
|
||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -320,15 +320,6 @@ protected:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreDraw() override
|
||||
{
|
||||
if (mDesc->mCaption.IsNotEmpty())
|
||||
{
|
||||
Menu_DrawTopBar(origin);
|
||||
Menu_DrawTopBarCaption(mDesc->mCaption, origin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class MainMenu : public RedneckListMenu
|
||||
|
@ -444,6 +435,12 @@ FSavegameInfo GameInterface::GetSaveSig()
|
|||
return { SAVESIG_RR, MINSAVEVER_RR, SAVEVER_RR };
|
||||
}
|
||||
|
||||
void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
||||
{
|
||||
Menu_DrawTopBar(origin);
|
||||
Menu_DrawTopBarCaption(text, origin);
|
||||
}
|
||||
|
||||
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position)
|
||||
{
|
||||
Menu_DrawBackground(origin);
|
||||
|
|
|
@ -166,6 +166,7 @@ struct GameInterface : ::GameInterface
|
|||
void StartGame(FGameStartup& gs) override;
|
||||
FSavegameInfo GetSaveSig() override;
|
||||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) override;
|
||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||
};
|
||||
|
||||
END_RR_NS
|
||||
|
|
|
@ -364,7 +364,7 @@ LISTMENU "MultiMenu"
|
|||
|
||||
ImageScroller "HelpMenu"
|
||||
{
|
||||
ifgame(Duke, Nam, WW2GI, Fury, Redneck, RedneckRides)
|
||||
ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides)
|
||||
{
|
||||
ImageItem "TEXTSTORY", 400
|
||||
ImageItem "F1HELP", 401
|
||||
|
@ -374,6 +374,11 @@ ImageScroller "HelpMenu"
|
|||
}
|
||||
animatedtransition
|
||||
}
|
||||
ifgame(fury)
|
||||
{
|
||||
ImageItem "TEXTSTORY", 400
|
||||
ImageItem "F1HELP", 401
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
@ -460,3 +465,29 @@ ImageScroller "CreditsMenu"
|
|||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Base definition for load game menu. Only the configurable part is done here
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
||||
ListMenu "LoadGameMenu"
|
||||
{
|
||||
Caption "$MNU_LOADGAME"
|
||||
Position 0, 40
|
||||
Class "LoadMenu" // uses its own implementation
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Base definition for save game menu. Only the configurable part is done here
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
||||
ListMenu "SaveGameMenu"
|
||||
{
|
||||
Caption "$MNU_SAVEGAME"
|
||||
Position 0, 40
|
||||
Class "SaveMenu" // uses its own implementation
|
||||
}
|
||||
|
Loading…
Reference in a new issue