diff --git a/assets/ArkPetsConfigDefault.json b/assets/ArkPetsConfigDefault.json
index a6282179..4213a6e1 100644
--- a/assets/ArkPetsConfigDefault.json
+++ b/assets/ArkPetsConfigDefault.json
@@ -1,4 +1,5 @@
{
+ "background_color":"#00000000",
"behavior_ai_activation":8,
"behavior_allow_interact":true,
"behavior_allow_sit":true,
diff --git a/assets/UI/SettingsModule.fxml b/assets/UI/SettingsModule.fxml
index 7b773389..9be5e0a1 100644
--- a/assets/UI/SettingsModule.fxml
+++ b/assets/UI/SettingsModule.fxml
@@ -35,6 +35,10 @@
+
+
+
+
diff --git a/assets/shaders/OutlineFragment.glsl b/assets/shaders/OutlineFragment.glsl
index 92ce8c0a..9f48f1a7 100644
--- a/assets/shaders/OutlineFragment.glsl
+++ b/assets/shaders/OutlineFragment.glsl
@@ -4,12 +4,14 @@
// Gap Seaming and Ouline Effect Fragment Shader for TwoColorPolygonBatch.
-#version 130
+#version 120
varying vec2 v_texCoords; // From VS
uniform sampler2D u_texture; // From TCPB
uniform vec3 u_outlineColor; // Required
uniform float u_outlineWidth; // Required
+uniform ivec2 u_textureSize;
+uniform float u_alpha;
const float c_alphaLv0 = 0.1;
const float c_alphaLv1 = 0.5;
@@ -31,7 +33,7 @@ vec4[8] getNeighbors(sampler2D tex, vec2 texCoords, vec2 offset) {
void main() {
vec4 texColor = texture2D(u_texture, v_texCoords);
- ivec2 texSize = textureSize(u_texture, 0);
+ ivec2 texSize = u_textureSize;
if (texColor.a < c_alphaLv0) {
// Outline effect apply on transparent areas
@@ -76,4 +78,6 @@ void main() {
// No effect apply on other areas
gl_FragColor = texColor;
}
+ // Alpha
+ gl_FragColor.a -= (1 - u_alpha);
}
diff --git a/assets/shaders/TCPBFragment.glsl b/assets/shaders/TCPBFragment.glsl
index e1d08d4a..18c72701 100644
--- a/assets/shaders/TCPBFragment.glsl
+++ b/assets/shaders/TCPBFragment.glsl
@@ -4,7 +4,7 @@
// Common Fragment Shader for TwoColorPolygonBatch.
-#version 130
+#version 120
#ifdef GL_ES
#define LOWP lowp
diff --git a/assets/shaders/TCPBVertex.glsl b/assets/shaders/TCPBVertex.glsl
index 8c38c3b7..cc8b7027 100644
--- a/assets/shaders/TCPBVertex.glsl
+++ b/assets/shaders/TCPBVertex.glsl
@@ -4,7 +4,7 @@
// Common Vertex Shader for TwoColorPolygonBatch.
-#version 130
+#version 120
attribute vec4 a_position;
attribute vec4 a_light;
diff --git a/core/src/cn/harryh/arkpets/ArkChar.java b/core/src/cn/harryh/arkpets/ArkChar.java
index f75cb088..da7647bc 100644
--- a/core/src/cn/harryh/arkpets/ArkChar.java
+++ b/core/src/cn/harryh/arkpets/ArkChar.java
@@ -51,6 +51,8 @@ public class ArkChar {
protected final AnimClipGroup animList;
protected final HashMap stageInsertMap;
+ protected float alpha;
+
/** Initializes an ArkPets character.
* @param config The ArkPets Config instance which contains the asset's information and other essential settings.
* @param scale The scale of the skeleton.
@@ -62,6 +64,7 @@ public ArkChar(ArkConfig config, float scale) {
camera.setMinInsert(canvasReserveLength - canvasMaxSize);
batch = new TwoColorPolygonBatch();
renderer = new SkeletonRenderer();
+ Color backgroundColor = config.getBackgroundColor();
/* Pre-multiplied alpha shouldn't be applied to models released in Arknights 2.1.41 or later,
otherwise you may get a corrupted rendering result. */
renderer.setPremultipliedAlpha(false);
@@ -120,7 +123,7 @@ protected void onApply(AnimData playing) {
}
};
// 6.Canvas setup
- setCanvas(Color.CLEAR);
+ setCanvas(backgroundColor);
stageInsertMap = new HashMap<>();
for (AnimStage stage : animList.clusterByStage().keySet()) {
// Figure out the suitable canvas size
@@ -227,6 +230,8 @@ protected void renderToBatch() {
shader2.bind();
shader2.setUniformf("u_outlineColor", 1f, 1f, 0f);
shader2.setUniformf("u_outlineWidth", outlineWidth.now());
+ shader2.setUniformi("u_textureSize", passedTexture.getWidth(), passedTexture.getHeight());
+ shader2.setUniformf("u_alpha", alpha);
batch.setShader(shader2);
ScreenUtils.clear(0, 0, 0, 0, true);
batch.begin();
diff --git a/core/src/cn/harryh/arkpets/ArkConfig.java b/core/src/cn/harryh/arkpets/ArkConfig.java
index b7b58bd1..28bbbe2a 100644
--- a/core/src/cn/harryh/arkpets/ArkConfig.java
+++ b/core/src/cn/harryh/arkpets/ArkConfig.java
@@ -11,6 +11,7 @@
import com.alibaba.fastjson.annotation.JSONField;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
+import com.badlogic.gdx.graphics.Color;
import java.io.*;
import java.net.URL;
@@ -38,6 +39,8 @@ public class ArkConfig implements Serializable {
// Config items and default values:
+ /** @since ArkPets 3.3 */ @JSONField(defaultValue = "#00000000")
+ public String background_color;
/** @since ArkPets 1.0 */ @JSONField(defaultValue = "8")
public int behavior_ai_activation;
/** @since ArkPets 1.0 */ @JSONField(defaultValue = "true")
@@ -111,6 +114,20 @@ public boolean isNewcomer() {
return isNewcomer;
}
+ /** Returns converted background color.
+ */
+ @JSONField(serialize = false)
+ public Color getBackgroundColor() {
+ Color backgroundColor;
+ if (background_color.matches("^#[0-9a-fA-F]{8}$")) {
+ backgroundColor = Color.valueOf(background_color);
+ } else {
+ Logger.warn("System", "Invalid background color,using transparent");
+ backgroundColor = Color.CLEAR;
+ }
+ return backgroundColor;
+ }
+
/** Gets the custom ArkConfig object by reading the external config file.
* If the external config file does not exist, a default config file will be generated.
* @return An ArkConfig object. {@code null} if failed.
diff --git a/core/src/cn/harryh/arkpets/ArkPets.java b/core/src/cn/harryh/arkpets/ArkPets.java
index 317d7d86..0f0710a5 100644
--- a/core/src/cn/harryh/arkpets/ArkPets.java
+++ b/core/src/cn/harryh/arkpets/ArkPets.java
@@ -18,6 +18,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.graphics.GL20;
import java.util.HashMap;
import java.util.List;
@@ -61,6 +62,8 @@ public void create() {
config = Objects.requireNonNull(ArkConfig.getConfig(), "ArkConfig returns a null instance, please check the config file.");
Gdx.input.setInputProcessor(this);
Gdx.graphics.setForegroundFPS(config.display_fps);
+ Logger.info("System", "OpenGL Version " + Gdx.gl.glGetString(GL20.GL_VERSION));
+ Logger.info("System", "OpenGL Vendor " + Gdx.gl.glGetString(GL20.GL_VENDOR));
// 2.Character setup
Logger.info("App", "Using model asset \"" + config.character_asset + "\"");
@@ -142,7 +145,7 @@ public void render() {
setWindowPos();
if (!windowAlpha.isEnded()) {
windowAlpha.addProgress(Gdx.graphics.getDeltaTime());
- hWndMine.setWindowAlpha(windowAlpha.now());
+ cha.alpha = windowAlpha.now();
}
promiseToolwindowStyle(1);
diff --git a/core/src/cn/harryh/arkpets/tray/MemberTrayImpl.java b/core/src/cn/harryh/arkpets/tray/MemberTrayImpl.java
index 43cf3702..476006c6 100644
--- a/core/src/cn/harryh/arkpets/tray/MemberTrayImpl.java
+++ b/core/src/cn/harryh/arkpets/tray/MemberTrayImpl.java
@@ -100,7 +100,7 @@ public void onExit() {
public void run() {
Gdx.app.exit();
}
- }, (int)durationNormal.toSeconds());
+ }, (int)durationNormal.toMillis());
}
@Override
diff --git a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java
index 9281bbcb..1a0bc290 100644
--- a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java
+++ b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java
@@ -8,7 +8,6 @@
import cn.harryh.arkpets.utils.Logger;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
-import com.badlogic.gdx.graphics.Color;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.system.MemoryUtil;
@@ -29,8 +28,9 @@ public static void main (String[] args) {
ArgPending.argCache = args;
// Logger
Logger.initialize(LogConfig.logCorePath, LogConfig.logCoreMaxKeep);
+ ArkConfig appConfig = Objects.requireNonNull(ArkConfig.getConfig());
try {
- Logger.setLevel(Objects.requireNonNull(ArkConfig.getConfig()).logging_level);
+ Logger.setLevel(appConfig.logging_level);
} catch (Exception ignored) {
}
new ArgPending(LogConfig.errorArg, args) {
@@ -74,7 +74,7 @@ protected void process(String command, String addition) {
// Configure window display
config.setInitialVisible(true);
config.setTransparentFramebuffer(true);
- config.setInitialBackgroundColor(Color.CLEAR);
+ config.setInitialBackgroundColor(appConfig.getBackgroundColor());
// Handle GLFW error
GLFW.glfwSetErrorCallback(new GLFWErrorCallback() {
@Override
diff --git a/desktop/src/cn/harryh/arkpets/controllers/SettingsModule.java b/desktop/src/cn/harryh/arkpets/controllers/SettingsModule.java
index a5dc65fa..991d7e7b 100644
--- a/desktop/src/cn/harryh/arkpets/controllers/SettingsModule.java
+++ b/desktop/src/cn/harryh/arkpets/controllers/SettingsModule.java
@@ -10,6 +10,7 @@
import cn.harryh.arkpets.guitasks.GuiTask;
import cn.harryh.arkpets.utils.*;
import cn.harryh.arkpets.utils.GuiComponents.*;
+import com.badlogic.gdx.graphics.Color;
import com.jfoenix.controls.*;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
@@ -40,6 +41,8 @@ public final class SettingsModule implements Controller {
@FXML
private JFXComboBox> configRenderOutline;
@FXML
+ private JFXComboBox> configBackgroundColor;
+ @FXML
private JFXCheckBox configWindowTopmost;
@FXML
private JFXComboBox configLoggingLevel;
@@ -140,6 +143,15 @@ public String getContent() {
app.config.display_render_outline = newValue.value();
app.config.save();
});
+ new ComboBoxSetup<>(configBackgroundColor).setItems(new NamedItem<>("透明", 0x00000000),
+ new NamedItem<>("绿色", 0x00ff00ff),
+ new NamedItem<>("蓝色", 0x0000ffff),
+ new NamedItem<>("品红色", 0xff00ffff))
+ .selectValue(Color.rgba8888(app.config.getBackgroundColor()), app.config.background_color + "(自定义)")
+ .setOnNonNullValueUpdated((observable, oldValue, newValue) -> {
+ app.config.background_color = String.format("#%08X", newValue.value());
+ app.config.save();
+ });
configWindowTopmost.setSelected(app.config.window_style_topmost);
configWindowTopmost.setOnAction(e -> {
app.config.window_style_topmost = configWindowTopmost.isSelected();