public static void Postfix(SGNavigationScreen __instance) { HarmonyManager.LogExceptions(() => { MapType?newMapType = null; if (Input.GetKeyUp(KeyCode.F1)) { newMapType = MapType.None; } else if (Input.GetKeyUp(KeyCode.F2)) { newMapType = MapType.Difficulty; } else if (Input.GetKeyUp(KeyCode.F3)) { newMapType = MapType.Visited; } else if (Input.GetKeyUp(KeyCode.F4)) { newMapType = MapType.MaxContracts; } if (newMapType.HasValue && newMapType.Value != CurrentMapType) { CurrentMapType = newMapType.Value; __instance.GetSimGameState().Starmap.Screen.RefreshSystems(); __instance.RefreshSystemIndicators(); } }); }
static void Postfix(SGNavigationScreen __instance, SimGameState ___simState) { foreach (MapMarker marker in Main.settings.mapMarkers.Values) { StarmapSystemRenderer systemRenderer = ___simState.Starmap.Screen.GetSystemRenderer(marker.systemName); GameObject prefab = null; if (marker.marker.useHmAnimation) { systemRenderer.SetFlashpointMiniCampaign(true); prefab = systemRenderer.flashpointMiniCampaignLocal; } else { systemRenderer.SetFlashpointAvailable(true); prefab = systemRenderer.flashpointAvailableLocal; } if (marker.marker.swapColour) { foreach (ParticleSystem componentsInChild in prefab.GetComponentsInChildren <ParticleSystem>()) { //Main.modLog.LogMessage(" " + componentsInChild.name + ": pr"); var main = componentsInChild.main; var colorGrad = main.startColor; Color color = marker.marker.GetColor(componentsInChild.name, colorGrad.colorMax.a); colorGrad.colorMax = color; main.startColor = colorGrad; } } } }
static bool Prefix(SGNavigationScreen __instance) { try { if (Fields.Deployment) { UIManager uiManager = (UIManager)AccessTools.Field(typeof(SGNavigationScreen), "uiManager").GetValue(__instance); SimGameState simState = (SimGameState)AccessTools.Field(typeof(SGNavigationScreen), "simState").GetValue(__instance); Action cleanup = delegate() { uiManager.ResetFader(UIManagerRootType.PopupRoot); simState.Starmap.Screen.AllowInput(true); }; string primaryButtonText = "Break Contract"; string message = "WARNING: This action will break your current deployment contract. Your reputation with the employer and the MRB will be negatively affected."; PauseNotification.Show("Navigation Change", message, simState.GetCrewPortrait(SimGameCrew.Crew_Sumire), string.Empty, true, delegate { cleanup(); Fields.Deployment = false; if (simState.DoesFactionGainReputation(Fields.DeploymentEmployer)) { Settings settings = Helper.LoadSettings(); ReflectionHelper.InvokePrivateMethode(simState, "SetReputation", new object[] { Fields.DeploymentEmployer, settings.DeploymentBreakRepCost, StatCollection.StatOperation.Int_Add, null }); ReflectionHelper.InvokePrivateMethode(simState, "SetReputation", new object[] { Faction.MercenaryReviewBoard, settings.DeploymentBreakMRBRepCost, StatCollection.StatOperation.Int_Add, null }); AccessTools.Field(typeof(SimGameState), "activeBreadcrumb").SetValue(simState, null); } simState.Starmap.SetActivePath(); simState.SetSimRoomState(DropshipLocation.SHIP); }, primaryButtonText, cleanup, "Cancel"); simState.Starmap.Screen.AllowInput(false); uiManager.SetFaderColor(uiManager.UILookAndColorConstants.PopupBackfill, UIManagerFader.FadePosition.FadeInBack, UIManagerRootType.PopupRoot, true); return(false); } else { return(true); } } catch (Exception e) { Logger.LogError(e); return(true); } }
static void Postfix(SGNavigationScreen __instance, Flashpoint flashpoint, ref StarmapSystemRenderer __result) { if (flashpoint.CurStatus == Flashpoint.Status.AVAILABLE || flashpoint.CurStatus == Flashpoint.Status.SELECTED_ENROUTE) { GameObject prefab = null; if (flashpoint.Def.isHeavyMetalCampaign) { if (__result.flashpointMiniCampaignLocal != null) { prefab = __result.flashpointMiniCampaignLocal; } } else { if (__result.flashpointAvailableLocal != null) { prefab = __result.flashpointAvailableLocal; } } if (prefab != null) { FpMarker marker = FlashPointController.Instance.findMarker(flashpoint.Def.Description.Id); if (marker != null && marker.swapColour) { foreach (ParticleSystem componentsInChild in prefab.GetComponentsInChildren <ParticleSystem>()) { //Main.modLog.LogMessage(" " + componentsInChild.name + ": pr"); var main = componentsInChild.main; var colorGrad = main.startColor; Color color = marker.GetColor(componentsInChild.name, colorGrad.colorMax.a); colorGrad.colorMax = color; main.startColor = colorGrad; } } } } }
private static bool Prefix(SGNavigationScreen __instance) { try { Flareup flareup = Utilities.currentFlareup(); WIIC.modLog.Warn?.Write($"OnTravelCourseAccepted. Flareup: {flareup}, ActiveTravelContract: {WIIC.sim.ActiveTravelContract}"); if (flareup == null) { return(true); } if (!WIIC.flareups.ContainsKey(WIIC.sim.CurSystem.ID)) { WIIC.modLog.Warn?.Write($"Found company tag indicating flareup participation, but no matching flareup for {WIIC.sim.CurSystem.ID}"); WIIC.sim.CompanyTags.Remove("WIIC_helping_attacker"); WIIC.sim.CompanyTags.Remove("WIIC_helping_defender"); return(true); } UIManager uiManager = (UIManager)AccessTools.Field(typeof(SGNavigationScreen), "uiManager").GetValue(__instance); void cleanup() { uiManager.ResetFader(UIManagerRootType.PopupRoot); WIIC.sim.Starmap.Screen.AllowInput(true); } string title = Strings.T("Navigation Change"); string primaryButtonText = Strings.T("Break Deployment"); string cancel = Strings.T("Cancel"); string message = Strings.T("Leaving {0} will break our current deployment. Our reputation with {1} and the MRB will suffer, Commander.", flareup.location.Name, flareup.employer.FactionDef.ShortName); WIIC.modLog.Info?.Write(message); PauseNotification.Show(title, message, WIIC.sim.GetCrewPortrait(SimGameCrew.Crew_Sumire), string.Empty, true, delegate { try { WIIC.modLog.Info?.Write("Breaking deployment contract"); Flareup flareup2 = Utilities.currentFlareup(); WIIC.modLog.Info?.Write("Flareup: {flareup2}"); if (flareup2 != null && flareup2.employer.DoesGainReputation) { WIIC.modLog.Info?.Write("Employer: {flareup2.employer}"); float employerRepBadFaithMod = WIIC.sim.Constants.Story.EmployerRepBadFaithMod; WIIC.modLog.Info?.Write("employerRepBadFaithMod: {employerRepBadFaithMod}"); WIIC.modLog.Info?.Write("CAREER: {SimGameState.SimGameType.CAREER}"); WIIC.modLog.Info?.Write("difficulty: {flareup2.location.Def.GetDifficulty(SimGameState.SimGameType.CAREER)}"); int num = (int)Math.Round(flareup2.location.Def.GetDifficulty(SimGameState.SimGameType.CAREER) * employerRepBadFaithMod); WIIC.sim.SetReputation(flareup2.employer, num); WIIC.sim.SetReputation(FactionEnumeration.GetMercenaryReviewBoardFactionValue(), num); } WIIC.sim.CompanyTags.Remove("WIIC_helping_attacker"); WIIC.sim.CompanyTags.Remove("WIIC_helping_defender"); WIIC.sim.RoomManager.RefreshTimeline(false); WIIC.sim.Starmap.SetActivePath(); WIIC.sim.SetSimRoomState(DropshipLocation.SHIP); cleanup(); } catch (Exception e) { WIIC.modLog.Error?.Write(e); } }, primaryButtonText, cleanup, cancel); WIIC.sim.Starmap.Screen.AllowInput(false); uiManager.SetFaderColor(uiManager.UILookAndColorConstants.PopupBackfill, UIManagerFader.FadePosition.FadeInBack, UIManagerRootType.PopupRoot); return(false); } catch (Exception e) { WIIC.modLog.Error?.Write(e); return(true); } }
public static void Postfix(SGNavigationScreen __instance, SimGameState simGame) { MapModesUI.SetupUIObjects(__instance); MapModesUI.SimGame = simGame; }
public static void RefreshSystemIndicators(this SGNavigationScreen sgNavigationScreen) { sgNavigationScreen.InvokeMethod("RefreshSystemIndicators"); }
public static SimGameState GetSimGameState(this SGNavigationScreen sgNavigationScreen) { return(sgNavigationScreen.GetFieldValue <SimGameState>("simState")); }
// UI STUFF internal static void SetupUIObjects(SGNavigationScreen navScreen) { NavigationScreen = navScreen; if (MapModeTextGameObject == null) { MapModeTextGameObject = new GameObject("NavigationComputer-Text"); MapModeTextGameObject.AddComponent <RectTransform>(); MapModeText = MapModeTextGameObject.AddComponent <TextMeshProUGUI>(); MapModeText.GetComponent <RectTransform>().sizeDelta = new Vector2(500, 100); MapModeText.alignment = TextAlignmentOptions.Center; } if (MapSearchGameObject == null) { MapSearchGameObject = new GameObject("NavigationComputer-Search"); MapSearchGameObject.AddComponent <RectTransform>().sizeDelta = new Vector2(500, 100); MapSearchInputField = MapSearchGameObject.AddComponent <TMP_InputField>(); var textArea = new GameObject("NavigationComputer-Search-TextArea"); textArea.AddComponent <RectMask2D>(); textArea.GetComponent <RectTransform>().sizeDelta = new Vector2(500, 100); textArea.transform.SetParent(MapSearchGameObject.transform); var text = new GameObject("NavigationComputer-Search-Text"); text.AddComponent <RectTransform>().sizeDelta = new Vector2(500, 100); var textTMP = text.AddComponent <TextMeshProUGUI>(); text.transform.SetParent(textArea.transform); textTMP.SetText(string.Empty); textTMP.enableWordWrapping = false; textTMP.extraPadding = true; textTMP.alignment = TextAlignmentOptions.Center; textTMP.fontSize = textTMP.fontSize * 0.75f; MapSearchInputField.textComponent = textTMP; MapSearchInputField.textViewport = textArea.GetComponent <RectTransform>(); } MapSearchGameObject.transform.SetParent(navScreen.transform); MapModeTextGameObject.transform.SetParent(navScreen.transform); // set font in the most roundabout way ever var fonts = Resources.FindObjectsOfTypeAll(typeof(TMP_FontAsset)); foreach (var o in fonts) { var font = (TMP_FontAsset)o; if (font.name == "UnitedSansReg-Black SDF") { MapModeText.font = font; } if (font.name == "UnitedSansReg-Medium SDF") { MapSearchInputField.textComponent.font = font; } } ResetMapUI(); }
static void Prefix(SGNavigationScreen __instance, ref int index) { index = -1; }