- fixed initialization of joystick menu with bogus MENUDEFS

This commit is contained in:
Christoph Oelckers 2017-02-16 18:55:36 +01:00
parent cfeb1724fe
commit ccb083ed25
4 changed files with 14 additions and 9 deletions

View file

@ -138,9 +138,13 @@ DEFINE_ACTION_FUNCTION(IJoystickConfig, GetNumAxes)
void UpdateJoystickMenu(IJoystickConfig *selected)
{
DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_JoystickOptions);
DMenuDescriptor **ddesc = MenuDescriptors.CheckKey("JoystickOptionsDefaults");
if (ddesc == nullptr) return; // without any data the menu cannot be set up and must remain empty.
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor)))
{
DOptionMenuDescriptor *opt = (DOptionMenuDescriptor *)*desc;
DOptionMenuDescriptor *dopt = (DOptionMenuDescriptor *)*ddesc;
if (dopt == nullptr) return;
DMenuItemBase *it;
int i;
@ -162,11 +166,7 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
}
}
}
#ifdef _WIN32
opt->mItems.Resize(8);
#else
opt->mItems.Resize(5);
#endif
opt->mItems = dopt->mItems;
it = opt->GetItem("ConfigureMessage");
if (it != nullptr) it->SetValue(0, !!Joysticks.Size());

View file

@ -112,7 +112,7 @@ class DMenuDescriptor : public DObject
public:
FName mMenuName;
FString mNetgameMessage;
PClass *mClass;
PClass *mClass = nullptr;
virtual size_t PropagateMark() { return 0; }
};

View file

@ -950,9 +950,9 @@ void M_ParseMenuDefs()
}
}
}
DefaultListMenuClass = DefaultListMenuSettings->GetClass();
DefaultListMenuClass = DefaultListMenuSettings->mClass;
DefaultListMenuSettings = nullptr;
DefaultOptionMenuClass = DefaultOptionMenuSettings->GetClass();
DefaultOptionMenuClass = DefaultOptionMenuSettings->mClass;
DefaultOptionMenuSettings = nullptr;
}

View file

@ -558,7 +558,7 @@ OptionMenu "MouseOptions"
//
//-------------------------------------------------------------------------------------------
OptionMenu "JoystickOptions"
OptionMenu "JoystickOptionsDefaults"
{
Title "$JOYMNU_OPTIONS"
Option "$JOYMNU_ENABLE", "use_joystick", "YesNo"
@ -576,6 +576,11 @@ OptionMenu "JoystickOptions"
// The rest will be filled in by joystick code if devices get connected or disconnected
}
OptionMenu "JoystickOptions"
{
Title "$JOYMNU_OPTIONS"
}
OptionValue "JoyAxisMapNames"
{
-1, "$OPTVAL_NONE"