mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 14:41:40 +00:00
This commit is contained in:
commit
bf9edec91a
11 changed files with 225 additions and 21 deletions
|
@ -790,7 +790,6 @@ static double mapystart=0; // y-value for the start of the map bitmap...used in
|
|||
static double mapxstart=0; //x-value for the bitmap.
|
||||
|
||||
static bool stopped = true;
|
||||
static int viewbottom;
|
||||
|
||||
static void AM_calcMinMaxMtoF();
|
||||
|
||||
|
@ -1063,7 +1062,7 @@ static void AM_findMinMaxBoundaries ()
|
|||
static void AM_calcMinMaxMtoF()
|
||||
{
|
||||
double a = SCREENWIDTH / max_w;
|
||||
double b = viewbottom / max_h;
|
||||
double b = StatusBar->GetTopOfStatusbar() / max_h;
|
||||
|
||||
min_scale_mtof = a < b ? a : b;
|
||||
max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS);
|
||||
|
@ -1421,7 +1420,7 @@ void AM_NewResolution()
|
|||
else if (scale_mtof > max_scale_mtof)
|
||||
AM_maxOutWindowScale();
|
||||
f_w = screen->GetWidth();
|
||||
f_h = viewbottom;
|
||||
f_h = StatusBar->GetTopOfStatusbar();
|
||||
AM_activateNewScale();
|
||||
}
|
||||
|
||||
|
@ -3169,7 +3168,6 @@ void AM_Drawer (int bottom)
|
|||
bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0;
|
||||
bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr;
|
||||
|
||||
viewbottom = bottom;
|
||||
if (am_portaloverlay)
|
||||
{
|
||||
sector_t *sec;
|
||||
|
@ -3186,7 +3184,7 @@ void AM_Drawer (int bottom)
|
|||
// and view size adjustments.
|
||||
f_x = f_y = 0;
|
||||
f_w = screen->GetWidth ();
|
||||
f_h = viewbottom;
|
||||
f_h = bottom;
|
||||
f_p = screen->GetPitch ();
|
||||
|
||||
AM_clearFB(AMColors[AMColors.Background]);
|
||||
|
|
|
@ -397,6 +397,7 @@ public:
|
|||
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY);
|
||||
void DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY);
|
||||
void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0);
|
||||
void SetClipRect(double x, double y, double w, double h, int flags = 0);
|
||||
|
||||
void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled);
|
||||
void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false);
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "gstrings.h"
|
||||
#include "cmdlib.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "virtual.h"
|
||||
|
||||
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
|
||||
enum
|
||||
|
@ -1545,10 +1546,16 @@ DBaseStatusBar *CreateCustomStatusBar(int scriptno)
|
|||
I_FatalError("Tried to create a status bar with no script!");
|
||||
|
||||
auto sbar = (DBaseStatusBar*)PClass::FindClass("SBarInfoWrapper")->CreateNew();
|
||||
IFVIRTUALPTR(sbar, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { sbar };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
auto core = new DSBarInfo(sbar, script);
|
||||
sbar->PointerVar<DSBarInfo>("core") = core;
|
||||
sbar->SetSize(script->height, script->_resW, script->_resH);
|
||||
sbar->CompleteBorder = script->completeBorder;
|
||||
|
||||
return sbar;
|
||||
}
|
||||
|
||||
|
|
|
@ -1910,7 +1910,82 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, Fill)
|
|||
PARAM_FLOAT(h);
|
||||
PARAM_INT_DEF(flags);
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
self->Fill(color, x, y, w, h);
|
||||
self->Fill(color, x, y, w, h, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// draw stuff
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void DBaseStatusBar::SetClipRect(double x, double y, double w, double h, int flags)
|
||||
{
|
||||
// resolve auto-alignment before making any adjustments to the position values.
|
||||
if (!(flags & DI_SCREEN_MANUAL_ALIGN))
|
||||
{
|
||||
if (x < 0) flags |= DI_SCREEN_RIGHT;
|
||||
else flags |= DI_SCREEN_LEFT;
|
||||
if (y < 0) flags |= DI_SCREEN_BOTTOM;
|
||||
else flags |= DI_SCREEN_TOP;
|
||||
}
|
||||
|
||||
x += drawOffset.X;
|
||||
y += drawOffset.Y;
|
||||
|
||||
if (!fullscreenOffsets)
|
||||
{
|
||||
StatusbarToRealCoords(x, y, w, h);
|
||||
}
|
||||
else
|
||||
{
|
||||
double orgx, orgy;
|
||||
|
||||
switch (flags & DI_SCREEN_HMASK)
|
||||
{
|
||||
default: orgx = 0; break;
|
||||
case DI_SCREEN_HCENTER: orgx = screen->GetWidth() / 2; break;
|
||||
case DI_SCREEN_RIGHT: orgx = screen->GetWidth(); break;
|
||||
}
|
||||
|
||||
switch (flags & DI_SCREEN_VMASK)
|
||||
{
|
||||
default: orgy = 0; break;
|
||||
case DI_SCREEN_VCENTER: orgy = screen->GetHeight() / 2; break;
|
||||
case DI_SCREEN_BOTTOM: orgy = screen->GetHeight(); break;
|
||||
}
|
||||
|
||||
// move stuff in the top right corner a bit down if the fps counter is on.
|
||||
if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10;
|
||||
|
||||
DVector2 Scale = GetHUDScale();
|
||||
|
||||
x *= Scale.X;
|
||||
y *= Scale.Y;
|
||||
w *= Scale.X;
|
||||
h *= Scale.Y;
|
||||
x += orgx;
|
||||
y += orgy;
|
||||
}
|
||||
int x1 = int(x);
|
||||
int y1 = int(y);
|
||||
int ww = int(x + w - x1); // account for scaling to non-integers. Truncating the values separately would fail for cases like
|
||||
int hh = int(y + h - y1); // y=3.5, height = 5.5 where adding both values gives a larger integer than adding the two integers.
|
||||
|
||||
screen->SetClipRect(x1, y1, ww, hh);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetClipRect)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(w);
|
||||
PARAM_FLOAT(h);
|
||||
PARAM_INT_DEF(flags);
|
||||
self->SetClipRect(x, y, w, h, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -376,6 +376,8 @@ void FGameConfigFile::DoGlobalSetup ()
|
|||
if (var != NULL) var->ResetToDefault();
|
||||
var = FindCVar("con_scaletext", NULL);
|
||||
if (var != NULL) var->ResetToDefault();
|
||||
var = FindCVar("uiscale", NULL);
|
||||
if (var != NULL) var->ResetToDefault();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "textures.h"
|
||||
|
||||
CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
||||
CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self < 0)
|
||||
{
|
||||
|
@ -82,9 +82,9 @@ int GetUIScale(int altval)
|
|||
if (altval > 0) scaleval = altval;
|
||||
else if (uiscale == 0)
|
||||
{
|
||||
// Default should try to scale to 640x480
|
||||
int vscale = screen->GetHeight() / 640;
|
||||
int hscale = screen->GetWidth() / 480;
|
||||
// Default should try to scale to 640x400
|
||||
int vscale = screen->GetHeight() / 400;
|
||||
int hscale = screen->GetWidth() / 640;
|
||||
scaleval = clamp(vscale, 1, hscale);
|
||||
}
|
||||
else scaleval = uiscale;
|
||||
|
@ -187,7 +187,25 @@ void DCanvas::SetClipRect(int x, int y, int w, int h)
|
|||
clipleft = clamp(x, 0, GetWidth());
|
||||
clipwidth = clamp(w, 0, GetWidth() - x);
|
||||
cliptop = clamp(y, 0, GetHeight());
|
||||
clipwidth = clamp(w, 0, GetHeight() - y);
|
||||
clipheight = clamp(h, 0, GetHeight() - y);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, SetClipRect)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(x);
|
||||
PARAM_INT(y);
|
||||
PARAM_INT(w);
|
||||
PARAM_INT(h);
|
||||
screen->SetClipRect(x, y, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, ClearClipRect)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
screen->ClearClipRect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DCanvas::GetClipRect(int *x, int *y, int *w, int *h)
|
||||
|
@ -198,6 +216,19 @@ void DCanvas::GetClipRect(int *x, int *y, int *w, int *h)
|
|||
if (h) *h = clipheight;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, GetClipRect)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
int x, y, w, h;
|
||||
screen->GetClipRect(&x, &y, &w, &h);
|
||||
if (numret > 0) ret[0].SetInt(x);
|
||||
if (numret > 1) ret[1].SetInt(y);
|
||||
if (numret > 2) ret[2].SetInt(w);
|
||||
if (numret > 3) ret[3].SetInt(h);
|
||||
return MIN(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
bool DCanvas::SetTextureParms(DrawParms *parms, FTexture *img, double xx, double yy) const
|
||||
{
|
||||
if (img != NULL)
|
||||
|
|
|
@ -1853,6 +1853,7 @@ HUDMNU_HEXENFLASHES = "Hexen weapon flashes";
|
|||
HUDMNU_POISONFLASHES = "Poison damage flashes";
|
||||
HUDMNU_ICEFLASHES = "Ice death flashes";
|
||||
HUDMNU_HAZARDFLASHES = "Poison Buildup flashes";
|
||||
HUDMNU_SCALEOPT = "Scaling Options";
|
||||
|
||||
// Scaling options
|
||||
SCALEMNU_TITLE = "Scaling Options";
|
||||
|
@ -1863,6 +1864,9 @@ SCALEMNU_STATBAR = "Status bar";
|
|||
SCALEMNU_HUD = "Fullscreen HUD";
|
||||
SCALEMNU_ALTHUD = "Alternative HUD";
|
||||
SCALEMNU_HUDASPECT = "HUD preserves aspect ratio";
|
||||
SCALEMNU_USEUI = "Use default scale";
|
||||
SCALEMNU_USEFS = "Scale to fullscreen";
|
||||
SCALEMNU_ADAPT = "Adapt to screen size";
|
||||
|
||||
// AltHUD Options
|
||||
ALTHUDMNU_TITLE = "Alternative HUD";
|
||||
|
|
|
@ -852,15 +852,15 @@ OptionMenu "HUDOptions"
|
|||
OptionMenu "ScalingOptions"
|
||||
{
|
||||
Title "$SCALEMNU_TITLE"
|
||||
Slider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, 0
|
||||
ScaleSlider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, "$SCALEMNU_ADAPT"
|
||||
StaticText " "
|
||||
// These will need a new control type.
|
||||
StaticText "$SCALEMNU_OVERRIDE", 1
|
||||
Option "$SCALEMNU_MESSAGES", "con_scaletext", "OnOff"
|
||||
Option "$SCALEMNU_CONSOLE", "con_scale", "OnOff"
|
||||
Option "$SCALEMNU_STATBAR", "st_scale", "OnOff"
|
||||
Option "$SCALEMNU_HUD", "hud_scale", "OnOff"
|
||||
Option "$SCALEMNU_ALTHUD", "hud_althudscale", "OnOff"
|
||||
ScaleSlider "$SCALEMNU_MESSAGES", "con_scaletext", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||
ScaleSlider "$SCALEMNU_CONSOLE", "con_scale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||
ScaleSlider "$SCALEMNU_STATBAR", "st_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS"
|
||||
ScaleSlider "$SCALEMNU_HUD", "hud_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS"
|
||||
ScaleSlider "$SCALEMNU_ALTHUD", "hud_althudscale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||
StaticText " "
|
||||
Option "$SCALEMNU_HUDASPECT", "hud_aspectscale", "OnOff"
|
||||
}
|
||||
|
|
|
@ -166,6 +166,10 @@ struct Screen native
|
|||
native static void DrawFrame(int x, int y, int w, int h);
|
||||
native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true);
|
||||
native static double GetAspectRatio();
|
||||
native static void SetClipRect(int x, int y, int w, int h);
|
||||
native static void ClearClipRect();
|
||||
native static int, int, int, int GetClipRect();
|
||||
|
||||
|
||||
// This is a leftover of the abandoned Inventory.DrawPowerup method.
|
||||
deprecated("2.5") static ui void DrawHUDTexture(TextureID tex, double x, double y)
|
||||
|
|
|
@ -666,7 +666,7 @@ class OptionMenuSliderBase : OptionMenuItem
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
private void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent)
|
||||
protected void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent)
|
||||
{
|
||||
String formater = String.format("%%.%df", fracdigits); // The format function cannot do the '%.*f' syntax.
|
||||
String textbuf;
|
||||
|
@ -1211,3 +1211,74 @@ class OptionMenuItemNumberField : OptionMenuFieldBase
|
|||
float mStep;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// A special slider that displays plain text for special settings related
|
||||
// to scaling.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class OptionMenuItemScaleSlider : OptionMenuItemSlider
|
||||
{
|
||||
String TextZero;
|
||||
String TextNegOne;
|
||||
int mClickVal;
|
||||
|
||||
OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "")
|
||||
{
|
||||
Super.Init(label, command, min, max, step, 0);
|
||||
mCVar =CVar.FindCVar(command);
|
||||
TextZero = zero;
|
||||
TextNEgOne = negone;
|
||||
mClickVal = -10;
|
||||
return self;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
|
||||
{
|
||||
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
|
||||
|
||||
int Selection = GetSliderValue();
|
||||
if ((Selection == 0 || Selection == -1) && mClickVal <= 0)
|
||||
{
|
||||
String text = Selection == 0? TextZero : Selection == -1? TextNegOne : "";
|
||||
screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDrawX = indent + CursorSpace();
|
||||
DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent);
|
||||
}
|
||||
return indent;
|
||||
}
|
||||
|
||||
override bool MouseEvent(int type, int x, int y)
|
||||
{
|
||||
int value = GetSliderValue();
|
||||
switch (type)
|
||||
{
|
||||
case Menu.MOUSE_Click:
|
||||
mClickVal = value;
|
||||
if (value <= 0) return false;
|
||||
return Super.MouseEvent(type, x, y);
|
||||
|
||||
case Menu.MOUSE_Move:
|
||||
if (mClickVal <= 0) return false;
|
||||
return Super.MouseEvent(type, x, y);
|
||||
|
||||
case Menu.MOUSE_Release:
|
||||
if (mClickVal <= 0)
|
||||
{
|
||||
mClickVal = -10;
|
||||
SetSliderValue(value + 1);
|
||||
return true;
|
||||
}
|
||||
mClickVal = -10;
|
||||
return Super.MouseEvent(type, x, y);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -327,6 +327,12 @@ class BaseStatusBar native ui
|
|||
native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = "");
|
||||
native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0);
|
||||
native int GetTopOfStatusBar();
|
||||
native void SetClipRect(double x, double y, double w, double h, int flags = 0);
|
||||
|
||||
void ClearClipRect()
|
||||
{
|
||||
screen.ClearClipRect();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
|
@ -984,13 +990,17 @@ class BaseStatusBar native ui
|
|||
double sizeOfImage = (horizontal ? texsize.X - border*2 : texsize.Y - border*2);
|
||||
Clip[(!horizontal) | ((!reverse)<<1)] = sizeOfImage - sizeOfImage *value;
|
||||
|
||||
// preserve the active clipping rectangle
|
||||
int cx, cy, cw, ch;
|
||||
[cx, cy, cw, ch] = screen.GetClipRect();
|
||||
|
||||
if(border != 0)
|
||||
{
|
||||
for(int i = 0; i < 4; i++) Clip[i] += border;
|
||||
|
||||
//Draw the whole foreground
|
||||
DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP);
|
||||
// SetClip
|
||||
SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags);
|
||||
}
|
||||
|
||||
if (offtex.IsValid() && TexMan.GetScaledSize(offtex) == texsize) DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP);
|
||||
|
@ -998,10 +1008,11 @@ class BaseStatusBar native ui
|
|||
|
||||
if (border == 0)
|
||||
{
|
||||
// SetClip
|
||||
SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags);
|
||||
DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP);
|
||||
}
|
||||
// UnsetClip
|
||||
// restore the previous clipping rectangle
|
||||
screen.SetClipRect(cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
Loading…
Reference in a new issue