ctrl k
  • .vscode/launch.json
    ■ ■ ■ ■ ■ ■
    skipped 11 lines
    12 12   // If you have changed target frameworks, make sure to update the program path.
    13 13   "program": "${workspaceFolder}/DoUrVerse.Desktop/bin/Debug/net8.0/DoUrVerse.dll",
    14 14   "cwd": "${workspaceFolder}/DoUrVerse.Desktop",
    15  - //"program": "${workspaceFolder}/DoUrVerse.Launcher/bin/Debug/net8.0/DoUrVerse.Launcher.dll",
    16  - //"cwd": "${workspaceFolder}/DoUrVerse.Launcher",
     15 + // "program": "${workspaceFolder}/DoUrVerse.Launcher/bin/Debug/net8.0/DoUrVerse.Launcher.dll",
     16 + // "cwd": "${workspaceFolder}/DoUrVerse.Launcher",
    17 17   "args": [],
    18 18   // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
    19 19   "console": "internalConsole",
    skipped 27 lines
  • DoUrVerse/Platform/AvaloniaAssetManager.cs
    ■ ■ ■ ■ ■ ■
    skipped 12 lines
    13 13   internal class AvaloniaAssetManager : IAssetManager
    14 14   {
    15 15   const string ASSEMBLYNAME = "DoUrVerse.Shared";
     16 + /// <summary>
     17 + ///
     18 + /// </summary>
     19 + /// <param name="path">The uri encoded path name. Prefixes 'avares://' if not present.</param>
     20 + /// <returns></returns>
    16 21   public Stream GetAssetStream(string path)
    17 22   {
    18 23   Uri uri;
    skipped 6 lines
    25 30   {
    26 31   uri = new Uri(path);
    27 32   }
     33 +
    28 34   return AssetLoader.Open(uri);
     35 +
    29 36   }
    30 37  
    31 38   public IPBitmap? GetBitmap(string path)
    skipped 11 lines
  • DoUrVerse/Platform/AvaloniaLogger.cs
    ■ ■ ■ ■ ■ ■
     1 +using System;
     2 +using System.IO;
     3 +using DoUrVerseLib.Platform;
     4 + 
     5 +namespace DoUrVerse.Platform;
     6 + 
     7 +public class AvaloniaLogger : ILogger
     8 +{
     9 + StreamWriter? _logWriter;
     10 + string _filename;
     11 + IPlatform _platform;
     12 + public AvaloniaLogger(IPlatform platform, string filename)
     13 + {
     14 + _filename = filename;
     15 + _platform = platform;
     16 + try {
     17 + setWriter();
     18 + }
     19 + catch
     20 + {
     21 + Environment.Exit(1);
     22 + }
     23 + }
     24 + public void Error(string message, Exception? e = null)
     25 + {
     26 + if (e == null)
     27 + {
     28 + writeLine($"[ERROR] {message}");
     29 + }
     30 + else
     31 + {
     32 + writeLine($"[ERROR] {message}:");
     33 + writeLine($"\t{e}");
     34 + if (e.StackTrace != null)
     35 + {
     36 + writeLine($"{e.StackTrace}");
     37 + }
     38 + }
     39 + }
     40 + 
     41 + public void Info(string message)
     42 + {
     43 + writeLine($"[INFO] {message}");
     44 + }
     45 + 
     46 + public void Warn(string message)
     47 + {
     48 + writeLine($"[WARNING] {message}");
     49 + }
     50 + void writeLine(string output)
     51 + {
     52 + if (_logWriter == null)
     53 + {
     54 + return;
     55 + }
     56 + else if (_logWriter.BaseStream.CanWrite == false)
     57 + {
     58 + setWriter();
     59 + }
     60 + 
     61 + try
     62 + {
     63 + _logWriter?.WriteLine($"{output}");
     64 + _logWriter?.Flush();
     65 + }
     66 + catch
     67 + {
     68 + //Unable to write to log
     69 + }
     70 + }
     71 + void setWriter()
     72 + {
     73 + Stream stream = _platform.FileOpenWrite(_filename);
     74 + _logWriter = new StreamWriter(stream);
     75 + Console.SetOut(_logWriter);
     76 + }
     77 +}
  • DoUrVerse/Platform/AvaloniaPlatform.cs
    ■ ■ ■ ■ ■
    skipped 23 lines
    24 24   public event ConfigLoadedEventHandler? ConfigLoaded;
    25 25   public event ConfigSettingUpdatedEventHandler? ConfigSettingUpdated;
    26 26   bool _initialized = false;
     27 + ILogger _logger;
     28 + public ILogger Log => _logger;
     29 + string _logfile;
     30 + public AvaloniaPlatform()
     31 + {
     32 + _logfile = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DoUrVerse", "application.log");
     33 + _logger = new AvaloniaLogger(this, _logfile);
     34 + }
    27 35  
    28 36   async public void SetClipboard(string text)
    29 37   {
    skipped 75 lines
    105 113   {
    106 114   return assets;
    107 115   }
    108  - public AvaloniaPlatform()
    109  - {
    110  - Debug.WriteLine("New avalonia platform");
    111  - }
    112 116   public void Initialize()
    113 117   {
    114 118   if (_initialized)
    skipped 64 lines
    179 183   NotifyUser.Error($"Could not load language {lang}");
    180 184   }
    181 185  
     186 + }
     187 +
     188 + public Stream FileOpenWrite(string filename) => File.OpenWrite(filename);
     189 +
     190 + public void Error(string message, Exception? e)
     191 + {
     192 + _logger.Error(message, e);
     193 + }
     194 + public void Info(string message)
     195 + {
     196 + _logger.Info(message);
     197 + }
     198 +
     199 + public void Warn(string message)
     200 + {
     201 + _logger.Warn(message);
    182 202   }
    183 203  }
    184 204   
  • DoUrVerse/ViewModels/BindingWorkspaceViewModel.cs
    ■ ■ ■ ■ ■ ■
    skipped 7 lines
    8 8  using DoUrVerseLib;
    9 9  using DoUrVerseLib.Platform;
    10 10  using DoUrVerse.Views;
     11 +using System.Linq;
    11 12  
    12 13  namespace DoUrVerse.ViewModels;
    13 14  
    skipped 78 lines
    92 93   if (_platform.IsUI)
    93 94   {
    94 95   string scVersion = _config.Settings.StarCitizenVersion;
    95  - using (Stream? defaultExport = _platform.Assets().GetAssetStream($"Assets/{scVersion}/default-export.xml"))
     96 + if (!Config.SCVersions.Contains(scVersion))
    96 97   {
     98 + string? nextVersion = Config.FindNextVersion(scVersion, Config.SCVersions);
     99 + _platform.Warn($"Configured to load version {scVersion} of Star Citizen. Oldest supported version is {nextVersion} which will be used now. You should change the setting.");
     100 +
     101 + if (nextVersion != null)
     102 + {
     103 + scVersion = nextVersion;
     104 + }
     105 + }
     106 +
     107 + string profileAsset = $"Assets/{scVersion}/default-export.xml";
     108 +
     109 + try {
     110 + using Stream? defaultExport = _platform.Assets().GetAssetStream(profileAsset);
    97 111   if (defaultExport != null)
    98 112   {
    99 113   Profile.ReadDefault(defaultExport);
    100 114   }
     115 + }
     116 + catch (FileNotFoundException)
     117 + {
     118 + //This is most likely because the config file is old and the bindings were removed from the application
     119 + // so load oldest profile instead
     120 + _platform.Error($"Asset '{profileAsset}' was not found");
     121 +
     122 + }
     123 + catch (Exception e)
     124 + {
     125 + _platform.Error($"Exception occured trying to locate asset '{profileAsset}'", e);
    101 126   }
    102 127   }
    103 128  
    skipped 20 lines
  • DoUrVerse/ViewModels/MainSettingsViewModel.cs
    ■ ■ ■ ■ ■ ■
    skipped 7 lines
    8 8  using System.Diagnostics;
    9 9  using System.Windows.Input;
    10 10  using DoUrVerseLib;
     11 +using System.Collections.ObjectModel;
    11 12  
    12 13  namespace DoUrVerse.ViewModels;
    13 14  
    skipped 63 lines
    77 78   get => Profile.Instance.IsChanged;
    78 79   }
    79 80  
    80  - public List<string> SelectableVersions => new()
    81  - {
    82  - //"3.22",
    83  - "3.23.1",
    84  - "3.24"
    85  - };
     81 + public ObservableCollection<string> SelectableVersions => new ObservableCollection<string>(Config.SCVersions);
    86 82  
    87 83   bool autoSaveProfile = false;
    88 84   public bool AutoSaveProfile
    skipped 166 lines
  • DoUrVerse.Desktop/DoUrVerse.Desktop.csproj
    ■ ■ ■ ■ ■ ■
    skipped 14 lines
    15 15   <ApplicationManifest>app.manifest</ApplicationManifest>
    16 16   <PackageId>DoUrVerse.Desktop</PackageId>
    17 17   <AssemblyName>DoUrVerse</AssemblyName>
    18  - <AssemblyVersion>0.4.2</AssemblyVersion>
    19  - <FileVersion>0.4.2</FileVersion>
     18 + <AssemblyVersion>0.4.2.1</AssemblyVersion>
     19 + <FileVersion>0.4.2.1</FileVersion>
    20 20   </PropertyGroup>
    21 21   
    22 22  
    skipped 22 lines
  • DoUrVerse.Launcher/DoUrVerse.Launcher.csproj
    ■ ■ ■ ■
    skipped 10 lines
    11 11   <UseAppHost>true</UseAppHost>
    12 12   <SourceRevisionId>build$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</SourceRevisionId>
    13 13   <CurrentBuildTime>$([System.DateTime]::Now.ToString("o"))</CurrentBuildTime>
    14  - <AssemblyVersion>0.4.2</AssemblyVersion>
     14 + <AssemblyVersion>0.4.2.1</AssemblyVersion>
    15 15   </PropertyGroup>
    16 16   
    17 17   <PropertyGroup>
    skipped 17 lines
  • DoUrVerse.Launcher/Logger.cs
    ■ ■ ■ ■ ■
    skipped 8 lines
    9 9   
    10 10  public class Logger
    11 11  {
    12  -
    13 12   string _filename = null;
    14 13   string _lockfile = null;
    15 14   EventWaitHandle waitHandle;
    skipped 95 lines
  • DoUrVerse.Tests/Config/Config_UpdateSCVersion.cs
    ■ ■ ■ ■ ■ ■
     1 + 
     2 + 
     3 +using DoUrVerseLib.Config;
     4 + 
     5 +namespace DoUrVerse.Tests;
     6 + 
     7 +public class Config_UpdateSCVersion
     8 +{
     9 + [Fact]
     10 + public void FindNextVersion_InOrder()
     11 + {
     12 + string[] SCVersions = ["3.22", "3.23", "3.23.1", "3.24"];
     13 + Assert.Equal("3.23", Config.FindNextVersion("3.22", SCVersions));
     14 + Assert.Equal("3.23.1", Config.FindNextVersion("3.23", SCVersions));
     15 + Assert.Equal("3.24", Config.FindNextVersion("3.23.1", SCVersions));
     16 + Assert.Null(Config.FindNextVersion("3.24", SCVersions));
     17 + }
     18 + [Fact]
     19 + public void FindNextVersion_Unordered()
     20 + {
     21 + string[] SCVersions = ["3.23", "3.24", "3.23.1", "3.22"];
     22 +
     23 + Assert.Equal("3.23", Config.FindNextVersion("3.22", SCVersions));
     24 + Assert.Equal("3.23.1", Config.FindNextVersion("3.23", SCVersions));
     25 + Assert.Equal("3.24", Config.FindNextVersion("3.23.1", SCVersions));
     26 + Assert.Null(Config.FindNextVersion("3.24", SCVersions));
     27 + }
     28 + 
     29 + [Fact]
     30 + public void FindNextVersion_InvalidSCName()
     31 + {
     32 + string[] SCVersions = ["3.23", "3.24", "3.23.1", "3.22"];
     33 +
     34 + Assert.Equal("3.22", Config.FindNextVersion("invalid", SCVersions));
     35 + }
     36 +}
  • DoUrVerse.Tests/TestPlatform.cs
    ■ ■ ■ ■ ■ ■
    skipped 81 lines
    82 82   {
    83 83  
    84 84   }
     85 + public void Error(string message, Exception? e = null)
     86 + {
     87 + throw new NotImplementedException();
     88 + }
     89 + public void Info(string message)
     90 + {
     91 + throw new NotImplementedException();
     92 + }
     93 + public void Warn(string message)
     94 + {
     95 + throw new NotImplementedException();
     96 + }
     97 +
     98 + public Stream FileOpenWrite(string filname)
     99 + {
     100 + throw new NotImplementedException();
     101 + }
    85 102  }
    86 103   
  • DoUrVerseLib/Config/Config.cs
    ■ ■ ■ ■ ■ ■
    skipped 19 lines
    20 20   const string FILENAME = "config.xml";
    21 21  
    22 22   public ConfigSetting Settings { get; set; }
     23 + public static string[] SCVersions { get; private set; } = ["3.23.1", "3.24"];
    23 24  
    24 25   [XmlIgnore]
    25 26   LocalizationService localizationService { get; set; } = new();
    skipped 306 lines
    332 333   return localizationService.GetBindableGroups();
    333 334   }
    334 335  
     336 + public static string? FindNextVersion(string scVersion, string[] versions)
     337 + {
    335 338  
     339 + var orderedList = new List<string>(versions).Order();
     340 + Version? nextVersion = null;
     341 + Version? configVersion;
     342 + if (!Version.TryParse(scVersion, out configVersion))
     343 + {
     344 + return orderedList.First();
     345 + }
     346 +
     347 + foreach (string versionString in orderedList)
     348 + {
     349 + Version availVersion = Version.Parse(versionString);
     350 + if (nextVersion == null && availVersion > configVersion)
     351 + {
     352 + nextVersion = availVersion;
     353 + }
     354 + else if (nextVersion != null && availVersion < nextVersion && nextVersion > configVersion)
     355 + {
     356 + //If the avail version is more recent to the version in the configuration file go with it instead.
     357 + nextVersion = availVersion;
     358 + }
     359 + }
     360 + if (nextVersion != null)
     361 + {
     362 + return nextVersion.ToString();
     363 + }
     364 + return null;
     365 + }
    336 366  }
  • DoUrVerseLib/Platform/ILogger.cs
    ■ ■ ■ ■ ■ ■
     1 +namespace DoUrVerseLib.Platform;
     2 + 
     3 + 
     4 +public interface ILogger
     5 +{
     6 + public void Error(string message, Exception? e = null);
     7 + public void Info(string message);
     8 + public void Warn(string message);
     9 +}
  • DoUrVerseLib/Platform/IPlatform.cs
    ■ ■ ■ ■
    skipped 20 lines
    21 21   Task<string?> SaveFileAsync(PlatformFileTypeGroup[] fileTypes);
    22 22   IAssetManager Assets();
    23 23   void Initialize();
    24  - //IDeviceManager Devices();
     24 + public void Error(string message, Exception? e = null);
     25 + public void Info(string message);
     26 + public void Warn(string message);
     27 + Stream FileOpenWrite(string filname);
    25 28  }
    26 29  
    27 30  public interface IDeviceManager
    skipped 5 lines
Please wait...
Page is in error, reload to recover