Skip to content

Commit 393f0ae

Browse files
authored
Working Linux (#42)
* basic linux app working * case-sensitive directory file loading * add first icon * add more icons * use png file instead of ico file * remove rest of unicode icons and use material ones where possible
1 parent 7082038 commit 393f0ae

File tree

10 files changed

+78
-30
lines changed

10 files changed

+78
-30
lines changed

AvaGui/App.axaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
x:Class="AvaGui.App"
3+
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
44
xmlns:local="using:AvaGui"
5+
x:Class="AvaGui.App"
56
RequestedThemeVariant="Default">
67
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
78

@@ -11,6 +12,7 @@
1112

1213
<Application.Styles>
1314
<FluentTheme />
15+
<materialIcons:MaterialIconStyles />
1416
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
1517
</Application.Styles>
1618

AvaGui/Assets/loco_icon.ico

-121 KB
Binary file not shown.

AvaGui/Assets/loco_icon.png

134 KB
Loading

AvaGui/AvaGui.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Avalonia" Version="11.0.11" />
36-
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.11" />
37-
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
38-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
39-
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.11" />
35+
<PackageReference Include="Avalonia" Version="11.1.0" />
36+
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.0" />
37+
<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
38+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
39+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
4040
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
41-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.11" />
42-
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
41+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0" />
42+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0" />
4343
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="11.0.10.1" />
4444
<PackageReference Include="bodong.PropertyModels" Version="11.0.10.1" />
45+
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.10" />
4546
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
4647
<PackageReference Include="ReactiveUI.Validation" Version="4.0.9" />
4748
<PackageReference Include="Zenith.Core" Version="1.0.20" />

AvaGui/Models/ObjectEditorModel.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,13 @@ public void LoadObjDirectory(string directory, IProgress<float>? progress, bool
330330
}
331331

332332
Settings.ObjDataDirectory = directory;
333-
var allFiles = Directory.GetFiles(directory, "*.dat", SearchOption.AllDirectories);
333+
var allFiles = Directory
334+
.GetFiles(directory, "*", SearchOption.AllDirectories); // the searchPattern doesn't support full regex and is not case sensitive on windows but is case sensitive on linux
335+
336+
allFiles = allFiles
337+
.Where(x => Path.GetExtension(x).Equals(".dat", StringComparison.OrdinalIgnoreCase))
338+
.ToArray();
339+
334340
if (useExistingIndex && File.Exists(Settings.GetObjDataFullPath(Settings.IndexFileName)))
335341
{
336342
HeaderIndex = DeserialiseHeaderIndexFromFile(Settings.GetObjDataFullPath(Settings.IndexFileName)) ?? HeaderIndex;
@@ -345,7 +351,7 @@ public void LoadObjDirectory(string directory, IProgress<float>? progress, bool
345351
else
346352
{
347353
Logger?.Info("Recreating index file");
348-
CreateIndex(allFiles, progress);
354+
CreateIndex(allFiles, progress); // do we need the array?
349355
SerialiseHeaderIndexToFile(Settings.GetObjDataFullPath(Settings.IndexFileName), HeaderIndex, GetOptions());
350356
}
351357

AvaGui/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"profiles": {
33
"WSL": {
44
"commandName": "WSL2",
5-
"distributionName": ""
5+
"distributionName": "Ubuntu-24.04"
66
},
77
"AvaGui": {
88
"commandName": "Project"
99
}
1010
}
11-
}
11+
}

AvaGui/ViewModels/MainWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public MainWindowViewModel()
107107
x,
108108
ReactiveCommand.Create(() => FolderTreeViewModel.CurrentDirectory = x),
109109
null)));
110-
ObjDataItems.Insert(0, new MenuItemModel("📂 Add new folder", ReactiveCommand.Create(SelectNewFolder), null));
110+
ObjDataItems.Insert(0, new MenuItemModel("Add new folder", ReactiveCommand.Create(SelectNewFolder), null));
111111
ObjDataItems.Insert(1, new MenuItemModel("-", ReactiveCommand.Create(() => { }), null));
112112

113113
//DataItems = new ObservableCollection<MenuItemModel>(Model.Settings.DataDirectories

AvaGui/Views/MainWindow.axaml

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
xmlns:pgc="clr-namespace:Avalonia.PropertyGrid.Controls;assembly=Avalonia.PropertyGrid"
1010
xmlns:sys="clr-namespace:System;assembly=mscorlib"
1111
xmlns:generic="clr-namespace:System.Collections.Generic;assembly=System.Runtime"
12+
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
1213
mc:Ignorable="d" d:DesignWidth="1024" d:DesignHeight="768"
1314
x:Class="AvaGui.Views.MainWindow"
1415
x:DataType="vm:MainWindowViewModel"
15-
Icon="/Assets/loco_icon.ico"
16+
Icon="/Assets/loco_icon.png"
1617
Title="{Binding WindowTitle}">
1718

1819
<Design.DataContext>
@@ -53,16 +54,31 @@
5354
</CroppedBitmap>
5455
</Image.Source>
5556
</Image>
56-
<TextBlock VerticalAlignment="Center" Text="{Binding NameComputed}"/>
57+
<TextBlock VerticalAlignment="Center" Text="{Binding NameComputed}" ToolTip.Tip="{Binding Path}"/>
5758
</StackPanel>
5859
</DataTemplate>
5960

6061
<DataTemplate DataType="vm:ObjectEditorViewModel">
6162
<StackPanel DataContext="{Binding}" Margin="10" Orientation="Vertical">
6263
<StackPanel Orientation="Horizontal">
63-
<Button Content="⭮ Reload" Command="{Binding ReloadObjectCommand}"/>
64-
<Button Content="💾 Save" Command="{Binding SaveObjectCommand}"/>
65-
<Button Content="💾 Save As" Command="{Binding SaveAsObjectCommand}"/>
64+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding ReloadObjectCommand}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Reload">
65+
<DockPanel>
66+
<materialIcons:MaterialIcon Kind="DatabaseRefresh" Width="24" Height="24" Margin="2" />
67+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Reload</TextBlock>
68+
</DockPanel>
69+
</Button>
70+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding SaveObjectCommand}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Save">
71+
<DockPanel>
72+
<materialIcons:MaterialIcon Kind="ContentSave" Width="24" Height="24" Margin="2" />
73+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Save</TextBlock>
74+
</DockPanel>
75+
</Button>
76+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding SaveAsObjectCommand}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Save As">
77+
<DockPanel>
78+
<materialIcons:MaterialIcon Kind="ContentSavePlus" Width="24" Height="24" Margin="2" />
79+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Save As</TextBlock>
80+
</DockPanel>
81+
</Button>
6682
</StackPanel>
6783
<TabControl>
6884
<TabItem Header="Headers">
@@ -95,8 +111,18 @@
95111
<TabItem Header="Image Table">
96112
<DockPanel DataContext="{Binding ImageTableViewModel}">
97113
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
98-
<Button Command="{Binding ImportImagesCommand}">📥 Import from Directory</Button>
99-
<Button Command="{Binding ExportImagesCommand}">📤 Export To Directory</Button>
114+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding ImportImagesCommand}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Import from Directory">
115+
<DockPanel>
116+
<materialIcons:MaterialIcon Kind="FolderUpload" Width="24" Height="24" Margin="2" />
117+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Import from Directory</TextBlock>
118+
</DockPanel>
119+
</Button>
120+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding ExportImagesCommand}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Export to Directory">
121+
<DockPanel>
122+
<materialIcons:MaterialIcon Kind="FolderDownload" Width="24" Height="24" Margin="2" />
123+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Export to Directory</TextBlock>
124+
</DockPanel>
125+
</Button>
100126
<!--<Label VerticalAlignment="Center">🔍 Image Scaling (1-10):</Label>
101127
<NumericUpDown Value="{Binding Zoom}" FormatString="0" Watermark="1" Width="108" Minimum="1" Maximum="10" />-->
102128
</StackPanel>
@@ -141,8 +167,8 @@
141167
<Menu>
142168
<MenuItem Header="_File">
143169
<!--<MenuItem Header="Load Palette" Command="{Binding LoadPalette}" />-->
144-
<MenuItem Header="Open settings folder" Command="{Binding OpenSettingsFolder}" />
145-
<MenuItem Header="🚉 Open single object" Command="{Binding OpenSingleObject}" />
170+
<MenuItem Header="Open settings folder" Command="{Binding OpenSettingsFolder}" />
171+
<MenuItem Header="Open single object" Command="{Binding OpenSingleObject}" />
146172
</MenuItem>
147173
<MenuItem Header="_ObjData" ItemsSource="{Binding ObjDataItems}" Classes="SubItems" >
148174
<MenuItem.Styles>
@@ -197,7 +223,7 @@
197223
</MenuItem.Styles>
198224
</MenuItem>-->
199225
</Menu>
200-
<ToggleSwitch IsChecked="{Binding IsDarkTheme, Mode=TwoWay}" HorizontalAlignment="Right" OnContent="🌒︎" OffContent="🌔︎" />
226+
<ToggleSwitch IsChecked="{Binding IsDarkTheme, Mode=TwoWay}" HorizontalAlignment="Right" OnContent="{materialIcons:MaterialIconExt Kind=MoonWaningCrescent}" OffContent="{materialIcons:MaterialIconExt Kind=WeatherSunny}" />
201227
</DockPanel>
202228
<Expander Header="Logs" Padding="0" ExpandDirection="Down" DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" Margin="8">
203229
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
@@ -213,10 +239,20 @@
213239
<RowDefinition Height="Auto"/>
214240
<RowDefinition Height="*"/>
215241
</Grid.RowDefinitions>
216-
<TextBox Grid.Row="0" Text="{Binding CurrentDirectory}" BorderBrush="Gray" Watermark="📁 Current directory" UseFloatingWatermark="True" IsReadOnly="True" VerticalContentAlignment="Center" Margin="2"/>
217-
<TextBox Grid.Row="1" Text="{Binding DirectoryFileCount}" BorderBrush="Gray" Watermark="🛢 Indexed objects for current directory" UseFloatingWatermark="True" IsReadOnly="True" Margin="2"/>
218-
<TextBox Grid.Row="2" Text="{Binding FilenameFilter}" BorderBrush="Gray" Watermark="🔎 Filename search" Margin="2"/>
219-
<Button Grid.Row="3" Content="⭮ Recreate current index" BorderBrush="Gray" Command="{Binding RecreateIndex}" HorizontalAlignment="Stretch" Margin="2"/>
242+
<TextBox Grid.Row="0" Text="{Binding CurrentDirectory}" BorderBrush="Gray" Watermark="Current directory" UseFloatingWatermark="True" IsReadOnly="True" VerticalContentAlignment="Center" Margin="2"/>
243+
<TextBox Grid.Row="1" Text="{Binding DirectoryFileCount}" BorderBrush="Gray" Watermark="Indexed objects for current directory" UseFloatingWatermark="True" IsReadOnly="True" Margin="2"/>
244+
245+
<DockPanel Grid.Row="2" Margin="2" >
246+
<materialIcons:MaterialIcon Kind="Magnify" Width="24" Height="24" Margin="2"/>
247+
<TextBox Text="{Binding FilenameFilter}" BorderBrush="Gray" Watermark="Filename search" />
248+
</DockPanel>
249+
250+
<Button Grid.Row="3" BorderBrush="Gray" Command="{Binding RecreateIndex}" HorizontalAlignment="Stretch" Margin="2" Padding="2" ToolTip.Tip="Recreate index">
251+
<DockPanel>
252+
<materialIcons:MaterialIcon Kind="DatabaseRefresh" Width="24" Height="24" Margin="2" />
253+
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4">Recreate index</TextBlock>
254+
</DockPanel>
255+
</Button>
220256
<ToggleSwitch Grid.Row="4" BorderBrush="Gray" IsChecked="{Binding DisplayVanillaOnly, Mode=TwoWay}" OnContent="Displaying vanilla only" OffContent="Displaying all objects" Margin="2" />
221257
<Border Grid.Row="5" BorderThickness="1" BorderBrush="Gray" CornerRadius="4">
222258
<TreeView ItemsSource="{Binding DirectoryItems}" SelectedItem="{Binding CurrentlySelectedObject}" Margin="2">

Gui/MainForm.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int CurrentUIImagePageNumber
9191
static string SettingsPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ApplicationName);
9292
static string SettingsFile => Path.Combine(SettingsPath, "settings.json");
9393

94-
readonly Version ApplicationVersion;
94+
Version ApplicationVersion { get; set; }
9595
StreamWriter logToFile;
9696

9797
public MainForm()
@@ -134,7 +134,11 @@ public MainForm()
134134
model = new MainFormModel(logger, SettingsFile, palette);
135135
}
136136

137-
#region Version
137+
CheckLatestVersion(assembly);
138+
}
139+
140+
void CheckLatestVersion(Assembly assembly)
141+
{
138142
ApplicationVersion = GetCurrentAppVersion(assembly);
139143

140144
var latestVersionText = "up-to-date";
@@ -154,7 +158,6 @@ public MainForm()
154158
latestVersionText = $"newer version exists: {latestVersion}";
155159
}
156160
}
157-
#endregion
158161

159162
Text = $"{ApplicationName} - {ApplicationVersion} ({latestVersionText})";
160163
}

loco_icon.png

134 KB
Loading

0 commit comments

Comments
 (0)