Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[addon] show application Version as ETS #50

Merged
merged 8 commits into from
Sep 12, 2024
Merged
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
53 changes: 53 additions & 0 deletions Kaenx.Creator/Converter/IntToVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Linq;

namespace Kaenx.Creator.Converter
{
public class IntToVersion : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
decimal majorVersion = Math.Floor((decimal)((int)value/16));
int minorVersion = (int)value % 16;
return $"{majorVersion}.{minorVersion}";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
int majorVersion;
int minorVersion;

if(value.ToString().Contains('.'))
{
string[] versions = value.ToString().Split('.');

if(!int.TryParse(versions[0], out majorVersion))
majorVersion = 0;

if(!int.TryParse(versions[1], out minorVersion))
minorVersion = 0;

if(minorVersion > 15)
{
minorVersion /= 10;
if(minorVersion > 15)
minorVersion = 15;
}
}else
{
if(!int.TryParse(value.ToString(), out majorVersion))
majorVersion = 0;

minorVersion = 0;
}

majorVersion *= 16;

return majorVersion + minorVersion;
}
}
}
4 changes: 4 additions & 0 deletions Kaenx.Creator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Title="Kaenx-Creator" Height="720" Width="1300">
<Window.Resources>
<conv:IntToHex x:Key="IntToHex" />
<conv:IntToVersion x:Key="IntToVersion" />
<conv:BoolNegation x:Key="BoolNegate" />
<conv:EmptyOListToBool x:Key="EmptyListToBool" />
<conv:EmptyToBool x:Key="EmptyToBool" />
Expand Down Expand Up @@ -651,6 +652,9 @@
<HeaderedContentControl Header="{x:Static p:Resources.prop_vers}">
<TextBox Text="{Binding Number, UpdateSourceTrigger=PropertyChanged}" />
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.prop_etsvers}">
<TextBox Text="{Binding Number, Converter={StaticResource IntToVersion}, UpdateSourceTrigger=PropertyChanged}" />
</HeaderedContentControl>
<HeaderedContentControl Header="{x:Static p:Resources.prop_versreplace}">
<TextBox Text="{Binding ReplacesVersions, UpdateSourceTrigger=PropertyChanged}" />
</HeaderedContentControl>
Expand Down
2 changes: 1 addition & 1 deletion Kaenx.Creator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,4 @@ private async void ClickCheckVersion(object sender, RoutedEventArgs e)
}
}
}
}
}
9 changes: 9 additions & 0 deletions Kaenx.Creator/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Kaenx.Creator/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@
<value>Version</value>
<comment/>
</data>
<data name="prop_etsvers" xml:space="preserve">
<value>ETS Version</value>
<comment/>
</data>
<data name="prop_buscurrent" xml:space="preserve">
<value>Busstrom</value>
<comment/>
Expand Down
4 changes: 4 additions & 0 deletions Kaenx.Creator/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@
<value>Version</value>
<comment/>
</data>
<data name="prop_etsvers" xml:space="preserve">
<value>ETS Version</value>
<comment/>
</data>
<data name="prop_buscurrent" xml:space="preserve">
<value>Bus Current</value>
<comment/>
Expand Down