- 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: protected:
FOptionMenuDescriptor *mDesc; FOptionMenuDescriptor *mDesc;
int GetPosition();
public: public:
FOptionMenuItem *GetItem(FName name); FOptionMenuItem *GetItem(FName name);
DOptionMenu(DMenu *parent = NULL, FOptionMenuDescriptor *desc = NULL); 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); 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) if (mDesc->mSelectedItem < 0)
{ {
// Figure out how many lines of text fit on the menu // Figure out how many lines of text fit on the menu
int y = mDesc->mPosition; int y = GetPosition();
y *= CleanYfac_1; y *= CleanYfac_1;
int rowheight = OptionSettings.mLinespacing * CleanYfac_1; int rowheight = OptionSettings.mLinespacing * CleanYfac_1;
@ -394,7 +399,7 @@ int DOptionMenu::GetIndent()
void DOptionMenu::Drawer () void DOptionMenu::Drawer ()
{ {
int y = mDesc->mPosition; int y = GetPosition();
if (mDesc->mTitle.IsNotEmpty()) if (mDesc->mTitle.IsNotEmpty())
{ {

View file

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