// Open options menu protected void AddOptionsMenu(bool soloAnimAllowed = true) { var settingsTopMenu = new GameplaySettingsTopMenu(soloAnimAllowed); settingsTopMenu.Selected += SettingsTopMenu_Selected; settingsTopMenu.Closed += optionsMenu_Closed; settingsTopMenu.AddToManager(new MenuCallbackEventArgs(this.AddMenu, this.menu_Closed)); }
// Selected an item in the map menu private void mapMenu_Selected(object sender, EventArgs e) { switch ((sender as MapCommandMenu).SelectedOption) { case Map_Menu_Options.Unit: RemoveTopMenu(); var unitMenu = new Window_Unit(); unitMenu.Status += unitMenu_Status; unitMenu.Closed += unitMenu_Closed; AddMenu(unitMenu); break; case Map_Menu_Options.Data: RemoveTopMenu(); var dataMenu = new Window_Data(); dataMenu.Closed += menu_ClosedCanceled; AddMenu(dataMenu); break; case Map_Menu_Options.Options: RemoveTopMenu(); var settingsTopMenu = new GameplaySettingsTopMenu(true); settingsTopMenu.Selected += SettingsTopMenu_Selected; settingsTopMenu.Closed += menu_ClosedCanceled; settingsTopMenu.AddToManager(new MenuCallbackEventArgs(this.AddMenu, this.menu_Closed)); break; case Map_Menu_Options.Suspend: var suspendConfirmWindow = new Parchment_Confirm_Window(); suspendConfirmWindow.set_text("Save and quit?", new Vector2(8, 0)); suspendConfirmWindow.add_choice("Yes", new Vector2(16, 16)); suspendConfirmWindow.add_choice("No", new Vector2(56, 16)); suspendConfirmWindow.size = new Vector2(104, 48); suspendConfirmWindow.loc = new Vector2(Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT) / 2 - suspendConfirmWindow.size / 2; var suspendConfirmMenu = new ConfirmationMenu(suspendConfirmWindow); suspendConfirmMenu.Confirmed += suspendConfirmMenu_Confirmed; suspendConfirmMenu.Canceled += menu_Closed; AddMenu(suspendConfirmMenu); break; case Map_Menu_Options.End: // If there are no units left to move, just end the turn if (!Global.game_map.ready_movable_units) { MenuHandler.MapMenuEndTurn(); } else { var endTurnConfirmWindow = new Parchment_Confirm_Window(); endTurnConfirmWindow.set_text("End your turn?", new Vector2(8, 0)); endTurnConfirmWindow.add_choice("Yes", new Vector2(16, 16)); endTurnConfirmWindow.add_choice("No", new Vector2(56, 16)); endTurnConfirmWindow.size = new Vector2(104, 48); endTurnConfirmWindow.loc = new Vector2(Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT) / 2 - endTurnConfirmWindow.size / 2; var endTurnConfirmMenu = new ConfirmationMenu(endTurnConfirmWindow); endTurnConfirmMenu.Confirmed += endTurnConfirmMenu_Confirmed; endTurnConfirmMenu.Canceled += menu_Closed; AddMenu(endTurnConfirmMenu); } break; } }
// Selected an item in the map menu private void mapMenu_Selected(object sender, EventArgs e) { var mapMenu = (sender as UnitEditorMapCommandMenu); switch (mapMenu.SelectedOption) { case Unit_Editor_Options.Unit: RemoveTopMenu(); var unitMenu = new Window_Unit_Team(); unitMenu.Status += unitMenu_Status; unitMenu.Closed += unitMenu_Closed; AddMenu(unitMenu); break; case Unit_Editor_Options.Add_Unit: MenuHandler.UnitEditorMapMenuAddUnit(); break; case Unit_Editor_Options.Paste_Unit: MenuHandler.UnitEditorMapMenuPasteUnit(); break; case Unit_Editor_Options.Reinforcements: RemoveTopMenu(); var reinforcementsMenu = new ReinforcementsMenu(ReinforcementData); reinforcementsMenu.Selected += reinforcementsMenu_Selected; reinforcementsMenu.Canceled += menu_ClosedCanceled; AddMenu(reinforcementsMenu); break; case Unit_Editor_Options.Options: RemoveTopMenu(); var settingsTopMenu = new GameplaySettingsTopMenu(false); settingsTopMenu.Selected += SettingsTopMenu_Selected; settingsTopMenu.Closed += menu_ClosedCanceled; settingsTopMenu.AddToManager(new MenuCallbackEventArgs(this.AddMenu, this.menu_Closed)); break; case Unit_Editor_Options.Clear_Units: // Clear Units Vector2 optionLocation = mapMenu.SelectedOptionLocation; var clearUnitsWindow = new Window_Command( optionLocation + new Vector2(8, 24), 80, new List <string> { "Confirm", "Cancel" }); clearUnitsWindow.immediate_index = 1; var clearUnitsCommandMenu = new CommandMenu(clearUnitsWindow); clearUnitsCommandMenu.Selected += clearUnitsCommandMenu_Selected; clearUnitsCommandMenu.Canceled += confirmMenu_Canceled; AddMenu(clearUnitsCommandMenu); break; case Unit_Editor_Options.Mirror_Units: // Mirror Units optionLocation = mapMenu.SelectedOptionLocation; var mirrorUnitsWindow = new Window_Command( optionLocation + new Vector2(8, 24), 80, new List <string> { "Confirm", "Cancel" }); mirrorUnitsWindow.immediate_index = 1; var mirrorUnitsCommandMenu = new CommandMenu(mirrorUnitsWindow); mirrorUnitsCommandMenu.Selected += mirrorUnitsCommandMenu_Selected; mirrorUnitsCommandMenu.Canceled += confirmMenu_Canceled; AddMenu(mirrorUnitsCommandMenu); break; case Unit_Editor_Options.Playtest: MenuHandler.UnitEditorMapMenuPlaytest(); break; case Unit_Editor_Options.Revert: MenuHandler.UnitEditorMapMenuRevert(); break; case Unit_Editor_Options.Save: MenuHandler.UnitEditorMapMenuSave(); break; case Unit_Editor_Options.Quit: // Quit optionLocation = mapMenu.SelectedOptionLocation; var quitConfirmWindow = new Window_Confirmation(); int height = 48; quitConfirmWindow.loc = optionLocation + new Vector2(0, 24); if (quitConfirmWindow.loc.Y + height > Config.WINDOW_HEIGHT) { quitConfirmWindow.loc = optionLocation + new Vector2(0, -40); } quitConfirmWindow.set_text("Are you sure?"); quitConfirmWindow.add_choice("Yes", new Vector2(16, 16)); quitConfirmWindow.add_choice("No", new Vector2(56, 16)); quitConfirmWindow.size = new Vector2(88, height); quitConfirmWindow.index = 1; var quitConfirmMenu = new ConfirmationMenu(quitConfirmWindow); quitConfirmMenu.Confirmed += quitConfirmMenu_Confirmed; quitConfirmMenu.Canceled += confirmMenu_Canceled; AddMenu(quitConfirmMenu); break; } }