public static float AddEventVarConditionComponents(Transform parentTransform, float xOffset, float yOffset, ITestable testable, Action updateAction) { UIElement ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset, yOffset, 18, 1); ui.SetText(new StringKey("val", "X_COLON", CommonStringKeys.TESTS)); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 18f, yOffset, 1, 1); ui.SetText(CommonStringKeys.PLUS, Color.green); ui.SetButton(delegate { AddTestOp(testable, updateAction); }); new UIElementBorder(ui, Color.green); if (testable.Tests.VarTestsComponents.Count > 0) { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset, yOffset, 1, 1); ui.SetText(CommonStringKeys.PLUS, Color.green); ui.SetButton(delegate { SelectAddParenthesis(testable, updateAction); }); new UIElementBorder(ui, Color.green); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 1.0f, yOffset, 2, 1); ui.SetText("(...)"); } yOffset++; int component_index = 0; foreach (VarTestsComponent tc in testable.Tests.VarTestsComponents) { if (tc is VarOperation) { int tmp_index = component_index; // only display arrows if item can be moved if (component_index != (testable.Tests.VarTestsComponents.Count - 1) && testable.Tests.VarTestsComponents.Count > 1 && testable.Tests.VarTestsComponents.FindIndex(component_index + 1, x => x.GetClassVarTestsComponentType() == VarTestsLogicalOperator.GetVarTestsComponentType()) != -1 ) { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset, yOffset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, false); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } if (component_index != 0 && testable.Tests.VarTestsComponents.FindLastIndex(component_index - 1, x => x.GetClassVarTestsComponentType() == VarTestsLogicalOperator.GetVarTestsComponentType()) != -1 ) { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 1.0f, yOffset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, true); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } VarOperation tmp = (VarOperation)tc; ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 2f, yOffset, 8.5f, 1); ui.SetText(tmp.var); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 10.5f, yOffset, 2, 1); ui.SetText(tmp.operation); ui.SetButton(delegate { SetTestOpp(tmp, updateAction); }); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 12.5f, yOffset, 5.5f, 1); ui.SetText(tmp.value); ui.SetButton(delegate { SetValue(tmp, updateAction); }); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 18f, yOffset++, 1, 1); ui.SetText(CommonStringKeys.MINUS, Color.red); ui.SetButton(delegate { RemoveOp(testable.Tests, tmp_index, updateAction); }); new UIElementBorder(ui, Color.red); } if (tc is VarTestsLogicalOperator) { VarTestsLogicalOperator tmp = (VarTestsLogicalOperator)tc; ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 9.5f, yOffset, 4, 1); if (tmp.op.Equals("AND")) { ui.SetText(CommonStringKeys.AND); } else if (tmp.op.Equals("OR")) { ui.SetText(CommonStringKeys.OR); } ui.SetButton(delegate { tmp.NextLogicalOperator(); updateAction.Invoke(); }); new UIElementBorder(ui); yOffset++; } if (tc is VarTestsParenthesis) { int tmp_index = component_index; VarTestsParenthesis tp = (VarTestsParenthesis)tc; if (component_index != (testable.Tests.VarTestsComponents.Count - 1) && testable.Tests.VarTestsComponents.FindIndex(component_index + 1, x => x.GetClassVarTestsComponentType() == VarOperation.GetVarTestsComponentType()) != -1 ) { if (tp.parenthesis == "(") { int valid_index = testable.Tests.FindNextValidPosition(component_index, false); if (valid_index != -1 && testable.Tests.FindClosingParenthesis(valid_index) != -1) { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset, yOffset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, false); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } } else if (tp.parenthesis == ")") { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset, yOffset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, false); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } } if (component_index != 0 && testable.Tests.VarTestsComponents.FindLastIndex(component_index - 1, x => x.GetClassVarTestsComponentType() == VarOperation.GetVarTestsComponentType()) != -1 ) { if (tp.parenthesis == "(") { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 1f, yOffset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, true); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } else if (tp.parenthesis == ")") { int valid_index = testable.Tests.FindNextValidPosition(component_index, true); if (valid_index != -1 && testable.Tests.FindOpeningParenthesis(valid_index) != -1) { ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 1f, yOffset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { testable.Tests.moveComponent(tmp_index, true); updateAction.Invoke(); }); new UIElementBorder(ui, Color.yellow); } } } ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 2f, yOffset, 2, 1); ui.SetText(tp.parenthesis); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, parentTransform); ui.SetLocation(xOffset + 4f, yOffset, 1, 1); ui.SetText(CommonStringKeys.MINUS, Color.red); ui.SetButton(delegate { testable.Tests.Remove(tmp_index); updateAction.Invoke(); }); new UIElementBorder(ui, Color.red); yOffset++; } component_index++; } return(yOffset + 1); }
virtual public float AddEventVarConditionComponents(float offset) { UIElement ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(0.5f, offset, 18, 1); ui.SetText(new StringKey("val", "X_COLON", TESTS)); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(18.5f, offset, 1, 1); ui.SetText(CommonStringKeys.PLUS, Color.green); ui.SetButton(delegate { AddTestOp(); }); new UIElementBorder(ui, Color.green); if (component.tests.VarTestsComponents.Count > 0) { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(0.5f, offset, 1, 1); ui.SetText(CommonStringKeys.PLUS, Color.green); ui.SetButton(delegate { SelectAddParenthesis(); }); new UIElementBorder(ui, Color.green); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(1.5f, offset, 2, 1); ui.SetText("(...)"); } offset++; int component_index = 0; foreach (VarTestsComponent tc in component.tests.VarTestsComponents) { if (tc is VarOperation) { int tmp_index = component_index; // only display arrows if item can be moved if (component_index != (component.tests.VarTestsComponents.Count - 1) && component.tests.VarTestsComponents.Count > 1 && component.tests.VarTestsComponents.FindIndex(component_index + 1, x => x.GetClassVarTestsComponentType() == VarTestsLogicalOperator.GetVarTestsComponentType()) != -1 ) { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(0.5f, offset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, false); Update(); }); new UIElementBorder(ui, Color.yellow); } if (component_index != 0 && component.tests.VarTestsComponents.FindLastIndex(component_index - 1, x => x.GetClassVarTestsComponentType() == VarTestsLogicalOperator.GetVarTestsComponentType()) != -1 ) { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(1.5f, offset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, true); Update(); }); new UIElementBorder(ui, Color.yellow); } VarOperation tmp = (VarOperation)tc; ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(2.5f, offset, 8.5f, 1); ui.SetText(tmp.var); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(11f, offset, 2, 1); ui.SetText(tmp.operation); ui.SetButton(delegate { SetTestOpp(tmp); }); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(13f, offset, 5.5f, 1); ui.SetText(tmp.value); ui.SetButton(delegate { SetValue(tmp); }); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(18.5f, offset++, 1, 1); ui.SetText(CommonStringKeys.MINUS, Color.red); ui.SetButton(delegate { RemoveOp(tmp_index); }); new UIElementBorder(ui, Color.red); } if (tc is VarTestsLogicalOperator) { VarTestsLogicalOperator tmp = (VarTestsLogicalOperator)tc; ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(10f, offset, 4, 1); if (tmp.op.Equals("AND")) { ui.SetText(AND); } else if (tmp.op.Equals("OR")) { ui.SetText(OR); } ui.SetButton(delegate { tmp.NextLogicalOperator(); Update(); }); new UIElementBorder(ui); offset++; } if (tc is VarTestsParenthesis) { int tmp_index = component_index; VarTestsParenthesis tp = (VarTestsParenthesis)tc; if (component_index != (component.tests.VarTestsComponents.Count - 1) && component.tests.VarTestsComponents.FindIndex(component_index + 1, x => x.GetClassVarTestsComponentType() == VarOperation.GetVarTestsComponentType()) != -1 ) { if (tp.parenthesis == "(") { int valid_index = component.tests.FindNextValidPosition(component_index, false); if (valid_index != -1 && component.tests.FindClosingParenthesis(valid_index) != -1) { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(0.5f, offset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, false); Update(); }); new UIElementBorder(ui, Color.yellow); } } else if (tp.parenthesis == ")") { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(0.5f, offset, 1, 1); ui.SetText(CommonStringKeys.DOWN, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, false); Update(); }); new UIElementBorder(ui, Color.yellow); } } if (component_index != 0 && component.tests.VarTestsComponents.FindLastIndex(component_index - 1, x => x.GetClassVarTestsComponentType() == VarOperation.GetVarTestsComponentType()) != -1 ) { if (tp.parenthesis == "(") { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(1.5f, offset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, true); Update(); }); new UIElementBorder(ui, Color.yellow); } else if (tp.parenthesis == ")") { int valid_index = component.tests.FindNextValidPosition(component_index, true); if (valid_index != -1 && component.tests.FindOpeningParenthesis(valid_index) != -1) { ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(1.5f, offset, 1, 1); ui.SetText(CommonStringKeys.UP, Color.yellow); ui.SetTextAlignment(TextAnchor.LowerCenter); ui.SetButton(delegate { component.tests.moveComponent(tmp_index, true); Update(); }); new UIElementBorder(ui, Color.yellow); } } } ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(2.5f, offset, 2, 1); ui.SetText(tp.parenthesis); new UIElementBorder(ui); ui = new UIElement(Game.EDITOR, scrollArea.GetScrollTransform()); ui.SetLocation(4.5f, offset, 1, 1); ui.SetText(CommonStringKeys.MINUS, Color.red); ui.SetButton(delegate { component.tests.Remove(tmp_index); Update(); }); new UIElementBorder(ui, Color.red); offset++; } component_index++; } return(offset + 1); }