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) {
|
/// <summary>
|
||||||
if (entries.SelectedItem == null) {
|
/// Gets the currently selected objective, even if a log entry in said objective
|
||||||
return;
|
/// is selected instead. If nothing is selected, returns null.
|
||||||
}
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Objective GetSelectedObjective() {
|
||||||
var obj = entries.SelectedItem;
|
var obj = entries.SelectedItem;
|
||||||
|
|
||||||
if (obj.GetType() != typeof(Objective)) {
|
if (obj == null) {
|
||||||
return;
|
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 };
|
CombatZoneDialog dialog = new CombatZoneDialog() { Owner = this };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user