Added Wise Old Man competition overlay from standalone project.
This commit is contained in:
85
osrs-toolbox/Models/CompetitionOverlayModel.cs
Normal file
85
osrs-toolbox/Models/CompetitionOverlayModel.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
public abstract class CompetitionOverlayModel : ModelBase
|
||||||
|
{
|
||||||
|
private int _competitionId = -1;
|
||||||
|
private int _groupId = -1;
|
||||||
|
private string _playerName = string.Empty;
|
||||||
|
private string _testOutput = string.Empty;
|
||||||
|
private StackPanel _gridOutput = new StackPanel();
|
||||||
|
private Visibility _controlsVisible = Visibility.Visible;
|
||||||
|
private string _toggleButtonText = string.Empty;
|
||||||
|
private bool _hideOtherPlayers = false;
|
||||||
|
private bool _hideZeroKC = false;
|
||||||
|
|
||||||
|
private ICommand _update;
|
||||||
|
private ICommand _toggleVisibility;
|
||||||
|
private ICommand _closeApp;
|
||||||
|
|
||||||
|
public int CompetitionID
|
||||||
|
{
|
||||||
|
get { return _competitionId; }
|
||||||
|
set { SetProperty(ref _competitionId, value, nameof(CompetitionID)); }
|
||||||
|
}
|
||||||
|
public int GroupID
|
||||||
|
{
|
||||||
|
get { return _groupId; }
|
||||||
|
set { SetProperty(ref _groupId, value, nameof(GroupID)); }
|
||||||
|
}
|
||||||
|
public string PlayerName
|
||||||
|
{
|
||||||
|
get { return _playerName; }
|
||||||
|
set { SetProperty(ref _playerName, value, nameof(PlayerName)); }
|
||||||
|
}
|
||||||
|
public string TestOutput
|
||||||
|
{
|
||||||
|
get { return _testOutput; }
|
||||||
|
set { SetProperty(ref _testOutput, value, nameof(TestOutput)); }
|
||||||
|
}
|
||||||
|
public StackPanel GridOutput
|
||||||
|
{
|
||||||
|
get { return _gridOutput; }
|
||||||
|
set { SetProperty(ref _gridOutput, value, nameof(GridOutput)); }
|
||||||
|
}
|
||||||
|
public Visibility ControlsVisible
|
||||||
|
{
|
||||||
|
get { return _controlsVisible; }
|
||||||
|
set { SetProperty(ref _controlsVisible, value, nameof(ControlsVisible)); }
|
||||||
|
}
|
||||||
|
public string ToggleButtonText
|
||||||
|
{
|
||||||
|
get { return _toggleButtonText; }
|
||||||
|
set { SetProperty(ref _toggleButtonText, value, nameof(ToggleButtonText)); }
|
||||||
|
}
|
||||||
|
public bool HideOtherPlayers
|
||||||
|
{
|
||||||
|
get { return _hideOtherPlayers; }
|
||||||
|
set { SetProperty(ref _hideOtherPlayers, value, nameof(HideOtherPlayers)); }
|
||||||
|
}
|
||||||
|
public bool HideZeroKC
|
||||||
|
{
|
||||||
|
get { return _hideZeroKC; }
|
||||||
|
set { SetProperty(ref _hideZeroKC, value, nameof(HideZeroKC)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand Update
|
||||||
|
{
|
||||||
|
get { return _update; }
|
||||||
|
set { SetProperty(ref _update, value, nameof(Update)); }
|
||||||
|
}
|
||||||
|
public ICommand ToggleVisibility
|
||||||
|
{
|
||||||
|
get { return _toggleVisibility; }
|
||||||
|
set { SetProperty(ref _toggleVisibility, value, nameof(ToggleVisibility)); }
|
||||||
|
}
|
||||||
|
public ICommand CloseApp
|
||||||
|
{
|
||||||
|
get { return _closeApp; }
|
||||||
|
set { SetProperty(ref _closeApp, value, nameof(CloseApp)); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
185
osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs
Normal file
185
osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
public class CompetitionOverlayViewModel : CompetitionOverlayModel
|
||||||
|
{
|
||||||
|
public CompetitionOverlayViewModel()
|
||||||
|
{
|
||||||
|
InitializeVariables();
|
||||||
|
InitializeCommands();
|
||||||
|
InitializeTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeVariables()
|
||||||
|
{
|
||||||
|
CompetitionID = 80030;
|
||||||
|
GroupID = 11197;
|
||||||
|
PlayerName = "kalakoi";
|
||||||
|
TestOutput = string.Empty;
|
||||||
|
GridOutput = new StackPanel();
|
||||||
|
ControlsVisible = Visibility.Visible;
|
||||||
|
ToggleButtonText = "V";
|
||||||
|
HideOtherPlayers = false;
|
||||||
|
HideZeroKC = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeCommands()
|
||||||
|
{
|
||||||
|
Update = new RelayCommand(DoUpdate);
|
||||||
|
CloseApp = new RelayCommand(DoCloseApp);
|
||||||
|
ToggleVisibility = new RelayCommand(DoToggleControls);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeTimer()
|
||||||
|
{
|
||||||
|
DispatcherTimer dt = new DispatcherTimer();
|
||||||
|
dt.Interval = TimeSpan.FromSeconds(5);
|
||||||
|
dt.Tick += new EventHandler(TimerTick);
|
||||||
|
dt.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TimerTick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DoUpdate(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoUpdate(object obj)
|
||||||
|
{
|
||||||
|
GridOutput = new StackPanel();
|
||||||
|
Competition c = new Competition();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
c = WiseOldMan.GetCompetition(CompetitionID);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
GridOutput.Children.Add(new OutlinedTextBlock()
|
||||||
|
{
|
||||||
|
Text = "Failed to load competition data",
|
||||||
|
Margin = new Thickness(3),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Stroke = Brushes.Black,
|
||||||
|
Fill = Brushes.White,
|
||||||
|
FontSize = 20,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
|
FontWeight = FontWeights.ExtraBold,
|
||||||
|
TextWrapping = TextWrapping.Wrap
|
||||||
|
});
|
||||||
|
OnPropertyChanged(nameof(GridOutput));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KCSum = 0;
|
||||||
|
string TempOut = c.title;
|
||||||
|
GridOutput.Children.Add(new OutlinedTextBlock()
|
||||||
|
{
|
||||||
|
Text = c.title,
|
||||||
|
Margin = new Thickness(3),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Stroke = Brushes.Black,
|
||||||
|
Fill = Brushes.White,
|
||||||
|
FontSize = 20,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
|
FontWeight = FontWeights.ExtraBold,
|
||||||
|
TextWrapping = TextWrapping.Wrap
|
||||||
|
});
|
||||||
|
foreach (CompetitionParticipation cp in c.participations)
|
||||||
|
{
|
||||||
|
StackPanel SubStack = new StackPanel()
|
||||||
|
{
|
||||||
|
Orientation = Orientation.Horizontal
|
||||||
|
};
|
||||||
|
|
||||||
|
Image typeImage = new Image();
|
||||||
|
if (cp.player.type == "ironman")
|
||||||
|
typeImage.Source = ExternalResources.IronImage;
|
||||||
|
else typeImage.Source = ExternalResources.MainImage;
|
||||||
|
typeImage.IsHitTestVisible = false;
|
||||||
|
|
||||||
|
SubStack.Children.Add(typeImage);
|
||||||
|
|
||||||
|
SubStack.Children.Add(new OutlinedTextBlock()
|
||||||
|
{
|
||||||
|
Text = cp.player.displayName,
|
||||||
|
Margin = new Thickness(3),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Stroke = Brushes.Black,
|
||||||
|
Fill = PlayerName.ToUpper() == cp.player.displayName.ToUpper() ? Brushes.Green : Brushes.White,
|
||||||
|
FontSize = 20,
|
||||||
|
FontWeight = FontWeights.ExtraBold,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
|
IsHitTestVisible = false
|
||||||
|
});
|
||||||
|
|
||||||
|
SubStack.Children.Add(new OutlinedTextBlock()
|
||||||
|
{
|
||||||
|
Text = string.Format(" - {0} KC", cp.progress.gained.ToString()),
|
||||||
|
Margin = new Thickness(3),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Stroke = Brushes.Black,
|
||||||
|
Fill = Brushes.White,
|
||||||
|
FontSize = 20,
|
||||||
|
FontWeight = FontWeights.ExtraBold,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
|
IsHitTestVisible = false
|
||||||
|
});
|
||||||
|
|
||||||
|
KCSum += cp.progress.gained;
|
||||||
|
|
||||||
|
bool AddToDisplay = true;
|
||||||
|
if (HideOtherPlayers && PlayerName.ToUpper() != cp.player.displayName.ToUpper())
|
||||||
|
AddToDisplay = false;
|
||||||
|
else if (HideZeroKC && cp.progress.gained == 0 && PlayerName.ToUpper() != cp.player.displayName.ToUpper())
|
||||||
|
AddToDisplay = false;
|
||||||
|
|
||||||
|
if (AddToDisplay)
|
||||||
|
GridOutput.Children.Add(SubStack);
|
||||||
|
}
|
||||||
|
GridOutput.Children.Add(new OutlinedTextBlock()
|
||||||
|
{
|
||||||
|
Text = string.Format("Total KC: {0}", KCSum),
|
||||||
|
Margin = new Thickness(3),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Stroke = Brushes.Black,
|
||||||
|
Fill = Brushes.White,
|
||||||
|
FontSize = 20,
|
||||||
|
FontWeight = FontWeights.ExtraBold,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
|
IsHitTestVisible = false
|
||||||
|
});
|
||||||
|
OnPropertyChanged(nameof(GridOutput));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoCloseApp(object obj)
|
||||||
|
{
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoToggleControls(object obj)
|
||||||
|
{
|
||||||
|
if (ControlsVisible == Visibility.Visible)
|
||||||
|
{
|
||||||
|
ControlsVisible = Visibility.Collapsed;
|
||||||
|
Application.Current.MainWindow.ResizeMode = ResizeMode.NoResize;
|
||||||
|
Application.Current.MainWindow.Topmost = true;
|
||||||
|
ToggleButtonText = ">";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ControlsVisible = Visibility.Visible;
|
||||||
|
Application.Current.MainWindow.ResizeMode = ResizeMode.CanResizeWithGrip;
|
||||||
|
Application.Current.MainWindow.Topmost = false;
|
||||||
|
ToggleButtonText = "V";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
53
osrs-toolbox/Views/CompetitionOverlayView.xaml
Normal file
53
osrs-toolbox/Views/CompetitionOverlayView.xaml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<Window x:Class="osrs_toolbox.CompetitionOverlayView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:osrs_toolbox"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Competition Info" Height="800" Width="500" AllowsTransparency="True" Background="Transparent" WindowStyle="None" ResizeMode="CanResizeWithGrip" MouseDown="Window_MouseDown">
|
||||||
|
<Window.DataContext>
|
||||||
|
<local:CompetitionOverlayViewModel/>
|
||||||
|
</Window.DataContext>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="1*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="1*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="1*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<local:OutlinedTextBlock Grid.Column="0" Text="Competition Tracker" Margin="3" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||||
|
<Button Command="{Binding ToggleVisibility, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="3" Padding="3" Content="{Binding ToggleButtonText, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<Button Command="{Binding CloseApp, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="3" Padding="3" Content="X"/>
|
||||||
|
</Grid>
|
||||||
|
<local:OutlinedTextBlock Text="Player:" Margin="3" Grid.Row="1" Grid.Column="0" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<TextBox Text="{Binding PlayerName, UpdateSourceTrigger=PropertyChanged}" Margin="3" Padding="3" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<local:OutlinedTextBlock Text="Group:" Margin="3" Grid.Row="2" Grid.Column="0" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<TextBox Text="{Binding GroupID, UpdateSourceTrigger=PropertyChanged}" Margin="3" Padding="3" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<local:OutlinedTextBlock Text="Competition:" Margin="3" Grid.Row="3" Grid.Column="0" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<TextBox Text="{Binding CompetitionID, UpdateSourceTrigger=PropertyChanged}" Margin="3" Padding="3" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<!--TextBlock Text="Debug Output:" Margin="3" Padding="3" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Left"/-->
|
||||||
|
<local:OutlinedTextBlock Text="Hide Other Players:" Margin="3" Grid.Row="4" Grid.Column="0" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<CheckBox IsChecked="{Binding HideOtherPlayers, UpdateSourceTrigger=PropertyChanged}" Margin="3" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<local:OutlinedTextBlock Text="Hide 0 KC:" Margin="3" Grid.Row="5" Grid.Column="0" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<CheckBox IsChecked="{Binding HideZeroKC, UpdateSourceTrigger=PropertyChanged}" Margin="3" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<Border Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Black" BorderThickness="0" Margin="3" Padding="3" CornerRadius="4">
|
||||||
|
<ContentControl Content="{Binding GridOutput, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
</Border>
|
||||||
|
<Button Content="Debug" Margin="3" Padding="3" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center" Command="{Binding Update, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ControlsVisible, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
33
osrs-toolbox/Views/CompetitionOverlayView.xaml.cs
Normal file
33
osrs-toolbox/Views/CompetitionOverlayView.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for CompetitionOverlayView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class CompetitionOverlayView : Window
|
||||||
|
{
|
||||||
|
public CompetitionOverlayView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.LeftButton == MouseButtonState.Pressed)
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user