public static void ShowMilestoneEditor(Rect rect, MilestoneDataControl milestone) { var window = MilestoneEditorWindow.Create(milestone); rect.position = GUIUtility.GUIToScreenPoint(rect.position); window.ShowAsDropDown(rect, new Vector2(Mathf.Max(rect.width, 250), 300)); }
public void Init(ProgressDataControl progressDataControl) { this.progress = progressDataControl; progressList = new DataControlList() { RequestRepaint = Repaint, Columns = new List <ColumnList.Column>() { new ColumnList.Column() { Text = "Analytics.Milestone.Time".Traslate() } }, drawCell = (rect, row, column, isActive, isFocused) => { var milestone = progressList.list[row] as MilestoneDataControl; if (milestone == null) { return; } switch (column) { default: if (GUI.Button(rect, milestone.getContent().ToString())) { MilestoneEditorWindow.ShowMilestoneEditor(rect, milestone); } break; case 1: EditorGUI.BeginChangeCheck(); var newProgress = EditorGUI.Slider(rect, "", milestone.getProgress(), 0, 1); if (EditorGUI.EndChangeCheck()) { milestone.setProgress(newProgress); } break; } } }; progressColumn = new ColumnList.Column() { Text = "Analytics.Completable.Progress".Traslate() }; }
public void Init(Completable.Milestone mil) { editor = EditorWindow.GetWindow <MilestoneEditorWindow>(); editor.Milestone = mil; scenes = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenesIDs(); characters = Controller.getInstance().getSelectedChapterDataControl().getNPCsList().getNPCsIDs(); items = Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItemsIDs(); List <string> tmplist = new List <string>(); foreach (Completable c in Controller.getInstance().getSelectedChapterDataControl().getCompletables()) { tmplist.Add(c.getId()); } completables = tmplist.ToArray(); selectedId = 0; antiguo = milestone.getType(); if (milestone.getId() != "") { string[] tmp = { }; switch (milestone.getType()) { case Completable.Milestone.MilestoneType.CHARACTER: tmp = characters; break; case Completable.Milestone.MilestoneType.ITEM: tmp = items; break; case Completable.Milestone.MilestoneType.SCENE: tmp = scenes; break; case Completable.Milestone.MilestoneType.COMPLETABLE: break; } for (int i = 0; i < tmp.Length; i++) { if (tmp[i] == milestone.getId()) { selectedId = i; break; } } } }
public static MilestoneEditorWindow Create(MilestoneDataControl mil) { editor = ScriptableObject.CreateInstance <MilestoneEditorWindow>(); editor.Milestone = mil; return(editor); }
public CompletablesWindow(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, aOptions) { completablesList = new DataControlList() { RequestRepaint = Repaint, Columns = new List <ColumnList.Column>() { new ColumnList.Column() { Text = TC.get("Analytics.Completable.Id") }, new ColumnList.Column() { Text = TC.get("Analytics.Completable.Start") }, new ColumnList.Column() { Text = TC.get("Analytics.Completable.End") }, new ColumnList.Column() { Text = TC.get("Analytics.Completable.Progress") }, new ColumnList.Column() { Text = TC.get("Analytics.Completable.Score") }, new ColumnList.Column() { Text = TC.get("Repeatable"), SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) } } }, drawCell = (rect, row, column, isActive, isFocused) => { var completable = completablesList.list[row] as CompletableDataControl; switch (column) { case 0: completable.renameElement(EditorGUI.TextField(rect, completable.getId())); break; case 1: if (GUI.Button(rect, completable.getStart().getContent().ToString())) { MilestoneEditorWindow.ShowMilestoneEditor(rect, completable.getStart()); } break; case 2: if (GUI.Button(rect, completable.getEnd().getContent().ToString())) { MilestoneEditorWindow.ShowMilestoneEditor(rect, completable.getEnd()); } break; case 3: if (GUI.Button(rect, TC.get("Analytics.Completable.Define"))) { ProgressEditorWindow.ShowProgressEditor(rect, completable.getProgress()); } break; case 4: { if (Available) { ScoreEditor(rect, completable.getScore()); } else { EditorGUI.HelpBox(rect, TC.get("Condition.Var.Warning"), MessageType.Error); } } break; case 5: completable.setRepeatable(GUI.Toggle(rect, completable.getRepeatable(), "?")); break; } } }; }
public void OnGUI() { GUILayout.Label("Progress is given by: "); progress.setType((Completable.Progress.ProgressType)EditorGUILayout.Popup((int)progress.getType(), typeoptions)); GUILayout.Label("Milestones: "); //GUILayout.BeginArea(tableRect); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(position.width * 0.9f)); GUILayout.BeginHorizontal(); if (progress.getType() == Completable.Progress.ProgressType.SUM) { GUILayout.Box("Time", GUILayout.Width(position.width * 0.88f)); } else { GUILayout.Box("Time", GUILayout.Width(position.width * 0.44f)); GUILayout.Box("Progress", GUILayout.Width(position.width * 0.44f)); } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition); foreach (Completable.Milestone milestone in progress.getMilestones()) { GUILayout.BeginHorizontal(); if (progress.getType() == Completable.Progress.ProgressType.SUM) { if (GUILayout.Button(milestone.ToString(), GUILayout.Width(position.width * 0.88f))) { MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>(); window.Init(milestone); } } else { if (GUILayout.Button(milestone.ToString(), GUILayout.Width(position.width * 0.44f))) { MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>(); window.Init(milestone); } milestone.setProgress(EditorGUILayout.Slider(milestone.getProgress(), 0, 1, GUILayout.Width(position.width * 0.44f))); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); //GUILayout.EndArea(); //GUILayout.BeginArea(rightPanelRect); GUILayout.BeginVertical(GUILayout.Width(0.1f * position.width)); if (GUILayout.Button(addTexture)) { progress.addMilestone(new Completable.Milestone()); } if (GUILayout.Button(moveUp)) { int pos = progress.getMilestones().IndexOf(selectedMilestone); if (pos > 0) { Completable.Milestone tmp = progress.getMilestones()[pos - 1]; progress.getMilestones()[pos - 1] = progress.getMilestones()[pos]; progress.getMilestones()[pos] = tmp; } } if (GUILayout.Button(moveDown)) { int pos = progress.getMilestones().IndexOf(selectedMilestone); if (pos < progress.getMilestones().Count - 1) { Completable.Milestone tmp = progress.getMilestones()[pos + 1]; progress.getMilestones()[pos + 1] = progress.getMilestones()[pos]; progress.getMilestones()[pos] = tmp; } } if (GUILayout.Button(clearImg)) { } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public override void Draw(int aID) { var windowWidth = Rect.width; var windowHeight = Rect.height; tableRect = new Rect(0f, 200, 0.8f * windowWidth, windowHeight * 0.33f); rightPanelRect = new Rect(0.85f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight); GUILayout.Label(TC.get("Analytics.GameStart") + Controller.getInstance().getSelectedChapterDataControl().getInitialScene()); GUILayout.Label(TC.get("Analytics.GameEnd")); end = EditorGUILayout.Popup(end, endoptions); GUILayout.Label(TC.get("Analytics.GameProgress")); progress = EditorGUILayout.Popup(progress, progressoptions); if (progress == 1) { GUILayout.Button(TC.get("Analytics.EditProgress")); } //GUILayout.BeginArea(tableRect); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(); GUILayout.Box(TC.get("Analytics.Completable.Id"), GUILayout.Width(windowWidth * col_width)); GUILayout.Box(TC.get("Analytics.Completable.Start"), GUILayout.Width(windowWidth * col_width)); GUILayout.Box(TC.get("Analytics.Completable.End"), GUILayout.Width(windowWidth * col_width)); GUILayout.Box(TC.get("Analytics.Completable.Progress"), GUILayout.Width(windowWidth * col_width)); GUILayout.Box(TC.get("Analytics.Completable.Score"), GUILayout.Width(windowWidth * col_width)); GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition); foreach (Completable completable in completables) { GUILayout.BeginHorizontal(); completable.setId(GUILayout.TextField(completable.getId(), GUILayout.Width(windowWidth * col_width))); if (GUILayout.Button(completable.getStart().ToString(), GUILayout.Width(windowWidth * col_width))) { MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>(); window.Init(completable.getStart()); } if (GUILayout.Button(completable.getEnd().ToString(), GUILayout.Width(windowWidth * col_width))) { MilestoneEditorWindow window = ScriptableObject.CreateInstance <MilestoneEditorWindow>(); window.Init(completable.getEnd()); } if (GUILayout.Button(TC.get("Analytics.Completable.Define"), GUILayout.Width(windowWidth * col_width))) { ProgressEditorWindow window = ScriptableObject.CreateInstance <ProgressEditorWindow>(); window.Init(completable.getProgress()); } selected_variable[completable] = EditorGUILayout.Popup(selected_variable[completable], variables, GUILayout.Width(windowWidth * col_width)); completable.getScore().setId(variables[selected_variable[completable]]); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); //GUILayout.EndArea(); //GUILayout.BeginArea(rightPanelRect); GUILayout.BeginVertical(GUILayout.Width(0.1f * windowWidth)); if (GUILayout.Button(addTexture)) { Completable nc = new Completable(); Completable.Score score = new Completable.Score(); score.setMethod(Completable.Score.ScoreMethod.SINGLE); score.setType(Completable.Score.ScoreType.VARIABLE); nc.setScore(score); completables.Add(nc); selected_variable.Add(nc, 0); } if (GUILayout.Button(moveUp)) { int pos = completables.IndexOf(selectedCompletable); if (pos > 0) { Completable tmp = completables[pos - 1]; completables[pos - 1] = completables[pos]; completables[pos] = tmp; } } if (GUILayout.Button(moveDown)) { int pos = completables.IndexOf(selectedCompletable); if (pos < completables.Count - 1) { Completable tmp = completables[pos + 1]; completables[pos + 1] = completables[pos]; completables[pos] = tmp; } } if (GUILayout.Button(clearImg)) { } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }