Rank badges and level equipment; no edge scrolling before the mouse has moved
- Military rank badges instead of level numbers: Lv 2-4 bronze chevrons, Lv 5-7 silver bars, Lv 8-9 gold stars, Lv 10 gold star in a wreath; rank names in the unit info (EN/DE) - Equipment grows with the level: shoulder pieces (bronze/silver/gold), helmets with horns (creatures) or plumes (heroes), capes from Lv 7, glowing ring from Lv 9, aura at Lv 10 - Fix: before the first mouse move the pointer counts as (0, 0) and the edge scrolling moved the camera at the start and after loading a savegame Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
52d49b0243
commit
729dd4fe4c
6 files changed
+170
-5
No files matched your search
+57
@@ -1183,6 +1183,63 @@ impl Gfx {
|
||||
s.chars().count() as f32 * GW * scale
|
||||
}
|
||||
|
||||
// Military rank badge for a level (k = size of one badge pixel in device pixels):
|
||||
// Lv 2-4: 1-3 bronze chevrons, Lv 5-7: 1-3 silver bars, Lv 8-9: 1-2 gold stars,
|
||||
// Lv 10: a gold star in a green wreath. Lv 1 has none. Returns the width drawn.
|
||||
pub fn badge(&self, x: f32, y: f32, level: u32, k: f32) -> f32 {
|
||||
let px = |gx: i32, gy: i32, c: Color| draw_rectangle(x + gx as f32 * k, y + gy as f32 * k, k, k, c);
|
||||
let plate = |w: i32, h: i32| draw_rectangle(x - k, y - k, (w + 2) as f32 * k, (h + 2) as f32 * k, Color::new(0.05, 0.03, 0.04, 0.85));
|
||||
let bronze = Color::from_rgba(214, 140, 70, 255);
|
||||
let silver = Color::from_rgba(215, 222, 235, 255);
|
||||
let gold = Color::from_rgba(255, 210, 70, 255);
|
||||
let star = |ox: i32, oy: i32, c: Color| {
|
||||
for (gx, gy) in [(2, 0), (1, 1), (2, 1), (3, 1), (0, 2), (1, 2), (2, 2), (3, 2), (4, 2), (1, 3), (2, 3), (3, 3), (0, 4), (1, 4), (3, 4), (4, 4)] {
|
||||
px(ox + gx, oy + gy, c);
|
||||
}
|
||||
};
|
||||
match level {
|
||||
0 | 1 => 0.0,
|
||||
2..=4 => {
|
||||
let n = (level - 1) as i32;
|
||||
plate(5, n * 2 + 1);
|
||||
for c in 0..n {
|
||||
// a chevron pointing up
|
||||
for (gx, gy) in [(2, 0), (1, 1), (3, 1), (0, 2), (4, 2)] {
|
||||
px(gx, c * 2 + gy - if gy == 2 { 1 } else { 0 }, bronze);
|
||||
}
|
||||
}
|
||||
7.0 * k
|
||||
}
|
||||
5..=7 => {
|
||||
let n = (level - 4) as i32;
|
||||
plate(5, n * 2 - 1);
|
||||
for b in 0..n {
|
||||
for gx in 0..5 {
|
||||
px(gx, b * 2, silver);
|
||||
}
|
||||
}
|
||||
7.0 * k
|
||||
}
|
||||
8 | 9 => {
|
||||
let n = (level - 7) as i32;
|
||||
plate(n * 6 - 1, 5);
|
||||
for s in 0..n {
|
||||
star(s * 6, 0, gold);
|
||||
}
|
||||
(n * 6 + 1) as f32 * k
|
||||
}
|
||||
_ => {
|
||||
plate(9, 7);
|
||||
let green = Color::from_rgba(90, 170, 80, 255);
|
||||
for (gx, gy) in [(0, 2), (0, 3), (0, 4), (1, 5), (2, 6), (8, 2), (8, 3), (8, 4), (7, 5), (6, 6), (3, 6), (5, 6), (1, 1), (7, 1)] {
|
||||
px(gx, gy, green);
|
||||
}
|
||||
star(2, 1, gold);
|
||||
11.0 * k
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// text with a dark shadow
|
||||
pub fn text_sh(&self, s: &str, x: f32, y: f32, scale: f32, color: Color) {
|
||||
self.text(s, x + scale, y + scale, scale, Color::new(0.0, 0.0, 0.0, color.a * 0.85));
|
||||
|
||||
Reference in new issue
Block a user