private void StartUpdateProcess() { try { Context.Logger.Info($"===> [{UpdateProcessName}] process STARTED! <==="); if (!NetworkChecker.IsNetworkAvailable()) { Data.Log(Context.LocalizedMessages.NotAvailableNetwork); Data.Dialog.ShowCloseDialog(Context.LocalizedMessages.NotAvailableNetwork, string.Empty, Application.Quit); Context.Logger.Error(null, $"[{UpdateProcessName}] process FAILED! Network is not available or connectivity is low/weak... Check your connection!"); return; } if (!NetworkChecker.IsRemoteServiceAvailable(Context.Settings.GetRemoteBuildsIndexUrl())) { Data.Log(Context.LocalizedMessages.NotAvailableServers); Data.Dialog.ShowCloseDialog(Context.LocalizedMessages.NotAvailableServers, string.Empty, Application.Quit); Context.Logger.Error(null, $"[{UpdateProcessName}] process FAILED! Our servers are not responding... Wait some minutes and retry!"); return; } Context.Initialize(); Task.Run(CheckForUpdates); } catch (Exception ex) { Data.Log(Context.LocalizedMessages.UpdateProcessFailed); Context.Logger.Error(ex, $"===> [{UpdateProcessName}] process FAILED! <==="); } }
public async Task SearchIgnoresCase() { DoppelCommandFactory.SetupStaticCommandFactory(); var gameFavoriter = new DoppelGameFavoriter(); var favoriteFetcher = new DoppelFavoriteGameFetcher(); var querier = new DoppelFavoriteGameQuerier(); var networkChecker = new NetworkChecker(); var doppelFetcher = new DoppelGameFetcher() { Games = new GameViewModel[] { NewGame("SoA", 1, gameFavoriter, querier), NewGame("s", 2, gameFavoriter, querier) } }; var viewModel = new MainPageViewModel(doppelFetcher, favoriteFetcher, networkChecker); await viewModel.Refresh(); viewModel.SearchText = "s"; var expectedCount = 2; var actualCount = viewModel.Games.Count(); Assert.AreEqual(expectedCount, actualCount); }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { var isInternetConnectionActive = NetworkChecker.IsIntenetConnectionAvailable(); if (!isInternetConnectionActive) { new MessageDialog("No internet Connection").ShowAsync(); return; } this.navigationHelper.OnNavigatedTo(e); }
void Start() { // Load custom textures and audio clips { if (ResourceLoader.TryGetAsset("Custom/Textures/hud.png", out Texture2D hudTextures)) { GameObject backgroundGo = GameObject.Find("Background"); if (backgroundGo != null) { Material uiMat = backgroundGo.GetComponent <UISprite>().material; uiMat.mainTextureScale = hudTextures.GetScaleVector(2048, 2048); uiMat.mainTexture = hudTextures; } } StartCoroutine(CoWaitAndSetParticleTexture()); } GuiController = base.gameObject.AddComponent <Ui.GuiController>(); base.gameObject.AddComponent <MicEF>(); if (!IsFirstInit) { return; } IsFirstInit = false; // Load skin validation service SkinChecker.Init(); // Load name and guild (if possible) FengGameManagerMKII.NameField = PlayerPrefs.GetString("name", string.Empty); if (FengGameManagerMKII.NameField.StripNGUI().Length < 1) { FengGameManagerMKII.NameField = LoginFengKAI.Player.Name; } LoginFengKAI.Player.Guild = PlayerPrefs.GetString("guildname", string.Empty); // Load various features Commands.Load(); Gamemodes.Load(); Properties.Load(); // Load network validation service NetworkChecker.Init(); DiscordRPC.StartTime = GameHelper.CurrentTimeMillis(); DiscordRPC.Initialize(); // Check for an update StartCoroutine(CoCheckForUpdate()); }
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e) { var state = NetworkChecker.IsNetworkAvailable(); if (state) { ToolTipText = GetLocalIPString(); } else { ToolTipText = "网络状态丢失"; } }
protected override void Initialize(UpdatingContext context) { context.OverrideSettings <SettingsOverride>((originalSettings, settingsOverride) => { originalSettings.DebugMode = settingsOverride.DebugMode; originalSettings.PatcherUpdaterSafeMode = settingsOverride.PatcherUpdaterSafeMode; }); context.Downloader.DownloadComplete += Data.DownloadComplete; NetworkChecker = new NetworkChecker(); _patcherUpdater = new PatcherUpdater(context); context.RegisterUpdateStep(_patcherUpdater); context.Runner.PerformedStep += (sender, updater) => { if (context.IsDirty(out var reasons, out var data)) { var stringReasons = ""; foreach (var reason in reasons) { stringReasons += $"{reason}, "; } stringReasons = stringReasons.Substring(0, stringReasons.Length - 2); context.Logger.Debug( $"Context is set to dirty: updater restart required. The files {stringReasons} have been replaced."); if (data.Count > 0) { if (data[0] is UpdaterSafeModeDefinition) { var definition = (UpdaterSafeModeDefinition)data[0]; UpdateRestartNeeded(definition.ExecutableToRun); return; } } UpdateRestartNeeded(); } }; _timeFromLastCheck = TimeBetweenEachCheckInSeconds; _isPreviousUpdateCompleted = true; Data.ProgressBar.gameObject.SetActive(false); }
protected override void Initialize(UpdatingContext context) { context.OverrideSettings <SettingsOverride>((originalSettings, settingsOverride) => { originalSettings.DebugMode = settingsOverride.DebugMode; originalSettings.PatcherUpdaterSafeMode = settingsOverride.PatcherUpdaterSafeMode; }); NetworkChecker = new NetworkChecker(); _repairer = new Repairer(context); _repairer.Downloader.DownloadComplete += Data.DownloadComplete; _updater = new Updater(context); _updater.Downloader.DownloadComplete += Data.DownloadComplete; context.RegisterUpdateStep(_repairer); context.RegisterUpdateStep(_updater); context.Runner.PerformedStep += (sender, updater) => { if (context.IsDirty(out var reasons, out var data)) { var stringReasons = ""; foreach (var reason in reasons) { stringReasons += $"{reason}, "; } stringReasons = stringReasons.Substring(0, stringReasons.Length - 2); context.Logger.Debug($"Context is set to dirty: updater restart required. The files {stringReasons} have been replaced."); if (data.Count > 0) { if (data[0] is UpdaterSafeModeDefinition) { var definition = (UpdaterSafeModeDefinition)data[0]; UpdateRestartNeeded(definition.ExecutableToRun); return; } } UpdateRestartNeeded(); } }; }
void OnLevelWasLoaded(int level) { ApplyCustomRenderSettings(); if (IN_GAME_MAIN_CAMERA.Gametype == GameType.Singleplayer || PhotonNetwork.offlineMode) { string difficulty = IN_GAME_MAIN_CAMERA.Difficulty switch { 0 => "Normal", 1 => "Hard", 2 => "Abnormal", _ => "Training" }; DiscordRPC.SetPresence(new Discord.Activity { Details = $"Playing offline.", State = $"{FengGameManagerMKII.Level.Name} / {difficulty}" }); } if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnReset(); } if (HasJoinedRoom) { return; } HasJoinedRoom = true; string joinMessage = Properties.JoinMessage.Value.NGUIToUnity(); if (joinMessage.StripNGUI().Length < 1) { joinMessage = Properties.JoinMessage.Value; } if (joinMessage.Length < 1) { return; } Commands.Find("say").Execute(InRoomChat.Instance, joinMessage.Split(' ')); } void OnPhotonPlayerConnected(PhotonPlayer player) { if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnPlayerJoin(player); } Logger.Info($"({player.Id}) " + player.Username.NGUIToUnity() + " connected.".AsColor("00FF00")); } void OnPhotonPlayerDisconnected(PhotonPlayer player) { if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnPlayerLeave(player); } Logger.Info($"({player.Id}) " + player.Username.NGUIToUnity() + " disconnected.".AsColor("FF0000")); } void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps) { NetworkChecker.OnPlayerPropertyModification(playerAndUpdatedProps); ModDetector.OnPlayerPropertyModification(playerAndUpdatedProps); } void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { NetworkChecker.OnRoomPropertyModification(propertiesThatChanged); PhotonPlayer sender = null; if (propertiesThatChanged.ContainsKey("sender") && propertiesThatChanged["sender"] is PhotonPlayer player) { sender = player; } if (sender != null && !sender.isMasterClient) { return; } if (propertiesThatChanged.ContainsKey("Map") && propertiesThatChanged["Map"] is string mapName) { LevelInfo levelInfo = LevelInfo.GetInfo(mapName); if (levelInfo != null) { FengGameManagerMKII.Level = levelInfo; } } if (propertiesThatChanged.ContainsKey("Lighting") && propertiesThatChanged["Lighting"] is string lightLevel && GExtensions.TryParseEnum(lightLevel, out DayLight time)) { Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().SetLighting(time); } } void OnJoinedLobby() { // TODO: Begin working on Friend system with Photon Friend API PhotonNetwork.playerName = Properties.PhotonUserId.Value; } void OnJoinedRoom() { HasJoinedRoom = false; // TODO: Potentially use custom event/group combo to sync game-settings whilst not triggering other mods int[] groups = new int[byte.MaxValue]; for (int i = 0; i < byte.MaxValue; i++) { groups[i] = i + 1; } PhotonNetwork.SetReceivingEnabled(groups, null); PhotonNetwork.SetSendingEnabled(groups, null); PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable { { CustomPropertyName, Build } }); StartCoroutine(CoUpdateMyPing()); string[] roomInfo = PhotonNetwork.room.name.Split('`'); if (roomInfo.Length < 7) { return; } DiscordRPC.SetPresence(new Discord.Activity { Details = $"Playing in {(roomInfo[5].Length < 1 ? string.Empty : "[PWD]")} {roomInfo[0].StripNGUI()}", State = $"({NetworkHelper.GetRegionCode().ToUpper()}) {roomInfo[1]} / {roomInfo[2].ToUpper()}" }); }