Skip to content

Commit 08f89c1

Browse files
committed
Simplify cell info and remove the X overlay
1 parent 77784c9 commit 08f89c1

File tree

8 files changed

+40
-158
lines changed

8 files changed

+40
-158
lines changed

EnhancePoE/Model/Cell.cs

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,43 @@
11
using System.ComponentModel;
2-
using System.Windows.Controls;
32

43
namespace EnhancePoE.Model
54
{
65
public class Cell : INotifyPropertyChanged
76
{
7+
public event PropertyChangedEventHandler PropertyChanged;
8+
protected virtual void OnPropertyChanged( string propertyName ) => PropertyChanged?.Invoke( this, new PropertyChangedEventArgs( propertyName ) );
9+
10+
public int XIndex { get; }
11+
public int YIndex { get; }
12+
public Item Item { get; private set; }
13+
814
private bool _active;
915
public bool Active
1016
{
1117
get => _active;
12-
set
18+
private set
1319
{
1420
_active = value;
1521
OnPropertyChanged( nameof( Active ) );
1622
}
1723
}
1824

19-
public event PropertyChangedEventHandler PropertyChanged;
20-
21-
protected virtual void OnPropertyChanged( string propertyName )
25+
public Cell( int x, int y )
2226
{
23-
PropertyChanged?.Invoke( this, new PropertyChangedEventArgs( propertyName ) );
27+
XIndex = x;
28+
YIndex = y;
2429
}
2530

26-
public int XIndex { get; set; }
27-
public int YIndex { get; set; }
28-
public string ItemID { get; set; }
29-
30-
public string CellName { get; set; }
31-
32-
private string _buttonName { get; set; }
33-
public string ButtonName
31+
public void Activate( ref Item item )
3432
{
35-
get => _buttonName;
36-
set
37-
{
38-
_buttonName = value;
39-
OnPropertyChanged( nameof( ButtonName ) );
40-
}
33+
Active = true;
34+
Item = item;
4135
}
4236

43-
public Button CellButton { get; set; }
44-
public Item CellItem { get; set; }
45-
public int TabIndex { get; set; }
46-
47-
public Cell()
37+
public void Deactivate()
4838
{
49-
CellButton = new Button
50-
{
51-
Content = ButtonName
52-
};
39+
Active = false;
40+
Item = null;
5341
}
5442
}
5543
}

EnhancePoE/Model/Data.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Threading;
@@ -619,29 +619,21 @@ public static void ActivateNextCell( bool active, Cell cell )
619619
// check for full sets
620620
if ( ItemSetListHighlight[0].EmptyItemSlots.Count == 0 )
621621
{
622-
if ( cell != null )
622+
if ( cell is not null )
623623
{
624-
var highlightItem = cell.CellItem;
625-
stashTab.DeactivateSingleItemCells( cell.CellItem );
626-
_ = ItemSetListHighlight[0].ItemList.Remove( highlightItem );
624+
_ = ItemSetListHighlight[0].ItemList.Remove( cell.Item );
625+
stashTab.DeactivateItemCells( cell.Item );
627626
}
628627

629628
foreach ( var i in ItemSetListHighlight[0].ItemList )
630629
{
631630
stashTab.ActivateItemCells( i );
632631
}
633632

634-
// mark item order
635-
if ( ItemSetListHighlight[0]?.ItemList.Count > 0 )
636-
{
637-
stashTab.MarkNextItem( ItemSetListHighlight[0].ItemList[0] );
638-
}
639-
640633
if ( ItemSetListHighlight[0].ItemList.Count == 0 )
641634
{
642635
ItemSetListHighlight.RemoveAt( 0 );
643636

644-
// activate next set
645637
ActivateNextCell( true, null );
646638
}
647639
}

EnhancePoE/Model/StashTab.cs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ public void InitializeCellList()
4242
{
4343
for ( int j = 0; j < size; j++ )
4444
{
45-
OverlayCellsList.Add( new Cell
46-
{
47-
Active = false,
48-
XIndex = j,
49-
YIndex = i
50-
} );
45+
OverlayCellsList.Add( new Cell( j, i ) );
5146
}
5247
}
5348
}
@@ -124,29 +119,29 @@ public void DeactivateItemCells()
124119
{
125120
foreach ( var cell in OverlayCellsList )
126121
{
127-
cell.Active = false;
122+
cell.Deactivate();
128123
}
129124
}
130125

131-
public void DeactivateSingleItemCells( Item item )
126+
public void DeactivateItemCells( Item item )
132127
{
133-
var AllCoordinates = new List<List<int>>();
128+
var itemCoordinates = new List<List<int>>();
134129

135130
for ( int i = 0; i < item.w; i++ )
136131
{
137132
for ( int j = 0; j < item.h; j++ )
138133
{
139-
AllCoordinates.Add( new List<int> { item.x + i, item.y + j } );
134+
itemCoordinates.Add( new List<int> { item.x + i, item.y + j } );
140135
}
141136
}
142137

143138
foreach ( var cell in OverlayCellsList )
144139
{
145-
foreach ( var coordinate in AllCoordinates )
140+
foreach ( var coordinate in itemCoordinates )
146141
{
147142
if ( coordinate[0] == cell.XIndex && coordinate[1] == cell.YIndex )
148143
{
149-
cell.Active = false;
144+
cell.Deactivate();
150145
}
151146
}
152147
}
@@ -169,23 +164,10 @@ public void ActivateItemCells( Item item )
169164
{
170165
if ( coordinate[0] == cell.XIndex && coordinate[1] == cell.YIndex )
171166
{
172-
cell.Active = true;
173-
cell.CellItem = item;
174-
cell.TabIndex = TabIndex;
167+
cell.Activate( ref item );
175168
}
176169
}
177170
}
178171
}
179-
180-
public void MarkNextItem( Item item )
181-
{
182-
foreach ( var cell in OverlayCellsList )
183-
{
184-
if ( cell.CellItem == item )
185-
{
186-
cell.ButtonName = "X";
187-
}
188-
}
189-
}
190172
}
191173
}

EnhancePoE/UserControls/DynamicGridControl.xaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:properties="clr-namespace:EnhancePoE.Properties"
7-
mc:Ignorable="d">
7+
mc:Ignorable="d"
8+
x:Name="Root">
89
<ItemsControl.Background>
910
<SolidColorBrush Opacity="0"
1011
Color="Transparent" />
1112
</ItemsControl.Background>
1213
<ItemsControl.ItemsPanel>
1314
<ItemsPanelTemplate>
14-
<UniformGrid Columns="12"
15-
Rows="12" />
15+
<UniformGrid Columns="{Binding ElementName=Root, Path=Size}"
16+
Rows="{Binding ElementName=Root, Path=Size}" />
1617
</ItemsPanelTemplate>
1718
</ItemsControl.ItemsPanel>
1819
<ItemsControl.ItemTemplate>
@@ -25,10 +26,7 @@
2526
<ControlTemplate TargetType="{x:Type Button}">
2627
<Border Background="{TemplateBinding Background}"
2728
BorderBrush="White"
28-
BorderThickness="0.5">
29-
<ContentPresenter HorizontalAlignment="Center"
30-
VerticalAlignment="Center" />
31-
</Border>
29+
BorderThickness="0.5" />
3230
</ControlTemplate>
3331
</Setter.Value>
3432
</Setter>
@@ -48,12 +46,6 @@
4846
Value="{Binding Source={x:Static properties:Settings.Default}, Path=ColorStash}" />
4947
<Setter Property="Opacity"
5048
Value="1" />
51-
<Setter Property="Content"
52-
Value="{Binding ButtonName}" />
53-
<Setter Property="Foreground"
54-
Value="White" />
55-
<Setter Property="FontSize"
56-
Value="20" />
5749
</DataTrigger>
5850
</Style.Triggers>
5951
</Style>

EnhancePoE/UserControls/DynamicGridControl.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
{
33
public partial class DynamicGridControl
44
{
5-
public DynamicGridControl()
5+
public int Size { get; }
6+
7+
public DynamicGridControl( int size )
68
{
9+
Size = size;
710
InitializeComponent();
811
}
912
}

EnhancePoE/UserControls/DynamicGridControlQuad.xaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

EnhancePoE/UserControls/DynamicGridControlQuad.xaml.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

EnhancePoE/View/StashTabWindow.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ public StashTabWindow()
8080

8181
IsOpen = true;
8282

83-
var stashTabItem = tab.Quad ?
84-
new TabItem { Content = new DynamicGridControlQuad { ItemsSource = tab.OverlayCellsList } } :
85-
new TabItem { Content = new DynamicGridControl { ItemsSource = tab.OverlayCellsList } };
83+
var size = tab.Quad ? 24 : 12;
84+
var stashTabItem = new TabItem { Content = new DynamicGridControl( size ) { ItemsSource = tab.OverlayCellsList } };
8685

8786
StashTabOverlayTabControl.ItemsSource = new List<TabItem>() { stashTabItem };
8887
StashTabOverlayTabControl.SelectedIndex = 0;

0 commit comments

Comments
 (0)