Skip to content

Commit

Permalink
Disallow handling DLC parts
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsoft committed May 31, 2019
1 parent fe5f9a5 commit def1487
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 1.22 (pre-release):
* [Change] Don't allow `KIS` to deploy or move the ground experiments.

# 1.21 (May 16th, 2019):
* [Fix #89] Portable containers revert to previous content when dropped.
Expand Down
11 changes: 8 additions & 3 deletions Lang/en-us.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Version: 6
// Version: 7
// Do NOT change the version unless a new string is added or an existing one was deleted.
// A simple string update is not a new version! The version number is used to keep all
// the localizations in sync. The EN-US localization file is the primary file, and all the
// other languages should catch-up as the version is increasing.
// Last updated: 02/01/2019
// Authors: KospY, IgorZ, Supercheese, rfelipe200
// Last updated: 02/03/2019
// Last updated: 15/05/2019
Localization
{
en-us
Expand Down Expand Up @@ -324,6 +323,9 @@ Localization
#kisLOC_01038 = [<<1>>] to attach
// The tooltip help string for the key binding to cancel the operation.
#kisLOC_01039 = [Escape] to cancel
// The action status to show in the tooltip when the player tries to pick up a
// ground experment from the scene. These parts must be handled via their menus.
#kisLOC_01040 = KIS cannot pickup deployed ground experiments.\nAccess the part's menu!

// ********** Type: KIS.KISAddonPointer, KSPDev Messages

Expand Down Expand Up @@ -566,6 +568,9 @@ Localization
// The info string in the editor to present if kerbals cannot access the items in
// the inventory when going EVA.
#kisLOC_00060 = <color=#FFA500>Cannot be accessed from EVA</color>
// The message to present when a stock game ground experiment part is attempted to
// be stored into inventory in the editor. Such parts cannot be handled by KIS.
#kisLOC_00061 = Use stock game abilities to handle this part

// ********** Type: KIS.ModuleKISItem, KSPDev Messages

Expand Down
10 changes: 8 additions & 2 deletions Lang/ru.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Version: 6
// Version: 7
// Before changing the version, read the instructions in the en-us.cfg file!
// Author: Igor Zavoychinskiy (IgorZ)
// Last updated: 02/01/2019
// Last updated: 15/05/2019
Localization
{
ru
Expand Down Expand Up @@ -320,6 +320,9 @@ Localization
#kisLOC_01038 = [<<1>>] присоединить
// The tooltip help string for the key binding to cancel the operation.
#kisLOC_01039 = [Escape] отмена действия
// The action status to show in the tooltip when the player tries to pick up a
// ground experment from the scene. These parts must be handled via their menus.
#kisLOC_01040 = КИС не умеет работать с такими деталями.\nПопробуйте использовать меню самой детали!
// ********** Type: KIS.KISAddonPointer, KSPDev Messages
Expand Down Expand Up @@ -562,6 +565,9 @@ Localization
// The info string in the editor to present if kerbals cannot access the items in
// the inventory when going EVA.
#kisLOC_00060 = <color=#FFA500>Недоступно извне аппарата</color>
// The message to present when a stock game ground experiment part is attempted to
// be stored into inventory in the editor. Such parts cannot be handled by KIS.
#kisLOC_00061 = Пользуйтесь возможностями основной игры для таких деталей
// ********** Type: KIS.ModuleKISItem, KSPDev Messages
Expand Down
13 changes: 12 additions & 1 deletion Source/KISAddonPickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace KIS {

// Next localization ID: #kisLOC_01040.
// Next localization ID: #kisLOC_01041.
[PersistentFieldsDatabase("KIS/settings/KISConfig")]
sealed class KISAddonPickup : MonoBehaviour {

Expand Down Expand Up @@ -277,6 +277,12 @@ sealed class KISAddonPickup : MonoBehaviour {
"#kisLOC_01039",
defaultTemplate: "[Escape] to cancel",
description: "The tooltip help string for the key binding to cancel the operation.");

static readonly Message CannotPickupGroundExperimentTooltipTxt = new Message(
"#kisLOC_01040",
defaultTemplate: "KIS cannot pickup deployed ground experiments.\nAccess the part's menu!",
description: "The action status to show in the tooltip when the player tries to pick up a"
+ " ground experment from the scene. These parts must be handled via their menus.");
#endregion

/// <summary>A helper class to handle mouse clicks in the editor.</summary>
Expand Down Expand Up @@ -1462,6 +1468,11 @@ bool CheckCanGrabRealPart(Part part) {
ReportCheckError(GrabNotOkStatusTooltipTxt, CannotMoveKerbonautTooltipTxt);
return false;
}
// Don't grab stock game's ground experiments.
if (part.Modules.OfType<ModuleGroundPart>().Any()) {
ReportCheckError(GrabNotOkStatusTooltipTxt, CannotPickupGroundExperimentTooltipTxt);
return false;
}
// Check if there are kerbals in range.
if (!HasActivePickupInRange(part)) {
ReportCheckError(TooFarStatusTooltipTxt, TooFarTooltipTxt, cursorIcon: TooFarIcon);
Expand Down
21 changes: 20 additions & 1 deletion Source/ModuleKISInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace KIS {

// Next localization ID: #kisLOC_00061.
// Next localization ID: #kisLOC_00062.
[PersistentFieldsDatabase("KIS/settings/KISConfig")]
public class ModuleKISInventory : PartModule,
// KSP interfaces.
Expand Down Expand Up @@ -415,6 +415,12 @@ static readonly Message<string, CompactNumberType, CompactNumberType>
defaultTemplate: "<color=#FFA500>Cannot be accessed from EVA</color>",
description: "The info string in the editor to present if kerbals cannot access the items in"
+ " the inventory when going EVA.");

static readonly Message CannotAddGroundSciencePartMsg = new Message(
"#kisLOC_00061",
defaultTemplate: "Use stock game abilities to handle this part",
description: "The message to present when a stock game ground experiment part is attempted to"
+ " be stored into inventory in the editor. Such parts cannot be handled by KIS.");
#endregion

#region Public types
Expand Down Expand Up @@ -1049,7 +1055,20 @@ public KIS_Item AddItem(ConfigNode partNode, int slot = -1) {
return item;
}

/// <summary>Adds and item, created from a real part.</summary>
/// <param name="p">The part to capture the state from.</param>
/// <param name="qty">The number of items to create in the slot.</param>
/// <param name="slot">
/// The slot to put the items into. If it's <c>-1</c>, then the slot will be selected
/// automatically.
/// </param>
/// <returns>The created slot or <c>null</c> if part cannot be added to the inventory.</returns>
public KIS_Item AddItem(Part p, int qty = 1, int slot = -1) {
if (p.Modules.OfType<ModuleCargoPart>().Any()) {
ScreenMessaging.ShowPriorityScreenMessage(CannotAddGroundSciencePartMsg);
UISounds.PlayBipWrong();
return null;
}
if (items.ContainsKey(slot)) {
slot = -1; // Choose automatically if the slot is already occupied.
}
Expand Down

0 comments on commit def1487

Please sign in to comment.