mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-30 10:03:56 +01:00
Put a blank line after the multi-line early-exit guards in the texture set code
Spacing only (CODE_STYLE: a blank line after a multi-line if/let-else guard), in methods this branch adds or changes.
This commit is contained in:
1 parent
8032697c99
commit
fcd3644744
6 files changed
+14
No files matched your search
@@ -1203,6 +1203,7 @@ fn tile_local((x, y): (f32, f32), (block, tile): ([u32; 2], [u32; 2])) -> Option
|
||||
if local[0] >= size[0] || local[1] >= size[1] {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some((origin, [(local[0] + 0.5) / size[0], (local[1] + 0.5) / size[1]], size))
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +278,7 @@ impl TextureSet {
|
||||
if self.tile_resolutions.is_empty() {
|
||||
return (self.resolution, self.height());
|
||||
}
|
||||
|
||||
let block = self.block_resolution();
|
||||
(block, block)
|
||||
}
|
||||
@@ -823,15 +824,18 @@ impl Project {
|
||||
if self.format_version > FORMAT_VERSION {
|
||||
return Err(CoreError::Invalid(format!("project format {} is newer than this TextureCraft supports ({FORMAT_VERSION})", self.format_version)));
|
||||
}
|
||||
|
||||
if let Some(t) = self.texture_sets.iter().find(|t| !t.uv_tiles.is_empty() && (t.tile_grid().is_none() || !t.uv_tiles.is_sorted_by(|a, b| a < b))) {
|
||||
return Err(CoreError::Invalid(format!("texture set \"{}\" has invalid UV tiles {:?}", t.name, t.uv_tiles)));
|
||||
}
|
||||
|
||||
let bad_tile_res = |t: &TextureSet| {
|
||||
t.tile_resolutions.iter().any(|(u, r)| !t.uv_tiles.contains(u) || !r.is_power_of_two() || !(MIN_RESOLUTION..=MAX_RESOLUTION).contains(r))
|
||||
};
|
||||
if let Some(t) = self.texture_sets.iter().find(|t| bad_tile_res(t)) {
|
||||
return Err(CoreError::Invalid(format!("texture set \"{}\" has invalid UV tile resolutions {:?}", t.name, t.tile_resolutions)));
|
||||
}
|
||||
|
||||
let bad_height = |set: &TextureSet| {
|
||||
set.resolution_height
|
||||
.is_some_and(|height| !height.is_power_of_two() || !(MIN_RESOLUTION..=MAX_RESOLUTION).contains(&height) || !set.tile_resolutions.is_empty())
|
||||
@@ -839,6 +843,7 @@ impl Project {
|
||||
if let Some(set) = self.texture_sets.iter().find(|set| bad_height(set)) {
|
||||
return Err(CoreError::Invalid(format!("texture set \"{}\" has an invalid height {:?}", set.name, set.resolution_height)));
|
||||
}
|
||||
|
||||
let mut seen = BTreeSet::new();
|
||||
for ts in 0..self.texture_sets.len() {
|
||||
for (id, depth) in self.walk(ts) {
|
||||
|
||||
@@ -175,6 +175,7 @@ impl ResizeTask {
|
||||
if set.resolution_height.is_some() && !set.tile_resolutions.is_empty() {
|
||||
return Err(bad("textureSet.resolution", "a texture set whose UV tiles have their own sizes stays square"));
|
||||
}
|
||||
|
||||
crate::session::check_size(set)?;
|
||||
let size = set.size();
|
||||
let mut log = crate::log::SessionLog::new();
|
||||
@@ -280,6 +281,7 @@ fn channels(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if remove.contains(&Channel::BaseColor) {
|
||||
return Err(bad(cmd, "base color can't be removed"));
|
||||
}
|
||||
|
||||
if let Some(both) = add.iter().find(|c| remove.contains(c)) {
|
||||
return Err(bad(cmd, format!("{} is both added and removed", both.label())));
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ impl ChannelManager {
|
||||
// Other sets may differ from this one: send the whole list so every set ends up the same
|
||||
return (on, off.into_iter().filter(|c| *c != Channel::BaseColor).collect());
|
||||
}
|
||||
|
||||
(on.into_iter().filter(|c| !set.has_channel(*c)).collect(), off.into_iter().filter(|c| set.has_channel(*c)).collect())
|
||||
}
|
||||
|
||||
|
||||
@@ -427,6 +427,7 @@ fn tile_row(ui: &mut Ui, set: usize, udim: u32, resolution: u32, set_width: u32,
|
||||
if let Some(size) = picked {
|
||||
return Some(TileAction::Resize(size));
|
||||
}
|
||||
|
||||
(response.clicked() || response.secondary_clicked()).then_some(TileAction::Select)
|
||||
}
|
||||
|
||||
@@ -435,6 +436,7 @@ fn shader_column_width(ui: &Ui, row_width: f32) -> f32 {
|
||||
if row_width < SHADER_MIN_ROW_WIDTH {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
dropdown_width(ui, tr(INSTANCE_NAME)) + DROPDOWN_GAP
|
||||
}
|
||||
|
||||
@@ -511,6 +513,7 @@ fn edit_field(ui: &mut Ui, state: &mut ListState, rect: Rect, size: f32) -> Opti
|
||||
if !response.lost_focus() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let edit = state.edit.take()?;
|
||||
(!ui.input(|input| input.key_pressed(egui::Key::Escape))).then_some(edit.2)
|
||||
}
|
||||
@@ -573,6 +576,7 @@ mod tests {
|
||||
if harness.state().resize.is_none() {
|
||||
break;
|
||||
}
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
harness.run_steps(2);
|
||||
|
||||
@@ -329,6 +329,7 @@ mod tests {
|
||||
if harness.state().resize.is_none() {
|
||||
break;
|
||||
}
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
harness.run_steps(2);
|
||||
|
||||
Reference in new issue
Block a user