more style
This commit is contained in:
@@ -3,7 +3,9 @@ package com.dostalgia;
|
|||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Single source of truth for all DOSBox configuration generation.
|
* Single source of truth for all DOSBox configuration generation.
|
||||||
@@ -11,11 +13,6 @@ import java.util.*;
|
|||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class ConfigBuilder {
|
public class ConfigBuilder {
|
||||||
|
|
||||||
/** Priority: .cue (5) > .iso (4) > .ccd (3) > .img (2) > .bin (1) */
|
|
||||||
private static final Map<String, Integer> CD_FORMAT_PRIORITY = Map.of(
|
|
||||||
".cue", 5, ".iso", 4, ".ccd", 3, ".img", 2, ".bin", 1
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a dosbox.conf for a game with a known executable.
|
* Build a dosbox.conf for a game with a known executable.
|
||||||
* @param relExe relative path to the executable inside the ZIP (e.g. "FALLOUT.EXE" or "FALLOUT/FALLOUT.EXE")
|
* @param relExe relative path to the executable inside the ZIP (e.g. "FALLOUT.EXE" or "FALLOUT/FALLOUT.EXE")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
|
|||||||
public class ConfigPatcher {
|
public class ConfigPatcher {
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(ConfigPatcher.class.getName());
|
private static final Logger LOG = Logger.getLogger(ConfigPatcher.class.getName());
|
||||||
private static final Pattern DRIVE_PATH = Pattern.compile("[A-Za-z]:(\\\\|/)[^\\s\"\\r\\n]+");
|
private static final Pattern DRIVE_PATH = Pattern.compile("[A-Za-z]:([\\\\/])[^\\s\"\\r\\n]+");
|
||||||
|
|
||||||
/** Scan and fix absolute paths in all text files in the given directory. */
|
/** Scan and fix absolute paths in all text files in the given directory. */
|
||||||
public void fixAbsolutePaths(Path extractDir) throws IOException {
|
public void fixAbsolutePaths(Path extractDir) throws IOException {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class GameService implements GameStore {
|
|||||||
// Detect bundle size
|
// Detect bundle size
|
||||||
try {
|
try {
|
||||||
Path bundlePath = gamesDir.resolve(game.getBundleFile());
|
Path bundlePath = gamesDir.resolve(game.getBundleFile());
|
||||||
if (bundlePath != null && Files.exists(bundlePath)) {
|
if (Files.exists(bundlePath)) {
|
||||||
game.setBundleSize(Files.size(bundlePath));
|
game.setBundleSize(Files.size(bundlePath));
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dostalgia;
|
package com.dostalgia;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,7 +9,7 @@ import java.util.List;
|
|||||||
* Decouples consumers (IgdbService, GameController) from the concrete storage implementation.
|
* Decouples consumers (IgdbService, GameController) from the concrete storage implementation.
|
||||||
*/
|
*/
|
||||||
public interface GameStore {
|
public interface GameStore {
|
||||||
Game load(String id) throws IOException, NoSuchFileException;
|
Game load(String id) throws IOException;
|
||||||
void save(Game game) throws IOException;
|
void save(Game game) throws IOException;
|
||||||
List<Game> list() throws IOException;
|
List<Game> list() throws IOException;
|
||||||
void delete(String id) throws IOException;
|
void delete(String id) throws IOException;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class IgdbService {
|
|||||||
private static final String TWITCH_AUTH = "https://id.twitch.tv/oauth2/token";
|
private static final String TWITCH_AUTH = "https://id.twitch.tv/oauth2/token";
|
||||||
private static final String IGDB_API = "https://api.igdb.com/v4";
|
private static final String IGDB_API = "https://api.igdb.com/v4";
|
||||||
private static final String IMG_BASE = "https://images.igdb.com/igdb/image/upload";
|
private static final String IMG_BASE = "https://images.igdb.com/igdb/image/upload";
|
||||||
private static final String COVER_SIZE = "t_cover_big"; // ~264x352, good for grid display
|
private static final String COVER_SIZE = "t_cover_big";
|
||||||
|
|
||||||
private final HttpClient http = HttpClient.newHttpClient();
|
private final HttpClient http = HttpClient.newHttpClient();
|
||||||
private final ObjectMapper mapper = new ObjectMapper();
|
private final ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -286,7 +286,7 @@ public class IgdbService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best == null) best = results.get(0);
|
if (best == null) best = results.getFirst();
|
||||||
|
|
||||||
applyMatch(game, best);
|
applyMatch(game, best);
|
||||||
LOG.info("IGDB auto-scrape: applied '" + best.get("name") + "' to '" + game.getTitle() + "'");
|
LOG.info("IGDB auto-scrape: applied '" + best.get("name") + "' to '" + game.getTitle() + "'");
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public class PlatformDetector {
|
|||||||
sig2 = buf[peOffset + 1];
|
sig2 = buf[peOffset + 1];
|
||||||
} else {
|
} else {
|
||||||
try (var fis2 = Files.newInputStream(exePath)) {
|
try (var fis2 = Files.newInputStream(exePath)) {
|
||||||
fis2.skip(peOffset);
|
|
||||||
sig1 = (byte) fis2.read();
|
sig1 = (byte) fis2.read();
|
||||||
sig2 = (byte) fis2.read();
|
sig2 = (byte) fis2.read();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,6 @@ public class UploadResource {
|
|||||||
@Inject
|
@Inject
|
||||||
IgdbService igdb;
|
IgdbService igdb;
|
||||||
|
|
||||||
@Inject
|
|
||||||
ConfigBuilder config;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ZipService zip;
|
ZipService zip;
|
||||||
|
|
||||||
@@ -202,7 +199,7 @@ public class UploadResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fname = upload.fileName().toLowerCase();
|
String fname = upload.fileName().toLowerCase();
|
||||||
String ext = "";
|
String ext;
|
||||||
if (fname.endsWith(".jpg") || fname.endsWith(".jpeg")) ext = ".jpg";
|
if (fname.endsWith(".jpg") || fname.endsWith(".jpeg")) ext = ".jpg";
|
||||||
else if (fname.endsWith(".png")) ext = ".png";
|
else if (fname.endsWith(".png")) ext = ".png";
|
||||||
else if (fname.endsWith(".webp")) ext = ".webp";
|
else if (fname.endsWith(".webp")) ext = ".webp";
|
||||||
|
|||||||
Reference in New Issue
Block a user