mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- use floats for menu item coordinates. This only has an effect in the ListMenu because the OptionMenu uses fixed offsets which work differently.
This commit is contained in:
parent
c0f588e234
commit
f3b6343e53
8 changed files with 68 additions and 66 deletions
|
@ -1117,7 +1117,7 @@ DMenuItemBase * CreateOptionMenuItemControl(const char *label, FName cmd, FKeyBi
|
|||
return (DMenuItemBase*)p;
|
||||
}
|
||||
|
||||
DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FTextureID tex, FName command, int param)
|
||||
DMenuItemBase * CreateListMenuItemPatch(double x, double y, int height, int hotkey, FTextureID tex, FName command, int param)
|
||||
{
|
||||
auto c = PClass::FindClass("ListMenuItemPatchItem");
|
||||
auto p = c->CreateNew();
|
||||
|
@ -1127,7 +1127,7 @@ DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FT
|
|||
return (DMenuItemBase*)p;
|
||||
}
|
||||
|
||||
DMenuItemBase * CreateListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, 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)
|
||||
{
|
||||
auto c = PClass::FindClass("ListMenuItemTextItem");
|
||||
auto p = c->CreateNew();
|
||||
|
|
|
@ -138,11 +138,11 @@ class DListMenuDescriptor : public DMenuDescriptor
|
|||
public:
|
||||
TArray<DMenuItemBase *> mItems;
|
||||
int mSelectedItem;
|
||||
int mSelectOfsX;
|
||||
int mSelectOfsY;
|
||||
double mSelectOfsX;
|
||||
double mSelectOfsY;
|
||||
FTextureID mSelector;
|
||||
int mDisplayTop;
|
||||
int mXpos, mYpos;
|
||||
double mXpos, mYpos;
|
||||
int mWLeft, mWRight;
|
||||
int mLinespacing; // needs to be stored for dynamically created menus
|
||||
int mAutoselect; // this can only be set by internal menu creation functions
|
||||
|
@ -288,7 +288,7 @@ class DMenuItemBase : public DObject
|
|||
{
|
||||
DECLARE_CLASS(DMenuItemBase, DObject)
|
||||
public:
|
||||
int mXpos, mYpos;
|
||||
double mXpos, mYpos;
|
||||
FNameNoInit mAction;
|
||||
bool mEnabled;
|
||||
|
||||
|
@ -298,7 +298,7 @@ public:
|
|||
bool SetValue(int i, int value);
|
||||
bool GetValue(int i, int *pvalue);
|
||||
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
||||
int GetY() { return mYpos; }
|
||||
double GetY() { return mYpos; }
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -355,7 +355,7 @@ DMenuItemBase * CreateOptionMenuItemStaticText(const char *name, bool v);
|
|||
DMenuItemBase * CreateOptionMenuItemSubmenu(const char *label, FName cmd, int center);
|
||||
DMenuItemBase * CreateOptionMenuItemControl(const char *label, FName cmd, FKeyBindings *bindings);
|
||||
DMenuItemBase * CreateOptionMenuItemJoyConfigMenu(const char *label, IJoystickConfig *joy);
|
||||
DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FTextureID tex, FName command, int param);
|
||||
DMenuItemBase * CreateListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -305,11 +305,11 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
|
|||
sc.MustGetString();
|
||||
desc->mSelector = GetMenuTexture(sc.String);
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
desc->mSelectOfsX = sc.Number;
|
||||
sc.MustGetFloat();
|
||||
desc->mSelectOfsX = sc.Float;
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
desc->mSelectOfsY = sc.Number;
|
||||
sc.MustGetFloat();
|
||||
desc->mSelectOfsY = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("Linespacing"))
|
||||
{
|
||||
|
@ -318,11 +318,11 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
|
|||
}
|
||||
else if (sc.Compare("Position"))
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
desc->mXpos = sc.Number;
|
||||
sc.MustGetFloat();
|
||||
desc->mXpos = sc.Float;
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
desc->mYpos = sc.Number;
|
||||
sc.MustGetFloat();
|
||||
desc->mYpos = sc.Float;
|
||||
}
|
||||
else if (sc.Compare("Centermenu"))
|
||||
{
|
||||
|
@ -973,13 +973,13 @@ static void BuildEpisodeMenu()
|
|||
if ((*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
|
||||
{
|
||||
DListMenuDescriptor *ld = static_cast<DListMenuDescriptor*>(*desc);
|
||||
int posy = ld->mYpos;
|
||||
int posy = (int)ld->mYpos;
|
||||
int topy = posy;
|
||||
|
||||
// Get lowest y coordinate of any static item in the menu
|
||||
for(unsigned i = 0; i < ld->mItems.Size(); i++)
|
||||
{
|
||||
int y = ld->mItems[i]->GetY();
|
||||
int y = (int)ld->mItems[i]->GetY();
|
||||
if (y < topy) topy = y;
|
||||
}
|
||||
|
||||
|
@ -1073,13 +1073,13 @@ static void BuildPlayerclassMenu()
|
|||
// add player display
|
||||
ld->mSelectedItem = ld->mItems.Size();
|
||||
|
||||
int posy = ld->mYpos;
|
||||
int posy = (int)ld->mYpos;
|
||||
int topy = posy;
|
||||
|
||||
// Get lowest y coordinate of any static item in the menu
|
||||
for(unsigned i = 0; i < ld->mItems.Size(); i++)
|
||||
{
|
||||
int y = ld->mItems[i]->GetY();
|
||||
int y = (int)ld->mItems[i]->GetY();
|
||||
if (y < topy) topy = y;
|
||||
}
|
||||
|
||||
|
@ -1333,8 +1333,8 @@ void M_StartupSkillMenu(FGameStartup *gs)
|
|||
if ((*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
|
||||
{
|
||||
DListMenuDescriptor *ld = static_cast<DListMenuDescriptor*>(*desc);
|
||||
int x = ld->mXpos;
|
||||
int y = ld->mYpos;
|
||||
int x = (int)ld->mXpos;
|
||||
int y = (int)ld->mYpos;
|
||||
|
||||
// Delete previous contents
|
||||
for(unsigned i=0; i<ld->mItems.Size(); i++)
|
||||
|
@ -1363,7 +1363,7 @@ void M_StartupSkillMenu(FGameStartup *gs)
|
|||
// Get lowest y coordinate of any static item in the menu
|
||||
for(unsigned i = 0; i < ld->mItems.Size(); i++)
|
||||
{
|
||||
int y = ld->mItems[i]->GetY();
|
||||
int y = (int)ld->mItems[i]->GetY();
|
||||
if (y < topy) topy = y;
|
||||
}
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ void M_StartupSkillMenu(FGameStartup *gs)
|
|||
{
|
||||
ld->mItems[i]->OffsetPositionY(topdelta);
|
||||
}
|
||||
y = ld->mYpos = posy - topdelta;
|
||||
ld->mYpos = y = posy - topdelta;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -4,11 +4,11 @@ class ListMenuDescriptor : MenuDescriptor native
|
|||
{
|
||||
native Array<ListMenuItem> mItems;
|
||||
native int mSelectedItem;
|
||||
native int mSelectOfsX;
|
||||
native int mSelectOfsY;
|
||||
native double mSelectOfsX;
|
||||
native double mSelectOfsY;
|
||||
native TextureID mSelector;
|
||||
native int mDisplayTop;
|
||||
native int mXpos, mYpos;
|
||||
native double mXpos, mYpos;
|
||||
native int mWLeft, mWRight;
|
||||
native int mLinespacing; // needs to be stored for dynamically created menus
|
||||
native int mAutoselect; // this can only be set by internal menu creation functions
|
||||
|
@ -51,16 +51,16 @@ class ListMenu : Menu
|
|||
mDesc = desc;
|
||||
if (desc.mCenter)
|
||||
{
|
||||
int center = 160;
|
||||
double center = 160;
|
||||
for(int i=0; i < mDesc.mItems.Size(); i++)
|
||||
{
|
||||
int xpos = mDesc.mItems[i].GetX();
|
||||
double xpos = mDesc.mItems[i].GetX();
|
||||
int width = mDesc.mItems[i].GetWidth();
|
||||
int curx = mDesc.mSelectOfsX;
|
||||
double curx = mDesc.mSelectOfsX;
|
||||
|
||||
if (width > 0 && mDesc.mItems[i].Selectable())
|
||||
{
|
||||
int left = 160 - (width - curx) / 2 - curx;
|
||||
double left = 160 - (width - curx) / 2 - curx;
|
||||
if (left < center) center = left;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
class ListMenuItem : MenuItemBase
|
||||
{
|
||||
void DrawSelector(int xofs, int yofs, TextureID tex)
|
||||
void DrawSelector(double xofs, double yofs, TextureID tex)
|
||||
{
|
||||
if (tex.isNull())
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ class ListMenuItemStaticPatch : ListMenuItem
|
|||
TextureID mTexture;
|
||||
bool mCentered;
|
||||
|
||||
void Init(int x, int y, TextureID patch, bool centered = false)
|
||||
void Init(double x, double y, TextureID patch, bool centered = false)
|
||||
{
|
||||
Super.Init(x, y);
|
||||
mTexture = patch;
|
||||
|
@ -82,17 +82,17 @@ class ListMenuItemStaticPatch : ListMenuItem
|
|||
return;
|
||||
}
|
||||
|
||||
int x = mXpos;
|
||||
double x = mXpos;
|
||||
Vector2 vec = TexMan.GetScaledSize(mTexture);
|
||||
if (mYpos >= 0)
|
||||
{
|
||||
if (mCentered) x -= int(vec.X) / 2;
|
||||
if (mCentered) x -= vec.X / 2;
|
||||
screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1);
|
||||
if (mCentered) x -= (int(vec.X) * CleanXfac)/2;
|
||||
x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1);
|
||||
if (mCentered) x -= (vec.X * CleanXfac)/2;
|
||||
screen.DrawTexture (mTexture, true, x, -mYpos*CleanYfac, DTA_CleanNoMove, true);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class ListMenuItemStaticPatch : ListMenuItem
|
|||
|
||||
class ListMenuItemStaticPatchCentered : ListMenuItemStaticPatch
|
||||
{
|
||||
void Init(int x, int y, TextureID patch)
|
||||
void Init(double x, double y, TextureID patch)
|
||||
{
|
||||
Super.Init(x, y, patch, true);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class ListMenuItemStaticText : ListMenuItem
|
|||
int mColor;
|
||||
bool mCentered;
|
||||
|
||||
void Init(ListMenuDescriptor desc, int x, int y, String text, int color = Font.CR_UNTRANSLATED)
|
||||
void Init(ListMenuDescriptor desc, double x, double y, String text, int color = Font.CR_UNTRANSLATED)
|
||||
{
|
||||
Super.Init(x, y);
|
||||
mText = text;
|
||||
|
@ -128,7 +128,7 @@ class ListMenuItemStaticText : ListMenuItem
|
|||
mCentered = false;
|
||||
}
|
||||
|
||||
void InitDirect(int x, int 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);
|
||||
mText = text;
|
||||
|
@ -144,13 +144,13 @@ class ListMenuItemStaticText : ListMenuItem
|
|||
String text = Stringtable.Localize(mText);
|
||||
if (mYpos >= 0)
|
||||
{
|
||||
int x = mXpos;
|
||||
double x = mXpos;
|
||||
if (mCentered) x -= mFont.StringWidth(text)/2;
|
||||
screen.DrawText(mFont, mColor, x, mYpos, text, DTA_Clean, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int x = (mXpos - 160) * CleanXfac + (Screen.GetWidth() >> 1);
|
||||
double x = (mXpos - 160) * CleanXfac + (Screen.GetWidth() >> 1);
|
||||
if (mCentered) x -= (mFont.StringWidth(text) * CleanXfac)/2;
|
||||
screen.DrawText (mFont, mColor, x, -mYpos*CleanYfac, text, DTA_CleanNoMove, true);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ class ListMenuItemStaticText : ListMenuItem
|
|||
|
||||
class ListMenuItemStaticTextCentered : ListMenuItemStaticText
|
||||
{
|
||||
void Init(ListMenuDescriptor desc, int x, int y, String text, int color = -1)
|
||||
void Init(ListMenuDescriptor desc, double x, double y, String text, int color = -1)
|
||||
{
|
||||
Super.Init(desc, x, y, text, color);
|
||||
mCentered = true;
|
||||
|
@ -179,7 +179,7 @@ class ListMenuItemSelectable : ListMenuItem
|
|||
int mHeight;
|
||||
int mParam;
|
||||
|
||||
protected void Init(int x, int y, int height, Name childmenu, int param = -1)
|
||||
protected void Init(double x, double y, int height, Name childmenu, int param = -1)
|
||||
{
|
||||
Super.Init(x, y, childmenu);
|
||||
mHeight = height;
|
||||
|
@ -250,7 +250,7 @@ class ListMenuItemTextItem : ListMenuItemSelectable
|
|||
mHotkey = hotkey.CharCodeAt(0);
|
||||
}
|
||||
|
||||
void InitDirect(int x, int 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);
|
||||
mText = text;
|
||||
|
@ -288,7 +288,7 @@ class ListMenuItemPatchItem : ListMenuItemSelectable
|
|||
mTexture = patch;
|
||||
}
|
||||
|
||||
void InitDirect(int x, int 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);
|
||||
mHotkey = hotkey.CharCodeAt(0);
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
class MenuItemBase : Object native
|
||||
{
|
||||
protected native int mXpos, mYpos;
|
||||
protected native double mXpos, mYpos;
|
||||
protected native Name mAction;
|
||||
native bool mEnabled;
|
||||
|
||||
void Init(int xpos = 0, int ypos = 0, Name actionname = 'None')
|
||||
void Init(double xpos = 0, double ypos = 0, Name actionname = 'None')
|
||||
{
|
||||
mXpos = xpos;
|
||||
mYpos = ypos;
|
||||
|
@ -36,10 +36,10 @@ class MenuItemBase : Object native
|
|||
virtual int GetIndent() { return 0; }
|
||||
virtual int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { return indent; }
|
||||
|
||||
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
||||
int GetY() { return mYpos; }
|
||||
int GetX() { return mXpos; }
|
||||
void SetX(int x) { mXpos = x; }
|
||||
void OffsetPositionY(double ydelta) { mYpos += ydelta; }
|
||||
double GetY() { return mYpos; }
|
||||
double GetX() { return mXpos; }
|
||||
void SetX(double x) { mXpos = x; }
|
||||
}
|
||||
|
||||
// this is only used to parse font color ranges in MENUDEF
|
||||
|
|
|
@ -71,7 +71,7 @@ class ListMenuItemPlayerNameBox : ListMenuItemSelectable
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void InitDirect(int x, int y, int height, int frameofs, String text, Font font, int color, Name command)
|
||||
void InitDirect(double x, double y, int height, int frameofs, String text, Font font, int color, Name command)
|
||||
{
|
||||
Super.Init(x, y, height, command);
|
||||
mText = text;
|
||||
|
@ -113,7 +113,7 @@ class ListMenuItemPlayerNameBox : ListMenuItemSelectable
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
protected void DrawBorder (int x, int y, int len)
|
||||
protected void DrawBorder (double x, double y, int len)
|
||||
{
|
||||
let left = TexMan.CheckForTexture("M_LSLEFT", TexMan.Type_MiscPatch);
|
||||
let mid = TexMan.CheckForTexture("M_LSCNTR", TexMan.Type_MiscPatch);
|
||||
|
@ -141,7 +141,9 @@ class ListMenuItemPlayerNameBox : ListMenuItemSelectable
|
|||
}
|
||||
else
|
||||
{
|
||||
screen.Clear(x, y, x + len, y + SmallFont.GetHeight() * 3/2, 0);
|
||||
int xx = int(x - 160) * CleanXfac + screen.GetWidth()/2;
|
||||
int yy = int(y - 100) * CleanXfac + screen.GetHeight()/2;
|
||||
screen.Clear(xx, yy, xx + len*CleanXfac, yy + SmallFont.GetHeight() * CleanYfac * 3/2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +163,7 @@ class ListMenuItemPlayerNameBox : ListMenuItemSelectable
|
|||
}
|
||||
|
||||
// Draw player name box
|
||||
int x = mXpos + mFont.StringWidth(text) + 16 + mFrameSize;
|
||||
double x = mXpos + mFont.StringWidth(text) + 16 + mFrameSize;
|
||||
DrawBorder (x, mYpos - mFrameSize, MAXPLAYERNAME+1);
|
||||
if (!mEnter)
|
||||
{
|
||||
|
@ -246,7 +248,7 @@ class ListMenuItemValueText : ListMenuItemSelectable
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void InitDirect(int x, int y, int height, String text, Font font, int color, int valuecolor, Name command, Name values)
|
||||
void InitDirect(double x, double y, int height, String text, Font font, int color, int valuecolor, Name command, Name values)
|
||||
{
|
||||
Super.Init(x, y, height, command);
|
||||
mText = text;
|
||||
|
@ -337,7 +339,7 @@ class ListMenuItemValueText : ListMenuItemSelectable
|
|||
String text = Stringtable.Localize(mText);
|
||||
screen.DrawText(mFont, selected? OptionMenuSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true);
|
||||
|
||||
int x = mXpos + mFont.StringWidth(text) + 8;
|
||||
double x = mXpos + mFont.StringWidth(text) + 8;
|
||||
if (mSelections.Size() > 0)
|
||||
{
|
||||
screen.DrawText(mFont, mFontColor2, x, mYpos, mSelections[mSelection], DTA_Clean, true);
|
||||
|
@ -385,7 +387,7 @@ class ListMenuItemSlider : ListMenuItemSelectable
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void InitDirect(int x, int y, int height, String text, Font font, int color, Name command, int min, int max, int step)
|
||||
void InitDirect(double x, double y, int height, String text, Font font, int color, Name command, int min, int max, int step)
|
||||
{
|
||||
Super.Init(x, y, height, command);
|
||||
mText = text;
|
||||
|
@ -463,7 +465,7 @@ class ListMenuItemSlider : ListMenuItemSelectable
|
|||
lm.ReleaseFocus();
|
||||
}
|
||||
|
||||
int slide_left = SmallFont.StringWidth ("Green") + 8 + mXpos;
|
||||
int slide_left = SmallFont.StringWidth ("Green") + 8 + int(mXpos);
|
||||
int slide_right = slide_left + 12*8; // 12 char cells with 8 pixels each.
|
||||
|
||||
if (type == Menu.MOUSE_Click)
|
||||
|
@ -491,7 +493,7 @@ class ListMenuItemSlider : ListMenuItemSelectable
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
protected void DrawSlider (int x, int y)
|
||||
protected void DrawSlider (double x, double y)
|
||||
{
|
||||
int range = mMaxrange - mMinrange;
|
||||
int cur = mSelection - mMinrange;
|
||||
|
@ -515,8 +517,8 @@ class ListMenuItemSlider : ListMenuItemSelectable
|
|||
|
||||
screen.DrawText(mFont, selected? OptionMenuSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true);
|
||||
|
||||
int x = SmallFont.StringWidth ("Green") + 8 + mXpos;
|
||||
int x2 = SmallFont.StringWidth (text) + 8 + mXpos;
|
||||
double x = SmallFont.StringWidth ("Green") + 8 + mXpos;
|
||||
double x2 = SmallFont.StringWidth (text) + 8 + mXpos;
|
||||
DrawSlider (MAX(x2, x), mYpos);
|
||||
}
|
||||
}
|
|
@ -252,8 +252,8 @@ class ListMenuItemPlayerDisplay : ListMenuItem
|
|||
}
|
||||
else
|
||||
{
|
||||
int x = (mXpos - 160) * CleanXfac + (screen.GetWidth() >> 1);
|
||||
int y = (mYpos - 100) * CleanYfac + (screen.GetHeight() >> 1);
|
||||
int x = int(mXpos - 160) * CleanXfac + (screen.GetWidth() >> 1);
|
||||
int y = int(mYpos - 100) * CleanYfac + (screen.GetHeight() >> 1);
|
||||
|
||||
screen.DrawTexture(mBackdrop, false, x, y - 1,
|
||||
DTA_DestWidth, 72 * CleanXfac,
|
||||
|
|
Loading…
Reference in a new issue