Skip to content

Commit

Permalink
copyToTargetGameModDirectory option
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Apr 24, 2022
1 parent 6f67f48 commit 27cfe3a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 50 deletions.
Binary file added Fronter.NET/Assets/Images/main_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions Fronter.NET/Fronter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>


<ItemGroup><!-- TODO: REMOVE -->
<ItemGroup>
<DebugResources Include="../DEBUG_RESOURCES/**/*.*" />
</ItemGroup>
<ItemGroup>
Expand All @@ -24,7 +24,7 @@
<Resources Include="Resources/**/*.*" />
</ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="Build">
<Copy SourceFiles="@(DebugResources)" DestinationFolder="$(OutDir)/%(RecursiveDir)" SkipUnchangedFiles="true" />
<Copy Condition="'$(Configuration)' == 'Debug'" SourceFiles="@(DebugResources)" DestinationFolder="$(OutDir)/%(RecursiveDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(Images)" DestinationFolder="$(OutDir)/Assets/Images/%(RecursiveDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(Resources)" DestinationFolder="$(OutDir)/Resources/%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
Expand All @@ -44,10 +44,4 @@
<ItemGroup>
<ProjectReference Include="..\commonItems.NET\commonItems\commonItems.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\OptionsView.axaml.cs">
<DependentUpon>OptionsView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>
22 changes: 3 additions & 19 deletions Fronter.NET/Models/Configuration/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Configuration {
public string DisplayName { get; private set; } = string.Empty;
public string SourceGame { get; private set; } = string.Empty;
public string TargetGame { get; private set; } = string.Empty;
public string AutoGenerateModsFrom { get; private set; } = string.Empty;
public bool CopyToTargetGameModDirectory { get; set; } = true;
public bool UpdateCheckerEnabled { get; private set; } = false;
public bool CheckForUpdatesOnStartup { get; private set; } = false;
public string ConverterReleaseForumThread { get; private set; } = string.Empty;
Expand All @@ -28,8 +28,6 @@ public class Configuration {
public List<RequiredFile> RequiredFiles { get; } = new();
public List<RequiredFolder> RequiredFolders { get; } = new();
public List<Option> Options { get; } = new();
public List<Mod> AutoLocatedMods { get; } = new();
public HashSet<string> PreloadedModFileNames { get; } = new();
private int optionCounter;

private static ILog logger = LogManager.GetLogger("CONFIGURATION");
Expand Down Expand Up @@ -103,8 +101,8 @@ private void RegisterKeys(Parser parser) {
parser.RegisterKeyword("targetGame", reader => {
TargetGame = reader.GetString();
});
parser.RegisterKeyword("autoGenerateModsFrom", reader => {
AutoGenerateModsFrom = reader.GetString();
parser.RegisterKeyword("copyToTargetGameModDirectory", reader => {
CopyToTargetGameModDirectory = reader.GetString() == "true";
});
parser.RegisterKeyword("enableUpdateChecker", reader => {
UpdateCheckerEnabled = reader.GetString() == "true";
Expand Down Expand Up @@ -151,10 +149,6 @@ private void RegisterPreloadKeys(Parser parser) {
option.SetCheckBoxSelectorPreloaded();
}
}
if (incomingKey == "selectedMods") {
var selections = valueReader.GetStrings();
PreloadedModFileNames.UnionWith(selections);
}
});
parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
}
Expand Down Expand Up @@ -255,16 +249,6 @@ public bool ExportConfiguration() {
writer.WriteLine($"{file.Name} = \"{file.Value}\"");
}

if (!string.IsNullOrEmpty(AutoGenerateModsFrom)) {
writer.WriteLine("selectedMods={");
foreach (var mod in AutoLocatedMods) {
if (PreloadedModFileNames.Contains(mod.FileName)) {
writer.WriteLine($"\t\"{mod.FileName}\"");
}
}
writer.WriteLine("}");
}

foreach (var option in Options) {
if (option.CheckBoxSelector is not null) {
writer.Write($"{option.Name} = {{ ");
Expand Down
9 changes: 5 additions & 4 deletions Fronter.NET/Services/ConverterLauncher.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Avalonia.Threading;
using commonItems;
using Fronter.Models;
using commonItems;
using Fronter.LogAppenders;
using Fronter.Models.Configuration;
using Fronter.ViewModels;
using log4net;
using log4net.Core;
using System;
Expand Down Expand Up @@ -48,6 +46,9 @@ public bool LaunchConverter() {
process.OutputDataReceived += (sender, args) => {
var logLine = MessageSlicer.SliceMessage(args.Data ?? string.Empty);
var level = logLine.Level;
if (level is null && string.IsNullOrEmpty(logLine.Message)) {
return;
}
Logger.Log(level ?? lastLevelFromBackend ?? Level.Info, logLine.Message);
if (level is not null) {
lastLevelFromBackend = level;
Expand Down
5 changes: 1 addition & 4 deletions Fronter.NET/Services/MessageSlicer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ public static LogLine SliceMessage(string message) {

var timestampPart = message[..posOpen].Trim();
if (dateTimeRegex.IsMatch(timestampPart)) {
} else {
logMessage.Message = message;
return logMessage;
logMessage.Timestamp = timestampPart;
}

logMessage.Timestamp = timestampPart;
var logLevelStr = message.Substring(posOpen + 1, posClose - posOpen - 1);
logMessage.Level = GetLogLevel(logLevelStr);
if (message.Length >= posClose + 2) {
Expand Down
10 changes: 3 additions & 7 deletions Fronter.NET/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public MainWindowViewModel() {
Config = new Configuration();

var appenders = LogManager.GetRepository().GetAppenders();
foreach (var appender in appenders) {
Logger.Debug($"test {appender.Name}");
}

var gridAppender = appenders.First(a => a.Name == "grid");
if (gridAppender is not LogGridAppender logGridAppender) {
throw new LogException($"Log appender \"{gridAppender.Name}\" is not a {typeof(LogGridAppender)}");
Expand Down Expand Up @@ -116,25 +112,25 @@ public bool VerifyMandatoryPaths() {
}

public void LaunchConverter() {
Progress = 0;
SaveStatus = "CONVERTSTATUSPRE";
ConvertStatus = "CONVERTSTATUSPRE";
CopyStatus = "CONVERTSTATUSPRE";

LogGridAppender.LogLines.Clear();
if (!VerifyMandatoryPaths()) {
return;
}
Config.ExportConfiguration();

var converterLauncher = new ConverterLauncher(Config);
bool success = false;
bool success;
var converterThread = new Thread(() => {
ConvertStatus = "CONVERTSTATUSIN";
success = converterLauncher.LaunchConverter();
if (success) {
ConvertStatus = "CONVERTSTATUSPOSTSUCCESS";
var modCopier = new ModCopier(Config);
bool copySuccess = false;
bool copySuccess;
var copyThread = new Thread(() => {
CopyStatus = "CONVERTSTATUSIN";
copySuccess = modCopier.CopyMod();
Expand Down
7 changes: 5 additions & 2 deletions Fronter.NET/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</Design.DataContext>

<DockPanel>
<DockPanel.Background>
<ImageBrush Source="/Assets/Images/main_image.png" Stretch="UniformToFill" Opacity="0.05" />
</DockPanel.Background>
<Menu DockPanel.Dock="Top">
<MenuItem Header="{ns:Loc MENUCONVERTER}">
<MenuItem Header="{ns:Loc CHECKFORUPDATES}" Command="{Binding CheckForUpdates}"/>
Expand All @@ -31,7 +34,7 @@
<MenuItem.Styles>
<Style Selector="MenuItem.LanguageChoice MenuItem">
<Setter Property="Header" Value="{Binding Value}"/>
<Setter Property="Command" Value="{Binding $parent[Window].DataContext.SetLanguage}"/>
<Setter Property="Command" Value="{Binding $parent[Window].DataContext.SetLanguage, FallbackValue={}}"/>
<Setter Property="CommandParameter" Value="{Binding Key}"/>
</Style>
</MenuItem.Styles>
Expand Down Expand Up @@ -64,7 +67,7 @@
</TabItem>

<TabItem Header="{ns:Loc CONVERTTAB}" VerticalContentAlignment="Center">
<Grid ColumnDefinitions="1*,2*" RowDefinitions="Auto" Margin="2,4,2,4" ShowGridLines="True">
<Grid ColumnDefinitions="1*,2*" RowDefinitions="Auto" Margin="2,4,2,4">
<StackPanel Grid.Row="0" Grid.Column="0">
<TextBlock Text="{ns:Loc LOGLEVEL}" HorizontalAlignment="Left" VerticalAlignment="Center"/>

Expand Down
7 changes: 2 additions & 5 deletions Fronter.NET/log4net.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
</appender>
<appender name="file" type="log4net.Appender.FileAppender">
<file value="log.txt" />
<!--<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="100MB" />
<staticLogFileName value="true" />-->
<appendToFile value="false" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{yyyy'-'MM'-'dd HH':'mm':'ss} [%level] %message%newline" />
</layout>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ backendExePath = CK2ToEU4Converter # Relative to converterFolder. If file extens
displayName = DISPLAYNAME
sourceGame = SOURCEGAME
targetGame = TARGETGAME
autoGenerateModsFrom = CK2ModsDirectory
copyToTargetGameModDirectory = true
requiredFile = {
name = SaveGame
Expand Down

0 comments on commit 27cfe3a

Please sign in to comment.