Skip to content

Commit

Permalink
[#43] Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Oct 28, 2023
1 parent 10648ee commit fa5824f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 48 deletions.
2 changes: 1 addition & 1 deletion macro_ui/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn parse_struct_field(field: &Field) -> TokenStream2 {
} else if is_option(field) {
let option_type = &get_option_type(field);
quote! {
#field_name: if parser.get_str(&format!("{}.{}", path, stringify!(#field_name))).is_some() {
#field_name: if parser.parse_bool(&format!("{}.{}.availability", path, stringify!(#field_name))) {
Some(#option_type::parse(parser, &format!("{}.{}", path, stringify!(#field_name)), &format!(" {}", spaces)))
} else {
Option::None
Expand Down
24 changes: 11 additions & 13 deletions resources/templates/appearance_edit.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -466,29 +466,27 @@
<b>Color:</b> {{ macros::add_select(name="appearance.body.clothing.pants.color", options=[ "Aqua","Black","Blue","Fuchsia","Gray","Green","Lime","Maroon","Navy","Olive","Orange","Purple","Red","SaddleBrown","Silver","Teal","White","Yellow" ], selected=appearance.body.clothing.pants.color, update=true) }}
</li>
<li>
<b>Belt:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.available", options=[ "true","false" ], selected=appearance.body.clothing.pants.belt.available, update=true) }}
{% if appearance.body.clothing.pants.belt.available == "true" %}
{% if appearance.body.clothing.pants.belt %}
<b>Belt Availability:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.availability", options=[ "true","false" ], selected=true, update=true) }}
<b>Belt</b>
<ul>
<li>
<b>Value</b>
<b>Buckle</b>
<ul>
<li>
<b>Buckle</b>
<ul>
<li>
<b>Style:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.value.buckle.style", options=[ "Box","Circle","Frame","Plate" ], selected=appearance.body.clothing.pants.belt.value.buckle.style, update=true) }}
</li>
<li>
<b>Color:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.value.buckle.color", options=[ "Aqua","Black","Blue","Fuchsia","Gray","Green","Lime","Maroon","Navy","Olive","Orange","Purple","Red","SaddleBrown","Silver","Teal","White","Yellow" ], selected=appearance.body.clothing.pants.belt.value.buckle.color, update=true) }}
</li>
</ul>
<b>Style:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.buckle.style", options=[ "Box","Circle","Frame","Plate" ], selected=appearance.body.clothing.pants.belt.buckle.style, update=true) }}
</li>
<li>
<b>Color:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.value.color", options=[ "Aqua","Black","Blue","Fuchsia","Gray","Green","Lime","Maroon","Navy","Olive","Orange","Purple","Red","SaddleBrown","Silver","Teal","White","Yellow" ], selected=appearance.body.clothing.pants.belt.value.color, update=true) }}
<b>Color:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.buckle.color", options=[ "Aqua","Black","Blue","Fuchsia","Gray","Green","Lime","Maroon","Navy","Olive","Orange","Purple","Red","SaddleBrown","Silver","Teal","White","Yellow" ], selected=appearance.body.clothing.pants.belt.buckle.color, update=true) }}
</li>
</ul>
</li>
<li>
<b>Color:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.color", options=[ "Aqua","Black","Blue","Fuchsia","Gray","Green","Lime","Maroon","Navy","Olive","Orange","Purple","Red","SaddleBrown","Silver","Teal","White","Yellow" ], selected=appearance.body.clothing.pants.belt.color, update=true) }}
</li>
</ul>
{% else %}
<b>Belt Availability:</b> {{ macros::add_select(name="appearance.body.clothing.pants.belt.availability", options=[ "true","false" ], selected=false, update=true) }}
{% endif %}
</li>
</ul>
Expand Down
19 changes: 7 additions & 12 deletions resources/templates/character.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -467,28 +467,23 @@
<b>Color:</b> {{ appearance.body.clothing.pants.color }}
</li>
<li>
{% if appearance.body.clothing.pants.belt %}
<b>Belt</b>
{% if appearance.body.clothing.pants.belt.available %}
<ul>
<li>
<b>Value</b>
<b>Buckle</b>
<ul>
<li>
<b>Buckle</b>
<ul>
<li>
<b>Style:</b> {{ appearance.body.clothing.pants.belt.value.buckle.style }}
</li>
<li>
<b>Color:</b> {{ appearance.body.clothing.pants.belt.value.buckle.color }}
</li>
</ul>
<b>Style:</b> {{ appearance.body.clothing.pants.belt.buckle.style }}
</li>
<li>
<b>Color:</b> {{ appearance.body.clothing.pants.belt.value.color }}
<b>Color:</b> {{ appearance.body.clothing.pants.belt.buckle.color }}
</li>
</ul>
</li>
<li>
<b>Color:</b> {{ appearance.body.clothing.pants.belt.color }}
</li>
</ul>
{% endif %}
</li>
Expand Down
31 changes: 17 additions & 14 deletions rpg_tools_core/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ impl EditorVisitor {
}

fn add_selection(&mut self, path: &str, variants: &[String]) {
self.add_named_selection(&self.get_name(), path, variants);
self.add_named_selection(&self.get_name(), path, variants, path);
}

fn add_named_selection(&mut self, name: &str, path: &str, variants: &[String]) {
fn add_named_selection(&mut self, name: &str, path: &str, variants: &[String], selected: &str) {
self.lines.push(format!(
"{0}<b>{1}:</b> {{{{ macros::add_select(name=\"{2}\", options=[ {3} ], selected={2}, update=true) }}}}",
"{}<b>{}:</b> {{{{ macros::add_select(name=\"{}\", options=[ {} ], selected={}, update=true) }}}}",
self.spaces,
name,
path,
variants.iter().map(|v| format!("\"{}\"", v)).collect::<Vec<_>>().join(","),
selected,
));
}
}
Expand Down Expand Up @@ -101,22 +102,24 @@ impl UiVisitor for EditorVisitor {
}

fn enter_option(&mut self) {
self.add_selection(
&format!("{}.available", self.get_path()),
self.lines
.push(format!("{}{{% if {} %}}", self.spaces, self.get_path(),));
self.add_named_selection(
&format!("{} Availability", self.get_name()),
&format!("{}.availability", self.get_path()),
&vec!["true".to_string(), "false".to_string()],
"true",
);
self.lines.push(format!(
"{}{{% if {}.available == \"true\" %}}",
self.spaces,
self.get_path(),
));
self.enter_list();
self.enter_child("value");
}

fn leave_option(&mut self) {
self.leave_child();
self.leave_list();
self.lines.push(format!("{}{{% else %}}", self.spaces));
self.add_named_selection(
&format!("{} Availability", self.get_name()),
&format!("{}.availability", self.get_path()),
&vec!["true".to_string(), "false".to_string()],
"false",
);
self.lines.push(format!("{}{{% endif %}}", self.spaces));
}

Expand Down
9 changes: 1 addition & 8 deletions rpg_tools_core/src/ui/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,10 @@ impl UiVisitor for ViewerVisitor {

fn enter_option(&mut self) {
self.lines
.push(format!("{}<b>{}</b>", self.spaces, self.get_name(),));
self.lines.push(format!(
"{}{{% if {} %}}",
self.spaces,
self.get_path(),
));
self.enter_list();
.push(format!("{}{{% if {} %}}", self.spaces, self.get_path(),));
}

fn leave_option(&mut self) {
self.leave_list();
self.lines.push(format!("{}{{% endif %}}", self.spaces));
}

Expand Down

0 comments on commit fa5824f

Please sign in to comment.