diff --git a/ItemBoxTracker/src/Plugin/Main.cs b/ItemBoxTracker/src/Plugin/Main.cs index a937c24..4f01ce2 100644 --- a/ItemBoxTracker/src/Plugin/Main.cs +++ b/ItemBoxTracker/src/Plugin/Main.cs @@ -17,7 +17,7 @@ public class Main : IPlugin, ISettingsOwner { private EventService Events; private HunterPieService HP; private InventoryService Inventory; - private InventoryView GUI; + private InventoryWidget GUI; private SettingsView settings; private SettingsView Settings { diff --git a/ItemBoxTracker/src/Plugin/Service/EventService.cs b/ItemBoxTracker/src/Plugin/Service/EventService.cs index c45c6cc..b8fee8c 100644 --- a/ItemBoxTracker/src/Plugin/Service/EventService.cs +++ b/ItemBoxTracker/src/Plugin/Service/EventService.cs @@ -6,10 +6,10 @@ namespace MHWItemBoxTracker.Service { public class EventService { private Game Context; - InventoryView GUI; + InventoryWidget GUI; InventoryService Inventory; SettingsView Settings; - public EventService(Game Context, InventoryView GUI, InventoryService Inventory, SettingsView Settings) { + public EventService(Game Context, InventoryWidget GUI, InventoryService Inventory, SettingsView Settings) { this.Context = Context; this.GUI = GUI; this.Inventory = Inventory; diff --git a/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml b/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml index 07b729f..84ebf4b 100644 --- a/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml +++ b/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml @@ -1,37 +1,24 @@ - - + Width="350"> + - - - - + - + diff --git a/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml.cs b/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml.cs index 9d667e6..ce847b1 100644 --- a/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml.cs +++ b/ItemBoxTracker/src/Plugin/Views/InventoryView.xaml.cs @@ -1,48 +1,10 @@ -using System.Threading.Tasks; -using HunterPie.Core.Settings; -using HunterPie.GUI; -using HunterPie.Plugins; -using MHWItemBoxTracker.Model; -using MHWItemBoxTracker.ViewModel; -using static MHWItemBoxTracker.Main; +using System.Windows.Controls; namespace MHWItemBoxTracker.Views { - public partial class InventoryView : Widget { - private static readonly string settingsJson = "widget.settings.json"; - private ItemBoxWidgetSettings widgetSettings { get; set; } - public override IWidgetSettings Settings => widgetSettings; - private InventoryViewModel VM; - public bool ShouldShow { - set { - WidgetHasContent = value; - ChangeVisibility(); - } - } - - public InventoryView(InventoryModel Inventory) : base() { + // TODO: Delete this somehow + public partial class InventoryView : UserControl { + public InventoryView() : base() { InitializeComponent(); - VM = new(Inventory); - DataContext = VM; - } - - public async Task Initialize() { - widgetSettings = await Plugin.LoadJson(settingsJson); - ApplySettings(); - } - - public void Unload() { - ShouldShow = false; - } - - public override void EnterWidgetDesignMode() { - base.EnterWidgetDesignMode(); - RemoveWindowTransparencyFlag(); - } - - public async override void LeaveWidgetDesignMode() { - base.LeaveWidgetDesignMode(); - ApplyWindowTransparencyFlag(); - await Plugin.SaveJson(settingsJson, widgetSettings); } } } diff --git a/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml b/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml new file mode 100644 index 0000000..7c08f3b --- /dev/null +++ b/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml @@ -0,0 +1,33 @@ + + + + + + diff --git a/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml.cs b/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml.cs new file mode 100644 index 0000000..b471ef7 --- /dev/null +++ b/ItemBoxTracker/src/Plugin/Views/InventoryWidget.xaml.cs @@ -0,0 +1,54 @@ +using System.Threading.Tasks; +using HunterPie.Core.Settings; +using HunterPie.GUI; +using HunterPie.Plugins; +using MHWItemBoxTracker.Model; +using MHWItemBoxTracker.ViewModel; +using static MHWItemBoxTracker.Main; + +namespace MHWItemBoxTracker.Views { + public partial class InventoryWidget : Widget { + private static readonly string settingsJson = "widget.settings.json"; + private ItemBoxWidgetSettings widgetSettings { get; set; } + public override IWidgetSettings Settings => widgetSettings; + public InventoryViewModel VM { get; } + public bool ShouldShow { + set { + WidgetHasContent = value; + ChangeVisibility(); + } + } + + public InventoryWidget(InventoryModel Inventory) : base() { + InitializeComponent(); + SetWindowFlags(); + VM = new(Inventory); + DataContext = this; + } + + public async Task Initialize() { + widgetSettings = await Plugin.LoadJson(settingsJson); + ApplySettings(); + } + + public void Unload() { + ShouldShow = false; + } + + public override void EnterWidgetDesignMode() { + base.EnterWidgetDesignMode(); + RemoveWindowTransparencyFlag(); + } + + public async override void LeaveWidgetDesignMode() { + ApplyWindowTransparencyFlag(); + base.LeaveWidgetDesignMode(); + await Plugin.SaveJson(settingsJson, widgetSettings); + } + + public override void ScaleWidget(double newScaleX, double newScaleY) { + base.ScaleWidget(newScaleX, newScaleY); + contents.LayoutTransform = LayoutTransform; + } + } +}