Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions AnnoMapEditor/MapTemplates/Models/MapElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ public Vector2 Position
}
private Vector2 _position = Vector2.Zero;

public bool IsLocked
{
get => _isLocked;
set => SetProperty(ref _isLocked, value, new[] { nameof(IsUnlocked) });
}
private bool _isLocked;

public bool IsUnlocked
{
get => !_isLocked;
set => SetProperty(ref _isLocked, !value, new[] { nameof(IsLocked) });
}


public MapElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,58 @@
HorizontalAlignment="Left"
Text="Fixed Island"
Margin="0"/>

<!-- Label -->
<TextBlock Text="Label"

<!-- lockable properties -->
<StackPanel IsEnabled="{Binding FixedIsland.IsUnlocked}">

<!-- Label -->
<TextBlock Text="Label"
Style="{StaticResource SubHeaderLabelStyle}"/>
<TextBox Margin="2"
Text="{Binding FixedIsland.Label, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Margin="2"
Text="{Binding FixedIsland.Label, UpdateSourceTrigger=PropertyChanged}" />

<!-- Rotation -->
<TextBlock Text="Rotation"
<!-- Rotation -->
<TextBlock Text="Rotation"
Style="{StaticResource SubHeaderLabelStyle}"/>
<local:FancyToggle Label="Randomize"
<local:FancyToggle Label="Randomize"
OnText="Yes" OffText="No"
IsEnabled="{Binding IsContinentalIsland, Converter={StaticResource BooleanNot}}"
IsChecked="{Binding FixedIsland.RandomizeRotation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Click="OnRotateCounterClockwise"
ToolTip="rotate counter clockwise"
Content="⤹"
Visibility="{Binding FixedIsland.RandomizeRotation, Converter={StaticResource VisibleOnFalse}}"/>
<Button Grid.Column="1"
<Button Grid.Column="1"
Click="OnRotateClockwise"
ToolTip="rotate clockwise"
Content="⤸"
Visibility="{Binding FixedIsland.RandomizeRotation, Converter={StaticResource VisibleOnFalse}}"/>
</Grid>
</Grid>

<!-- IslandType -->
<TextBlock Text="Island Type"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="4"
ItemsSource="{Binding IslandTypeItems}"
SelectedItem="{Binding FixedIsland.IslandType}"/>
<!-- IslandType -->
<TextBlock Text="Island Type"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="4"
ItemsSource="{Binding IslandTypeItems}" />

<!-- Fertilities -->
<fertilities:FertilityControl DataContext="{Binding FertilitiesViewModel}" />
<!-- Slots -->
<slots:SlotsControl DataContext="{Binding SlotsViewModel}" />
<!-- Fertilities -->
<fertilities:FertilityControl DataContext="{Binding FertilitiesViewModel}" />

<!-- Slots -->
<slots:SlotsControl DataContext="{Binding SlotsViewModel}" />

</StackPanel>

<!-- Locking -->
<local:FancyToggle Label="Lock Island"
OnText="Locked" OffText="Unlocked"
Margin="0,32"
IsChecked="{Binding FixedIsland.IsLocked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ResourceDictionary Source="../../Resources/Styles.xaml" />
<ResourceDictionary>
<converters:ObjectToVisibility x:Key="CollapsedOnNull" />
<converters:BooleaNotConverter x:Key="BooleanNot" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand All @@ -31,25 +32,35 @@
Text="Random Island"
Margin="0"/>

<!-- Label -->
<TextBlock Text="Label"
Style="{StaticResource SubHeaderLabelStyle}"/>
<TextBox Margin="2"
Text="{Binding RandomIsland.Label, UpdateSourceTrigger=PropertyChanged}"/>

<!-- IslandType -->
<TextBlock Text="Island Type"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="2"
ItemsSource="{Binding IslandTypeItems}"
SelectedItem="{Binding RandomIsland.IslandType}"/>

<!-- IslandSize -->
<TextBlock Text="Island Size"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="2"
ItemsSource="{Binding IslandSizeItems}"
SelectedItem="{Binding RandomIsland.IslandSize}"/>

<!-- lockable properties -->
<StackPanel IsEnabled="{Binding RandomIsland.IsUnlocked}">

<!-- Label -->
<TextBlock Text="Label"
Style="{StaticResource SubHeaderLabelStyle}"/>
<TextBox Margin="2"
Text="{Binding RandomIsland.Label, UpdateSourceTrigger=PropertyChanged}" />

<!-- IslandType -->
<TextBlock Text="Island Type"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="2"
ItemsSource="{Binding IslandTypeItems}"
SelectedItem="{Binding RandomIsland.IslandType}" />

<!-- IslandSize -->
<TextBlock Text="Island Size"
Style="{StaticResource SubHeaderLabelStyle}"/>
<ComboBox Margin="2"
ItemsSource="{Binding IslandSizeItems}"
SelectedItem="{Binding RandomIsland.IslandSize}" />

</StackPanel>

<!-- Locking -->
<local:FancyToggle Label="Lock Island"
OnText="Locked" OffText="Unlocked"
Margin="0,32"
IsChecked="{Binding RandomIsland.IsLocked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</UserControl>
24 changes: 24 additions & 0 deletions AnnoMapEditor/UI/Controls/MapTemplates/IslandControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@
Fill="Gold"
Points="0,0 40,0 0,40"
Visibility="{Binding RandomizeRotation, Converter={StaticResource VisibleOnFalse}, FallbackValue=Hidden}"/>

</Canvas>

<!-- lock icon-->
<Canvas RenderTransformOrigin="0.5,0.5"
Width="{Binding SizeInTiles}"
Height="{Binding SizeInTiles}"
Visibility="{Binding Island.IsLocked, Converter={StaticResource VisibleOnTrue}}">
<Canvas.RenderTransform>
<RotateTransform Angle="180"/>
</Canvas.RenderTransform>

<Image Source="{Binding LockIconOutline}"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="-45"/>
</Image.RenderTransform>
</Image>
<Image Source="{Binding LockIcon}"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="-45"/>
</Image.RenderTransform>
</Image>
</Canvas>

<!-- Label -->
Expand Down
4 changes: 3 additions & 1 deletion AnnoMapEditor/UI/Controls/MapTemplates/IslandControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AnnoMapEditor.UI.Controls.MapTemplates
using System.Windows.Media;

namespace AnnoMapEditor.UI.Controls.MapTemplates
{
/// <summary>
/// Interaction logic for IslandControl.xaml
Expand Down
5 changes: 5 additions & 0 deletions AnnoMapEditor/UI/Controls/MapTemplates/IslandViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace AnnoMapEditor.UI.Controls.MapTemplates
{
public abstract class IslandViewModel : MapElementViewModel
{
public static ImageSource LockIcon { get; } = Settings.Instance.DataArchive.TryLoadIcon("data/ui/2kimages/main/icons/icon_lock_0.dds")!;

public static ImageSource LockIconOutline { get; } = Settings.Instance.DataArchive.TryLoadIcon("data/ui/2kimages/main/icons/icon_lock_outline_0.dds")!;


static readonly Dictionary<string, SolidColorBrush> BorderBrushes = new()
{
["Normal"] = new(Color.FromArgb(255, 8, 172, 137)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public MapElementViewModel(MapElement element)

public override void OnDragged(Vector2 newPosition)
{
Element.Position = newPosition;
if (!Element.IsLocked)
Element.Position = newPosition;
}
}
}