Refactored Feature to Mod

This commit is contained in:
2026-03-24 11:48:04 +01:00
parent 174c95240c
commit 3138f7ec62
28 changed files with 196 additions and 196 deletions
@@ -1,21 +1,21 @@
package org.saturnclient.ui.components;
import org.saturnclient.feature.FeatureLayout;
import org.saturnclient.feature.HudFeature;
import org.saturnclient.mod.HudMod;
import org.saturnclient.mod.ModLayout;
import org.saturnclient.ui.Element;
import org.saturnclient.ui.ElementContext;
import org.saturnclient.ui.RenderScope;
public class HudModPreview extends Element {
HudFeature feature;
HudMod feature;
public HudModPreview(HudFeature feature) {
public HudModPreview(HudMod feature) {
this.feature = feature;
}
@Override
public void render(RenderScope scope, ElementContext ctx) {
FeatureLayout layout = feature.getDimensions();
ModLayout layout = feature.getDimensions();
if (layout.renderBackground) {
scope.drawRoundedRectangle(0, 0, layout.width, layout.height,
@@ -2,8 +2,8 @@ package org.saturnclient.ui.components;
import org.saturnclient.common.provider.Providers;
import org.saturnclient.config.Theme;
import org.saturnclient.feature.Feature;
import org.saturnclient.feature.HudFeature;
import org.saturnclient.mod.HudMod;
import org.saturnclient.mod.Mod;
import org.saturnclient.ui.Element;
import org.saturnclient.ui.ElementContext;
import org.saturnclient.ui.RenderScope;
@@ -14,13 +14,13 @@ import org.saturnclient.ui.screens.ConfigEditor;
public class SaturnModule extends Element {
private final Feature mod;
private final Mod mod;
static int p = 10; // padding
static int s = 14; // settings icon size
static int expand = 5; // settings icon click area
public SaturnModule(Feature mod) {
public SaturnModule(Mod mod) {
this.mod = mod;
this.width = 160;
this.height = 50;
@@ -142,7 +142,7 @@ public class SaturnModule extends Element {
1.0f);
if (settingsHover) {
if (mod instanceof HudFeature h) {
if (mod instanceof HudMod h) {
Providers.saturn.getClient().setScreen(new ConfigEditor(mod.getConfig(), h));
} else {
Providers.saturn.getClient().setScreen(new ConfigEditor(mod.getConfig()));
@@ -12,8 +12,8 @@ import org.saturnclient.config.property.KeybindingProperty;
import org.saturnclient.config.property.NamespaceProperty;
import org.saturnclient.config.property.Property;
import org.saturnclient.config.property.SelectProperty;
import org.saturnclient.feature.FeatureLayout;
import org.saturnclient.feature.HudFeature;
import org.saturnclient.mod.HudMod;
import org.saturnclient.mod.ModLayout;
import org.saturnclient.ui.RenderScope;
import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.components.HudModPreview;
@@ -30,7 +30,7 @@ import org.saturnclient.ui.resources.Fonts;
public class ConfigEditor extends SaturnScreen {
private ConfigManager config;
private HudFeature hudFeature;
private HudMod hudFeature;
private HudModPreview preview;
public ConfigEditor(ConfigManager config) {
@@ -39,7 +39,7 @@ public class ConfigEditor extends SaturnScreen {
this.config = config;
}
public ConfigEditor(ConfigManager config, HudFeature hudFeature) {
public ConfigEditor(ConfigManager config, HudMod hudFeature) {
super("Config Editor");
this.config = config;
@@ -160,7 +160,7 @@ public class ConfigEditor extends SaturnScreen {
@Override
public void render(RenderScope renderScope, int mouseX, int mouseY, float delta, long elapsed) {
if (this.preview != null) {
FeatureLayout layout = hudFeature.getDimensions();
ModLayout layout = hudFeature.getDimensions();
draw(this.preview
.dimensions(layout.width, (int) (layout.height * layout.scale.value * 2.0f))
.scale(1.0f) // Because the centering won't work properly
@@ -2,10 +2,10 @@ package org.saturnclient.ui.screens;
import org.saturnclient.common.ref.render.MatrixStackRef;
import org.saturnclient.config.ConfigManager;
import org.saturnclient.feature.HudFeature;
import org.saturnclient.feature.FeatureLayout;
import org.saturnclient.feature.FeatureManager;
import org.saturnclient.feature.Feature;
import org.saturnclient.mod.HudMod;
import org.saturnclient.mod.Mod;
import org.saturnclient.mod.ModLayout;
import org.saturnclient.mod.ModManager;
import org.saturnclient.ui.RenderScope;
import org.saturnclient.ui.SaturnScreen;
@@ -13,17 +13,17 @@ import java.util.ArrayList;
import java.util.List;
public class HudEditor extends SaturnScreen {
private final List<HudFeature> hudMods = new ArrayList<>();
private HudFeature draggingMod = null;
private final List<HudMod> hudMods = new ArrayList<>();
private HudMod draggingMod = null;
private boolean resizing = false;
private int offsetX, offsetY;
private static final int RESIZE_MARGIN = 3;
public HudEditor() {
super("HUD Editor");
for (Feature m : FeatureManager.ENABLED_MODS) {
if (m.isEnabled() && m instanceof HudFeature) {
hudMods.add((HudFeature) m);
for (Mod m : ModManager.ENABLED_MODS) {
if (m.isEnabled() && m instanceof HudMod) {
hudMods.add((HudMod) m);
}
}
}
@@ -32,8 +32,8 @@ public class HudEditor extends SaturnScreen {
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 0) {
for (int m = hudMods.size() - 1; m >= 0; m--) {
HudFeature mod = hudMods.get(m);
FeatureLayout dim = mod.getDimensions();
HudMod mod = hudMods.get(m);
ModLayout dim = mod.getDimensions();
// Check if clicking the corner for resizing
if (isCorner(mouseX, mouseY, dim)) {
@@ -69,7 +69,7 @@ public class HudEditor extends SaturnScreen {
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
if (draggingMod != null) {
FeatureLayout dim = draggingMod.getDimensions();
ModLayout dim = draggingMod.getDimensions();
if (resizing) {
// Scale based on cursor movement
@@ -90,8 +90,8 @@ public class HudEditor extends SaturnScreen {
@Override
public void render(RenderScope renderScope, int mouseX, int mouseY, float delta, long elapsed) {
for (HudFeature mod : hudMods) {
FeatureLayout dim = mod.getDimensions();
for (HudMod mod : hudMods) {
ModLayout dim = mod.getDimensions();
MatrixStackRef matrices = renderScope.getMatrixStack();
matrices.push();
@@ -113,12 +113,12 @@ public class HudEditor extends SaturnScreen {
}
}
private boolean isInside(double mouseX, double mouseY, FeatureLayout dim) {
private boolean isInside(double mouseX, double mouseY, ModLayout dim) {
return mouseX >= dim.x.value && mouseX <= dim.x.value + (dim.width * dim.scale.value) &&
mouseY >= dim.y.value && mouseY <= dim.y.value + (dim.height * dim.scale.value);
}
private boolean isCorner(double mouseX, double mouseY, FeatureLayout dim) {
private boolean isCorner(double mouseX, double mouseY, ModLayout dim) {
float rightX = dim.x.value + dim.width * dim.scale.value;
float bottomY = dim.y.value + dim.height * dim.scale.value;
@@ -1,8 +1,8 @@
package org.saturnclient.ui.screens;
import org.saturnclient.config.AnimationConfig;
import org.saturnclient.feature.FeatureManager;
import org.saturnclient.feature.Feature;
import org.saturnclient.mod.Mod;
import org.saturnclient.mod.ModManager;
import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.anim.SlideFade;
import org.saturnclient.ui.components.SaturnModule;
@@ -29,7 +29,7 @@ public class ModMenu extends SaturnScreen {
AnimationStagger moduleStagger = new AnimationStagger(AnimationConfig.modMenu);
for (Feature mod : FeatureManager.MODS) {
for (Mod mod : ModManager.MODS) {
moduleStagger.draw(
new SaturnModule(mod)
.position((160 + g) * col, (50 + g) * row)