Skip to content

Commit

Permalink
Added checkbox to General Config to allow AutoUpdate feature to be tu…
Browse files Browse the repository at this point in the history
…rned on/off (default is off)

Fixed AutoUpdater ConfigVersion null exception
  • Loading branch information
cozy1 committed Sep 28, 2017
1 parent 69972b7 commit 960f901
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 18 deletions.
21 changes: 19 additions & 2 deletions RocksmithTookitGUI/Config/GeneralConfig.Designer.cs

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

5 changes: 3 additions & 2 deletions RocksmithTookitGUI/Config/GeneralConfig.cs
Expand Up @@ -21,10 +21,11 @@ public partial class GeneralConfig : UserControl
// only gets called one time
public GeneralConfig()
{
// increment Version here to force RocksmithToolkitUpdater to do a fresh install of RocksmithToolkitLib.*.xml
ConfigVersion.Version = "1";
InitializeComponent();

// increment the Version here to force RocksmithToolkitUpdater to do a fresh install of RocksmithToolkitLib.*.xml
ConfigVersion.Version = "2";

// fix readonly textbox/cuebox background colors
general_rs1path.BackColor = SystemColors.Window;
general_rs2014path.BackColor = SystemColors.Window;
Expand Down
7 changes: 6 additions & 1 deletion RocksmithTookitGUI/MainForm.cs
Expand Up @@ -29,6 +29,11 @@ public static bool IsInDesignMode
public MainForm(string[] args)
{
InitializeComponent();

// uncomment to debug AutoUpdater without internet connection
//var debug1 = new RocksmithToolkitUpdater.AutoUpdater();
//var debug2 = debug1.ReplaceRepo;

// EH keeps main form responsive/refreshed
this.Shown += MainForm_Splash;

Expand Down Expand Up @@ -58,7 +63,7 @@ private void InitMainForm()
updateButton.Text = "Updates Disabled";
updateButton.Visible = true;
}
else
else if (ConfigRepository.Instance().GetBoolean("general_autoupdate"))
{
bWorker = new BackgroundWorker();
bWorker.DoWork += CheckForUpdate;
Expand Down
2 changes: 1 addition & 1 deletion RocksmithTookitGUI/Properties/AssemblyInfo.cs
Expand Up @@ -29,6 +29,6 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.8.4.1")]
[assembly: AssemblyInformationalVersion("5451e04a")]
[assembly: AssemblyInformationalVersion("69972b7e")]
[assembly: AssemblyConfiguration("BETA")]
[assembly: NeutralResourcesLanguageAttribute("en")]
Binary file modified RocksmithTookitGUI/Resources/BetaInfo.rtf
Binary file not shown.
2 changes: 1 addition & 1 deletion RocksmithToolkitLib/Properties/AssemblyInfo.cs
Expand Up @@ -27,6 +27,6 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.8.4.1")]
[assembly: AssemblyInformationalVersion("5451e04a")]
[assembly: AssemblyInformationalVersion("69972b7e")]
[assembly: AssemblyConfiguration("BETA")]
[assembly: NeutralResourcesLanguageAttribute("en")]
8 changes: 4 additions & 4 deletions RocksmithToolkitLib/RocksmithToolkitLib.Config.xml
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ArrayOfConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- general config key count = 16 -->"
<Config Key="general_configversion" Value="1" />
<!-- general config key count = 17 -->"
<Config Key="general_configversion" Value="2" />
<Config Key="general_firstrun" Value="true" />
<Config Key="general_showrevnote" Value="true" />
<Config Key="general_autoupdate" Value="false" />
<Config Key="general_usebeta" Value="true" />
<Config Key="general_replacerepo" Value="false" />
<Config Key="general_replacerepo" Value="true" />
<Config Key="general_urllastestrelease" Value="https://www.rscustom.net/builds/latest" />
<Config Key="general_urllastestbuild" Value="https://www.rscustom.net/builds/latest_test" />
<Config Key="general_defaultappid_RS2012" Value="206102" />
Expand All @@ -27,7 +28,6 @@
<Config Key="creator_fixmultitone" Value="true" />
<Config Key="creator_fixlowbass" Value="true" />
<Config Key="creator_autosavetemplate" Value="true" />

<!-- converter config key count = 2 -->"
<Config Key="converter_source" Value="Pc" />
<Config Key="converter_target" Value="XBox360" />
Expand Down
5 changes: 5 additions & 0 deletions RocksmithToolkitLib/XmlRepository/ConfigRepository.cs
Expand Up @@ -65,6 +65,11 @@ public bool ValueChanged(string configKey, object value)
return true;
}

public string GetString(string configKey) // used by AugoUpdater and AssemblyCaller maybe there's better way
{
return (string)(List.FirstOrDefault(s => s.Key == configKey).Value).ToString();
}

public bool GetBoolean(string configKey)
{
return Convert.ToBoolean(List.FirstOrDefault(s => s.Key == configKey).Value);
Expand Down
2 changes: 2 additions & 0 deletions RocksmithToolkitLib/XmlRepository/ConfigVersion.cs
Expand Up @@ -5,6 +5,8 @@ namespace RocksmithToolkitLib.XmlRepository
{
public static class ConfigVersion
{
// used to force RocksmithToolkitUpdater
// to do a fresh install of RocksmithToolkitLib.*.xml
public static string Version { get; set; }
}
}
10 changes: 7 additions & 3 deletions RocksmithToolkitUpdater/AssemblyCaller.cs
@@ -1,23 +1,27 @@
using System;
using System.Linq;
using System.Reflection;
using System.Diagnostics;

namespace RocksmithToolkitUpdater
{
public class AssemblyCaller : MarshalByRefObject
{
private const string UPDATER_DOMAIN = "UpdaterDomain";

public static object CallStatic(string assemblyPath, string typeName, string method, params object[] methodParams) {
public static object CallStatic(string assemblyPath, string typeName, string method, params object[] methodParams)
{
return Call(assemblyPath, typeName, method, null, true, methodParams);
}

public static object Call(string assemblyPath, string typeName, string method, Type[] paramTypes, params object[] methodParams) {
public static object Call(string assemblyPath, string typeName, string method, Type[] paramTypes, params object[] methodParams)
{
return Call(assemblyPath, typeName, method, paramTypes, false, methodParams);
}

// EXECUTE METHOD IN LIBS WITHOUT LOCK FILE
private static object Call(string assemblyPath, string typeName, string method, Type[] paramTypes, bool createInstance, params object[] methodParams) {
private static object Call(string assemblyPath, string typeName, string method, Type[] paramTypes, bool createInstance, params object[] methodParams)
{
AppDomain domain = AppDomain.CreateDomain(UPDATER_DOMAIN);
AssemblyCaller assemblyCaller = new AssemblyCaller();
assemblyCaller = (AssemblyCaller)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(AssemblyCaller).FullName);
Expand Down
6 changes: 4 additions & 2 deletions RocksmithToolkitUpdater/AutoUpdater.cs
Expand Up @@ -37,12 +37,14 @@ private string FileUrl
}

private bool? _replaceRepo;
private bool ReplaceRepo
public bool ReplaceRepo
{
get
{
// TODO: test and dubug new code
var configVers = (string)AssemblyCaller.CallStatic(Path.Combine(workDir, APP_RSLIB), "RocksmithToolkitLib.XmlRepository.ConfigRepository", "", "general_configversion");
// hacked together GetString method to avoid null exceptions
var configVers = (string)AssemblyCaller.CallStatic(Path.Combine(workDir, APP_RSLIB), "RocksmithToolkitLib.XmlRepository.ConfigRepository", "GetString", "general_configversion");

if (String.IsNullOrEmpty(configVers))
_replaceRepo = true;
else if (configVers != ConfigVersion.Version)
Expand Down
2 changes: 1 addition & 1 deletion RocksmithToolkitUpdater/Properties/AssemblyInfo.cs
Expand Up @@ -29,6 +29,6 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.8.4.1")]
[assembly: AssemblyInformationalVersion("5451e04a")]
[assembly: AssemblyInformationalVersion("69972b7e")]
[assembly: AssemblyConfiguration("BETA")]
[assembly: NeutralResourcesLanguageAttribute("en")]
2 changes: 1 addition & 1 deletion VersionInfo.txt
@@ -1,3 +1,3 @@
2.8.4.1
5451e04a
69972b7e
BETA

0 comments on commit 960f901

Please sign in to comment.