Skip to content

Commit

Permalink
fixed issue where richtext symbols didn't scale with the font size in…
Browse files Browse the repository at this point in the history
… deck editor
  • Loading branch information
brine authored and kellyelton committed Apr 23, 2024
1 parent 821ed29 commit b8721de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion octgnFX/Octgn.JodsEngine/DeckBuilder/SearchControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void GenerateColumns(DataNew.Entities.Game game)
Path = new PropertyPath(prop.Name),
Mode = BindingMode.OneTime,
Converter = new RichTextConverter(),
ConverterParameter = game
ConverterParameter = game.DeckEditorFont
};

var factory = new FrameworkElementFactory(typeof(RichTextBlock));
Expand Down
4 changes: 2 additions & 2 deletions octgnFX/Octgn.JodsEngine/Play/Gui/CardControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private static void RestoreCardHandler(object sender, RoutedEventArgs e)
// detaches and then re-attaches the control, e.g. when we change Z-order
// by calling Move on an ObservableCollection.
/* if (_card == null)
{
{
_card = DataContext as Card;
if (_card != null) _card.PropertyChanged += PropertyChangeHandler;
}*/
Expand Down Expand Up @@ -1205,7 +1205,7 @@ private void Card_ToolTipOpening(object sender, ToolTipEventArgs e)
tooltipTextBlock.Inlines.Add(new Run(property.Key.Name + ": ") { FontWeight = FontWeights.Bold });
if (property.Key.Type == PropertyType.RichText && property.Value is RichTextPropertyValue richText)
{
tooltipTextBlock.Inlines.Add(RichTextConverter.ConvertToSpan(richText, Program.GameEngine.Definition));
tooltipTextBlock.Inlines.Add(RichTextConverter.ConvertToSpan(richText, Program.GameEngine.Definition.NoteFont));
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions octgnFX/Octgn.JodsEngine/Utils/Converters/RichTextConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ namespace Octgn.Utils.Converters
public class RichTextConverter : IValueConverter
{
internal static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
internal static Game Game;
internal static Font Font;

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Game = parameter as Game;
Font = parameter as Font;
var propval = value as RichTextPropertyValue;
if (propval == null) return null;
if (!(propval.Value is IRichText)) throw new InvalidOperationException($"{nameof(RichTextPropertyValue)}.{nameof(value)} is the wrong type");
Expand All @@ -34,9 +34,9 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
return span.Inlines.ToList();
}

public static Span ConvertToSpan(RichTextPropertyValue value, Game game)
public static Span ConvertToSpan(RichTextPropertyValue value, Font font)
{
Game = game;
Font = font;
Span span = new Span();
InternalProcess(span, value.Value);
return span;
Expand Down Expand Up @@ -90,7 +90,7 @@ private static void InternalProcess(Span span, IRichText node)
var image = new Image
{
Margin = new Thickness(0, 0, 0, -2),
Height = span.FontSize + 2,
Height = Font.Size + 2,
Stretch = Stretch.Uniform,
Source = new BitmapImage(new Uri(symbol.Source)),
ToolTip = symbol.Name
Expand Down

0 comments on commit b8721de

Please sign in to comment.