IEnumerator OpenMoreInfoPopup(ReleaseInfo info) { bool isDone = false; var skin = _pmSettings.ReleaseMoreInfoDialog; Vector2 scrollPos = Vector2.zero; var popupId = _view.AddPopup(delegate(Rect fullRect) { var popupRect = ImguiUtil.CenterRectInRect(fullRect, skin.PopupSize); _view.DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, skin.PanelPadding); GUILayout.BeginArea(contentRect); { GUILayout.Label("Release Info", skin.HeadingStyle); GUILayout.Space(skin.HeadingBottomPadding); scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, skin.ScrollViewStyle, GUILayout.Height(skin.ListHeight)); { GUILayout.Space(skin.ListPaddingTop); PmViewHandlerCommon.AddReleaseInfoMoreInfoRows(info, skin); } GUI.EndScrollView(); } GUILayout.EndArea(); var okButtonRect = new Rect( contentRect.xMin + 0.5f * contentRect.width - 0.5f * skin.OkButtonWidth, contentRect.yMax - skin.MarginBottom - skin.OkButtonHeight, skin.OkButtonWidth, skin.OkButtonHeight); if (GUI.Button(okButtonRect, "Ok") || Event.current.keyCode == KeyCode.Escape) { isDone = true; } }); while (!isDone) { yield return(null); } _view.RemovePopup(popupId); }
void DisplayGenericProcessingDialog(Rect fullRect) { var skin = _pmSettings.AsyncPopupPane; var popupRect = ImguiUtil.CenterRectInRect(fullRect, skin.PopupSize); DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, skin.PanelPadding); GUILayout.BeginArea(contentRect); { string title; if (string.IsNullOrEmpty(BlockedStatusTitle)) { title = "Processing"; } else { title = BlockedStatusTitle; } GUILayout.Label(title, skin.HeadingTextStyle, GUILayout.ExpandWidth(true)); GUILayout.Space(skin.HeadingBottomPadding); string statusMessage = ""; if (!string.IsNullOrEmpty(BlockedStatusMessage)) { statusMessage = BlockedStatusMessage; int numExtraDots = (int)(Time.realtimeSinceStartup * skin.DotRepeatRate) % 4; statusMessage += new String('.', numExtraDots); // This is very hacky but the only way I can figure out how to keep the message a fixed length // so that the text doesn't jump around as the number of dots change // I tried using spaces instead of _ but that didn't work statusMessage += ImguiUtil.WrapWithColor(new String('_', 3 - numExtraDots), _settings.Theme.LoadingOverlapPopupColor); } GUILayout.Label(statusMessage, skin.StatusMessageTextStyle, GUILayout.ExpandWidth(true)); } GUILayout.EndArea(); }
IEnumerator OpenMoreInfoPopup(PackageInfo info) { bool isDone = false; var skin = _pmSettings.ReleaseMoreInfoDialog; Vector2 scrollPos = Vector2.zero; var popupId = _view.AddPopup(delegate(Rect fullRect) { var popupRect = ImguiUtil.CenterRectInRect(fullRect, skin.PopupSize); _view.DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, skin.PanelPadding); var scrollViewRect = new Rect( contentRect.xMin, contentRect.yMin, contentRect.width, contentRect.height - skin.MarginBottom - skin.OkButtonHeight - skin.OkButtonTopPadding); GUILayout.BeginArea(scrollViewRect); { scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, skin.ScrollViewStyle, GUILayout.ExpandHeight(true)); { GUILayout.Space(skin.ListPaddingTop); GUILayout.Label("Package Info", skin.HeadingStyle); GUILayout.Space(skin.HeadingBottomPadding); PmViewHandlerCommon.DrawMoreInfoRow(skin, "Name", info.Name); GUILayout.Space(skin.RowSpacing); PmViewHandlerCommon.DrawMoreInfoRow(skin, "Path", info.Path); GUILayout.Space(skin.RowSpacing); PmViewHandlerCommon.DrawMoreInfoRow(skin, "Creation Date", !string.IsNullOrEmpty(info.InstallInfo.InstallDate) ? info.InstallInfo.InstallDate : PmViewHandlerCommon.NotAvailableLabel); GUILayout.Space(skin.ListPaddingTop); GUILayout.Space(skin.ListPaddingTop); GUILayout.Label("Release Info", skin.HeadingStyle); GUILayout.Space(skin.HeadingBottomPadding); if (string.IsNullOrEmpty(info.InstallInfo.ReleaseInfo.Id)) { GUI.color = skin.ValueStyle.normal.textColor; GUILayout.Label("No release is associated with this package", skin.HeadingStyle); GUI.color = Color.white; } else { PmViewHandlerCommon.AddReleaseInfoMoreInfoRows(info.InstallInfo.ReleaseInfo, skin); } GUILayout.Space(skin.RowSpacing); } GUI.EndScrollView(); } GUILayout.EndArea(); var okButtonRect = new Rect( contentRect.xMin + 0.5f * contentRect.width - 0.5f * skin.OkButtonWidth, contentRect.yMax - skin.MarginBottom - skin.OkButtonHeight, skin.OkButtonWidth, skin.OkButtonHeight); if (GUI.Button(okButtonRect, "Ok") || Event.current.keyCode == KeyCode.Escape) { isDone = true; } }); while (!isDone) { yield return(null); } _view.RemovePopup(popupId); }
public IEnumerator <string> PromptForInput(string label, string defaultValue) { string userInput = defaultValue; InputDialogStates state = InputDialogStates.None; bool isFirst = true; var popupId = AddPopup(delegate(Rect fullRect) { if (Event.current.type == EventType.KeyDown) { switch (Event.current.keyCode) { case KeyCode.Return: { state = InputDialogStates.Submitted; break; } case KeyCode.Escape: { state = InputDialogStates.Cancelled; break; } } } var popupRect = ImguiUtil.CenterRectInRect(fullRect, _pmSettings.InputDialog.PopupSize); DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, _pmSettings.InputDialog.PanelPadding); GUILayout.BeginArea(contentRect); { GUILayout.Label(label, _pmSettings.InputDialog.LabelStyle); GUI.SetNextControlName("PopupTextField"); userInput = GUILayout.TextField(userInput, 100); GUI.SetNextControlName(""); GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Submit", GUILayout.MaxWidth(100))) { state = InputDialogStates.Submitted; } if (GUILayout.Button("Cancel", GUILayout.MaxWidth(100))) { state = InputDialogStates.Cancelled; } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); if (isFirst) { isFirst = false; // Need to remove focus then regain focus on the text box for it to select the whole contents GUI.FocusControl(""); } else if (string.IsNullOrEmpty(GUI.GetNameOfFocusedControl())) { GUI.FocusControl("PopupTextField"); } }); while (state == InputDialogStates.None) { yield return(null); } RemovePopup(popupId); if (state == InputDialogStates.Submitted) { yield return(userInput); } else { // Just return null } }
IEnumerator <PopupChoices> ShowPopup() { var label = "Enter new project name:"; var choices = new PopupChoices(); choices.NewProjectName = "Untitled"; PmView.InputDialogStates state = PmView.InputDialogStates.None; bool isFirst = true; var popupId = _view.AddPopup(delegate(Rect fullRect) { if (Event.current.type == EventType.KeyDown) { switch (Event.current.keyCode) { case KeyCode.Return: { state = PmView.InputDialogStates.Submitted; break; } case KeyCode.Escape: { state = PmView.InputDialogStates.Cancelled; break; } } } var popupRect = ImguiUtil.CenterRectInRect(fullRect, _settings.PopupSize); _view.DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, _pmSettings.InputDialog.PanelPadding); GUILayout.BeginArea(contentRect); { GUILayout.Label(label, _pmSettings.InputDialog.LabelStyle); GUI.SetNextControlName("PopupTextField"); choices.NewProjectName = GUILayout.TextField(choices.NewProjectName, 100); GUI.SetNextControlName(""); GUILayout.Space(5); GUILayout.BeginHorizontal(); { choices.DuplicateSettings = GUILayout.Toggle(choices.DuplicateSettings, "", GUILayout.Height(_settings.CheckboxHeight)); GUILayout.Label("Share Project Settings with '{0}'".Fmt(ProjenyEditorUtil.GetCurrentProjectName())); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Submit", GUILayout.MaxWidth(100))) { state = PmView.InputDialogStates.Submitted; } if (GUILayout.Button("Cancel", GUILayout.MaxWidth(100))) { state = PmView.InputDialogStates.Cancelled; } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); if (isFirst) { isFirst = false; // Need to remove focus then regain focus on the text box for it to select the whole contents GUI.FocusControl(""); } else if (string.IsNullOrEmpty(GUI.GetNameOfFocusedControl())) { GUI.FocusControl("PopupTextField"); } }); while (state == PmView.InputDialogStates.None) { yield return(null); } _view.RemovePopup(popupId); if (state == PmView.InputDialogStates.Submitted) { yield return(choices); } else { // Just return null } }