quick and messy voxel palettes in editor
This commit is contained in:
parent
f764cd14c3
commit
c15da5e333
|
@ -1,9 +1,16 @@
|
||||||
version 1
|
version 1
|
||||||
0 0 0|1 0 0
|
0 2 -1|1 0.6600001 0
|
||||||
0 0 1|1 0 0.77999973
|
0 3 -1|1 0.6600001 0
|
||||||
0 0 2|0.0800004 0 1
|
0 -1 0|1 0.6600001 0
|
||||||
0 0 3|0 0.7600002 1
|
0 0 0|1 0.6600001 0
|
||||||
0 0 4|0 1 0.3399999
|
0 1 0|1 0.6600001 0
|
||||||
0 0 5|0.5 1 0
|
0 -1 5|1 0.6600001 0
|
||||||
0 0 6|1 0.8399999 0
|
0 -1 6|1 0.6600001 0
|
||||||
0 0 7|1 0.4200003 0
|
0 0 4|1 0.6600001 0
|
||||||
|
0 1 4|1 0.6600001 0
|
||||||
|
0 0 7|1 0.6600001 0
|
||||||
|
0 1 7|1 0.6600001 0
|
||||||
|
0 2 1|1 0.6600001 0
|
||||||
|
0 3 1|1 0.6600001 0
|
||||||
|
0 2 5|1 0.6600001 0
|
||||||
|
0 2 6|1 0.6600001 0
|
|
@ -287,8 +287,8 @@ pub fn edit_window_ui(
|
||||||
shared_ui_state.window = pos;
|
shared_ui_state.window = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.show(contexts.ctx_mut(), |ui| {
|
response.show(contexts.ctx_mut(), |ui| {
|
||||||
|
//ui.ctx().set_pixels_per_point(0.1);
|
||||||
let mut label = String::from("Pre-Alpha");
|
let mut label = String::from("Pre-Alpha");
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
writeln!(label, " Controls:").ok();
|
writeln!(label, " Controls:").ok();
|
||||||
|
@ -301,6 +301,48 @@ pub fn edit_window_ui(
|
||||||
color_picker::Alpha::Opaque,
|
color_picker::Alpha::Opaque,
|
||||||
);
|
);
|
||||||
ui.label(label);
|
ui.label(label);
|
||||||
|
let mut color_to_set: Option<Color> = None;
|
||||||
|
for each in &shared_ui_state.meshes {
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
//color palette clickables.
|
||||||
|
let handle = each.id.clone();
|
||||||
|
let asset = oct_assets.get(handle);
|
||||||
|
if asset.is_some() {
|
||||||
|
let list = asset.unwrap().model.collect_voxels();
|
||||||
|
let mut count: Vec<(Color, usize)> = Vec::new();
|
||||||
|
fn eq(c1: &Color, c2: &mut Color) -> bool {
|
||||||
|
c1.r() == c2.r() && c1.g() == c2.g() && c1.b() == c2.b()
|
||||||
|
}
|
||||||
|
for (_, _, color) in &list {
|
||||||
|
let mut is_committed = false;
|
||||||
|
for (each_col, each_count) in &mut count {
|
||||||
|
if eq(color, each_col) {
|
||||||
|
*each_count += 1;
|
||||||
|
is_committed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !is_committed {
|
||||||
|
count.push((color.clone(), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count.sort_by(|a, b| b.1.cmp(&a.1));
|
||||||
|
if !count.is_empty() {
|
||||||
|
ui.label(each.path.clone());
|
||||||
|
for (color, count) in count {
|
||||||
|
let button =
|
||||||
|
egui::Button::new(count.to_string()).fill(egui_color_from(color));
|
||||||
|
if ui.add(button).clicked() {
|
||||||
|
color_to_set = Some(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(color) = color_to_set {
|
||||||
|
shared_ui_state.brush_color = egui_color_from(color);
|
||||||
|
}
|
||||||
if ui.button("Add Origin Voxel").clicked() {
|
if ui.button("Add Origin Voxel").clicked() {
|
||||||
//
|
//
|
||||||
for pair in &mut pairs.handles {
|
for pair in &mut pairs.handles {
|
||||||
|
@ -315,7 +357,7 @@ pub fn edit_window_ui(
|
||||||
}
|
}
|
||||||
if ui.button("Save Any Changes").clicked() {
|
if ui.button("Save Any Changes").clicked() {
|
||||||
//save all files.
|
//save all files.
|
||||||
for each in &shared_ui_state.meshes {
|
for each in &mut shared_ui_state.meshes {
|
||||||
if each.has_changed_since_last_save {
|
if each.has_changed_since_last_save {
|
||||||
let handle = each.id.clone();
|
let handle = each.id.clone();
|
||||||
let path = each.path.clone() + ".vvg";
|
let path = each.path.clone() + ".vvg";
|
||||||
|
@ -327,6 +369,7 @@ pub fn edit_window_ui(
|
||||||
asset.unwrap(),
|
asset.unwrap(),
|
||||||
);
|
);
|
||||||
if result {
|
if result {
|
||||||
|
each.has_changed_since_last_save = false;
|
||||||
println!("{} saved to disk.", &path);
|
println!("{} saved to disk.", &path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue