Skip to content

Commit

Permalink
#422: Skip games with outer whitespace in their titles
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 19, 2024
1 parent 7454d96 commit 8f4be97
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Unreleased

* Fixed:
* If a custom game's title begins or ends with a space,
that custom game will now be ignored.
Previously, Ludusavi would make a backup folder for the game including the space,
but the OS (namely Windows) would remove the space from the folder title,
causing unpredictable behavior when Ludusavi couldn't find the expected folder name.

## v0.27.0 (2024-11-19)

* Added:
Expand Down
10 changes: 9 additions & 1 deletion src/gui/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::{BTreeSet, HashSet};

use iced::Length;
use iced::{widget::text_input, Length};

use crate::{
cloud::{rclone_monitor, Remote, RemoteChoice},
Expand All @@ -25,6 +25,14 @@ use crate::{
},
};

pub const ERROR_ICON: text_input::Icon<iced::Font> = text_input::Icon {
font: crate::gui::font::ICONS,
code_point: crate::gui::icon::Icon::Error.as_char(),
size: None,
spacing: 5.0,
side: text_input::Side::Right,
};

#[derive(Clone, Debug, Default)]
pub struct Flags {
pub update_manifest: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/gui/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum Icon {
}

impl Icon {
pub fn as_char(&self) -> char {
pub const fn as_char(&self) -> char {
match self {
Self::Add => '\u{E145}',
Self::AddCircle => '\u{E147}',
Expand Down
17 changes: 6 additions & 11 deletions src/gui/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

use std::collections::{HashMap, VecDeque};

use iced::{widget::text_input, Length};
use iced::Length;

use crate::{
cloud::Remote,
gui::{
common::{EditAction, Message, RedirectEditActionField, Screen, UndoSubject},
common::{EditAction, Message, RedirectEditActionField, Screen, UndoSubject, ERROR_ICON},
modal::{ModalField, ModalInputKind},
style,
widget::{id, Element, TextInput, Undoable},
Expand Down Expand Up @@ -460,19 +460,14 @@ impl TextHistories {
| UndoSubject::RedirectTarget(_)
| UndoSubject::CustomGameFile(_, _)
| UndoSubject::BackupFilterIgnoredPath(_)
| UndoSubject::RcloneExecutable => (!path_appears_valid(&current)).then_some(text_input::Icon {
font: crate::gui::font::ICONS,
code_point: crate::gui::icon::Icon::Error.as_char(),
size: None,
spacing: 5.0,
side: text_input::Side::Right,
}),
| UndoSubject::RcloneExecutable => (!path_appears_valid(&current)).then_some(ERROR_ICON),
UndoSubject::CustomGameName(_) | UndoSubject::CustomGameAlias(_) => {
(current.trim() != current).then_some(ERROR_ICON)
}
UndoSubject::SecondaryManifest(_)
| UndoSubject::BackupSearchGameName
| UndoSubject::RestoreSearchGameName
| UndoSubject::CustomGamesSearchGameName
| UndoSubject::CustomGameName(_)
| UndoSubject::CustomGameAlias(_)
| UndoSubject::CustomGameRegistry(_, _)
| UndoSubject::BackupFilterIgnoredRegistry(_)
| UndoSubject::RcloneArguments
Expand Down
21 changes: 18 additions & 3 deletions src/resource/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,20 @@ impl Manifest {

fn add_custom_games(&mut self, config: &Config) {
for custom_game in &config.custom_games {
if custom_game.ignore || custom_game.name.trim().is_empty() {
let name = &custom_game.name;

if custom_game.ignore {
continue;
}
if name.is_empty() {
log::warn!("ignoring custom game with blank name: '{name}'");
continue;
}
if name.trim() != name {
log::warn!("ignoring custom game with outer whitespace: '{name}'");
continue;
}

self.add_custom_game(custom_game.clone());
}
}
Expand Down Expand Up @@ -712,8 +723,12 @@ impl Manifest {
let manifest = secondary.data.0;

for (name, mut game) in manifest {
if name.trim().is_empty() {
log::debug!("ignoring secondary manifest game with blank name: '{name}'");
if name.is_empty() {
log::warn!("ignoring secondary manifest game with blank name: '{name}'");
continue;
}
if name.trim() != name {
log::warn!("ignoring secondary manifest game with outer whitespace: '{name}'");
continue;
}

Expand Down

0 comments on commit 8f4be97

Please sign in to comment.