/// <summary> /// Opens URL in Steam overlay or external browser. /// </summary> /// <param name="url">Url to open.</param> /// <param name="urlFriendlyName">Friendly name of URL to show in confirmation screen, e.g. Steam Workshop</param> public static void OpenUrlWithFallback(string url, string urlFriendlyName, bool useWhitelist = false) { if (useWhitelist && !IsUrlWhitelisted(url)) { MySandboxGame.Log.WriteLine("URL NOT ALLOWED: " + url);//gameplay may not be running yet, so no message box :-( return; } var confirmMessage = MyTexts.AppendFormat(new StringBuilder(), MyCommonTexts.MessageBoxTextOpenUrlOverlayNotEnabled, urlFriendlyName); OpenUrl(url, UrlOpenMode.SteamOrExternalWithConfirm, confirmMessage); }
/// <summary> /// Opens URL in Steam overlay or external browser. /// </summary> /// <param name="url">Url to open.</param> /// <param name="openMode">How to open the url.</param> public static void OpenUrl(string url, UrlOpenMode openMode, StringBuilder confirmMessage = null) { bool tryOverlay = (openMode & UrlOpenMode.SteamOverlay) != 0; bool tryExternal = (openMode & UrlOpenMode.ExternalBrowser) != 0; bool confirm = (openMode & UrlOpenMode.ConfirmExternal) != 0; bool steamOverlayShown = tryOverlay && Gui.OpenSteamOverlay(url); if (MyFakes.XBOX_PREVIEW) { MyGuiSandbox.Show(MySpaceTexts.MessageBoxTextErrorFeatureNotAvailableYet, MySpaceTexts.MessageBoxCaptionError); } else { if (!steamOverlayShown && tryExternal) { if (confirm) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm), messageText : confirmMessage ?? MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MessageBoxTextOpenBrowser, url), callback : delegate(MyGuiScreenMessageBox.ResultEnum retval) { if (retval == MyGuiScreenMessageBox.ResultEnum.YES) { OpenExternalBrowser(url); } })); } else { OpenExternalBrowser(url); } } } }
private void OnClickReportBug(MyGuiControlButton obj) { MyGuiSandbox.OpenUrl(MyPerGameSettings.BugReportUrl, UrlOpenMode.SteamOrExternalWithConfirm, MyTexts.AppendFormat(new StringBuilder(), MyCommonTexts.MessageBoxTextOpenBrowser, "forums.keenswh.com")); }
private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer) { switch (result.State) { case MyDownloadWorldStateEnum.Success: progress.CloseScreen(); var world = multiplayer.ProcessWorldDownloadResult(result); if (MyFakes.ENABLE_BATTLE_SYSTEM && multiplayer.Battle) { MyGuiScreenLoadSandbox.LoadMultiplayerBattleWorld(world, multiplayer); } else { MyGuiScreenLoadSandbox.LoadMultiplayerSession(world, multiplayer); } break; case MyDownloadWorldStateEnum.InProgress: if (result.ReceivedBlockCount == 1) { MyLog.Default.WriteLine("First world part received"); } string percent = (result.Progress * 100).ToString("0."); float size = result.ReceivedDatalength; string prefix = MyUtils.FormatByteSizePrefix(ref size); string worldSize = size.ToString("0.") + " " + prefix + "B"; if (progress.Text != null) { progress.Text.Clear(); } if (float.IsNaN(result.Progress)) { MyLog.Default.WriteLine("World requested - preemble received"); if (progress.Text != null) { progress.Text.Append(MyTexts.Get(MySpaceTexts.DialogWaitingForWorldData)); } } else { if (progress.Text != null) { progress.Text.AppendFormat(MyTexts.GetString(MySpaceTexts.DialogTextDownloadingWorld), percent, worldSize); } } break; case MyDownloadWorldStateEnum.WorldNotAvailable: MyLog.Default.WriteLine("World requested - world not available"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogDownloadWorld_WorldDoesNotExists); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.ConnectionFailed: MyLog.Default.WriteLine("World requested - connection failed"); progress.Cancel(); MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MultiplayerErrorConnectionFailed, result.ConnectionError)); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.DeserializationFailed: case MyDownloadWorldStateEnum.InvalidMessage: MyLog.Default.WriteLine("World requested - message invalid (wrong version?)"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogTextDownloadWorldFailed); multiplayer.Dispose(); break; default: throw new InvalidBranchException(); } }
/// <summary> /// Opens URL in Steam overlay or external browser. /// </summary> /// <param name="url">Url to open.</param> /// <param name="urlFriendlyName">Friendly name of URL to show in confirmation screen, e.g. Steam Workshop</param> public static void OpenUrlWithFallback(string url, string urlFriendlyName) { var confirmMessage = MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MessageBoxTextOpenUrlOverlayNotEnabled, urlFriendlyName); OpenUrl(url, UrlOpenMode.SteamOrExternalWithConfirm, confirmMessage); }