Manual AI seats for matches: host toggles empty seats, co-op allies fight heroes
This commit is contained in:
1 parent
3492eacd59
commit
ee7b76fa6a
10 files changed
+308
-43
No files matched your search
+38
-7
@@ -235,6 +235,7 @@ enum Btn {
|
||||
MatchCoopNext,
|
||||
MatchCoopCreate,
|
||||
MatchTake(usize),
|
||||
MatchAi(usize),
|
||||
MatchReady,
|
||||
MatchStart,
|
||||
MatchResume,
|
||||
@@ -312,6 +313,7 @@ pub enum MenuAction {
|
||||
MatchCreate,
|
||||
MatchCoopCreate(usize),
|
||||
MatchTakeSide(u8),
|
||||
MatchSetAi(u8, bool),
|
||||
MatchReady(bool),
|
||||
MatchStart,
|
||||
MatchResume,
|
||||
@@ -654,6 +656,10 @@ impl Menu {
|
||||
Some(s) => MenuAction::MatchTakeSide(s.side),
|
||||
None => MenuAction::Consumed,
|
||||
},
|
||||
Some(Btn::MatchAi(i)) => match self.match_ui.seats.get(i) {
|
||||
Some(s) if s.side != 0 => MenuAction::MatchSetAi(s.side, !s.ai),
|
||||
_ => MenuAction::Consumed,
|
||||
},
|
||||
Some(Btn::Campaign) => {
|
||||
self.page = Some(Page::Campaign);
|
||||
self.scroll = 0;
|
||||
@@ -1462,7 +1468,12 @@ impl Menu {
|
||||
yy += CH() * 1.4;
|
||||
let seat_cols = (cols - 6) as usize;
|
||||
for (k, s) in ui.seats.iter().take(4).enumerate() {
|
||||
let name = if Some(s.side) == ui.local_side { format!("{} ({})", s.name, tr("net.you")) } else { s.name.clone() };
|
||||
let is_local = Some(s.side) == ui.local_side;
|
||||
let name = if is_local {
|
||||
format!("{} ({})", s.name, tr("net.you"))
|
||||
} else {
|
||||
s.name.clone()
|
||||
};
|
||||
let side_label = match s.side {
|
||||
0 => tr("net.side0"),
|
||||
2 => tr("net.side2"),
|
||||
@@ -1470,13 +1481,33 @@ impl Menu {
|
||||
4 => tr("net.side4"),
|
||||
_ => s.side.to_string(),
|
||||
};
|
||||
let line = format!("{} {} {} {} {}", side_label, name, if s.connected { "●" } else { "○" }, if s.ready { "✓" } else { "—" }, if s.side == 0 { tr("net.host") } else { String::new() });
|
||||
gfx.text(&line, ix, yy, SMALL(), if s.connected { TXT } else { DIM });
|
||||
let status = if s.connected { "●" } else if s.ai { "AI" } else { "○" };
|
||||
let ready = if s.ready || s.ai { "✓" } else { "—" };
|
||||
let line = format!("{} {} {} {} {}", side_label, name, status, ready, if s.side == 0 { tr("net.host") } else { String::new() });
|
||||
gfx.text(&line, ix, yy, SMALL(), if s.connected || s.ai { TXT } else { DIM });
|
||||
if !ui.started && ui.local_side.is_some() && !s.connected {
|
||||
let r = Rect::new(ix + 34.0 * CW(), yy, 12.0 * CW(), CH() * 2.0);
|
||||
let label = if Some(s.side) == ui.local_side { tr("net.you") } else { tr("net.join") };
|
||||
button(gfx, r, &label, r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchTake(k)));
|
||||
if ui.is_host && s.side != 0 {
|
||||
if s.ai {
|
||||
let r = Rect::new(ix + 34.0 * CW(), yy, 12.0 * CW(), CH() * 2.0);
|
||||
let label = tr("net.ai_off");
|
||||
button(gfx, r, &label, r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchAi(k)));
|
||||
} else {
|
||||
let join_label = if is_local { tr("net.you") } else { tr("net.join") };
|
||||
let r = Rect::new(ix + 22.0 * CW(), yy, 12.0 * CW(), CH() * 2.0);
|
||||
button(gfx, r, &join_label, r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchTake(k)));
|
||||
let ai_label = tr("net.ai");
|
||||
let r = Rect::new(ix + 36.0 * CW(), yy, 12.0 * CW(), CH() * 2.0);
|
||||
button(gfx, r, &ai_label, r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchAi(k)));
|
||||
}
|
||||
} else if !s.ai {
|
||||
let r = Rect::new(ix + 34.0 * CW(), yy, 12.0 * CW(), CH() * 2.0);
|
||||
let label = if is_local { tr("net.you") } else { tr("net.join") };
|
||||
button(gfx, r, &label, r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchTake(k)));
|
||||
}
|
||||
}
|
||||
yy += CH() * 2.0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user