Skip to content

Commit

Permalink
Add New Features
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Apr 21, 2024
1 parent 0063ccb commit 0f48bc0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
6 changes: 6 additions & 0 deletions assets/UI/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
-fx-effect: dropshadow(gaussian, derive(black, 90%), 10, 0.1, 0, 0.5);
}

/* Color constants */
.root {
-text-normal: #242424;
-theme-color: #2A528C;
Expand Down Expand Up @@ -374,6 +375,11 @@ JFXSlider {
-fx-text-fill: -text-normal;
}

.config-field JFXComboBox .list-cell {
-fx-cursor: hand;
-fx-padding: 4px 8px 4px 8px;
}

.config-field JFXCheckBox,
.config-field HBox Label {
-fx-font-size: 12px;
Expand Down
22 changes: 11 additions & 11 deletions desktop/src/cn/harryh/arkpets/controllers/BehaviorModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private void initConfigBehavior() {
GuiComponents.SliderSetup<Integer> setupPhysicGravity = new GuiComponents.SimpleMultipleIntegerSliderSetup(configPhysicGravity, 10);
setupPhysicGravity
.setDisplay(configPhysicGravityValue, "%d px/s²", "像素每平方秒 (pixel/s²)")
.setRange(0, 1000)
.setTicks(100, 10)
.setRange(0, 2000)
.setTicks(200, 10)
.setSliderValue(app.config.physic_gravity_acc)
.setOnChanged((observable, oldValue, newValue) -> {
app.config.physic_gravity_acc = setupPhysicGravity.getValidatedValue();
Expand All @@ -133,8 +133,8 @@ private void initConfigBehavior() {
GuiComponents.SliderSetup<Integer> setupPhysicAirFriction = new GuiComponents.SimpleMultipleIntegerSliderSetup(configPhysicAirFriction, 10);
setupPhysicAirFriction
.setDisplay(configPhysicAirFrictionValue, "%d px/s²", "像素每平方秒 (pixel/s²)")
.setRange(0, 1000)
.setTicks(100, 10)
.setRange(0, 2000)
.setTicks(200, 10)
.setSliderValue(app.config.physic_air_friction_acc)
.setOnChanged((observable, oldValue, newValue) -> {
app.config.physic_air_friction_acc = setupPhysicAirFriction.getValidatedValue();
Expand All @@ -143,8 +143,8 @@ private void initConfigBehavior() {
GuiComponents.SliderSetup<Integer> setupPhysicStaticFriction = new GuiComponents.SimpleMultipleIntegerSliderSetup(configPhysicStaticFriction, 10);
setupPhysicStaticFriction
.setDisplay(configPhysicStaticFrictionValue, "%d px/s²", "像素每平方秒 (pixel/s²)")
.setRange(0, 1000)
.setTicks(100, 10)
.setRange(0, 2000)
.setTicks(200, 10)
.setSliderValue(app.config.physic_static_friction_acc)
.setOnChanged((observable, oldValue, newValue) -> {
app.config.physic_static_friction_acc = setupPhysicStaticFriction.getValidatedValue();
Expand All @@ -153,8 +153,8 @@ private void initConfigBehavior() {
GuiComponents.SliderSetup<Integer> setupPhysicSpeedLimitX = new GuiComponents.SimpleMultipleIntegerSliderSetup(configPhysicSpeedLimitX, 10);
setupPhysicSpeedLimitX
.setDisplay(configPhysicSpeedLimitXValue, "%d px/s", "像素每秒 (pixel/s)")
.setRange(0, 1000)
.setTicks(100, 10)
.setRange(0, 2000)
.setTicks(200, 10)
.setSliderValue(app.config.physic_speed_limit_x)
.setOnChanged((observable, oldValue, newValue) -> {
app.config.physic_speed_limit_x = setupPhysicSpeedLimitX.getValidatedValue();
Expand All @@ -163,8 +163,8 @@ private void initConfigBehavior() {
GuiComponents.SliderSetup<Integer> setupPhysicSpeedLimitY = new GuiComponents.SimpleMultipleIntegerSliderSetup(configPhysicSpeedLimitY, 10);
setupPhysicSpeedLimitY
.setDisplay(configPhysicSpeedLimitYValue, "%d px/s", "像素每秒 (pixel/s)")
.setRange(0, 1000)
.setTicks(100, 10)
.setRange(0, 2000)
.setTicks(200, 10)
.setSliderValue(app.config.physic_speed_limit_y)
.setOnChanged((observable, oldValue, newValue) -> {
app.config.physic_speed_limit_y = setupPhysicSpeedLimitY.getValidatedValue();
Expand Down Expand Up @@ -202,7 +202,7 @@ protected Boolean call() {
return task;
}
};
ss.setDelay(new Duration(2000));
ss.setDelay(new Duration(2500));
ss.setPeriod(new Duration(5000));
ss.setRestartOnFailure(true);
ss.start();
Expand Down
35 changes: 32 additions & 3 deletions desktop/src/cn/harryh/arkpets/controllers/SettingsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,17 @@ public final class SettingsModule implements Controller<ArkHomeFX> {

private GuiComponents.NoticeBar appVersionNotice;
private GuiComponents.NoticeBar diskFreeSpaceNotice;
private GuiComponents.NoticeBar fpsUnreachableNotice;

private ArkHomeFX app;

@Override
public void initializeWith(ArkHomeFX app) {
this.app = app;
initNoticeBox();
initConfigDisplay();
initConfigAdvanced();
initAbout();
initNoticeBox();
initScheduledListener();
}

Expand All @@ -79,7 +80,9 @@ private void initConfigDisplay() {
new NamedItem<>("x1.0", 1f),
new NamedItem<>("x1.25", 1.25f),
new NamedItem<>("x1.5", 1.5f),
new NamedItem<>("x2.0", 2f))
new NamedItem<>("x2.0", 2f),
new NamedItem<>("x2.5", 2.5f),
new NamedItem<>("x3.0", 3.0f))
.selectValue(app.config.display_scale, "x" + app.config.display_scale + "(自定义)")
.setOnNonNullValueUpdated((observable, oldValue, newValue) -> {
app.config.display_scale = newValue.value();
Expand All @@ -88,11 +91,13 @@ private void initConfigDisplay() {
new GuiComponents.ComboBoxSetup<>(configDisplayFps).setItems(new NamedItem<>("25", 25),
new NamedItem<>("30", 30),
new NamedItem<>("45", 45),
new NamedItem<>("60", 60))
new NamedItem<>("60", 60),
new NamedItem<>("120", 120))
.selectValue(app.config.display_fps, app.config.display_fps + "(自定义)")
.setOnNonNullValueUpdated((observable, oldValue, newValue) -> {
app.config.display_fps = newValue.value();
app.config.saveConfig();
fpsUnreachableNotice.refresh();
});
new GuiComponents.ComboBoxSetup<>(configCanvasSize).setItems(new NamedItem<>("最宽", 4),
new NamedItem<>("较宽", 8),
Expand Down Expand Up @@ -264,6 +269,30 @@ protected String getText() {
return "当前磁盘存储空间不足,可能影响使用体验。";
}
};
fpsUnreachableNotice = new GuiComponents.NoticeBar(noticeBox) {
@Override
protected boolean isToActivate() {
for (ArkConfig.Monitor i : ArkConfig.Monitor.getMonitors())
if (i.hz >= configDisplayFps.getValue().value())
return false;
return true;
}

@Override
protected String getColorString() {
return GuiPrefabs.Colors.COLOR_WARNING;
}

@Override
protected String getIconSVGPath() {
return GuiPrefabs.Icons.ICON_WARNING_ALT;
}

@Override
protected String getText() {
return "当前设置的帧率超过了当前显示器的刷新率。";
}
};
}

private void initScheduledListener() {
Expand Down

0 comments on commit 0f48bc0

Please sign in to comment.