public CodeBrowser() : base(Constants.WINDOW_ID_CODEBROWSER, "Ribbon Codes") { STYLE_CODE.stretchWidth = false; STYLE_CODE.fixedWidth = 100; STYLE_CODE.alignment = TextAnchor.MiddleLeft; STYLE_NAME.stretchWidth = true; STYLE_NAME.alignment = TextAnchor.MiddleLeft; // // copy activitiesfor sorting into code list Log.Detail("adding action codes to code browser " + ActionPool.Instance()); foreach (Activity activity in ActivityPool.Instance()) { Pair <String, String> code = new Pair <String, String>(activity.GetCode(), activity.GetName()); codes.Add(code); } // sort by code Log.Detail("sorting codes in code browser"); codes.Sort( delegate(Pair <String, String> left, Pair <String, String> right) { return(left.first.CompareTo(right.first)); }); }
public override string ToString() { string timestamp = Utils.ConvertToEarthTime(UniversalTime) + ": "; Action action = ActionPool.Instance().GetActionForCode(Code); if (action != null) { return(timestamp + action.CreateLogBookEntry(this)); } Ribbon ribbon = RibbonPool.Instance().GetRibbonForCode(Code); if (ribbon != null) { Achievement achievement = ribbon.GetAchievement(); return(timestamp + achievement.CreateLogBookEntry(this)); } return("unknown logbook entry (code " + Code + ")"); }
public void CreateFromLogbook(List <LogbookEntry> book) { Log.Detail("creating hall of fame from logbook"); Clear(); lock (this) { if (book.Count == 0) { Log.Detail("no logbook entries"); return; } Log.Detail("resolving logbook"); LogbookEntry lastEntry = null; foreach (LogbookEntry log in book) { if (Log.IsLogable(Log.LEVEL.TRACE)) { Log.Trace("processing logbook entry " + log.UniversalTime + ": " + log.Code + " " + log.Name); } try { // this is a custom ribbon entry if (log.Code.StartsWith(DataChange.DATACHANGE_CUSTOMRIBBON.GetCode())) { changeCustomRibbon(log); // if (Log.IsLogable(Log.LEVEL.DETAIL)) { Log.Detail("adding custom ribbon " + log.Code + ": " + log.Name); } logbook.Add(log); // continue; } HallOfFameEntry entry = GetEntry(log.Name); if (entry == null) { entry = CreateEntry(log.Name); } Action action = ActionPool.Instance().GetActionForCode(log.Code); if (action != null) { action.DoAction(log.UniversalTime, entry, log.Data); addLogbookEntry(log, entry); } else { // those codes have change switch (log.Code) { case "CO": log.Code = "CO:Sun"; break; case "CO1": log.Code = "CO1:Sun"; break; } // Ribbon ribbon = RibbonPool.Instance().GetRibbonForCode(log.Code); if (ribbon != null) { Achievement achievement = ribbon.GetAchievement(); bool sameTransaction = InSameTransaction(log, lastEntry); if (!achievement.HasToBeFirst() || !accomplished.Contains(achievement) || sameTransaction) { // make sure old transactions have same timestamps in each entry if (sameTransaction) { log.UniversalTime = lastEntry.UniversalTime; } // entry.Award(ribbon); addLogbookEntry(log, entry); // to prevent multiple first ribbon awards accomplished.Add(ribbon.GetAchievement()); } } else { Log.Warning("no ribbon for code " + log.Code + " found"); } } } catch (KeyNotFoundException) { Log.Error("kerbal " + log.Name + " not found"); } catch (Exception e) { Log.Error("failed to create data in hall of fame for " + log.Name); Log.Error(e.GetType() + ": " + e.Message); } lastEntry = log; } // end for } Log.Detail("new hall of fame created"); }