Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added yellow color and a warning to courses that do not have the tech…
Browse files Browse the repository at this point in the history
… unlocked yet
siimav committed Jan 24, 2019
1 parent 18dcbce commit f3f2ff1
Showing 3 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Source/Crew/CourseTemplate.cs
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ public class CourseTemplate
public ConfigNode RewardLog = null; //the flight log to insert
public ConfigNode ExpireLog = null; // expire all these on complete

public bool isTemporary = false;

public CourseTemplate(ConfigNode source)
{
sourceNode = source;
@@ -134,6 +136,7 @@ public void PopulateFromSourceNode(ConfigNode source = null)
source.TryGetValue("expirationUseStupid", ref expirationUseStupid);

source.TryGetValue("required", ref required);
source.TryGetValue("isTemporary", ref isTemporary);

string repeatStr = source.GetValue("repeatable");
if (!string.IsNullOrEmpty(repeatStr))
10 changes: 7 additions & 3 deletions Source/Crew/CrewHandler.cs
Original file line number Diff line number Diff line change
@@ -513,8 +513,10 @@ public void AddPartCourses(AvailablePart ap)
if (!partSynsHandled.Contains(name))
{
partSynsHandled.Add(name);
GenerateCourseProf(ap);
if (ResearchAndDevelopment.PartModelPurchased(ap))
bool isPartUnlocked = ResearchAndDevelopment.PartModelPurchased(ap);

GenerateCourseProf(ap, !isPartUnlocked);
if (isPartUnlocked)
{
GenerateCourseMission(ap);
}
@@ -843,14 +845,15 @@ protected void GenerateOfferedCourses() //somehow provide some variable options
//fire an event to let other mods add available courses (where they can pass variables through then)
}

protected void GenerateCourseProf(AvailablePart ap)
protected void GenerateCourseProf(AvailablePart ap, bool isTemporary)
{
ConfigNode n = new ConfigNode("FS_COURSE");
string name = TrainingDatabase.SynonymReplace(ap.name);

n.AddValue("id", "prof_" + name);
n.AddValue("name", "Proficiency: " + name);
n.AddValue("time", 1d + (TrainingDatabase.GetTime(name) * 86400d));
n.AddValue("isTemporary", isTemporary);

n.AddValue("conflicts", "TRAINING_proficiency:" + name);

@@ -872,6 +875,7 @@ protected void GenerateCourseMission(AvailablePart ap)
n.AddValue("id", "msn_" + name);
n.AddValue("name", "Mission: " + name);
n.AddValue("time", 1d + TrainingDatabase.GetTime(name + "-Mission") * 86400d);
n.AddValue("isTemporary", false);
n.AddValue("timeUseStupid", true);
n.AddValue("seatMax", ap.partPrefab.CrewCapacity * 2);
n.AddValue("expiration", settings.trainingMissionExpirationDays * 86400d);
22 changes: 20 additions & 2 deletions Source/Crew/FSGUI.cs
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ public class FSGUI : UIBase
private Vector2 nautListScroll = new Vector2();
private Dictionary<ProtoCrewMember, ActiveCourse> activeMap = new Dictionary<ProtoCrewMember, ActiveCourse>();
private Vector2 courseSelectorScroll = new Vector2();
private GUIStyle courseBtnStyle = null;
private GUIStyle tempCourseLblStyle = null;
private GUIContent nautRowAlarmBtnContent = new GUIContent(GameDatabase.Instance.GetTexture("RP-0/KACIcon15", false));

protected void nautListHeading()
@@ -171,10 +173,17 @@ public tabs summaryTab()

protected void courseSelector()
{
if (courseBtnStyle == null)
{
courseBtnStyle = new GUIStyle(GUI.skin.button);
courseBtnStyle.normal.textColor = Color.yellow;
}

courseSelectorScroll = GUILayout.BeginScrollView(courseSelectorScroll, GUILayout.Width(505), GUILayout.Height(430));
try {
foreach (CourseTemplate course in CrewHandler.Instance.OfferedCourses) {
if (GUILayout.Button(course.name))
var style = course.isTemporary ? courseBtnStyle : GUI.skin.button;
if (GUILayout.Button(course.name, style))
selectedCourse = new ActiveCourse(course);
}
} finally {
@@ -191,6 +200,12 @@ public tabs coursesTab()

public tabs newCourseTab()
{
if (tempCourseLblStyle == null)
{
tempCourseLblStyle = new GUIStyle(GUI.skin.label);
tempCourseLblStyle.normal.textColor = Color.yellow;
}

GUILayout.BeginHorizontal();
try {
GUILayout.FlexibleSpace();
@@ -199,7 +214,10 @@ public tabs newCourseTab()
} finally {
GUILayout.EndHorizontal();
}
GUILayout.Label(selectedCourse.description);
if (!string.IsNullOrEmpty(selectedCourse.description))
GUILayout.Label(selectedCourse.description);
if (selectedCourse.isTemporary)
GUILayout.Label("Tech for this part is still being researched", tempCourseLblStyle);
summaryBody(tabs.NewCourse);
if (selectedCourse.seatMax > 0)
GUILayout.Label(selectedCourse.seatMax - selectedCourse.Students.Count + " remaining seat(s).");

0 comments on commit f3f2ff1

Please sign in to comment.