Skip to content

Commit 08371e7

Browse files
Added open lua button
1 parent 38a40aa commit 08371e7

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

MSURandomizer/Services/MsuMonitorWindowService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Linq;
33
using AutoMapper;
4+
using AvaloniaControls;
45
using AvaloniaControls.ControlServices;
56
using AvaloniaControls.Services;
67
using Microsoft.Extensions.Logging;
@@ -24,7 +25,7 @@ public class MsuMonitorWindowService(
2425
IRomLauncherService romLauncherService,
2526
ILogger<MsuMonitorWindowService> logger) : ControlService
2627
{
27-
private MsuMonitorWindowViewModel _model { get; set; } = new();
28+
private readonly MsuMonitorWindowViewModel _model = new();
2829

2930
public MsuMonitorWindowViewModel InitializeModel()
3031
{
@@ -138,6 +139,11 @@ public void StopMonitor()
138139
msuMonitorService.MsuShuffled -= MsuMonitorServiceOnMsuShuffled;
139140
}
140141

142+
public void OpenLuaFolder()
143+
{
144+
CrossPlatformTools.OpenDirectory(msuAppSettingsService.MsuAppSettings.DefaultLuaDirectory);
145+
}
146+
141147
private bool VerifyMsuTypeCompatibility(MsuType msuType) => msuGameService.IsMsuTypeCompatible(msuType);
142148

143149
private void MsuMonitorServiceOnMsuShuffled(object? sender, EventArgs e)

MSURandomizer/ViewModels/MsuMonitorWindowViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace MSURandomizer.ViewModels;
88
[MapsTo(typeof(SnesConnectorSettings))]
99
public class MsuMonitorWindowViewModel : ViewModelBase
1010
{
11-
[Reactive] public SnesConnectorType ConnectorType { get; set; }
11+
[Reactive]
12+
[ReactiveLinkedProperties(nameof(IsLuaFolderButtonVisible))]
13+
public SnesConnectorType ConnectorType { get; set; }
1214

1315
public string Usb2SnesAddress { get; set; } = "";
1416

@@ -28,9 +30,14 @@ public class MsuMonitorWindowViewModel : ViewModelBase
2830
[ReactiveLinkedProperties(nameof(LastUpdateTimeText))]
2931
public DateTime LastUpdateTime { get; set; } = DateTime.Now;
3032

33+
public bool IsLuaFolderButtonVisible => ConnectorType == SnesConnectorType.Lua;
34+
3135
public bool HasErrorMessage => !string.IsNullOrEmpty(ErrorMessage);
3236

3337
public string LastUpdateTimeText => $"Last updated {DateTime.Now.ToShortTimeString()}";
3438

3539
public SnesConnectorType CurrentConnectorType { get; set; }
40+
41+
public Func<Enum, bool> FilterConnectorTypes => @enum =>
42+
(SnesConnectorType)@enum is SnesConnectorType.None or SnesConnectorType.Sni or SnesConnectorType.Usb2Snes or SnesConnectorType.Lua;
3643
}

MSURandomizer/Views/MsuMonitorWindow.axaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:controls="clr-namespace:AvaloniaControls.Controls;assembly=AvaloniaControls"
66
xmlns:viewModels="clr-namespace:MSURandomizer.ViewModels"
77
xmlns:views="clr-namespace:MSURandomizer.Views"
8+
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
89
mc:Ignorable="d"
910
d:DesignWidth="800" d:DesignHeight="450"
1011
x:Class="MSURandomizer.Views.MsuMonitorWindow"
@@ -20,9 +21,13 @@
2021
<controls:EnumComboBox
2122
EnumType="{Binding ConnectorType, Converter={StaticResource TypeConverter}}"
2223
Value="{Binding ConnectorType, Mode=TwoWay}"
24+
Filter="{Binding FilterConnectorTypes}"
2325
MinWidth="150"
2426
ValueChanged="SnesConnectoTypeEnumComboBox_OnValueChanged"
2527
/>
28+
<Button Name="FolderButton" Height="24.5" Margin="5 0 0 0" Click="FolderButton_OnClick" ToolTip.Tip="Open Lua Script Folder" IsVisible="{Binding IsLuaFolderButtonVisible}">
29+
<avalonia:MaterialIcon Kind="Folder"/>
30+
</Button>
2631
<TextBlock Text="{Binding ConnectionStatus}" VerticalAlignment="Center" Margin="5 0 0 0"/>
2732
</StackPanel>
2833
<TextBlock Grid.Column="1" Text="{Binding LastUpdateTimeText}" VerticalAlignment="Center" TextAlignment="Right"/>

MSURandomizer/Views/MsuMonitorWindow.axaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using Avalonia.Controls;
4+
using Avalonia.Interactivity;
45
using AvaloniaControls.Controls;
56
using AvaloniaControls.Extensions;
67
using AvaloniaControls.Models;
@@ -55,4 +56,9 @@ private void TopLevel_OnClosed(object? sender, EventArgs e)
5556
{
5657
_service?.StopMonitor();
5758
}
59+
60+
private void FolderButton_OnClick(object? sender, RoutedEventArgs e)
61+
{
62+
_service?.OpenLuaFolder();
63+
}
5864
}

MSURandomizerLibrary/MsuShuffleStyle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum MsuShuffleStyle
1616
/// <summary>
1717
/// Same as the regular standard shuffle, only for related tracks it will try to use the same MSU
1818
/// </summary>
19-
[Description("Standard shuffle - shuffle songs meant for that location, pairing related tracks such as a dungeon and its boss theme")]
19+
[Description("Standard shuffle (pair tracks) - shuffle songs meant for that location, pairing related tracks such as a dungeon and its boss theme")]
2020
ShuffleWithPairedTracks,
2121

2222
/// <summary>
@@ -29,6 +29,6 @@ public enum MsuShuffleStyle
2929
/// <summary>
3030
/// Shuffle mode where literally any song can be picked. Even for special tracks such as
3131
/// </summary>
32-
[Description("Chaos shuffle - shuffle in songs not meant for a given location, including special tracks like the crystal get")]
32+
[Description("Chaos shuffle (full chaos)- shuffle in songs not meant for a given location, including special tracks like the crystal get")]
3333
ChaosAllTracks
3434
}

0 commit comments

Comments
 (0)