internal void Save(GameConfig config) { this.Log_DebugOnly("Save", "Saving config for window[{0}]", configNodeName); config.SetWindowRect(configNodeName, WindowRect); this.Log_DebugOnly("Load", "Saved config for window[{0}] WindowRect[{1}]", configNodeName, WindowRect); }
internal void Load(GameConfig config) { this.Log_DebugOnly("Load", "Loading config for window[{0}]", configNodeName); config.GetWindowRect(configNodeName, ref WindowRect); this.Log_DebugOnly("Load", "Loaded config for window[{0}] WindowRect[{1}]", configNodeName, WindowRect); }
public static float GetFitnessModifiedGeeTolerance(float tolerance, KeepFitCrewMember crew, GameConfig config) { float healthGeeToleranceModifier = crew.fitnessLevel / config.initialFitnessLevel; // tolerance goes down to 50% normal tolerance if you zero out on your fitness compared to baseline float result = (tolerance / 2) + tolerance * (healthGeeToleranceModifier / 2); return result; }
internal virtual void Init(KeepFitScenarioModule module) { this.Log_DebugOnly("Init", "."); this.module = module; this.gameConfig = module.GetGameConfig(); }
public KeepFitScenarioModule() { this.Log_DebugOnly("Constructor", "."); gameConfig = new GameConfig(); }
protected void DrawCrew(int windowHandle, ICollection <KeepFitCrewMember> crew, bool showGeeLoadings, bool showAllCrewExpanded) { GameConfig gameConfig = scenarioModule.GetGameConfig(); GUILayout.Space(4); foreach (KeepFitCrewMember crewMember in crew) { bool expanded; if (showAllCrewExpanded) { expanded = true; } else { expandedCrew.TryGetValue(crewMember.Name, out expanded); } // first line - crewmember name GUILayout.BeginHorizontal(); GUILayout.Label(crewMember.Name + "(" + (crewMember.loaded ? "loaded" : "generated") + ")", uiResources.styleCrewName); DrawActivityLevel(crewMember.activityLevel); GUILayout.FlexibleSpace(); if (!showAllCrewExpanded && DrawChevron(expanded)) { expanded = !expanded; if (expanded) { expandedCrew[crewMember.Name] = true; } else { expandedCrew.Remove(crewMember.Name); } } GUILayout.EndHorizontal(); GUILayout.Space(4); if (!expanded) { continue; } // second line - fitness current / max DrawBar2("Fit", "Current / max Fitness level", (float)crewMember.fitnessLevel, (float)gameConfig.maxFitnessLevel); GUILayout.Space(2); if (!showGeeLoadings) { continue; } //// 3rd to <n>th line - Gee(inst) current / max foreach (Period period in Enum.GetValues(typeof(Period))) { GeeToleranceConfig tolerance = gameConfig.GetGeeTolerance(period); GeeLoadingAccumulator accum; crewMember.geeAccums.TryGetValue(period, out accum); if (accum != null && tolerance != null) { float geeWarn = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.warn, crewMember, gameConfig); float geeFatal = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.fatal, crewMember, gameConfig); string label = "G(" + period.ToString().Substring(0, 1) + ")"; string tooltip = "Gee(" + period + ") Current / Max - Orange warn, Red fatal"; float level = accum.GetLastGeeMeanPerSecond(); float max = geeFatal;//(level < geeFatal ? geeFatal : geeFatal + 20); DrawBar3(label, tooltip, level, geeWarn, geeFatal, max); GUILayout.Space(1); } } } }
public KeepFitScenarioModule() { this.Log_DebugOnly("Constructor", "."); gameConfig = new GameConfig(); keepFitAPIImplementation.setGameConfig(gameConfig); }
internal override void DrawWindow(int id) { base.DrawWindow(id); GameConfig config = scenarioModule.GetGameConfig(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("KeepFit v" + Statics.GetDllVersion(this) + " : " + (config.enabled ? "Enabled" : "Disabled")); GUILayout.FlexibleSpace(); if (GUILayout.Button((config.enabled ? "Disable" : "Enable"), GUILayout.Width(80))) { config.enabled = !config.enabled; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Choose a Skin"); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("KSP Style", "Sets the style to be the default KSPStyle"))) { SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.KSP); } if (GUILayout.Button(new GUIContent("Unity Style", "Sets the style to be the default Unity Style"))) { SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.Unity); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("WimpMode: " + (config.wimpMode ? "Enabled" : "Disabled")); GUILayout.FlexibleSpace(); if (GUILayout.Button((config.wimpMode ? "Disable" : "Enable"), GUILayout.Width(80))) { config.wimpMode = !config.wimpMode; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Min Gee For Exercising when Landed: " + config.minimumLandedGeeForExcercising); GUILayout.FlexibleSpace(); // TODO - need a float editor widget here for minimumLandedGeeForExcercising GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Initial fitness level:" + config.initialFitnessLevel.ToString()); GUILayout.FlexibleSpace(); if (GUILayout.Button("+5", GUILayout.Width(80))) { config.initialFitnessLevel += 5; config.validate(); } if (GUILayout.Button("-5", GUILayout.Width(80))) { config.initialFitnessLevel -= 5; config.validate(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Min fitness level:" + config.minFitnessLevel.ToString()); GUILayout.FlexibleSpace(); if (GUILayout.Button("+5", GUILayout.Width(80))) { config.minFitnessLevel += 5; config.validate(); } if (GUILayout.Button("-5", GUILayout.Width(80))) { config.minFitnessLevel -= 5; config.validate(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Max fitness level:" + config.maxFitnessLevel.ToString()); GUILayout.FlexibleSpace(); if (GUILayout.Button("+5", GUILayout.Width(80))) { config.maxFitnessLevel += 5; config.validate(); } if (GUILayout.Button("-5", GUILayout.Width(80))) { config.maxFitnessLevel -= 5; config.validate(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
private void showFloatPairEditor(string text, string text1, string text2, ref WipValuePair wipValuePair, ref float value1, ref float value2, ref GameConfig config) { GUILayout.BeginHorizontal(); GUILayout.Label(text + " : "); GUILayout.FlexibleSpace(); showFloatEditor(text1, ref wipValuePair.one, ref value1, ref config, false); showFloatEditor(text2, ref wipValuePair.two, ref value2, ref config, false); GUILayout.EndHorizontal(); }
internal void setGameConfig(GameConfig gameConfig) { this.gameConfig = gameConfig; }
private void showFloatEditor(string text, ref WipValue wipValue, ref float value, ref GameConfig config, bool ownHoriztonal) { if (ownHoriztonal) GUILayout.BeginHorizontal(); GUILayout.Label(text + " : " + ((!wipValue.valid && wipValue.value != null) ? "(" + value + ")" : "")); if (ownHoriztonal) GUILayout.FlexibleSpace(); if (wipValue.value == null) { wipValue.value = value.ToString(); } wipValue.value = GUILayout.TextField(wipValue.value, GUILayout.Width(40)); float tempValue; wipValue.valid = float.TryParse(wipValue.value, out tempValue); if (ownHoriztonal) GUILayout.EndHorizontal(); if (wipValue.valid) { value = tempValue; if (config.validate()) { wipValue.value = null; } } }
public static float GetFitnessModifiedGeeTolerance(float tolerance, KeepFitCrewMember crew, GameConfig config) { float healthGeeToleranceModifier = crew.fitnessLevel / config.initialFitnessLevel; // tolerance goes down to 50% normal tolerance if you zero out on your fitness compared to baseline float result = (tolerance / 2) + tolerance * (healthGeeToleranceModifier / 2); return(result); }
private void showFloatEditor(string text, ref WipValue wipValue, ref float value, ref GameConfig config, bool ownHoriztonal) { if (ownHoriztonal) { GUILayout.BeginHorizontal(); } GUILayout.Label(text + " : " + ((!wipValue.valid && wipValue.value != null) ? "(" + value + ")" : "")); if (ownHoriztonal) { GUILayout.FlexibleSpace(); } if (wipValue.value == null) { wipValue.value = value.ToString(); } wipValue.value = GUILayout.TextField(wipValue.value, GUILayout.Width(40)); float tempValue; wipValue.valid = float.TryParse(wipValue.value, out tempValue); if (ownHoriztonal) { GUILayout.EndHorizontal(); } if (wipValue.valid) { value = tempValue; if (config.validate()) { wipValue.value = null; } } }