Skip to content

Commit

Permalink
Support for toolbox builds (#908)
Browse files Browse the repository at this point in the history
Closes #866
  • Loading branch information
AlexMacocian committed Dec 10, 2024
1 parent aabc98e commit ce810da
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 14 deletions.
23 changes: 23 additions & 0 deletions Daybreak/Controls/Buttons/GWToolboxButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<UserControl x:Class="Daybreak.Controls.Buttons.GWToolboxButton"
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:Daybreak.Controls.Buttons"
xmlns:glyphs="clr-namespace:Daybreak.Controls.Glyphs"
x:Name="_this"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<local:CircularButton Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Highlight="{StaticResource MahApps.Brushes.Accent}"
Clicked="HighlightButton_Clicked">
<local:CircularButton.Content>
<Viewbox Stretch="Fill" Width="60" Height="60">
<glyphs:GWToolboxGlyph Foreground="{StaticResource MahApps.Brushes.ThemeForeground}" Margin="10"
IsEnabled="{Binding ElementName=_this, Path=IsEnabled, Mode=OneWay}" />
</Viewbox>
</local:CircularButton.Content>
</local:CircularButton>
</Grid>
</UserControl>
30 changes: 30 additions & 0 deletions Daybreak/Controls/Buttons/GWToolboxButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Windows.Controls;
using System.Windows.Extensions;
using System.Windows.Input;

namespace Daybreak.Controls.Buttons;
/// <summary>
/// Interaction logic for GWToolboxButton.xaml
/// </summary>
public partial class GWToolboxButton : UserControl
{
public event EventHandler? Clicked;

[GenerateDependencyProperty]
private ICommand click = default!;

public GWToolboxButton()
{
this.InitializeComponent();
}

private void HighlightButton_Clicked(object sender, EventArgs e)
{
this.Clicked?.Invoke(this, e);
if (this.Click?.CanExecute(e) is true)
{
this.Click?.Execute(e);
}
}
}
14 changes: 13 additions & 1 deletion Daybreak/Controls/Glyphs/GWToolboxGlyph.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
x:Name="_this"
d:DesignHeight="450" d:DesignWidth="800">
<Viewbox>
<TextBlock Text="G" Foreground="{Binding ElementName=_this, Path=Foreground, Mode=OneWay}"></TextBlock>
<Grid Width="340"
Height="340">
<Path Data="M0 0 C1.69962891 0.81404297 1.69962891 0.81404297 3.43359375 1.64453125 C4.07280762 1.95092529 4.71202148 2.25731934 5.37060547 2.57299805 C6.05268066 2.89953369 6.73475586 3.22606934 7.4375 3.5625 C8.51088623 4.07840698 8.51088623 4.07840698 9.60595703 4.60473633 C33.07648031 15.71332157 58.20660998 23.45166112 83 31 C83.83915356 34.42410649 84.05926568 36.89731576 83.2578125 40.328125 C83.07863281 41.12863281 82.89945313 41.92914063 82.71484375 42.75390625 C82.42287109 43.98947266 82.42287109 43.98947266 82.125 45.25 C79.95981225 54.61257049 78.80315353 63.70030735 78.625 73.3125 C78.58761719 74.09689453 78.55023438 74.88128906 78.51171875 75.68945312 C78.47783701 77.90494256 78.49928258 79.84021033 79 82 C80.62284471 83.38633711 82.2883043 84.72498887 84 86 C84.41015625 88.828125 84.41015625 88.828125 84.0625 92.25 C83.99893311 92.89130859 83.93536621 93.53261719 83.86987305 94.19335938 C83.62182231 96.46940323 83.31718748 98.73256264 83 101 C82.87947266 101.88365234 82.75894531 102.76730469 82.63476562 103.67773438 C77.61859906 139.23134419 67.36610237 175.93719364 44 204 C43.3800415 204.75337646 43.3800415 204.75337646 42.74755859 205.52197266 C30.9225617 219.730647 14.81960314 231.0531445 -4 233 C-20.71983429 233.82228693 -36.61601945 226.64306773 -49.0625 215.75 C-58.28148344 207.09279837 -65.58587028 197.85423576 -72 187 C-72.34417969 186.4215332 -72.68835938 185.84306641 -73.04296875 185.24707031 C-87.77913242 160.10807846 -95.27522291 130.68338831 -99 102 C-99.16701416 100.75428223 -99.16701416 100.75428223 -99.33740234 99.48339844 C-99.61844344 97.26166082 -99.85331009 95.04202409 -100.0625 92.8125 C-100.17722656 91.60207031 -100.29195313 90.39164062 -100.41015625 89.14453125 C-99.86780385 84.98649615 -97.93270119 83.87830796 -95 81 C-92.40922021 67.77338739 -96.39701691 51.03100756 -99.61962891 38.10107422 C-100.05417978 35.70072454 -100.06105541 33.43425251 -100 31 C-99.08114014 30.71914551 -98.16228027 30.43829102 -97.21557617 30.14892578 C-71.7487105 22.34448968 -46.49579684 14.27767304 -22.3046875 3.0078125 C-21.59924805 2.68039063 -20.89380859 2.35296875 -20.16699219 2.015625 C-18.63608221 1.29811875 -17.11120546 0.56767189 -15.59082031 -0.171875 C-14.80030273 -0.54570313 -14.00978516 -0.91953125 -13.1953125 -1.3046875 C-12.48648926 -1.64741699 -11.77766602 -1.99014648 -11.04736328 -2.34326172 C-6.94255944 -3.6599708 -3.71205826 -1.77858331 0 0 Z M-76 45 C-70.67263892 57.26829788 -62.42669599 64.9191649 -52 73 C-50.9495752 73.82298584 -50.9495752 73.82298584 -49.87792969 74.66259766 C-47.56985092 76.46962566 -45.25506555 78.26765881 -42.9375 80.0625 C-42.18670166 80.64741211 -41.43590332 81.23232422 -40.66235352 81.83496094 C-39.95780029 82.37540039 -39.25324707 82.91583984 -38.52734375 83.47265625 C-37.89562256 83.96000244 -37.26390137 84.44734863 -36.61303711 84.94946289 C-35.0415108 86.18191384 -35.0415108 86.18191384 -33 86 C-37.22972745 69.87416409 -49.70021449 58.25961896 -63.55883789 49.86669922 C-67.61320412 47.5284124 -71.4558599 46.11999345 -76 45 Z M58 45 C49.60410566 48.92923078 42.07699017 52.91486072 35 59 C34.02417969 59.76570313 33.04835937 60.53140625 32.04296875 61.3203125 C24.58047203 67.5488346 19.37037237 76.67653535 17 86 C32.34910153 79.06931822 51.43312191 62.87282934 59 48 C58.505 46.515 58.505 46.515 58 45 Z M-33 123 C-33 133.23 -33 143.46 -33 154 C-35.18625 151.215625 -37.3725 148.43125 -39.625 145.5625 C-40.30127441 144.70470947 -40.97754883 143.84691895 -41.67431641 142.96313477 C-45.70908589 137.79898221 -49.44743003 132.50673051 -53 127 C-54.29971645 130.89914934 -53.38975743 132.22671204 -51.875 136 C-51.41480469 137.14855469 -50.95460938 138.29710937 -50.48046875 139.48046875 C-48.42384425 144.36970009 -46.25980483 149.2015208 -44 154 C-55.41709426 146.64808324 -66.42601753 138.65389885 -76 129 C-71.16687929 151.97153842 -62.94822305 172.65927242 -48 191 C-46.61160919 188.79159824 -46.61160919 188.79159824 -48.07421875 185.359375 C-48.60555791 183.82068427 -49.14376221 182.28435318 -49.6875 180.75 C-52.39647045 172.89509269 -54.80881405 165.01716272 -57 157 C-53.30196233 160.5979103 -49.92544172 164.34963335 -46.625 168.3125 C-45.65670035 169.4652222 -44.68795092 170.61756673 -43.71875 171.76953125 C-43.25339844 172.32334473 -42.78804687 172.8771582 -42.30859375 173.44775391 C-40.59629839 175.47886844 -38.86704659 177.49435425 -37.125 179.5 C-36.63257813 180.0671875 -36.14015625 180.634375 -35.6328125 181.21875 C-33.49348725 183.55255936 -31.24978321 185.77309594 -29 188 C-29.02320313 186.98421875 -29.04640625 185.9684375 -29.0703125 184.921875 C-29.20335849 176.3903012 -28.77978278 168.39040454 -27 160 C-26.55269531 160.80824219 -26.10539062 161.61648437 -25.64453125 162.44921875 C-21.22880673 170.43361209 -21.22880673 170.43361209 -15 177 C-13.5459375 178.2065625 -13.5459375 178.2065625 -12.0625 179.4375 C-9.10484429 181.32737095 -9.10484429 181.32737095 -5.9375 180.5 C0.36188669 177.2832919 3.14999992 173.50162176 6.5703125 167.4375 C7.91092998 165.15185708 9.36880126 163.08484573 11 161 C12.32374613 169.75799894 13.26275688 178.1262658 13 187 C17.8236406 183.07990007 22.01850339 178.95499212 26 174.1875 C26.51401367 173.58019043 27.02802734 172.97288086 27.55761719 172.34716797 C31.50003252 167.66415416 35.32259093 162.89457968 39 158 C38.49752444 164.15532564 37.03376813 169.90093933 35.28417969 175.80688477 C34.11553496 179.88585806 34.11553496 179.88585806 35 184 C46.64999788 169.24863749 57.83197506 149.07774064 59 130 C58.01 130.845625 57.02 131.69125 56 132.5625 C55.02353516 133.39394531 55.02353516 133.39394531 54.02734375 134.2421875 C52.77194938 135.33067973 51.53148409 136.43699163 50.31640625 137.5703125 C43.4926485 143.86215149 35.68778705 148.84059923 28 154 C28.2673999 153.39526855 28.5347998 152.79053711 28.81030273 152.16748047 C30.02644682 149.40637612 31.23204194 146.64078542 32.4375 143.875 C32.85837891 142.92367187 33.27925781 141.97234375 33.71289062 140.9921875 C35.73230067 136.33946677 37.52695587 132.10887659 38 127 C35.25727542 129.64139147 32.89453306 132.33071862 30.65234375 135.40625 C30.04712891 136.23253906 29.44191406 137.05882812 28.81835938 137.91015625 C27.88733398 139.19212891 27.88733398 139.19212891 26.9375 140.5 C25.69667987 142.19796438 24.45579669 143.89588269 23.21484375 145.59375 C22.66948975 146.34333984 22.12413574 147.09292969 21.56225586 147.86523438 C20.05724876 149.92177166 18.52904582 151.96127224 17 154 C17 143.77 17 133.54 17 123 C13.46142115 126.50265682 13.46142115 126.50265682 10.7734375 130.36328125 C10.38591309 130.9960498 9.99838867 131.62881836 9.59912109 132.28076172 C9.19516113 132.95123535 8.79120117 133.62170898 8.375 134.3125 C4.43088603 140.76067119 0.33479845 147.07583011 -3.95166016 153.30200195 C-6.24904568 156.37263026 -6.24904568 156.37263026 -7 160 C-7.66 160 -8.32 160 -9 160 C-9.35771484 158.97132813 -9.35771484 158.97132813 -9.72265625 157.921875 C-11.25435046 154.41818304 -13.28104884 151.38737599 -15.4375 148.25 C-16.33197545 146.93183442 -17.22515181 145.6127866 -18.1171875 144.29296875 C-18.81859863 143.255354 -18.81859863 143.255354 -19.53417969 142.19677734 C-22.59713197 137.60643014 -25.55190023 132.9441383 -28.50756836 128.28417969 C-29.64612115 126.50613733 -30.81946441 124.75044932 -32 123 C-32.33 123 -32.66 123 -33 123 Z M33 184 C34 186 34 186 34 186 Z "
Fill="{Binding ElementName=_this, Path=Foreground, Mode=OneWay}"/>
<Path Data="M0 0 C1.69962891 0.81404297 1.69962891 0.81404297 3.43359375 1.64453125 C4.07280762 1.95092529 4.71202148 2.25731934 5.37060547 2.57299805 C6.05268066 2.89953369 6.73475586 3.22606934 7.4375 3.5625 C8.51088623 4.07840698 8.51088623 4.07840698 9.60595703 4.60473633 C33.07648031 15.71332157 58.20660998 23.45166112 83 31 C83.83915356 34.42410649 84.05926568 36.89731576 83.2578125 40.328125 C83.07863281 41.12863281 82.89945313 41.92914063 82.71484375 42.75390625 C82.42287109 43.98947266 82.42287109 43.98947266 82.125 45.25 C79.95981225 54.61257049 78.80315353 63.70030735 78.625 73.3125 C78.58761719 74.09689453 78.55023438 74.88128906 78.51171875 75.68945312 C78.47783701 77.90494256 78.49928258 79.84021033 79 82 C80.62284471 83.38633711 82.2883043 84.72498887 84 86 C84.41015625 88.828125 84.41015625 88.828125 84.0625 92.25 C83.99893311 92.89130859 83.93536621 93.53261719 83.86987305 94.19335938 C83.62182231 96.46940323 83.31718748 98.73256264 83 101 C82.87947266 101.88365234 82.75894531 102.76730469 82.63476562 103.67773438 C77.61859906 139.23134419 67.36610237 175.93719364 44 204 C43.3800415 204.75337646 43.3800415 204.75337646 42.74755859 205.52197266 C30.9225617 219.730647 14.81960314 231.0531445 -4 233 C-20.71983429 233.82228693 -36.61601945 226.64306773 -49.0625 215.75 C-58.28148344 207.09279837 -65.58587028 197.85423576 -72 187 C-72.34417969 186.4215332 -72.68835938 185.84306641 -73.04296875 185.24707031 C-87.77913242 160.10807846 -95.27522291 130.68338831 -99 102 C-99.16701416 100.75428223 -99.16701416 100.75428223 -99.33740234 99.48339844 C-99.61844344 97.26166082 -99.85331009 95.04202409 -100.0625 92.8125 C-100.17722656 91.60207031 -100.29195313 90.39164062 -100.41015625 89.14453125 C-99.86780385 84.98649615 -97.93270119 83.87830796 -95 81 C-92.40922021 67.77338739 -96.39701691 51.03100756 -99.61962891 38.10107422 C-100.05417978 35.70072454 -100.06105541 33.43425251 -100 31 C-99.08114014 30.71914551 -98.16228027 30.43829102 -97.21557617 30.14892578 C-71.7487105 22.34448968 -46.49579684 14.27767304 -22.3046875 3.0078125 C-21.59924805 2.68039063 -20.89380859 2.35296875 -20.16699219 2.015625 C-18.63608221 1.29811875 -17.11120546 0.56767189 -15.59082031 -0.171875 C-14.80030273 -0.54570313 -14.00978516 -0.91953125 -13.1953125 -1.3046875 C-12.48648926 -1.64741699 -11.77766602 -1.99014648 -11.04736328 -2.34326172 C-6.94255944 -3.6599708 -3.71205826 -1.77858331 0 0 Z M-18.25 7.9375 C-36.8876525 16.93406904 -56.29380201 23.57522439 -75.92749023 30.01489258 C-76.6885054 30.26463837 -77.44952057 30.51438416 -78.2335968 30.771698 C-79.66586004 31.24080233 -81.09867796 31.70821789 -82.53215027 32.1736145 C-86.07615671 33.33160554 -89.55719317 34.56791505 -93 36 C-92.87882812 36.77601562 -92.75765625 37.55203125 -92.6328125 38.3515625 C-92.08232188 41.9001097 -91.54078315 45.44996096 -91 49 C-90.82082031 50.15113281 -90.64164063 51.30226562 -90.45703125 52.48828125 C-89.22656093 60.65749395 -88.47623288 68.75365171 -88 77 C-86.35 77.66 -84.7 78.32 -83 79 C-87.69798658 83.83221477 -87.69798658 83.83221477 -90.8125 85.5625 C-93.92329278 89.02881196 -93.62266402 91.47263091 -93.41796875 96.03125 C-89.14054852 136.64675427 -75.97593871 180.75667079 -46 210 C-45.34 210 -44.68 210 -44 210 C-44 210.66 -44 211.32 -44 212 C-41.79910834 213.54945208 -39.62495006 214.94689313 -37.3125 216.3125 C-36.29615479 216.91481445 -36.29615479 216.91481445 -35.25927734 217.52929688 C-23.77347658 224.16923213 -12.6113988 228.76241782 0.62890625 225.6640625 C4.02864686 224.71191109 6.89706812 223.71651551 10 222 C11.04289755 219.93109581 11.04289755 219.93109581 11 218 C11.66 218.33 12.32 218.66 13 219 C12.67 219.66 12.34 220.32 12 221 C15.79828441 219.60316715 19.0830434 217.85189245 22.5 215.6875 C23.87671875 214.82705078 23.87671875 214.82705078 25.28125 213.94921875 C56.09784766 191.85513509 68.91973834 146.71273279 74.97265625 111.484375 C75.25808088 109.71962707 75.53825044 107.95401908 75.8125 106.1875 C75.93657227 105.39400146 76.06064453 104.60050293 76.18847656 103.78295898 C76.51328423 101.5239169 76.77724219 99.27129002 77 97 C77.1225415 95.80636841 77.1225415 95.80636841 77.24755859 94.58862305 C77.49173418 90.41664748 77.56537939 88.67946487 74.8125 85.37109375 C73.884375 84.73300781 72.95625 84.09492187 72 83.4375 C70.6078125 82.44556641 70.6078125 82.44556641 69.1875 81.43359375 C68.465625 80.96050781 67.74375 80.48742187 67 80 C70 78 70 78 72 77 C72.42083851 74.85454032 72.42083851 74.85454032 72.52734375 72.25 C72.63272461 70.74566406 72.63272461 70.74566406 72.74023438 69.2109375 C72.86790482 67.13281657 72.9955131 65.05469182 73.12304688 62.9765625 C73.76127375 53.84589338 75.29605888 44.98013941 77 36 C76.08226807 35.70456299 75.16453613 35.40912598 74.21899414 35.10473633 C57.04373741 29.55726864 39.97761385 23.82115187 23.1875 17.1875 C22.52605988 16.92772369 21.86461975 16.66794739 21.18313599 16.40029907 C13.25224989 13.27492982 5.477654 9.92873888 -2.17622375 6.17411804 C-8.81967145 2.96916877 -11.98285513 4.8201538 -18.25 7.9375 Z "
Fill="{Binding ElementName=_this, Path=Foreground, Mode=OneWay}"/>
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.2" ScaleY="1.05"></ScaleTransform>
<TranslateTransform X="176" Y="50"></TranslateTransform>
</TransformGroup>
</Grid.RenderTransform>
</Grid>
</Viewbox>
</UserControl>
10 changes: 9 additions & 1 deletion Daybreak/Controls/Templates/BuildEntryTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@
mc:Ignorable="d"
xmlns:controls="clr-namespace:Daybreak.Controls"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<TextBlock
FontSize="12"
Text="GWToolboxpp build"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Visibility="{Binding IsToolboxBuild, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<buttons:HighlightButton
FontSize="16"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
HighlightColor="{StaticResource MahApps.Brushes.Accent}"
Title="{Binding Name}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
VerticalContentAlignment="Bottom"
Clicked="HighlightButton_Clicked"
Height="40"
ToolTip="Open build template"/>
Expand Down
38 changes: 38 additions & 0 deletions Daybreak/Models/Guildwars/BuildEntryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,44 @@ public abstract class BuildEntryBase : INotifyPropertyChanged, IBuildEntry

public Dictionary<string, string>? Metadata { get; set; }
public string? PreviousName { get; set; }
public int? ToolboxBuildId
{
get
{
if (this.Metadata?.TryGetValue(nameof(this.ToolboxBuildId), out var toolBoxBuildString) is true &&
int.TryParse(toolBoxBuildString, out var toolboxBuild))
{
return toolboxBuild;
}

return default;
}
set
{
this.Metadata ??= [];
this.Metadata[nameof(this.ToolboxBuildId)] = value.HasValue ? value.Value.ToString() : string.Empty;
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.ToolboxBuildId)));
}
}
public bool IsToolboxBuild
{
get
{
if (this.Metadata?.TryGetValue(nameof(this.IsToolboxBuild), out var toolBoxBuildString) is true &&
bool.TryParse(toolBoxBuildString, out var toolboxBuild))
{
return toolboxBuild;
}

return false;
}
set
{
this.Metadata ??= [];
this.Metadata[nameof(this.IsToolboxBuild)] = value.ToString();
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.IsToolboxBuild)));
}
}
public DateTimeOffset CreationTime
{
get
Expand Down
12 changes: 11 additions & 1 deletion Daybreak/Services/Toolbox/IToolboxService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Daybreak.Models.Progress;
using Daybreak.Models.Builds;
using Daybreak.Models.Progress;
using Daybreak.Services.Mods;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -13,4 +15,12 @@ public interface IToolboxService : IModService
Task NotifyUserIfUpdateAvailable(CancellationToken cancellationToken);

Task<bool> SetupToolbox(ToolboxInstallationStatus toolboxInstallationStatus);

IAsyncEnumerable<TeamBuildEntry> GetToolboxBuilds(CancellationToken cancellationToken);

Task<bool> SaveToolboxBuild(TeamBuildEntry teamBuildEntry, CancellationToken cancellationToken);

Task<bool> DeleteToolboxBuild(TeamBuildEntry teamBuildEntry, CancellationToken cancellationToken);

Task<bool> ExportBuildToToolbox(TeamBuildEntry teamBuildEntry, CancellationToken cancellationToken);
}
Loading

0 comments on commit ce810da

Please sign in to comment.