mirror of
https://github.com/widberg/bff
synced 2026-08-23 14:26:03 -04:00
Fix new clippy lints
This commit is contained in:
parent
7112cab4eb
commit
bfde236f28
8 changed files with 91 additions and 99 deletions
|
|
@ -20,10 +20,10 @@ fn collect_cps_names(cps: &Cps, name_context: &NameContext) -> HashSet<Name> {
|
|||
names.insert(name_context.parse_i32_or_hash_name(stem));
|
||||
}
|
||||
for line in script.lines() {
|
||||
if let Some(command_name) = line.split_whitespace().next() {
|
||||
if !command_name.is_empty() {
|
||||
names.insert(name_context.parse_i32_or_hash_name(command_name));
|
||||
}
|
||||
if let Some(command_name) = line.split_whitespace().next()
|
||||
&& !command_name.is_empty()
|
||||
{
|
||||
names.insert(name_context.parse_i32_or_hash_name(command_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ fn impl_from_specific_to_generic(input: &DeriveInput) -> TokenStream {
|
|||
let into = attrs(&f.attrs);
|
||||
|
||||
if into {
|
||||
if let Type::Path(p) = field_type {
|
||||
if p.path.get_ident().is_none() {
|
||||
if let Type::Path(p) = field_type
|
||||
&& p.path.get_ident().is_none() {
|
||||
let first = p.path.segments.first().unwrap();
|
||||
if first.ident == "DynArray" {
|
||||
return quote! { #field_ident: resource.#field_ident.inner.into_iter().map(|x| x.into()).collect::<Vec<_>>().into() };
|
||||
|
|
@ -166,7 +166,6 @@ fn impl_from_specific_to_generic(input: &DeriveInput) -> TokenStream {
|
|||
return quote! { #field_ident: resource.#field_ident.into_iter().map(|x| x.into()).collect::<Vec<_>>() };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
quote! { #field_ident: resource.#field_ident.into() }
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ fn does_not_have_skip_attr(attrs: &Vec<Attribute>) -> bool {
|
|||
if !attr.path().is_ident("referenced_names") {
|
||||
continue;
|
||||
}
|
||||
if let syn::Meta::List(meta) = &attr.meta {
|
||||
if meta.tokens.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let syn::Meta::List(meta) = &attr.meta
|
||||
&& meta.tokens.is_empty()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
attr.parse_nested_meta(|meta| {
|
||||
if meta.path.is_ident("skip") {
|
||||
|
|
|
|||
|
|
@ -47,23 +47,24 @@ pub fn create_artifact(bigfile: &BigFile, class: Class) -> Option<Artifact> {
|
|||
match class {
|
||||
Class::Bitmap(bitmap) => {
|
||||
let data_name = OsString::from("data");
|
||||
if let Ok(mut exported_artifacts) = BffExport::export(&bitmap) {
|
||||
if let Some(exported_artifact) = exported_artifacts.remove(&data_name) {
|
||||
match exported_artifact {
|
||||
BffArtifact::Dds(bytes) => {
|
||||
return Some(Artifact::Bitmap {
|
||||
format: BitmapFormat::Dds,
|
||||
data: Arc::new(bytes),
|
||||
});
|
||||
}
|
||||
BffArtifact::Binary(bytes) => {
|
||||
return Some(Artifact::Bitmap {
|
||||
format: BitmapFormat::Raw,
|
||||
data: Arc::new(bytes),
|
||||
});
|
||||
}
|
||||
BffArtifact::Text(_) => {}
|
||||
if let Ok(mut exported_artifacts) = BffExport::export(&bitmap)
|
||||
&& let Some(exported_artifact) = exported_artifacts.remove(&data_name)
|
||||
{
|
||||
match exported_artifact {
|
||||
BffArtifact::Dds(bytes) => {
|
||||
return Some(Artifact::Bitmap {
|
||||
format: BitmapFormat::Dds,
|
||||
data: Arc::new(bytes),
|
||||
});
|
||||
}
|
||||
BffArtifact::Binary(bytes) => {
|
||||
return Some(Artifact::Bitmap {
|
||||
format: BitmapFormat::Raw,
|
||||
data: Arc::new(bytes),
|
||||
});
|
||||
}
|
||||
BffArtifact::Text(_) => {}
|
||||
BffArtifact::Wav(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,10 +363,10 @@ fn uninstall() -> BffGuiResult<()> {
|
|||
if let Ok(default) =
|
||||
registry::open_subkey(classes.raw(), &extension_key_name, KEY_READ | KEY_WRITE)
|
||||
{
|
||||
if let Some(prog_id) = registry::get_default_value_sz(default.raw())? {
|
||||
if prog_id == PROG_ID {
|
||||
registry::delete_default_value_if_exists(default.raw())?;
|
||||
}
|
||||
if let Some(prog_id) = registry::get_default_value_sz(default.raw())?
|
||||
&& prog_id == PROG_ID
|
||||
{
|
||||
registry::delete_default_value_if_exists(default.raw())?;
|
||||
}
|
||||
|
||||
if let Ok(open_with) =
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ impl Gui {
|
|||
let filtered_count = bigfile
|
||||
.resources
|
||||
.values()
|
||||
.filter(|res| is_resource_visible(*res))
|
||||
.filter(|res| is_resource_visible(res))
|
||||
.count();
|
||||
ui.label(format!("{}/{}", filtered_count, bigfile.resources.len()));
|
||||
});
|
||||
|
|
@ -271,7 +271,7 @@ impl Gui {
|
|||
let mut res: Vec<(Name, Name, usize)> = bigfile
|
||||
.resources
|
||||
.values()
|
||||
.filter(|res| is_resource_visible(*res))
|
||||
.filter(|res| is_resource_visible(res))
|
||||
.map(|r| (r.name, r.class_name, r.size()))
|
||||
.collect();
|
||||
match new_state.sort.sort_type {
|
||||
|
|
@ -313,16 +313,15 @@ impl Gui {
|
|||
egui::Layout::top_down_justified(egui::Align::LEFT),
|
||||
|ui| {
|
||||
ui.set_min_width(10.0);
|
||||
if ui.input(|i| i.key_pressed(egui::Key::ArrowDown)) {
|
||||
if let Some(cur) = self.resource_name {
|
||||
let mut res_iter = resources.iter().cycle();
|
||||
if res_iter.any(|n| n == &cur) {
|
||||
let res = *res_iter.next().unwrap();
|
||||
response.resource_clicked = Some(res);
|
||||
(
|
||||
response.info_created,
|
||||
response.artifact_created,
|
||||
) = load_artifact(
|
||||
if ui.input(|i| i.key_pressed(egui::Key::ArrowDown))
|
||||
&& let Some(cur) = self.resource_name
|
||||
{
|
||||
let mut res_iter = resources.iter().cycle();
|
||||
if res_iter.any(|n| n == &cur) {
|
||||
let res = *res_iter.next().unwrap();
|
||||
response.resource_clicked = Some(res);
|
||||
(response.info_created, response.artifact_created) =
|
||||
load_artifact(
|
||||
&self.artifacts,
|
||||
&self.infos,
|
||||
bigfile,
|
||||
|
|
@ -331,24 +330,19 @@ impl Gui {
|
|||
platform,
|
||||
self.name_context.as_ref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ui.input(|i| i.key_pressed(egui::Key::ArrowUp)) {
|
||||
if let Some(cur) = self.resource_name {
|
||||
let mut res_iter = resources.iter();
|
||||
if let Some(i) = res_iter.position(|n| n == &cur) {
|
||||
let c = if i == 0 {
|
||||
resources.len() - 1
|
||||
} else {
|
||||
i - 1
|
||||
};
|
||||
let res = *resources.get(c).unwrap();
|
||||
response.resource_clicked = Some(res);
|
||||
(
|
||||
response.info_created,
|
||||
response.artifact_created,
|
||||
) = load_artifact(
|
||||
if ui.input(|i| i.key_pressed(egui::Key::ArrowUp))
|
||||
&& let Some(cur) = self.resource_name
|
||||
{
|
||||
let mut res_iter = resources.iter();
|
||||
if let Some(i) = res_iter.position(|n| n == &cur) {
|
||||
let c =
|
||||
if i == 0 { resources.len() - 1 } else { i - 1 };
|
||||
let res = *resources.get(c).unwrap();
|
||||
response.resource_clicked = Some(res);
|
||||
(response.info_created, response.artifact_created) =
|
||||
load_artifact(
|
||||
&self.artifacts,
|
||||
&self.infos,
|
||||
bigfile,
|
||||
|
|
@ -357,7 +351,6 @@ impl Gui {
|
|||
platform,
|
||||
self.name_context.as_ref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ impl Gui {
|
|||
egui::SidePanel::right("right")
|
||||
.resizable(true)
|
||||
.show(ctx, |ui: &mut egui::Ui| {
|
||||
if let Some(name) = self.resource_name {
|
||||
if let Some(info) = self.infos.get(&name) {
|
||||
egui::ScrollArea::both()
|
||||
.auto_shrink([false; 2])
|
||||
.id_salt("code_scroll")
|
||||
.show(ui, |ui| {
|
||||
selectable_text(ui, info);
|
||||
});
|
||||
}
|
||||
if let Some(name) = self.resource_name
|
||||
&& let Some(info) = self.infos.get(&name)
|
||||
{
|
||||
egui::ScrollArea::both()
|
||||
.auto_shrink([false; 2])
|
||||
.id_salt("code_scroll")
|
||||
.show(ui, |ui| {
|
||||
selectable_text(ui, info);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,12 +137,11 @@ where
|
|||
}
|
||||
|
||||
pub fn parse_forced_hash_name<S: AsRef<str>>(string: S) -> Option<(Self, String)> {
|
||||
if let Some(string) = string.as_ref().strip_prefix(FORCED_NAME_STRING_CHAR) {
|
||||
if let Some((value, s)) = string.split_once(FORCED_NAME_STRING_CHAR) {
|
||||
if let Ok(value) = value.parse::<H::Target>() {
|
||||
return Some((Self::new(value), s.to_owned()));
|
||||
}
|
||||
}
|
||||
if let Some(string) = string.as_ref().strip_prefix(FORCED_NAME_STRING_CHAR)
|
||||
&& let Some((value, s)) = string.split_once(FORCED_NAME_STRING_CHAR)
|
||||
&& let Ok(value) = value.parse::<H::Target>()
|
||||
{
|
||||
return Some((Self::new(value), s.to_owned()));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
@ -735,19 +734,19 @@ impl Names {
|
|||
match self.name_type {
|
||||
NameType::Asobo32 => {
|
||||
let name = NameAsobo32::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::Asobo32(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::Asobo32(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(out, r#"{} \"{}\""#, name, string)?;
|
||||
}
|
||||
NameType::AsoboAlternate32 => {
|
||||
let name = NameAsoboAlternate32::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::AsoboAlternate32(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::AsoboAlternate32(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
|
|
@ -758,10 +757,10 @@ impl Names {
|
|||
}
|
||||
NameType::Kalisto32 => {
|
||||
let name = NameKalisto32::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::Kalisto32(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::Kalisto32(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
|
|
@ -772,10 +771,10 @@ impl Names {
|
|||
}
|
||||
NameType::BlackSheep32 => {
|
||||
let name = NameBlackSheep32::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::BlackSheep32(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::BlackSheep32(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
|
|
@ -786,10 +785,10 @@ impl Names {
|
|||
}
|
||||
NameType::Asobo64 => {
|
||||
let name = NameAsobo64::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::Asobo64(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::Asobo64(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
|
|
@ -800,10 +799,10 @@ impl Names {
|
|||
}
|
||||
NameType::Ubisoft64 => {
|
||||
let name = NameUbisoft64::hash_string(string);
|
||||
if let Some(names) = names {
|
||||
if !names.contains(&&Name::Ubisoft64(name)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(names) = names
|
||||
&& !names.contains(&&Name::Ubisoft64(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue