void convert_macro() { m_OkNG = true; var sm = new MacroControl(); sm.G = G; sm.m_state = m_state; sm.m_lines = m_lines; sm.Start(); for (var loop = 0; loop <= 10000; loop++) { if (loop == 10000) { throw new SystemException("Unexpected! {8C70F7D9-7E73-4E1C-BF94-320DA272DF02}"); } sm.update(); if (sm.IsEnd()) { break; } } m_needAgain = sm.m_bNeedCheckAgain; m_lines = sm.m_resultlines; }
private void BuildCommands() { const int PAGE = 4; ScrollArea rightArea = new ScrollArea(190, 52 + 25 + 4, 150, 360, true); NiceButton addButton = new NiceButton(190, 20, 130, 20, ButtonAction.Activate, "New macro") { IsSelectable = false, ButtonParameter = (int)Buttons.NewMacro }; addButton.MouseClick += (sender, e) => { EntryDialog dialog = new EntryDialog(250, 150, "Macro name:", name => { if (string.IsNullOrWhiteSpace(name)) { return; } MacroManager manager = Engine.SceneManager.GetScene <GameScene>().Macros; List <Macro> macros = manager.GetAllMacros(); if (macros.Any(s => s.Name == name)) { return; } NiceButton nb; rightArea.Add(nb = new NiceButton(0, 0, 130, 25, ButtonAction.Activate, name) { ButtonParameter = (int)Buttons.Last + 1 + rightArea.Children.Count, }); nb.IsSelected = true; _macroControl?.Dispose(); _macroControl = new MacroControl(name) { X = 400, Y = 20, }; Add(_macroControl, PAGE); nb.MouseClick += (sss, eee) => { _macroControl?.Dispose(); _macroControl = new MacroControl(name) { X = 400, Y = 20, }; Add(_macroControl, PAGE); }; }); Engine.UI.Add(dialog); }; Add(addButton, PAGE); NiceButton delButton = new NiceButton(190, 52, 130, 20, ButtonAction.Activate, "Delete macro") { IsSelectable = false, ButtonParameter = (int)Buttons.DeleteMacro }; delButton.MouseClick += (ss, ee) => { NiceButton nb = rightArea.FindControls <ScrollAreaItem>() .SelectMany(s => s.Children.OfType <NiceButton>()) .SingleOrDefault(a => a.IsSelected); if (nb != null) { QuestionGump dialog = new QuestionGump("Do you want\ndelete it?", b => { if (!b) { return; } nb.Parent.Dispose(); if (_macroControl != null) { MacroCollectionControl control = _macroControl.FindControls <MacroCollectionControl>().SingleOrDefault(); if (control == null) { return; } Engine.SceneManager.GetScene <GameScene>().Macros.RemoveMacro(control.Macro); } if (rightArea.Children.OfType <ScrollAreaItem>().All(s => s.IsDisposed)) { _macroControl?.Dispose(); } }); Engine.UI.Add(dialog); } }; Add(delButton, PAGE); Add(new Line(190, 52 + 25 + 2, 150, 1, Color.Gray.PackedValue), PAGE); Add(rightArea, PAGE); Add(new Line(191 + 150, 21, 1, 418, Color.Gray.PackedValue), PAGE); foreach (Macro macro in Engine.SceneManager.GetScene <GameScene>().Macros.GetAllMacros()) { NiceButton nb; rightArea.Add(nb = new NiceButton(0, 0, 130, 25, ButtonAction.Activate, macro.Name) { ButtonParameter = (int)Buttons.Last + 1 + rightArea.Children.Count, }); nb.IsSelected = true; nb.MouseClick += (sss, eee) => { _macroControl?.Dispose(); _macroControl = new MacroControl(macro.Name) { X = 400, Y = 20, }; Add(_macroControl, PAGE); }; } }