Skip to content

Commit

Permalink
Merge pull request #98 from half-nothing/v4.x-vcs
Browse files Browse the repository at this point in the history
VCS phase merge II
  • Loading branch information
isHarryh authored Jan 19, 2025
2 parents 4238b8c + 252b503 commit 6f27246
Show file tree
Hide file tree
Showing 45 changed files with 1,044 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ test*/
/assets/ArkPetsConfig.json
/assets/models_data.json
/assets/*.zip
/assets/data/
/assets/voice_data*
70 changes: 70 additions & 0 deletions assets/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
CREATE TABLE IF NOT EXISTS "metadata"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"repo" TEXT NOT NULL,
"group" TEXT NOT NULL,
"key" TEXT NOT NULL,
"value" TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS "char_info"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"asset_id" TEXT NOT NULL,
"store_path" TEXT NOT NULL,
"type" TEXT NOT NULL,
"style" TEXT,
"name" TEXT NOT NULL,
"appellation" TEXT,
"skin_group_id" TEXT NOT NULL,
"skin_group_name" TEXT NOT NULL,
"md5" TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS "model_assets"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"model_id" INTEGER NOT NULL,
"type" TEXT NOT NULL,
"filename" TEXT NOT NULL,
"md5" TEXT NOT NULL DEFAULT '',
"exist" BOOLEAN NOT NULL DEFAULT FALSE,
"vcs" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "model_assets_fk_id" FOREIGN KEY ("model_id") REFERENCES "char_info" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE IF NOT EXISTS "model_tags"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"model_id" INTEGER NOT NULL,
"tag" TEXT NOT NULL,
CONSTRAINT "model_tags_fk_id" FOREIGN KEY ("model_id") REFERENCES "char_info" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE IF NOT EXISTS "model_voice"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"model_id" INTEGER NOT NULL,
"language" TEXT NOT NULL,
"duration" DOUBLE NOT NULL,
"md5" TEXT NOT NULL DEFAULT '',
"exist" BOOLEAN NOT NULL DEFAULT FALSE,
"vcs" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "model_voice_fk_id" FOREIGN KEY ("model_id") REFERENCES "char_info" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE IF NOT EXISTS "model_voice_clips"
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"model_voice_id" INTEGER NOT NULL,
"start" DOUBLE NOT NULL,
"duration" DOUBLE NOT NULL,
CONSTRAINT "model_voice_clips_fk_id" FOREIGN KEY ("model_voice_id") REFERENCES "model_voice" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE UNIQUE INDEX IF NOT EXISTS "metadata_index" ON "metadata" ("repo", "group", "key");
CREATE UNIQUE INDEX IF NOT EXISTS "char_info_asset_id_index" ON "char_info" ("asset_id");
CREATE INDEX IF NOT EXISTS "model_assets_model_id_index" ON "model_assets" ("model_id");
CREATE INDEX IF NOT EXISTS "model_tags_model_id_index" ON "model_tags" ("model_id");
CREATE INDEX IF NOT EXISTS "model_voice_model_id_index" ON "model_voice" ("model_id");
CREATE INDEX IF NOT EXISTS "model_voice_clips_model_voice_id_index" ON "model_voice_clips" ("model_voice_id");
19 changes: 9 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ buildscript {
}
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7")
}

val appName: String by project

allprojects {
Expand All @@ -41,6 +37,7 @@ allprojects {
plugin("java-library")
plugin("org.openjfx.javafxplugin")
plugin("org.jetbrains.kotlin.jvm")
plugin("io.gitlab.arturbosch.detekt")
}

version = "$appVersion${getVersionMetadata()}"
Expand All @@ -61,6 +58,7 @@ allprojects {
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7")
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
Expand Down Expand Up @@ -97,15 +95,16 @@ allprojects {
}
}
}
}

// code style check for kotlin
detekt {
buildUponDefaultConfig = true
autoCorrect = true
config.setFrom(rootProject.files("detekt.yml"))
// code style check for kotlin
detekt {
buildUponDefaultConfig = true
autoCorrect = true
config.setFrom(rootProject.files("detekt.yml"))
}
}


// git hooks for automatically checking code style
gitHooks {
setHooks(
Expand Down
29 changes: 25 additions & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ sourceSets {
}
}

detekt {
source.setFrom("src/")
}

dependencies {
val gdxVersion: String by rootProject
val jnaVersion: String by rootProject
val javaFXVersion: String by rootProject
val dbusVersion: String by rootProject
val javaFXPlatforms: String by rootProject
val lwjglList: String by rootProject
val lwjglVersion: String by rootProject

// Spine Runtime
api("com.esotericsoftware.spine:spine-libgdx:3.8.99.1")
Expand All @@ -20,14 +28,27 @@ dependencies {
api("net.java.dev.jna:jna:$jnaVersion")
api("net.java.dev.jna:jna-platform:$jnaVersion")
// JavaFX
api("org.openjfx:javafx-base:$javaFXVersion:win")
api("org.openjfx:javafx-controls:$javaFXVersion:win")
api("org.openjfx:javafx-graphics:$javaFXVersion:win")
api("org.openjfx:javafx-fxml:$javaFXVersion:win")
javaFXPlatforms.split(',').forEach {
api("org.openjfx:javafx-base:$javaFXVersion:$it")
api("org.openjfx:javafx-controls:$javaFXVersion:$it")
api("org.openjfx:javafx-graphics:$javaFXVersion:$it")
api("org.openjfx:javafx-fxml:$javaFXVersion:$it")
}
// JFoenix
api("com.jfoenix:jfoenix:9.0.1")
// FastJson
api("com.alibaba:fastjson:2.0.39")
// Log4j
api("apache-log4j:log4j:1.2.15")
// dbus-java
api("com.github.hypfvieh:dbus-java-core:$dbusVersion")
api("com.github.hypfvieh:dbus-java-transport-native-unixsocket:$dbusVersion")
// LWJGL
lwjglList.split(',').forEach {
api("org.lwjgl:$it") {
version {
strictly(lwjglVersion)
}
}
}
}
135 changes: 82 additions & 53 deletions core/src/cn/harryh/arkpets/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,123 @@
*/
public final class Const {
// App version
public static final Version appVersion = new Version(3, 5, 0);
public static final Version datasetLowestVersion = new Version(2, 2, 0);
public static final Version appVersion = new Version(3, 5, 0);
public static final Version datasetLowestVersion = new Version(2, 2, 0);

// App name
public static final String appName = "ArkPets";
public static final String desktopTitle = appName + " Launcher " + appVersion;
public static final NumberedTitleManager coreTitleManager = new NumberedTitleManager(appName);
public static final String appName = "ArkPets";
public static final String desktopTitle = appName + " Launcher " + appVersion;
public static final NumberedTitleManager coreTitleManager = new NumberedTitleManager(appName);

// IO presets
public static final int zipBufferSizeDefault = 16 * 1024;
public static final int httpBufferSizeDefault = 16 * 1024;
public static final int httpTimeoutDefault = 20 * 1000;
public static final int zipBufferSizeDefault = 16 * 1024;
public static final int httpBufferSizeDefault = 16 * 1024;
public static final int httpTimeoutDefault = 20 * 1000;
public static final long diskFreeSpaceRecommended = 1024 * 1024 * 1024L;

// Graphics presets
public static final int fpsDefault = 30;
public static final int coreWidthDefault = 150;
public static final int coreHeightDefault = 150;
public static final int canvasReserveLength = 20;
public static final int canvasMaxSize = 4320;
public static final float skelBaseScale = 0.3f;
public static final int fpsDefault = 30;
public static final int coreWidthDefault = 150;
public static final int coreHeightDefault = 150;
public static final int canvasReserveLength = 20;
public static final int canvasMaxSize = 4320;
public static final float skelBaseScale = 0.3f;

// Behavior presets
public static final int behaviorBaseWeight = 320;
public static final int behaviorWeightLv1 = 32;
public static final int behaviorWeightLv2 = 64;
public static final float droppedThreshold = 10f;
public static final int behaviorBaseWeight = 320;
public static final int behaviorWeightLv1 = 32;
public static final int behaviorWeightLv2 = 64;
public static final float droppedThreshold = 10f;

// Duration presets
public static final Duration durationFast = new Duration(150);
public static final Duration durationNormal = new Duration(300);

// Encoding presets
public static final String charsetDefault = "UTF-8";
public static final String charsetDefault = "UTF-8";

// Paths of static files and internal files
public static final String configExternal = "ArkPetsConfig.json";
public static final String configInternal = "/ArkPetsConfigDefault.json";
public static final String iconFilePng = "/icons/icon.png";
public static final String pass1VShader = "shaders/TCPBVertex.glsl";
public static final String pass1FShader = "shaders/TCPBFragment.glsl";
public static final String pass2VShader = "shaders/TCPBVertex.glsl";
public static final String pass2FShader = "shaders/OutlineFragment.glsl";
public static final String configExternal = "ArkPetsConfig.json";
public static final String configInternal = "/ArkPetsConfigDefault.json";
public static final String iconFilePng = "/icons/icon.png";
public static final String pass1VShader = "shaders/TCPBVertex.glsl";
public static final String pass1FShader = "shaders/TCPBFragment.glsl";
public static final String pass2VShader = "shaders/TCPBVertex.glsl";
public static final String pass2FShader = "shaders/OutlineFragment.glsl";

// Changeable constants
public static boolean isHttpsTrustAll = false;
public static boolean isUpdateAvailable = false;
public static boolean isNewcomer = false;
public static boolean isHttpsTrustAll = false;
public static boolean isUpdateAvailable = false;
public static boolean isNewcomer = false;

// Socket C/S constants
public static final String serverHost = "localhost";
public static final int[] serverPorts = {8686, 8866, 8989, 8899, 8800};
public static final int reconnectDelayMillis = 5 * 1000;
public static final int[] serverPorts = {8686, 8866, 8989, 8899, 8800};
public static final int reconnectDelayMillis = 5 * 1000;

// Misc constants
public static final Pattern ipPortRegex = Pattern.compile(
public static final Pattern ipPortRegex = Pattern.compile(
"^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?):\\d{1,5}$");
public static final Pattern hexColorRegex = Pattern.compile(
public static final Pattern hexColorRegex = Pattern.compile(
"^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$");

/** Paths presets definition class.
*/
public static class PathConfig {
public static final String urlApi = "https://arkpets.harryh.cn/p/arkpets/client/api.php";
public static final String urlDownload = "https://arkpets.harryh.cn/p/arkpets/?from=client#/download";
public static final String urlHelp = "https://arkpets.harryh.cn/p/arkpets/?from=client#/help";
public static final String urlOfficial = "https://arkpets.harryh.cn/p/arkpets/?from=client";
public static final String urlReadme = "https://github.com/isHarryh/Ark-Pets#readme";
public static final String urlLicense = "https://github.com/isHarryh/Ark-Pets";
public static final String urlModelsZip = "isHarryh/Ark-Models/archive/refs/heads/main.zip";
public static final String urlModelsData = "isHarryh/Ark-Models/main/models_data.json";
public static final String tempDirPath = "temp/";
public static final String fileModelsZipName = "ArkModels";
public static final String fileModelsDataPath = "models_data.json";
public static final String tempModelsUnzipDirPath = tempDirPath + "models_unzipped/";
public static final String tempModelsZipCachePath = tempDirPath + fileModelsZipName + ".zip";
public static final String tempQueryVersionCachePath = tempDirPath + "ApiQueryVersionCache";
public static final String urlApi = "https://arkpets.harryh.cn/p/arkpets/client/api.php";
public static final String urlDownload = "https://arkpets.harryh.cn/p/arkpets/?from=client#/download";
public static final String urlHelp = "https://arkpets.harryh.cn/p/arkpets/?from=client#/help";
public static final String urlOfficial = "https://arkpets.harryh.cn/p/arkpets/?from=client";
public static final String urlReadme = "https://github.com/isHarryh/Ark-Pets#readme";
public static final String urlLicense = "https://github.com/isHarryh/Ark-Pets";
public static final String urlModelsZip = "isHarryh/Ark-Models/archive/refs/heads/main.zip";
public static final String urlModelsData = "isHarryh/Ark-Models/main/models_data.json";
public static final String tempDirPath = "temp/";
public static final String fileModelsZipName = "ArkModels";
public static final String fileModelsDataPath = "models_data.json";
public static final String tempModelsUnzipDirPath = tempDirPath + "models_unzipped/";
public static final String tempModelsZipCachePath = tempDirPath + fileModelsZipName + ".zip";
public static final String tempQueryVersionCachePath = tempDirPath + "ApiQueryVersionCache";

// Database config
public static final String dataDirPath = "data/";
public static final String databaseFilename = "models.sqlite3";
public static final String initSqlFilename = "init.sql";
public static final String databaseFilePath = dataDirPath + databaseFilename;
public static final Version databaseVersion = new Version(1, 0, 0);
}

public static class RepositoryConfig {
public static class ModelRepository {
public static class MetadataGroup {
public static final String defaultGroup = "default";
public static final String sortTagGroup = "sortTag";
}

public static final String repoName = "ModelRepository";
public static final String repoPath = "models";
public static final String metadataFilePath = "models_data.json";
}

public static class VoiceRepository {
public static class MetadataGroup {
public static final String defaultGroup = "default";
}

public static final String repoName = "VoiceRepository";
public static final String repoPath = "voice";
}
}


/** Logging presets definition class.
*/
public static class LogConfig {
public static final int logCoreMaxKeep = 32;
public static final int logDesktopMaxKeep = 8;
public static final int logCoreMaxKeep = 32;
public static final int logDesktopMaxKeep = 8;

public static final String logCorePath = "logs/core";
public static final String logDesktopPath = "logs/desktop";
public static final String logCorePath = "logs/core";
public static final String logDesktopPath = "logs/desktop";

public static final String error = "ERROR";
public static final String warn = "WARN";
Expand All @@ -123,8 +152,8 @@ public static class LogConfig {
/** Fonts provider class.
*/
public static class FontsConfig {
private static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf";
private static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf";
private static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf";
private static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf";

public static void loadFontsToJavafx() {
javafx.scene.text.Font.loadFont(FontsConfig.class.getResourceAsStream(fontFileRegular),
Expand Down
Loading

0 comments on commit 6f27246

Please sign in to comment.