diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b97e8..9f200f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [1.14.0] - 2023-01-21 + +### Added + +- Ability to change to zoom level to the approximate current map size. + +### Changed + +- Minimum API version to 3.18.1 + + ## [1.13.0] - 2022-07-24 ### Added @@ -150,6 +161,7 @@ - Initial release [unreleasedTabThatIMightUseLater]: https://github.com/thespbgamer/ZoomLevel/compare/v1.13.0...HEAD +[1.14.0]: https://github.com/thespbgamer/ZoomLevel/releases/tag/1.14.0 [1.13.0]: https://github.com/thespbgamer/ZoomLevel/releases/tag/1.13.0 [1.12.0]: https://github.com/thespbgamer/ZoomLevel/releases/tag/1.12.0 [1.11.0]: https://github.com/thespbgamer/ZoomLevel/releases/tag/1.11.0 diff --git a/README.md b/README.md index 6292cb5..27beef3 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,17 @@ Here's what you can change: * Player controls: - Setting Name | Default Value | Description - :-------------------------------------------------- | :-------------------------------------------------------------- | :------------------ - `KeybindListIncreaseZoomOrUI` | `OemPeriod` aka `.` or `RightStick` | Key to Increase Zoom or UI Level. - `KeybindListDecreaseZoomOrUI` | `OemComma` aka `,` or `LeftStick` | Key to Decrease Zoom or UI Level. - `KeybindListHoldToChangeUI` | `LeftShift` or `RightShift` or `LeftTrigger and RightTrigger"` | Key you need to hold to change the UI. - `KeybindListResetZoomOrUI` | `null` aka **nothing** | Key to Reset the Zoom or UI Level. - `KeybindListMaxZoomOrUI` | `null` aka **nothing** | Key to Max the Zoom out or Maximize the UI. - `KeybindListMinZoomOrUI` | `null` aka **nothing** | Key to Max the Zoom in or Minimize the UI. - `KeybindListToggleUI` | `null` aka **nothing** | Keybinds to toggle the UI Visibility. - `KeybindListToggleHideUIWithCertainZoom` | `null` aka **nothing** | Keybinds to hides the UI at a certain Zoom Level. + Setting Name | Default Value | Description + :------------------------------------------------------------ | :-------------------------------------------------------------- | :----------------------------------------------- + `KeybindListIncreaseZoomOrUI` | `OemPeriod` aka `.` or `RightStick` | Key to Increase Zoom or UI Level. + `KeybindListDecreaseZoomOrUI` | `OemComma` aka `,` or `LeftStick` | Key to Decrease Zoom or UI Level. + `KeybindListHoldToChangeUI` | `LeftShift` or `RightShift` or `LeftTrigger and RightTrigger"` | Key you need to hold to change the UI. + `KeybindListResetZoomOrUI` | `null` aka **nothing** | Key to Reset the Zoom or UI Level. + `KeybindListMaxZoomOrUI` | `null` aka **nothing** | Key to Max the Zoom out or Maximize the UI. + `KeybindListMinZoomOrUI` | `null` aka **nothing** | Key to Max the Zoom in or Minimize the UI. + `KeybindListToggleUI` | `null` aka **nothing** | Keybinds to toggle the UI Visibility. + `KeybindListToggleHideUIWithCertainZoom` | `null` aka **nothing** | Keybinds to hides the UI at a certain Zoom Level. + `KeybindListChangeZoomToApproximateCurrentMapSize` | `null` aka **nothing** | Keybinds to change to zoom level to the approximate current map size. * Zoom and UI values: diff --git a/ZoomLevel/ModConfig.cs b/ZoomLevel/ModConfig.cs index 5d20a8d..172dbf1 100644 --- a/ZoomLevel/ModConfig.cs +++ b/ZoomLevel/ModConfig.cs @@ -12,6 +12,7 @@ internal class ModConfig public KeybindList KeybindListMinZoomOrUI { get; set; } = KeybindList.Parse(""); public KeybindList KeybindListToggleUI { get; set; } = KeybindList.Parse(""); public KeybindList KeybindListToggleHideUIWithCertainZoom { get; set; } = KeybindList.Parse(""); + public KeybindList KeybindListChangeZoomToApproximateCurrentMapSize { get; set; } = KeybindList.Parse(""); public float ZoomLevelIncreaseValue { get; set; } = 0.05f; public float ZoomLevelDecreaseValue { get; set; } = -0.05f; diff --git a/ZoomLevel/ModEntry.cs b/ZoomLevel/ModEntry.cs index 5901b70..a02f0c7 100644 --- a/ZoomLevel/ModEntry.cs +++ b/ZoomLevel/ModEntry.cs @@ -43,6 +43,8 @@ private void onLaunched(object sender, GameLaunchedEventArgs e) genericModConfigMenuAPI.AddKeybindList(ModManifest, () => configsForTheMod.KeybindListMinZoomOrUI, (KeybindList val) => configsForTheMod.KeybindListMinZoomOrUI = val, () => Helper.Translation.Get("keybinds.ZoomOrUIMinLevels.name"), () => Helper.Translation.Get("keybinds.ZoomOrUIMinLevels.description")); genericModConfigMenuAPI.AddKeybindList(ModManifest, () => configsForTheMod.KeybindListToggleUI, (KeybindList val) => configsForTheMod.KeybindListToggleUI = val, () => Helper.Translation.Get("keybinds.ToggleUIVisibility.name"), () => Helper.Translation.Get("keybinds.ToggleUIVisibility.description")); genericModConfigMenuAPI.AddKeybindList(ModManifest, () => configsForTheMod.KeybindListToggleHideUIWithCertainZoom, (KeybindList val) => configsForTheMod.KeybindListToggleHideUIWithCertainZoom = val, () => Helper.Translation.Get("keybinds.ToggleHideUIAtCertainZoom.name"), () => Helper.Translation.Get("keybinds.ToggleHideUIAtCertainZoom.description")); + genericModConfigMenuAPI.AddKeybindList(ModManifest, () => configsForTheMod.KeybindListChangeZoomToApproximateCurrentMapSize, (KeybindList val) => configsForTheMod.KeybindListChangeZoomToApproximateCurrentMapSize = val, () => Helper.Translation.Get("keybinds.ChangeZoomToApproximateCurrentMapSize.name"), () => Helper.Translation.Get("keybinds.ChangeZoomToApproximateCurrentMapSize.description")); + genericModConfigMenuAPI.AddSectionTitle(ModManifest, () => Helper.Translation.Get("values.title.name"), () => Helper.Translation.Get("values.title.description")); genericModConfigMenuAPI.AddNumberOption(ModManifest, () => configsForTheMod.ZoomLevelIncreaseValue, (float val) => configsForTheMod.ZoomLevelIncreaseValue = val, () => Helper.Translation.Get("values.ZoomOrUILevelsIncrease.name"), () => Helper.Translation.Get("values.ZoomOrUILevelsIncrease.description"), 0.01f, 0.50f, 0.01f, FormatPercentage); @@ -64,6 +66,7 @@ private void Events_Input_ButtonPressed(object sender, ButtonPressedEventArgs e) if (!Context.IsWorldReady || (!Context.IsPlayerFree && !configsForTheMod.ZoomAndUIControlEverywhere)) { return; } bool wasThePreviousButtonPressSucessfull = false; + if (configsForTheMod.KeybindListHoldToChangeUI.IsDown()) { if (configsForTheMod.KeybindListIncreaseZoomOrUI.JustPressed()) @@ -137,6 +140,14 @@ private void Events_Input_ButtonPressed(object sender, ButtonPressedEventArgs e) //Game1.addHUDMessage(new HUDMessage("Hide UI With Certain Zoom is now: " + configsForTheMod.IsHideUIWithCertainZoom.ToString(), 2)); Game1.addHUDMessage(new HUDMessage(Helper.Translation.Get("hudMessages.HideUIWithCertainZoomIs.message", new { value = configsForTheMod.IsHideUIWithCertainZoom.ToString() }), 2)); } + else if (configsForTheMod.KeybindListChangeZoomToApproximateCurrentMapSize.JustPressed()) + { + ChangeZoomLevelToCurrentMapSize(); + wasThePreviousButtonPressSucessfull = true; + } + + + if (configsForTheMod.SuppressControllerButton == true && wasThePreviousButtonPressSucessfull == true) { @@ -144,6 +155,28 @@ private void Events_Input_ButtonPressed(object sender, ButtonPressedEventArgs e) } } + private void ChangeZoomLevelToCurrentMapSize() + { + if (Game1.currentLocation != null) + { + int mapWidth = Game1.currentLocation.map.DisplayWidth; + int mapHeight = Game1.currentLocation.map.DisplayHeight; + int screenWidth = Game1.graphics.GraphicsDevice.Viewport.Width; + int screenHeight = Game1.graphics.GraphicsDevice.Viewport.Height; + float zoomLevel; + if (mapWidth > mapHeight) + { + zoomLevel = (float)screenWidth / (float)mapWidth; + } + else + { + zoomLevel = (float)screenHeight / (float)mapHeight; + } + Game1.options.desiredBaseZoomLevel = zoomLevel; + RefreshWindow(); + } + } + private void CheckAndUpdateUIValues() { if (configsForTheMod.IsHideUIWithCertainZoom == true) @@ -258,6 +291,7 @@ private string FormatPercentage(float val) { return $"{val:0.#%}"; } + } //Generic Mod Config Menu API diff --git a/ZoomLevel/i18n/default.json b/ZoomLevel/i18n/default.json index e95cdaa..2520abb 100644 --- a/ZoomLevel/i18n/default.json +++ b/ZoomLevel/i18n/default.json @@ -17,6 +17,8 @@ "keybinds.ToggleUIVisibility.description": "Keybinds to toggle the UI Visibility.", "keybinds.ToggleHideUIAtCertainZoom.name": "Toggle Hide UI at Certain Zoom", "keybinds.ToggleHideUIAtCertainZoom.description": "Keybinds to hides the UI at a certain Zoom Level.", + "keybinds.ChangeZoomToApproximateCurrentMapSize.name": "Zoom to Approximate Map Size", + "keybinds.ChangeZoomToApproximateCurrentMapSize.description": "Keybinds to change to zoom level to the approximate current map size.", "values.title.name": "Values:", "values.title.description": "All the values that changes the Zoom Level and UI Level.", "values.ZoomOrUILevelsIncrease.name": "Zoom or UI Levels Increase", diff --git a/ZoomLevel/i18n/en.json b/ZoomLevel/i18n/en.json index e95cdaa..2520abb 100644 --- a/ZoomLevel/i18n/en.json +++ b/ZoomLevel/i18n/en.json @@ -17,6 +17,8 @@ "keybinds.ToggleUIVisibility.description": "Keybinds to toggle the UI Visibility.", "keybinds.ToggleHideUIAtCertainZoom.name": "Toggle Hide UI at Certain Zoom", "keybinds.ToggleHideUIAtCertainZoom.description": "Keybinds to hides the UI at a certain Zoom Level.", + "keybinds.ChangeZoomToApproximateCurrentMapSize.name": "Zoom to Approximate Map Size", + "keybinds.ChangeZoomToApproximateCurrentMapSize.description": "Keybinds to change to zoom level to the approximate current map size.", "values.title.name": "Values:", "values.title.description": "All the values that changes the Zoom Level and UI Level.", "values.ZoomOrUILevelsIncrease.name": "Zoom or UI Levels Increase", diff --git a/ZoomLevel/manifest.json b/ZoomLevel/manifest.json index af2986d..f73f529 100644 --- a/ZoomLevel/manifest.json +++ b/ZoomLevel/manifest.json @@ -1,10 +1,10 @@ { "Name": "ZoomLevel", "Author": "thespbgamer", - "Version": "1.13.0", + "Version": "1.14.0", "Description": "Change the Zoom and UI levels with a simple keybind.", "UniqueID": "thespbgamer.ZoomLevel", "EntryDll": "ZoomLevel.dll", - "MinimumApiVersion": "3.15.1", + "MinimumApiVersion": "3.18.1", "UpdateKeys": [ "GitHub:thespbgamer/ZoomLevel", "Nexus:7363" ] } \ No newline at end of file