-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed debug message and made compatible to KIS 1.2.2
- Loading branch information
obivandamme
committed
Aug 14, 2015
1 parent
3f5104b
commit 4ccffd1
Showing
2 changed files
with
53 additions
and
68 deletions.
There are no files selected for viewing
101 changes: 43 additions & 58 deletions
101
Source/Workshop/Workshop/OseModuleInventoryPreference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Workshop | ||
{ | ||
public class OseModuleInventoryPreference : PartModule | ||
{ | ||
[KSPField(guiActive = true, guiName = "OSE Debug", isPersistant = true)] | ||
public bool isFavored = false; | ||
|
||
[KSPEvent(guiActive = false, guiName = "Favor Inventory")] | ||
public void ContextMenuOnFavorInventory() | ||
{ | ||
if (isFavored) | ||
{ | ||
isFavored = false; | ||
Events["ContextMenuOnFavorInventory"].guiName = "Favor Inventory"; | ||
} | ||
else | ||
{ | ||
isFavored = true; | ||
Events["ContextMenuOnFavorInventory"].guiName = "Unfavor Inventory"; | ||
} | ||
} | ||
|
||
public override void OnStart(StartState state) | ||
{ | ||
base.OnStart(state); | ||
if (VesselHasWorkshop()) | ||
{ | ||
Events["ContextMenuOnFavorInventory"].guiActive = true; | ||
} | ||
if (isFavored) | ||
{ | ||
Events["ContextMenuOnFavorInventory"].guiName = "Unfavor Inventory"; | ||
} | ||
} | ||
|
||
private bool VesselHasWorkshop() | ||
{ | ||
if (this.part.vessel == null) | ||
return false; | ||
if (this.part.vessel.Parts == null) | ||
return false; | ||
|
||
foreach (var part in vessel.Parts) | ||
{ | ||
if (part.GetComponent<OseModuleWorkshop>() != null) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} | ||
using System.Linq; | ||
|
||
namespace Workshop | ||
{ | ||
public class OseModuleInventoryPreference : PartModule | ||
{ | ||
[KSPField(isPersistant = true)] | ||
public bool isFavored = false; | ||
|
||
[KSPEvent(guiActive = false, guiName = "Favor Inventory")] | ||
public void ContextMenuOnFavorInventory() | ||
{ | ||
if (isFavored) | ||
{ | ||
isFavored = false; | ||
Events["ContextMenuOnFavorInventory"].guiName = "Favor Inventory"; | ||
} | ||
else | ||
{ | ||
isFavored = true; | ||
Events["ContextMenuOnFavorInventory"].guiName = "Unfavor Inventory"; | ||
} | ||
} | ||
|
||
public override void OnStart(StartState state) | ||
{ | ||
base.OnStart(state); | ||
if (VesselHasWorkshop()) | ||
{ | ||
Events["ContextMenuOnFavorInventory"].guiActive = true; | ||
} | ||
if (isFavored) | ||
{ | ||
Events["ContextMenuOnFavorInventory"].guiName = "Unfavor Inventory"; | ||
} | ||
} | ||
|
||
private bool VesselHasWorkshop() | ||
{ | ||
return HighLogic.LoadedSceneIsFlight && this.vessel.Parts.Any(p => p.GetComponent<OseModuleWorkshop>() != null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters