Skip to content

Commit

Permalink
Update to 1.3 with Localizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tomforwood committed May 29, 2017
1 parent 7ab8fa5 commit 6fc8de5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 156 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions SampleAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void analyze(IScienceDataContainer cont, ScienceData sd)
base.ReviewData();
}

[KSPField(guiActive = true, guiName = "Status", isPersistant = false)]
public string status;
//[KSPField(guiActive = true, guiName = "Status", isPersistant = false)]
//public string status;

public void addDataButton(ScienceData sd, IScienceDataContainer cont)
{
Expand Down
2 changes: 1 addition & 1 deletion ScienceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static ScienceSubject getScienceSubject(string name, Vessel vessel)
CelestialBody body = vessel.mainBody;
string biome = "";
if(vessel.LandedOrSplashed) biome = vessel.landedAt;
ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, situation, body, biome);
ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, situation, body, biome, biome);
return subject;
}
}
Expand Down
15 changes: 9 additions & 6 deletions StationScience.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@
<RootNamespace>StationScience</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>H:\KSP_win1.2\KSP_win64\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>H:\KSP-1.3\KSP_win64\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAssets">
<HintPath>H:\KSP_win1.2\KSP_win64\KSP_x64_Data\Managed\KSPAssets.dll</HintPath>
<Reference Include="KSPAssets, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>H:\KSP-1.3\KSP_win64\KSP_x64_Data\Managed\KSPAssets.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="UnityEngine">
<HintPath>H:\KSP_win1.2\KSP_win64\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>H:\KSP-1.3\KSP_win64\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
25 changes: 10 additions & 15 deletions StnSciContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ You should have received a copy of the GNU General Public License
*/

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Contracts;
using Contracts.Parameters;
using KSP;
using KSP.Localization;
using KSPAchievements;

// Thanks to MrHappyFace for the intial code I used to figure out Contracts
Expand Down Expand Up @@ -148,12 +144,11 @@ private class ContractCandidate

protected override bool Generate()
{
Debug.Log("Fish");
StnSciScenario.Log("Considering a StatSci contract");
//StnSciScenario.Log("Considering a StatSci contract");
if (ActiveCount() >= StnSciScenario.Instance.settings.maxContracts)
{
StnSciScenario.Log("StationScience contracts cap hit (" +
StnSciScenario.Instance.settings.maxContracts + ").");
/*StnSciScenario.Log("StationScience contracts cap hit (" +
StnSciScenario.Instance.settings.maxContracts + ").");*/
return false;
}
double xp = StnSciScenario.Instance.xp + Reputation.Instance.reputation * StnSciScenario.Instance.settings.reputationFactor;
Expand Down Expand Up @@ -288,7 +283,7 @@ private int ActiveCount(String exp = null, CelestialBody body = null)
(exp == null || sscon.experimentType != null) &&
(body == null || sscon.targetBody != null) &&
((exp == null || exp == sscon.experimentType.name) &&
(body == null || body.theName == sscon.targetBody.theName)))
(body == null || body.name == sscon.targetBody.name)))
ret += 1;
}
return ret;
Expand All @@ -315,7 +310,7 @@ private int CompletedCount(String exp = null, CelestialBody body = null)
(exp == null || sscon.experimentType != null) &&
(body == null || sscon.targetBody != null) &&
((exp == null || exp == sscon.experimentType.name) &&
(body == null || body.theName == sscon.targetBody.theName)))
(body == null || body.name == sscon.targetBody.name)))
ret += 1;
}
return ret;
Expand Down Expand Up @@ -358,20 +353,20 @@ protected override string GetHashString()
}
protected override string GetTitle()
{
return "Perform " + experimentType.title + " in orbit around " + targetBody.theName;
return Localizer.Format("Perform <<1>> in orbit around <<2>>", experimentType.title, targetBody.name);
}
protected override string GetDescription()
{
//those 3 strings appear to do nothing
return TextGen.GenerateBackStories(Agent.Name, Agent.GetMindsetString(), "experiment", "station", "kill all humans", new System.Random().Next());
return TextGen.GenerateBackStories("Station Science", Agent.Name, "station science experiment", experimentType.title, new System.Random().Next(), true, true, true);
}
protected override string GetSynopsys()
{
return "We need you to complete " + experimentType.title + " in orbit around " + targetBody.theName + ", and return it to Kerbin for recovery";
return Localizer.Format("We need you to complete <<1>> in orbit around <<2>>, and return it to Kerbin for recovery", experimentType.title, targetBody.name);
}
protected override string MessageCompleted()
{
return "You have successfully performed " + experimentType.title + " in orbit around " + targetBody.theName;
return Localizer.Format("You have successfully performed <<1>> in orbit around <<2>>" + experimentType.title + "" + targetBody.name);
}

protected override void OnCompleted()
Expand Down
139 changes: 7 additions & 132 deletions StnSciParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,135 +23,11 @@ You should have received a copy of the GNU General Public License
using KSP;
using Contracts;
using Contracts.Parameters;
using KSP.Localization;

namespace StationScience.Contracts.Parameters
{
/*
public class UnlockPartsParameter : ContractParameter
{
List<AvailablePart> parts;
public UnlockPartsParameter()
{
this.Enabled = true;
this.DisableOnStateChange = true;
this.parts = new List<AvailablePart>();
}
public UnlockPartsParameter(IEnumerable<AvailablePart> p)
{
this.Enabled = true;
this.DisableOnStateChange = true;
SetParts(p);
doUpdate();
}
public UnlockPartsParameter(string p)
{
this.Enabled = true;
this.DisableOnStateChange = true;
SetParts(p);
doUpdate();
}
public void SetParts(IEnumerable<AvailablePart> p)
{
this.parts = new List<AvailablePart>(p);
}
public void SetParts(string p)
{
this.parts = new List<AvailablePart>();
foreach (string s in p.Split(','))
{
AvailablePart a = PartLoader.getPartInfoByName(s);
if (a != null)
this.parts.Add(a);
else
StnSciScenario.LogError("Part not found: " + s);
}
}
public List<AvailablePart> GetParts()
{
return new List<AvailablePart>(this.parts);
}
protected override string GetHashString()
{
return "test";
}
public string GetReadableList()
{
StringBuilder ret = new StringBuilder("");
for (int i = 0; i < this.parts.Count; i++)
{
if (i > 0)
{
if (i == this.parts.Count - 1)
ret.Append(" and ");
else
ret.Append(", ");
}
ret.Append(this.parts[i].title);
}
return ret.ToString();
}
public string GetNameList()
{
return string.Join(",", parts.Select(part => part.name).ToArray());
}
protected override string GetTitle()
{
return "Research " + GetReadableList();
}
protected override void OnRegister()
{
GameEvents.OnPartPurchased.Add(OnPartPurchased);
GameEvents.OnTechnologyResearched.Add(OnTechnologyResearched);
}
protected override void OnUnregister()
{
GameEvents.OnPartPurchased.Remove(OnPartPurchased);
GameEvents.OnTechnologyResearched.Remove(OnTechnologyResearched);
}
private void OnPartPurchased(AvailablePart a)
{
doUpdate();
}
private void OnTechnologyResearched(GameEvents.HostTargetAction<RDTech, RDTech.OperationResult> a)
{
doUpdate();
}
private void doUpdate()
{
if (parts.All(part => ResearchAndDevelopment.PartTechAvailable(part) && ResearchAndDevelopment.PartModelPurchased(part)))
SetComplete();
else
SetIncomplete();
}
protected override void OnSave(ConfigNode node)
{
base.OnSave(node);
node.AddValue("parts", GetNameList());
}
protected override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
string parts = node.GetValue("parts");
SetParts(parts);
doUpdate();
}
}*/


public interface PartRelated
{
AvailablePart GetPartType();
Expand Down Expand Up @@ -202,14 +78,13 @@ protected override string GetHashString()

protected override string GetTitle()
{
return "Complete " + experimentType.title + " in orbit around " + targetBody.theName;
return Localizer.Format("Complete <<1>> in orbit around <<2>>", experimentType.title, targetBody.GetDisplayName());
}

protected override string GetNotes()
{
return "Launch a new experiment part (" + experimentType.title +
"), bring it into orbit around " + targetBody.theName +
", complete the experiment, return it (with results inside) to Kerbin and recover it";
return Localizer.Format("Launch a new experiment part (<<1>>), bring it into orbit around <<2>>, "+
"complete the experiment, return it (with results inside) to Kerbin and recover it", experimentType.title, targetBody.GetDisplayName());
}

private bool SetExperiment(string exp)
Expand Down Expand Up @@ -334,7 +209,7 @@ private void OnVesselSituationChange(GameEvents.HostedFromToAction<Vessel,Vessel
if(!((arg.from == Vessel.Situations.LANDED || arg.from == Vessel.Situations.PRELAUNCH) &&
(arg.to == Vessel.Situations.FLYING || arg.to == Vessel.Situations.SUB_ORBITAL)))
return;
if (arg.host.mainBody.theName != "Kerbin")
if (arg.host.mainBody.name != "Kerbin")
return;
AvailablePart experimentType = StnSciParameter.getExperimentType(this);
if (experimentType == null)
Expand Down Expand Up @@ -431,7 +306,7 @@ protected override string GetTitle()
if (targetBody == null)
return "Complete in orbit";
else
return "Complete in orbit around " + targetBody.theName;
return Localizer.Format("Complete in orbit around <<1>>", targetBody.GetDisplayName());
}

private float lastUpdate = 0;
Expand Down

0 comments on commit 6fc8de5

Please sign in to comment.