Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MiniMap System. #2362

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions Intersect (Core)/Config/MinimapOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Intersect.Config
{
/// <summary>
/// Options for the game map.
/// </summary>
public partial class MinimapOptions
{
/// <summary>
/// Indicates whether or not the minimap window is enabled.
/// </summary>
public bool EnableMinimapWindow { get; set; } = false;

/// <summary>
/// Configures the size at which each minimap tile is rendered.
/// </summary>
public Point TileSize { get; set; } = new(8, 8);

/// <summary>
/// Configures the minimum zoom level (0 - 100)
/// </summary>
public byte MinimumZoom { get; set; } = 1;

/// <summary>
/// Configures the maximum zoom level (0 - 100)
/// </summary>
public byte MaximumZoom { get; set; } = 100;

/// <summary>
/// Configures the default zoom level (0 - 100)
/// </summary>
public byte DefaultZoom { get; set; } = 25;

/// <summary>
/// Configures the amount to zoom by each step.
/// </summary>
public byte ZoomStep { get; set; } = 5;

/// <summary>
/// Configures the images used within the minimap. If any are left blank the system will default to its color.
/// </summary>
public Images MinimapImages { get; set; } = new();

/// <summary>
/// Configures the colours used within the minimap.
/// </summary>
public Colors MinimapColors { get; set; } = new();

/// <summary>
/// Configures which map layers the minimap will render.
/// </summary>
public List<string> RenderLayers { get; set; } = new List<string>
{
"Ground",
"Mask 1",
"Mask 2",
"Fringe 1",
"Fringe 2",
};

[OnDeserializing]
internal void OnDeserializingMethod(StreamingContext context)
{
RenderLayers.Clear();
}

[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
Validate();
}

/// <summary>
/// Validates the properties of the map options object.
/// </summary>
public void Validate()
{
if (MinimumZoom is < 0 or > 100)
{
MinimumZoom = 0;
}

if (MaximumZoom is < 0 or > 100)
{
MaximumZoom = 100;
}

if (DefaultZoom is < 0 or > 100)
{
DefaultZoom = 0;
}
}

public class Colors
{
public Color Player { get; set; } = Color.Cyan;

public Color PartyMember { get; set; } = Color.Blue;

public Color MyEntity { get; set; } = Color.Red;

public Color Npc { get; set; } = Color.Orange;

public Color Event { get; set; } = Color.Blue;

public Dictionary<string, Color> Resource { get; set; } = new() { { "None", Color.White } };

public Color Default { get; set; } = Color.Magenta;
}

public class Images
{
public string Player { get; set; } = "minimap_player.png";

public string PartyMember { get; set; } = "minimap_partymember.png";

public string MyEntity { get; set; } = "minimap_me.png";

public string Npc { get; set; } = "minimap_npc.png";

public string Event { get; set; } = "minimap_event.png";

public Dictionary<string, string> Resource { get; set; } = new() { { "None", "minimap_resource_none.png" } };

public string Default { get; set; } = "minimap_npc.png";
}
}
}
3 changes: 3 additions & 0 deletions Intersect (Core)/Config/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public partial class Options
[JsonProperty("Player")]
public PlayerOptions PlayerOpts = new PlayerOptions();

[JsonProperty("Minimap")]
public MinimapOptions MinimapOpts = new();

[JsonProperty("Party")]
public PartyOptions PartyOpts = new PartyOptions();

Expand Down
2 changes: 2 additions & 0 deletions Intersect.Client/Core/Controls/ControlEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public enum Control

OpenFriends,

OpenMinimap,

OpenSettings,

OpenDebugger,
Expand Down
2 changes: 2 additions & 0 deletions Intersect.Client/Core/Controls/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public void ResetDefaults()
CreateControlMap(Control.HoldToZoomIn, ControlValue.Default, ControlValue.Default);
CreateControlMap(Control.HoldToZoomOut, ControlValue.Default, ControlValue.Default);
CreateControlMap(Control.ToggleFullscreen, new ControlValue(Keys.Alt, Keys.Enter), ControlValue.Default);
CreateControlMap(Control.OpenMinimap, new ControlValue(Keys.None, Keys.M), ControlValue.Default);

}

private static void MigrateControlBindings(Control control)
Expand Down
5 changes: 5 additions & 0 deletions Intersect.Client/Core/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ public static void OnKeyPressed(Keys modifier, Keys key)
case Control.OpenGuild:
_ = (Interface.Interface.GameUi?.GameMenu.ToggleGuildWindow());

break;

case Control.OpenMinimap:
Interface.Interface.GameUi?.GameMenu?.ToggleMinimapWindow();

break;
}

Expand Down
Loading
Loading