Skip to content
Open
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
1 change: 1 addition & 0 deletions Mappy/Mappy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<Compile Include="Models\BandboxMode.cs" />
<Compile Include="Models\ComboBoxViewModel.cs" />
<Compile Include="Models\CoreModel.cs" />
<Compile Include="Models\Enums\GUITab.cs" />
<Compile Include="Models\FeatureClipboardRecord.cs" />
<Compile Include="Models\FeatureInstance.cs" />
<Compile Include="Models\FeatureInstanceEventArgs.cs" />
Expand Down
14 changes: 12 additions & 2 deletions Mappy/Models/CoreModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
namespace Mappy.Models
{
using System.ComponentModel;
using System.Drawing;

using Mappy.Models.Enums;
using Mappy.Util;

public class CoreModel : Notifier, IReadOnlyApplicationModel
Expand All @@ -20,6 +19,8 @@ public class CoreModel : Notifier, IReadOnlyApplicationModel
private Size gridSize = new Size(16, 16);
private Color gridColor = MappySettings.Settings.GridColor;

private GUITab guiTab = GUITab.Sections;

private int viewportWidth;
private int viewportHeight;

Expand Down Expand Up @@ -94,6 +95,15 @@ public Color GridColor
}
}

public GUITab SelectedGUITab
{
get => this.guiTab;
set
{
this.SetField(ref this.guiTab, value, nameof(this.SelectedGUITab));
}
}

public void SetViewportLocation(Point location)
{
this.Map.IfSome(
Expand Down
11 changes: 11 additions & 0 deletions Mappy/Models/Enums/GUITab.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Mappy.Models.Enums
{
public enum GUITab
{
Sections,
Features,
Starts,
Attributes,
Other
}
}
3 changes: 3 additions & 0 deletions Mappy/Models/IMainFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Drawing;
using Mappy.Models.Enums;

public interface IMainFormViewModel
{
Expand Down Expand Up @@ -132,5 +133,7 @@ public interface IMainFormViewModel
void ImportCustomSectionMenuItemClick();

void Load();

void ChangeSelectedTabType(GUITab tabType);
}
}
3 changes: 3 additions & 0 deletions Mappy/Models/IReadOnlyApplicationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.ComponentModel;
using System.Drawing;
using Mappy.Models.Enums;

public interface IReadOnlyApplicationModel : INotifyPropertyChanged
{
Expand All @@ -26,5 +27,7 @@ public interface IReadOnlyApplicationModel : INotifyPropertyChanged
Size GridSize { get; }

Color GridColor { get; }

GUITab SelectedGUITab { get; }
}
}
7 changes: 6 additions & 1 deletion Mappy/Models/MainFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Drawing;
using System.Linq;
using System.Reactive.Linq;

using Mappy.Models.Enums;
using Mappy.Services;

public class MainFormViewModel : IMainFormViewModel
Expand Down Expand Up @@ -341,5 +341,10 @@ public void Load()
{
this.dispatcher.Initialize();
}

public void ChangeSelectedTabType(GUITab tabType)
{
this.dispatcher.ChangeSelectedTab(tabType);
}
}
}
6 changes: 6 additions & 0 deletions Mappy/Services/Dispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Mappy.Data;
using Mappy.IO;
using Mappy.Models;
using Mappy.Models.Enums;
using Mappy.Util;
using Mappy.Util.ImageSampling;

Expand Down Expand Up @@ -545,6 +546,11 @@ public void SelectStartPosition(int index)
this.model.Map.IfSome(x => x.SelectStartPosition(index));
}

public void ChangeSelectedTab(GUITab tab)
{
this.model.SelectedGUITab = tab;
}

private static IEnumerable<string> GetMapNames(HpiArchive hpi)
{
return hpi.GetFiles("maps")
Expand Down
253 changes: 130 additions & 123 deletions Mappy/UI/Forms/MainForm.Designer.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Mappy/UI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using Mappy.Models;
using Mappy.UI.Controls;
using Mappy.Util;

public partial class MainForm : Form
{
Expand Down Expand Up @@ -294,5 +295,15 @@ private void ToggleHeightGridMenuItemClick(object sender, EventArgs e)
{
this.model.ToggleHeightGridMenuItemClick();
}

private void GUITabs_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.sidebarTabs.SelectedTab == null)
{
return;
}

this.model.ChangeSelectedTabType(Util.MapTabNameToGUIType(this.sidebarTabs.SelectedTab.Name));
}
}
}
27 changes: 23 additions & 4 deletions Mappy/Util/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Mappy.Util
using Mappy.Collections;
using Mappy.Data;
using Mappy.Models;
using Mappy.Models.Enums;
using Mappy.Properties;
using Mappy.Services;
using Mappy.Util.ImageSampling;
Expand Down Expand Up @@ -172,6 +173,7 @@ public static BackgroundWorker RenderMinimapWorker()
public struct FeatureInfo
{
public Bitmap Image { get; set; }

public Point Location { get; set; }
}

Expand All @@ -187,10 +189,10 @@ public static IEnumerable<Color> EnumerateBigMinimapImage(RenderMinimapArgs args
args.FeatureService.TryGetFeature(f.FeatureName)
.Where(rec => rec.Permanent)
.Select(rec => new FeatureInfo
{
Image = rec.Image,
Location = rec.GetDrawBounds(args.MapModel.Tile.HeightGrid, f.X, f.Y).Location
}))
{
Image = rec.Image,
Location = rec.GetDrawBounds(args.MapModel.Tile.HeightGrid, f.X, f.Y).Location
}))
.ToList();
featuresList.Sort((a, b) =>
{
Expand Down Expand Up @@ -489,6 +491,23 @@ public static GridCoordinates ToGridCoordinates(Point p)
return new GridCoordinates(p.X, p.Y);
}

public static GUITab MapTabNameToGUIType(string tabName)
{
switch (tabName)
{
case "sectionsTab":
return GUITab.Sections;
case "featuresTab":
return GUITab.Features;
case "attributesTab":
return GUITab.Attributes;
case "startPositionsTab":
return GUITab.Starts;
default:
return GUITab.Other;
}
}

public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, TValue defaultValue)
{
TValue result;
Expand Down