allow adding combat zone wins even if an entry is selected
This commit is contained in:
parent
5405d125d5
commit
1362e53d6b
@ -206,18 +206,42 @@ namespace EliteBGS {
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
||||
if (entries.SelectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently selected objective, even if a log entry in said objective
|
||||
/// is selected instead. If nothing is selected, returns null.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Objective GetSelectedObjective() {
|
||||
var obj = entries.SelectedItem;
|
||||
|
||||
if (obj.GetType() != typeof(Objective)) {
|
||||
return;
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Objective objective = obj as Objective;
|
||||
if (obj.GetType() == typeof(Objective)) {
|
||||
return obj as Objective;
|
||||
}
|
||||
|
||||
// Some form of entry perhaps?
|
||||
if (obj.GetType().IsSubclassOf(typeof(LogEntry))) {
|
||||
LogEntry entry = obj as LogEntry;
|
||||
Objective objective = entries.Items
|
||||
.OfType<Objective>()
|
||||
.First(x => x.LogEntries.Contains(entry))
|
||||
;
|
||||
|
||||
return objective;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
||||
Objective objective = GetSelectedObjective();
|
||||
|
||||
if (objective == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CombatZoneDialog dialog = new CombatZoneDialog() { Owner = this };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user