static void ParseOptionMenu(FScanner &sc) { sc.MustGetString(); FOptionMenuDescriptor *desc = new FOptionMenuDescriptor; desc->mType = MDESC_OptionsMenu; desc->mMenuName = sc.String; desc->mSelectedItem = -1; desc->mScrollPos = 0; desc->mClass = NULL; desc->mPosition = DefaultOptionMenuSettings.mPosition; desc->mScrollTop = DefaultOptionMenuSettings.mScrollTop; desc->mIndent = DefaultOptionMenuSettings.mIndent; desc->mDontDim = DefaultOptionMenuSettings.mDontDim; ParseOptionMenuBody(sc, desc); bool scratch = ReplaceMenu(sc, desc); if (desc->mIndent == 0) desc->CalcIndent(); if (scratch) delete desc; }
void UpdateJoystickMenu(IJoystickConfig *selected) { FMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_JoystickOptions); if (desc != NULL && (*desc)->mType == MDESC_OptionsMenu) { FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc; FOptionMenuItem *it; for(unsigned i=0;i<opt->mItems.Size();i++) { delete opt->mItems[i]; } opt->mItems.Clear(); int i; int itemnum = -1; I_GetJoysticks(Joysticks); if ((unsigned)itemnum >= Joysticks.Size()) { itemnum = Joysticks.Size() - 1; } if (selected != NULL) { for (i = 0; (unsigned)i < Joysticks.Size(); ++i) { if (Joysticks[i] == selected) { itemnum = i; break; } } } // Todo: Block joystick for changing this one. it = new FOptionMenuItemOption("Enable controller support", "use_joystick", "YesNo", NULL, false); opt->mItems.Push(it); #ifdef _WIN32 it = new FOptionMenuItemOption("Enable DirectInput controllers", "joy_dinput", "YesNo", NULL, false); opt->mItems.Push(it); it = new FOptionMenuItemOption("Enable XInput controllers", "joy_xinput", "YesNo", NULL, false); opt->mItems.Push(it); it = new FOptionMenuItemOption("Enable raw PlayStation 2 adapters", "joy_ps2raw", "YesNo", NULL, false); opt->mItems.Push(it); #endif it = new FOptionMenuItemStaticText(" ", false); opt->mItems.Push(it); if (Joysticks.Size() == 0) { it = new FOptionMenuItemStaticText("No controllers detected", false); opt->mItems.Push(it); if (!use_joystick) { it = new FOptionMenuItemStaticText("Controller support must be", false); opt->mItems.Push(it); it = new FOptionMenuItemStaticText("enabled to detect any", false); opt->mItems.Push(it); } } else { it = new FOptionMenuItemStaticText("Configure controllers:", false); opt->mItems.Push(it); for (int i = 0; i < (int)Joysticks.Size(); ++i) { it = new FOptionMenuItemJoyConfigMenu(Joysticks[i]->GetName(), Joysticks[i]); opt->mItems.Push(it); if (i == itemnum) opt->mSelectedItem = opt->mItems.Size(); } } if (opt->mSelectedItem >= (int)opt->mItems.Size()) { opt->mSelectedItem = opt->mItems.Size() - 1; } opt->CalcIndent(); // If the joystick config menu is open, close it if the device it's // open for is gone. for (i = 0; (unsigned)i < Joysticks.Size(); ++i) { if (Joysticks[i] == SELECTED_JOYSTICK) { break; } } if (i == (int)Joysticks.Size()) { SELECTED_JOYSTICK = NULL; if (DMenu::CurrentMenu != NULL && DMenu::CurrentMenu->IsKindOf(RUNTIME_CLASS(DJoystickConfigMenu))) { DMenu::CurrentMenu->Close(); } } } }