Skip to content

Commit

Permalink
Merge pull request #383 from ihsoft/next
Browse files Browse the repository at this point in the history
Release v1.28
  • Loading branch information
ihsoft authored Jan 16, 2021
2 parents a20ada1 + ecb9464 commit 3530848
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 36 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.28 (January 15th, 2021):
* [Fix #378] Dropped parts cannot be moved or trigger physics.
* [Fix #379] KIS functionality interferes with the stock construction mode.
* [Fix #380] Model equippable parts cannot be carried.
* [Fix #381] Hide UI command doesn't play well with KIS.
* [Fix #382] Static attach doesn't verify which joint is broken.

# 1.27 (December 23rd, 2020):
* [Enhancement] Check for colliders when node attaching a part.
* [Enhancement] Add KIS inventory to the stock inventory parts: SEQ-9 & SEQ-24.
Expand Down
6 changes: 3 additions & 3 deletions KIS.version
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"NAME": "Kerbal Inventory System",
"URL": "https://raw.githubusercontent.com/ihsoft/KIS/master/KIS.version",
"VERSION": {
"BUILD": 37622,
"BUILD": 40880,
"MAJOR": 1,
"MINOR": 27,
"PATCH": 7662
"MINOR": 28,
"PATCH": 7685
}
}
44 changes: 39 additions & 5 deletions Source/KISAddonPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,30 @@ public enum PointerState {
}
private static OnPointerState SendPointerState;

#region MonoBehaviour methods
void Awake() {
GameEvents.onHideUI.Add(HideUI);
GameEvents.OnEVAConstructionMode.Add(OnConstructionModeChange);
}

void OnDestroy() {
GameEvents.onHideUI.Remove(HideUI);
GameEvents.OnEVAConstructionMode.Remove(OnConstructionModeChange);
}

void HideUI() {
DebugEx.Info("Stop KIS behavior due to HIDE UI command");
CancelPointer(null);
}

void OnConstructionModeChange(bool open) {
if (open) {
DebugEx.Info("Stop KIS behavior due to construct mode");
CancelPointer(null);
}
}
#endregion

public delegate void OnPointerState(PointerTarget pTarget, PointerState pState,
Part hoverPart, AttachNode hoverNode);

Expand Down Expand Up @@ -295,7 +319,7 @@ public static void StopPointer(bool unlockUI = true) {
DebugEx.Fine("StopPointer()");
running = false;
ResetMouseOver();
SendPointerState(PointerTarget.Nothing, PointerState.OnPointerStopped, null, null);
SendPointerState?.Invoke(PointerTarget.Nothing, PointerState.OnPointerStopped, null, null);
if (unlockUI) {
UnlockUI();
}
Expand Down Expand Up @@ -679,15 +703,25 @@ public void UpdatePointer() {
}
}

/// <summary>Cancels the drag mode if one was active.</summary>
public static void CancelPointer(MonoBehaviour waitForObject) {
if (waitForObject == null) {
StopPointer();
SendPointerClick?.Invoke(PointerTarget.Nothing, Vector3.zero, Quaternion.identity, null, null);
} else {
// Delay UI unlocking to prevent key bindings side effects.
StopPointer(unlockUI: false);
SendPointerClick?.Invoke(PointerTarget.Nothing, Vector3.zero, Quaternion.identity, null, null);
AsyncCall.CallOnEndOfFrame(waitForObject, UnlockUI);
}
}

/// <summary>Handles keyboard input.</summary>
private void UpdateKey() {
if (isRunning) {
if (KIS_Shared.IsKeyUp(KeyCode.Escape) || KIS_Shared.IsKeyDown(KeyCode.Return)) {
DebugEx.Fine("Cancel key pressed, stop eva attach mode");
StopPointer(unlockUI: false);
SendPointerClick(PointerTarget.Nothing, Vector3.zero, Quaternion.identity, null, null);
// Delay unlocking to not let ESC be handled by the game.
AsyncCall.CallOnEndOfFrame(this, UnlockUI);
CancelPointer(this);
}
if (GameSettings.Editor_toggleSymMethod.GetKeyDown()) { // "R" by default.
if (pointerTarget != PointerTarget.PartMount && attachNodes.Count() > 1) {
Expand Down
17 changes: 5 additions & 12 deletions Source/KIS_Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,8 @@ public ActionType shortcutAction {
}
}

public bool carried {
get {
if (carriable && inventory.invType == ModuleKISInventory.InventoryType.Eva
&& HighLogic.LoadedSceneIsFlight) {
return true;
}
return false;
}
}
public bool carried =>
carriable && inventory.invType == ModuleKISInventory.InventoryType.Eva && HighLogic.LoadedSceneIsFlight;

/// <summary>Creates an item, restored form the save file.</summary>
/// <param name="itemNode">The item config node to load the data from.</param>
Expand Down Expand Up @@ -696,7 +689,8 @@ IEnumerator AlignEquippedPart() {
var lastMass = totalSlotMass;
var lastCost = totalSlotCost;
while (equippedGameObj != null && evaTransform != null) {
if (carried && lastUpdated + 0.1f < Time.unscaledTime) {
// The carried parts may have their content changed if equipped in mode "part".
if (carried && equippedPart != null && lastUpdated + 0.1f < Time.unscaledTime) {
lastUpdated = Time.unscaledTime;
CaptureItemStateFromPart(equippedPart);
if (!Mathd.AreSame(lastMass, totalSlotMass) || !Mathd.AreSame(lastCost, totalSlotCost)) {
Expand Down Expand Up @@ -733,8 +727,7 @@ void CaptureItemStateFromPart(Part copyFrom) {
// Don't trust the part's mass. It can be affected by too many factors.
_itemDryMass = copyFrom.partInfo.partPrefab.mass
+ copyFrom.GetModuleMass(copyFrom.partInfo.partPrefab.mass);
_itemDryCost = copyFrom.partInfo.cost
+ copyFrom.GetModuleCosts(copyFrom.partInfo.cost);
_itemDryCost = copyFrom.partInfo.cost + copyFrom.GetModuleCosts(copyFrom.partInfo.cost);
_resourceMass = 0;
_resourceCost = 0;
foreach (var resource in copyFrom.Resources) {
Expand Down
8 changes: 8 additions & 0 deletions Source/KIS_Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,14 @@ public static void MoveAssembly(Part assemblyRoot, string srcAttachNodeId,
/// </param>
public static void PlaceVessel(
Vessel movingVessel, Vector3 newPosition, Quaternion newRotation, Vessel refVessel) {
// Find and destroy static attach joints that game applies to fix the vessels on the ground.
foreach (var joint in movingVessel.rootPart.gameObject.GetComponents<Joint>()) {
if (joint.connectedBody == null) {
DebugEx.Fine("Dropping vessel static attach joint");
// The joint will be automatically re-created once the vessel is moved.
GameObject.DestroyImmediate(joint);
}
}
movingVessel.SetPosition(newPosition, usePristineCoords: true);
movingVessel.SetRotation(newRotation);
var refVelocity = Vector3.zero;
Expand Down
8 changes: 7 additions & 1 deletion Source/ModuleKISInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP.UI;
using UnityEngine;

namespace KIS {
Expand Down Expand Up @@ -1214,7 +1215,9 @@ void GUIStyles() {
}

void OnGUI() {
if (!showGui) {
if (!showGui
|| EVAConstructionModeController.Instance != null && EVAConstructionModeController.Instance.IsOpen
|| !UIMasterController.Instance.IsUIShowing) {
return;
}

Expand Down Expand Up @@ -1896,6 +1899,9 @@ void OnHelmetChanged(KerbalEVA changedKerbal, bool helmetVisible, bool neckRingV
}

void UpdateKey() {
if (EVAConstructionModeController.Instance != null && EVAConstructionModeController.Instance.IsOpen) {
return;
}
if (invType != InventoryType.Eva
|| !HighLogic.LoadedSceneIsFlight
|| FlightGlobals.ActiveVessel != part.vessel
Expand Down
13 changes: 7 additions & 6 deletions Source/ModuleKISItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,13 @@ IEnumerator WaitAndStaticAttach() {
// Resets item state when joint is broken.
// A callback from MonoBehaviour.
void OnJointBreak(float breakForce) {
if (staticAttached) {
HostedDebugLog.Warning(this, "A static joint has just been broken! Force: {0}", breakForce);
} else {
HostedDebugLog.Warning(this, "A fixed joint has just been broken! Force: {0}", breakForce);
}
GroundDetach();
AsyncCall.CallOnFixedUpdate(this, () => {
// Verify if it was our joint broken.
if (staticAttached && staticAttachJoint == null) {
HostedDebugLog.Warning(this, "A static joint has just been broken! Force: {0}", breakForce);
GroundDetach();
}
});
}
#endregion
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion ("1.27.*")]
[assembly: AssemblyInformationalVersion ("1.27 for KSP v1")]
[assembly: KSPAssembly ("KIS", 1, 27)]
[assembly: AssemblyVersion ("1.28.*")]
[assembly: AssemblyInformationalVersion ("1.28 for KSP v1.11+")]
[assembly: KSPAssembly ("KIS", 1, 28)]
3 changes: 3 additions & 0 deletions Tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Requirements

* The v15.0 version of `MSBuild`: (get it from here)[https://www.visualstudio.com/downloads/].
16 changes: 12 additions & 4 deletions Tools/clients/CurseForgeClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import os.path
import re
import ssl
import urllib2

from utils import FormDataUtil
Expand All @@ -38,6 +39,8 @@
API_GET_VERSIONS = '/api/game/versions'
# The project details are not available via the stock API. So using CFWidgets.
API_GET_PROJECT = 'https://api.cfwidget.com/project/{project_id}'
# The user agent ID to use to make calls to the backend. Cloudflare doesn't accept empty values.
USER_AGENT = 'KSPDevReleaseScript'

LOGGER = logging.getLogger('ApiClient')

Expand Down Expand Up @@ -169,18 +172,23 @@ def UploadFile(project_id, filepath, changelog, game_versions,

def _CallAPI(url, data, headers, raise_on_error=True):
"""Invokes the API call."""
headers = headers or {}
if 'user-agent' not in headers:
headers['user-agent'] = USER_AGENT
resp_obj = { 'error': True, 'reason': 'unknown' }
try:
request = urllib2.Request(url, data, headers=headers or {})
response = urllib2.urlopen(request)
request = urllib2.Request(url, data, headers=headers)
gcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
response = urllib2.urlopen(request, context=gcontext)
resp_obj = json.loads(response.read())
headers = response.info().dict
except urllib2.HTTPError as ex:
resp_obj = { 'error': True, 'reason': '%d - %s' % (ex.code, ex.reason) }
try:
resp_obj = json.loads(ex.read())
except:
pass # Not a JSON response
except Exception as e:
if 'errorMessage' not in resp_obj:
resp_obj['errorMessage'] = str(e)
if ex.code == 401:
raise AuthorizationRequiredError(resp_obj['errorMessage'])
if ex.code == 403:
Expand Down
3 changes: 1 addition & 2 deletions Tools/release_setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"{COMPILED_BINARY}",
"?{MINIAVC_VERSION_FILE}",
"/Binaries/MiniAVC-V2.dll",
"/Binaries/KSPDev_Utils*",
"-KSP-AVC-V2.version"
"/Binaries/KSPDev_Utils*"
]
}
}

0 comments on commit 3530848

Please sign in to comment.