private static void DontShowMinimap_Patch(On.Minimap.orig_SetMapMode orig, Minimap self, int mode) { if (ConfigUtil.Get <bool>("Map", "showNoMinimap")) { if ((Chat.instance == null || !Chat.instance.HasFocus()) && !global::Console.IsVisible() && !InventoryGui.IsVisible() && !Minimap.InTextInput()) { if (ZInput.GetButtonDown("Map") || ZInput.GetButtonDown("JoyMap") || (self.m_mode == Minimap.MapMode.Large && (Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyButtonB")))) { if (mode == (int)Minimap.MapMode.Large) { return; } if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.Large)) { mode = (int)Minimap.MapMode.None; } } else { if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.None)) { mode = (int)Minimap.MapMode.None; } } } } orig(self, mode); }
public static bool Prefix(InventoryGui __instance) { if (!__instance.m_inventoryGroup.IsActive()) { return(false); } if (ZInput.GetButtonDown("JoyTabLeft")) { __instance.SetActiveGroup(__instance.m_activeGroup - 1); } if (ZInput.GetButtonDown("JoyTabRight")) { __instance.SetActiveGroup(__instance.m_activeGroup + 1); } if (__instance.m_activeGroup == 0 && !__instance.IsContainerOpen()) { __instance.SetActiveGroup(1); } if (__instance.m_activeGroup == __instance.m_uiGroups.Length - 1) { __instance.UpdateRecipeGamepadInput(); } return(false); }
public void OnSelectedRarity(ItemRarity rarity) { if (rarity == SelectedRarity) { return; } OnCraftCanceled(); SelectedRarity = rarity; var nextButtonIndex = (int)SelectedRarity + 1; if (nextButtonIndex >= RarityButtons.Count) { nextButtonIndex = 0; } for (var index = 0; index < RarityButtons.Count; index++) { var rarityButton = RarityButtons[index]; var gp = rarityButton.GetComponent <UIGamePad>(); if (gp != null) { gp.enabled = index == nextButtonIndex; gp.m_hint.SetActive(ZInput.IsGamepadActive() && index == RarityButtons.Count - 1); } } }
public static void Postfix(ref ZInput __instance) { #if DEBUG Debug.Log("----> ZInput Reset"); #endif InputManager.Instance.Load(__instance); }
public void Update() { if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use")) { Close(); } }
static public void Postfix(ZInput __instance) { foreach (var button in Buttons) { __instance.AddButton(button.name, button.code); } }
// Token: 0x060004F2 RID: 1266 RVA: 0x00028E98 File Offset: 0x00027098 private void Update() { Player localPlayer = Player.m_localPlayer; if (localPlayer && !InventoryGui.IsVisible() && !Menu.IsVisible() && !GameCamera.InFreeFly()) { if (ZInput.GetButtonDown("JoyDPadLeft")) { this.m_selected = Mathf.Max(0, this.m_selected - 1); } if (ZInput.GetButtonDown("JoyDPadRight")) { this.m_selected = Mathf.Min(this.m_elements.Count - 1, this.m_selected + 1); } if (ZInput.GetButtonDown("JoyDPadUp")) { localPlayer.UseHotbarItem(this.m_selected + 1); } } if (this.m_selected > this.m_elements.Count - 1) { this.m_selected = Mathf.Max(0, this.m_elements.Count - 1); } this.UpdateIcons(localPlayer); }
void Update() { if (m_keyInit && ZInput.GetButtonDown("TogglePins")) { m_pinsVisible = !m_pinsVisible; } }
// Called every frame private void Update() { // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads, // we need to check that ZInput is ready to use first. if (ZInput.instance != null) { // Check if our button is pressed. This will only return true ONCE, right after our button is pressed. // If we hold the button down, it won't spam toggle our menu. if (ZInput.GetButtonDown("JotunnModExample_Menu")) { showGUI = !showGUI; } } // Use the name of the ButtonConfig to identify the button pressed if (evilSwordSpecial != null && ZInput.instance != null && MessageHud.instance != null) { if (ZInput.GetButtonDown(evilSwordSpecial.Name) && MessageHud.instance.m_msgQeue.Count == 0) { MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$evilsword_beevilmessage"); } if (Input.GetKeyDown(KeyCode.F7)) { Player.m_localPlayer?.RaiseSkill(testSkillType, 1f); } } }
static void Prefix(ZInput __instance) { if (modEnabled.Value) { SetButtons(); } }
static void Postfix(Player __instance) { bool keyReplantDown = CRConfig.useCustomReplantKey ? Input.GetKeyDown(CRConfig.customReplantKey) : (ZInput.GetButtonDown("Remove") || ZInput.GetButtonDown("JoyRemove")); if (keyReplantDown) { if (__instance.CultivatorEquipped()) { GameObject[] parameters = new GameObject[] { null, null }; PlayerExt.FindHoverObject.Invoke(__instance, parameters); var maybePickable = parameters[0]?.GetComponent <Pickable>(); if (maybePickable != null) { if (maybePickable.Replantable()) { maybePickable.Replant(__instance); if (CRConfig.multipick) { foreach (var crop in maybePickable.FindPickableOfKindInRadius(CRConfig.range)) { crop.Replant(__instance); } } } } } } }
private void Update() { // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads, // we need to check that ZInput is ready to use first. if (ZInput.instance != null) { // Check if our button is pressed. This will only return true ONCE, right after our button is pressed. if (ZInput.GetButtonDown("EscapeChallenge")) { if (Player.m_localPlayer && Player.m_localPlayer.m_intro) { Player.m_localPlayer.m_intro = false; var hitData = new HitData(); hitData.m_damage.m_damage = 99999f; Player.m_localPlayer.Damage(hitData); var client = WebSocketObject.GetComponent <WebSocketClient>(); var message = new Message { type = "forceQuit" }; client.Send(JsonMapper.ToJson(message)); } } } }
static void SetButtons() { if (!modEnabled.Value || ZInput.instance == null) { return; } ZInput zInput = ZInput.instance; Dictionary <string, ZInput.ButtonDef> m_buttons = Traverse.Create(zInput).Field("m_buttons").GetValue <Dictionary <string, ZInput.ButtonDef> >(); m_buttons.Clear(); using (var enumerator = context.Config.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.Key.Section == "Config") { continue; } ButtonInfo info = new ButtonInfo(enumerator.Current.Key.Key, (ConfigEntry <string>)enumerator.Current.Value); if (Enum.TryParse <KeyCode>(info.key, out KeyCode keyCode)) { zInput.AddButton(info.button, keyCode, info.repeatDelay, info.repeatInterval); } else { zInput.AddButton(info.button, info.key, info.inverted, info.repeatDelay, info.repeatInterval); } } } zInput.Save(); Dbgl("Finished setting buttons"); }
private static void RotateWithWheel(Player __instance) { var wheel = Input.GetAxis("Mouse ScrollWheel"); var playerData = PlayersData[__instance]; if (!wheel.Equals(0f) || ZInput.GetButton("JoyRotate")) { if (Input.GetKey(Configuration.Current.FreePlacementRotation.rotateY)) { playerData.PlaceRotation += Vector3.up * Mathf.Sign(wheel); __instance.m_placeRotation = (int)(playerData.PlaceRotation.y / 22.5f); } else if (Input.GetKey(Configuration.Current.FreePlacementRotation.rotateX)) { playerData.PlaceRotation += Vector3.right * Mathf.Sign(wheel); } else if (Input.GetKey(Configuration.Current.FreePlacementRotation.rotateZ)) { playerData.PlaceRotation += Vector3.forward * Mathf.Sign(wheel); } else { __instance.m_placeRotation = ClampPlaceRotation(__instance.m_placeRotation); playerData.PlaceRotation = new Vector3(0, __instance.m_placeRotation * 22.5f, 0); } playerData.PlaceRotation = ClampAngles(playerData.PlaceRotation); Debug.Log("Angle " + playerData.PlaceRotation); } }
static void Postfix(Player __instance) { bool keyReplantDown = (CRConfig.useCustomReplantKey || CRConfig.oldStyle) ? ZInput.GetButtonDown(CRConfig.replantButton.Name) : (ZInput.GetButtonDown("Remove") || ZInput.GetButtonDown("JoyRemove")); if (keyReplantDown) { if (__instance.CultivatorEquipped()) { __instance.FindHoverObject(out GameObject hover, out Character _); var maybePickable = hover?.GetComponent <Pickable>(); if (maybePickable != null) { if (maybePickable.Replantable()) { maybePickable.Replant(__instance); if (CRConfig.multipick) { foreach (var crop in maybePickable.FindPickableOfKindInRadius(CRConfig.range)) { crop.Replant(__instance); } } } } } } }
static bool Prefix(Player __instance, bool takeInput, float dt, PieceTable ___m_buildPieces, GameObject ___m_placementGhost) { if (!AllowByKey() || !CheckKeyHeld(pullItemsKey.Value) || !__instance.InPlaceMode() || !takeInput || Hud.IsPieceSelectionVisible()) { return(true); } if (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyPlace")) { Piece selectedPiece = ___m_buildPieces.GetSelectedPiece(); if (selectedPiece != null) { if (selectedPiece.m_repairPiece) { return(true); } if (___m_placementGhost != null) { int placementStatus = (int)typeof(Player).GetField("m_placementStatus", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance); if (placementStatus == 0) { Dbgl($"pulling resources to player inventory for piece {selectedPiece.name}"); PullResources(__instance, selectedPiece.m_resources, 0); } } } } return(false); }
private void setPitch() { float yAxis = Input.GetAxis("Mouse Y") * PlayerController.m_mouseSens; yAxis += -ZInput.GetJoyRightStickY() * 110f * Time.deltaTime; _pitch = Mathf.Clamp(_pitch - yAxis, -89f, 89f); }
/// <summary> /// Set any key hint config using buttons without a backing bep config dirty /// </summary> private void ZInput_Save(ZInput self) { foreach (var config in KeyHints.Values.Where(x => x.ButtonConfigs.Any(y => !y.IsConfigBacked))) { config.Dirty = true; } }
private static void UpdateInitialHotkeyBarInput() { if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyDPadRight")) { SelectHotkeyBar(0, false); } }
internal void Load(ZInput zinput) { Debug.Log("---- Registering custom inputs ----"); if (zinput == null) { Debug.LogError("\t-> ZInput does not exist yet, delaying..."); return; } foreach (var pair in Buttons) { var btn = pair.Value; if (btn.Axis != null && btn.Axis.Length > 0) { zinput.AddButton(btn.Name, btn.Axis, btn.Inverted, btn.RepeatDelay, btn.RepeatInterval); } else { zinput.AddButton(btn.Name, btn.Key, btn.RepeatDelay, btn.RepeatInterval); } Debug.Log("Registered input: " + pair.Key); } }
public void Update() { // Not all of these inputs work and I do not know why, only Escape works if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use")) { EffectChoiceButtons[0].onClick.Invoke(); } }
// Token: 0x060004EC RID: 1260 RVA: 0x00028D99 File Offset: 0x00026F99 private void LateUpdate() { this.m_sendButton.interactable = this.IsValid(); if (Feedback.IsVisible() && (Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu"))) { this.OnBack(); } }
public void Update() { //EpicLoot.Log("AugmentsAvailableDialog.Update"); if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use")) { OnClose(); } }
private static float getJoyLeftStickYPatched() { if (VRControls.mainControlsActive) { return(0.0f); } return(ZInput.GetJoyLeftStickY()); }
public ZMachine(byte[] aData) { Memory = new ZMemory(aData); Story = new ZStory(Memory); Screen = new ZConsoleScreen(this); Input = new ZInput(Story, Screen, Memory); Output = new ZOutput(Screen); }
// Token: 0x0600060A RID: 1546 RVA: 0x00033990 File Offset: 0x00031B90 private void LoadSettings() { ZInput.instance.Load(); AudioListener.volume = PlayerPrefs.GetFloat("MasterVolume", AudioListener.volume); MusicMan.m_masterMusicVolume = PlayerPrefs.GetFloat("MusicVolume", 1f); AudioMan.SetSFXVolume(PlayerPrefs.GetFloat("SfxVolume", 1f)); this.m_continousMusic.isOn = (PlayerPrefs.GetInt("ContinousMusic", 1) == 1); PlayerController.m_mouseSens = PlayerPrefs.GetFloat("MouseSensitivity", PlayerController.m_mouseSens); PlayerController.m_invertMouse = (PlayerPrefs.GetInt("InvertMouse", 0) == 1); float @float = PlayerPrefs.GetFloat("GuiScale", 1f); this.m_volumeSlider.value = AudioListener.volume; this.m_sensitivitySlider.value = PlayerController.m_mouseSens; this.m_sfxVolumeSlider.value = AudioMan.GetSFXVolume(); this.m_musicVolumeSlider.value = MusicMan.m_masterMusicVolume; this.m_guiScaleSlider.value = @float * 100f; this.m_invertMouse.isOn = PlayerController.m_invertMouse; this.m_gamepadEnabled.isOn = ZInput.IsGamepadEnabled(); this.m_languageKey = Localization.instance.GetSelectedLanguage(); this.m_language.text = Localization.instance.Localize("$language_" + this.m_languageKey.ToLower()); this.m_cameraShake.isOn = (PlayerPrefs.GetInt("CameraShake", 1) == 1); this.m_shipCameraTilt.isOn = (PlayerPrefs.GetInt("ShipCameraTilt", 1) == 1); this.m_quickPieceSelect.isOn = (PlayerPrefs.GetInt("QuickPieceSelect", 0) == 1); this.m_showKeyHints.isOn = (PlayerPrefs.GetInt("KeyHints", 1) == 1); this.m_dofToggle.isOn = (PlayerPrefs.GetInt("DOF", 1) == 1); this.m_vsyncToggle.isOn = (PlayerPrefs.GetInt("VSync", 0) == 1); this.m_bloomToggle.isOn = (PlayerPrefs.GetInt("Bloom", 1) == 1); this.m_ssaoToggle.isOn = (PlayerPrefs.GetInt("SSAO", 1) == 1); this.m_sunshaftsToggle.isOn = (PlayerPrefs.GetInt("SunShafts", 1) == 1); this.m_aaToggle.isOn = (PlayerPrefs.GetInt("AntiAliasing", 1) == 1); this.m_caToggle.isOn = (PlayerPrefs.GetInt("ChromaticAberration", 1) == 1); this.m_motionblurToggle.isOn = (PlayerPrefs.GetInt("MotionBlur", 1) == 1); this.m_softPartToggle.isOn = (PlayerPrefs.GetInt("SoftPart", 1) == 1); this.m_tesselationToggle.isOn = (PlayerPrefs.GetInt("Tesselation", 1) == 1); this.m_shadowQuality.value = (float)PlayerPrefs.GetInt("ShadowQuality", 2); this.m_lod.value = (float)PlayerPrefs.GetInt("LodBias", 2); this.m_lights.value = (float)PlayerPrefs.GetInt("Lights", 2); this.m_vegetation.value = (float)PlayerPrefs.GetInt("ClutterQuality", 2); this.m_fullscreenToggle.isOn = Screen.fullScreen; this.m_oldFullscreen = this.m_fullscreenToggle.isOn; this.m_oldRes = Screen.currentResolution; this.m_oldRes.width = Screen.width; this.m_oldRes.height = Screen.height; this.m_selectedRes = this.m_oldRes; ZLog.Log(string.Concat(new object[] { "Current res ", Screen.currentResolution.width, "x", Screen.currentResolution.height, " ", Screen.width, "x", Screen.height })); }
private void PlayerUpdatePostfix(Player self) { if (!_isModEnabled.Value || self != Player.m_localPlayer || !self.m_hovering || !ZInput.GetButtonDown(_deleteObjectButton.Name)) { return; } DeleteHoverObject(self); }
static void Prefix(Player __instance, float ___m_lastToolUseTime, ref float ___m_placePressedTime) { __instance.m_placeDelay = placeDelay; if (!modEnabled.Value) { return; } string rightItem = __instance.GetRightItem()?.m_shared.m_name; if (rightItem == "$item_hammer") { if (!repeatBuildPlace.Value) { return; } __instance.m_placeDelay = repeatBuildPlaceDelay.Value; } else if (rightItem == "$item_hoe") { if (!repeatTerrainMod.Value) { return; } __instance.m_placeDelay = repeatTerrainModDelay.Value; } else if (rightItem == "$item_cultivator") { if (!repeatPlanting.Value) { return; } __instance.m_placeDelay = repeatPlantingDelay.Value; } if (!wasSelecting && (ZInput.GetButton("Attack") || ZInput.GetButton("JoyPlace")) && Time.time - ___m_lastToolUseTime > __instance.m_placeDelay) { if (InventoryGui.IsVisible() || Minimap.IsOpen() || StoreGui.IsVisible() || Hud.IsPieceSelectionVisible()) { wasSelecting = true; } else { ___m_placePressedTime = Time.time; } } else if (wasSelecting && !ZInput.GetButton("Attack") && !ZInput.GetButton("JoyPlace")) { wasSelecting = false; } }
static bool Prefix(string name, ref bool __result) { // Need to bypass original function for any required ZInputs that begin // with "Joy" to ensure the VR Controls still work when // Gamepad is disabled. if (VRControls.mainControlsActive && !ZInput.IsGamepadEnabled() && isUsedJoyZinput(name)) { __result = VRControls.instance.GetButtonDown(name); return(false); } return(true); }
private static void Postfix() { if (!isEnabled.Value) { return; } if (waitDialog.activeSelf) { Cursor.lockState = CursorLockMode.None; Cursor.visible = ZInput.IsMouseActive(); } }