Skip to content

Commit

Permalink
No video beatmap download option. Resolved #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ringosham committed Jun 26, 2018
1 parent b4055f7 commit dadfe06
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/com/ringosham/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public boolean isVideoDownload() {
return videoDownload;
}

public void setVideoDownload(boolean videoDownload) {
this.videoDownload = videoDownload;
}

private static class Defaults {
private static final Locale locale = Locale.US;
private static final boolean videoDownload = true;
Expand Down
4 changes: 4 additions & 0 deletions src/com/ringosham/controller/SettingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class SettingScreen {
private TextField gameDirectory;
@FXML
private ComboBox<Language> languageOption;
@FXML
private CheckBox videoDownload;
private boolean isLanguageChanged = false;
private MainScreen mainScreen;

Expand Down Expand Up @@ -72,6 +74,7 @@ public Language fromString(String string) {
int selectedIndex = getIndexFromLocale(Global.INSTANCE.getLocale());
languageOption.getSelectionModel().select(selectedIndex);
languageOption.valueProperty().addListener((ObsValue, oldValue, newValue) -> isLanguageChanged = true);
videoDownload.setSelected(Global.INSTANCE.isVideoDownload());
}

private int getIndexFromLocale(Locale locale) {
Expand All @@ -92,6 +95,7 @@ public void apply() {
return;
Global.INSTANCE.setLazerDirectory(new File(gameDirectory.getText()));
Global.INSTANCE.setLocale(languageOption.getSelectionModel().getSelectedItem().getLocale());
Global.INSTANCE.setVideoDownload(videoDownload.isSelected());
try {
Global.INSTANCE.saveConfig();
} catch (IOException e) {
Expand Down
4 changes: 3 additions & 1 deletion src/com/ringosham/fxml/settings.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="194.0" prefWidth="453.0"
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="230.0" prefWidth="453.0"
xmlns="http://javafx.com/javafx/8.0.121">
<Label layoutX="14.0" layoutY="14.0" text="%gameDirectory" AnchorPane.leftAnchor="14.0"
AnchorPane.topAnchor="14.0"/>
Expand All @@ -26,4 +26,6 @@
<Label layoutX="14.0" layoutY="96.0" text="%language" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="96.0"/>
<ComboBox fx:id="languageOption" layoutX="14.0" layoutY="113.0" prefWidth="150.0" AnchorPane.leftAnchor="14.0"
AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="113.0"/>
<CheckBox fx:id="videoDownload" layoutX="14.0" layoutY="154.0" mnemonicParsing="false" text="%videoDownload"
AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="154.0"/>
</AnchorPane>
1 change: 1 addition & 0 deletions src/com/ringosham/lang/lang_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cancel=Cancel
gameDirectory=Game directory
browse=Browse
language=Language
videoDownload=Download beatmap video
#--------------------------------
# Import/Export diaogs
#--------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/com/ringosham/lang/lang_zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ confirmExit=\u78BA\u8A8D\u96E2\u958B?
confirmExitDesc=\u4E00\u9805\u7A0B\u5E8F\u4ECD\u7136\u904B\u884C\u4E2D\uFF0C\u78BA\u5B9A\u96E2\u958B?
disclaimer=\u514D\u8CAC\u8072\u660E
disclaimerHead=\u5728\u4F7F\u7528\u4EE5\u4E0B\u529F\u80FD\u524D\uFF0C\u4F60\u5FC5\u9808\u540C\u610F\u4EE5\u4E0B\u5B88\u5247
disclaimerDesc=1. \u4F60\u4E0D\u53EF\u4EE5\u5229\u7528\u6B64\u529F\u80FD\u8F49\u8F09\u6B4C\u66F2\n2. \u5728\u4EFB\u4F55\u60C5\u6CC1\u4E0B\uFF0C\u958B\u767C\u4EBA\u54E1\u4E0D\u6703\u5C0D\u4EFB\u4F55\u4FB5\u6B0A\u8CA0\u8CAC
disclaimerDesc=1. \u4F60\u4E0D\u53EF\u4EE5\u5229\u7528\u6B64\u529F\u80FD\u975E\u6CD5\u8F49\u8F09\u6B4C\u66F2\n2. \u5728\u4EFB\u4F55\u60C5\u6CC1\u4E0B\uFF0C\u958B\u767C\u4EBA\u54E1\u4E0D\u6703\u5C0D\u4EFB\u4F55\u4FB5\u6B0A\u8CA0\u8CAC
table.installed=\u5B89\u88DD
table.id=\u5716\u8B5CID
table.title=\u6B4C\u66F2\u540D\u7A31
Expand All @@ -35,6 +35,7 @@ cancel=\u53D6\u6D88
gameDirectory=\u904A\u6232\u76EE\u9304
browse=\u700F\u89BD
language=\u8A9E\u8A00
videoDownload=\u4E0B\u8F09\u5716\u8B5C\u5F71\u7247
chooseExportDir=\u9078\u64C7\u532F\u51FA\u8CC7\u6599\u593E
chooseImportFile=\u9078\u64C7\u532F\u5165\u6A94\u6848
chooseExportFile=\u9078\u64C7\u532F\u51FA\u5730\u5740
Expand Down
7 changes: 6 additions & 1 deletion src/com/ringosham/threads/imports/download/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class Downloader {
private static final String downloadUrlPrefix = "https://osu.ppy.sh/beatmapsets/";
private static final String downloadUrlSuffix = "/download";
private static final String downloadNoVidUrlSuffix = "/download?noVideo=1";
private final MainScreen mainScreen;
private final List<BeatmapXML> beatmaps;

Expand All @@ -40,7 +41,11 @@ void downloadBeatmap() {
File osz = new File(Global.INSTANCE.getLazerDirectory(), "/files/" + getValidFileName(filename));
if (!osz.exists()) {
try {
URL url = new URL(downloadUrlPrefix + beatmap.getBeatmapID() + downloadUrlSuffix);
URL url;
if (Global.INSTANCE.isVideoDownload())
url = new URL(downloadUrlPrefix + beatmap.getBeatmapID() + downloadUrlSuffix);
else
url = new URL(downloadUrlPrefix + beatmap.getBeatmapID() + downloadNoVidUrlSuffix);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");

Expand Down

0 comments on commit dadfe06

Please sign in to comment.