void CheckCourse() { PopupToolUI.Clear(); if (CourseBase.Holes.Any(x => x.pins.Count == 0 || x.tees.Count == 0 || x.flyBys.Count == 0)) { PopupToolUI.Add("Course doesn't have 18 pins/tees/flybys."); } if (CourseBase.Info.Splash == null || CourseBase.Info.Cameo == null) { PopupToolUI.Add("Course doesn't have Course Images."); } if (CourseBase.Hazards.Any(x => x.Layer.name == Utility.GetName(HazardBase.Type.Out_of_Bounds)) == false) { PopupToolUI.Add("Course doesn't have 'Out Of Bounds' hazard."); } }
public override void OnUI(bool selected) { if (selected == false) { return; } BeginUI(); Move(1, 0); Background(4); if (MainToolUI.InfoPanel) { SetColor(Green); } if (Button(courseInfoTexture)) { MainToolUI.InfoPanel = !MainToolUI.InfoPanel; } SetColor(); Move(1, 0); if (Button(helpTexture)) { Application.OpenURL("http://perfectparallel.com/documentation"); } #region Version Move(0, 0.47f); SetColor(Black); MovePixels(1, 1); Label(CourseBase.version, 1, 1, EditorStyles.boldLabel); MovePixels(-1, -1); SetColor(); Label(CourseBase.version, 1, 1, EditorStyles.boldLabel); Move(0, -0.47f); #endregion SetColor(); Move(1, 0); if (Button(androidTexture)) { MainToolUI.AndroidPanel = !MainToolUI.AndroidPanel; } Move(1, 0); EditorGUI.BeginDisabledGroup(!PlatformBase.IO.IsEditor); if (PopupToolUI.Count() != 0) { SetColor(Yellow); } if (Button(new GUIContent(buildTexture, (PopupToolUI.Count() != 0 ? "Click to build it anyway" : null)))) { if (PopupToolUI.Count() == 0) { CheckCourse(); if (PopupToolUI.Count() == 0) { CourseBase.BuildCourse((int)Utility.FromName <UnityEditor.BuildTarget>(BuildTarget)); } } else { CourseBase.BuildCourse((int)Utility.FromName <UnityEditor.BuildTarget>(BuildTarget)); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(MainToolUI.NormalMode); if (!MainToolUI.NormalMode || BuildTarget != UnityEditor.BuildTarget.WebPlayerStreamed.ToString()) { Move(1.3f, 0.35f); Background(2.0f, 0.35f); Background(2.0f, 0.35f); BuildTarget = EditorGUI.EnumPopup(GetRect(2.0f, 1.0f), Utility.FromName <UnityEditor.BuildTarget>(BuildTarget)).ToString(); Color color = GUI.color; SetColor(Black); Move(-0.45f, -0.15f); MovePixels(1, 1); Label("►", 3, 3, EditorStyles.largeLabel); MovePixels(-1, -1); SetColor(); GUI.color = color; Move(-0.01f, 0.01f); Label("►", 3, 3, EditorStyles.largeLabel); Move(-0.05f, -0.6f); } EditorGUI.EndDisabledGroup(); SetColor(); Move(1, 0); Move(3, 0); EditorGUI.BeginDisabledGroup(!PlatformBase.IO.IsEditor); if (!MainToolUI.CommunityMode) { Background(2); if (Button(importTexture)) { string path = PlatformBase.Editor.OpenFileDialog("Load .geojson", PlatformBase.IO.CoursesPath, "geojson"); if (!string.IsNullOrEmpty(path)) { GeoJSON.ImportSplines(path); } } Move(1, 0); if (Button(exportTexture)) { string path = PlatformBase.Editor.SaveFileDialog("Save .geojson", PlatformBase.IO.CoursesPath, "", "geojson"); if (!string.IsNullOrEmpty(path)) { GeoJSON.ExportSplines(path); } } Move(1, 0); Background(4); Label("Export Terrain Step", 2.7f); Move(0, 0.35f); ExportTerrainStep = FloatSlider(ExportTerrainStep, 0.01f, 10.0f, 3.0f, 0.6f); Move(0, -0.35f); Move(3, 0); if (Button(terrainTexture)) { string path = PlatformBase.Editor.SaveFileDialog("Save .bil", PlatformBase.IO.CoursesPath, "", "bil"); if (!string.IsNullOrEmpty(path)) { GeoJSON.ExportTerrain(path, ExportTerrainStep); } } Move(1, 0); } EditorGUI.EndDisabledGroup(); EndUI(); }
public override void OnUI(bool selected) { #region Key Events if (Event.current.keyCode == KeyCode.Tab && Event.current.type == EventType.keyDown) { if (EULA == false) { EULA = true; } else if (SceneView.lastActiveSceneView.orthographic) { SceneView.lastActiveSceneView.orthographic = false; } else if (Tools.current != UnityEditor.Tool.View) { Tools.current = UnityEditor.Tool.View; } else if (PlatformBase.IO.IsEditor) { if (PlatformBase.Editor.ActiveTransform == null) { PlatformBase.Editor.ActiveTransform = CourseBase.Terrain.transform; } else { PlatformBase.Editor.ActiveTransform = null; } } Event.current.Use(); } #endregion BeginUI(); MoveToRight(); Move(-3, 0); Background(); if (Button(xTexture)) { DisablePerform(); } MoveToLeft(); Background(); if (!ToolLocked) { Move(0, 1); Background(1, Screen.height / BoxSize - 1); Move(0, -1); } Move(1, 0); if (SelectedTool != Tool.None) { Background(Screen.width / BoxSize - 3); } Move(-1, 0); #region Banner Messages if (EULA == false) { if (Button(wwwTexture)) { SelectedTool = SelectedTool; } Move(1, 0); SetColor(HalfGreen); if (Button("End User License Agreement - Press TAB to agree", 8)) { EULA = true; } SetColor(); Move(-1, 0); Move(0, 1); Background(Screen.width / BoxSize - 2, Screen.height / BoxSize - 1); Background(Screen.width / BoxSize - 2, Screen.height / BoxSize - 1); GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.wordWrap = true; labelStyle.normal.textColor = Color.white; Rect scrollViewRect = GetRect(Screen.width / BoxSize - 2, (Screen.height - TopBoxHeight) / BoxSize - 1); float textHeight = 0; for (int i = 0; i < eulaText.Length; i += 4096) { string text = eulaText.Substring(i, Mathf.Min(eulaText.Length - i, 4096)); if (text.Contains("\n") && text.Length == 4096) { int index = text.LastIndexOf("\n"); text = eulaText.Substring(i, index); i += index; i -= 4096; } textHeight += labelStyle.CalcHeight(new GUIContent(text), scrollViewRect.width - 20); } Rect textRect = new Rect(0, 0, scrollViewRect.width - 20, textHeight); eulaScrollPos = GUI.BeginScrollView(scrollViewRect, eulaScrollPos, textRect); for (int i = 0; i < eulaText.Length; i += 4096) { string text = eulaText.Substring(i, Mathf.Min(eulaText.Length - i, 4096)); if (text.Contains("\n") && text.Length == 4096) { int index = text.LastIndexOf("\n"); text = eulaText.Substring(i, index); i += index; i -= 4096; } textRect.height = labelStyle.CalcHeight(new GUIContent(text), scrollViewRect.width - 20); SetColor(Black); GUI.Label(new Rect(textRect.x + 1, textRect.y + 1, textRect.width, textRect.height), text, labelStyle); SetColor(); GUI.Label(textRect, text, labelStyle); textRect.y += textRect.height; } GUI.EndScrollView(); Move(0, -1); EndUI(); return; } else if (SceneView.lastActiveSceneView.orthographic) { if (Button(wwwTexture)) { SelectedTool = SelectedTool; } Move(1, 0); SetColor(HalfGreen); if (Button("CourseForge has limited functionality in ISO mode, press TAB to switch back", 14)) { SceneView.lastActiveSceneView.orthographic = false; } SetColor(); Move(-1, 0); EndUI(); return; } else if (Tools.current != UnityEditor.Tool.View) { if (Button(wwwTexture)) { SelectedTool = SelectedTool; } Move(1, 0); SetColor(HalfGreen); if (Button("CourseForge has limited functionality in this view mode, press TAB to switch back", 14)) { Tools.current = UnityEditor.Tool.View; } SetColor(); Move(-1, 0); EndUI(); return; } else if (CourseBase.TerrainSelected) { if (Button(wwwTexture)) { SelectedTool = SelectedTool; } Move(1, 0); SetColor(HalfGreen); if (Button("Terrain Mode - Press TAB to exit", 6)) { PlatformBase.Editor.ActiveTransform = null; } SetColor(); Move(-1, 0); EndUI(); return; } else if (selected) { if (ToolButton(Tool.FileTool, wwwTexture)) { OnCleanup(); } Move(1, 0); if (SelectedTool > Tool.FileTool && Button((ToolName.Length > 8 ? ToolName.Substring(0, 8) + "..." : ToolName), 2)) { GameObject toolObject = GameObject.Find(ToolName); if (toolObject != null) { EditorGUIUtility.PingObject(toolObject); Selection.activeGameObject = toolObject; } } Move(-1, 0); } Move(0, 1); #endregion #region Top if (ToolButton(Tool.SplineTool, freehandTexture)) { OnCleanup(); if (CourseBase.TerrainLowered) { CourseBase.RestoreTerrain(); } } Move(0, 1); if (ToolButton(Tool.PlantTool, plantTexture)) { OnCleanup(); if (CourseBase.TerrainLowered) { CourseBase.RestoreTerrain(); } } Move(0, 1); if (Button(terrainTexture)) { SelectedTool = Tool.None; OnCleanup(); if (PlatformBase.IO.IsEditor) { PlatformBase.Editor.ActiveTransform = CourseBase.Terrain.transform; } } Move(0, 1); if (CourseBase.TerrainLowered) { SetColor(Red); } if (Button(terrainLoweredTexture)) { SelectedTool = Tool.None; OnCleanup(); if (!CourseBase.TerrainLowered) { CourseBase.SaveTerrain(); CourseBase.LowerTerrain(); } else { CourseBase.RestoreTerrain(); } } SetColor(); Move(0, 1); if (Button(updateTexture)) { if (CourseBase.TerrainLowered) { CourseBase.RestoreTerrain(); } CourseBase.RefreshCourse(); } Move(0, 1); if (Button(buildSplinesTexture)) { if (CourseBase.TerrainLowered) { CourseBase.RestoreTerrain(); } PopupToolUI.Clear(); CourseBase.BakeSplines(true); } Move(0, 1); #endregion #region Bottom MoveToBottom(); Move(0, -1); if (HideLines) { SetColor(HalfGrey); } if (Button(splineEyeTexture)) { HideLines = !HideLines; } SetColor(); Move(0, -1); if (AutoHide) { SetColor(HalfGrey); } if (Button(autoEyeTexture)) { AutoHide = !AutoHide; } SetColor(); Move(0, -1); if (HideMeshes) { SetColor(HalfGrey); } if (Button(eyeTexture)) { AutoHide = false; HideMeshes = !HideMeshes; List <SplineBase> splines = CourseBase.Splines; for (int i = 0; i < splines.Count; ++i) { splines[i].Renderer.UpdateVisibility(splines[i], !HideMeshes); } } SetColor(); Move(0, -1); if (MainToolUI.NormalMode) { EditorGUI.BeginDisabledGroup(true); LayerPanel = false; } if (LayerPanel) { SetColor(Green); } if (Button(layersTexture)) { LayerPanel = !LayerPanel; } SetColor(); Move(0, -1); if (MainToolUI.NormalMode) { EditorGUI.EndDisabledGroup(); } #endregion EndUI(); }
public override void OnScene(bool selected) { #region ProgressBar if (CourseBase.BuildSplinesCount != 0) { float count = CourseBase.BuildSplinesCount; float buildLineCount = CourseBase.BuildLineSplines.Count; float buildCount = CourseBase.BuildSplines.Count; float progress = buildLineCount / count * 0.5f + buildCount / count * 0.5f; string text = "Done"; if (buildLineCount != 0) { text = "Updating " + CourseBase.BuildLineSplines[0].name; } else if (buildCount != 0) { text = "Building " + CourseBase.BuildSplines[0].name; } if (EditorUtility.DisplayCancelableProgressBar("Build progress bar", text, 1.0f - progress)) { CourseBase.BuildLineSplines.Clear(); CourseBase.BuildSplines.Clear(); CourseBase.BuildSplinesCount = 0; } else { SplineBase spline = null; if (CourseBase.BuildLineSplines.Count != 0) { spline = CourseBase.BuildLineSplines[0]; } else if (CourseBase.BuildSplines.Count != 0) { spline = CourseBase.BuildSplines[0]; } Exception exception = CourseBase.DoSplineBakeStep(); if (exception != null) { string message = exception.Message; if (exception.StackTrace.Contains("Poly2Tri.DTSweep.FinalizationPolygon (Poly2Tri.DTSweepContext tcx)")) { message = "Too big extra/shrink."; } if (exception.StackTrace.Contains("New points from triangulation.")) { message = "Wrong spline shape or/and lines are crossed."; } if (exception.Message.Contains("stack overflow")) { message = "Too many vertices in one mesh."; } Debug.LogException(exception); if (spline && !string.IsNullOrEmpty(message)) { PopupToolUI.Add(message, "Focus", spline.name); } } } progressBar = true; } else if (GeoJSON.Exporting) { float progress = GeoJSON.Progress; string text = "Done"; if (progress != 1) { text = "Exporting " + (progress * 100).ToString("F2") + "%"; } if (EditorUtility.DisplayCancelableProgressBar("Export progress bar", text, progress)) { GeoJSON.CancelExport(); } else { for (int i = 0; i < 10000; ++i) { GeoJSON.DoExportTerrainStep(); } } progressBar = true; } else { if (progressBar) { EditorUtility.ClearProgressBar(); progressBar = false; } } #endregion if (selected) { OnAutoHide(); OnAutoTerrain(); Update(); if (!HideLines) { splineTool.OnScene(SelectedTool == Tool.SplineTool); } if (!HideLines) { plantTool.OnScene(SelectedTool == Tool.PlantTool); } } OnUI(selected); if (selected) { if (!ToolLocked) { if (LayerPanel) { layerTool.OnUI(true); } if (InfoPanel) { infoTool.OnUI(true); } if (WarningPanel) { popupTool.OnUI(true); } if (AndroidPanel) { androidTool.OnUI(true); } fileTool.OnUI(SelectedTool == Tool.FileTool); plantTool.OnUI(SelectedTool == Tool.PlantTool); splineTool.OnUI(SelectedTool == Tool.SplineTool); } HandleUtility.Repaint(); } #region Touch BeginUI(); if (!ToolLocked) { Touch(1, Screen.height / BoxSize); } if (SelectedTool != Tool.None) { Touch(Screen.width / BoxSize - 2, 1); } EndUI(); #endregion #region Tooltip if (!string.IsNullOrEmpty(GUI.tooltip)) { string text = GUI.tooltip; Rect rect = new Rect(); rect.x = Event.current.mousePosition.x; rect.y = Event.current.mousePosition.y; rect.width = GUI.skin.label.CalcSize(new GUIContent(text)).x; rect.height = GUI.skin.label.CalcSize(new GUIContent(text)).y; BeginUI(); MoveToPixels((int)rect.x, (int)rect.y); SetBoxSize((int)rect.width, (int)rect.height); Background(1, 1, 0.9f); LabelNoOffset(text); EndUI(); } #endregion }