DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 7ce88fae9680596019fc15be5ec510df7ea939b8 deck-builder/client/src/util/action_to_log.rs -rw-r--r-- 1.6 KiB
7ce88faeJonni Liljamo feat(client): sorta finished log ui, remove old 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * This file is part of laurelin_client
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::prelude::*;

use crate::api::game::{Action, Command};

macro_rules! section {
    ($value:expr, $style:ident) => {
        TextSection {
            value: $value,
            style: $style.clone(),
        }
    };

    ($value:expr, $style:expr) => {
        TextSection {
            value: $value,
            style: $style,
        }
    };
}

pub fn action_to_log(
    action: &Action,
    (font, font_bold): (Handle<Font>, Handle<Font>),
    style: TextStyle,
) -> Vec<TextSection> {
    match &action.command {
        Command::InitSupplyPile { card, amount } => {
            vec![
                section!(format!("Created supply pile of "), style),
                section!(format!("{}", card.name), TextStyle {
                    font: font_bold.clone(),
                    ..style.clone()
                }),
                section!(format!(" with "), style),
                section!(format!("{}", amount), TextStyle {
                    font: font_bold.clone(),
                    ..style.clone()
                }),
                section!(format!(" cards."), TextStyle {
                    ..style.clone()
                }),
            ]
        }
        _ => {
            vec![
                TextSection {
                    value: format!("No log configuration for this command"),
                    style: TextStyle {
                        ..style
                    },
                },
            ]
        }
    }
}