mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 15:22:08 +00:00
- use Raze's layout for load and save game menus.
This has a lot less black void on screen.
This commit is contained in:
parent
b8281f4758
commit
62138decfe
9 changed files with 109 additions and 40 deletions
|
@ -1529,6 +1529,19 @@ void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, in
|
||||||
twod->AddColorOnlyQuad(right, top - offset, offset, height + 2 * offset, color);
|
twod->AddColorOnlyQuad(right, top - offset, offset, height + 2 * offset, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_COLOR(color);
|
||||||
|
PARAM_INT(left);
|
||||||
|
PARAM_INT(top);
|
||||||
|
PARAM_INT(width);
|
||||||
|
PARAM_INT(height);
|
||||||
|
PARAM_INT(thickness);
|
||||||
|
DrawFrame(twod, color, left, top, width, height, thickness);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2)
|
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2)
|
||||||
{
|
{
|
||||||
if (designheight < 240 && realheight >= 480) designheight = 240;
|
if (designheight < 240 && realheight >= 480) designheight = 240;
|
||||||
|
|
|
@ -285,8 +285,8 @@ ListMenu "LoadGameMenu"
|
||||||
{
|
{
|
||||||
NetgameMessage "$CLOADNET"
|
NetgameMessage "$CLOADNET"
|
||||||
}
|
}
|
||||||
StaticTextCentered 160, -10, "$MNU_LOADGAME"
|
CaptionItem "$MNU_LOADGAME"
|
||||||
Position 80,54
|
Position 80,40
|
||||||
Class "LoadMenu" // uses its own implementation
|
Class "LoadMenu" // uses its own implementation
|
||||||
Size Clean
|
Size Clean
|
||||||
}
|
}
|
||||||
|
@ -299,8 +299,8 @@ ListMenu "LoadGameMenu"
|
||||||
|
|
||||||
ListMenu "SaveGameMenu"
|
ListMenu "SaveGameMenu"
|
||||||
{
|
{
|
||||||
StaticTextCentered 160, -10, "$MNU_SAVEGAME"
|
CaptionItem "$MNU_SAVEGAME"
|
||||||
Position 80,54
|
Position 80,40
|
||||||
Class "SaveMenu" // uses its own implementation
|
Class "SaveMenu" // uses its own implementation
|
||||||
Size Clean
|
Size Clean
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ struct TexMan
|
||||||
NOT_FLAT = 24
|
NOT_FLAT = 24
|
||||||
};
|
};
|
||||||
|
|
||||||
native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny);
|
native static TextureID CheckForTexture(String name, int usetype = Type_Any, int flags = TryAny);
|
||||||
native static String GetName(TextureID tex);
|
native static String GetName(TextureID tex);
|
||||||
native static int, int GetSize(TextureID tex);
|
native static int, int GetSize(TextureID tex);
|
||||||
native static Vector2 GetScaledSize(TextureID tex);
|
native static Vector2 GetScaledSize(TextureID tex);
|
||||||
|
@ -389,6 +389,7 @@ struct Screen native
|
||||||
native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...);
|
native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...);
|
||||||
native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...);
|
native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...);
|
||||||
native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255);
|
native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255);
|
||||||
|
native static void DrawLineFrame(Color color, int x0, int y0, int w, int h, int thickness = 1);
|
||||||
native static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255);
|
native static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255);
|
||||||
native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true);
|
native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true);
|
||||||
native static double GetAspectRatio();
|
native static double GetAspectRatio();
|
||||||
|
@ -482,6 +483,7 @@ struct Font native
|
||||||
native static Font FindFont(Name fontname);
|
native static Font FindFont(Name fontname);
|
||||||
native static Font GetFont(Name fontname);
|
native static Font GetFont(Name fontname);
|
||||||
native BrokenLines BreakLines(String text, int maxlen);
|
native BrokenLines BreakLines(String text, int maxlen);
|
||||||
|
native int GetGlyphHeight(int code);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Console native
|
struct Console native
|
||||||
|
|
|
@ -172,7 +172,7 @@ class ListMenu : Menu
|
||||||
case MKEY_Enter:
|
case MKEY_Enter:
|
||||||
if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate())
|
if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate())
|
||||||
{
|
{
|
||||||
MenuSound("menu/choose");
|
MenuSound("menu/advance");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -265,10 +265,13 @@ class ListMenu : Menu
|
||||||
{
|
{
|
||||||
for(int i=0;i<mDesc.mItems.Size(); i++)
|
for(int i=0;i<mDesc.mItems.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mDesc.mItems[i].mEnabled > 0) mDesc.mItems[i].Draw(mDesc.mSelectedItem == i, mDesc);
|
if (mDesc.mItems[i].mEnabled) mDesc.mItems[i].Draw(mDesc.mSelectedItem == i, mDesc);
|
||||||
}
|
}
|
||||||
if (mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mDesc.mItems.Size())
|
if (mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mDesc.mItems.Size())
|
||||||
|
{
|
||||||
|
if (!menuDelegate.DrawSelector(mDesc))
|
||||||
mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc);
|
mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc);
|
||||||
|
}
|
||||||
Super.Drawer();
|
Super.Drawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ class ListMenuItemSelectable : ListMenuItem
|
||||||
|
|
||||||
override bool CheckCoordinate(int x, int y)
|
override bool CheckCoordinate(int x, int y)
|
||||||
{
|
{
|
||||||
return mEnabled && y >= mYpos && y < mYpos + mHeight; // no x check here
|
return mEnabled > 0 && y >= mYpos && y < mYpos + mHeight; // no x check here
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool Selectable()
|
override bool Selectable()
|
||||||
|
@ -340,3 +340,31 @@ class ListMenuItemPatchItem : ListMenuItemSelectable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// caption - draws a text using the customizer's caption hook
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
class ListMenuItemCaptionItem : ListMenuItem
|
||||||
|
{
|
||||||
|
String mText;
|
||||||
|
Font mFont;
|
||||||
|
|
||||||
|
void Init(ListMenuDescriptor desc, String text, String fnt = "BigFont")
|
||||||
|
{
|
||||||
|
Super.Init(0, 0);
|
||||||
|
mText = text;
|
||||||
|
mFont = Font.FindFont(fnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
||||||
|
{
|
||||||
|
let font = generic_ui || !desc.mFont ? NewSmallFont : desc.mFont;
|
||||||
|
if (font && mText.Length() > 0)
|
||||||
|
{
|
||||||
|
menuDelegate.DrawCaption(mText, font, 0, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,14 +91,11 @@ class LoadSaveMenu : ListMenu
|
||||||
int listboxRows;
|
int listboxRows;
|
||||||
int listboxHeight;
|
int listboxHeight;
|
||||||
int listboxRight;
|
int listboxRight;
|
||||||
int listboxBottom;
|
|
||||||
|
|
||||||
int commentLeft;
|
int commentLeft;
|
||||||
int commentTop;
|
int commentTop;
|
||||||
int commentWidth;
|
int commentWidth;
|
||||||
int commentHeight;
|
int commentHeight;
|
||||||
int commentRight;
|
|
||||||
int commentBottom;
|
|
||||||
int commentRows;
|
int commentRows;
|
||||||
|
|
||||||
bool mEntering;
|
bool mEntering;
|
||||||
|
@ -118,33 +115,34 @@ class LoadSaveMenu : ListMenu
|
||||||
override void Init(Menu parent, ListMenuDescriptor desc)
|
override void Init(Menu parent, ListMenuDescriptor desc)
|
||||||
{
|
{
|
||||||
Super.Init(parent, desc);
|
Super.Init(parent, desc);
|
||||||
|
bool aspect43 = true;
|
||||||
|
int Width43 = screen.GetHeight() * 4 / 3;
|
||||||
|
int Left43 = (screen.GetWidth() - Width43) / 2;
|
||||||
|
|
||||||
manager = SavegameManager.GetManager();
|
manager = SavegameManager.GetManager();
|
||||||
manager.ReadSaveStrings();
|
manager.ReadSaveStrings();
|
||||||
|
double wScale = Width43 / 640.;
|
||||||
|
|
||||||
savepicLeft = 10;
|
savepicLeft = Left43 + int(20 * wScale);
|
||||||
savepicTop = 54*CleanYfac;
|
savepicTop = mDesc.mYpos * screen.GetHeight() / 200 ;
|
||||||
savepicWidth = 216*screen.GetWidth() / 640;
|
savepicWidth = int(240 * wScale);
|
||||||
savepicHeight = 135*screen.GetHeight() / 400;
|
savepicHeight = int(180 * wScale);
|
||||||
|
|
||||||
FontScale = max(screen.GetHeight() / 480, 1);
|
FontScale = max(screen.GetHeight() / 480, 1);
|
||||||
rowHeight = int(max((NewConsoleFont.GetHeight() + 1) * FontScale, 1));
|
rowHeight = int(max((NewConsoleFont.GetHeight() + 1) * FontScale, 1));
|
||||||
|
|
||||||
listboxLeft = savepicLeft + savepicWidth + 14;
|
listboxLeft = savepicLeft + savepicWidth + int(20*wScale);
|
||||||
listboxTop = savepicTop;
|
listboxTop = savepicTop;
|
||||||
listboxWidth = screen.GetWidth() - listboxLeft - 10;
|
listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale);
|
||||||
int listboxHeight1 = screen.GetHeight() - listboxTop - 10;
|
int listboxHeight1 = screen.GetHeight() - listboxTop - int(20*wScale);
|
||||||
listboxRows = (listboxHeight1 - 1) / rowHeight;
|
listboxRows = (listboxHeight1 - 1) / rowHeight;
|
||||||
listboxHeight = listboxRows * rowHeight + 1;
|
listboxHeight = listboxRows * rowHeight + 1;
|
||||||
listboxRight = listboxLeft + listboxWidth;
|
listboxRight = listboxLeft + listboxWidth;
|
||||||
listboxBottom = listboxTop + listboxHeight;
|
|
||||||
|
|
||||||
commentLeft = savepicLeft;
|
commentLeft = savepicLeft;
|
||||||
commentTop = savepicTop + savepicHeight + 16;
|
commentTop = savepicTop + savepicHeight + int(16 * wScale);
|
||||||
commentWidth = savepicWidth;
|
commentWidth = savepicWidth;
|
||||||
//commentHeight = (51+(screen.GetHeight()>200?10:0))*CleanYfac;
|
commentHeight = listboxHeight - savepicHeight - int(16 * wScale);
|
||||||
commentHeight = listboxHeight - savepicHeight - 16;
|
|
||||||
commentRight = commentLeft + commentWidth;
|
|
||||||
commentBottom = commentTop + commentHeight;
|
|
||||||
commentRows = commentHeight / rowHeight;
|
commentRows = commentHeight / rowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +165,12 @@ class LoadSaveMenu : ListMenu
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
virtual void DrawFrame(int left, int top, int width, int height)
|
||||||
|
{
|
||||||
|
let framecolor = Color(255, 80, 80, 80);
|
||||||
|
Screen.DrawLineFrame(framecolor, left, top, width, height, screen.GetHeight() / 240);
|
||||||
|
}
|
||||||
|
|
||||||
override void Drawer ()
|
override void Drawer ()
|
||||||
{
|
{
|
||||||
Super.Drawer();
|
Super.Drawer();
|
||||||
|
@ -182,24 +186,25 @@ class LoadSaveMenu : ListMenu
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen.DrawFrame (savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
DrawFrame(savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
||||||
if (!manager.DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight))
|
if (!manager.DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight))
|
||||||
{
|
{
|
||||||
screen.Clear (savepicLeft, savepicTop, savepicLeft+savepicWidth, savepicTop+savepicHeight, 0, 0);
|
screen.Dim(0, 0.6, savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
||||||
|
|
||||||
if (manager.SavegameCount() > 0)
|
if (manager.SavegameCount() > 0)
|
||||||
{
|
{
|
||||||
|
if (Selected >= manager.SavegameCount()) Selected = 0;
|
||||||
String text = (Selected == -1 || !manager.GetSavegame(Selected).bOldVersion)? Stringtable.Localize("$MNU_NOPICTURE") : Stringtable.Localize("$MNU_DIFFVERSION");
|
String text = (Selected == -1 || !manager.GetSavegame(Selected).bOldVersion)? Stringtable.Localize("$MNU_NOPICTURE") : Stringtable.Localize("$MNU_DIFFVERSION");
|
||||||
int textlen = NewSmallFont.StringWidth(text) * CleanXfac;
|
int textlen = NewSmallFont.StringWidth(text);
|
||||||
|
|
||||||
screen.DrawText (NewSmallFont, Font.CR_GOLD, savepicLeft+(savepicWidth-textlen)/2,
|
screen.DrawText (NewSmallFont, Font.CR_GOLD, (savepicLeft+(savepicWidth-textlen)/2) / FontScale,
|
||||||
savepicTop+(savepicHeight-rowHeight)/2, text, DTA_CleanNoMove, true);
|
(savepicTop+(savepicHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw comment area
|
// Draw comment area
|
||||||
Screen.DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
||||||
screen.Clear (commentLeft, commentTop, commentRight, commentBottom, 0, 0);
|
screen.Dim(0, 0.6, commentLeft, commentTop, commentWidth, commentHeight);
|
||||||
|
|
||||||
int numlinestoprint = min(commentRows, BrokenSaveComment? BrokenSaveComment.Count() : 0);
|
int numlinestoprint = min(commentRows, BrokenSaveComment? BrokenSaveComment.Count() : 0);
|
||||||
for(int i = 0; i < numlinestoprint; i++)
|
for(int i = 0; i < numlinestoprint; i++)
|
||||||
|
@ -210,8 +215,8 @@ class LoadSaveMenu : ListMenu
|
||||||
|
|
||||||
|
|
||||||
// Draw file area
|
// Draw file area
|
||||||
Screen.DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||||
screen.Clear (listboxLeft, listboxTop, listboxRight, listboxBottom, 0, 0);
|
screen.Dim(0, 0.6, listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||||
|
|
||||||
if (manager.SavegameCount() == 0)
|
if (manager.SavegameCount() == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,10 +129,14 @@ class Menu : Object native ui version("2.4")
|
||||||
switch (mkey)
|
switch (mkey)
|
||||||
{
|
{
|
||||||
case MKEY_Back:
|
case MKEY_Back:
|
||||||
|
{
|
||||||
Close();
|
Close();
|
||||||
MenuSound (GetCurrentMenu() != null? "menu/backup" : "menu/clear");
|
let m = GetCurrentMenu();
|
||||||
|
MenuSound(m != null ? "menu/backup" : "menu/clear");
|
||||||
|
if (!m) menuDelegate.MenuDismissed();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,9 +287,9 @@ class Menu : Object native ui version("2.4")
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
static void MenuSound(Sound snd)
|
static void MenuSound(Name snd)
|
||||||
{
|
{
|
||||||
S_StartSound (snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHAN_UI, snd_menuvolume, ATTN_NONE);
|
menuDelegate.PlaySound(snd);
|
||||||
}
|
}
|
||||||
|
|
||||||
deprecated("4.0") static void DrawConText (int color, int x, int y, String str)
|
deprecated("4.0") static void DrawConText (int color, int x, int y, String str)
|
||||||
|
|
|
@ -5,6 +5,21 @@ class MenuDelegateBase
|
||||||
virtual int DrawCaption(String title, Font fnt, int y, bool drawit)
|
virtual int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||||
{
|
{
|
||||||
screen.DrawText(fnt, OptionMenuSettings.mTitleColor, (screen.GetWidth() - fnt.StringWidth(title) * CleanXfac_1) / 2, 10 * CleanYfac_1, title, DTA_CleanNoMove_1, true);
|
screen.DrawText(fnt, OptionMenuSettings.mTitleColor, (screen.GetWidth() - fnt.StringWidth(title) * CleanXfac_1) / 2, 10 * CleanYfac_1, title, DTA_CleanNoMove_1, true);
|
||||||
return y + fnt.GetHeight();
|
return (y + fnt.GetHeight()) * CleanYfac_1; // return is spacing in screen pixels.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void PlaySound(Name sound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool DrawSelector(ListMenuDescriptor desc)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void MenuDismissed()
|
||||||
|
{
|
||||||
|
// overriding this allows to execute special actions when the menu closes
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,9 +456,8 @@ class OptionMenu : Menu
|
||||||
{
|
{
|
||||||
y = DrawCaption(mDesc.mTitle, -y, true);
|
y = DrawCaption(mDesc.mTitle, -y, true);
|
||||||
}
|
}
|
||||||
mDesc.mDrawTop = y;
|
mDesc.mDrawTop = y / CleanYfac_1; // mouse checks are done in clean space.
|
||||||
int fontheight = OptionMenuSettings.mLinespacing * CleanYfac_1;
|
int fontheight = OptionMenuSettings.mLinespacing * CleanYfac_1;
|
||||||
y *= CleanYfac_1;
|
|
||||||
|
|
||||||
int indent = GetIndent();
|
int indent = GetIndent();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue