/// <summary> /// Display the <see cref="Macros"/> window at the given width using the given style. /// </summary> private void DisplayMacros() { showMacros = RexUIUtils.Toggle(showMacros, _texts["macros_header"]); if (showMacros) { // box begins EditorGUILayout.BeginVertical(slimBox); { // scroll begins scroll4 = EditorGUILayout.BeginScrollView(scroll4); { string deleted = null; foreach (var macro in _macros) { EditorGUILayout.BeginHorizontal(); { // Draw the RUN button if (GUILayout.Button(_texts.GetText("macro_go", tooltipFormat: macro), GUILayout.Width(30))) { // parse, compile & execute Execute(macro); } // Remove the macro if the X button is pressed if (GUILayout.Button(_texts["macro_remove"], GUILayout.Width(20))) { deleted = macro; } // if the label is pressed... then run this code..? // TODO: Highlight this... if (GUILayout.Button(_texts.GetText("select_macro", macro, macro), GUI.skin.label)) { RexISM.Code = macro; RexISM.DisplayHelp = false; } } EditorGUILayout.EndHorizontal(); } if (deleted != null) { _macros = RexMacroHandler.Remove(deleted); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } }
public void MacroTest() { var before = RexMacroHandler.LoadMacros(); foreach (var item in before) { RexMacroHandler.Remove(item); } Assert.IsEmpty(RexMacroHandler.LoadMacros()); Assert.AreEqual(new[] { "Lol" }, RexMacroHandler.Save("Lol")); Assert.AreEqual(new[] { "Lol" }, RexMacroHandler.LoadMacros()); Assert.IsEmpty(RexMacroHandler.Remove("Lol")); Assert.IsEmpty(RexMacroHandler.LoadMacros()); Assert.AreEqual(new[] { "Lol1" }, RexMacroHandler.Save("Lol1")); Assert.AreEqual(new[] { "Lol1", "Lol2" }, RexMacroHandler.Save("Lol2")); Assert.AreEqual(new[] { "Lol1", "Lol2", "Lol3" }, RexMacroHandler.Save("Lol3")); Assert.AreEqual(new[] { "Lol1", "Lol2", "Lol3" }, RexMacroHandler.LoadMacros()); foreach (var item in before) { RexMacroHandler.Save(item); } }