mirror of
https://codeberg.org/icewind/vmt-parser.git
synced 2026-06-03 12:04:06 +02:00
patch
This commit is contained in:
parent
9fff536cc3
commit
b6a7ee888b
4 changed files with 28 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ mod worldvertextransition;
|
||||||
|
|
||||||
pub use lightmappedgeneric::LightMappedGenericMaterial;
|
pub use lightmappedgeneric::LightMappedGenericMaterial;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
pub use unlitgeneric::UnlitGenericMaterial;
|
pub use unlitgeneric::UnlitGenericMaterial;
|
||||||
pub use water::WaterMaterial;
|
pub use water::WaterMaterial;
|
||||||
pub use worldvertextransition::WorldVertexTransitionMaterial;
|
pub use worldvertextransition::WorldVertexTransitionMaterial;
|
||||||
|
|
@ -19,4 +20,12 @@ pub enum Material {
|
||||||
Water(WaterMaterial),
|
Water(WaterMaterial),
|
||||||
#[serde(rename = "worldvertextransition")]
|
#[serde(rename = "worldvertextransition")]
|
||||||
WorldVertexTransition(WorldVertexTransitionMaterial),
|
WorldVertexTransition(WorldVertexTransitionMaterial),
|
||||||
|
#[serde(rename = "patch")]
|
||||||
|
Patch(PatchMaterial),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct PatchMaterial {
|
||||||
|
include: String,
|
||||||
|
replace: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
tests/data/patch.vmt
Normal file
8
tests/data/patch.vmt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
"patch"
|
||||||
|
{
|
||||||
|
"include" "materials/glass/glasswindow001a.vmt"
|
||||||
|
"replace"
|
||||||
|
{
|
||||||
|
"$envmap" "maps/koth_bagel_rc2a/c1920_704_41"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ use vmt_parser::from_str;
|
||||||
#[test_case("tests/data/mvm_backpack.vmt")]
|
#[test_case("tests/data/mvm_backpack.vmt")]
|
||||||
#[test_case("tests/data/water_murky.vmt")]
|
#[test_case("tests/data/water_murky.vmt")]
|
||||||
#[test_case("tests/data/blendrocktograss002.vmt")]
|
#[test_case("tests/data/blendrocktograss002.vmt")]
|
||||||
|
#[test_case("tests/data/patch.vmt")]
|
||||||
fn test_serde(path: &str) {
|
fn test_serde(path: &str) {
|
||||||
let raw = read_to_string(path).unwrap();
|
let raw = read_to_string(path).unwrap();
|
||||||
match from_str(&raw) {
|
match from_str(&raw) {
|
||||||
|
|
|
||||||
10
tests/snapshots/parse__tests__data__patch.vmt.snap
Normal file
10
tests/snapshots/parse__tests__data__patch.vmt.snap
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: tests/parse.rs
|
||||||
|
expression: result
|
||||||
|
---
|
||||||
|
patch(PatchMaterial(
|
||||||
|
include: "materials/glass/glasswindow001a.vmt",
|
||||||
|
replace: {
|
||||||
|
"$envmap": "maps/koth_bagel_rc2a/c1920_704_41",
|
||||||
|
},
|
||||||
|
))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue