Skip to content

Commit

Permalink
Fix #270
Browse files Browse the repository at this point in the history
- Disable inventory in the edtior.
- Show equpped state in the seat.
- Only allow equp from the active vessel.
  • Loading branch information
ihsoft committed Oct 27, 2018
1 parent 5b70985 commit a0071b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# 1.15 (pre-release):
* [Change] KSP 1.5.* compatibility.
* [Fix #270] Command seats must not be allowed to have inventory.

# 1.14 (July 18th, 2018):
* [Change] Migrate to KSPDev Utils 0.37.0. A stability fix.
Expand Down
23 changes: 15 additions & 8 deletions Source/ModuleKISInventory.cs
Expand Up @@ -579,10 +579,13 @@ public enum InventoryType {
var invEvent = PartModuleUtils.GetEvent(this, ToggleInventory);
if (invType == InventoryType.Pod) {
if (HighLogic.LoadedSceneIsEditor) {
// Cannot pre-load inventory for the command seats: they have no inventory!
invEvent.guiActiveEditor = part.FindModuleImplementing<KerbalSeat>() == null;
invEvent.guiActive = true;
invEvent.guiActiveUnfocused = true;
invEvent.guiName = PodSeatInventoryMenuTxt.Format(podSeat);
} else {
invEvent.guiActiveEditor = false;
invEvent.guiActive = false;
invEvent.guiActiveUnfocused = false;
ProtoCrewMember crewAtPodSeat = part.protoModuleCrew.Find(x => x.seatIdx == podSeat);
Expand Down Expand Up @@ -690,7 +693,9 @@ public enum InventoryType {
openAnim = part.FindModelAnimators(openAnimName)[0];
}

if (invType == InventoryType.Eva) {
// Only equip if this is a kerbal module. Pods and command seats have POD inventory too.
// SPECIAL CASE: kerbal in a command seat is NOT "isEVA", but it has the EVA module.
if (invType == InventoryType.Eva && part.FindModuleImplementing<KerbalEVA>() != null) {
var protoCrewMember = part.protoModuleCrew[0];
kerbalTrait = protoCrewMember.experienceTrait.Title;
foreach (var item in startEquip) {
Expand Down Expand Up @@ -1647,7 +1652,8 @@ public enum InventoryType {

//Equip
if (contextItem != null) {
if (contextItem.equipable && contextItem.quantity == 1 && invType == InventoryType.Eva) {
if (contextItem.equipable && contextItem.quantity == 1
&& invType == InventoryType.Eva && FlightGlobals.ActiveVessel == part.vessel) {
noAction = false;
if (contextItem.equipped) {
if (GUILayout.Button(UnequipItemContextMenuBtn)) {
Expand Down Expand Up @@ -1869,12 +1875,13 @@ public enum InventoryType {
var item = items[slotIndex];
GUI.DrawTexture(textureRect, item.icon.texture, ScaleMode.ScaleToFit);
// Part's vessel is null when in the editor mode.
if (part.vessel != null && FlightGlobals.ActiveVessel == part.vessel
&& FlightGlobals.ActiveVessel.isEVA) {
// Keyboard shortcut
//TODO(ihsoft): Show the slot shorcut instead.
int slotNb = slotIndex + 1;
GUI.Label(textureRect, SlotIdContextCaption.Format(slotNb), upperLeftStyle);
if (part.vessel != null && FlightGlobals.ActiveVessel == part.vessel) {
if (FlightGlobals.ActiveVessel.isEVA) {
// Keyboard shortcut
//TODO(ihsoft): Show the slot shorcut instead.
int slotNb = slotIndex + 1;
GUI.Label(textureRect, SlotIdContextCaption.Format(slotNb), upperLeftStyle);
}
if (item.carried) {
GUI.Label(textureRect, CarriedItemContextCaption, upperRightStyle);
} else if (item.equipped) {
Expand Down

0 comments on commit a0071b4

Please sign in to comment.