static void Prefix(FejdStartup __instance, List <PlayerProfile> ___m_profiles) { if (!modEnabled.Value) { return; } var profile = ___m_profiles.Find(p => p.GetFilename() == (string)typeof(Game).GetField("m_profileFilename", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); backpackFileName = Path.GetFileNameWithoutExtension(profile.GetFilename()) + "_backpack"; LoadBackpackInventory(); }
static bool Prefix(FejdStartup __instance, ref List <PlayerProfile> ___m_profiles) { Dbgl($"New character done, editing {editingCharacter}"); if (!editingCharacter) { return(true); } title.gameObject.SetActive(false); FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic").gameObject.SetActive(true); editingCharacter = false; string text = __instance.m_csNewCharacterName.text; string text2 = text.ToLower(); PlayerProfile playerProfile = Traverse.Create(FejdStartup.instance).Field("m_profiles").GetValue <List <PlayerProfile> >()[Traverse.Create(FejdStartup.instance).Field("m_profileIndex").GetValue <int>()]; Player currentPlayerInstance = Traverse.Create(FejdStartup.instance).Field("m_playerInstance").GetValue <GameObject>().GetComponent <Player>(); playerProfile.SavePlayerData(currentPlayerInstance); playerProfile.SetName(text); var fileNameRef = Traverse.Create(playerProfile).Field("m_filename"); string fileName = fileNameRef.GetValue <string>(); if (fileName != text2) { string path = Path.Combine(Utils.GetSaveDataPath(), "characters"); if (File.Exists(Path.Combine(path, fileName + ".fch"))) { File.Move(Path.Combine(path, fileName + ".fch"), Path.Combine(path, text2 + ".fch")); } if (File.Exists(Path.Combine(path, fileName + ".fch.old"))) { File.Move(Path.Combine(path, fileName + ".fch.old"), Path.Combine(path, text2 + ".fch.old")); } if (File.Exists(Path.Combine(path, fileName + ".fch.new"))) { File.Move(Path.Combine(path, fileName + ".fch.new"), Path.Combine(path, text2 + ".fch.new")); } fileNameRef.SetValue(text2); } playerProfile.Save(); __instance.m_selectCharacterPanel.SetActive(true); __instance.m_newCharacterPanel.SetActive(false); ___m_profiles = null; Traverse.Create(__instance).Method("SetSelectedProfile", new object[] { text2 }).GetValue(); return(false); }
private static void Postfix(ref FejdStartup __instance) { // logo GameObject logo = GameObject.Find("LOGO"); logo.GetComponent <Image>().sprite = VPlusMainMenu.VPlusLogoSprite; // version text for bottom right of startup __instance.m_versionLabel.fontSize = 14; string gameVersion = Version.CombineVersion(global::Version.m_major, global::Version.m_minor, global::Version.m_patch); __instance.m_versionLabel.text = "version " + gameVersion + "\n" + "ValheimPlus " + ValheimPlusPlugin.version; }
private static void FejdStartup_Start(On.FejdStartup.orig_Start orig, FejdStartup self) { orig(self); foreach (var i in ObjectDB.instance.m_items) { var iDrop = i.GetComponent <ItemDrop>(); if (iDrop.m_itemData.IsEquipable() && iDrop.m_itemData.m_shared.m_name.Contains("$item")) { itemLookup[iDrop.m_itemData.m_shared.m_name] = iDrop; var isSwordNotContainsSword = iDrop.m_itemData.m_shared.m_skillType == Skills.SkillType.Swords && !i.name.Contains($"Sword"); //Filter out non swords (armors) from the default type (sword) Config.GeneralSettings.Bind <int>($"{(isSwordNotContainsSword ? Skills.SkillType.Run : iDrop.m_itemData.m_shared.m_skillType)}", $"{i.name}", 0, "The minimum level which is required to equip the item."); } } }
static void Postfix(ref FejdStartup __instance) { ZLog.Log(genUI); if (!GenOptionsUI.instance) { ZLog.Log("ShowStartGame GenOptionsUI.instance == false"); GenOptionsUI.instance = genUI.AddComponent <GenOptionsUI>(); } ZLog.Log("ShowStartGame"); GameObject currentSelectedGameObject = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; int index = __instance.FindSelectedWorld(currentSelectedGameObject); GenOptionsUI.instance.worldName = __instance.m_world.m_name; genUI.SetActive(true); }
static void Prefix(FejdStartup __instance, List <PlayerProfile> ___m_profiles) { if (!modEnabled.Value) { return; } var profile = ___m_profiles.Find(p => p.GetFilename() == (string)typeof(Game).GetField("m_profileFilename", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); long id = profile.GetPlayerID(); string name = profile.GetName(); backpackObjectName = backpackObjectPrefix + "_" + backpackGUID.Value + "_" + name; backpack = null; backpackZDO = null; }
private static void Postfix(ref FejdStartup __instance) { // logo if (Configuration.Current.ValheimPlus.IsEnabled && Configuration.Current.ValheimPlus.mainMenuLogo) { GameObject logo = GameObject.Find("LOGO"); logo.GetComponent <Image>().sprite = VPlusMainMenu.VPlusLogoSprite; } // version text for bottom right of startup __instance.m_versionLabel.fontSize = 14; string gameVersion = Version.CombineVersion(global::Version.m_major, global::Version.m_minor, global::Version.m_patch); __instance.m_versionLabel.text = "version " + gameVersion + "\n" + "ValheimPlus " + ValheimPlusPlugin.version; if (Configuration.Current.ValheimPlus.IsEnabled && Configuration.Current.ValheimPlus.serverBrowserAdvertisement) { DefaultControls.Resources uiResources = new DefaultControls.Resources(); GameObject joinpanel = GameObjectAssistant.GetChildComponentByName <Transform>("JoinPanel", __instance.m_startGamePanel).gameObject; if (joinpanel) { foreach (Transform panel in joinpanel.transform) { if (panel.gameObject.name == "Server help") { GameObject serverHelpObj = panel.gameObject; GameObject banner = GameObject.Instantiate(serverHelpObj); banner.transform.SetParent(joinpanel.transform, false); banner.transform.localPosition = banner.transform.localPosition + new Vector3(0, -300); banner.GetComponent <RectTransform>().sizeDelta = new Vector2(315, 315); banner.transform.GetChild(0).GetComponent <Text>().text = ""; banner.transform.GetChild(1).gameObject.SetActive(false); GameObject bannerButton = DefaultControls.CreateButton(uiResources); bannerButton.transform.SetParent(banner.transform, false); bannerButton.GetComponentInChildren <Text>().text = ""; bannerButton.GetComponent <RectTransform>().sizeDelta = new Vector2(315, 315); bannerButton.GetComponent <Button>().image.sprite = VPlusMainMenu.VPlusBannerSprite; bannerButton.GetComponent <Button>().transition = Selectable.Transition.SpriteSwap; SpriteState ss = new SpriteState(); ss.highlightedSprite = VPlusMainMenu.VPlusBannerHoverSprite; bannerButton.GetComponent <Button>().spriteState = ss; bannerButton.GetComponent <Button>().onClick.AddListener(delegate { Application.OpenURL("http://zap-hosting-banner.valheim.plus"); }); } } } } }
public static bool Start(FejdStartup self) { Button v = GameObject.Instantiate(self.m_manualIPButton, self.m_serverListPanel.transform); v.gameObject.transform.SetPositionAndRotation(new Vector3(v.gameObject.transform.position.x, v.gameObject.transform.position.y - 50, v.gameObject.transform.position.z), v.gameObject.transform.rotation); v.GetComponentInChildren <Text>().text = "[V+] Valgrind Server"; v.onClick = new Button.ButtonClickedEvent(); v.onClick.AddListener(() => { ZSteamMatchmaking.instance.QueueServerJoin("67.222.140.86:6956"); }); JoinValgrind = v; return(CONST.NOSKIP); }
static void Postfix(FejdStartup __instance) { if (!Input.GetKeyDown(hotKey.Value)) { return; } Dbgl("pressed hot key"); string worldName = PlayerPrefs.GetString("world"); Game.SetProfile(PlayerPrefs.GetString("profile")); if (worldName == null || worldName.Length == 0) { return; } Dbgl($"got world name {worldName}"); typeof(FejdStartup).GetMethod("UpdateCharacterList", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { }); typeof(FejdStartup).GetMethod("UpdateWorldList", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true }); bool isOn = __instance.m_publicServerToggle.isOn; bool isOn2 = __instance.m_openServerToggle.isOn; string text = __instance.m_serverPassword.text; World world = (World)typeof(FejdStartup).GetMethod("FindWorld", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { worldName }); if (world == null) { return; } Dbgl($"got world"); ZNet.SetServer(true, isOn2, isOn, worldName, text, world); ZNet.SetServerHost("", 0); string eventLabel = "open:" + isOn2.ToString() + ",public:" + isOn.ToString(); GoogleAnalyticsV4.instance.LogEvent("Menu", "WorldStart", eventLabel, 0L); Dbgl($"transitioning..."); typeof(FejdStartup).GetMethod("TransitionToMainScene", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { }); }
private void Update() { if (!Settings.Enabled.Value) { return; } FejdStartup fejdStartup = FejdStartup.instance; if (!fejdStartup) { return; } if (!hardcoreLabel) { InitHardcoreLabel(); } if (!uiPanel) { InitUIPanel(); } if (fejdStartup.m_characterSelectScreen.activeInHierarchy) { Traverse tInstance = Traverse.Create(fejdStartup); int profileIndex = tInstance.Field <int>("m_profileIndex").Value; List <PlayerProfile> profiles = tInstance.Field <List <PlayerProfile> >("m_profiles").Value; if (profiles?.Count > 0) { PlayerProfile profile = profiles[profileIndex]; long profileID = profile.GetPlayerID(); bool isHardcore = hardcoreProfiles.Exists((HardcoreData data) => { return(data.profileID == profileID && data.isHardcore); }); hardcoreLabel.SetActive(isHardcore); } } if (Input.GetKeyDown(KeyCode.F4)) { } }
static void Postfix(ref FejdStartup __instance, ref bool centerSelection) { if (GenOptionsUI.instance) { ZLog.Log("SetSelectedWorld GenOptionsUI.instance == true"); if (!centerSelection) { ZLog.Log("centerSelection == false || should activate UI"); //__instance.m_joinGameButton.interactable = (__instance.m_joinServer != null); PatchInitUI.genUI.SetActive(true); GenOptionsUI.instance.worldName = __instance.m_world.m_name; } else { ZLog.Log("centerSelection == true || should deactivate UI"); PatchInitUI.genUI.SetActive(false); } } }
public static bool Update(FejdStartup self) { if (JoinValgrind != null) { var x = Time.deltaTime; i = i + (0.1 * x * (up ? 1 : -1)); if (i >= 1) { up = false; } if (i <= 0) { up = true; } JoinValgrind.GetComponentInChildren <Text>().color = SmartBepInMods.Tools.HTTP.ColorExtensions.HSL2RGB(i, 0.5, 0.5); } return(CONST.NOSKIP); }
// Some mod could have initialized Localization before all mods are loaded. // See https://github.com/Valheim-Modding/Jotunn/issues/193 private void LoadAndSetupModLanguages(On.FejdStartup.orig_SetupGui orig, FejdStartup self) { orig(self); On.Localization.LoadLanguages += Localization_LoadLanguages; On.Localization.SetupLanguage += Localization_SetupLanguage; List <string> tmplist = Localization.instance.m_languages.ToList(); tmplist.AddRange(Localization.instance.LoadLanguages()); tmplist = tmplist.Distinct().ToList(); Localization.instance.m_languages.Clear(); Localization.instance.m_languages.AddRange(tmplist); string lang = PlayerPrefs.GetString("language", DefaultLanguage); Localization.instance.SetupLanguage(lang); On.Localization.LoadLanguages -= Localization_LoadLanguages; On.Localization.SetupLanguage -= Localization_SetupLanguage; }
public static void Prefix(FejdStartup __instance) { Dbgl($"loading main scene"); Image image = Instantiate(__instance.m_loading.transform.Find("Bkg").GetComponent <Image>(), __instance.m_loading.transform); if (image == null) { Dbgl($"missed bkg"); return; } Dbgl($"setting sprite to loading screen"); image.sprite = loadingSprite; image.color = loadingColorMask.Value; image.type = Image.Type.Simple; image.preserveAspect = true; Text text = Instantiate(__instance.m_loading.transform.Find("Text").GetComponent <Text>(), __instance.m_loading.transform); text.text = loadingText.Value; text.color = loadingTextColor.Value; __instance.m_loading.transform.Find("Text").gameObject.SetActive(false); }
static void Postfix(FejdStartup __instance) { if (!modEnabled.Value) { return; } __instance.m_joinIPAddress.onValueChanged.RemoveListener(SaveIPAddress); string text = ""; if (rememberIP.Value) { text += lastIPAddress.Value; } if (rememberPort.Value && lastPort.Value.Length > 0) { text += ":" + lastPort.Value; } __instance.m_joinIPAddress.text = text; __instance.m_joinIPAddress.onValueChanged.AddListener(SaveIPAddress); }
private static readonly int fontSize = 20; // Beware, padding isn't tied to this! Might break layout public static void Show(FejdStartup menu) { if (menu.m_profiles == null) { menu.m_profiles = PlayerProfile.GetAllPlayerProfiles(); } if (menu.m_profileIndex >= menu.m_profiles.Count) { menu.m_profileIndex = menu.m_profiles.Count - 1; } if (menu.m_profileIndex >= 0 && menu.m_profileIndex < menu.m_profiles.Count) { PlayerProfile playerProfile = menu.m_profiles[menu.m_profileIndex]; menu.m_csName.text = $"{playerProfile.GetName()}\n" + $"<size={fontSize}>Kills: {playerProfile.m_playerStats.m_kills} Deaths: {playerProfile.m_playerStats.m_deaths} Crafts: {playerProfile.m_playerStats.m_crafts} Builds: {playerProfile.m_playerStats.m_builds}</size>"; menu.m_csName.gameObject.SetActive(true); Vector2 startBtnPos = (menu.m_csStartButton.transform as RectTransform).anchoredPosition; menu.m_csName.rectTransform.anchoredPosition = new Vector2(menu.m_csName.rectTransform.anchoredPosition.x, startBtnPos.y + padding); menu.SetupCharacterPreview(playerProfile); return; } menu.m_csName.gameObject.SetActive(false); menu.ClearCharacterPreview(); }
static void Postfix(FejdStartup __instance) { if (!modEnabled.Value) { return; } var edit = Instantiate(FejdStartup.instance.m_selectCharacterPanel.transform.Find("BottomWindow").Find("New")); edit.name = "Edit"; edit.transform.parent = FejdStartup.instance.m_selectCharacterPanel.transform.Find("BottomWindow"); edit.GetComponent <RectTransform>().anchoredPosition = new Vector3(-751, -50, 0); edit.transform.Find("Text").GetComponent <Text>().text = buttonText.Value; edit.GetComponent <Button>().onClick.RemoveAllListeners(); edit.GetComponent <Button>().onClick = new Button.ButtonClickedEvent(); edit.GetComponent <Button>().onClick.AddListener(StartCharacterEdit); title = Instantiate(FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic")); title.name = "EditTitle"; title.parent = FejdStartup.instance.m_newCharacterPanel.transform; title.GetComponent <Text>().text = titleText.Value; title.GetComponent <RectTransform>().anchoredPosition = FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic").GetComponent <RectTransform>().anchoredPosition; title.gameObject.SetActive(false); }
private static void OnFejdStartup(FejdStartup __instance) { var parent = __instance.m_versionLabel.transform.parent.gameObject; var bepinGo = new GameObject("BepInEx Version"); bepinGo.transform.parent = parent.transform; bepinGo.AddComponent <CanvasRenderer>(); bepinGo.transform.localPosition = Vector3.zero; var rt = bepinGo.AddComponent <RectTransform>(); rt.anchorMin = new Vector2(0.03f, 0.95f); rt.anchorMax = new Vector2(0.3f, 0.95f); var text = bepinGo.AddComponent <Text>(); text.font = Font.CreateDynamicFontFromOSFont("Arial", 20); text.text = $"Running BepInEx {BepInExVersion}\n{Chainloader.PluginInfos.Count} plugins loaded"; if (Console.instance.IsConsoleEnabled()) { text.text += "\nPress F5 to open console"; } text.color = Color.white; text.fontSize = 20; }
public static void Postfix(FejdStartup __instance) { var mainGui = __instance.m_mainMenu; guiBundle = guiBundle ?? EmbeddedAsset.LoadAssetBundle("Assets.valheimtwitchgui"); var prefab = guiBundle.LoadAsset <GameObject>("Valheim Twitch GUI"); gui = UnityEngine.Object.Instantiate(prefab); gui.transform.SetParent(mainGui.transform); guiScript = gui.GetComponent <ValheimTwitchGUIScript>(); guiScript.mainButton.OnClick(() => OnMainButtonClick()); guiScript.refreshRewardButton.OnClick(() => { Plugin.Instance.UpdateRwardsList(); UpdateRewardGrid(); }); guiScript.rewardSettings.OnSettingsChanged += OnRewardSettingschanged; guiScript.addRewardForm.OnSave += OnNewRewardSave; UpdateMainButonText(); UpdateRewardGrid(); }
public static void Prefix(FejdStartup __instance) { }
private static void AddWaterMark(ref FejdStartup __instance) { Patches.CustomWatermark.Apply(__instance); }
private static void InitUIPanel() { FejdStartup instance = FejdStartup.instance; GameObject panel = instance.m_newCharacterPanel; RectTransform hairPanel = panel.transform.Find("CusomizationPanel").Find("HairPanel").GetComponent <RectTransform>(); float width = hairPanel.rect.width; GameObject hardcorePanel = new GameObject("HardcorePanel"); RectTransform hardcorePanelRect = hardcorePanel.AddComponent <RectTransform>(); hardcorePanelRect.SetParent(panel.transform); hardcorePanelRect.anchorMin = new Vector2(1f, 0.5f); hardcorePanelRect.anchorMax = new Vector2(1f, 0.5f); hardcorePanelRect.anchoredPosition = new Vector2(-width / 2, 0f); hardcorePanelRect.sizeDelta = new Vector2(width, 150); Color fadedWhite = new Color(0.784f, 0.784f, 0.784f); Image hardcorePanelBG = hardcorePanel.AddComponent <Image>(); hardcorePanelBG.sprite = panel.transform.Find("CusomizationPanel").Find("bkg").GetComponent <Image>().sprite; hardcorePanelBG.color = fadedWhite * 0.8f; Toggle maletoggle = panel.GetComponent <PlayerCustomizaton>().m_maleToggle; Sprite checkboxSprite = maletoggle.image.sprite; Sprite checkmarkSprite = (maletoggle.graphic as Image).sprite; CanvasGroup canvas = panel.GetComponent <CanvasGroup>(); string[] toggleNames = new string[] { "Hardcore", "Skip Intro", "Disable Tutorials" }; int count = toggleNames.Length; for (int i = 0; i < count; i++) { string toggleName = toggleNames[i] + " Toggle"; float vOffset = (i * 50) + 25; GameObject toggleGO = new GameObject(toggleName); RectTransform toggleRect = toggleGO.AddComponent <RectTransform>(); toggleRect.SetParent(hardcorePanelRect); toggleRect.anchorMin = new Vector2(0f, 1f); toggleRect.anchorMax = new Vector2(0f, 1f); toggleRect.anchoredPosition = new Vector2((width / 2) + 28, -vOffset); toggleRect.sizeDelta = new Vector2(width, 150); GameObject checkboxGO = new GameObject(toggleName + " Checkbox"); RectTransform checkboxRect = checkboxGO.AddComponent <RectTransform>(); checkboxRect.SetParent(toggleRect); checkboxRect.anchorMin = new Vector2(0f, 0.5f); checkboxRect.anchorMax = new Vector2(0f, 0.5f); checkboxRect.anchoredPosition = new Vector2(0f, 0f); checkboxRect.sizeDelta = new Vector2(28f, 28f); Image checkbox = checkboxGO.AddComponent <Image>(); checkbox.color = Color.white; checkbox.sprite = checkboxSprite; GameObject checkmarkGO = new GameObject(toggleName + " Checkmark"); RectTransform checkmarkRect = checkmarkGO.AddComponent <RectTransform>(); checkmarkRect.SetParent(toggleRect); checkmarkRect.anchorMin = new Vector2(0f, 0.5f); checkmarkRect.anchorMax = new Vector2(0f, 0.5f); checkmarkRect.anchoredPosition = new Vector2(0f, 0f); checkmarkRect.sizeDelta = new Vector2(28f, 28f); Image checkmark = checkmarkGO.AddComponent <Image>(); checkmark.sprite = checkmarkSprite; checkmark.color = new Color(1f, 0.641f, 0f); Toggle toggle = toggleGO.AddComponent <Toggle>(); toggle.image = checkbox; toggle.graphic = checkmark; toggle.isOn = false; toggle.transition = Selectable.Transition.ColorTint; toggle.colors = maletoggle.colors; GameObject textGO = new GameObject(toggleName + " Label"); RectTransform textRect = textGO.AddComponent <RectTransform>(); textRect.SetParent(checkboxRect); textRect.anchorMin = new Vector2(1f, 0.5f); textRect.anchorMax = new Vector2(1f, 0.5f); textRect.sizeDelta = new Vector2(width - 28, 50); Outline outline = textGO.AddComponent <Outline>(); outline.effectColor = Color.black; outline.effectDistance = new Vector2(1f, -1f); Text text = textGO.AddComponent <Text>(); text.font = canvas.GetComponentInChildren <Text>().font; text.fontSize = maletoggle.GetComponentInChildren <Text>().fontSize; text.color = maletoggle.GetComponentInChildren <Text>().color; text.alignment = TextAnchor.MiddleCenter; text.raycastTarget = false; string localizationToken = "$hardcore_" + toggleNames[i].ToLower().Replace(' ', '_'); text.text = Localization.instance.Localize(localizationToken); textRect.anchoredPosition = new Vector2((text.preferredWidth / 2) + 5, 0f); ButtonSfx sfx = toggleGO.AddComponent <ButtonSfx>(); sfx.m_sfxPrefab = maletoggle.GetComponentInChildren <ButtonSfx>().m_sfxPrefab; } uiPanel = hardcorePanel; Log.LogInfo($"{uiPanel} Initialized."); }
public static void Apply(FejdStartup menu) { menu.m_versionLabel.text = $"{menu.m_versionLabel.text}\n<size={fontSize}><color={colorCode}>{Main.MODNAME}: " + Main.VERSION + "</color></size>"; }
private static void FejdStartup_Awake(FejdStartup __instance) => Instance.FejdStartup_Awake(__instance);
private static void Postfix(FejdStartup __instance) { Events.Client.FEJDSTARTUP.Update(__instance); }
static void Postfix(ref FejdStartup __instance) { m_fejdStartup = __instance; }
private static void OnFejdStartupAwakeMonoModHookShowcase(On.FejdStartup.orig_Awake orig, FejdStartup self) { // calling the original method orig(self); Log.LogInfo("Hello from a monomod hook, this method is fired after the original method is called : " + self.m_betaText); }
static void Prefix(FejdStartup __instance) { RunicPower.UnsetMostThings(); }
static void Postfix(FejdStartup __instance) { string text = "192.168.31.143"; __instance.m_joinIPAddress.text = text; }
static void Postfix(ref FejdStartup __instance) { __instance.m_versionLabel.text += $"\n<size=6><color=#ADB2FFFF>{Main.AUTHOR}'s {Main.MODNAME} v{Main.VERSION}</color></size>"; }