Skip to content

Commit

Permalink
Fixed issue where changing the FocusFollowsClick in the settings was…
Browse files Browse the repository at this point in the history
…n't being saved properly

 Fixed issue where changing the global setting in the settings wasn't being honored
  • Loading branch information
linuxgurugamer committed Dec 25, 2022
1 parent 47d61fa commit 811693e
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ChangeLog

2.1.10.19
Fixed issue where changing the FocusFollowsClick in the settings wasn't being saved properly
Fixed issue where changing the global setting in the settings wasn't being honored

2.1.10.18
Fixed a memory leak where two game events were beiing used, added a DontDestroyOnLoad to RegisterToolbar
Updated version number to avoid dependency issues
Expand Down
2 changes: 1 addition & 1 deletion ClickThroughBlocker.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 2,
"MINOR": 1,
"PATCH": 10,
"BUILD": 18
"BUILD": 19
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
Expand Down
5 changes: 3 additions & 2 deletions ClickThroughBlocker/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

using System.Reflection;

[assembly: AssemblyVersion("1.1.10.17")]
[assembly: AssemblyFileVersion("1.1.10.17")]
[assembly: AssemblyVersion("2.1.10.18")]
[assembly: AssemblyFileVersion("2.1.10.18")]
[assembly: KSPAssembly("ClickThroughBlocker", 2, 1, 0)]
1 change: 1 addition & 0 deletions ClickThroughBlocker/AssemblyVersion.tt
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
[assembly: KSPAssembly("ClickThroughBlocker", <#= major #>, <#= minor #>, 0)]
8 changes: 5 additions & 3 deletions ClickThroughBlocker/ClickThroughBlocker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@
<LastGenOutput>AssemblyVersion.cs</LastGenOutput>
</Content>
</ItemGroup>

<ItemGroup>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\Assembly*.dll">
<Private>False</Private>
</Reference>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\UnityEngine*.dll">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="ToolbarControl">
<HintPath>$(KSPDIR)\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down Expand Up @@ -116,4 +118,4 @@ if $(ConfigurationName) == Release (
<PreBuildEvent>
"$(DevEnvDir)\texttransform.exe" "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
</PropertyGroup>
</Project>
</Project>
16 changes: 11 additions & 5 deletions ClickThroughBlocker/OneTimePopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void PopUpWindow(int id)
GUILayout.BeginHorizontal();
if (GUILayout.Button("Save as global default for all new saves"))
{
SaveGlobalDefault();
SaveGlobalDefault(focusFollowsClick);
}
if (GUILayout.Button("Accept"))
{
Expand Down Expand Up @@ -140,21 +140,27 @@ static string GlobalDefaultFile
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../Global.cfg";
}
}
void SaveGlobalDefault()
static internal void SaveGlobalDefault(bool focusFollowsClick)
{
ConfigNode node = new ConfigNode();
node.AddValue("focusFollowsClick", focusFollowsClick);
node.Save(GlobalDefaultFile);
}

static internal bool GetGlobalDefault(ref bool b)
{
if (System.IO.File.Exists(GlobalDefaultFile))
{
ConfigNode node = ConfigNode.Load(GlobalDefaultFile);
if (node.TryGetValue("focusFollowsClick", ref b))
if (HighLogic.CurrentGame.Parameters.CustomParams<CTB>().global)
{
return true;
ConfigNode node = ConfigNode.Load(GlobalDefaultFile);
if (node.TryGetValue("focusFollowsClick", ref b))
{
return true;
}
}
else
return HighLogic.CurrentGame.Parameters.CustomParams<CTB>().focusFollowsclick;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion ClickThroughBlocker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
//[assembly: KSPAssembly("ClickThroughBlocker",1, 8, 0)]
//[assembly: AssemblyVersion("0.1.7.0")]
//[assembly: KSPAssembly("ClickThroughBlocker", 1, 8, 0)]

8 changes: 7 additions & 1 deletion ClickThroughBlocker/RegisterToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ void Start()
ToolbarControl.RegisterMod(ClearInputLocks.MODID2, ClearInputLocks.MODNAME2);
GameEvents.onGameNewStart.Add(OnGameNewStart);
GameEvents.onGameStateCreated.Add(OnGameStateCreated);
GameEvents.OnGameSettingsWritten.Add(OnGameSettingsWritten);
DontDestroyOnLoad(this);
}
void OnGameSettingsWritten()
{
if (HighLogic.CurrentGame.Parameters.CustomParams<CTB>().global)
OneTimePopup.SaveGlobalDefault (HighLogic.CurrentGame.Parameters.CustomParams<CTB>().focusFollowsclick);
}

void OnGameNewStart()
{
bool b = false ;
bool b = false;
if (OneTimePopup.GetGlobalDefault(ref b))
{
HighLogic.CurrentGame.Parameters.CustomParams<CTB>().focusFollowsclick = b;
Expand Down
4 changes: 2 additions & 2 deletions GameData/000_ClickThroughBlocker/ClickThroughBlocker.version
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"REPOSITORY": "ClickThroughBlocker"
},
"VERSION": {
"MAJOR": 1,
"MAJOR": 2,
"MINOR": 1,
"PATCH": 10,
"BUILD": 17
"BUILD": 18
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
Expand Down
14 changes: 12 additions & 2 deletions GameData/000_ClickThroughBlocker/changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ KERBALCHANGELOG
author = Linuxgurugamer




VERSION
{
version = 2.1.10.18
CHANGE
{
change = Fixed a memory leak where two game events were being used, added a DontDestroyOnLoad to RegisterToolbar
change = Updated version number to avoid dependency issues
type = update
}
}
VERSION
{
version = 0.1.10.17
CHANGE
{
change - Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
change = Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
change = Added InstallChecker to ensure installation into correct directory
type = update
}
Expand Down
11 changes: 11 additions & 0 deletions changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ KERBALCHANGELOG



VERSION
{
version = 2.1.10.19
CHANGE
{
change = Fixed issue where changing the FocusFollowsClick in the settings wasn't being saved properly
change = Fixed issue where changing the global setting in the settings wasn't being honored

type = update
}
}
VERSION
{
version = 2.1.10.18
Expand Down
2 changes: 2 additions & 0 deletions deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ rem but not always

set H=%KSPDIR%

set H=R:\KSP_1.12.4

set GAMEDIR=000_ClickThroughBlocker
set GAMEDATA=GameData
set VERSIONFILE=ClickThroughBlocker.version
Expand Down

0 comments on commit 811693e

Please sign in to comment.