public void RecordCustomRibbon(Ribbon ribbon) { CustomAchievement achievement = ribbon.GetAchievement() as CustomAchievement; if (achievement != null) { int nr = achievement.GetNr(); double now = HighLogic.CurrentGame.UniversalTime; if (Log.IsLogable(Log.LEVEL.DETAIL)) { Log.Detail("new or changed custom ribbon " + ribbon.GetName() + " recorded at " + Utils.ConvertToKerbinTime(now)); } String code = DataChange.DATACHANGE_CUSTOMRIBBON.GetCode() + nr; TakeLog(now, code, achievement.GetName(), achievement.GetText()); } else { Log.Error("invalid custom ribbon achievement"); } }
private void AwardSelectedCustomRibbon() { if (selected == null) { Log.Warning("no custom ribbon selected"); return; } CustomAchievement achievement = selected.GetAchievement() as CustomAchievement; if (achievement == null) { Log.Warning("invalid custom ribbon"); return; } // changed name or text? if (!achievement.GetText().Equals(customRibbonText) || !achievement.GetName().Equals(customRibbonName)) { Log.Detail("name or text change of ribbon " + selected.GetCode()); // change name and text achievement.SetName(customRibbonName); achievement.SetText(customRibbonText); // record changed ribbon HallOfFame.Instance().RecordCustomRibbon(selected); } // assign ribbon to kerbal Log.Trace("assigning custom ribbon " + selected + " to kerbal " + entry.GetKerbal().name + " at game time " + Planetarium.GetUniversalTime()); HallOfFame.Instance().BeginArwardOfRibbons(); HallOfFame.Instance().Record(entry.GetKerbal(), selected); HallOfFame.Instance().EndArwardOfRibbons(); // // mark game as updated, if not in flight if (HighLogic.LoadedScene != GameScenes.FLIGHT) { Log.Trace("mark game as updated"); HighLogic.CurrentGame.Updated(); } }