|
|
@@ -215,18 +215,48 @@ impl Geometry { |
|
|
|
self.push_filled(x1, y1, x2, y2, c.r, c.g, c.b, c.a); |
|
|
|
} |
|
|
|
|
|
|
|
// renders a rectangle over the TileFrame |
|
|
|
// frame should be in screen co-ordinates |
|
|
|
pub fn push_filled_block(&mut self, block: Block2D, c: Col) { |
|
|
|
let w = self.block_width; |
|
|
|
let h = self.block_height; |
|
|
|
|
|
|
|
let x1 = (block.x as f32) * w; |
|
|
|
let y1 = (block.y as f32) * h; |
|
|
|
let x2 = ((block.x + 1) as f32) * w; |
|
|
|
let y2 = ((block.y + 1) as f32) * h; |
|
|
|
let x2 = x1 + w; |
|
|
|
let y2 = y1 + h; |
|
|
|
|
|
|
|
self.push_filled(x1, y1, x2, y2, c.r, c.g, c.b, c.a); |
|
|
|
} |
|
|
|
|
|
|
|
// block is position of lower left hand block |
|
|
|
// width and height are in block coordinates |
|
|
|
// |
|
|
|
pub fn push_filled_dialogue_bg(&mut self, block: Block2D, width: usize, height: usize, c: Col) { |
|
|
|
let w = self.block_width; |
|
|
|
let h = self.block_height; |
|
|
|
|
|
|
|
let x1 = (block.x as f32) * w; |
|
|
|
let y1 = (block.y as f32) * h; |
|
|
|
let x2 = x1 + (width as f32 * w); |
|
|
|
let y2 = y1 + (height as f32 * h); |
|
|
|
|
|
|
|
self.push_filled(x1, y1, x2, y2, c.r, c.g, c.b, c.a); |
|
|
|
|
|
|
|
let no_offset = Vec2D { x: 0.0, y: 0.0}; |
|
|
|
for y in block.y..(block.y + height as i32) { |
|
|
|
self.push_sprite(Sprite::BorderLeft, c, Block2D { x: block.x - 1, y }, no_offset); |
|
|
|
self.push_sprite(Sprite::BorderRight, c, Block2D { x: block.x + width as i32, y }, no_offset); |
|
|
|
} |
|
|
|
|
|
|
|
for x in block.x..(block.x + width as i32) { |
|
|
|
self.push_sprite(Sprite::BorderBottom, c, Block2D { x, y: block.y - 1}, no_offset); |
|
|
|
self.push_sprite(Sprite::BorderTop, c, Block2D { x, y: block.y + height as i32}, no_offset); |
|
|
|
} |
|
|
|
|
|
|
|
self.push_sprite(Sprite::BorderBottomLeft, c, Block2D { x: block.x - 1, y: block.y - 1 }, no_offset); |
|
|
|
self.push_sprite(Sprite::BorderBottomRight, c, Block2D { x: block.x + width as i32, y: block.y - 1 }, no_offset); |
|
|
|
|
|
|
|
self.push_sprite(Sprite::BorderTopLeft, c, Block2D { x: block.x - 1, y: block.y + height as i32 }, no_offset); |
|
|
|
self.push_sprite(Sprite::BorderTopRight, c, Block2D { x: block.x + width as i32, y: block.y + height as i32 }, no_offset); |
|
|
|
} |
|
|
|
|
|
|
|
pub fn push_outline_block(&mut self, block: Block2D, thickness: f32, c: Col) { |
|
|
@@ -279,6 +309,31 @@ impl Geometry { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// render first line at pos |
|
|
|
// remaining lines in pos.y - n |
|
|
|
pub fn push_centred_boxed_multiline(&mut self, lines: &Vec<&str>, centre: Block2D, text_col: Col, background_colour: Col) { |
|
|
|
|
|
|
|
let longest_length = lines.iter().fold(0, |longest, line| |
|
|
|
if line.len() > longest { |
|
|
|
line.len() |
|
|
|
} else { |
|
|
|
longest |
|
|
|
}); |
|
|
|
|
|
|
|
let height = lines.len(); |
|
|
|
let width = longest_length / 2; |
|
|
|
let pos = Block2D { x: centre.x - (width as i32 / 2), y: centre.y + (height as i32 / 2)}; |
|
|
|
|
|
|
|
self.push_filled_dialogue_bg(Block2D { x: pos.x, y: pos.y - (height as i32 - 1)}, |
|
|
|
width, |
|
|
|
height, |
|
|
|
background_colour); |
|
|
|
|
|
|
|
for y in 0..height { |
|
|
|
self.push_text(lines[y], Block2D { x: pos.x, y: pos.y - (y as i32) }, text_col); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fn push_char(&mut self, c: char, pos: Vec2D, col: Col, char_w: f32, char_h: f32) -> Vec2D { |
|
|
|
let (t1, t2, t3, t4) = self.get_char_uv(c); |
|
|
|
|