Skip to content

Commit

Permalink
Merge branch 'master' into lr2oraja
Browse files Browse the repository at this point in the history
  • Loading branch information
wcko87 committed Mar 3, 2024
2 parents 38a1b83 + 7d8b334 commit aa69103
Show file tree
Hide file tree
Showing 86 changed files with 4,543 additions and 4,091 deletions.
File renamed without changes.
68 changes: 22 additions & 46 deletions src/bms/player/beatoraja/BMSResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BMSResource {
/**
* 音源読み込みタスク
*/
private ArrayDeque<AudioLoaderThread> audioloaders = new ArrayDeque<AudioLoaderThread>();
private ArrayDeque<Thread> audioloaders = new ArrayDeque<Thread>();
/**
* BMSのBGAリソース
*/
Expand All @@ -39,7 +39,7 @@ public class BMSResource {
/**
* BGA読み込みタスク
*/
private ArrayDeque<BGALoaderThread> bgaloaders = new ArrayDeque<BGALoaderThread>();
private ArrayDeque<Thread> bgaloaders = new ArrayDeque<Thread>();
/**
* backbmp
*/
Expand Down Expand Up @@ -102,11 +102,28 @@ public boolean setBMSFile(BMSModel model, final Path f, final Config config, BMS

if(MainLoader.getIllegalSongCount() == 0) {
// Audio, BGAともキャッシュがあるため、何があっても全リロードする
BGALoaderThread bgaloader = new BGALoaderThread(
config.getBga() == Config.BGA_ON || (config.getBga() == Config.BGA_AUTO && (mode.mode == BMSPlayerMode.Mode.AUTOPLAY || mode.mode == BMSPlayerMode.Mode.REPLAY)) ? model : null);
final BMSModel bgamodel = config.getBga() == Config.BGA_ON || (config.getBga() == Config.BGA_AUTO && (mode.mode == BMSPlayerMode.Mode.AUTOPLAY || mode.mode == BMSPlayerMode.Mode.REPLAY)) ? model : null;
Thread bgaloader = new Thread(() -> {
try {
bga.abort();
bga.setModel(bgamodel);
bgaon = bgamodel != null;
} catch (Throwable e) {
Logger.getGlobal().severe(e.getClass().getName() + " : " + e.getMessage());
e.printStackTrace();
}
});
bgaloaders.addLast(bgaloader);
bgaloader.start();
AudioLoaderThread audioloader = new AudioLoaderThread(model);
Thread audioloader = new Thread(() -> {
try {
audio.abort();
audio.setModel(model);
} catch (Throwable e) {
Logger.getGlobal().severe(e.getClass().getName() + " : " + e.getMessage());
e.printStackTrace();
}
});
audioloaders.addLast(audioloader);
audioloader.start();
}
Expand Down Expand Up @@ -197,45 +214,4 @@ public void dispose() {
backbmp = null;
}
}

class BGALoaderThread extends Thread {

private final BMSModel model;

public BGALoaderThread(BMSModel model) {
this.model = model;
}

@Override
public void run() {
try {
bga.abort();
bga.setModel(model);
bgaon = model != null;
} catch (Throwable e) {
Logger.getGlobal().severe(e.getClass().getName() + " : " + e.getMessage());
e.printStackTrace();
}
}
}

class AudioLoaderThread extends Thread {

private final BMSModel model;

public AudioLoaderThread(BMSModel model) {
this.model = model;
}

@Override
public void run() {
try {
audio.abort();
audio.setModel(model);
} catch (Throwable e) {
Logger.getGlobal().severe(e.getClass().getName() + " : " + e.getMessage());
e.printStackTrace();
}
}
}
}
40 changes: 38 additions & 2 deletions src/bms/player/beatoraja/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
*/
public class Config implements Validatable {

/**
* 旧コンフィグパス。そのうち削除
*/
static final Path configpath_old = Paths.get("config.json");
/**
* コンフィグパス(UTF-8)
*/
static final Path configpath = Paths.get("config_sys.json");

/**
Expand Down Expand Up @@ -116,6 +122,8 @@ public class Config implements Validatable {

private String soundpath = "sound";

private String systemfontpath = "font/VL-Gothic-Regular.ttf";
private String messagefontpath = "font/VL-Gothic-Regular.ttf";
/**
* BMSルートディレクトリパス
*/
Expand Down Expand Up @@ -154,17 +162,20 @@ public class Config implements Validatable {
private int irSendCount = 5;

private boolean useDiscordRPC = false;
private boolean setClipboardScreenshot = false;

private static final String[] DEFAULT_TABLEURL = { "http://bmsnormal2.syuriken.jp/table.html",
"http://bmsnormal2.syuriken.jp/table_insane.html",
"http://www.ribbit.xyz/bms/tables/normal.html",
"http://www.ribbit.xyz/bms/tables/insane.html",
"http://walkure.net/hakkyou/for_glassist/bms/?lamp=easy",
"http://walkure.net/hakkyou/for_glassist/bms/?lamp=normal",
"http://walkure.net/hakkyou/for_glassist/bms/?lamp=hard",
"http://walkure.net/hakkyou/for_glassist/bms/?lamp=fc",
"https://stellabms.xyz/sl/table.html",
"https://stellabms.xyz/st/table.html",
"https://mocha-repository.info/table/dpn_header.json",
"https://mocha-repository.info/table/dpi_header.json",
"https://stellabms.xyz/dp/table.html",
"https://stellabms.xyz/dpst/table.html",
"https://mocha-repository.info/table/ln_header.json",
"https://pmsdifficulty.xxxxxxxx.jp/_pastoral_insane_table.html",
"https://excln.github.io/table24k/table.html",
Expand Down Expand Up @@ -375,6 +386,14 @@ public boolean isUseDiscordRPC() {
public void setUseDiscordRPC(boolean useDiscordRPC) {
this.useDiscordRPC = useDiscordRPC;
}

public boolean isSetClipboardWhenScreenshot() {
return setClipboardScreenshot;
}

public void setClipboardWhenScreenshot(boolean setClipboardScreenshot) {
this.setClipboardScreenshot = setClipboardScreenshot;
}

public boolean isUpdatesong() {
return updatesong;
Expand Down Expand Up @@ -480,6 +499,22 @@ public void setSkinpath(String skinpath) {
this.skinpath = skinpath;
}

public String getSystemfontpath() {
return systemfontpath;
}

public void setSystemfontpath(String systemfontpath) {
this.systemfontpath = systemfontpath;
}

public String getMessagefontpath() {
return messagefontpath;
}

public void setMessagefontpath(String messagefontpath) {
this.messagefontpath = messagefontpath;
}

public boolean validate() {
displaymode = (displaymode != null) ? displaymode : DisplayMode.WINDOW;
resolution = (resolution != null) ? resolution : Resolution.HD;
Expand Down Expand Up @@ -537,6 +572,7 @@ public static Config read() {
e.printStackTrace();
}
} else if(Files.exists(configpath_old)) {
// 旧コンフィグ読み込み。そのうち削除
Json json = new Json();
json.setIgnoreUnknownFields(true);
try (FileReader reader = new FileReader(configpath_old.toFile())) {
Expand Down
37 changes: 9 additions & 28 deletions src/bms/player/beatoraja/CourseDataAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

import java.io.*;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
* コースデータへのアクセス
Expand All @@ -25,32 +23,23 @@ public CourseDataAccessor(String path) {
} catch (IOException e) {
}
}

/**
* 全てのキャッシュされた難易度表データを読み込む
* 全てのコースデータを読み込む
*
* @return 全てのキャッシュされた難易度表データ
*/
public CourseData[] readAll() {
List<CourseData> result = new ArrayList<>();
for(String name : readAllNames()) {
result.addAll(Arrays.asList(read(name)));
}
return result.toArray(new CourseData[result.size()]) ;
return Stream.of(readAllNames()).flatMap(name -> Stream.of(read(name))).toArray(CourseData[]::new);
}

public String[] readAllNames() {
List<String> result = new ArrayList<>();
try (DirectoryStream<Path> paths = Files.newDirectoryStream(Paths.get(coursedir))) {
for (Path p : paths) {
if (p.toString().endsWith(".json")) {
String filename = p.getFileName().toString();
result.add(filename.substring(0, filename.lastIndexOf('.')));
}
}
try (Stream<Path> paths = Files.list(Paths.get(coursedir))) {
return paths.map(p -> p.getFileName().toString().substring(0, p.getFileName().toString().lastIndexOf('.'))).toArray(String[]::new);
} catch (IOException e) {
e.printStackTrace();
return new String[0];
}
return result.toArray(new String[result.size()]) ;
}

public CourseData[] read(String name) {
Expand All @@ -61,13 +50,7 @@ public CourseData[] read(String name) {
json.setIgnoreUnknownFields(true);
CourseData[] courses = json.fromJson(CourseData[].class,
new BufferedInputStream(Files.newInputStream(p)));
List<CourseData> result = new ArrayList<CourseData>();
for(CourseData course : courses) {
if(course.validate()) {
result.add(course);
}
}
return result.toArray(new CourseData[result.size()]);
return Stream.of(courses).filter(CourseData::validate).toArray(CourseData[]::new);
} catch(Throwable e) {

}
Expand All @@ -92,9 +75,7 @@ public CourseData[] read(String name) {
*/
public void write(String name, CourseData[] cd) {
try {
for(CourseData c : cd) {
c.shrink();
}
Stream.of(cd).forEach(CourseData::shrink);
Json json = new Json();
json.setOutputType(JsonWriter.OutputType.json);
OutputStreamWriter fw = new OutputStreamWriter(new BufferedOutputStream(
Expand Down
Loading

0 comments on commit aa69103

Please sign in to comment.