Skip to content

Commit

Permalink
don't list duplicate fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Aug 27, 2024
1 parent ad10308 commit 267056f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/delphi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,20 @@ impl std::ops::Add<&UStr> for UStr {
}
}

impl std::hash::Hash for UStr {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.as_slice().hash(state);
}
}

impl PartialEq for UStr {
fn eq(&self, other: &Self) -> bool {
self.as_slice() == other.as_slice()
}
}

impl Eq for UStr {}

impl Drop for UStr {
fn drop(&mut self) {
unsafe { UStrClr(self) }
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ unsafe extern "C" fn move_extensions_from_localappdata_to_exedir() {
if filenames.is_empty() {
return
}
let message = format!("These extension files need to be moved to the install folder:\n\n{filenames}\n\nProceed?");
let message =
format!("These extension files need to be moved to the install folder:\n\n{filenames}\n\nProceed?");
let answer = show_question(&UStr::new(message));
if answer != 6 {
return
Expand Down
15 changes: 8 additions & 7 deletions src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,20 +1344,21 @@ pub unsafe fn load_gmk(mut path: PathBuf) -> Result<()> {
{
// get font list
let font_list: u32 = delphi_call!(0x6fb55c);
let mut message = String::new();
let mut missing_fonts = HashSet::new();
for font in ide::FONTS.assets().iter().filter_map(Option::as_ref) {
let index: i32 = delphi_call!(0x43ee44, font_list, font.sys_name.0);
if index < 0 {
if message.is_empty() {
message = "Warning: this game uses the following fonts, which are not installed:".to_string();
}
message += "\n";
message += &font.sys_name.to_os_string().into_string().unwrap();
missing_fonts.insert(font.sys_name.clone());
}
}
// free font list
let _: u32 = delphi_call!(0x405a7c, font_list);
if !message.is_empty() {
if !missing_fonts.is_empty() {
let mut message = "Warning: this game uses the following fonts, which are not installed:".to_string();
for font in missing_fonts {
message += "\n";
message += &font.to_os_string().into_string().unwrap();
}
show_message(message);
}
}
Expand Down

0 comments on commit 267056f

Please sign in to comment.