Editor layout fixes from a visual check
No fog while painting, readable tool bars, a two-row spawn block, a dialog that keeps the clicks to itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abe01ff23e
commit
aacc6a00b2
3 files changed
+77
-41
No files matched your search
+42
-25
@@ -207,6 +207,13 @@ impl Editor {
|
||||
pub fn frame(&mut self, gfx: &Gfx, r3d: &mut R3d, dt: f32, now: f64) -> EdAction {
|
||||
clear_background(Color::from_rgba(4, 3, 5, 255));
|
||||
self.im.begin();
|
||||
// an open dialog takes the clicks: the page behind it only draws
|
||||
let held = (self.im.pressed, self.im.released, self.im.wheel);
|
||||
if self.open_dialog {
|
||||
self.im.pressed = false;
|
||||
self.im.released = false;
|
||||
self.im.wheel = 0.0;
|
||||
}
|
||||
let mut act = EdAction::None;
|
||||
match self.screen {
|
||||
Screen::Map(i) => {
|
||||
@@ -236,6 +243,7 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
if self.open_dialog {
|
||||
(self.im.pressed, self.im.released, self.im.wheel) = held;
|
||||
begin_ui();
|
||||
if let Some(a) = self.open_screen(gfx) {
|
||||
act = a;
|
||||
@@ -263,30 +271,18 @@ impl Editor {
|
||||
let mut act = EdAction::None;
|
||||
let (w, h) = (sw(), sh());
|
||||
let im = &mut self.im;
|
||||
// top bar: name, author, language, file and server buttons
|
||||
// top bar: the title and the buttons, then name, author, language
|
||||
let bar_h = CH() * 5.0;
|
||||
panel(gfx, Rect::new(0.0, 0.0, w, bar_h), "");
|
||||
gfx.text(&tr("ed.campaign"), CW(), CH() * 0.4, S(), FRAME_HI);
|
||||
let fw = (CW() * 24.0).min(w * 0.25);
|
||||
label(gfx, CW(), CH() * 2.0, &tr("ed.name"), DIM);
|
||||
im.text_field(gfx, id("cname", 0), Rect::new(CW() * 8.0, CH() * 1.7, fw, CH() * 1.5), &mut self.doc.name, 40);
|
||||
label(gfx, CW(), CH() * 3.5, &tr("ed.author"), DIM);
|
||||
im.text_field(gfx, id("cauthor", 0), Rect::new(CW() * 8.0, CH() * 3.3, fw, CH() * 1.5), &mut self.doc.author, 32);
|
||||
let lx = CW() * 9.0 + fw;
|
||||
label(gfx, lx, CH() * 2.0, &tr("ed.language"), DIM);
|
||||
let langs = languages();
|
||||
let names: Vec<String> = langs.iter().map(|(_, n)| n.clone()).collect();
|
||||
let cur = langs.iter().find(|(c, _)| *c == self.doc.language).map(|(_, n)| n.clone()).unwrap_or_else(|| self.doc.language.clone());
|
||||
if let Some(k) = im.dropdown(gfx, id("clang", 0), Rect::new(lx, CH() * 3.3, CW() * 14.0, CH() * 1.5), &cur, &names) {
|
||||
self.doc.language = langs[k].0.clone();
|
||||
}
|
||||
// buttons on the right
|
||||
gfx.text(&tr("ed.campaign"), CW(), CH() * 0.8, S(), FRAME_HI);
|
||||
let labels = [tr("ed.play"), tr("ed.new"), tr("ed.open"), tr("ed.save_file"), tr("ed.save_server"), tr("ed.close")];
|
||||
let bw = labels.iter().map(|l| gfx.measure(l, S())).fold(0.0, f32::max) + CW() * 2.0;
|
||||
let mut bx = w - CW() - bw;
|
||||
let mut bx = w - CW();
|
||||
for k in (0..labels.len()).rev() {
|
||||
let r = Rect::new(bx, CH() * 0.6, bw, CH() * 1.7);
|
||||
if im.button(gfx, r, &labels[k]) {
|
||||
let bw = gfx.measure(&labels[k], S()) + CW() * 2.0;
|
||||
bx -= bw;
|
||||
let r = Rect::new(bx, CH() * 0.5, bw, CH() * 1.7);
|
||||
let clicked = if k == 0 { im.button_c(gfx, r, &labels[k], GREEN) } else { im.button(gfx, r, &labels[k]) };
|
||||
if clicked {
|
||||
match k {
|
||||
0 => act = EdAction::Play,
|
||||
1 => {
|
||||
@@ -303,18 +299,39 @@ impl Editor {
|
||||
_ => act = EdAction::Close,
|
||||
}
|
||||
}
|
||||
bx -= bw + CW() * 0.5;
|
||||
bx -= CW() * 0.5;
|
||||
}
|
||||
let y2 = CH() * 2.9;
|
||||
let fw = (CW() * 22.0).min(w * 0.2);
|
||||
let mut x = CW();
|
||||
label(gfx, x, y2 + CH() * 0.25, &tr("ed.name"), DIM);
|
||||
x += gfx.measure(&tr("ed.name"), S()) + CW();
|
||||
im.text_field(gfx, id("cname", 0), Rect::new(x, y2, fw, CH() * 1.5), &mut self.doc.name, 40);
|
||||
x += fw + CW() * 1.5;
|
||||
label(gfx, x, y2 + CH() * 0.25, &tr("ed.author"), DIM);
|
||||
x += gfx.measure(&tr("ed.author"), S()) + CW();
|
||||
im.text_field(gfx, id("cauthor", 0), Rect::new(x, y2, fw * 0.8, CH() * 1.5), &mut self.doc.author, 32);
|
||||
x += fw * 0.8 + CW() * 1.5;
|
||||
label(gfx, x, y2 + CH() * 0.25, &tr("ed.language"), DIM);
|
||||
x += gfx.measure(&tr("ed.language"), S()) + CW();
|
||||
let langs = languages();
|
||||
let names: Vec<String> = langs.iter().map(|(_, n)| n.clone()).collect();
|
||||
let cur = langs.iter().find(|(c, _)| *c == self.doc.language).map(|(_, n)| n.clone()).unwrap_or_else(|| self.doc.language.clone());
|
||||
if let Some(k) = im.dropdown(gfx, id("clang", 0), Rect::new(x, y2, CW() * 14.0, CH() * 1.5), &cur, &names) {
|
||||
self.doc.language = langs[k].0.clone();
|
||||
}
|
||||
x += CW() * 15.5;
|
||||
let mut publ = self.published;
|
||||
if self.server_id.is_some() && im.toggle(gfx, w - CW() * 2.0 - bw * 3.5, CH() * 3.1, &tr("ed.published"), &mut publ) {
|
||||
if self.server_id.is_some() && im.toggle(gfx, x, y2, &tr("ed.published"), &mut publ) {
|
||||
self.published = publ;
|
||||
act = EdAction::Publish(publ);
|
||||
}
|
||||
let add = Rect::new(w - CW() - bw, CH() * 3.0, bw, CH() * 1.7);
|
||||
if im.button(gfx, add, &tr("ed.add_mission")) {
|
||||
let al = tr("ed.add_mission");
|
||||
let aw = gfx.measure(&al, S()) + CW() * 2.0;
|
||||
if im.button(gfx, Rect::new(w - CW() - aw, y2 - CH() * 0.1, aw, CH() * 1.7), &al) {
|
||||
let n = self.doc.missions.len();
|
||||
self.doc.add_mission();
|
||||
self.doc.missions[n].pos = (-self.graph.pan.x / CW() * 0.0 + 40.0 + (n % 5) as f32 * 220.0, 40.0 + (n / 5) as f32 * 140.0);
|
||||
self.doc.missions[n].pos = (40.0 + (n % 5) as f32 * 220.0, 40.0 + (n / 5) as f32 * 140.0);
|
||||
}
|
||||
|
||||
// the canvas: cards and arrows
|
||||
|
||||
Reference in new issue
Block a user