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 M_ParseMenuDefs() { int lump, lastlump = 0; OptionSettings.mTitleColor = V_FindFontColor(gameinfo.mTitleColor); OptionSettings.mFontColor = V_FindFontColor(gameinfo.mFontColor); OptionSettings.mFontColorValue = V_FindFontColor(gameinfo.mFontColorValue); OptionSettings.mFontColorMore = V_FindFontColor(gameinfo.mFontColorMore); OptionSettings.mFontColorHeader = V_FindFontColor(gameinfo.mFontColorHeader); OptionSettings.mFontColorHighlight = V_FindFontColor(gameinfo.mFontColorHighlight); OptionSettings.mFontColorSelection = V_FindFontColor(gameinfo.mFontColorSelection); DefaultListMenuSettings.Reset(); DefaultOptionMenuSettings.Reset(); atterm( DeinitMenus); DeinitMenus(); while ((lump = Wads.FindLump ("MENUDEF", &lastlump)) != -1) { FScanner sc(lump); sc.SetCMode(true); while (sc.GetString()) { if (sc.Compare("LISTMENU")) { ParseListMenu(sc); } else if (sc.Compare("DEFAULTLISTMENU")) { ParseListMenuBody(sc, &DefaultListMenuSettings); if (DefaultListMenuSettings.mItems.Size() > 0) { I_FatalError("You cannot add menu items to the menu default settings."); } } else if (sc.Compare("OPTIONVALUE")) { ParseOptionValue(sc); } else if (sc.Compare("OPTIONSTRING")) { ParseOptionString(sc); } else if (sc.Compare("OPTIONMENUSETTINGS")) { ParseOptionSettings(sc); } else if (sc.Compare("OPTIONMENU")) { ParseOptionMenu(sc); } else if (sc.Compare("DEFAULTOPTIONMENU")) { ParseOptionMenuBody(sc, &DefaultOptionMenuSettings); if (DefaultOptionMenuSettings.mItems.Size() > 0) { I_FatalError("You cannot add menu items to the menu default settings."); } } else { sc.ScriptError("Unknown keyword '%s'", sc.String); } } } }
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(); } } } }