Skip to content

Commit

Permalink
Removed debug message and made compatible to KIS 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
obivandamme committed Aug 14, 2015
1 parent 3f5104b commit 4ccffd1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 68 deletions.
101 changes: 43 additions & 58 deletions Source/Workshop/Workshop/OseModuleInventoryPreference.cs
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);
}
}
}
20 changes: 10 additions & 10 deletions Source/Workshop/Workshop/Workshop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Kerbal Space Program\WorkshopDev_1.2.1\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\..\..\..\Privat\Workshop_1.2.2\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KIS, Version=1.1.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Kerbal Space Program\WorkshopDev_1.2.1\GameData\KIS\Plugins\KIS.dll</HintPath>
<Reference Include="KIS">
<HintPath>..\..\..\..\..\..\..\..\..\Privat\Workshop_1.2.2\GameData\KIS\Plugins\KIS.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Kerbal Space Program\WorkshopDev_1.2.1\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\..\..\..\Privat\Workshop_1.2.2\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -69,7 +66,10 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>IF EXIST "D:\Kerbal Space Program\WorkshopDev_1.2.1" xcopy "$(TargetPath)" "D:\Kerbal Space Program\WorkshopDev_1.2.1\GameData\Workshop\Plugins\" /Y
IF EXIST "D:\Development\Workshop\GameData\Workshop\Plugins" xcopy "$(TargetPath)" "D:\Development\Workshop\GameData\Workshop\Plugins\" /Y</PostBuildEvent>
IF EXIST "D:\Development\Workshop\GameData\Workshop\Plugins" xcopy "$(TargetPath)" "D:\Development\Workshop\GameData\Workshop\Plugins\" /Y

IF EXIST "C:\Privat\Workshop_1.2.2" xcopy "$(TargetPath)" "C:\Privat\Workshop_1.2.2\GameData\Workshop\Plugins\" /Y
IF EXIST "C:\Users\MartinP\Documents\Visual Studio 2013\Projects\Workshop\GameData\Workshop\Plugins" xcopy "$(TargetPath)" "C:\Users\MartinP\Documents\Visual Studio 2013\Projects\Workshop\GameData\Workshop\Plugins\" /Y</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 4ccffd1

Please sign in to comment.