Skip to content

Commit

Permalink
Replaced unnessicarily complex Abstract Class for initializing categ…
Browse files Browse the repository at this point in the history
…ory with simpler code

 Made KBFilter non-destroyable
  • Loading branch information
linuxgurugamer committed Aug 5, 2024
1 parent 038e10e commit 52f2f98
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ChangeLog

0.6.0
Replaced unnessicarily complex Abstract Class for initializing category with simpler code
Made KBFilter non-destroyable

0.5.0.15
Thanks to github user @Clayell for this:
Fixes some typos and grammar
Expand Down Expand Up @@ -62,4 +66,5 @@ ChangeLog
ClickThroughBlocker
ToolbarController
B9PartSwitch
SpaceTuxLibrary
SpaceTuxLibrary

52 changes: 26 additions & 26 deletions GameData/KerBalloons/KerBalloons.version
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"NAME": "KerBalloons",
"URL": "http://ksp.spacetux.net/avc/KerBalloons",
"DOWNLOAD": "https://github.com/linuxgurugamer/KerBalloons/releases",
"GITHUB": {
"USERNAME": "linuxgurugamer",
"REPOSITORY": "KerBalloons",
"ALLOW_PRE_RELEASE": false
},
"VERSION": {
"MAJOR": 0,
"MINOR": 5,
"PATCH": 0,
"BUILD": 7
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 8,
"PATCH": 0
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 8,
"PATCH": 0
}
}
{
"NAME": "KerBalloons",
"URL": "http://ksp.spacetux.net/avc/KerBalloons",
"DOWNLOAD": "https://github.com/linuxgurugamer/KerBalloons/releases",
"GITHUB": {
"USERNAME": "linuxgurugamer",
"REPOSITORY": "KerBalloons",
"ALLOW_PRE_RELEASE": false
},
"VERSION": {
"MAJOR": 0,
"MINOR": 6,
"PATCH": 0,
"BUILD": 0
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 12,
"PATCH": 4
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 12,
"PATCH": 0
}
}
9 changes: 7 additions & 2 deletions KerBalloons.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
},
"VERSION": {
"MAJOR": 0,
"MINOR": 5,
"MINOR": 6,
"PATCH": 0,
"BUILD": 15
"BUILD": 0
},
"KSP_VERSION": {
"MAJOR": 1,
Expand All @@ -22,5 +22,10 @@
"MAJOR": 1,
"MINOR": 12,
"PATCH": 0
},
"KSP_VERSION_MAX": {
"MAJOR": 1,
"MINOR": 12,
"PATCH": 99
}
}
4 changes: 2 additions & 2 deletions Kerballoons/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

using System.Reflection;

[assembly: AssemblyVersion("0.5.0.9")]
[assembly: AssemblyFileVersion("0.5.0.9")]
[assembly: AssemblyVersion("0.6.0.0")]
[assembly: AssemblyFileVersion("0.6.0.0")]
36 changes: 15 additions & 21 deletions Kerballoons/KerBalloonsCatagory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,28 @@
using UnityEngine;
using ToolbarControl_NS;

using KSP_Log;

namespace Kerballoons
{

[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class KBFilter : BaseFilter
public class KBFilter : MonoBehaviour
{
protected override string Manufacturer
private readonly List<AvailablePart> parts = new List<AvailablePart>();
internal string category = "Filter by function";
internal bool filter = true;

protected string Manufacturer
{
get { return "KerBalloons"; }// part manufacturer in cfgs and agents files
set { }
}
protected override string categoryTitle
protected string categoryTitle
{
get { return "KerBalloons"; } // the category name
set { }
}
}

public abstract class BaseFilter : MonoBehaviour
{
private readonly List<AvailablePart> parts = new List<AvailablePart>();
internal string category = "Filter by function";
internal bool filter = true;
protected abstract string Manufacturer { get; set; }
protected abstract string categoryTitle { get; set; }

void Awake()
{
Expand All @@ -47,14 +44,18 @@ void Awake()
}
if (parts.Count > 0)
GameEvents.onGUIEditorToolbarReady.Add(SubCategories);
DontDestroyOnLoad(this);

}

#if false
void OnDestroy()
{
if (parts.Count > 0)
GameEvents.onGUIEditorToolbarReady.Remove(SubCategories);

}
#endif

private bool EditorItemsFilter(AvailablePart avPart)
{
Expand All @@ -70,15 +71,8 @@ private void SubCategories()

private Icon GetIcon(string iconName)
{
#if false
var normIcon = new Texture2D(32, 32, TextureFormat.RGBA32, false);
var normIconFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), iconName + "_off.png"); // icon to be present in same folder as dll
WWW www = new WWW(normIconFile);
www.LoadImageIntoTexture(normIcon);
#endif
Texture2D normIcon = new Texture2D(2,2);

if (!ToolbarControl.LoadImageFromFile(ref normIcon, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)+ "/../PluginData/"+ iconName + "_off.png"))
Texture2D normIcon = new Texture2D(2, 2);
if (!ToolbarControl.LoadImageFromFile(ref normIcon, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../PluginData/" + iconName + "_off.png"))
{
Debug.Log("Error loading: " + iconName + "_off.png");
}
Expand Down

0 comments on commit 52f2f98

Please sign in to comment.