- Backend update from Raze

Mostly cleanup and better separation of game/backend concerns.
This commit is contained in:
Christoph Oelckers 2022-06-06 12:09:29 +02:00
parent b7f3cc157d
commit c62e14d2c1
30 changed files with 200 additions and 196 deletions

View file

@ -55,9 +55,6 @@ struct FLatchedValue
static TArray<FLatchedValue> LatchedValues; static TArray<FLatchedValue> LatchedValues;
bool FBaseCVar::m_DoNoSet = false;
bool FBaseCVar::m_UseCallback = false;
FBaseCVar *CVars = NULL; FBaseCVar *CVars = NULL;
int cvar_defflags; int cvar_defflags;

View file

@ -216,8 +216,8 @@ private:
void (*m_Callback)(FBaseCVar &); void (*m_Callback)(FBaseCVar &);
FBaseCVar *m_Next; FBaseCVar *m_Next;
static bool m_UseCallback; static inline bool m_UseCallback = false;
static bool m_DoNoSet; static inline bool m_DoNoSet = false;
void *m_ExtraDataPointer; void *m_ExtraDataPointer;

View file

@ -255,7 +255,6 @@ public:
failed = true; failed = true;
} }
// The decoder needs a buffer with even height
Pic.Resize(width * height * 4); Pic.Resize(width * height * 4);

View file

@ -1,6 +1,8 @@
#include "i_interface.h" #include "i_interface.h"
#include "st_start.h"
// Some global engine variables taken out of the backend code. // Some global engine variables taken out of the backend code.
FStartupScreen* StartWindow;
SystemCallbacks sysCallbacks; SystemCallbacks sysCallbacks;
FString endoomName; FString endoomName;
bool batchrun; bool batchrun;

View file

@ -1698,4 +1698,4 @@ CCMD(fs_dir)
bool hidden = fileSystem.FindFile(fn1) != i; bool hidden = fileSystem.FindFile(fn1) != i;
Printf(PRINT_NONOTIFY, "%s%-64s %-15s (%5d) %10d %s %s\n", hidden ? TEXTCOLOR_RED : TEXTCOLOR_UNTRANSLATED, fn1, fns, fnid, length, container, hidden ? "(h)" : ""); Printf(PRINT_NONOTIFY, "%s%-64s %-15s (%5d) %10d %s %s\n", hidden ? TEXTCOLOR_RED : TEXTCOLOR_UNTRANSLATED, fn1, fns, fnid, length, container, hidden ? "(h)" : "");
} }
} }

View file

@ -430,4 +430,4 @@ void FGLRenderer::PresentStereo()
} }
} }
} }

View file

@ -455,7 +455,7 @@ void FSkyVertexBuffer::RenderRow(FRenderState& state, EDrawType prim, int row, T
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color) void FSkyVertexBuffer::DoRenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color)
{ {
auto& primStart = which ? mPrimStartBuild : mPrimStartDoom; auto& primStart = which ? mPrimStartBuild : mPrimStartDoom;
if (tex && tex->isValid()) if (tex && tex->isValid())
@ -510,7 +510,7 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float
{ {
SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale); SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale);
} }
RenderDome(state, tex, mode, false, color); DoRenderDome(state, tex, mode, false, color);
} }
@ -570,5 +570,6 @@ void FSkyVertexBuffer::RenderBox(FRenderState& state, FSkyBox* tex, float x_offs
state.Draw(DT_TriangleStrip, FaceStart(4), 4); state.Draw(DT_TriangleStrip, FaceStart(4), 4);
state.EnableModelMatrix(false); state.EnableModelMatrix(false);
state.SetObjectColor(0xffffffff);
} }

View file

@ -90,7 +90,7 @@ public:
} }
void RenderRow(FRenderState& state, EDrawType prim, int row, TArray<unsigned int>& mPrimStart, bool apply = true); void RenderRow(FRenderState& state, EDrawType prim, int row, TArray<unsigned int>& mPrimStart, bool apply = true);
void RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color = 0xffffffff); void DoRenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color = 0xffffffff);
void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0, PalEntry color = 0xffffffff); void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0, PalEntry color = 0xffffffff);
void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color = 0xffffffff); void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color = 0xffffffff);

View file

@ -11158,7 +11158,7 @@ ExpEmit FxLocalArrayDeclaration::Emit(VMFunctionBuilder *build)
auto zero = build->GetConstantInt(0); auto zero = build->GetConstantInt(0);
auto elementSizeConst = build->GetConstantInt(static_cast<PArray *>(ValueType)->ElementSize); auto elementSizeConst = build->GetConstantInt(static_cast<PArray *>(ValueType)->ElementSize);
int arrOffsetReg; int arrOffsetReg = 0;
if (!isDynamicArray) if (!isDynamicArray)
{ {
arrOffsetReg = build->Registers[REGT_POINTER].Get(1); arrOffsetReg = build->Registers[REGT_POINTER].Get(1);

View file

@ -425,9 +425,9 @@ PNamespace *ParseOneScript(const int baselump, ZCCParseState &state)
{ {
FString fullPath = IncludeLocs[i].FileName.GetChars(); // get full path, format 'wad:filepath/filename' FString fullPath = IncludeLocs[i].FileName.GetChars(); // get full path, format 'wad:filepath/filename'
long start = fullPath.IndexOf(":"); // find first ':' auto start = fullPath.IndexOf(":"); // find first ':'
long end = fullPath.LastIndexOf("/"); // find last '/' auto end = fullPath.LastIndexOf("/"); // find last '/'
if (start!=-1&&end!=-1) if (start!=-1&&end!=-1)
{ {
@ -443,7 +443,7 @@ PNamespace *ParseOneScript(const int baselump, ZCCParseState &state)
while (relativePath.IndexOf("../") == 0) // go back one folder for each '..' while (relativePath.IndexOf("../") == 0) // go back one folder for each '..'
{ {
relativePath = relativePath.Mid(3); relativePath = relativePath.Mid(3);
long slash_index = resolvedPath.LastIndexOf("/"); auto slash_index = resolvedPath.LastIndexOf("/");
if (slash_index != -1) { if (slash_index != -1) {
resolvedPath = resolvedPath.Mid(0,slash_index); resolvedPath = resolvedPath.Mid(0,slash_index);
} else { } else {

View file

@ -350,15 +350,15 @@ FStartScreen* GetGameStartScreen(int max_progress)
{ {
try try
{ {
if (GameStartupInfo.Type == FStartupInfo::HexenStartup || (gameinfo.gametype == GAME_Hexen && GameStartupInfo.Type == FStartupInfo::DefaultStartup)) if (GameStartupInfo.Type == FStartupInfo::HexenStartup)
{ {
return CreateHexenStartScreen(max_progress); return CreateHexenStartScreen(max_progress);
} }
else if (GameStartupInfo.Type == FStartupInfo::HereticStartup || (gameinfo.gametype == GAME_Heretic && GameStartupInfo.Type == FStartupInfo::DefaultStartup)) else if (GameStartupInfo.Type == FStartupInfo::HereticStartup)
{ {
return CreateHereticStartScreen(max_progress); return CreateHereticStartScreen(max_progress);
} }
else if (GameStartupInfo.Type == FStartupInfo::StrifeStartup || (gameinfo.gametype == GAME_Strife && GameStartupInfo.Type == FStartupInfo::DefaultStartup)) else if (GameStartupInfo.Type == FStartupInfo::StrifeStartup)
{ {
return CreateStrifeStartScreen(max_progress); return CreateStrifeStartScreen(max_progress);
} }

View file

@ -34,7 +34,6 @@
** **
*/ */
#include "doomtype.h"
#include "files.h" #include "files.h"
#include "gi.h" #include "gi.h"
#include "bitmap.h" #include "bitmap.h"

View file

@ -198,34 +198,26 @@ void I_ResetFrameTime()
FirstFrameStartTime += (CurrentFrameStartTime - ft); FirstFrameStartTime += (CurrentFrameStartTime - ft);
} }
double I_GetInputFrac(bool const synchronised, double const ticrate) double I_GetInputFrac(bool const synchronised)
{ {
if (!synchronised) if (!synchronised)
{ {
const double max = 1000. / ticrate;
const double now = I_msTimeF(); const double now = I_msTimeF();
const double elapsedInputTicks = std::min(now - lastinputtime, max); const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
lastinputtime = now; lastinputtime = now;
if (elapsedInputTicks < max) if (result < 1)
{ {
// Calculate an amplification to apply to the result before returning, // Calculate an amplification to apply to the result before returning,
// factoring in the game's ticrate and the value of the result. // factoring in the game's ticrate and the value of the result.
// This rectifies a deviation of 100+ ms or more depending on the length // This rectifies a deviation of 100+ ms or more depending on the length
// of the operation to be within 1-2 ms of synchronised input // of the operation to be within 1-2 ms of synchronised input
// from 60 fps to at least 1000 fps at ticrates of 30 and 40 Hz. // from 60 fps to at least 1000 fps at ticrates of 30 and 40 Hz.
const double result = elapsedInputTicks * ticrate * (1. / 1000.); return result * (1. + 0.35 * (1. - GameTicRate * (1. / 50.)) * (1. - result));
return result * (1. + 0.35 * (1. - ticrate * (1. / 50.)) * (1. - result));
}
else
{
return 1;
} }
} }
else
{ return 1;
return 1;
}
} }
void I_ResetInputTime() void I_ResetInputTime()

View file

@ -40,7 +40,7 @@ uint64_t I_nsTime();
void I_ResetFrameTime(); void I_ResetFrameTime();
// Return a decimal fraction to scale input operations at framerate // Return a decimal fraction to scale input operations at framerate
double I_GetInputFrac(bool const synchronised, double const ticrate = GameTicRate); double I_GetInputFrac(bool const synchronised);
// Reset the last input check to after a lengthy operation // Reset the last input check to after a lengthy operation
void I_ResetInputTime(); void I_ResetInputTime();

View file

@ -335,7 +335,6 @@ int restart = 0;
bool AppActive = true; bool AppActive = true;
bool playedtitlemusic; bool playedtitlemusic;
FStartupScreen* StartWindow;
FStartScreen* StartScreen; FStartScreen* StartScreen;
cycle_t FrameCycles; cycle_t FrameCycles;
@ -3098,6 +3097,17 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray<FString>& allwads, TArr
int max_progress = TexMan.GuesstimateNumTextures(); int max_progress = TexMan.GuesstimateNumTextures();
int per_shader_progress = 0;//screen->GetShaderCount()? (max_progress / 10 / screen->GetShaderCount()) : 0; int per_shader_progress = 0;//screen->GetShaderCount()? (max_progress / 10 / screen->GetShaderCount()) : 0;
bool nostartscreen = batchrun || restart || Args->CheckParm("-join") || Args->CheckParm("-host") || Args->CheckParm("-norun"); bool nostartscreen = batchrun || restart || Args->CheckParm("-join") || Args->CheckParm("-host") || Args->CheckParm("-norun");
if (GameStartupInfo.Type == FStartupInfo::DefaultStartup)
{
if (gameinfo.gametype == GAME_Hexen)
GameStartupInfo.Type = FStartupInfo::HexenStartup;
else if (gameinfo.gametype == GAME_Heretic)
GameStartupInfo.Type = FStartupInfo::HereticStartup;
else if (gameinfo.gametype == GAME_Strife)
GameStartupInfo.Type = FStartupInfo::StrifeStartup;
}
StartScreen = nostartscreen? nullptr : GetGameStartScreen(per_shader_progress > 0 ? max_progress * 10 / 9 : max_progress + 3); StartScreen = nostartscreen? nullptr : GetGameStartScreen(per_shader_progress > 0 ? max_progress * 10 / 9 : max_progress + 3);
GameConfig->DoKeySetup(gameinfo.ConfigName); GameConfig->DoKeySetup(gameinfo.ConfigName);

View file

@ -220,13 +220,17 @@ struct System native
native static bool SoundEnabled(); native static bool SoundEnabled();
native static bool MusicEnabled(); native static bool MusicEnabled();
native static double GetTimeFrac(); native static double GetTimeFrac();
static bool specialKeyEvent(InputEvent ev) static bool specialKeyEvent(InputEvent ev)
{ {
if (ev.type == InputEvent.Type_KeyDown || ev.type == InputEvent.Type_KeyUp) if (ev.type == InputEvent.Type_KeyDown || ev.type == InputEvent.Type_KeyUp)
{ {
int key = ev.KeyScan; int key = ev.KeyScan;
if (key == InputEvent.KEY_VOLUMEDOWN || key == InputEvent.KEY_VOLUMEUP || (key > InputEvent.KEY_LASTJOYBUTTON && key < InputEvent.KEY_PAD_LTHUMB_RIGHT)) return true; let binding = Bindings.GetBinding(key);
bool volumekeys = key == InputEvent.KEY_VOLUMEDOWN || key == InputEvent.KEY_VOLUMEUP;
bool gamepadkeys = key > InputEvent.KEY_LASTJOYBUTTON && key < InputEvent.KEY_PAD_LTHUMB_RIGHT;
bool altkeys = key == InputEvent.KEY_LALT || key == InputEvent.KEY_RALT;
if (volumekeys || gamepadkeys || altkeys || binding ~== "screenshot") return true;
} }
return false; return false;
} }

View file

@ -73,20 +73,20 @@ class ColorpickerMenu : OptionMenu
int mStartItem; int mStartItem;
CVar mCVar; CVar mCVar;
double GetColor(int index) double GetColor(int index)
{ {
double v = index == 0? mRed : index == 1? mGreen : mBlue; double v = index == 0? mRed : index == 1? mGreen : mBlue;
return v; return v;
} }
void SetColor(int index, double val) void SetColor(int index, double val)
{ {
if (index == 0) mRed = val; if (index == 0) mRed = val;
else if (index == 1) mGreen = val; else if (index == 1) mGreen = val;
else mBlue = val; else mBlue = val;
} }
//============================================================================= //=============================================================================
// //
// //
@ -119,7 +119,7 @@ class ColorpickerMenu : OptionMenu
mDesc.mIndent = 0; mDesc.mIndent = 0;
mDesc.CalcIndent(); mDesc.CalcIndent();
} }
//============================================================================= //=============================================================================
// //
// //
@ -273,7 +273,7 @@ class ColorpickerMenu : OptionMenu
if (h > fh) h = fh; if (h > fh) h = fh;
else if (h < 4) return; // no space to draw it. else if (h < 4) return; // no space to draw it.
int indent = (screen.GetWidth() / 2); int indent = (screen.GetWidth() / 2);
int p = 0; int p = 0;
@ -328,7 +328,7 @@ class ColorpickerMenu : OptionMenu
y += 49*CleanYfac_1; y += 49*CleanYfac_1;
screen.DrawText (SmallFont, Font.CR_GRAY, x+(48-SmallFont.StringWidth("---->")/2)*CleanXfac_1, y, "---->", DTA_CleanNoMove_1, true); screen.DrawText (SmallFont, Font.CR_GRAY, x+(48-SmallFont.StringWidth("---->")/2)*CleanXfac_1, y, "---->", DTA_CleanNoMove_1, true);
} }
override void OnDestroy() override void OnDestroy()
{ {
if (mStartItem >= 0) if (mStartItem >= 0)

View file

@ -47,20 +47,20 @@ class ImageScrollerDescriptor : MenuDescriptor native
class ImageScrollerPage : MenuItemBase class ImageScrollerPage : MenuItemBase
{ {
int virtWidth, virtHeight; int virtWidth, virtHeight;
protected void DrawText(Font fnt, int color, double x, double y, String text) protected void DrawText(Font fnt, int color, double x, double y, String text)
{ {
screen.DrawText(fnt, color, x, y, text, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43); screen.DrawText(fnt, color, x, y, text, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43);
} }
protected void DrawTexture(TextureID tex, double x, double y) protected void DrawTexture(TextureID tex, double x, double y)
{ {
screen.DrawTexture(tex, true, x, y, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43); screen.DrawTexture(tex, true, x, y, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43);
} }
virtual void OnStartPage() virtual void OnStartPage()
{} {}
virtual void OnEndPage() virtual void OnEndPage()
{} {}
} }
@ -74,13 +74,13 @@ class ImageScrollerPage : MenuItemBase
class ImageScrollerPageImageItem : ImageScrollerPage class ImageScrollerPageImageItem : ImageScrollerPage
{ {
TextureID mTexture; TextureID mTexture;
void Init(ImageScrollerDescriptor desc, String patch) void Init(ImageScrollerDescriptor desc, String patch)
{ {
Super.Init(); Super.Init();
mTexture = TexMan.CheckForTexture(patch); mTexture = TexMan.CheckForTexture(patch);
} }
override void Drawer(bool selected) override void Drawer(bool selected)
{ {
Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal); Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal);
@ -100,7 +100,7 @@ class ImageScrollerPageTextItem : ImageScrollerPage
TextureID mTexture; TextureID mTexture;
Color mBrightness; Color mBrightness;
double mTextScale; double mTextScale;
void Init(ImageScrollerDescriptor desc, String txt, int y = -1) void Init(ImageScrollerDescriptor desc, String txt, int y = -1)
{ {
Super.Init(); Super.Init();
@ -110,16 +110,16 @@ class ImageScrollerPageTextItem : ImageScrollerPage
mTextScale = desc.textScale; mTextScale = desc.textScale;
virtWidth = desc.virtWidth; virtWidth = desc.virtWidth;
virtHeight = desc.virtHeight; virtHeight = desc.virtHeight;
mText = mFont.BreakLines(Stringtable.Localize(txt.Filter()), int(virtWidth / mTextScale)); mText = mFont.BreakLines(Stringtable.Localize(txt.Filter()), int(virtWidth / mTextScale));
mYpos = y >= 0? y : virtHeight / 2 - mText.Count() * mFont.GetHeight() * mTextScale / 2; mYpos = y >= 0? y : virtHeight / 2 - mText.Count() * mFont.GetHeight() * mTextScale / 2;
} }
override void Drawer(bool selected) override void Drawer(bool selected)
{ {
Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_Color, mBrightness); Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_Color, mBrightness);
let fontheight = mFont.GetHeight() * mTextScale; let fontheight = mFont.GetHeight() * mTextScale;
let y = mYpos; let y = mYpos;
let c = mText.Count(); let c = mText.Count();
@ -180,7 +180,7 @@ class ImageScrollerMenu : Menu
// //
// //
//============================================================================= //=============================================================================
override bool MenuEvent(int mkey, bool fromcontroller) override bool MenuEvent(int mkey, bool fromcontroller)
{ {
if (mDesc.mItems.Size() <= 1) if (mDesc.mItems.Size() <= 1)
@ -228,7 +228,7 @@ class ImageScrollerMenu : Menu
// //
// //
//============================================================================= //=============================================================================
override bool MouseEvent(int type, int x, int y) override bool MouseEvent(int type, int x, int y)
{ {
// Todo: Implement some form of drag event to switch between pages. // Todo: Implement some form of drag event to switch between pages.
@ -244,7 +244,7 @@ class ImageScrollerMenu : Menu
// //
// //
//============================================================================= //=============================================================================
private bool DrawTransition() private bool DrawTransition()
{ {
double now = MSTime() * (120. / 1000.); double now = MSTime() * (120. / 1000.);
@ -270,7 +270,7 @@ class ImageScrollerMenu : Menu
// //
// //
//============================================================================= //=============================================================================
override void Drawer() override void Drawer()
{ {
if (previous != null) if (previous != null)

View file

@ -41,7 +41,7 @@
class OptionMenuSliderJoySensitivity : OptionMenuSliderBase class OptionMenuSliderJoySensitivity : OptionMenuSliderBase
{ {
JoystickConfig mJoy; JoystickConfig mJoy;
OptionMenuSliderJoySensitivity Init(String label, double min, double max, double step, int showval, JoystickConfig joy) OptionMenuSliderJoySensitivity Init(String label, double min, double max, double step, int showval, JoystickConfig joy)
{ {
Super.Init(label, min, max, step, showval); Super.Init(label, min, max, step, showval);
@ -71,7 +71,7 @@ class OptionMenuSliderJoyScale : OptionMenuSliderBase
int mAxis; int mAxis;
int mNeg; int mNeg;
JoystickConfig mJoy; JoystickConfig mJoy;
OptionMenuSliderJoyScale Init(String label, int axis, double min, double max, double step, int showval, JoystickConfig joy) OptionMenuSliderJoyScale Init(String label, int axis, double min, double max, double step, int showval, JoystickConfig joy)
{ {
Super.Init(label, min, max, step, showval); Super.Init(label, min, max, step, showval);
@ -138,7 +138,7 @@ class OptionMenuItemJoyMap : OptionMenuItemOptionBase
{ {
int mAxis; int mAxis;
JoystickConfig mJoy; JoystickConfig mJoy;
OptionMenuItemJoyMap Init(String label, int axis, Name values, int center, JoystickConfig joy) OptionMenuItemJoyMap Init(String label, int axis, Name values, int center, JoystickConfig joy)
{ {
Super.Init(label, 'none', values, null, center); Super.Init(label, 'none', values, null, center);
@ -191,7 +191,7 @@ class OptionMenuItemInverter : OptionMenuItemOptionBase
{ {
int mAxis; int mAxis;
JoystickConfig mJoy; JoystickConfig mJoy;
OptionMenuItemInverter Init(String label, int axis, int center, JoystickConfig joy) OptionMenuItemInverter Init(String label, int axis, int center, JoystickConfig joy)
{ {
Super.Init(label, "none", "YesNo", NULL, center); Super.Init(label, "none", "YesNo", NULL, center);
@ -223,7 +223,7 @@ class OptionMenuItemInverter : OptionMenuItemOptionBase
class OptionMenuItemJoyConfigMenu : OptionMenuItemSubmenu class OptionMenuItemJoyConfigMenu : OptionMenuItemSubmenu
{ {
JoystickConfig mJoy; JoystickConfig mJoy;
OptionMenuItemJoyConfigMenu Init(String label, JoystickConfig joy) OptionMenuItemJoyConfigMenu Init(String label, JoystickConfig joy)
{ {
Super.Init(label, "JoystickConfigMenu"); Super.Init(label, "JoystickConfigMenu");
@ -243,7 +243,7 @@ class OptionMenuItemJoyConfigMenu : OptionMenuItemSubmenu
if (res && joymenu != null) joymenu.mJoy = mJoy; if (res && joymenu != null) joymenu.mJoy = mJoy;
return res; return res;
} }
static void SetController(OptionMenuDescriptor opt, JoystickConfig joy) static void SetController(OptionMenuDescriptor opt, JoystickConfig joy)
{ {
OptionMenuItem it; OptionMenuItem it;
@ -296,7 +296,7 @@ class OptionMenuItemJoyConfigMenu : OptionMenuItemSubmenu
opt.mPosition = -25; opt.mPosition = -25;
opt.CalcIndent(); opt.CalcIndent();
} }
} }
//============================================================================= //=============================================================================

View file

@ -120,7 +120,7 @@ class ListMenu : Menu
mDesc.mItems[i].OnMenuCreated(); mDesc.mItems[i].OnMenuCreated();
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -136,7 +136,7 @@ class ListMenu : Menu
} }
return NULL; return NULL;
} }
//============================================================================= //=============================================================================
// //
@ -243,7 +243,7 @@ class ListMenu : Menu
int h = mDesc.DisplayHeight(); int h = mDesc.DisplayHeight();
double fx, fy, fw, fh; double fx, fy, fw, fh;
[fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43); [fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43);
x = int((x - fx) * w / fw); x = int((x - fx) * w / fw);
y = int((y - fy) * h / fh); y = int((y - fy) * h / fh);
} }
@ -311,7 +311,7 @@ class ListMenu : Menu
} }
Super.Drawer(); Super.Drawer();
} }
//============================================================================= //=============================================================================
// //
// //

View file

@ -109,7 +109,7 @@ class ListMenuItemStaticPatch : ListMenuItem
mColor = desc.mFontColor; mColor = desc.mFontColor;
} }
override void Draw(bool selected, ListMenuDescriptor desc) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
if (!mTexture.Exists()) if (!mTexture.Exists())
@ -163,7 +163,7 @@ class ListMenuItemStaticText : ListMenuItem
mColor = color >= 0? color : desc.mFontColor; mColor = color >= 0? color : desc.mFontColor;
mCentered = false; mCentered = false;
} }
void InitDirect(double x, double y, String text, Font font, int color = Font.CR_UNTRANSLATED, bool centered = false) void InitDirect(double x, double y, String text, Font font, int color = Font.CR_UNTRANSLATED, bool centered = false)
{ {
Super.Init(x, y); Super.Init(x, y);
@ -172,7 +172,7 @@ class ListMenuItemStaticText : ListMenuItem
mColor = color; mColor = color;
mCentered = centered; mCentered = centered;
} }
override void Draw(bool selected, ListMenuDescriptor desc) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
if (mText.Length() != 0) if (mText.Length() != 0)
@ -216,12 +216,12 @@ class ListMenuItemSelectable : ListMenuItem
mParam = param; mParam = param;
mHotkey = 0; mHotkey = 0;
} }
override bool CheckCoordinate(int x, int y) override bool CheckCoordinate(int x, int y)
{ {
return mEnabled > 0 && 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()
{ {
return mEnabled > 0; return mEnabled > 0;
@ -231,13 +231,13 @@ class ListMenuItemSelectable : ListMenuItem
{ {
return c > 0 && c == mHotkey; return c > 0 && c == mHotkey;
} }
override bool Activate() override bool Activate()
{ {
Menu.SetMenu(mAction, mParam); Menu.SetMenu(mAction, mParam);
return true; return true;
} }
override bool MouseEvent(int type, int x, int y) override bool MouseEvent(int type, int x, int y)
{ {
if (type == Menu.MOUSE_Release) if (type == Menu.MOUSE_Release)
@ -250,7 +250,7 @@ class ListMenuItemSelectable : ListMenuItem
} }
return false; return false;
} }
override Name, int GetAction() override Name, int GetAction()
{ {
return mAction, mParam; return mAction, mParam;
@ -279,7 +279,7 @@ class ListMenuItemTextItem : ListMenuItemSelectable
mColorSelected = desc.mFontcolor2; mColorSelected = desc.mFontcolor2;
mHotkey = hotkey.GetNextCodePoint(0); mHotkey = hotkey.GetNextCodePoint(0);
} }
void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0) void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
{ {
Super.Init(x, y, height, child, param); Super.Init(x, y, height, child, param);
@ -290,7 +290,7 @@ class ListMenuItemTextItem : ListMenuItemSelectable
int pos = 0; int pos = 0;
mHotkey = hotkey.GetNextCodePoint(0); mHotkey = hotkey.GetNextCodePoint(0);
} }
override void Draw(bool selected, ListMenuDescriptor desc) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
let font = menuDelegate.PickFont(mFont); let font = menuDelegate.PickFont(mFont);
@ -313,31 +313,31 @@ class ListMenuItemTextItem : ListMenuItemSelectable
class ListMenuItemPatchItem : ListMenuItemSelectable class ListMenuItemPatchItem : ListMenuItemSelectable
{ {
TextureID mTexture; TextureID mTexture;
void Init(ListMenuDescriptor desc, TextureID patch, String hotkey, Name child, int param = 0) void Init(ListMenuDescriptor desc, TextureID patch, String hotkey, Name child, int param = 0)
{ {
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param); Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param);
mHotkey = hotkey.GetNextCodePoint(0); mHotkey = hotkey.GetNextCodePoint(0);
mTexture = patch; mTexture = patch;
} }
void InitDirect(double x, double y, int height, TextureID patch, String hotkey, Name child, int param = 0) void InitDirect(double x, double y, int height, TextureID patch, String hotkey, Name child, int param = 0)
{ {
Super.Init(x, y, height, child, param); Super.Init(x, y, height, child, param);
mHotkey = hotkey.GetNextCodePoint(0); mHotkey = hotkey.GetNextCodePoint(0);
mTexture = patch; mTexture = patch;
} }
override void Draw(bool selected, ListMenuDescriptor desc) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
DrawTexture(desc, mTexture, mXpos, mYpos); DrawTexture(desc, mTexture, mXpos, mYpos);
} }
override int GetWidth() override int GetWidth()
{ {
return TexMan.GetSize(mTexture); return TexMan.GetSize(mTexture);
} }
} }
//============================================================================= //=============================================================================
@ -357,7 +357,7 @@ class ListMenuItemCaptionItem : ListMenuItem
mText = text; mText = text;
mFont = Font.FindFont(fnt); mFont = Font.FindFont(fnt);
} }
override void Draw(bool selected, ListMenuDescriptor desc) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
let font = menuDelegate.PickFont(desc.mFont); let font = menuDelegate.PickFont(desc.mFont);

View file

@ -87,7 +87,7 @@ class LoadSaveMenu : ListMenu
int listboxLeft; int listboxLeft;
int listboxTop; int listboxTop;
int listboxWidth; int listboxWidth;
int listboxRows; int listboxRows;
int listboxHeight; int listboxHeight;
int listboxRight; int listboxRight;
@ -101,10 +101,10 @@ class LoadSaveMenu : ListMenu
bool mEntering; bool mEntering;
TextEnterMenu mInput; TextEnterMenu mInput;
double FontScale; double FontScale;
BrokenLines BrokenSaveComment; BrokenLines BrokenSaveComment;
//============================================================================= //=============================================================================
// //
@ -119,13 +119,13 @@ class LoadSaveMenu : ListMenu
manager.ReadSaveStrings(); manager.ReadSaveStrings();
SetWindows(); SetWindows();
} }
private void SetWindows() private void SetWindows()
{ {
bool aspect43 = true; bool aspect43 = true;
int Width43 = screen.GetHeight() * 4 / 3; int Width43 = screen.GetHeight() * 4 / 3;
int Left43 = (screen.GetWidth() - Width43) / 2; int Left43 = (screen.GetWidth() - Width43) / 2;
double wScale = Width43 / 640.; double wScale = Width43 / 640.;
savepicLeft = Left43 + int(20 * wScale); savepicLeft = Left43 + int(20 * wScale);
@ -135,7 +135,7 @@ class LoadSaveMenu : ListMenu
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 + int(20*wScale); listboxLeft = savepicLeft + savepicWidth + int(20*wScale);
listboxTop = savepicTop; listboxTop = savepicTop;
listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale); listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale);
@ -151,7 +151,7 @@ class LoadSaveMenu : ListMenu
commentRows = commentHeight / rowHeight; commentRows = commentHeight / rowHeight;
} }
//============================================================================= //=============================================================================
// //
// //
@ -202,7 +202,7 @@ class LoadSaveMenu : ListMenu
if (Selected >= manager.SavegameCount()) Selected = 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); int textlen = NewSmallFont.StringWidth(text);
screen.DrawText (NewSmallFont, Font.CR_GOLD, (savepicLeft + savepicWidth / 2) / FontScale - textlen/2, screen.DrawText (NewSmallFont, Font.CR_GOLD, (savepicLeft + savepicWidth / 2) / FontScale - textlen/2,
(savepicTop+(savepicHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); (savepicTop+(savepicHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true);
} }
@ -218,7 +218,7 @@ class LoadSaveMenu : ListMenu
screen.DrawText(NewConsoleFont, Font.CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment.StringAt(i), screen.DrawText(NewConsoleFont, Font.CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment.StringAt(i),
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true);
} }
// Draw file area // Draw file area
DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight); DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
@ -257,7 +257,7 @@ class LoadSaveMenu : ListMenu
} }
screen.SetClipRect(listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1)); screen.SetClipRect(listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1));
if (j == Selected) if (j == Selected)
{ {
screen.Clear (listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1), mEntering ? Color(255,255,0,0) : Color(255,0,0,255)); screen.Clear (listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1), mEntering ? Color(255,255,0,0) : Color(255,0,0,255));
@ -388,7 +388,7 @@ class LoadSaveMenu : ListMenu
return Super.MenuEvent(mkey, fromcontroller); return Super.MenuEvent(mkey, fromcontroller);
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -422,8 +422,8 @@ class LoadSaveMenu : ListMenu
return Super.MouseEvent(type, x, y); return Super.MouseEvent(type, x, y);
} }
//============================================================================= //=============================================================================
// //
// //
@ -466,13 +466,13 @@ class LoadSaveMenu : ListMenu
return Super.OnUIEvent(ev); return Super.OnUIEvent(ev);
} }
} }
class SaveMenu : LoadSaveMenu class SaveMenu : LoadSaveMenu
{ {
String mSaveName; String mSaveName;
//============================================================================= //=============================================================================
// //
// //
@ -508,7 +508,7 @@ class SaveMenu : LoadSaveMenu
// //
// //
//============================================================================= //=============================================================================
override bool MenuEvent (int mkey, bool fromcontroller) override bool MenuEvent (int mkey, bool fromcontroller)
{ {
if (Super.MenuEvent(mkey, fromcontroller)) if (Super.MenuEvent(mkey, fromcontroller))
@ -603,7 +603,7 @@ class SaveMenu : LoadSaveMenu
mSaveName = ""; mSaveName = "";
} }
} }
} }
//============================================================================= //=============================================================================

View file

@ -76,14 +76,14 @@ struct JoystickConfig native version("2.4")
native float GetAxisDeadZone(int axis); native float GetAxisDeadZone(int axis);
native void SetAxisDeadZone(int axis, float zone); native void SetAxisDeadZone(int axis, float zone);
native int GetAxisMap(int axis); native int GetAxisMap(int axis);
native void SetAxisMap(int axis, int gameaxis); native void SetAxisMap(int axis, int gameaxis);
native String GetName(); native String GetName();
native int GetNumAxes(); native int GetNumAxes();
native String GetAxisName(int axis); native String GetAxisName(int axis);
} }
class Menu : Object native ui version("2.4") class Menu : Object native ui version("2.4")
@ -139,7 +139,7 @@ class Menu : Object native ui version("2.4")
native static void SetMouseCapture(bool on); native static void SetMouseCapture(bool on);
native void Close(); native void Close();
native void ActivateMenu(); native void ActivateMenu();
//============================================================================= //=============================================================================
// //
// //
@ -156,7 +156,7 @@ class Menu : Object native ui version("2.4")
AnimatedTransition = false; AnimatedTransition = false;
Animated = false; Animated = false;
} }
//============================================================================= //=============================================================================
// //
// //
@ -230,7 +230,7 @@ class Menu : Object native ui version("2.4")
{ {
SetCapture(true); SetCapture(true);
} }
} }
else if (ev.type == UIEvent.Type_MouseMove) else if (ev.type == UIEvent.Type_MouseMove)
{ {
@ -259,7 +259,7 @@ class Menu : Object native ui version("2.4")
{ {
return false; return false;
} }
//============================================================================= //=============================================================================
// //
// //
@ -289,7 +289,7 @@ class Menu : Object native ui version("2.4")
} }
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -330,34 +330,34 @@ class Menu : Object native ui version("2.4")
{ {
menuDelegate.PlaySound(snd); 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)
{ {
screen.DrawText (ConFont, color, x, y, str, DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac); screen.DrawText (ConFont, color, x, y, str, DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac);
} }
static Font OptionFont() static Font OptionFont()
{ {
return NewSmallFont; return NewSmallFont;
} }
static int OptionHeight() static int OptionHeight()
{ {
return OptionFont().GetHeight(); return OptionFont().GetHeight();
} }
static int OptionWidth(String s) static int OptionWidth(String s)
{ {
return OptionFont().StringWidth(s); return OptionFont().StringWidth(s);
} }
static void DrawOptionText(int x, int y, int color, String text, bool grayed = false) static void DrawOptionText(int x, int y, int color, String text, bool grayed = false)
{ {
String label = Stringtable.Localize(text); String label = Stringtable.Localize(text);
int overlay = grayed? Color(96,48,0,0) : 0; int overlay = grayed? Color(96,48,0,0) : 0;
screen.DrawText (OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay); screen.DrawText (OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay);
} }
} }

View file

@ -7,11 +7,11 @@ class MenuDelegateBase ui
if (drawit) screen.DrawText(fnt, OptionMenuSettings.mTitleColor, (screen.GetWidth() - fnt.StringWidth(title) * CleanXfac_1) / 2, 10 * CleanYfac_1, title, DTA_CleanNoMove_1, true); if (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()) * CleanYfac_1; // return is spacing in screen pixels. return (y + fnt.GetHeight()) * CleanYfac_1; // return is spacing in screen pixels.
} }
virtual void PlaySound(Name sound) virtual void PlaySound(Name sound)
{ {
} }
virtual bool DrawSelector(ListMenuDescriptor desc) virtual bool DrawSelector(ListMenuDescriptor desc)
{ {
return false; return false;
@ -21,7 +21,7 @@ class MenuDelegateBase ui
{ {
// overriding this allows to execute special actions when the menu closes // overriding this allows to execute special actions when the menu closes
} }
virtual Font PickFont(Font fnt) virtual Font PickFont(Font fnt)
{ {
if (generic_ui || !fnt) return NewSmallFont; if (generic_ui || !fnt) return NewSmallFont;

View file

@ -68,7 +68,7 @@ class MessageBoxMenu : Menu
if (SmallFont && SmallFont.CanPrint(message) && SmallFont.CanPrint("$TXT_YES") && SmallFont.CanPrint("$TXT_NO")) textFont = SmallFont; if (SmallFont && SmallFont.CanPrint(message) && SmallFont.CanPrint("$TXT_YES") && SmallFont.CanPrint("$TXT_NO")) textFont = SmallFont;
else if (OriginalSmallFont && OriginalSmallFont.CanPrint(message) && OriginalSmallFont.CanPrint("$TXT_YES") && OriginalSmallFont.CanPrint("$TXT_NO")) textFont = OriginalSmallFont; else if (OriginalSmallFont && OriginalSmallFont.CanPrint(message) && OriginalSmallFont.CanPrint("$TXT_YES") && OriginalSmallFont.CanPrint("$TXT_NO")) textFont = OriginalSmallFont;
} }
if (!textFont) if (!textFont)
{ {
arrowFont = textFont = NewSmallFont; arrowFont = textFont = NewSmallFont;
@ -97,7 +97,7 @@ class MessageBoxMenu : Menu
} }
Handler = native_handler; Handler = native_handler;
} }
//============================================================================= //=============================================================================
// //
// //
@ -140,7 +140,7 @@ class MessageBoxMenu : Menu
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -227,7 +227,7 @@ class MessageBoxMenu : Menu
} }
return Super.OnUIEvent(ev); return Super.OnUIEvent(ev);
} }
override bool OnInputEvent(InputEvent ev) override bool OnInputEvent(InputEvent ev)
{ {
if (ev.type == InputEvent.Type_KeyDown) if (ev.type == InputEvent.Type_KeyDown)

View file

@ -65,7 +65,7 @@ class OptionMenuDescriptor : MenuDescriptor native
mIndent = 0; mIndent = 0;
mDontDim = 0; mDontDim = 0;
} }
//============================================================================= //=============================================================================
// //
// //
@ -133,7 +133,7 @@ class OptionMenu : Menu
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -149,7 +149,7 @@ class OptionMenu : Menu
} }
return NULL; return NULL;
} }
//============================================================================= //=============================================================================
// //
@ -284,7 +284,7 @@ class OptionMenu : Menu
do do
{ {
++mDesc.mSelectedItem; ++mDesc.mSelectedItem;
if (CanScrollDown && mDesc.mSelectedItem == VisBottom) if (CanScrollDown && mDesc.mSelectedItem == VisBottom)
{ {
mDesc.mScrollPos++; mDesc.mScrollPos++;
@ -380,7 +380,7 @@ class OptionMenu : Menu
return true; return true;
} }
//============================================================================= //=============================================================================
// //
// //
@ -417,7 +417,7 @@ class OptionMenu : Menu
return Super.MouseEvent(type, x, y); return Super.MouseEvent(type, x, y);
} }
//============================================================================= //=============================================================================
// //
// //
@ -432,7 +432,7 @@ class OptionMenu : Menu
mDesc.mItems[i].Ticker(); mDesc.mItems[i].Ticker();
} }
} }
//============================================================================= //=============================================================================
// //
// //
@ -533,12 +533,12 @@ class OptionMenu : Menu
{ {
mFocusControl = OptionMenuItem(fc); mFocusControl = OptionMenuItem(fc);
} }
override bool CheckFocus(MenuItemBase fc) override bool CheckFocus(MenuItemBase fc)
{ {
return mFocusControl == fc; return mFocusControl == fc;
} }
override void ReleaseFocus() override void ReleaseFocus()
{ {
mFocusControl = NULL; mFocusControl = NULL;

View file

@ -36,7 +36,7 @@ class OptionMenuItem : MenuItemBase
{ {
String mLabel; String mLabel;
bool mCentered; bool mCentered;
protected void Init(String label, String command, bool center = false) protected void Init(String label, String command, bool center = false)
{ {
Super.Init(0, 0, command); Super.Init(0, 0, command);
@ -48,11 +48,11 @@ class OptionMenuItem : MenuItemBase
{ {
Menu.DrawOptionText(x, y, color, text, grayed); Menu.DrawOptionText(x, y, color, text, grayed);
} }
protected int drawLabel(int indent, int y, int color, bool grayed = false) protected int drawLabel(int indent, int y, int color, bool grayed = false)
{ {
String label = Stringtable.Localize(mLabel); String label = Stringtable.Localize(mLabel);
int x; int x;
int w = Menu.OptionWidth(label) * CleanXfac_1; int w = Menu.OptionWidth(label) * CleanXfac_1;
if (!mCentered) x = indent - w; if (!mCentered) x = indent - w;
@ -66,24 +66,24 @@ class OptionMenuItem : MenuItemBase
Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed); Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed);
} }
int CursorSpace() int CursorSpace()
{ {
return (14 * CleanXfac_1); return (14 * CleanXfac_1);
} }
override bool Selectable() override bool Selectable()
{ {
return true; return true;
} }
override int GetIndent() override int GetIndent()
{ {
if (mCentered) return 0; if (mCentered) return 0;
if (screen.GetWidth() < 640) return screen.GetWidth() / 2; if (screen.GetWidth() < 640) return screen.GetWidth() / 2;
return Menu.OptionWidth(Stringtable.Localize(mLabel)); return Menu.OptionWidth(Stringtable.Localize(mLabel));
} }
override bool MouseEvent(int type, int x, int y) override bool MouseEvent(int type, int x, int y)
{ {
if (Selectable() && type == Menu.MOUSE_Release) if (Selectable() && type == Menu.MOUSE_Release)
@ -147,7 +147,7 @@ class OptionMenuItemLabeledSubmenu : OptionMenuItemSubmenu
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
{ {
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
String text = mLabelCVar.GetString(); String text = mLabelCVar.GetString();
if (text.Length() == 0) text = Stringtable.Localize("$notset"); if (text.Length() == 0) text = Stringtable.Localize("$notset");
drawValue(indent, y, OptionMenuSettings.mFontColorValue, text); drawValue(indent, y, OptionMenuSettings.mFontColorValue, text);
@ -166,7 +166,7 @@ class OptionMenuItemCommand : OptionMenuItemSubmenu
private String ccmd; // do not allow access to this from the outside. private String ccmd; // do not allow access to this from the outside.
bool mCloseOnSelect; bool mCloseOnSelect;
private bool mUnsafe; private bool mUnsafe;
OptionMenuItemCommand Init(String label, Name command, bool centered = false, bool closeonselect = false) OptionMenuItemCommand Init(String label, Name command, bool centered = false, bool closeonselect = false)
{ {
Super.Init(label, command, 0, centered); Super.Init(label, command, 0, centered);
@ -255,7 +255,7 @@ class OptionMenuItemOptionBase : OptionMenuItem
Name mValues; // Entry in OptionValues table Name mValues; // Entry in OptionValues table
CVar mGrayCheck; CVar mGrayCheck;
int mCenter; int mCenter;
const OP_VALUES = 0x11001; const OP_VALUES = 0x11001;
protected void Init(String label, Name command, Name values, CVar graycheck, int center) protected void Init(String label, Name command, Name values, CVar graycheck, int center)
@ -288,11 +288,11 @@ class OptionMenuItemOptionBase : OptionMenuItem
{ {
return 0; return 0;
} }
virtual void SetSelection(int Selection) virtual void SetSelection(int Selection)
{ {
} }
//============================================================================= //=============================================================================
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
{ {
@ -338,7 +338,7 @@ class OptionMenuItemOptionBase : OptionMenuItem
} }
return true; return true;
} }
virtual bool isGrayed() virtual bool isGrayed()
{ {
return mGrayCheck != null && !mGrayCheck.GetInt(); return mGrayCheck != null && !mGrayCheck.GetInt();
@ -542,7 +542,7 @@ class OptionMenuItemControlBase : OptionMenuItem
} }
return false; return false;
} }
void SendKey(int key) void SendKey(int key)
{ {
mInput = key; mInput = key;
@ -717,7 +717,7 @@ class OptionMenuSliderBase : OptionMenuItem
{ {
return 0; return 0;
} }
virtual void SetSliderValue(double val) virtual void SetSliderValue(double val)
{ {
} }
@ -862,7 +862,7 @@ class OptionMenuSliderBase : OptionMenuItem
class OptionMenuItemSlider : OptionMenuSliderBase class OptionMenuItemSlider : OptionMenuSliderBase
{ {
CVar mCVar; CVar mCVar;
OptionMenuItemSlider Init(String label, Name command, double min, double max, double step, int showval = 1, CVar graycheck = NULL) OptionMenuItemSlider Init(String label, Name command, double min, double max, double step, int showval = 1, CVar graycheck = NULL)
{ {
Super.Init(label, min, max, step, showval, command, graycheck); Super.Init(label, min, max, step, showval, command, graycheck);
@ -941,11 +941,11 @@ class OptionMenuItemColorPicker : OptionMenuItem
if (mCVar != null) if (mCVar != null)
{ {
Menu.MenuSound("menu/choose"); Menu.MenuSound("menu/choose");
// This code is a bit complicated because it should allow subclassing the // This code is a bit complicated because it should allow subclassing the
// colorpicker menu. // colorpicker menu.
// New color pickers must inherit from the internal one to work here. // New color pickers must inherit from the internal one to work here.
let desc = MenuDescriptor.GetDescriptor('Colorpickermenu'); let desc = MenuDescriptor.GetDescriptor('Colorpickermenu');
if (desc != NULL && (desc.mClass == null || desc.mClass is "ColorPickerMenu")) if (desc != NULL && (desc.mClass == null || desc.mClass is "ColorPickerMenu"))
{ {
@ -1042,7 +1042,7 @@ class OptionMenuFieldBase : OptionMenuItem
class OptionMenuItemTextField : OptionMenuFieldBase class OptionMenuItemTextField : OptionMenuFieldBase
{ {
TextEnterMenu mEnter; TextEnterMenu mEnter;
OptionMenuItemTextField Init (String label, Name command, CVar graycheck = null) OptionMenuItemTextField Init (String label, Name command, CVar graycheck = null)
{ {
Super.Init(label, command, graycheck); Super.Init(label, command, graycheck);
@ -1175,7 +1175,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
String TextZero; String TextZero;
String TextNegOne; String TextNegOne;
int mClickVal; int mClickVal;
OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "") OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "")
{ {
Super.Init(label, command, min, max, step, 0); Super.Init(label, command, min, max, step, 0);
@ -1204,7 +1204,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
} }
return indent; return indent;
} }
override bool MouseEvent(int type, int x, int y) override bool MouseEvent(int type, int x, int y)
{ {
int value = int(GetSliderValue()); int value = int(GetSliderValue());
@ -1214,11 +1214,11 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
mClickVal = value; mClickVal = value;
if (value <= 0) return false; if (value <= 0) return false;
return Super.MouseEvent(type, x, y); return Super.MouseEvent(type, x, y);
case Menu.MOUSE_Move: case Menu.MOUSE_Move:
if (mClickVal <= 0) return false; if (mClickVal <= 0) return false;
return Super.MouseEvent(type, x, y); return Super.MouseEvent(type, x, y);
case Menu.MOUSE_Release: case Menu.MOUSE_Release:
if (mClickVal <= 0) if (mClickVal <= 0)
{ {
@ -1231,7 +1231,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
} }
return false; return false;
} }
} }
//============================================================================= //=============================================================================

View file

@ -15,14 +15,14 @@ class ReverbEdit : OptionMenu
super.Init(parent, desc); super.Init(parent, desc);
OnReturn(); OnReturn();
} }
override void OnReturn() override void OnReturn()
{ {
string env; string env;
int id; int id;
[env, id] = GetSelectedEnvironment(); [env, id] = GetSelectedEnvironment();
let li = GetItem('EvironmentName'); let li = GetItem('EvironmentName');
if (li != NULL) if (li != NULL)
{ {
@ -126,7 +126,7 @@ class OptionMenuItemReverbSelect : OptionMenuItemSubMenu
return self; return self;
} }
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
{ {
int x = drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); int x = drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
@ -164,7 +164,7 @@ class OptionMenuItemReverbOption : OptionMenuItemOptionBase
{ {
return int(ReverbEdit.GetValue(mValIndex)); return int(ReverbEdit.GetValue(mValIndex));
} }
override void SetSelection(int Selection) override void SetSelection(int Selection)
{ {
ReverbEdit.SetValue(mValIndex, Selection); ReverbEdit.SetValue(mValIndex, Selection);
@ -182,7 +182,7 @@ class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase
int mValIndex; int mValIndex;
String mEditValue; String mEditValue;
TextEnterMenu mEnter; TextEnterMenu mEnter;
OptionMenuItemSliderReverbEditOption Init(String label, double min, double max, double step, int showval, int valindex) OptionMenuItemSliderReverbEditOption Init(String label, double min, double max, double step, int showval, int valindex)
{ {
Super.Init(label, min, max, step, showval); Super.Init(label, min, max, step, showval);
@ -190,7 +190,7 @@ class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase
mEnter = null; mEnter = null;
return self; return self;
} }
override double GetSliderValue() override double GetSliderValue()
{ {
@ -201,7 +201,7 @@ class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase
{ {
ReverbEdit.SetValue(mValIndex, val); ReverbEdit.SetValue(mValIndex, val);
} }
override bool Selectable() override bool Selectable()
{ {
return !ReverbEdit.GrayCheck(); return !ReverbEdit.GrayCheck();
@ -228,7 +228,7 @@ class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase
} }
return indent; return indent;
} }
override bool MenuEvent (int mkey, bool fromcontroller) override bool MenuEvent (int mkey, bool fromcontroller)
{ {
if (mkey == Menu.MKEY_Enter) if (mkey == Menu.MKEY_Enter)
@ -253,6 +253,6 @@ class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase
return Super.MenuEvent(mkey, fromcontroller); return Super.MenuEvent(mkey, fromcontroller);
} }
} }

View file

@ -38,7 +38,7 @@ class TextEnterMenu : Menu
{ {
const INPUTGRID_WIDTH = 13; const INPUTGRID_WIDTH = 13;
const INPUTGRID_HEIGHT = 5; const INPUTGRID_HEIGHT = 5;
const Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-=.,!?@'\":;[]()<>^#$%&*/_ \b"; const Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-=.,!?@'\":;[]()<>^#$%&*/_ \b";
String mEnterString; String mEnterString;
@ -50,7 +50,7 @@ class TextEnterMenu : Menu
int CursorSize; int CursorSize;
bool AllowColors; bool AllowColors;
Font displayFont; Font displayFont;
//============================================================================= //=============================================================================
// //
// //
@ -106,13 +106,13 @@ class TextEnterMenu : Menu
{ {
return mEnterString; return mEnterString;
} }
override bool TranslateKeyboardEvents() override bool TranslateKeyboardEvents()
{ {
return mInputGridOkay; return mInputGridOkay;
} }
//============================================================================= //=============================================================================
// //
// //
@ -303,7 +303,7 @@ class TextEnterMenu : Menu
return false; return false;
} }
//============================================================================= //=============================================================================
// //
// //
@ -375,5 +375,5 @@ class TextEnterMenu : Menu
} }
Super.Drawer(); Super.Drawer();
} }
} }

View file

@ -23,22 +23,22 @@ class StatusBarCore native ui
DI_MIRROR = 0x1000, // flip the texture horizontally, like a mirror DI_MIRROR = 0x1000, // flip the texture horizontally, like a mirror
DI_ITEM_RELCENTER = 0x2000, DI_ITEM_RELCENTER = 0x2000,
DI_MIRRORY = 0x40000000, DI_MIRRORY = 0x40000000,
DI_SCREEN_AUTO = 0, // decide based on given offsets. DI_SCREEN_AUTO = 0, // decide based on given offsets.
DI_SCREEN_MANUAL_ALIGN = 0x4000, // If this is on, the following flags will have an effect DI_SCREEN_MANUAL_ALIGN = 0x4000, // If this is on, the following flags will have an effect
DI_SCREEN_TOP = DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_TOP = DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_VCENTER = 0x8000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VCENTER = 0x8000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_BOTTOM = 0x10000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_BOTTOM = 0x10000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_VOFFSET = 0x18000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VOFFSET = 0x18000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_VMASK = 0x18000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VMASK = 0x18000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_LEFT = DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_LEFT = DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_HCENTER = 0x20000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HCENTER = 0x20000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_RIGHT = 0x40000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_RIGHT = 0x40000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_HOFFSET = 0x60000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HOFFSET = 0x60000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_HMASK = 0x60000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HMASK = 0x60000 | DI_SCREEN_MANUAL_ALIGN,
DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP | DI_SCREEN_LEFT, DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP | DI_SCREEN_LEFT,
DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP | DI_SCREEN_RIGHT, DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP | DI_SCREEN_RIGHT,
DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_LEFT, DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_LEFT,
@ -49,21 +49,21 @@ class StatusBarCore native ui
DI_SCREEN_CENTER_TOP = DI_SCREEN_TOP | DI_SCREEN_HCENTER, DI_SCREEN_CENTER_TOP = DI_SCREEN_TOP | DI_SCREEN_HCENTER,
DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_HCENTER, DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_HCENTER,
DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET | DI_SCREEN_VOFFSET, DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET | DI_SCREEN_VOFFSET,
DI_ITEM_AUTO = 0, // equivalent with bottom center, which is the default alignment. DI_ITEM_AUTO = 0, // equivalent with bottom center, which is the default alignment.
DI_ITEM_TOP = 0x80000, DI_ITEM_TOP = 0x80000,
DI_ITEM_VCENTER = 0x100000, DI_ITEM_VCENTER = 0x100000,
DI_ITEM_BOTTOM = 0, // this is the default vertical alignment DI_ITEM_BOTTOM = 0, // this is the default vertical alignment
DI_ITEM_VOFFSET = 0x180000, DI_ITEM_VOFFSET = 0x180000,
DI_ITEM_VMASK = 0x180000, DI_ITEM_VMASK = 0x180000,
DI_ITEM_LEFT = 0x200000, DI_ITEM_LEFT = 0x200000,
DI_ITEM_HCENTER = 0, // this is the default horizontal alignment DI_ITEM_HCENTER = 0, // this is the default horizontal alignment
DI_ITEM_RIGHT = 0x400000, DI_ITEM_RIGHT = 0x400000,
DI_ITEM_HOFFSET = 0x600000, DI_ITEM_HOFFSET = 0x600000,
DI_ITEM_HMASK = 0x600000, DI_ITEM_HMASK = 0x600000,
DI_ITEM_LEFT_TOP = DI_ITEM_TOP|DI_ITEM_LEFT, DI_ITEM_LEFT_TOP = DI_ITEM_TOP|DI_ITEM_LEFT,
DI_ITEM_RIGHT_TOP = DI_ITEM_TOP|DI_ITEM_RIGHT, DI_ITEM_RIGHT_TOP = DI_ITEM_TOP|DI_ITEM_RIGHT,
DI_ITEM_LEFT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_LEFT, DI_ITEM_LEFT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_LEFT,
@ -71,7 +71,7 @@ class StatusBarCore native ui
DI_ITEM_CENTER = DI_ITEM_VCENTER|DI_ITEM_HCENTER, DI_ITEM_CENTER = DI_ITEM_VCENTER|DI_ITEM_HCENTER,
DI_ITEM_CENTER_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_HCENTER, DI_ITEM_CENTER_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_HCENTER,
DI_ITEM_OFFSETS = DI_ITEM_HOFFSET|DI_ITEM_VOFFSET, DI_ITEM_OFFSETS = DI_ITEM_HOFFSET|DI_ITEM_VOFFSET,
DI_TEXT_ALIGN_LEFT = 0, DI_TEXT_ALIGN_LEFT = 0,
DI_TEXT_ALIGN_RIGHT = 0x800000, DI_TEXT_ALIGN_RIGHT = 0x800000,
DI_TEXT_ALIGN_CENTER = 0x1000000, DI_TEXT_ALIGN_CENTER = 0x1000000,
@ -94,7 +94,7 @@ class StatusBarCore native ui
FNF_WHENNOTZERO = 0x1, FNF_WHENNOTZERO = 0x1,
FNF_FILLZEROS = 0x2, FNF_FILLZEROS = 0x2,
} }
// These are block properties for the drawers. A child class can set them to have a block of items use the same settings. // These are block properties for the drawers. A child class can set them to have a block of items use the same settings.
native double Alpha; native double Alpha;
native Vector2 drawOffset; // can be set by subclasses to offset drawing operations native Vector2 drawOffset; // can be set by subclasses to offset drawing operations
@ -118,17 +118,17 @@ class StatusBarCore native ui
native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0); native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0);
native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native void Fill(Color col, double x, double y, double w, double h, int flags = 0);
native void SetClipRect(double x, double y, double w, double h, int flags = 0); native void SetClipRect(double x, double y, double w, double h, int flags = 0);
native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1); native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1);
native Vector2 GetHUDScale(); native Vector2 GetHUDScale();
native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1); native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1);
native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1); native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1);
void ClearClipRect() void ClearClipRect()
{ {
screen.ClearClipRect(); screen.ClearClipRect();
} }
//============================================================================ //============================================================================
// //
// Returns how much the status bar's graphics extend into the view // Returns how much the status bar's graphics extend into the view
@ -137,7 +137,7 @@ class StatusBarCore native ui
// by the element requesting this information. // by the element requesting this information.
// //
//============================================================================ //============================================================================
virtual int GetProtrusion(double scaleratio) const virtual int GetProtrusion(double scaleratio) const
{ {
return 0; return 0;
@ -156,7 +156,7 @@ class LinearValueInterpolator : Object
{ {
int mCurrentValue; int mCurrentValue;
int mMaxChange; int mMaxChange;
static LinearValueInterpolator Create(int startval, int maxchange) static LinearValueInterpolator Create(int startval, int maxchange)
{ {
let v = new("LinearValueInterpolator"); let v = new("LinearValueInterpolator");
@ -164,12 +164,12 @@ class LinearValueInterpolator : Object
v.mMaxChange = maxchange; v.mMaxChange = maxchange;
return v; return v;
} }
void Reset(int value) void Reset(int value)
{ {
mCurrentValue = value; mCurrentValue = value;
} }
// This must be called periodically in the status bar's Tick function. // This must be called periodically in the status bar's Tick function.
// Do not call this in the Draw function because that may skip some frames! // Do not call this in the Draw function because that may skip some frames!
void Update(int destvalue) void Update(int destvalue)
@ -183,7 +183,7 @@ class LinearValueInterpolator : Object
mCurrentValue = min(destvalue, mCurrentValue + mMaxChange); mCurrentValue = min(destvalue, mCurrentValue + mMaxChange);
} }
} }
// This must be called in the draw function to retrieve the value for output. // This must be called in the draw function to retrieve the value for output.
int GetValue() int GetValue()
{ {
@ -197,8 +197,8 @@ class DynamicValueInterpolator : Object
int mMinChange; int mMinChange;
int mMaxChange; int mMaxChange;
double mChangeFactor; double mChangeFactor;
static DynamicValueInterpolator Create(int startval, double changefactor, int minchange, int maxchange) static DynamicValueInterpolator Create(int startval, double changefactor, int minchange, int maxchange)
{ {
let v = new("DynamicValueInterpolator"); let v = new("DynamicValueInterpolator");
@ -208,12 +208,12 @@ class DynamicValueInterpolator : Object
v.mChangeFactor = changefactor; v.mChangeFactor = changefactor;
return v; return v;
} }
void Reset(int value) void Reset(int value)
{ {
mCurrentValue = value; mCurrentValue = value;
} }
// This must be called periodically in the status bar's Tick function. // This must be called periodically in the status bar's Tick function.
// Do not call this in the Draw function because that may skip some frames! // Do not call this in the Draw function because that may skip some frames!
void Update(int destvalue) void Update(int destvalue)
@ -228,7 +228,7 @@ class DynamicValueInterpolator : Object
mCurrentValue = min(destvalue, mCurrentValue + diff); mCurrentValue = min(destvalue, mCurrentValue + diff);
} }
} }
// This must be called in the draw function to retrieve the value for output. // This must be called in the draw function to retrieve the value for output.
int GetValue() int GetValue()
{ {