Add a button for cleaning crash-reports and logs manually

This commit is contained in:
huanghongxun
2018-10-23 14:08:51 +08:00
parent 7dcd0eb616
commit c9d825b6c1
7 changed files with 26 additions and 2 deletions

View File

@@ -93,6 +93,16 @@ public class HMCLGameRepository extends DefaultGameRepository {
refreshVersionsAsync().start(); refreshVersionsAsync().start();
} }
private void clean(File directory) throws IOException {
FileUtils.deleteDirectory(new File(directory, "crash-reports"));
FileUtils.deleteDirectory(new File(directory, "logs"));
}
public void clean(String id) throws IOException {
clean(getBaseDirectory());
clean(getRunDirectory(id));
}
private File getVersionSettingFile(String id) { private File getVersionSettingFile(String id) {
return new File(getVersionRoot(id), "hmclversion.cfg"); return new File(getVersionRoot(id), "hmclversion.cfg");
} }

View File

@@ -156,7 +156,7 @@ public final class Controllers {
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!modpacks.isEmpty()) { if (!modpacks.isEmpty()) {
File modpack = modpacks.get(0); File modpack = modpacks.get(0);
Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(modpack), i18n("install.modpack")); Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(Profiles.getSelectedProfile(), modpack), i18n("install.modpack"));
event.setDropCompleted(true); event.setDropCompleted(true);
} }
} }

View File

@@ -98,7 +98,8 @@ public final class VersionPage extends StackPane implements DecoratorPage {
new IconedMenuItem(null, i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> Versions.renameVersion(profile, version), managementPopup)), new IconedMenuItem(null, i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> Versions.renameVersion(profile, version), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> Versions.deleteVersion(profile, version), managementPopup)), new IconedMenuItem(null, i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> Versions.deleteVersion(profile, version), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.redownload_assets_index"), FXUtils.withJFXPopupClosing(() -> new GameAssetIndexDownloadTask(profile.getDependency(), profile.getRepository().getResolvedVersion(version)).start(), managementPopup)), new IconedMenuItem(null, i18n("version.manage.redownload_assets_index"), FXUtils.withJFXPopupClosing(() -> new GameAssetIndexDownloadTask(profile.getDependency(), profile.getRepository().getResolvedVersion(version)).start(), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.remove_libraries"), FXUtils.withJFXPopupClosing(() -> FileUtils.deleteDirectoryQuietly(new File(profile.getRepository().getBaseDirectory(), "libraries")), managementPopup)) new IconedMenuItem(null, i18n("version.manage.remove_libraries"), FXUtils.withJFXPopupClosing(() -> FileUtils.deleteDirectoryQuietly(new File(profile.getRepository().getBaseDirectory(), "libraries")), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(() -> Versions.cleanVersion(profile, version), managementPopup))
); );
FXUtils.installTooltip(btnDelete, i18n("version.manage.remove")); FXUtils.installTooltip(btnDelete, i18n("version.manage.remove"));

View File

@@ -35,12 +35,14 @@ import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent; import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
import org.jackhuang.hmcl.ui.construct.MessageBox; import org.jackhuang.hmcl.ui.construct.MessageBox;
import org.jackhuang.hmcl.ui.export.ExportWizardProvider; import org.jackhuang.hmcl.ui.export.ExportWizardProvider;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.platform.OperatingSystem; import org.jackhuang.hmcl.util.platform.OperatingSystem;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
@@ -100,6 +102,14 @@ public class Versions {
} }
} }
public static void cleanVersion(Profile profile, String id) {
try {
profile.getRepository().clean(id);
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to clean game directory", e);
}
}
public static void generateLaunchScript(Profile profile, String id) { public static void generateLaunchScript(Profile profile, String id) {
if (checkForLaunching(profile, id)) { if (checkForLaunching(profile, id)) {
GameRepository repository = profile.getRepository(); GameRepository repository = profile.getRepository();

View File

@@ -382,6 +382,7 @@ version.launch_script.failed=Unable to make launch script.
version.launch_script.save=Save the launch script version.launch_script.save=Save the launch script
version.launch_script.success=Finished script creation, %s. version.launch_script.success=Finished script creation, %s.
version.manage=Game List version.manage=Game List
version.manage.clean=Clean game directory
version.manage.manage=Manage Game version.manage.manage=Manage Game
version.manage.redownload_assets_index=Redownload Assets Index version.manage.redownload_assets_index=Redownload Assets Index
version.manage.remove=Delete this game version.manage.remove=Delete this game

View File

@@ -382,6 +382,7 @@ version.launch_script.failed=生成啟動腳本失敗
version.launch_script.save=儲存啟動腳本 version.launch_script.save=儲存啟動腳本
version.launch_script.success=啟動腳本已生成完畢:%s version.launch_script.success=啟動腳本已生成完畢:%s
version.manage=遊戲列表 version.manage=遊戲列表
version.manage.clean=清理遊戲目錄
version.manage.manage=游戏管理 version.manage.manage=游戏管理
version.manage.redownload_assets_index=更新資源列表 version.manage.redownload_assets_index=更新資源列表
version.manage.remove=刪除該版本 version.manage.remove=刪除該版本

View File

@@ -382,6 +382,7 @@ version.launch_script.failed=生成启动脚本失败
version.launch_script.save=保存启动脚本 version.launch_script.save=保存启动脚本
version.launch_script.success=启动脚本已生成完毕:%s version.launch_script.success=启动脚本已生成完毕:%s
version.manage=游戏列表 version.manage=游戏列表
version.manage.clean=清理游戏目录
version.manage.manage=游戏管理 version.manage.manage=游戏管理
version.manage.redownload_assets_index=更新资源列表 version.manage.redownload_assets_index=更新资源列表
version.manage.remove=删除该版本 version.manage.remove=删除该版本