public void Populate(MedicalScannerBoundUserInterfaceState state) { Contents.RemoveAllChildren(); var text = new StringBuilder(); if (state.MaxHealth == 0) { text.Append("No patient data."); } else { text.Append($"Patient's health: {state.CurrentHealth}/{state.MaxHealth}\n"); if (state.DamageDictionary != null) { foreach (var(dmgType, amount) in state.DamageDictionary) { text.Append($"\n{dmgType}: {amount}"); } } } Contents.AddChild(new Label() { Text = text.ToString() }); }
public void Populate(MedicalScannerBoundUserInterfaceState state) { var text = new StringBuilder(); var entities = IoCManager.Resolve <IEntityManager>(); if (!state.Entity.HasValue || !state.HasDamage() || !entities.EntityExists(state.Entity.Value)) { Diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text"); ScanButton.Disabled = true; SetSize = (250, 100); } else { text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", Name: entities.GetComponent<MetaDataComponent>(state.Entity.Value).EntityName))}\n"); var totalDamage = state.DamagePerType.Values.Sum(); text.Append($"{Loc.GetString("medical-scanner-window-entity-damage-total-text", ("amount", totalDamage))}\n"); HashSet <string> shownTypes = new(); // Show the total damage and type breakdown for each damage group. foreach (var(damageGroupId, damageAmount) in state.DamagePerGroup) { text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", damageGroupId), ("amount", damageAmount))}"); // Show the damage for each type in that group. var group = IoCManager.Resolve <IPrototypeManager>().Index <DamageGroupPrototype>(damageGroupId); foreach (var type in group.DamageTypes) { if (state.DamagePerType.TryGetValue(type, out var typeAmount)) { // If damage types are allowed to belong to more than one damage group, they may appear twice here. Mark them as duplicate. if (!shownTypes.Contains(type)) { shownTypes.Add(type); text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", type), ("amount", typeAmount))}"); } else { text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-duplicate-text", ("damageType", type), ("amount", typeAmount))}"); } } } text.Append('\n'); } Diagnostics.Text = text.ToString(); ScanButton.Disabled = state.IsScanned; // TODO MEDICALSCANNER resize window based on the length of text / number of damage types? // Also, maybe add color schemes for specific damage groups? SetSize = (250, 600); } }
public void Populate(MedicalScannerBoundUserInterfaceState state) { var text = new StringBuilder(); if (!state.Entity.HasValue || !state.HasDamage() || !IoCManager.Resolve <IEntityManager>().TryGetEntity(state.Entity.Value, out var entity)) { _diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text"); ScanButton.Disabled = true; SetSize = (250, 100); } else { text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entity.Name))}\n"); foreach (var(@class, classAmount) in state.DamageClasses) { text.Append($"\n{Loc.GetString("medical-scanner-window-damage-class-text", ("damageClass", @class), ("amount", classAmount))}"); foreach (var type in @class.ToTypes()) { if (!state.DamageTypes.TryGetValue(type, out var typeAmount)) { continue; } text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType",type) ,("amount", typeAmount))}"); } text.Append('\n'); } _diagnostics.Text = text.ToString(); ScanButton.Disabled = state.IsScanned; SetSize = (250, 575); } }
public void Populate(MedicalScannerBoundUserInterfaceState state) { var text = new StringBuilder(); if (!state.Entity.HasValue || !state.HasDamage() || !IoCManager.Resolve <IEntityManager>().TryGetEntity(state.Entity.Value, out var entity)) { _diagnostics.Text = Loc.GetString("No patient data."); ScanButton.Disabled = true; SetSize = (250, 100); } else { text.Append($"{entity.Name}{Loc.GetString("'s health:")}\n"); foreach (var(@class, classAmount) in state.DamageClasses) { text.Append($"\n{Loc.GetString("{0}: {1}", @class, classAmount)}"); foreach (var type in @class.ToTypes()) { if (!state.DamageTypes.TryGetValue(type, out var typeAmount)) { continue; } text.Append($"\n- {Loc.GetString("{0}: {1}", type, typeAmount)}"); } text.Append("\n"); } _diagnostics.Text = text.ToString(); ScanButton.Disabled = state.IsScanned; SetSize = (250, 575); } }
public void Populate(MedicalScannerBoundUserInterfaceState state) { ScanButton.Disabled = !state.IsScannable; }
public void Populate(MedicalScannerBoundUserInterfaceState state) { var text = new StringBuilder(); if (!state.Entity.HasValue || !state.HasDamage() || !IoCManager.Resolve <IEntityManager>().TryGetEntity(state.Entity.Value, out var entity)) { _diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text"); ScanButton.Disabled = true; SetSize = (250, 100); } else { text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entity.Name))}\n"); // Show the total damage var totalDamage = state.DamagePerTypeID.Values.Sum(); text.Append($"{Loc.GetString("medical-scanner-window-entity-damage-total-text", ("amount", totalDamage))}\n"); // Keep track of how many damage types we have shown HashSet <string> shownTypeIDs = new(); // First show just the total damage and type breakdown for each damge group that is fully supported by that entitygroup. foreach (var(damageGroupID, damageAmount) in state.DamagePerSupportedGroupID) { // Show total damage for the group text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", damageGroupID), ("amount", damageAmount))}"); // Then show the damage for each type in that group. // currently state has a dictionary mapping groupsIDs to damage, and typeIDs to damage, but does not know how types and groups are related. // So use PrototypeManager. var group = IoCManager.Resolve <IPrototypeManager>().Index <DamageGroupPrototype>(damageGroupID); foreach (var type in group.DamageTypes) { if (state.DamagePerTypeID.TryGetValue(type.ID, out var typeAmount)) { // If damage types are allowed to belong to more than one damage group, they may appear twice here. Mark them as duplicate. if (!shownTypeIDs.Contains(type.ID)) { shownTypeIDs.Add(type.ID); text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", type.ID), ("amount", typeAmount))}"); } else { text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-duplicate-text", ("damageType", type.ID), ("amount", typeAmount))}"); } } } text.Append('\n'); } // Then, lets also list any damageType that was not fully Supported by the entity's damageContainer var textAppendix = new StringBuilder(); int totalMiscDamage = 0; // Iterate over ids that have not been printed. foreach (var damageTypeID in state.DamagePerTypeID.Keys.Where(typeID => !shownTypeIDs.Contains(typeID))) { //This damage type was not yet added to the text. textAppendix.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", damageTypeID), ("amount", state.DamagePerTypeID[damageTypeID]))}"); totalMiscDamage += state.DamagePerTypeID[damageTypeID]; } // Is there any information to show? Did any damage types not belong to a group? if (textAppendix.Length > 0) { text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", "Miscellaneous"), ("amount", totalMiscDamage))}"); text.Append(textAppendix); } _diagnostics.Text = text.ToString(); ScanButton.Disabled = state.IsScanned; // TODO MEDICALSCANNER resize window based on the length of text / number of damage types? // Also, maybe add color schemes for specific damage groups? SetSize = (250, 600); } }