public override bool doTool() { bool elementDeleted = false; // Delete the block only if it is not the last one lastSelectedResources = parentDataControl.getSelectedResources(); if (resourcesList.Count > 1) { if (resourcesList.Remove((ResourcesUni)dataControl.getContent())) { resourcesIndex = resourcesDataControlList.IndexOf((ResourcesDataControl)dataControl); resourcesDataControlList.Remove((ResourcesDataControl)dataControl); int selectedResources = parentDataControl.getSelectedResources(); // Decrease the selected index if necessary if (selectedResources > 0 && selectedResources >= resourcesIndex) { parentDataControl.setSelectedResources(selectedResources - 1); } //controller.dataModified( ); elementDeleted = true; } } // If it was the last one, show an error message else { Controller.getInstance().showErrorDialog(TC.get("Operation.DeleteResourcesTitle"), TC.get("Operation.DeleteResourcesErrorLastResources")); } return(elementDeleted); }
public override bool redoTool() { resourcesList.Add(newResources); resourcesDataControlList.Add(newResourcesDataControl); parent.setSelectedResources(resourcesList.Count - 1); Controller.getInstance().updatePanel(); return(true); }
public override bool doTool() { if (!(dataControl is ResourcesDataControl)) { return(false); } newElement = (ResourcesUni)(((ResourcesUni)(dataControl.getContent()))); newDataControl = new ResourcesDataControl(newElement, ((ResourcesDataControl)dataControl).getResourcesType()); resourcesList.Add(newElement); resourcesDataControlList.Add(newDataControl); parent.setSelectedResources(resourcesList.Count - 1); return(true); }
protected void Awake() { conditionsTex = (Texture2D)Resources.Load("EAdventureData/img/icons/conditions-24x24", typeof(Texture2D)); noConditionsTex = (Texture2D)Resources.Load("EAdventureData/img/icons/no-conditions-24x24", typeof(Texture2D)); appearanceList = new DataControlList() { RequestRepaint = Repaint, headerHeight = 20, footerHeight = 20, Columns = new List <ColumnList.Column>() { new ColumnList.Column() { Text = TC.get("Item.LookPanelTitle"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } }, new ColumnList.Column() { Text = TC.get("Conditions.Title"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } } }, drawCell = (rect, index, col, isActive, isFocused) => { var resources = dataControl.getResources()[index]; switch (col) { case 0: if (index == appearanceList.index) { EditorGUI.BeginChangeCheck(); var newname = EditorGUI.TextField(rect, "Resources " + (index + 1), resources.getName()); if (EditorGUI.EndChangeCheck()) { resources.renameElement(newname); } } else { EditorGUI.LabelField(rect, "Resources " + (index + 1) + ": " + resources.getName()); } break; case 1: if (GUI.Button(rect, resources.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex)) { appearanceList.index = index; ConditionEditorWindow window = CreateInstance <ConditionEditorWindow>(); window.Init(resources.getConditions()); } break; } }, onSelectCallback = (list) => { if (list.index == -1) { list.index = 0; } dataControl.setSelectedResources(list.index); if (onAppearanceSelected != null) { onAppearanceSelected(dataControl); } } }; }