- Backend update from Raze.

This commit is contained in:
Christoph Oelckers 2020-10-07 16:00:39 +02:00
parent 3ea0658449
commit b8281f4758
21 changed files with 249 additions and 83 deletions

View file

@ -461,10 +461,10 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
if (x < (double)parms.lclip || y < (double)parms.uclip || x + w >(double)parms.rclip || y + h >(double)parms.dclip)
{
dg.mScissor[0] = parms.lclip;
dg.mScissor[1] = parms.uclip;
dg.mScissor[2] = parms.rclip;
dg.mScissor[3] = parms.dclip;
dg.mScissor[0] = parms.lclip + int(offset.X);
dg.mScissor[1] = parms.uclip + int(offset.Y);
dg.mScissor[2] = parms.rclip + int(offset.X);
dg.mScissor[3] = parms.dclip + int(offset.Y);
dg.mFlags |= DTF_Scissor;
}
else
@ -475,10 +475,10 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
dg.mVertCount = 4;
dg.mVertIndex = (int)mVertices.Reserve(4);
TwoDVertex* ptr = &mVertices[dg.mVertIndex];
ptr->Set(x, y, 0, u1, v1, vertexcolor); ptr++;
ptr->Set(x, y + h, 0, u1, v2, vertexcolor); ptr++;
ptr->Set(x + w, y, 0, u2, v1, vertexcolor); ptr++;
ptr->Set(x + w, y + h, 0, u2, v2, vertexcolor); ptr++;
Set(ptr, x, y, 0, u1, v1, vertexcolor); ptr++;
Set(ptr, x, y + h, 0, u1, v2, vertexcolor); ptr++;
Set(ptr, x + w, y, 0, u2, v1, vertexcolor); ptr++;
Set(ptr, x + w, y + h, 0, u2, v2, vertexcolor); ptr++;
}
else
{
@ -502,19 +502,19 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
double x4 = parms.x + xscale * (xd2 * cosang + yd2 * sinang);
double y4 = parms.y - yscale * (xd2 * sinang - yd2 * cosang);
dg.mScissor[0] = parms.lclip;
dg.mScissor[1] = parms.uclip;
dg.mScissor[2] = parms.rclip;
dg.mScissor[3] = parms.dclip;
dg.mScissor[0] = parms.lclip + int(offset.X);
dg.mScissor[1] = parms.uclip + int(offset.Y);
dg.mScissor[2] = parms.rclip + int(offset.X);
dg.mScissor[3] = parms.dclip + int(offset.Y);
dg.mFlags |= DTF_Scissor;
dg.mVertCount = 4;
dg.mVertIndex = (int)mVertices.Reserve(4);
TwoDVertex* ptr = &mVertices[dg.mVertIndex];
ptr->Set(x1, y1, 0, u1, v1, vertexcolor); ptr++;
ptr->Set(x2, y2, 0, u1, v2, vertexcolor); ptr++;
ptr->Set(x3, y3, 0, u2, v1, vertexcolor); ptr++;
ptr->Set(x4, y4, 0, u2, v2, vertexcolor); ptr++;
Set(ptr, x1, y1, 0, u1, v1, vertexcolor); ptr++;
Set(ptr, x2, y2, 0, u1, v2, vertexcolor); ptr++;
Set(ptr, x3, y3, 0, u2, v1, vertexcolor); ptr++;
Set(ptr, x4, y4, 0, u2, v2, vertexcolor); ptr++;
}
dg.mIndexIndex = mIndices.Size();
@ -571,10 +571,10 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
}
if (minx < (double)parms.lclip || miny < (double)parms.uclip || maxx >(double)parms.rclip || maxy >(double)parms.dclip)
{
dg.mScissor[0] = parms.lclip;
dg.mScissor[1] = parms.uclip;
dg.mScissor[2] = parms.rclip;
dg.mScissor[3] = parms.dclip;
dg.mScissor[0] = parms.lclip + int(offset.X);
dg.mScissor[1] = parms.uclip + int(offset.Y);
dg.mScissor[2] = parms.rclip + int(offset.X);
dg.mScissor[3] = parms.dclip + int(offset.Y);
dg.mFlags |= DTF_Scissor;
}
else
@ -583,7 +583,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
dg.mVertIndex = (int)mVertices.Reserve(dg.mVertCount);
TwoDVertex *ptr = &mVertices[dg.mVertIndex];
for ( int i=0; i<dg.mVertCount; i++ )
ptr[i].Set(shape->mTransformedVertices[i].X, shape->mTransformedVertices[i].Y, 0, shape->mCoords[i].X, shape->mCoords[i].Y, vertexcolor);
Set(&ptr[i], shape->mTransformedVertices[i].X, shape->mTransformedVertices[i].Y, 0, shape->mCoords[i].X, shape->mCoords[i].Y, vertexcolor);
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += shape->mIndices.Size();
for ( int i=0; i<int(shape->mIndices.Size()); i+=3 )
@ -655,7 +655,7 @@ void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
u = t * cosrot - v * sinrot;
v = v * cosrot + t * sinrot;
}
mVertices[poly.mVertIndex+i].Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale, color0);
Set(&mVertices[poly.mVertIndex+i], points[i].X, points[i].Y, 0, u*uscale, v*vscale, color0);
}
poly.mIndexIndex = mIndices.Size();
@ -694,10 +694,10 @@ void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigne
dg.mType = DrawTypeTriangles;
if (clipx1 > 0 || clipy1 > 0 || clipx2 < GetWidth() - 1 || clipy2 < GetHeight() - 1)
{
dg.mScissor[0] = clipx1;
dg.mScissor[1] = clipy1;
dg.mScissor[2] = clipx2 + 1;
dg.mScissor[3] = clipy2 + 1;
dg.mScissor[0] = clipx1 + int(offset.X);
dg.mScissor[1] = clipy1 + int(offset.Y);
dg.mScissor[2] = clipx2 + 1 + int(offset.X);
dg.mScissor[3] = clipy2 + 1 + int(offset.Y);
dg.mFlags |= DTF_Scissor;
}
@ -712,7 +712,7 @@ void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigne
for (size_t i=0;i<vtcount;i++)
{
ptr->Set(vt[i].X, vt[i].Y, 0.f, vt[i].Z, vt[i].W, color);
Set(ptr, vt[i].X, vt[i].Y, 0.f, vt[i].Z, vt[i].W, color);
ptr++;
}
@ -841,18 +841,18 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
dg.mVertIndex = (int)mVertices.Reserve(4);
auto ptr = &mVertices[dg.mVertIndex];
ptr->Set(left, top, 0, fU1, fV1, color); ptr++;
Set(ptr, left, top, 0, fU1, fV1, color); ptr++;
if (local_origin < 4)
{
ptr->Set(left, bottom, 0, fU1, fV2, color); ptr++;
ptr->Set(right, top, 0, fU2, fV1, color); ptr++;
Set(ptr, left, bottom, 0, fU1, fV2, color); ptr++;
Set(ptr, right, top, 0, fU2, fV1, color); ptr++;
}
else
{
ptr->Set(left, bottom, 0, fU2, fV1, color); ptr++;
ptr->Set(right, top, 0, fU1, fV2, color); ptr++;
Set(ptr, left, bottom, 0, fU2, fV1, color); ptr++;
Set(ptr, right, top, 0, fU1, fV2, color); ptr++;
}
ptr->Set(right, bottom, 0, fU2, fV2, color); ptr++;
Set(ptr, right, bottom, 0, fU2, fV2, color); ptr++;
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6;
AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2);
@ -875,10 +875,10 @@ void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, F
dg.mVertIndex = (int)mVertices.Reserve(4);
dg.mRenderStyle = style? *style : LegacyRenderStyles[STYLE_Translucent];
auto ptr = &mVertices[dg.mVertIndex];
ptr->Set(x1, y1, 0, 0, 0, color); ptr++;
ptr->Set(x1, y1 + h, 0, 0, 0, color); ptr++;
ptr->Set(x1 + w, y1, 0, 0, 0, color); ptr++;
ptr->Set(x1 + w, y1 + h, 0, 0, 0, color); ptr++;
Set(ptr, x1, y1, 0, 0, 0, color); ptr++;
Set(ptr, x1, y1 + h, 0, 0, 0, color); ptr++;
Set(ptr, x1 + w, y1, 0, 0, 0, color); ptr++;
Set(ptr, x1 + w, y1 + h, 0, 0, 0, color); ptr++;
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6;
AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2);
@ -911,10 +911,10 @@ void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1,
if (clipx1 > 0 || clipy1 > 0 || clipx2 < GetWidth()- 1 || clipy2 < GetHeight() - 1)
{
dg.mScissor[0] = clipx1;
dg.mScissor[1] = clipy1;
dg.mScissor[2] = clipx2 + 1;
dg.mScissor[3] = clipy2 + 1;
dg.mScissor[0] = clipx1 + int(offset.X);
dg.mScissor[1] = clipy1 + int(offset.Y);
dg.mScissor[2] = clipx2 + 1 + int(offset.X);
dg.mScissor[3] = clipy2 + 1 + int(offset.Y);
dg.mFlags |= DTF_Scissor;
}
@ -922,8 +922,8 @@ void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1,
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];
dg.mVertCount = 2;
dg.mVertIndex = (int)mVertices.Reserve(2);
mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p);
mVertices[dg.mVertIndex+1].Set(x2, y2, 0, 0, 0, p);
Set(&mVertices[dg.mVertIndex], x1, y1, 0, 0, 0, p);
Set(&mVertices[dg.mVertIndex+1], x2, y2, 0, 0, 0, p);
AddCommand(&dg);
}
@ -958,10 +958,10 @@ void F2DDrawer::AddThickLine(int x1, int y1, int x2, int y2, double thickness, u
dg.mVertIndex = (int)mVertices.Reserve(4);
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];
auto ptr = &mVertices[dg.mVertIndex];
ptr->Set(corner0.X, corner0.Y, 0, 0, 0, p); ptr++;
ptr->Set(corner1.X, corner1.Y, 0, 0, 0, p); ptr++;
ptr->Set(corner2.X, corner2.Y, 0, 0, 0, p); ptr++;
ptr->Set(corner3.X, corner3.Y, 0, 0, 0, p); ptr++;
Set(ptr, corner0.X, corner0.Y, 0, 0, 0, p); ptr++;
Set(ptr, corner1.X, corner1.Y, 0, 0, 0, p); ptr++;
Set(ptr, corner2.X, corner2.Y, 0, 0, 0, p); ptr++;
Set(ptr, corner3.X, corner3.Y, 0, 0, 0, p); ptr++;
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6;
AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2);
@ -985,7 +985,7 @@ void F2DDrawer::AddPixel(int x1, int y1, uint32_t color)
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];
dg.mVertCount = 1;
dg.mVertIndex = (int)mVertices.Reserve(1);
mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p);
Set(&mVertices[dg.mVertIndex], x1, y1, 0, 0, 0, p);
AddCommand(&dg);
}

View file

@ -167,6 +167,7 @@ public:
bool isIn2D;
bool locked; // prevents clearing of the data so it can be reused multiple times (useful for screen fades)
float screenFade = 1.f;
DVector2 offset;
public:
int fullscreenautoaspect = 0;
int cliptop = -1, clipleft = -1, clipwidth = -1, clipheight = -1;
@ -216,6 +217,19 @@ public:
void SetClipRect(int x, int y, int w, int h);
void GetClipRect(int* x, int* y, int* w, int* h);
DVector2 SetOffset(const DVector2& vec)
{
auto v = offset;
offset = vec;
return v;
}
void Set(TwoDVertex* v, double xx, double yy, double zz, double uu, double vv, PalEntry col)
{
v->Set(xx + offset.X, yy + offset.Y, zz, uu, vv, col);
}
int DrawCount() const
{
return mData.Size();

View file

@ -99,7 +99,7 @@ SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels,
{
int flags = 0;
if (numchannels < 2) flags |= SoundStream::Mono;
auto stream = GSnd->CreateStream(cb, size, flags, samplerate, userdata);
auto stream = GSnd->CreateStream(cb, int(size), flags, samplerate, userdata);
if (stream) stream->Play(true, 1);
return stream;
}

View file

@ -81,5 +81,6 @@ struct doomcom_t
extern doomcom_t doomcom;
extern bool netgame, multiplayer;
extern int consoleplayer;
#endif

View file

@ -715,8 +715,10 @@ xx(MainmenuTextOnly)
xx(Episodemenu)
xx(Playerclassmenu)
xx(HexenDefaultPlayerclassmenu)
xx(ListMenuItemBloodDripDrawer)
xx(Skillmenu)
xx(Startgame)
xx(StartgameNoSkill)
xx(StartgameConfirm)
xx(StartgameConfirmed)
xx(Loadgamemenu)
@ -1078,6 +1080,7 @@ xx(PlayerSkin)
xx(NewPlayerMenu)
xx(AltHud)
xx(GameScreen)
xx(ListM)
// summary
xx(cwidth)
@ -1086,3 +1089,11 @@ xx(wrapwidth)
xx(scalefactorx)
xx(scalefactory)
xx(scalemode)
xy(menu_cursor, "menu/cursor")
xy(menu_choose, "menu/choose")
xy(menu_backup, "menu/backup")
xy(menu_clear, "menu/clear")
xy(menu_dismiss, "menu/dismiss")
xy(menu_change, "menu/change")
xy(menu_advance, "menu/advance")

View file

@ -1044,8 +1044,8 @@ bool FScanner::ScanValue(bool allowfloat, bool evaluate)
auto d = constants.CheckKey(String);
if (!d) return false;
if (!allowfloat && int64_t(*d) != *d) return false;
BigNumber = *d;
Number = *d;
BigNumber = int64_t(*d);
Number = int(*d);
Float = *d;
}
if (neg)
@ -1231,8 +1231,8 @@ void FScanner::AddSymbol(const char *name, int64_t value)
{
Symbol sym;
sym.tokenType = TK_IntConst;
sym.Number = value;
sym.Float = value;
sym.Number = int(value);
sym.Float = double(value);
symbols.Insert(name, sym);
}

View file

@ -100,7 +100,7 @@ float BackbuttonAlpha;
static bool MenuEnabled = true;
DMenu *CurrentMenu;
int MenuTime;
DObject* menuCustomizer;
DObject* menuDelegate;
extern PClass *DefaultListMenuClass;
@ -192,9 +192,61 @@ void M_MarkMenus()
GC::Mark(pair->Value);
}
GC::Mark(CurrentMenu);
GC::Mark(menuCustomizer);
GC::Mark(menuDelegate);
}
//============================================================================
//
// Transition animation
//
//============================================================================
static MenuTransition transition;
bool MenuTransition::StartTransition(DMenu* from, DMenu* to, MenuTransitionType animtype)
{
if (!from->canAnimate() || !to->canAnimate() || animtype == MA_None)
{
return false;
}
else
{
start = I_GetTimeNS() * (120. / 1'000'000'000.);
length = 30;
dir = animtype == MA_Advance ? 1 : -1;
previous = from;
current = to;
if (from) GC::AddSoftRoot(from);
if (to) GC::AddSoftRoot(to);
return true;
}
}
bool MenuTransition::Draw()
{
double now = I_GetTimeNS() * (120. / 1'000'000'000);
if (now < start + length)
{
double factor = 120 * screen->GetWidth() / screen->GetHeight();
double phase = (now - start) / double(length) * M_PI + M_PI / 2;
DVector2 origin;
origin.Y = 0;
origin.X = factor * dir * (sin(phase) - 1.);
twod->SetOffset(origin);
previous->CallDrawer();
origin.X = factor * dir * (sin(phase) + 1.);
twod->SetOffset(origin);
current->CallDrawer();
return true;
}
if (previous) GC::DelSoftRoot(previous);
if (current) GC::DelSoftRoot(current);
return false;
}
//============================================================================
//
// DMenu base class
@ -299,6 +351,13 @@ void DMenu::Close ()
if (CurrentMenu == nullptr) return; // double closing can happen in the save menu.
assert(CurrentMenu == this);
CurrentMenu = mParentMenu;
if (false)// todo: && mParentMenu && transition.StartTransition(this, mParentMenu, MA_Return))
{
return;
}
else
{
Destroy();
if (CurrentMenu != nullptr)
{
@ -315,6 +374,7 @@ void DMenu::Close ()
M_ClearMenus();
}
}
}
static void Close(DMenu *menu)
@ -407,11 +467,15 @@ void M_DoStartControlPanel (bool scaleoverride)
void M_ActivateMenu(DMenu *menu)
{
if (menuactive == MENU_Off) menuactive = MENU_On;
if (CurrentMenu != nullptr && CurrentMenu->mMouseCapture)
if (CurrentMenu != nullptr)
{
if (CurrentMenu->mMouseCapture)
{
CurrentMenu->mMouseCapture = false;
I_ReleaseMouseCapture();
}
//transition.StartTransition(CurrentMenu, menu, MA_Advance);
}
CurrentMenu = menu;
GC::WriteBarrier(CurrentMenu);
}
@ -888,7 +952,7 @@ DEFINE_GLOBAL(menuactive)
DEFINE_GLOBAL(BackbuttonTime)
DEFINE_GLOBAL(BackbuttonAlpha)
DEFINE_GLOBAL(GameTicRate)
DEFINE_GLOBAL(menuCustomizer)
DEFINE_GLOBAL(menuDelegate)
DEFINE_FIELD(DMenu, mParentMenu)
DEFINE_FIELD(DMenu, mMouseCapture);
@ -1027,6 +1091,17 @@ DMenuItemBase * CreateListMenuItemText(double x, double y, int height, int hotke
return (DMenuItemBase*)p;
}
DMenuItemBase* CreateListMenuItemStaticText(double x, double y, const char* text, FFont* font, PalEntry color, bool centered)
{
auto c = PClass::FindClass("ListMenuItemStaticText");
auto p = c->CreateNew();
FString textstr = text;
VMValue params[] = { p, x, y, &textstr, font, int(color.d), centered };
auto f = dyn_cast<PFunction>(c->FindSymbol("InitDirect", false));
VMCall(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
return (DMenuItemBase*)p;
}
bool DMenuItemBase::Activate()
{
IFVIRTUAL(DMenuItemBase, Activate)

View file

@ -47,7 +47,7 @@ class DMenu;
extern DMenu *CurrentMenu;
extern int MenuTime;
class DMenuItemBase;
extern DObject* menuCustomizer;
extern DObject* menuDelegate;
//=============================================================================
//
@ -165,6 +165,31 @@ struct FMenuRect
};
enum MenuTransitionType
{ // Note: This enum is for logical categories, not visual types.
MA_None,
MA_Return,
MA_Advance,
};
class DMenu;
struct MenuTransition
{
DMenu* previous;
DMenu* current;
double start;
int32_t length;
int32_t dir;
bool StartTransition(DMenu* from, DMenu* to, MenuTransitionType animtype);
bool Draw();
};
class DMenu : public DObject
{
DECLARE_CLASS (DMenu, DObject)
@ -195,6 +220,7 @@ public:
bool CallMenuEvent(int mkey, bool fromcontroller);
void CallTicker();
void CallDrawer();
bool canAnimate() { return false; }
};
//=============================================================================
@ -209,7 +235,7 @@ class DMenuItemBase : public DObject
public:
double mXpos, mYpos;
FName mAction;
bool mEnabled;
int mEnabled;
bool Activate();
bool SetString(int i, const char *s);
@ -277,6 +303,7 @@ DMenuItemBase * CreateOptionMenuItemJoyConfigMenu(const char *label, IJoystickCo
DMenuItemBase * CreateListMenuItemPatch(double x, double y, int height, int hotkey, FTextureID tex, FName command, int param);
DMenuItemBase * CreateListMenuItemText(double x, double y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param);
DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool centered = false);
DMenuItemBase* CreateListMenuItemStaticText(double x, double y, const char* text, FFont* font, PalEntry color, bool centered = false);
void UpdateVRModes(bool considerQuadBuffered=true);

View file

@ -151,10 +151,10 @@ void DeinitMenus()
}
MenuDescriptors.Clear();
OptionValues.Clear();
if (menuCustomizer)
if (menuDelegate)
{
menuCustomizer->Destroy();
menuCustomizer = nullptr;
menuDelegate->Destroy();
menuDelegate = nullptr;
}
}

View file

@ -355,6 +355,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetCursor, GetCursor)
ACTION_RETURN_STRING(FString(self->GetCursor()));
}
static int GetGlyphHeight(FFont* fnt, int code)
{
auto glyph = fnt->GetChar(code, CR_UNTRANSLATED, nullptr);
return glyph ? (int)glyph->GetDisplayHeight() : 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetGlyphHeight, GetGlyphHeight)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_INT(code);
ACTION_RETURN_INT(GetGlyphHeight(self, code));
}
//==========================================================================
//
// file system

View file

@ -265,6 +265,11 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
}
}
}
if (!(flags & TEXMAN_NoAlias))
{
int* alias = aliases.CheckKey(name);
if (alias) return FTextureID(*alias);
}
return FTextureID(-1);
}
@ -1539,6 +1544,19 @@ void FTextureManager::SetTranslation(FTextureID fromtexnum, FTextureID totexnum)
}
//-----------------------------------------------------------------------------
//
// Adds an alias name to the texture manager.
// Aliases are only checked if no real texture with the given name exists.
//
//-----------------------------------------------------------------------------
void FTextureManager::AddAlias(const char* name, FGameTexture* tex)
{
FTextureID id = tex->GetID();
if (tex != Textures[id.GetIndex()].Texture || !tex->isValid()) return; // Whatever got passed in here was not valid, so ignore the alias.
aliases.Insert(name, id.GetIndex());
}
//==========================================================================
//

View file

@ -89,7 +89,8 @@ public:
TEXMAN_ShortNameOnly = 16,
TEXMAN_DontCreate = 32,
TEXMAN_Localize = 64,
TEXMAN_ForceLookup = 128
TEXMAN_ForceLookup = 128,
TEXMAN_NoAlias = 256,
};
enum
@ -144,6 +145,8 @@ public:
tmanips.Remove(cname);
}
void AddAlias(const char* name, FGameTexture* tex);
private:
// texture counting
@ -190,6 +193,7 @@ private:
TArray<int> Translation;
TMap<FName, TextureManipulation> tmanips;
TMap<FName, int> aliases;
public:

View file

@ -73,8 +73,10 @@ bool FName::NameManager::Inited;
static const char *PredefinedNames[] =
{
#define xx(n) #n,
#define xy(n, s) s,
#include "namedef.h"
#undef xx
#undef xy
};
// CODE --------------------------------------------------------------------

View file

@ -40,8 +40,10 @@
enum ENamedName
{
#define xx(n) NAME_##n,
#define xy(n, s) NAME_##n,
#include "namedef.h"
#undef xx
#undef xy
};
class FString;

View file

@ -1262,8 +1262,8 @@ void SetDefaultMenuColors()
OptionSettings.mFontColorHighlight = V_FindFontColor(gameinfo.mFontColorHighlight);
OptionSettings.mFontColorSelection = V_FindFontColor(gameinfo.mFontColorSelection);
auto cls = PClass::FindClass("MenuCustomize");
menuCustomizer = cls->CreateNew();
auto cls = PClass::FindClass("MenuDelegateBase");
menuDelegate = cls->CreateNew();
}
CCMD (menu_main)

View file

@ -176,7 +176,7 @@ struct _ native // These are the global variables, the struct is only here to av
native readonly @MusPlayingInfo musplaying;
native readonly bool generic_ui;
native readonly int GameTicRate;
native MenuCustomize menuCustomizer;
native MenuDelegateBase menuDelegate;
native readonly int consoleplayer;
}

View file

@ -265,7 +265,7 @@ class ListMenu : Menu
{
for(int i=0;i<mDesc.mItems.Size(); i++)
{
if (mDesc.mItems[i].mEnabled) mDesc.mItems[i].Draw(mDesc.mSelectedItem == i, mDesc);
if (mDesc.mItems[i].mEnabled > 0) 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);

View file

@ -224,7 +224,7 @@ class ListMenuItemSelectable : ListMenuItem
override bool Selectable()
{
return mEnabled;
return mEnabled > 0;
}
override bool CheckHotkey(int c)

View file

@ -1,6 +1,6 @@
// This class allows global customization of certain menu aspects, e.g. replacing the menu caption.
class MenuCustomize
class MenuDelegateBase
{
virtual int DrawCaption(String title, Font fnt, int y, bool drawit)
{

View file

@ -8,7 +8,7 @@ class MenuItemBase : Object native ui version("2.4")
{
protected native double mXpos, mYpos;
protected native Name mAction;
native bool mEnabled;
native int mEnabled;
void Init(double xpos = 0, double ypos = 0, Name actionname = 'None')
{

View file

@ -433,7 +433,7 @@ class OptionMenu : Menu
let font = generic_ui || !mDesc.mFont ? NewSmallFont : mDesc.mFont;
if (font && mDesc.mTitle.Length() > 0)
{
return menuCustomizer.DrawCaption(title, font, y, drawit);
return menuDelegate.DrawCaption(title, font, y, drawit);
}
else
{