From df2f9ae0a0d0745cd1d5d12b7f836e625e13ac5c Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Tue, 12 Jan 2021 00:48:02 -0800 Subject: [PATCH 01/10] Fix #380 --- Source/KIS_Item.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/KIS_Item.cs b/Source/KIS_Item.cs index 0ce731a2..79114a34 100644 --- a/Source/KIS_Item.cs +++ b/Source/KIS_Item.cs @@ -696,7 +696,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)) { From a7cddb44912664a8a8579e527071dfcfed935c16 Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Tue, 12 Jan 2021 00:48:31 -0800 Subject: [PATCH 02/10] Minor style refatcoring --- Source/KIS_Item.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Source/KIS_Item.cs b/Source/KIS_Item.cs index 79114a34..73559fcf 100644 --- a/Source/KIS_Item.cs +++ b/Source/KIS_Item.cs @@ -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; /// Creates an item, restored form the save file. /// The item config node to load the data from. @@ -734,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) { From 0a686e5ba070a6273a433ee9a080e5224eaed30e Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Tue, 12 Jan 2021 19:39:53 -0800 Subject: [PATCH 03/10] Start v1.28 --- CHANGELOG.md | 3 +++ Source/Properties/AssemblyInfo.cs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 941bb35e..b3a9d1e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.28 (pre-release): +* [Fix #380] Model equippable parts cannot be carried. + # 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. diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 960fea96..509edc98 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -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)] From 41f4f751f32cf907bff27b1cd2ebcaa4157306fc Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:23:49 -0800 Subject: [PATCH 04/10] Fix #381 --- CHANGELOG.md | 1 + Source/KISAddonPointer.cs | 35 ++++++++++++++++++++++++++++++----- Source/ModuleKISInventory.cs | 4 +++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a9d1e0..395989dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 1.28 (pre-release): * [Fix #380] Model equippable parts cannot be carried. +* [Fix #381] Hide UI command doesn't play well with KIS. # 1.27 (December 23rd, 2020): * [Enhancement] Check for colliders when node attaching a part. diff --git a/Source/KISAddonPointer.cs b/Source/KISAddonPointer.cs index d576990d..22949a31 100644 --- a/Source/KISAddonPointer.cs +++ b/Source/KISAddonPointer.cs @@ -248,6 +248,21 @@ public enum PointerState { } private static OnPointerState SendPointerState; + #region MonoBehaviour methods + void Awake() { + GameEvents.onHideUI.Add(HideUI); + } + + void OnDestroy() { + GameEvents.onHideUI.Remove(HideUI); + } + + void HideUI() { + DebugEx.Info("Stop KIS behavior due to HIDE UI command"); + CancelPointer(null); + } + #endregion + public delegate void OnPointerState(PointerTarget pTarget, PointerState pState, Part hoverPart, AttachNode hoverNode); @@ -295,7 +310,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(); } @@ -679,15 +694,25 @@ public void UpdatePointer() { } } + /// Cancels the drag mode if one was active. + 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); + } + } + /// Handles keyboard input. 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) { diff --git a/Source/ModuleKISInventory.cs b/Source/ModuleKISInventory.cs index 94e94bd5..cd81c81b 100644 --- a/Source/ModuleKISInventory.cs +++ b/Source/ModuleKISInventory.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using KSP.UI; using UnityEngine; namespace KIS { @@ -1214,7 +1215,8 @@ void GUIStyles() { } void OnGUI() { - if (!showGui) { + if (!showGui + || !UIMasterController.Instance.IsUIShowing) { return; } From 814ad9ac4980dc75409906473c98d9b7836d27c2 Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:24:10 -0800 Subject: [PATCH 05/10] Fix #379 --- CHANGELOG.md | 1 + Source/KISAddonPointer.cs | 9 +++++++++ Source/ModuleKISInventory.cs | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 395989dc..36e11ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # 1.28 (pre-release): +* [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. diff --git a/Source/KISAddonPointer.cs b/Source/KISAddonPointer.cs index 22949a31..8fc756e5 100644 --- a/Source/KISAddonPointer.cs +++ b/Source/KISAddonPointer.cs @@ -251,16 +251,25 @@ public enum PointerState { #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, diff --git a/Source/ModuleKISInventory.cs b/Source/ModuleKISInventory.cs index cd81c81b..bd0e192c 100644 --- a/Source/ModuleKISInventory.cs +++ b/Source/ModuleKISInventory.cs @@ -1216,6 +1216,7 @@ void GUIStyles() { void OnGUI() { if (!showGui + || EVAConstructionModeController.Instance != null && EVAConstructionModeController.Instance.IsOpen || !UIMasterController.Instance.IsUIShowing) { return; } @@ -1898,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 From e7b7a742923ebe74ac199544e218c141d396c9cc Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:27:32 -0800 Subject: [PATCH 06/10] Fix #382 --- CHANGELOG.md | 1 + Source/ModuleKISItem.cs | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e11ee2..e80cdfff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * [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. diff --git a/Source/ModuleKISItem.cs b/Source/ModuleKISItem.cs index 54adefee..511af841 100644 --- a/Source/ModuleKISItem.cs +++ b/Source/ModuleKISItem.cs @@ -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 } From 34ce8654109b827ec13eb84546258f342d8eba42 Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:32:10 -0800 Subject: [PATCH 07/10] Fix #378 --- CHANGELOG.md | 1 + Source/KIS_Shared.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e80cdfff..9ba3b7bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # 1.28 (pre-release): +* [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. diff --git a/Source/KIS_Shared.cs b/Source/KIS_Shared.cs index d24ab5bd..ed09d829 100644 --- a/Source/KIS_Shared.cs +++ b/Source/KIS_Shared.cs @@ -928,6 +928,14 @@ public static void MoveAssembly(Part assemblyRoot, string srcAttachNodeId, /// 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()) { + 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; From 770240bc17c9ab4cf0b9bcab9cfeff6d4e9349ab Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:40:33 -0800 Subject: [PATCH 08/10] Update release script --- Tools/clients/CurseForgeClient.py | 16 ++++++++++++---- Tools/release_setup.json | 3 +-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Tools/clients/CurseForgeClient.py b/Tools/clients/CurseForgeClient.py index 1b98f247..bf7af657 100644 --- a/Tools/clients/CurseForgeClient.py +++ b/Tools/clients/CurseForgeClient.py @@ -19,6 +19,7 @@ import logging import os.path import re +import ssl import urllib2 from utils import FormDataUtil @@ -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') @@ -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: diff --git a/Tools/release_setup.json b/Tools/release_setup.json index bcdf545d..e103466e 100644 --- a/Tools/release_setup.json +++ b/Tools/release_setup.json @@ -26,8 +26,7 @@ "{COMPILED_BINARY}", "?{MINIAVC_VERSION_FILE}", "/Binaries/MiniAVC-V2.dll", - "/Binaries/KSPDev_Utils*", - "-KSP-AVC-V2.version" + "/Binaries/KSPDev_Utils*" ] } } From c33787c598febc80a92e467c383bcdb06403e26e Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:41:15 -0800 Subject: [PATCH 09/10] Create README.md --- Tools/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Tools/README.md diff --git a/Tools/README.md b/Tools/README.md new file mode 100644 index 00000000..67e51dbf --- /dev/null +++ b/Tools/README.md @@ -0,0 +1,3 @@ +# Requirements + +* The v15.0 version of `MSBuild`: (get it from here)[https://www.visualstudio.com/downloads/]. From ecb946486b236312b3dc73dc2664fc2ad3e06312 Mon Sep 17 00:00:00 2001 From: Igor Zavoychinskiy Date: Fri, 15 Jan 2021 22:46:29 -0800 Subject: [PATCH 10/10] Release v1.28 --- CHANGELOG.md | 2 +- KIS.version | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba3b7bd..8cae7402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 1.28 (pre-release): +# 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. diff --git a/KIS.version b/KIS.version index 9a598d42..b8e5ff3d 100644 --- a/KIS.version +++ b/KIS.version @@ -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 } } \ No newline at end of file