Skip to content

Commit

Permalink
Add remaining monster.
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Mar 21, 2020
1 parent 73f488e commit a535fb6
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 47 deletions.
8 changes: 8 additions & 0 deletions src/Lurker.UI/Lurker.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<Compile Include="ViewModels\OutgoingOfferViewModel.cs" />
<Compile Include="ViewModels\PoeOverlayBase.cs" />
<Compile Include="ViewModels\PositionViewModel.cs" />
<Compile Include="ViewModels\RemainingMonsterViewModel.cs" />
<Compile Include="ViewModels\ScreenBase.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\TradebarViewModel.cs" />
Expand All @@ -260,6 +261,9 @@
<Compile Include="Views\PositionView.xaml.cs">
<DependentUpon>PositionView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\RemainingMonsterView.xaml.cs">
<DependentUpon>RemainingMonsterView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -312,6 +316,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\RemainingMonsterView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
25 changes: 17 additions & 8 deletions src/Lurker.UI/ViewModels/BulbViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public abstract class BulbViewModel : PoeOverlayBase
private INotifyPropertyChanged _actionView;
protected static readonly int DefaultBulbHeight = 220;
protected System.Action _action;
private System.Action _previousAction;

#endregion

Expand All @@ -36,6 +37,7 @@ public abstract class BulbViewModel : PoeOverlayBase
public BulbViewModel(IWindowManager windowManager, DockingHelper dockingHelper, ClientLurker lurker, SettingsService settingsService)
: base(windowManager, dockingHelper, lurker, settingsService)
{
this.SetDefaultAction();
}

#endregion
Expand Down Expand Up @@ -64,6 +66,11 @@ protected set
}
}

/// <summary>
/// Defaults the action.
/// </summary>
protected virtual System.Action DefaultAction => null;

#endregion

#region Methods
Expand All @@ -82,22 +89,23 @@ public void OnClick()
this._action.Invoke();
}


/// <summary>
/// Defaults the action.
/// Hides this instance.
/// </summary>
protected virtual void DefaultAction()
protected void Hide()
{
this.ActionView = null;
this._action = this._previousAction;
this._previousAction = null;
this.NotifyOfPropertyChange(nameof(this.HasAction));
}

/// <summary>
/// Hides this instance.
/// Sets the default action.
/// </summary>
protected void Hide()
protected void SetDefaultAction()
{
this.ActionView = null;
this._action = null;
this.NotifyOfPropertyChange(nameof(this.HasAction));
this.SetAction(new BulbMessage() { Action = this.DefaultAction });
}

/// <summary>
Expand All @@ -107,6 +115,7 @@ protected void Hide()
protected void SetAction(BulbMessage message)
{
message.OnShow?.Invoke(this.Hide);
this._previousAction = this._action;
this._action = message.Action;
this.ActionView = message.View;

Expand Down
5 changes: 1 addition & 4 deletions src/Lurker.UI/ViewModels/LifeBulbViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ protected override void SetWindowPosition(PoeWindowInformation windowInformation
/// <summary>
/// Defaults the action.
/// </summary>
protected override void DefaultAction()
{
this._keyboardHelper.JoinHideout();
}
protected override System.Action DefaultAction => () => this._keyboardHelper.JoinHideout();

#endregion
}
Expand Down
30 changes: 17 additions & 13 deletions src/Lurker.UI/ViewModels/ManaBulbViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace Lurker.UI.ViewModels
using Lurker.UI.Helpers;
using Lurker.UI.Models;
using Lurker.UI.Views;
using System;

public class ManaBulbViewModel : BulbViewModel, IHandle<ManaBulbMessage>
{
#region Fields

private IEventAggregator _eventAggregator;
private PoeKeyboardHelper _keyboardHelper;
private SettingsViewModel _settingsViewModel;

#endregion
Expand All @@ -35,12 +35,22 @@ public class ManaBulbViewModel : BulbViewModel, IHandle<ManaBulbMessage>
public ManaBulbViewModel(IEventAggregator eventAggregator, IWindowManager windowManager, DockingHelper dockingHelper, ClientLurker lurker, SettingsService settingsService, PoeKeyboardHelper keyboard, SettingsViewModel settingsViewModel)
: base(windowManager, dockingHelper, lurker, settingsService)
{
this._keyboardHelper = keyboard;
this._settingsViewModel = settingsViewModel;
this._eventAggregator = eventAggregator;
this._eventAggregator.Subscribe(this);

lurker.LocationChanged += this.Lurker_LocationChanged;
lurker.RemainingMonsters += this.Lurker_RemainingMonsters;
}

/// <summary>
/// Lurkers the remaining monsters.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
private void Lurker_RemainingMonsters(object sender, Patreon.Events.MonstersRemainEvent e)
{
this.SetAction(new ManaBulbMessage() { View = new RemainingMonsterViewModel(e), DisplayTime = TimeSpan.FromSeconds(3)});
}

/// <summary>
Expand All @@ -50,16 +60,13 @@ public ManaBulbViewModel(IEventAggregator eventAggregator, IWindowManager window
/// <param name="e">The e.</param>
private void Lurker_LocationChanged(object sender, Patreon.Events.LocationChangedEvent e)
{
var message = new ManaBulbMessage();
if (e.Location.EndsWith("Hideout"))
{
this.Hidden = false;
this.ShowView();
}
else
{
this.Hidden = true;
this.HideView();
message.Action = this.DefaultAction;
}

this.SetAction(message);
}

#endregion
Expand Down Expand Up @@ -95,10 +102,7 @@ protected override void SetWindowPosition(PoeWindowInformation windowInformation
/// <summary>
/// Defaults the action.
/// </summary>
protected override void DefaultAction()
{
this._eventAggregator.PublishOnUIThread(this._settingsViewModel);
}
protected override System.Action DefaultAction => () => this._eventAggregator.PublishOnUIThread(this._settingsViewModel);

#endregion
}
Expand Down
10 changes: 0 additions & 10 deletions src/Lurker.UI/ViewModels/PoeOverlayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public PoeOverlayBase(IWindowManager windowManager, DockingHelper dockingHelper,
/// </summary>
public bool DebugEnabled => this._settingsService.DebugEnabled;

/// <summary>
/// Gets or sets a value indicating whether this <see cref="PoeOverlayBase"/> is hidden.
/// </summary>
protected bool Hidden { get; set; }

#endregion

#region Methods
Expand Down Expand Up @@ -94,11 +89,6 @@ private void DockingHelper_OnForegroundChange(object sender, bool e)
{
if (e)
{
if (this.Hidden)
{
return;
}

this.ShowView();
}
else
Expand Down
46 changes: 46 additions & 0 deletions src/Lurker.UI/ViewModels/RemainingMonsterViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------
// <copyright file="RemainingMonsterViewModel.cs" company="Wohs">
// Missing Copyright information from a valid stylecop.json file.
// </copyright>
//-----------------------------------------------------------------------

namespace Lurker.UI.ViewModels
{
using Lurker.Patreon.Events;

public class RemainingMonsterViewModel : Caliburn.Micro.PropertyChangedBase
{
#region Fields

private MonstersRemainEvent _monsterEvent;

#endregion

#region Constructors

/// <summary>
/// Initializes a new instance of the <see cref="RemainingMonsterViewModel"/> class.
/// </summary>
/// <param name="monsterEvent">The monster event.</param>
public RemainingMonsterViewModel(MonstersRemainEvent monsterEvent)
{
this._monsterEvent = monsterEvent;
}

#endregion

#region Properties

/// <summary>
/// Gets or sets the monster remaining.
/// </summary>
public int MonsterCount => this._monsterEvent.MonsterCount;

/// <summary>
/// Gets a value indicating whether [less than50].
/// </summary>
public bool LessThan50 => this.MonsterCount < 50;

#endregion
}
}
20 changes: 20 additions & 0 deletions src/Lurker.UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ public string BusyMessage
}
}

/// <summary>
/// Gets or sets the busy message.
/// </summary>
/// <value>
/// The busy message.
/// </value>
public bool RemainingMonsterEnabled
{
get
{
return this._settingService.RemainingMonsterEnabled;
}

set
{
this._settingService.RemainingMonsterEnabled = value;
this.NotifyOfPropertyChange();
}
}

/// <summary>
/// Gets or sets the sold message.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/ViewModels/UpdateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Lurker.UI.ViewModels
using System.IO;
using System.Reflection;

public class UpdateViewModel: Caliburn.Micro.PropertyChangedBase
public class UpdateViewModel : Caliburn.Micro.PropertyChangedBase
{
#region Constructors

Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/Views/LifeBulbView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Title="LifeBulbView">
<Grid>
<ContentControl Height="80" x:Name="ActionView" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Ellipse Cursor="Hand" x:Name="Test" cal:Message.Attach="[Event MouseDown] = [Action OnClick()]">
<Ellipse Cursor="Hand" x:Name="Test" cal:Message.Attach="[Event MouseDown] = [Action OnClick()]" Visibility="{Binding HasAction, Converter={StaticResource BooleanToVisibilityConverter}}">
<Ellipse.Clip>
<RectangleGeometry x:Name="RectangleGeometry"/>
</Ellipse.Clip>
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/Views/ManaBulbView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Title="ManaBulbView">
<Grid>
<ContentControl Height="160" x:Name="ActionView" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Ellipse Cursor="Hand" x:Name="Test" cal:Message.Attach="[Event MouseDown] = [Action OnClick()]">
<Ellipse Cursor="Hand" x:Name="Test" cal:Message.Attach="[Event MouseDown] = [Action OnClick()]" Visibility="{Binding HasAction, Converter={StaticResource BooleanToVisibilityConverter}}">
<Ellipse.Style>
<Style TargetType="{x:Type Ellipse}">
<Setter Property="Opacity" Value="0.002"/>
Expand Down
24 changes: 24 additions & 0 deletions src/Lurker.UI/Views/RemainingMonsterView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<UserControl x:Class="Lurker.UI.Views.RemainingMonsterView"
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"
xmlns:local="clr-namespace:Lurker.UI.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid ShowGridLines="True">
<Ellipse Height="80" Width="80">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Setter Property="Fill" Value="#972e1b"/>
<Style.Triggers>
<DataTrigger Binding="{Binding LessThan50}" Value="true">
<Setter Property="Fill" Value="#3ace3a"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="28" Foreground="White" Text="{Binding MonsterCount}"/>
</Grid>
</UserControl>
21 changes: 21 additions & 0 deletions src/Lurker.UI/Views/RemainingMonsterView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//-----------------------------------------------------------------------
// <copyright file="RemainingMonsterView.xaml.cs" company="Wohs">
// Missing Copyright information from a valid stylecop.json file.
// </copyright>
//-----------------------------------------------------------------------

namespace Lurker.UI.Views
{
using System.Windows.Controls;

/// <summary>
/// Interaction logic for RemainingMonsterView.xaml
/// </summary>
public partial class RemainingMonsterView : UserControl
{
public RemainingMonsterView()
{
this.InitializeComponent();
}
}
}
17 changes: 11 additions & 6 deletions src/Lurker.UI/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,17 @@
VerticalAlignment="Top"
Text="(Ctrl + F)" />
</StackPanel>
<Controls:ToggleSwitch Grid.Row="1"
Margin="0,30,0,0"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Header="Debug Mode"
IsChecked="{Binding DebugEnabled}"/>
<StackPanel Orientation="Horizontal" Margin="0,30,0,0" HorizontalAlignment="Center">
<Controls:ToggleSwitch
Header="Remaining Monster"
IsChecked="{Binding RemainingMonsterEnabled}"/>
<Controls:ToggleSwitch Grid.Row="1"
VerticalAlignment="Top"
Margin="30,0,0,0"
HorizontalAlignment="Center"
Header="Debug Mode"
IsChecked="{Binding DebugEnabled}"/>
</StackPanel>
</StackPanel>
</Grid>
</TabItem>
Expand Down
Loading

0 comments on commit a535fb6

Please sign in to comment.