Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Resources/GameData/kOS/Parts/kOSMachine0m/part.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PART
MODULE
{
name = kOSProcessor
diskSpace = 5000
diskSpace = 4096
ECPerBytePerSecond = 0
ECPerInstruction = 0.000004
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/GameData/kOS/Parts/kOSMachine0mLegacy/part.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PART
MODULE
{
name = kOSProcessor
diskSpace = 5000
diskSpace = 4096
}

RESOURCE
Expand Down
2 changes: 1 addition & 1 deletion Resources/GameData/kOS/Parts/kOSMachine1m/part.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PART
MODULE
{
name = kOSProcessor
diskSpace = 10000
diskSpace = 8192
ECPerBytePerSecond = 0
ECPerInstruction = 0.000004
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/GameData/kOS/Parts/kOSMachineRad/part.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PART
MODULE
{
name = kOSProcessor
diskSpace = 60000
diskSpace = 65568
ECPerBytePerSecond = 0
ECPerInstruction = 0.000004
}
Expand Down
38 changes: 25 additions & 13 deletions src/kOS/Module/kOSProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public string Tag
[KSPField(isPersistant = true, guiName = "kOS Base Module Mass", guiActive = false, groupName = PAWGroup, groupDisplayName = PAWGroup)]
public float baseModuleMass = 0F; // this is the base mass added to a part for including the kOSProcessor, default to 0.

[KSPField(isPersistant = false, guiName = "kOS Disk Space", guiActive = false, guiActiveEditor = true, groupName = PAWGroup, groupDisplayName = PAWGroup), UI_ChooseOption(scene = UI_Scene.Editor)]
public string diskSpaceUI = "1024";
[KSPField(isPersistant = false, guiName = "kOS Disk Space", guiActive = false, guiActiveEditor = true, groupName = PAWGroup, groupDisplayName = PAWGroup), UI_FloatRange(scene = UI_Scene.Editor)]
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 --> raised to 2048 to mimich Apollo

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

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

[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
public float diskSpaceMassFactor = 0.0000000048829F; //implies approx 0.020kg for 4096bytes of diskSpace
Expand All @@ -134,7 +134,7 @@ public string Tag
// IMPORTANT: The value defaults to zero and must be overriden in the module
// definition for any given part (within the part.cfg file).
[KSPField(isPersistant = true, guiActive = false)]
public float ECPerBytePerSecond = 0F;
public float ECPerBytePerSecond = 0.000002F; //needs tuning, MM can be used for more modern specs

public kOSProcessor()
{
Expand Down Expand Up @@ -373,14 +373,25 @@ private void UpdateRP1TechLevel(bool InEditor)
private void PopulateDiskSpaceUI()
{
//populate diskSpaceUI selector
diskSpaceUI = diskSpace.ToString();
// Set the initial value to current disk space
diskSpaceUI = diskSpace;

// Get the field and setup the slider
BaseField field = Fields["diskSpaceUI"];
UI_ChooseOption options = (UI_ChooseOption)field.uiControlEditor;
var sizeOptions = new string[3];
sizeOptions[0] = baseDiskSpace.ToString();
sizeOptions[1] = (baseDiskSpace * 2).ToString();
sizeOptions[2] = (baseDiskSpace * 4).ToString();
options.options = sizeOptions;


UI_FloatRange slider = new UI_FloatRange
{
minValue = baseDiskSpace,
maxValue = baseDiskSpace * 8, //Set i Little higher based on what nasa flew with read only ROM space (4kb is rough and read only doesnt exist in KOS)
stepIncrement = baseDiskSpace / 8f,
scene = UI_Scene.Editor
};

//These should be here, yes they are declared above but this is good practice to include parms when making the ui object
field.uiControlEditor = slider;
field.guiActiveEditor = true;
field.guiName = "KOS Disk Space";
}

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