Co-op campaign matches and command markers: mission relay, allied masters, temporary flags

This commit is contained in:
Richard Zink committed 2026-11-04 20:07:06 +01:00
1 parent dc22e27184
commit 5928acf7f6
12 files changed
+433 -27

No files matched your search

+35 -2
View File
@@ -231,6 +231,9 @@ enum Btn {
MatchJoin,
MatchJoinRoom(usize),
MatchCreate,
MatchCoopPrev,
MatchCoopNext,
MatchCoopCreate,
MatchTake(usize),
MatchReady,
MatchStart,
@@ -307,6 +310,7 @@ pub enum MenuAction {
OpenMatch,
MatchJoin(String),
MatchCreate,
MatchCoopCreate(usize),
MatchTakeSide(u8),
MatchReady(bool),
MatchStart,
@@ -327,6 +331,7 @@ pub struct Menu {
pub focus: usize, // field that gets the typed text
pub error: Option<String>, // message on the login and account pages
pub match_ui: MatchUi, // copied state of the multiplayer relay, shown on the Match page
pub coop_mission: usize, // co-op campaign mission selected on the Match page
pub in_match: bool, // a match is being played; the pause menu changes its shape
confirm: Option<Btn>, // overwrite / delete waiting for a second click
scroll: usize,
@@ -353,6 +358,7 @@ impl Menu {
focus: 0,
error: None,
match_ui: MatchUi::default(),
coop_mission: crate::campaign::coop_mission_indexes().first().copied().unwrap_or(0),
in_match: false,
confirm: None,
scroll: 0,
@@ -616,6 +622,17 @@ impl Menu {
None => MenuAction::Consumed,
},
Some(Btn::MatchCreate) => MenuAction::MatchCreate,
Some(Btn::MatchCoopPrev) => {
self.coop_mission = crate::campaign::next_coop_mission(self.coop_mission, -1);
self.confirm = None;
MenuAction::Consumed
}
Some(Btn::MatchCoopNext) => {
self.coop_mission = crate::campaign::next_coop_mission(self.coop_mission, 1);
self.confirm = None;
MenuAction::Consumed
}
Some(Btn::MatchCoopCreate) => MenuAction::MatchCoopCreate(self.coop_mission),
Some(Btn::MatchReady) => MenuAction::MatchReady(!self.match_ui.ready),
Some(Btn::MatchStart) => MenuAction::MatchStart,
Some(Btn::MatchResume) => MenuAction::MatchResume,
@@ -1374,6 +1391,16 @@ impl Menu {
yy += CH() * 1.6;
}
if !ui.started && !ui.room_open() {
if let Some(d) = missions().get(self.coop_mission) {
let line = trf("net.coop_mission", &[(self.coop_mission + 1).to_string(), tr(&format!("camp.{}.title", d.key))]);
let maxc = ((cols - 6) as f32 * CW() / (GW * SMALL())) as usize;
for (_k, text) in wrap(&line, maxc).iter().take(2).enumerate() {
gfx.text(text, ix, yy, SMALL(), GOLD);
yy += GH * SMALL() * 1.35;
}
}
}
self.field(gfx, ix, yy, w, &tr("net.join_hint"), 0, false);
self.field(gfx, ix, yy + CH() * 2.4, w, &tr("net.chat"), 1, false);
yy += CH() * 4.8;
@@ -1382,6 +1409,11 @@ impl Menu {
if !ui.started {
items.push((Btn::MatchCreate, tr("net.create")));
items.push((Btn::MatchJoin, tr("net.join")));
if !ui.room_open() {
items.push((Btn::MatchCoopPrev, "<".to_string()));
items.push((Btn::MatchCoopCreate, tr("net.coop_create")));
items.push((Btn::MatchCoopNext, ">".to_string()));
}
if ui.room_open() {
items.push((Btn::MatchReady, tr(if ui.ready { "net.unready" } else { "net.ready" })));
if ui.is_host {
@@ -1402,12 +1434,13 @@ impl Menu {
}
items.push((Btn::Back, tr("menu.back")));
let bw = 14.0 * CW();
for (k, (b, label)) in items.iter().take(6).enumerate() {
let shown = items.iter().take(9).count();
for (k, (b, label)) in items.iter().take(shown).enumerate() {
let r = Rect::new(ix + (k % 3) as f32 * (bw + CW()), yy + (k / 3) as f32 * CH() * 2.4, bw, CH() * 2.0);
button(gfx, r, label, r.contains(vec2(mx, my)), FRAME);
self.buttons.push((r, *b));
}
yy += CH() * 5.4;
yy += CH() * 2.4 * ((shown + 2) / 3) as f32;
if !ui.rooms.is_empty() && !ui.started {
gfx.text(&tr("net.rooms"), ix, yy, S(), GOLD);