-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb1366a
commit 53ff474
Showing
8 changed files
with
181 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<src:Widget x:Class="MHWItemBoxTracker.GUI.ItemBoxTracker" | ||
xmlns:src="clr-namespace:HunterPie.GUI;assembly=HunterPie.UI" | ||
xmlns:Custom="clr-namespace:HunterPie.GUIControls.Custom_Controls;assembly=HunterPie.UI" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" ShowInTaskbar="False" Topmost="True" | ||
SizeToContent="Height" Width="350" WidgetActive="True" | ||
MouseDown="OnMouseDown"> | ||
<Grid> | ||
<ListBox Name="theList" HorizontalContentAlignment="Stretch" IsEnabled="False"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<Grid Margin="0,2"> | ||
<!--<Image />--> | ||
<TextBlock Grid.Column="0" Text="{Binding name}" FontSize="14" HorizontalAlignment="Left" Padding="0,0,10,0" /> | ||
<TextBlock Grid.Column="1" Text="{Binding ratio}" FontSize="14" HorizontalAlignment="Right" Padding="0,0,10,0" /> | ||
<ProgressBar Grid.Column="2" Minimum="0" Maximum="100" Value="{Binding progress}" /> | ||
<!--<Custom:MinimalHealthBar Style="{StaticResource OVERLAY_MONSTER_PART_BAR_STYLE}" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" />--> | ||
|
||
<Grid.ColumnDefinitions> | ||
<!--<ColumnDefinition Width="50" />--> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="75" /> | ||
<ColumnDefinition Width="100" /> | ||
</Grid.ColumnDefinitions> | ||
</Grid> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
</Grid> | ||
</src:Widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using HunterPie.GUI; | ||
using HunterPie.Core; | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
using MHWItemBoxTracker.Config; | ||
using System.Linq; | ||
using Debugger = HunterPie.Logger.Debugger; | ||
|
||
namespace MHWItemBoxTracker.GUI | ||
{ | ||
public partial class ItemBoxTracker : Widget | ||
{ | ||
public ItemBoxTracker() | ||
{ | ||
InitializeComponent(); | ||
BaseWidth = Width; | ||
BaseHeight = Height; | ||
SetWindowFlags(); | ||
ApplySettings(); | ||
} | ||
|
||
public void setItemsToDisplay(List<ItemBoxRow> itemBoxRows) | ||
{ | ||
Dispatch(() => | ||
{ | ||
theList.ItemsSource = itemBoxRows; | ||
Debugger.Log(itemBoxRows.Count > 0 ? "Loading Box!!!" : "Hiding Box!!!"); | ||
WidgetHasContent = (itemBoxRows.Count > 0); | ||
ChangeVisibility(); | ||
} | ||
); | ||
|
||
} | ||
|
||
|
||
public override void EnterWidgetDesignMode() | ||
{ | ||
base.EnterWidgetDesignMode(); | ||
RemoveWindowTransparencyFlag(); | ||
} | ||
|
||
public override void LeaveWidgetDesignMode() | ||
{ | ||
base.LeaveWidgetDesignMode(); | ||
ApplyWindowTransparencyFlag(); | ||
SaveSettings(); | ||
} | ||
|
||
private void SaveSettings() | ||
{ | ||
var config = ConfigLoader.loadConfig(); | ||
if (config.overlayPosition == null || config.overlayPosition.Length != 2) | ||
{ | ||
config.overlayPosition = new int[] { 0, 0 }; | ||
} | ||
config.overlayPosition[0] = (int)Left; // - UserSettings.PlayerConfig.Overlay.Position[0]; | ||
config.overlayPosition[1] = (int)Top; // - UserSettings.PlayerConfig.Overlay.Position[1]; | ||
|
||
ConfigLoader.saveConfig(config); | ||
} | ||
|
||
public override void ApplySettings(bool FocusTrigger = false) | ||
{ | ||
Dispatch(() => | ||
{ | ||
if (!FocusTrigger) | ||
{ | ||
var config = ConfigLoader.loadConfig(); | ||
Left = config?.overlayPosition?[0] ?? 0; // + UserSettings.PlayerConfig.Overlay.Position[0]; | ||
Top = config?.overlayPosition?[1] ?? 0; // + UserSettings.PlayerConfig.Overlay.Position[1]; | ||
WidgetActive = config?.IsEnabled ?? true; | ||
Opacity = 0.6; | ||
} | ||
base.ApplySettings(); | ||
}); | ||
} | ||
private void Dispatch(System.Action function) => Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, function); | ||
|
||
private void OnMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) | ||
{ | ||
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) | ||
{ | ||
MoveWidget(); | ||
//SaveSettings(); | ||
} | ||
} | ||
} | ||
|
||
public class ItemBoxRow | ||
{ | ||
public string name { get; set; } | ||
public string ratio { get; set; } | ||
public double progress { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows; | ||
using HunterPie.Core; | ||
using HunterPie.GUI; | ||
using MHWItemBoxTracker.Config; | ||
using Debugger = HunterPie.Logger.Debugger; | ||
|
||
namespace MHWItemBoxTracker.helper | ||
{ | ||
class ItemBoxTracker | ||
{ | ||
private Player player { get; } | ||
private GUI.ItemBoxTracker gui; | ||
|
||
public ItemBoxTracker(Player player) | ||
{ | ||
this.player = player; | ||
Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, | ||
new Action(() => | ||
{ | ||
gui = new GUI.ItemBoxTracker(); | ||
Overlay.RegisterWidget(gui); | ||
})); | ||
} | ||
|
||
public void loadItemBox(object source = null, EventArgs e = null) | ||
{ | ||
if (!player.InHarvestZone) return; | ||
|
||
Debugger.Log("Loading Box!!!"); | ||
|
||
var items = ConfigLoader.loadConfig().tracking; | ||
var box = player.ItemBox; | ||
var ids = items.Select(ic => ic.itemId).ToHashSet(); | ||
|
||
Debugger.Log(String.Join(",", ids)); | ||
var itemsHeld = box.FindItemsInBox(ids); | ||
Debugger.Log(String.Join(",", itemsHeld)); | ||
foreach (ItemConfig item in items){ | ||
var itemBoxRows = new List<GUI.ItemBoxRow>(); | ||
foreach (ItemConfig item in items) | ||
{ | ||
int amountHeld = 0; | ||
itemsHeld.TryGetValue(item.itemId, out amountHeld); | ||
Debugger.Log($"{item.name}: {amountHeld}/{item.amount}"); | ||
|
||
itemBoxRows.Add(new GUI.ItemBoxRow | ||
{ | ||
name = item.name, | ||
ratio = $"{amountHeld}/{item.amount}", | ||
progress = 100.0 * amountHeld / item.amount, | ||
}); | ||
} | ||
gui?.setItemsToDisplay(itemBoxRows); | ||
} | ||
|
||
public void unloadItemBox(object source = null, EventArgs e = null) | ||
{ | ||
Debugger.Log("Hiding Box!!!"); | ||
gui?.setItemsToDisplay(new List<GUI.ItemBoxRow>()); | ||
} | ||
} | ||
} |