add a "graphics as text" option for Overworld Objects

useful for dealing with dynamic sprites, like the old man or the pokemon icon feature
This commit is contained in:
haven1433
2023-12-13 10:03:10 -06:00
parent e7eec2f348
commit aab2f69f67
2 changed files with 48 additions and 7 deletions

View File

@@ -444,6 +444,31 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
}
}
private string graphicsText;
public string GraphicsText {
get {
if (graphicsText != null) return graphicsText;
graphicsText = Graphics.ToString();
return graphicsText;
}
set {
graphicsText = value;
if (!graphicsText.TryParseInt(out var result)) return;
Graphics = result;
}
}
private bool showGraphicsAsText;
public bool ShowGraphicsAsText {
get => showGraphicsAsText;
set {
Set(ref showGraphicsAsText, value, old => {
graphicsText = null;
NotifyPropertyChanged(nameof(GraphicsText));
});
}
}
/// <summary>
/// FireRed Only.
/// Kind is either 0 or 255.
@@ -1188,6 +1213,7 @@ show:
this.berries = berries;
for (int i = 0; i < sprites.Count; i++) Options.Add(VisualComboOption.CreateFromSprite(i.ToString(), sprites[i].PixelData, sprites[i].PixelWidth, i, 2, true));
DefaultOW = defaultSprite;
ShowGraphicsAsText = Graphics >= Options.Count;
objectEvent.Model.TryGetList("FacingOptions", out var list);
FacingOptions.Update(ComboOption.Convert(list), MoveType);
FacingOptions.Bind(nameof(FacingOptions.SelectedIndex), (sender, e) => MoveType = FacingOptions.ModelValue);

View File

@@ -307,15 +307,30 @@
<TextBlock Text="ID:"/>
</local:AngleBorder>
<local:AngleTextBox Direction="Out" TextBinding="{Binding ObjectID, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox IsChecked="{Binding ShowGraphicsAsText}" Content="Dynamic Graphics" />
</StackPanel>
<local:AngleComboBox Grid.Row="0" Grid.Column="1" Direction="Right" SelectedIndex="{Binding Graphics}" ItemsSource="{Binding Options}" Margin="0,2,2,2">
<local:AngleComboBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="220" />
</ItemsPanelTemplate>
</local:AngleComboBox.ItemsPanel>
</local:AngleComboBox>
<Decorator Grid.Row="0" Grid.Column="1">
<Decorator.Style>
<Style TargetType="Decorator">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowGraphicsAsText}" Value="True">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</Decorator.Style>
<local:AngleComboBox Direction="Right" SelectedIndex="{Binding Graphics}" ItemsSource="{Binding Options}" Margin="0,2,2,2">
<local:AngleComboBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="220" />
</ItemsPanelTemplate>
</local:AngleComboBox.ItemsPanel>
</local:AngleComboBox>
</Decorator>
<local:AngleTextBox Grid.Row="0" Grid.Column="1" Direction="Right" VerticalAlignment="Bottom" TextBinding="{Binding GraphicsText, UpdateSourceTrigger=PropertyChanged}" Margin="0,2,2,2"
Visibility="{Binding ShowGraphicsAsText, Converter={StaticResource BoolToVisibility}}" />
<CheckBox Grid.Row="1" Grid.Column="1" Visibility="{Binding HasKind, Converter={StaticResource BoolToVisibility}}" IsChecked="{Binding Kind}" Content="Clone">
<CheckBox.ToolTip>