Versus map size on the match page; the size sets the number of seats
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b927b0df7
commit
6880324e33
22 files changed
+59
-1
No files matched your search
+23
@@ -238,6 +238,7 @@ enum Btn {
|
||||
Tab(usize),
|
||||
Change(usize, i32),
|
||||
MapW(i32),
|
||||
MatchSize(i32),
|
||||
Land,
|
||||
MapH(i32),
|
||||
Difficulty(i32),
|
||||
@@ -437,6 +438,7 @@ pub struct Menu {
|
||||
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
|
||||
match_size: usize, // the versus map size (from the settings, for drawing)
|
||||
pub coop_editor: bool, // the Match page offers a campaign document instead of the built-in missions
|
||||
pub coop_league: bool, // ... and that document is the co-op campaign "League against the Lightwatch"
|
||||
league_doc: Option<CampaignDoc>, // the co-op campaign, built the first time it is chosen
|
||||
@@ -497,6 +499,7 @@ impl Menu {
|
||||
error: None,
|
||||
match_ui: MatchUi::default(),
|
||||
coop_mission: crate::campaign::coop_mission_indexes().first().copied().unwrap_or(0),
|
||||
match_size: 128,
|
||||
coop_editor: false,
|
||||
coop_league: false,
|
||||
league_doc: None,
|
||||
@@ -682,6 +685,12 @@ impl Menu {
|
||||
MenuAction::Consumed
|
||||
}
|
||||
Some(Btn::Start) => MenuAction::NewGame,
|
||||
Some(Btn::MatchSize(d)) => {
|
||||
let sizes = crate::lobby::MATCH_SIZES;
|
||||
let k = sizes.iter().position(|&s| s >= settings.match_size).unwrap_or(2) as i32;
|
||||
settings.match_size = sizes[(k + d).clamp(0, sizes.len() as i32 - 1) as usize];
|
||||
MenuAction::SettingsChanged
|
||||
}
|
||||
Some(Btn::MapW(d)) => {
|
||||
settings.map_w = (settings.map_w as i32 + d * 32).clamp(MIN_SIZE as i32, MAX_SIZE as i32) as usize;
|
||||
MenuAction::SettingsChanged
|
||||
@@ -953,6 +962,7 @@ impl Menu {
|
||||
self.buttons.clear();
|
||||
self.lang_opts.clear();
|
||||
self.cur_lang = settings.language.clone();
|
||||
self.match_size = settings.match_size;
|
||||
let Some(page) = self.page else {
|
||||
self.lang_open = None;
|
||||
return;
|
||||
@@ -2053,6 +2063,19 @@ impl Menu {
|
||||
}
|
||||
}
|
||||
}
|
||||
// a new versus match: the map size and with it the number of seats
|
||||
if !ui.started && !ui.room_open() {
|
||||
let n = self.match_size;
|
||||
let seats = crate::lobby::seats_for(n).len();
|
||||
let r = Rect::new(ix, yy, 4.0 * CW(), CH() * 2.0);
|
||||
button(gfx, r, "<", r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchSize(-1)));
|
||||
gfx.text(&trf("net.map_size", &[n.to_string(), n.to_string(), seats.to_string()]), ix + 5.0 * CW(), yy + CH() * 0.5, S(), TXT);
|
||||
let r = Rect::new(ix + 30.0 * CW(), yy, 4.0 * CW(), CH() * 2.0);
|
||||
button(gfx, r, ">", r.contains(vec2(mx, my)), FRAME);
|
||||
self.buttons.push((r, Btn::MatchSize(1)));
|
||||
yy += CH() * 2.4;
|
||||
}
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user