Made checkboxes do stuff
This commit is contained in:
@ -58,7 +58,7 @@ impl ItemInfoState {
|
||||
}
|
||||
ItemInfoMessage::EditChangeNotes(new_notes) => self.change_notes = new_notes,
|
||||
ItemInfoMessage::AbsToggled(value) => self.use_abs_path = value,
|
||||
ItemInfoMessage::ConvertToggled(value) => self.convert_rpy = value,
|
||||
ItemInfoMessage::ConvertToggled(val) => self.convert_rpy = val,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +81,8 @@ impl ItemInfoState {
|
||||
ItemInfoMessage::BrowsePreviewImage,
|
||||
),
|
||||
text(" "),
|
||||
checkbox("Use absolute path (Don't toggle if you don't know what it means!)", self.use_abs_path, ItemInfoMessage::AbsToggled),
|
||||
checkbox("Convert rpy to rpym (Don't toggle if you don't know what it means!)", self.convert_rpy, ItemInfoMessage::AbsToggled),
|
||||
text(" "),
|
||||
self.target_folder.view(
|
||||
"Target Folder:\n(What will be uploaded, this MUST be your mod's folder)\nFor example \"\\game\\mods\\YourMod\"",
|
||||
"Target Folder:\n(What will be uploaded, this should be your mod's folder)\nFor example \"\\game\\mods\\YourMod\"",
|
||||
"",
|
||||
ItemInfoMessage::EditTargetFolder,
|
||||
ItemInfoMessage::BrowseTargetFolder,
|
||||
@ -98,6 +95,12 @@ impl ItemInfoState {
|
||||
),
|
||||
text(" "),
|
||||
text("You can add more screenshots and a description after your mod gets uploaded."),
|
||||
text(" "),
|
||||
text("Don't touch these if you don't know what they mean!"),
|
||||
text(" "),
|
||||
checkbox("Use absolute path.", self.use_abs_path, ItemInfoMessage::AbsToggled),
|
||||
text(" "),
|
||||
checkbox("Convert rpy to rpym.", self.convert_rpy, ItemInfoMessage::ConvertToggled),
|
||||
]
|
||||
.into()
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ impl WorkshopClient {
|
||||
) -> Result<(PublishedFileId, bool), SteamError> {
|
||||
let temp_dir = std::env::temp_dir(); // Get the temporary directory
|
||||
let temp_folder = temp_dir.join("wani_workshop_folder"); // Create a specific folder within temporary directory
|
||||
let full_folder = temp_folder.join("mods");
|
||||
let mut full_folder = temp_folder.join("mods");
|
||||
|
||||
// Create the folders if they doesn't exist
|
||||
if !temp_folder.exists() {
|
||||
@ -211,9 +211,41 @@ impl WorkshopClient {
|
||||
let _ = fs::create_dir(&full_folder);
|
||||
}
|
||||
|
||||
if item_info.use_abs_path {
|
||||
full_folder = temp_folder.clone()
|
||||
}
|
||||
|
||||
// // Copy the contents of the target folder to the temporary folder
|
||||
let _ = fs_extra::dir::copy(&item_info.target_folder, &full_folder, &fs_extra::dir::CopyOptions::new());
|
||||
|
||||
|
||||
if item_info.convert_rpy {
|
||||
let entries = match fs::read_dir(&full_folder) {
|
||||
Ok(entries) => entries,
|
||||
Err(_err) => return Err(SteamError::FileNotFound),
|
||||
};
|
||||
for entry in entries {
|
||||
let entry = match entry {
|
||||
Ok(entry) => entry,
|
||||
Err(_err) => return Err(SteamError::FileNotFound),
|
||||
};
|
||||
let path = entry.path();
|
||||
if let Some(extension) = path.extension() {
|
||||
let extension_str = extension.to_string_lossy().to_lowercase();
|
||||
if extension_str == "rpy" {
|
||||
let new_path = path.with_extension("rpym");
|
||||
if let Err(_err) = fs::rename(&path, &new_path) {
|
||||
return Err(SteamError::FileNotFound);
|
||||
}
|
||||
} else if extension_str == "rpyc" {
|
||||
if let Err(_err) = fs::remove_file(&path) {
|
||||
return Err(SteamError::FileNotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rx = {
|
||||
let app_id = self.steam_client.utils().app_id();
|
||||
|
||||
|
Reference in New Issue
Block a user