Skip to content

Commit

Permalink
1.8 Support + Release Prep
Browse files Browse the repository at this point in the history
  • Loading branch information
DRVeyl authored and DRVeyl committed Apr 4, 2020
2 parents 78581fb + 3975add commit f639a0a
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 482 deletions.
Binary file modified GameData/ROLib/Plugins/ROLib.dll
Binary file not shown.
16 changes: 8 additions & 8 deletions GameData/ROLib/ROLib.version
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
"ALLOW_PRE_RELEASE" : false
},
"VERSION" : {
"MAJOR" : 0,
"MINOR" : 4,
"MAJOR" : 1,
"MINOR" : 0,
"PATCH" : 0,
"BUILD" : 0
},
"KSP_VERSION" : {
"MAJOR": "1",
"MINOR": "7",
"PATCH": "3"
"MINOR": "8",
"PATCH": "1"
},
"KSP_VERSION_MIN": {
"MAJOR": "1",
"MINOR": "7",
"PATCH": "3"
"MINOR": "8",
"PATCH": "1"
},
"KSP_VERSION_MAX": {
"MAJOR": "1",
"MINOR": "7",
"PATCH": "3"
"MINOR": "9",
"PATCH": "99"
}
}
43 changes: 16 additions & 27 deletions Source/ROLib/ModelDef/ROLModelModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public void textureSetSelected(BaseField field, System.Object oldValue)
m.applyTextureSet(m.textureSetName, !ROLGameSettings.persistRecolor());
if (m.textureField != null)
{
m.partModule.ROLupdateUIChooseOptionControl(m.textureField.name, m.definition.getTextureSetNames(), m.definition.getTextureSetTitles(), true, m.textureSetName);
m.partModule.ROLupdateUIChooseOptionControl(m.textureField.name, m.definition.getTextureSetNames(), m.definition.getTextureSetTitles());
}
});
}
Expand Down Expand Up @@ -657,20 +657,20 @@ public void updateSelections()
if (availableOptions == null || availableOptions.Length < 1) { MonoBehaviour.print("ERROR: No valid models found for: " + getErrorReportModuleName()); }
string[] names = ROLUtils.getNames(availableOptions, s => s.definition.name);
string[] displays = ROLUtils.getNames(availableOptions, s => s.definition.title);
partModule.ROLupdateUIChooseOptionControl(modelField.name, names, displays, true, modelName);
partModule.ROLupdateUIChooseOptionControl(modelField.name, names, displays);
modelField.guiActiveEditor = names.Length > 1;
}
//updates the texture set selection for the currently configured model definition, including disabling of the texture-set selection UI when needed
if (textureField != null)
{
partModule.ROLupdateUIChooseOptionControl(textureField.name, definition.getTextureSetNames(), definition.getTextureSetTitles(), true, textureSetName);
partModule.ROLupdateUIChooseOptionControl(textureField.name, definition.getTextureSetNames(), definition.getTextureSetTitles());
}
if (layoutField != null)
{
ModelDefinitionLayoutOptions mdlo = optionsCache.ROLFind(m => m.definition == definition);
string[] layoutNames = mdlo.getLayoutNames();
string[] layoutTitles = mdlo.getLayoutTitles();
partModule.ROLupdateUIChooseOptionControl(layoutField.name, layoutNames, layoutTitles, true, layoutName);
partModule.ROLupdateUIChooseOptionControl(layoutField.name, layoutNames, layoutTitles);
layoutField.guiActiveEditor = layoutField.guiActiveEditor && currentLayout.positions.Length > 1;
}
}
Expand Down Expand Up @@ -745,7 +745,7 @@ public void setScaleForHeightAndDiameter(float newHeight, float newDiameter)
/// <param name="newDiameter"></param>
public void setScaleForHeightAndDiameter(float newHeight, float newDiameter, bool solar)
{
float newHorizScale, newVertScale = 0.0f;
float newHorizScale, newVertScale;
if (solar)
{
newHorizScale = newDiameter / definition.panelWidth;
Expand Down Expand Up @@ -847,7 +847,7 @@ public void updateTextureUIControl()
if (textureField == null) { return; }
string[] names = definition.getTextureSetNames();
string[] titles = definition.getTextureSetTitles();
partModule.ROLupdateUIChooseOptionControl(textureField.name, names, titles, true, textureSetName);
partModule.ROLupdateUIChooseOptionControl(textureField.name, names, titles);
textureField.guiActiveEditor = names.Length > 1;
}

Expand All @@ -872,25 +872,19 @@ public void updateAttachNodeBody(String[] nodeNames, bool userInput)
if (nodeNames.Length == 1 && (nodeNames[0] == "NONE" || nodeNames[0] == "none")) { return; }
float currentVerticalPosition = this.currentVerticalPosition;

AttachNode node = null;
AttachNodeBaseData data;

Vector3 pos = Vector3.zero;
Vector3 orient = Vector3.up;
int size = 4;

bool invert = definition.shouldInvert(orientation);

int nodeCount = definition.bodyNodeData == null ? 0 : definition.bodyNodeData.Length;
int len = nodeNames.Length;
for (int i = 0; i < len; i++)
{
node = part.FindAttachNode(nodeNames[i]);
AttachNode node = part.FindAttachNode(nodeNames[i]);
if (i < nodeCount)
{
data = definition.bodyNodeData[i];
size = Mathf.RoundToInt(data.size * currentHorizontalScale);
pos = data.position;
int size = Mathf.RoundToInt(data.size * currentHorizontalScale);
Vector3 pos = data.position;
pos.y *= currentVerticalScale;
pos.x *= currentHorizontalScale;
pos.z *= currentHorizontalScale;
Expand All @@ -900,7 +894,7 @@ public void updateAttachNodeBody(String[] nodeNames, bool userInput)
pos.x = -pos.x;
}
pos.y += currentVerticalPosition;
orient = data.orientation;
Vector3 orient = data.orientation;
if (invert) { orient = -orient; orient.z = -orient.z; }
if (node == null)//create it
{
Expand Down Expand Up @@ -1070,8 +1064,8 @@ private void saveColors(RecoloringData[] colors)
string data = string.Empty;
for (int i = 0; i < len; i++)
{
if (i > 0) { data = data + ";"; }
data = data + colors[i].getPersistentData();
if (i > 0) data += ";";
data += colors[i].getPersistentData();
}
persistentData = data;
}
Expand Down Expand Up @@ -1397,21 +1391,16 @@ public void getRCSMountingValues(float vPos, bool upper, out float radius, out f
//if (invert) { upper = !upper; }
if (currentDefinition.rcsPositionData != null)
{
ModelAttachablePositionData mapd = null;
ModelAttachablePositionData mapd;
if (upper)//always 0th index in config
{
mapd = currentDefinition.rcsPositionData[0];
}
else//if both positions specified, will always be 1st index, else 0th
{
if (currentDefinition.rcsPositionData.Length > 1)
{
mapd = currentDefinition.rcsPositionData[1];//lower def
}
else
{
mapd = currentDefinition.rcsPositionData[0];//default to upper def if no lower defined
}
// Lower definition [1] if defined, otherwise default to Upper definition [0]
int index = currentDefinition.rcsPositionData.Length > 1 ? 1 : 0;
mapd = currentDefinition.rcsPositionData[index];
}
mapd.getModelPosition(currentHorizontalScale, currentVerticalScale, vPos, invert, out radius, out posY);
posY += getPlacementOffset();
Expand Down
39 changes: 15 additions & 24 deletions Source/ROLib/Modules/ModuleROSolar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ private void ResetModel()
panelLength = coreModule.definition.panelLength;
panelWidth = coreModule.definition.panelWidth;
panelScale = 1.0f;
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep, true, panelLength);
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep, true, panelWidth);
this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep, true, panelScale);
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep);
ModelChangedHandler(true);
prevLength = panelLength;
prevWidth = panelWidth;
prevScale = panelScale;
MonoUtilities.RefreshPartContextWindow(part);
}

[KSPField] public string solarPanelType = "static";
Expand Down Expand Up @@ -270,7 +271,7 @@ public void InitializeUI()
{
// Set up the core variant UI control
string[] variantNames = ROLUtils.getNames(variantSets.Values, m => m.variantName);
this.ROLupdateUIChooseOptionControl(nameof(currentVariant), variantNames, variantNames, true, currentVariant);
this.ROLupdateUIChooseOptionControl(nameof(currentVariant), variantNames, variantNames);
Fields[nameof(currentVariant)].guiActiveEditor = variantSets.Count > 1;
Fields[nameof(currentVariant)].uiControlEditor.onFieldChanged = (a, b) =>
{
Expand Down Expand Up @@ -302,16 +303,11 @@ public void InitializeUI()
Fields[nameof(panelLength)].guiActiveEditor = lengthWidth;
Fields[nameof(panelWidth)].guiActiveEditor = lengthWidth;
Fields[nameof(panelScale)].guiActiveEditor = !lengthWidth;
if (!lengthWidth)
{
this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep, true, panelScale);
}
else
{
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep, true, panelLength);
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep, true, panelWidth);
}
this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep);
ModelChangedHandlerWithSymmetry(true, true);
MonoUtilities.RefreshPartContextWindow(part);
};

Fields[nameof(panelLength)].uiControlEditor.onFieldChanged =
Expand Down Expand Up @@ -345,23 +341,18 @@ public void InitializeUI()
};

Fields[nameof(panelScale)].guiActiveEditor = !lengthWidth;
if (!lengthWidth)
this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep, true, panelScale);
Fields[nameof(panelLength)].guiActiveEditor = (lengthWidth && maxLength != minLength);
Fields[nameof(panelWidth)].guiActiveEditor = (lengthWidth && maxLength != minLength);

this.ROLupdateUIFloatEditControl(nameof(panelScale), 0.1f, 100f, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep);
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep);

Fields[nameof(TechLevel)].uiControlEditor.onFieldChanged = (a, b) =>
{
ModelChangedHandlerWithSymmetry(true, true);
};

if (maxLength == minLength || !lengthWidth)
Fields[nameof(panelLength)].guiActiveEditor = false;
else
this.ROLupdateUIFloatEditControl(nameof(panelLength), minLength, maxLength, largeStep, smallStep, slideStep, true, panelLength);

if (maxWidth == minWidth || !lengthWidth)
Fields[nameof(panelWidth)].guiActiveEditor = false;
else
this.ROLupdateUIFloatEditControl(nameof(panelWidth), minWidth, maxWidth, largeStep, smallStep, slideStep, true, panelWidth);
}

private void SetMaxTechLevel()
Expand Down
Loading

0 comments on commit f639a0a

Please sign in to comment.