mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (designheight < 240 && realheight >= 480) designheight = 240;
|
||||
|
|
|
@ -285,8 +285,8 @@ ListMenu "LoadGameMenu"
|
|||
{
|
||||
NetgameMessage "$CLOADNET"
|
||||
}
|
||||
StaticTextCentered 160, -10, "$MNU_LOADGAME"
|
||||
Position 80,54
|
||||
CaptionItem "$MNU_LOADGAME"
|
||||
Position 80,40
|
||||
Class "LoadMenu" // uses its own implementation
|
||||
Size Clean
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ ListMenu "LoadGameMenu"
|
|||
|
||||
ListMenu "SaveGameMenu"
|
||||
{
|
||||
StaticTextCentered 160, -10, "$MNU_SAVEGAME"
|
||||
Position 80,54
|
||||
CaptionItem "$MNU_SAVEGAME"
|
||||
Position 80,40
|
||||
Class "SaveMenu" // uses its own implementation
|
||||
Size Clean
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ struct TexMan
|
|||
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 int, int GetSize(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 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 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 Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true);
|
||||
native static double GetAspectRatio();
|
||||
|
@ -482,6 +483,7 @@ struct Font native
|
|||
native static Font FindFont(Name fontname);
|
||||
native static Font GetFont(Name fontname);
|
||||
native BrokenLines BreakLines(String text, int maxlen);
|
||||
native int GetGlyphHeight(int code);
|
||||
}
|
||||
|
||||
struct Console native
|
||||
|
|
|
@ -172,7 +172,7 @@ class ListMenu : Menu
|
|||
case MKEY_Enter:
|
||||
if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate())
|
||||
{
|
||||
MenuSound("menu/choose");
|
||||
MenuSound("menu/advance");
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -265,10 +265,13 @@ class ListMenu : Menu
|
|||
{
|
||||
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())
|
||||
mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc);
|
||||
{
|
||||
if (!menuDelegate.DrawSelector(mDesc))
|
||||
mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc);
|
||||
}
|
||||
Super.Drawer();
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ class ListMenuItemSelectable : ListMenuItem
|
|||
|
||||
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()
|
||||
|
@ -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 listboxHeight;
|
||||
int listboxRight;
|
||||
int listboxBottom;
|
||||
|
||||
int commentLeft;
|
||||
int commentTop;
|
||||
int commentWidth;
|
||||
int commentHeight;
|
||||
int commentRight;
|
||||
int commentBottom;
|
||||
int commentRows;
|
||||
|
||||
bool mEntering;
|
||||
|
@ -118,33 +115,34 @@ class LoadSaveMenu : ListMenu
|
|||
override void Init(Menu parent, ListMenuDescriptor desc)
|
||||
{
|
||||
Super.Init(parent, desc);
|
||||
bool aspect43 = true;
|
||||
int Width43 = screen.GetHeight() * 4 / 3;
|
||||
int Left43 = (screen.GetWidth() - Width43) / 2;
|
||||
|
||||
manager = SavegameManager.GetManager();
|
||||
manager.ReadSaveStrings();
|
||||
double wScale = Width43 / 640.;
|
||||
|
||||
savepicLeft = 10;
|
||||
savepicTop = 54*CleanYfac;
|
||||
savepicWidth = 216*screen.GetWidth() / 640;
|
||||
savepicHeight = 135*screen.GetHeight() / 400;
|
||||
savepicLeft = Left43 + int(20 * wScale);
|
||||
savepicTop = mDesc.mYpos * screen.GetHeight() / 200 ;
|
||||
savepicWidth = int(240 * wScale);
|
||||
savepicHeight = int(180 * wScale);
|
||||
|
||||
FontScale = max(screen.GetHeight() / 480, 1);
|
||||
rowHeight = int(max((NewConsoleFont.GetHeight() + 1) * FontScale, 1));
|
||||
|
||||
listboxLeft = savepicLeft + savepicWidth + 14;
|
||||
listboxLeft = savepicLeft + savepicWidth + int(20*wScale);
|
||||
listboxTop = savepicTop;
|
||||
listboxWidth = screen.GetWidth() - listboxLeft - 10;
|
||||
int listboxHeight1 = screen.GetHeight() - listboxTop - 10;
|
||||
listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale);
|
||||
int listboxHeight1 = screen.GetHeight() - listboxTop - int(20*wScale);
|
||||
listboxRows = (listboxHeight1 - 1) / rowHeight;
|
||||
listboxHeight = listboxRows * rowHeight + 1;
|
||||
listboxRight = listboxLeft + listboxWidth;
|
||||
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;
|
||||
commentHeight = listboxHeight - savepicHeight - 16;
|
||||
commentRight = commentLeft + commentWidth;
|
||||
commentBottom = commentTop + commentHeight;
|
||||
commentHeight = listboxHeight - savepicHeight - int(16 * wScale);
|
||||
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 ()
|
||||
{
|
||||
Super.Drawer();
|
||||
|
@ -182,24 +186,25 @@ class LoadSaveMenu : ListMenu
|
|||
return;
|
||||
}
|
||||
|
||||
Screen.DrawFrame (savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
||||
DrawFrame(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 (Selected >= manager.SavegameCount()) Selected = 0;
|
||||
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,
|
||||
savepicTop+(savepicHeight-rowHeight)/2, text, DTA_CleanNoMove, true);
|
||||
screen.DrawText (NewSmallFont, Font.CR_GOLD, (savepicLeft+(savepicWidth-textlen)/2) / FontScale,
|
||||
(savepicTop+(savepicHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw comment area
|
||||
Screen.DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
||||
screen.Clear (commentLeft, commentTop, commentRight, commentBottom, 0, 0);
|
||||
DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
||||
screen.Dim(0, 0.6, commentLeft, commentTop, commentWidth, commentHeight);
|
||||
|
||||
int numlinestoprint = min(commentRows, BrokenSaveComment? BrokenSaveComment.Count() : 0);
|
||||
for(int i = 0; i < numlinestoprint; i++)
|
||||
|
@ -210,8 +215,8 @@ class LoadSaveMenu : ListMenu
|
|||
|
||||
|
||||
// Draw file area
|
||||
Screen.DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||
screen.Clear (listboxLeft, listboxTop, listboxRight, listboxBottom, 0, 0);
|
||||
DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||
screen.Dim(0, 0.6, listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||
|
||||
if (manager.SavegameCount() == 0)
|
||||
{
|
||||
|
|
|
@ -129,10 +129,14 @@ class Menu : Object native ui version("2.4")
|
|||
switch (mkey)
|
||||
{
|
||||
case MKEY_Back:
|
||||
{
|
||||
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 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)
|
||||
|
|
|
@ -5,6 +5,21 @@ class MenuDelegateBase
|
|||
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);
|
||||
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);
|
||||
}
|
||||
mDesc.mDrawTop = y;
|
||||
mDesc.mDrawTop = y / CleanYfac_1; // mouse checks are done in clean space.
|
||||
int fontheight = OptionMenuSettings.mLinespacing * CleanYfac_1;
|
||||
y *= CleanYfac_1;
|
||||
|
||||
int indent = GetIndent();
|
||||
|
||||
|
|
Loading…
Reference in a new issue