Skip to content

Commit

Permalink
fix batch file encoding so they work properly
Browse files Browse the repository at this point in the history
Changed settings file name and added migration code
fix missing settings file
  • Loading branch information
xantari committed Jan 11, 2021
1 parent 144a26a commit c9f5c88
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion PinCab.Configurator/DatabaseBrowser.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pincab.Configurator.exe -databasebrowser
Pincab.Configurator.exe -databasebrowser
2 changes: 1 addition & 1 deletion PinCab.Configurator/GameManager.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pincab.Configurator.exe -gamemanager
Pincab.Configurator.exe -gamemanager
12 changes: 2 additions & 10 deletions PinCab.Configurator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public MainForm()
private void UpdateDisplayDetailsFromSettingsFile()
{
_settings = settingManager.LoadSettings();
if (_settings == null)
{
string msg = "Settings file not found. Creating brand new file.";
Log.Information(msg);
txtData.Text += msg + "\r\n";
_settings = new ProgramSettings();
settingManager.SaveSettings(_settings);
}
foreach (var display in _settings?.DisplaySettings)
{
var loadedDisplaySettingToUpdate = _displayDetails.GetByDisplayName(display.DisplayName);
Expand All @@ -82,8 +74,8 @@ private void UpdateDisplayDetailsFromSettingsFile()
}
else
{
Log.Information("Display: {display} not found. Unable to find settings file data to the display. You may need to manually edit the DisplaySettings.json file to re-number your displays or reboot windows if you just installed graphics driver updates to restore the original display numbers.", display.DisplayName);
txtData.Text += $"Display: {display.DisplayName} not found. Unable to find settings file data to the display. You may need to manually edit the DisplaySettings.json file to re-number your displays or reboot windows if you just installed graphics driver updates to restore the original display numbers.\r\n";
Log.Information("Display: {display} not found. Unable to find settings file data to the display. You may need to manually edit the PincabSettings.json file to re-number your displays or reboot windows if you just installed graphics driver updates to restore the original display numbers.", display.DisplayName);
txtData.Text += $"Display: {display.DisplayName} not found. Unable to find settings file data to the display. You may need to manually edit the PincabSettings.json file to re-number your displays or reboot windows if you just installed graphics driver updates to restore the original display numbers.\r\n";
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions PinCab.Configurator/Pincab.Configurator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<!--https://stackoverflow.com/questions/2011434/preventing-referenced-assembly-pdb-and-xml-files-copied-to-output-->
<AllowedReferenceRelatedFileExtensions>
.pdb;
</AllowedReferenceRelatedFileExtensions>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -24,15 +31,8 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<!--https://stackoverflow.com/questions/2011434/preventing-referenced-assembly-pdb-and-xml-files-copied-to-output-->
<AllowedReferenceRelatedFileExtensions>
.pdb;
</AllowedReferenceRelatedFileExtensions>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
29 changes: 28 additions & 1 deletion PinCab.Configurator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Serilog;
using PinCab.Utils;
using PinCab.Utils.Models;
using PinCab.Utils.Utils;
using Serilog;
using Serilog.Core;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -33,6 +36,18 @@ static void Main(string[] args)

Log.Information("Application Started. Version: {version}", Assembly.GetExecutingAssembly().GetName().Version.ToString());

MigrateFromPreviousVersion();

ProgramSettingsManager settingManager = new ProgramSettingsManager();
var settings = settingManager.LoadSettings();
if (settings == null)
{
string msg = "Settings file not found. Creating brand new file.";
Log.Information(msg);
settings = new ProgramSettings();
settingManager.SaveSettings(settings);
}

if (args.Count() > 0)
{
if (args.Contains("-screenreseditor"))
Expand All @@ -48,6 +63,18 @@ static void Main(string[] args)
Application.Run(new MainForm());
}

private static void MigrateFromPreviousVersion()
{
//1/11/2021 - MRO: Changed the primary settings config file name, migrate old name to new
var oldSettingsFileName = ApplicationHelpers.GetApplicationFolder() + "\\DisplaySettings.json";
var newSettingsFileName = ApplicationHelpers.GetApplicationFolder() + "\\PincabSettings.json";
if (File.Exists(oldSettingsFileName) && !File.Exists(newSettingsFileName))
{
File.Move(oldSettingsFileName, newSettingsFileName);
Log.Information("Migrated settings file from old name (DisplaySettings.json) to (PincabSettings.json)");
}
}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Log.Error("Thread Exception occurred. {ex}", e.Exception);
Expand Down
2 changes: 1 addition & 1 deletion PinCab.Configurator/RomBrowser.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pincab.Configurator.exe -rombrowser
Pincab.Configurator.exe -rombrowser
2 changes: 1 addition & 1 deletion PinCab.Configurator/ScreenresEditor.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pincab.Configurator.exe -screenreseditor
Pincab.Configurator.exe -screenreseditor
7 changes: 7 additions & 0 deletions PinCab.Utils/Models/ProgramSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public ProgramSettings()
DisplaySettings = new List<DisplaySettings>();
RecordTimeSeconds = 30;
RecordFramerate = 30;
DatabaseUpdateRecheckMinutes = 60;
LastDatabaseRefreshTimeUtc = new DateTime(1900, 1, 1);
IPDBDatabaseUrl = "https://raw.githubusercontent.com/xantari/Ipdb.Database/master/Ipdb.Database/Database/ipdbdatabase.json";
VPForumsDatabaseUrl = "https://raw.githubusercontent.com/xantari/VirtualPinball.Databases/master/Databases/vpforumsdatabase.json";
VPinballDatabaseUrl = "https://raw.githubusercontent.com/xantari/VirtualPinball.Databases/master/Databases/vpinballdatabase.json";
VPUniverseDatabaseUrl = "https://raw.githubusercontent.com/xantari/VirtualPinball.Databases/master/Databases/vpuniversedatabase.json";
VPSSpreadsheetUrl = "https://raw.githubusercontent.com/xantari/VirtualPinball.Databases/master/Databases/vpsdatabase.json";
}

public string FFMpegFullPath { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions PinCab.Utils/Utils/ProgramSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ProgramSettings LoadSettings(string fileAndPathToSettingFile = "")
{
string settingsFileNameAndPath;
if (fileAndPathToSettingFile == string.Empty)
settingsFileNameAndPath = ApplicationHelpers.GetApplicationFolder() + "\\DisplaySettings.json";
settingsFileNameAndPath = ApplicationHelpers.GetApplicationFolder() + "\\PincabSettings.json";
else
settingsFileNameAndPath = fileAndPathToSettingFile;
if (File.Exists(settingsFileNameAndPath))
Expand Down Expand Up @@ -56,7 +56,7 @@ public void SaveSettings(ProgramSettings settings, string fileAndPathToSettingFi
{
string settingsFileNameAndPath;
if (fileAndPathToSettingFile == string.Empty)
settingsFileNameAndPath = ApplicationHelpers.GetApplicationFolder() + "\\DisplaySettings.json";
settingsFileNameAndPath = ApplicationHelpers.GetApplicationFolder() + "\\PincabSettings.json";
else
settingsFileNameAndPath = fileAndPathToSettingFile;

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Wiki here: https://github.com/xantari/PinCab.Configurator/wiki (Or click on Wiki

# Instructions

If you want to backup the display settings the key file is DisplaySettings.json in the application folder. This file is automatically created when you first setup your display configuration.
If you want to backup the display settings the key file is PincabSettings.json in the application folder. This file is automatically created when you first setup your display configuration.

Logging information is in the Log.txt file in the application root folder.

Expand Down

0 comments on commit c9f5c88

Please sign in to comment.