- fixed text input menu and y-positioning of option menus.

This commit is contained in:
Christoph Oelckers 2020-01-05 12:12:14 +01:00
parent bddcde73f4
commit b6862cfd70
3 changed files with 22 additions and 12 deletions

View File

@ -647,6 +647,8 @@ class DOptionMenu : public DMenu
protected:
FOptionMenuDescriptor *mDesc;
int GetPosition();
public:
FOptionMenuItem *GetItem(FName name);
DOptionMenu(DMenu *parent = NULL, FOptionMenuDescriptor *desc = NULL);

View File

@ -74,6 +74,11 @@ void DrawOptionText(int x, int y, int color, const char *text, bool grayed)
DrawText (twod, OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, TAG_END);
}
int DOptionMenu::GetPosition()
{
return mDesc->mPosition * screen->GetHeight() / 1080; // y position uses a 1920x1080 screen as reference but has to adjust to scaled 320x200 content.
}
//=============================================================================
//
//
@ -210,7 +215,7 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller)
if (mDesc->mSelectedItem < 0)
{
// Figure out how many lines of text fit on the menu
int y = mDesc->mPosition;
int y = GetPosition();
y *= CleanYfac_1;
int rowheight = OptionSettings.mLinespacing * CleanYfac_1;
@ -394,7 +399,7 @@ int DOptionMenu::GetIndent()
void DOptionMenu::Drawer ()
{
int y = mDesc->mPosition;
int y = GetPosition();
if (mDesc->mTitle.IsNotEmpty())
{

View File

@ -876,12 +876,14 @@ public:
FString Represent() override
{
FString text = mEntering ? mEditName : FString(GetCVarString());
if ( mEntering )
if (mEntering)
{
FString text;
text = mInput->GetText();
text += '_';
return text;
return text;
}
else return FString(GetCVarString());
}
int Draw(FOptionMenuDescriptor*desc, int y, int indent, bool selected) override
@ -902,10 +904,9 @@ public:
if ( mkey == MKEY_Enter )
{
M_MenuSound(AdvanceSound);
mEditName = GetCVarString();
mEntering = true;
DMenu* input = new DTextEnterMenu(DMenu::CurrentMenu, NewSmallFont, mEditName, 256, fromcontroller );
M_ActivateMenu( input );
mInput = new DTextEnterMenu(DMenu::CurrentMenu, NewSmallFont, GetCVarString(), 256, fromcontroller );
M_ActivateMenu( mInput );
return true;
}
else if ( mkey == MKEY_Input )
@ -913,16 +914,18 @@ public:
if ( mCVar )
{
UCVarValue vval;
vval.String = mEditName;
vval.String = mInput->GetText();
mCVar->SetGenericRep( vval, CVAR_String );
}
mEntering = false;
mInput = nullptr;
return true;
}
else if ( mkey == MKEY_Abort )
{
mEntering = false;
mInput = nullptr;
return true;
}
@ -931,7 +934,7 @@ public:
private:
bool mEntering;
FString mEditName;
DTextEnterMenu* mInput;
};
//=============================================================================