Skip to content

Commit 7c92a54

Browse files
committed
Added a 12x slider
I tested with "* 4" and it seemed a tad small for the Config tweak mod (using Patch Manager to add kos to cockpits) So Working in the Script i noticed a block of math keeping it Clamped. so i left it as 8*BaseDiskSpace and increased smoothing cost is not an issue without a tweak patch, so that has not been changed but using 1024 * 8 with extra cost would be recommended to follow IRL ByteSizes. Most parts in the KOS mod seem to rise just out of that area. i felt as if it was to limited for upgrades One last note: would recommend adjusting "public float ECPerInstruction = 0.000004F;" to 0.000008F.
1 parent 110b209 commit 7c92a54

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

src/kOS/Module/kOSProcessor.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public string Tag
101101
[KSPField(isPersistant = true, guiName = "kOS Base Module Mass", guiActive = false, groupName = PAWGroup, groupDisplayName = PAWGroup)]
102102
public float baseModuleMass = 0F; // this is the base mass added to a part for including the kOSProcessor, default to 0.
103103

104-
[KSPField(isPersistant = false, guiName = "kOS Disk Space", guiActive = false, guiActiveEditor = true, groupName = PAWGroup, groupDisplayName = PAWGroup), UI_ChooseOption(scene = UI_Scene.Editor)]
105-
public string diskSpaceUI = "1024";
104+
[KSPField(isPersistant = false, guiName = "kOS Disk Space", guiActive = false, guiActiveEditor = true, groupName = PAWGroup, groupDisplayName = PAWGroup), UI_FloatRange(scene = UI_Scene.Editor)]
105+
public float diskSpaceUI = 1024f; //needed for the slider, Could convert from String back into float or int. but works better and feels natural to have as a float to begin with
106106

107107
[KSPField(isPersistant = true, guiName = "CPU/Disk Upgrade Cost", guiActive = false, guiActiveEditor = true, groupName = PAWGroup, groupDisplayName = PAWGroup)]
108108
public float additionalCost = 0F;
@@ -111,7 +111,7 @@ public string Tag
111111
public float additionalMassGui = 0F;
112112

113113
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
114-
public float diskSpaceCostFactor = 0.0244140625F; //implies approx 100funds for 4096bytes of diskSpace
114+
public float diskSpaceCostFactor = 0.0244140625F; //implies approx 100funds for 4096bytes of diskSpace. SliderNote: would recommend a small increase to: 0.0484140625F
115115

116116
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
117117
public float diskSpaceMassFactor = 0.0000000048829F; //implies approx 0.020kg for 4096bytes of diskSpace
@@ -376,11 +376,19 @@ private void PopulateDiskSpaceUI()
376376
diskSpaceUI = diskSpace.ToString();
377377
BaseField field = Fields["diskSpaceUI"];
378378
UI_ChooseOption options = (UI_ChooseOption)field.uiControlEditor;
379-
var sizeOptions = new string[3];
380-
sizeOptions[0] = baseDiskSpace.ToString();
381-
sizeOptions[1] = (baseDiskSpace * 2).ToString();
382-
sizeOptions[2] = (baseDiskSpace * 4).ToString();
383-
options.options = sizeOptions;
379+
380+
UI_FloatRange slider = new UI_FloatRange
381+
{
382+
minValue = baseDiskSpace,
383+
maxValue = baseDiskSpace * 8,
384+
stepIncrement = baseDiskSpace / 4f,
385+
scene = UI_Scene.Editor
386+
};
387+
388+
//These should be here, yes they are declared above but this is good practice to include parms when making the ui object
389+
field.uiControlEditor = slider;
390+
field.guiActiveEditor = true;
391+
field.guiName = "KOS Disk Space";
384392
}
385393

386394
//implement IPartMassModifier component
@@ -812,9 +820,10 @@ public void Update()
812820
InitUI();
813821
}
814822
UpdateRP1TechLevel(true);
815-
if (diskSpace != Convert.ToInt32(diskSpaceUI))
823+
// This part is now just rounding from INT, this counters any issue with DiskSpace or BaseDiskSpace being incorrect or "Out of range"
824+
if (diskSpace != Mathf.RoundToInt(diskSpaceUI)) //Tested in-game, no issues found
816825
{
817-
diskSpace = Convert.ToInt32(diskSpaceUI);
826+
diskSpace = Mathf.RoundToInt(diskSpaceUI); ///Tested as well
818827
UpdateCostAndMass();
819828
GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
820829
}

0 commit comments

Comments
 (0)