public override void OnGUI(Rect position) { Styles.Init(); GUILayout.Label(Content.welcomeText, GlobalStyles.welcomeTextStyle); var selectorRect = GUILayoutUtility.GetRect(position.width, 260); selector.Draw(selectorRect); GUILayout.BeginVertical(Styles.extraStyle); GUILayout.Label(Content.extraText, EditorStyles.boldLabel); EditorGUIUtility.SetIconSize(new Vector2(16, 16)); var noExtrasToShow = true; var documentPath = GetDocumentationPath(); if (!string.IsNullOrEmpty(documentPath)) { GlobalStyles.LayoutExternalLink(Content.documentationText, GetDocumentationPath()); noExtrasToShow = false; } var demoPath = GetDemoPath(); if (!string.IsNullOrEmpty(demoPath)) { if (GlobalStyles.LayoutButtonLink(Content.viewDemoText)) { EditorSceneManager.OpenScene(demoPath, OpenSceneMode.Single); } noExtrasToShow = false; } if (noExtrasToShow) { GUILayout.Label(Content.noExtrasText); } GUILayout.EndVertical(); }
public override void OnGUI(Rect position) { Styles.Init(); position = ApplySettingsPadding(position); GUILayout.BeginArea(position); GUILayout.FlexibleSpace(); var img = Content.logo; var imgRect = GUILayoutUtility.GetRect(img.width, img.height); GUI.DrawTexture(imgRect, img, ScaleMode.ScaleToFit); GUILayout.Space(30); GUILayout.Label(Content.aboutVersionText, Styles.aboutVersionStyle); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.Label(Content.createdByText, Styles.createdByTextStyle, GUILayout.Width(160)); GUILayout.Space(10); GUILayout.Label(Content.c1, EditorStyles.boldLabel); GlobalStyles.LayoutExternalLink(Content.c1WebsiteText, Content.c1WebsiteLink); GlobalStyles.LayoutExternalLink(Content.c1EmailText, Content.c1EmailLink); GlobalStyles.LayoutExternalLink(Content.c1TwitterText, Content.c1TwitterLink); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.Label(Content.createdByText2, Styles.createdByTextStyle, GUILayout.Width(160)); GUILayout.Space(10); GUILayout.Label(Content.c2, EditorStyles.boldLabel); GlobalStyles.LayoutExternalLink(Content.c2TwitterText, Content.c2TwitterLink); GlobalStyles.LayoutExternalLink(Content.c2WebsiteText, Content.c2WebsiteLink); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Space(25); GUILayout.Label(Content.disclaimerText, Styles.disclaimerStyle); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndArea(); }
public override void OnGUI(Rect position) { Styles.Init(); position = ApplySettingsPadding(position); GUILayout.BeginArea(position); { GUILayout.Label(title, GlobalStyles.settingsHeaderText); EditorGUILayout.Space(); // rating bar EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(Content.ratingPrompt, EditorStyles.boldLabel); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var starColor = EditorGUIUtility.isProSkin ? Styles.proStarColor : Styles.nonProStarColor; if (rating == maxRating) { starColor = Styles.maxRatingStarColor; } GlobalStyles.BeginColorArea(starColor); for (int i = 0; i < maxRating; i++) { var starRect = GUILayoutUtility.GetRect(GUIContent.none, Styles.ratingStyle); // use manual mouse events in order to trigger on mouse down rather than mouse up if (Event.current.type == EventType.Repaint) { Styles.ratingStyle.Draw(starRect, GUIContent.none, false, false, i < rating, false); } else if (Event.current.type == EventType.MouseDown) { if (starRect.Contains(Event.current.mousePosition)) { var oldRating = rating; rating = i + 1; EditorPrefs.SetInt("pkpro_feedback_rating", rating); UpdateFaders(); if (timedFeedbackPopupMode) { fadeTimedPopupModeBody.target = true; // snap to target on first use if (oldRating == 0) { fadeRatingPopup.value = fadeRatingPopup.target; fadeSupportPopup.value = fadeSupportPopup.target; } } Event.current.Use(); window.Repaint(); } } EditorGUIUtility.AddCursorRect(starRect, MouseCursor.Link); } GlobalStyles.EndColorArea(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (timedFeedbackPopupMode) { GlobalStyles.BeginColorArea(Color.Lerp(new Color(1, 1, 1, 0), Color.white, fadeTimedPopupModeBody.faded)); } GUILayout.Space(5); //Rating Dialog if (EditorGUILayout.BeginFadeGroup(fadeRatingPopup.faded)) { EditorGUILayout.LabelField(Content.ReviewText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.RatingLinkText, Content.RatingLink); } EditorGUILayout.EndFadeGroup(); //Support dialog if (EditorGUILayout.BeginFadeGroup(fadeSupportPopup.faded)) { EditorGUILayout.LabelField(Content.SupportText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.SupportLinkText, Content.s1WebsiteLink); } EditorGUILayout.EndFadeGroup(); //Feedback Email //Feedback input box GUI.enabled = !hasSubmitted; { float minHeight = EditorGUIUtility.singleLineHeight * 4; // @Hack to get textarea to properly scale with text var textRect = GUILayoutUtility.GetRect(0, 999, 0, 0); textRect.height = Styles.feedbackTextAreaStyle.CalcHeight(new GUIContent(feedbackText), textRect.width); textRect = GUILayoutUtility.GetRect(textRect.width, textRect.height, Styles.feedbackTextAreaStyle, GUILayout.MinHeight(minHeight)); feedbackText = EditorGUI.TextArea(textRect, feedbackText, Styles.feedbackTextAreaStyle); if (string.IsNullOrEmpty(feedbackText)) { GlobalStyles.BeginColorArea(new Color(1, 1, 1, GUI.color.a * 0.6f)); var placeholderContent = rating == maxRating ? Content.highRatingPlaceholder : Content.lowRatingPlaceholder; GUI.Label(textRect, placeholderContent, Styles.feedbackPlaceholderStyle); GlobalStyles.EndColorArea(); } var buttonContent = hasSubmitted ? Content.submittedButton : Content.submitButton; if (GUILayout.Button(buttonContent)) { hasSubmitted = true; CreateAndSendFeedbackReport(); } } GUI.enabled = true; GUILayout.FlexibleSpace(); EditorGUILayout.Space(); //Content submission GUILayout.Label(Content.GalleryText, EditorStyles.boldLabel); GUILayout.Label(Content.GalleryResponseText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.GalleryLinkText, Content.GalleryLink); EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); GUILayout.Label(Content.supportLabel, EditorStyles.boldLabel); GlobalStyles.LayoutExternalLink(Content.s1Text, Content.s1WebsiteLink); if (!string.IsNullOrEmpty(documentPath)) { GlobalStyles.LayoutExternalLink(Content.s2Text, documentPath); } } if (timedFeedbackPopupMode) { GlobalStyles.EndColorArea(); } GUILayout.EndArea(); }
public override void OnGUI(Rect position) { position = ApplySettingsPadding(position); Styles.Init(); GUILayout.BeginArea(position); { GUILayout.Label(title, Styles.TitleStyle); EditorGUIUtility.labelWidth = 250; position.x = 0; position.y = 0; EditorGUILayout.Space(); } GUILayout.EndArea(); position = ApplySettingsPadding(position); GUILayout.BeginArea(position); { hasNotRatedFadePopup.target = !hasRated; GUILayout.Space(30); //Star Bar if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { //GUILayout.FlexibleSpace(); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(Content.ratingPrompt, Styles.subHeadingStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { //Rating selector is invisible GlobalStyles.StartColorArea(Color.clear); //Push ratings bar to middle //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { GUILayout.FlexibleSpace(); //Ensure maximum middle-ness EditorGUILayout.IntField(0, GUILayout.MaxWidth(EditorGUIUtility.fieldWidth)); } //EditorGUILayout.EndFadeGroup(); //Rating selector EditorGUI.BeginChangeCheck(); rating = EditorGUILayout.IntSlider(rating, 1, maxRating, GUILayout.MaxWidth(starSizeFull + EditorGUIUtility.fieldWidth)); if (EditorGUI.EndChangeCheck()) { hasRated = true; } GlobalStyles.EndColorArea(); Rect lastRect = GUILayoutUtility.GetLastRect(); Rect filledStarRect = new Rect(lastRect.x, lastRect.y - (starSize / 8f), starSizeFull / (maxRating / (float)rating), starSize); Rect emptyStarRect = new Rect(filledStarRect.x + filledStarRect.width, filledStarRect.y, starSizeFull - filledStarRect.width, starSize); //Draw full stars if (!hasRated) { GUI.DrawTextureWithTexCoords( new Rect(filledStarRect.x, filledStarRect.y, starSizeFull, starSize), Styles.starEmptyTex, new Rect(0, 0, maxRating, 1)); } else if (rating < maxRating) { GlobalStyles.StartColorArea(new Color(0.2755f, 0.2755f, 0.2755f, 1)); GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1)); GlobalStyles.EndColorArea(); } else { GlobalStyles.StartColorArea(new Color(1, 0.61f, 0, 1)); GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1)); GlobalStyles.EndColorArea(); } if (hasRated) { //Draw empty stars GlobalStyles.StartColorArea(EditorGUIUtility.isProSkin ? Color.white : new Color(0.2755f, 0.2755f, 0.2755f, 1)); GUI.DrawTextureWithTexCoords(emptyStarRect, Styles.starEmptyTex, new Rect(0, 0, maxRating - rating, 1)); GlobalStyles.EndColorArea(); } } //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { GUILayout.FlexibleSpace(); //} //EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndHorizontal(); hasRatedFadePopup.target = hasRated; if (EditorGUILayout.BeginFadeGroup(hasRatedFadePopup.faded)) { GUILayout.Space(5); //Show the rating dialog if rating is full fadeRatingPopup.target = rating == maxRating; //Show the support dialog if rating is less than the support level fadeSupportPopup.target = rating < supportRating && hasRated; //Rating Dialog if (EditorGUILayout.BeginFadeGroup(fadeRatingPopup.faded)) { EditorGUILayout.LabelField(Content.ReviewText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.RatingLinkText, Content.RatingLink); } EditorGUILayout.EndFadeGroup(); //Support dialog if (EditorGUILayout.BeginFadeGroup(fadeSupportPopup.faded)) { EditorGUILayout.LabelField(Content.SupportText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.SupportLinkText, Content.s1WebsiteLink); } EditorGUILayout.EndFadeGroup(); //Feedback Email //Feedback input box GUI.enabled = !hasSubmitted; { float minHeight = EditorGUIUtility.singleLineHeight * 3; //Expand the textbox if required if ((rating == maxRating) && !String.IsNullOrEmpty(feedbackText)) { int count = feedbackText.Split('\n').Length; if (count > 3) { minHeight = count * EditorGUIUtility.singleLineHeight; } } else if ((rating < maxRating) && !String.IsNullOrEmpty(feedbackText2)) { int count = feedbackText2.Split('\n').Length; if (count > 3) { minHeight = count * EditorGUIUtility.singleLineHeight; } } if (!hasSubmitted) { if (rating < maxRating && hasRated) { feedbackText2 = EditorGUILayout.TextArea(feedbackText2, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } else { feedbackText = EditorGUILayout.TextArea(feedbackText, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } } else { EditorGUILayout.LabelField(feedbackText, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } if (!hasSubmitted && GUILayout.Button(Content.SubmitFeedback)) { if (rating < maxRating && hasRated) { feedbackText = feedbackText2; } hasSubmitted = true; StringBuilder ratingAppendBuilder = new StringBuilder(); for (int i = 0; i < maxRating; i++) { if (i < rating) { ratingAppendBuilder.Append('★'); } else { ratingAppendBuilder.Append('☆'); } } ratingAppendBuilder.Append('|').Append(String.Format( "{0}|{1}.{2}.{3} ", Application.unityVersion, GlobalPortalSettings.MAJOR_VERSION, GlobalPortalSettings.MINOR_VERSION, GlobalPortalSettings.PATCH_VERSION)); ratingAppendBuilder.Append('|').Append(SKSGlobalRenderSettings.Instance.ToString()); ratingAppendBuilder.Append('|').Append(GlobalPortalSettings.Instance.ToString()); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.deviceUniqueIdentifier)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.graphicsDeviceName)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.operatingSystem)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.processorType)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.systemMemorySize)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.graphicsMemorySize)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", Application.platform)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", EditorUserBuildSettings.activeBuildTarget)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", PlayerSettings.stereoRenderingPath)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SetupUtility.projectMode.ToString())); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", Application.systemLanguage)); String feedbackNext = feedbackText; feedbackNext = feedbackNext.Replace(Environment.NewLine, " "); feedbackNext = feedbackNext.Replace("\n", " "); feedbackNext = feedbackNext.Replace("|", " "); feedbackNext = feedbackNext + '|' + ratingAppendBuilder; //Queue and send IRC message (wow such technology (I swear there is a reason we're doing it this way)) TcpClient socket = new TcpClient(); Int32 port = 7000; string server = "irc.rizon.net"; String chan = "#SKSPortalKitFeedback"; socket.Connect(server, port); StreamReader input = new System.IO.StreamReader(socket.GetStream()); StreamWriter output = new System.IO.StreamWriter(socket.GetStream()); String nick = SystemInfo.deviceName; output.Write( "USER " + nick + " 0 * :" + "ChunkBuster" + "\r\n" + "NICK " + nick + "\r\n" ); output.Flush(); Thread sendMsgThread = new Thread(() => { bool joined = false; while (true) { try { String buf = input.ReadLine(); //Debug.Log(buf); if (buf == null) { //Debug.Log("Null"); return; } //Send pong reply to any ping messages if (buf.StartsWith("PING ")) { output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush(); } if (buf[0] != ':') { continue; } /* IRC commands come in one of these formats: * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n * :SERVER COMAND ARGS ... :DATA\r\n */ //After server sends 001 command, we can set mode to bot and join a channel if (buf.Split(' ')[1] == "001") { output.Write( "MODE " + nick + " +B\r\n" + "JOIN " + chan + "\r\n" ); output.Flush(); joined = true; continue; } if (buf.Contains("End of /NAMES list")) { String[] outputText = feedbackNext.Split('\n'); foreach (string s in outputText) { output.Write("PRIVMSG " + chan + " :" + s + "\r\n"); output.Flush(); Thread.Sleep(200); } socket.Close(); return; } } catch (Exception) { //If this doesn't function perfectly then just dispose of it, not worth possibly causing issues with clients over network issues return; } } }); sendMsgThread.Start(); } if (hasSubmitted) { GUILayout.Button(Content.SubmittedFeedback); } } GUI.enabled = true; GUILayout.Space(20); //Content submission GUILayout.Label(Content.GalleryText, Styles.subHeadingStyle); GUILayout.Label(Content.GalleryResponseText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.GalleryLinkText, Content.GalleryLink); GUILayout.FlexibleSpace(); } else { GUILayout.FlexibleSpace(); } EditorGUILayout.EndFadeGroup(); GUILayout.Label(Content.supportLabel, Styles.subHeadingStyle); GlobalStyles.LayoutExternalLink(Content.s1Text, Content.s1WebsiteLink); GlobalStyles.LayoutExternalLink(Content.s2Text, Content.s2WebsiteLink); } GUILayout.EndArea(); }