public override void ClickEvent() { menu = (EditorMenu)Managers.Executive.menuStack.Peek(); try { Menus.EditorMenu menu = (EditorMenu)Managers.Executive.menuStack.Peek(); Managers.Executive.NewEditor(menu.changeIndex, menu.levelIndex); } catch(InvalidDataException) { if (menu.levelIndex > Managers.Executive.levels.Count + 1) throw new Exception("Can't find existing level with that index"); Managers.Executive.NewEditor(1, menu.levelIndex); } }
public static Menus.Menu ParseMenuData(StreamReader file) { List<Menus.Buttons.Button> buttons = new List<Menus.Buttons.Button>(); Menus.Menu menu; string m_name, line, b_name; Vector2 position; string[] split; int inIndex = 0, deIndex = 0, boIndex = 0; m_name = file.ReadLine().Split(':')[1]; while ((line = file.ReadLine()) != null) { split = line.Split(':'); b_name = split[0]; split = split[1].Split(','); position = new Vector2(Convert.ToInt32(split[0]), Convert.ToInt32(split[1])); switch (b_name) { case "IncreaseButton": buttons.Add(new Menus.Buttons.IncreaseButton(position, b_name, m_name, inIndex)); inIndex++; break; case "DecreaseButton": buttons.Add(new Menus.Buttons.DecreaseButton(position, b_name, m_name, deIndex)); deIndex++; break; case "EditorButton": buttons.Add(new Menus.Buttons.EditorButton(position, b_name)); break; case "StartEditorButton": buttons.Add(new Menus.Buttons.StartEditorButton(position, b_name)); break; case "BackButton": buttons.Add(new Menus.Buttons.BackButton(position, b_name)); break; case "BoolButton": buttons.Add(new Menus.Buttons.BoolButton(position, b_name, boIndex)); boIndex++; break; case "TextField": buttons.Add(new Menus.Buttons.TextField(position, b_name)); break; case "SmallButton": buttons.Add(new Menus.Buttons.SmallButton(position, b_name)); break; case "SmallRowButton": buttons.Add(new Menus.Buttons.SmallButton(position, b_name)); break; case "SmallColButton": buttons.Add(new Menus.Buttons.SmallButton(position, b_name)); break; case "SmallLevelButton": buttons.Add(new Menus.Buttons.SmallButton(position, b_name)); break; default: buttons.Add(new Menus.Buttons.Button(position, b_name)); break; } } file.Close(); switch (m_name) { case "EditorMenu": menu = new Menus.EditorMenu(m_name, buttons); break; default: menu = new Menus.Menu(m_name, buttons); break; } return menu; }