make it easier to debug objects by warping to them, draw turn cycler

arrows a little more successfully
This commit is contained in:
Dustin Carlino 2020-01-31 14:06:36 -08:00
parent 1d13ae39c3
commit 8228f53d02
8 changed files with 30 additions and 10 deletions

View File

@ -41,6 +41,16 @@ impl<T> Warn<T> {
self.value
}
pub fn expect(self, context: String) -> T {
if !self.warnings.is_empty() {
println!("{} warnings ({}):", self.warnings.len(), context);
for line in self.warnings {
println!("{}", line);
}
}
self.value
}
pub fn get(self, timer: &mut Timer) -> T {
// TODO Context from the current Timer phase, caller
for line in self.warnings {

View File

@ -15,7 +15,7 @@ pub const INACTIVE_CHOICE_COLOR: Color = Color::grey(0.4);
// TODO Don't do this!
const MAX_CHAR_WIDTH: f64 = 25.0;
pub const SCALE_DOWN: f64 = 10.0;
pub const SCALE_DOWN: f64 = 60.0;
// These're hardcoded for simplicity; this list doesn't change much.
const DEJA_VU: FontId = FontId(0);

View File

@ -148,10 +148,10 @@ impl InfoPanel {
time: ui.primary.sim.time(),
composite: Composite::new(ManagedWidget::col(col).bg(Color::grey(0.3)))
.aligned(
HorizontalAlignment::Percent(0.1),
HorizontalAlignment::Percent(0.02),
VerticalAlignment::Percent(0.2),
)
.max_size_percent(40, 60)
.max_size_percent(30, 60)
.build(ctx),
also_draw: batch.upload(ctx),
}

View File

@ -1,5 +1,6 @@
use crate::game::{State, Transition, WizardState};
use crate::helpers::ID;
use crate::sandbox::SandboxMode;
use crate::ui::{PerMapUI, UI};
use ezgui::{EventCtx, GfxCtx, Warper, Wizard};
use geom::Pt2D;
@ -54,12 +55,19 @@ impl Warping {
}
impl State for Warping {
fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> Transition {
fn event(&mut self, ctx: &mut EventCtx, _: &mut UI) -> Transition {
if let Some(evmode) = self.warper.event(ctx) {
Transition::KeepWithMode(evmode)
} else {
ui.primary.current_selection = self.id.clone();
Transition::Pop
if let Some(id) = self.id.clone() {
Transition::PopWithData(Box::new(move |state, ui, ctx| {
if let Some(ref mut s) = state.downcast_mut::<SandboxMode>() {
s.common.launch_info_panel(id, ctx, ui);
}
}))
} else {
Transition::Pop
}
}
}

View File

@ -146,7 +146,7 @@ impl Renderable for DrawIntersection {
*maybe_redraw = Some((
ctx.sim.time(),
g.prerender.upload(batch),
Text::from(Line(format!("{}", idx + 1)).roboto()),
Text::from(Line(format!("{}", idx + 1)).roboto().size(90)),
ctx.map.get_i(self.id).polygon.center(),
));
}

View File

@ -213,7 +213,7 @@ impl DrawPedCrowd {
let label = Text::from(
Line(format!("{}", input.members.len()))
.fg(Color::BLACK)
.size(15),
.size(60),
);
DrawPedCrowd {

View File

@ -12,7 +12,9 @@ impl DrawTurn {
pub fn draw_full(t: &Turn, g: &mut GfxCtx, color: Color) {
g.draw_polygon(
color,
&t.geom.make_arrow(BIG_ARROW_THICKNESS * 2.0).unwrap(),
&t.geom
.make_arrow(BIG_ARROW_THICKNESS)
.expect(format!("draw_full {}", t.id)),
);
}

View File

@ -28,7 +28,7 @@ pub struct SandboxMode {
agent_meter: AgentMeter,
gameplay: Box<dyn gameplay::GameplayState>,
gameplay_mode: GameplayMode,
common: CommonState,
pub common: CommonState,
tool_panel: WrappedComposite,
minimap: Minimap,
}