|
1 | 1 | use crate::client_state::ShownPlayer;
|
2 | 2 | use macroquad::math::{vec2, Vec2};
|
3 |
| -use macroquad::prelude::screen_height; |
4 | 3 | use macroquad::ui::root_ui;
|
5 |
| -use macroquad::window::screen_width; |
6 | 4 |
|
7 | 5 | pub fn top_left_label(p: Vec2, label: &str) {
|
8 | 6 | root_ui().label(p, label);
|
9 | 7 | }
|
10 | 8 |
|
11 |
| -pub fn top_center_label(p: Vec2, label: &str) { |
12 |
| - root_ui().label(vec2(screen_width() / 2.0, 0.) + p, label); |
| 9 | +pub fn top_center_label(player: &ShownPlayer, p: Vec2, label: &str) { |
| 10 | + root_ui().label(vec2(player.screen_size.x / 2.0, 0.) + p, label); |
13 | 11 | }
|
14 | 12 |
|
15 |
| -pub fn right_center_label(p: Vec2, label: &str) { |
16 |
| - root_ui().label(vec2(screen_width(), screen_height() / 2.0) + p, label); |
| 13 | +pub fn right_center_label(player: &ShownPlayer, p: Vec2, label: &str) { |
| 14 | + root_ui().label( |
| 15 | + vec2(player.screen_size.x, player.screen_size.y / 2.0) + p, |
| 16 | + label, |
| 17 | + ); |
17 | 18 | }
|
18 | 19 |
|
19 |
| -pub fn right_center_button(p: Vec2, label: &str) -> bool { |
20 |
| - root_ui().button(vec2(screen_width(), screen_height() / 2.0) + p, label) |
| 20 | +pub fn right_center_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool { |
| 21 | + root_ui().button( |
| 22 | + vec2(player.screen_size.x, player.screen_size.y / 2.0) + p, |
| 23 | + label, |
| 24 | + ) |
21 | 25 | }
|
22 | 26 |
|
23 |
| -pub fn bottom_left_button(p: Vec2, label: &str) -> bool { |
24 |
| - root_ui().button(vec2(0., screen_height()) + p, label) |
| 27 | +pub fn bottom_left_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool { |
| 28 | + root_ui().button(vec2(0., player.screen_size.y) + p, label) |
25 | 29 | }
|
26 | 30 |
|
27 |
| -pub fn bottom_right_button(p: Vec2, label: &str) -> bool { |
28 |
| - root_ui().button(vec2(screen_width(), screen_height()) + p, label) |
| 31 | +pub fn bottom_right_button(player: &ShownPlayer, p: Vec2, label: &str) -> bool { |
| 32 | + root_ui().button(vec2(player.screen_size.x, player.screen_size.y) + p, label) |
29 | 33 | }
|
30 | 34 |
|
31 | 35 | pub fn cancel_pos(player: &ShownPlayer) -> Vec2 {
|
32 | 36 | small_dialog(player)
|
33 |
| - .then(|| Vec2::new(screen_width() / 4.0, 190.)) |
34 |
| - .unwrap_or_else(|| Vec2::new(screen_width() / 2., screen_height() - 130.)) |
| 37 | + .then(|| Vec2::new(player.screen_size.x / 4.0, 190.)) |
| 38 | + .unwrap_or_else(|| Vec2::new(player.screen_size.x / 2., player.screen_size.y - 130.)) |
35 | 39 | }
|
36 | 40 |
|
37 | 41 | pub fn ok_pos(player: &ShownPlayer) -> Vec2 {
|
38 | 42 | small_dialog(player)
|
39 |
| - .then(|| Vec2::new(screen_width() / 4.0 - 150., 190.)) |
40 |
| - .unwrap_or_else(|| Vec2::new(screen_width() / 2. - 150., screen_height() - 130.)) |
| 43 | + .then(|| Vec2::new(player.screen_size.x / 4.0 - 150., 190.)) |
| 44 | + .unwrap_or_else(|| { |
| 45 | + Vec2::new( |
| 46 | + player.screen_size.x / 2. - 150., |
| 47 | + player.screen_size.y - 130., |
| 48 | + ) |
| 49 | + }) |
41 | 50 | }
|
42 | 51 |
|
43 | 52 | pub fn ok_only_pos(player: &ShownPlayer) -> Vec2 {
|
44 | 53 | small_dialog(player)
|
45 |
| - .then(|| Vec2::new(screen_width() / 4.0 - 75., 190.)) |
46 |
| - .unwrap_or_else(|| Vec2::new(screen_width() / 2. - 75., screen_height() - 130.)) |
| 54 | + .then(|| Vec2::new(player.screen_size.x / 4.0 - 75., 190.)) |
| 55 | + .unwrap_or_else(|| Vec2::new(player.screen_size.x / 2. - 75., player.screen_size.y - 130.)) |
47 | 56 | }
|
48 | 57 |
|
49 | 58 | fn small_dialog(player: &ShownPlayer) -> bool {
|
|
0 commit comments