mindustry logic execution, map- and schematic- parsing and rendering
tint storage blocks
bendn 2023-06-30
parent 9c51474 · commit 07be37f
-rw-r--r--Cargo.toml2
-rw-r--r--src/data/renderer.rs12
-rw-r--r--src/team.rs29
3 files changed, 32 insertions, 11 deletions
diff --git a/Cargo.toml b/Cargo.toml
index adcbea5..03d69b1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mindus"
-version = "1.0.6"
+version = "1.0.7"
edition = "2021"
description = "A library for working with mindustry data formats (eg schematics) (fork of plandustry)"
authors = [
diff --git a/src/data/renderer.rs b/src/data/renderer.rs
index a22a7ef..05486d8 100644
--- a/src/data/renderer.rs
+++ b/src/data/renderer.rs
@@ -7,7 +7,8 @@ use image::imageops::overlay;
use image::{DynamicImage, RgbaImage};
use zip::ZipArchive;
-use crate::utils::image::repeat;
+use crate::team::SHARDED;
+use crate::utils::image::*;
use super::schematic::Schematic;
@@ -33,8 +34,8 @@ fn load_zip() {
}
}
pub const TOP: &str = "-top";
-const SUFFIXES: &[&str; 8] = &[
- "-bottom", "-mid", "", "-base", "-left", "-right", TOP, "-over",
+const SUFFIXES: &[&str; 9] = &[
+ "-bottom", "-mid", "", "-base", "-left", "-right", TOP, "-over", "-team",
];
pub(crate) fn read<S>(category: &str, name: &str, size: S) -> RgbaImage
where
@@ -54,7 +55,10 @@ where
{
let mut c = RgbaImage::new(size.into() * 32, size.into() * 32);
for suffix in suffixes {
- if let Some(p) = load(category, &format!("{name}{suffix}")) {
+ if let Some(mut p) = load(category, &format!("{name}{suffix}")) {
+ if suffix == &"-team" {
+ tint(&mut p, SHARDED.color());
+ }
image::imageops::overlay(&mut c, &p, 0, 0);
}
}
diff --git a/src/team.rs b/src/team.rs
index f431bd2..f25f7a4 100644
--- a/src/team.rs
+++ b/src/team.rs
@@ -1,6 +1,8 @@
use std::error::Error;
use std::fmt;
+use image::Rgb;
+
use crate::content::{Content, Type};
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
@@ -112,15 +114,30 @@ impl Content for Team {
}
}
-#[allow(dead_code)]
+impl Team {
+ pub fn color(&self) -> Rgb<u8> {
+ macro_rules! h {
+ ($x:literal) => {
+ Rgb(color_hex::color_from_hex!($x))
+ };
+ }
+ match self {
+ &SHARDED => h!("ffd37f"),
+ &DERELICT => h!("4d4e58"),
+ &CRUX => h!("f25555"),
+ &MALIS => h!("a27ce5"),
+ &GREEN => h!("54d67d"),
+ &BLUE => h!("6c87fd"),
+ &NEOPLASTIC => h!("e05438"),
+ _ => h!("a9a9a9"),
+ }
+ }
+}
+
pub const DERELICT: Team = Team(0);
-#[allow(dead_code)]
pub const SHARDED: Team = Team(1);
-#[allow(dead_code)]
pub const CRUX: Team = Team(2);
-#[allow(dead_code)]
pub const MALIS: Team = Team(3);
-#[allow(dead_code)]
pub const GREEN: Team = Team(4);
-#[allow(dead_code)]
pub const BLUE: Team = Team(5);
+pub const NEOPLASTIC: Team = Team(6);