Skip to content

Commit

Permalink
Ability to change to zoom level to the approximate current map size.
Browse files Browse the repository at this point in the history
Also changed the minimum API version to 3.18.1
  • Loading branch information
thespbgamer committed Jan 21, 2023
1 parent 02eaa32 commit 0e07f85
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions ZoomLevel/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions ZoomLevel/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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())
Expand Down Expand Up @@ -137,13 +140,43 @@ 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)
{
Helper.Input.Suppress(e.Button);
}
}

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)
Expand Down Expand Up @@ -258,6 +291,7 @@ private string FormatPercentage(float val)
{
return $"{val:0.#%}";
}

}

//Generic Mod Config Menu API
Expand Down
2 changes: 2 additions & 0 deletions ZoomLevel/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions ZoomLevel/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions ZoomLevel/manifest.json
Original file line number Diff line number Diff line change
@@ -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" ]
}

0 comments on commit 0e07f85

Please sign in to comment.