Skip to content

Commit

Permalink
Viewer: Fixed Markdown formatting and added Copy Details context
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthysell committed Feb 5, 2024
1 parent fa199f0 commit 8aac36e
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 68 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Mzinga Changelog #

## next ##

Viewer: Fix formatting of Markdown text blocks
Viewer: Add "Copy Details" to context-menu for dialogs with expandable Details

## v0.15.0 ##

* Added native ARM64 builds for Windows, MacOS, and Linux
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![CI Build](https://github.com/jonthysell/Mzinga/actions/workflows/ci.yml/badge.svg)](https://github.com/jonthysell/Mzinga/actions/workflows/ci.yml)

Mzinga is a collection of open-source software to play the board game [Hive](https://gen42.com/games/hive), with the primary goal of building a community of developers who create Hive-playing AIs.
Mzinga is a collection of open-source software to play the abstract board game [Hive](https://gen42.com/games/hive), with the primary goal of building a community of developers who create Hive-playing AIs.

To that end, Mzinga proposes a [Universal Hive Protocol](https://github.com/jonthysell/Mzinga/wiki/UniversalHiveProtocol) to support interoperability for Hive-playing software.

Expand Down
8 changes: 5 additions & 3 deletions src/Mzinga.Viewer/Resources/MarkdownStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<Setter Property="Margin"
Value="10,0" />
</Style>
<Style Selector="md|MarkdownScrollViewer ScrollViewer">
<Setter Property="VerticalScrollBarVisibility"
Value="Disabled" />
<Style Selector="md|MarkdownScrollViewer ScrollViewer /template/ ScrollContentPresenter">
<Setter Property="Padding"
Value="0" />
<Setter Property="Margin"
Value="0,0,30,0" />
</Style>
</Styles>
2 changes: 1 addition & 1 deletion src/Mzinga.Viewer/ViewModels/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static string GetAboutText()
{
return string.Join(Environment.NewLine + Environment.NewLine,
"## Mzinga ##",
"Mzinga is a collection of open-source software to play the board game [Hive](https://gen42.com/games/hive), with the primary goal of building a community of developers who create Hive-playing AIs.",
"Mzinga is a collection of open-source software to play the abstract board game [Hive](https://gen42.com/games/hive), with the primary goal of building a community of developers who create Hive-playing AIs.",
"To that end, Mzinga proposes a [Universal Hive Protocol](https://github.com/jonthysell/Mzinga/wiki/UniversalHiveProtocol) to support interoperability for Hive-playing software.",
"For more information on Mzinga and its projects, please check out the [Mzinga Wiki](https://github.com/jonthysell/Mzinga/wiki).",
"## MzingaViewer ##",
Expand Down
9 changes: 0 additions & 9 deletions src/Mzinga.Viewer/ViewModels/ConfirmationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ public enum ConfirmationResult

public class ConfirmationViewModel : InformationViewModelBase
{
public static AppViewModel AppVM
{
get
{
return AppViewModel.Instance;
}

}

#region Properties

public ConfirmationResult Result { get; private set; } = ConfirmationResult.Cancel;
Expand Down
10 changes: 1 addition & 9 deletions src/Mzinga.Viewer/ViewModels/InformationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Mzinga.Core;

namespace Mzinga.Viewer.ViewModels
{
public class InformationViewModel : InformationViewModelBase
{
public static AppViewModel AppVM
{
get
{
return AppViewModel.Instance;
}

}

#region Commands

public RelayCommand Accept
Expand Down
36 changes: 36 additions & 0 deletions src/Mzinga.Viewer/ViewModels/InformationViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
using System;

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace Mzinga.Viewer.ViewModels
{
public abstract class InformationViewModelBase : ObservableObject
{
public static AppViewModel AppVM
{
get
{
return AppViewModel.Instance;
}

}

public string Title
{
get
Expand Down Expand Up @@ -47,6 +57,32 @@ protected set

public bool ShowDetails => !string.IsNullOrWhiteSpace(Details);

#region Commands

public RelayCommand CopyDetailsToClipboard
{
get
{
return _copyDetailsToClipboard ??= new RelayCommand(() =>
{
try
{
AppVM.TextToClipboard(Details);
}
catch (Exception ex)
{
ExceptionUtils.HandleException(ex);
}
}, () =>
{
return ShowDetails;
});
}
}
private RelayCommand _copyDetailsToClipboard = null;

#endregion

public event EventHandler RequestClose;

public InformationViewModelBase(string message, string title, string details = null)
Expand Down
26 changes: 11 additions & 15 deletions src/Mzinga.Viewer/Views/AboutWindow.axaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Window CanResize="False"
MinHeight="100"
MinWidth="100"
SizeToContent="WidthAndHeight"
SizeToContent="Height"
Title="{Binding Title}"
Width="600"
WindowStartupLocation="CenterOwner"
d:DesignHeight="640"
d:DesignWidth="480"
Expand Down Expand Up @@ -39,20 +40,15 @@
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ScrollViewer Margin="0,5"
Padding="10,0,30,0"
Width="500">
<md:MarkdownScrollViewer Markdown="{Binding Body, Mode=OneWay}"
Width="460"
x:DataType="vm:ObservableAboutTabItem">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
</ScrollViewer>
<md:MarkdownScrollViewer Markdown="{Binding Body, Mode=OneWay}"
x:DataType="vm:ObservableAboutTabItem">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
Expand Down
32 changes: 17 additions & 15 deletions src/Mzinga.Viewer/Views/ConfirmationWindow.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Window CanResize="False"
MinHeight="100"
MinWidth="480"
SizeToContent="WidthAndHeight"
SizeToContent="Height"
Title="{Binding Title}"
Width="480"
WindowStartupLocation="CenterOwner"
Expand Down Expand Up @@ -38,20 +38,22 @@
IsVisible="{Binding ShowDetails}"
Margin="5"
Padding="0">
<Grid Height="100">
<ScrollViewer Margin="0,5"
Padding="10,0,30,0"
Width="440">
<md:MarkdownScrollViewer Markdown="{Binding Details, Mode=OneWay}"
Width="400">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding (vm:ConfirmationViewModel)$parent[Window].DataContext.AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
</ScrollViewer>
<Grid Height="150"
Margin="5">
<md:MarkdownScrollViewer Markdown="{Binding Details, Mode=OneWay}">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding (vm:ConfirmationViewModel)$parent[Window].DataContext.AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding CopyDetailsToClipboard}"
Header="Copy Details" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
</Expander>
</StackPanel>
Expand Down
30 changes: 16 additions & 14 deletions src/Mzinga.Viewer/Views/InformationWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@
IsVisible="{Binding ShowDetails}"
Margin="5"
Padding="0">
<Grid Height="100">
<ScrollViewer Margin="0,5"
Padding="10,0,30,0"
Width="440">
<md:MarkdownScrollViewer Markdown="{Binding Details, Mode=OneWay}"
Width="400">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding (vm:ConfirmationViewModel)$parent[Window].DataContext.AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
</ScrollViewer>
<Grid Height="150"
Margin="5">
<md:MarkdownScrollViewer Markdown="{Binding Details, Mode=OneWay}">
<md:MarkdownScrollViewer.Styles>
<StyleInclude Source="avares://MzingaViewer/Resources/MarkdownStyles.axaml" />
</md:MarkdownScrollViewer.Styles>
<md:MarkdownScrollViewer.Engine>
<md:Markdown HyperlinkCommand="{Binding (vm:ConfirmationViewModel)$parent[Window].DataContext.AppVM.LaunchURL}" />
</md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding CopyDetailsToClipboard}"
Header="Copy Details" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
</Expander>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/Mzinga.Viewer/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding CopyHistoryToClipboard}"
Header="Copy History to Clipboard" />
Header="Copy History" />
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
Expand Down

0 comments on commit 8aac36e

Please sign in to comment.