fps display
This commit is contained in:
@@ -36,14 +36,13 @@ public class SaturnClient implements ModInitializer {
|
||||
);
|
||||
|
||||
public static Property<Integer> NORMAL = config.property(
|
||||
"Normal color",
|
||||
"Default color",
|
||||
new Property<Integer>(
|
||||
ColorHelper.getArgb(255, 182, 182, 182),
|
||||
Property.PropertyType.HEX
|
||||
)
|
||||
);
|
||||
|
||||
// public static int NORMAL = ColorHelper.getArgb(255, 182, 182, 182);
|
||||
public static int WHITE = ColorHelper.getArgb(255, 255, 255, 255);
|
||||
public static TextRenderer textRenderer = null;
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.saturnclient.saturnmods;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public interface HudMod {
|
||||
public void setDimensions(ModDimensions dimensions);
|
||||
|
||||
public ModDimensions getDimensions();
|
||||
|
||||
public void renderDummy(DrawContext context);
|
||||
|
||||
@@ -6,12 +6,15 @@ import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.menus.HudEditor;
|
||||
import org.saturnclient.saturnmods.mods.ArmorDisplay;
|
||||
import org.saturnclient.saturnmods.mods.Coordinates;
|
||||
import org.saturnclient.saturnmods.mods.*;
|
||||
|
||||
public class ModManager {
|
||||
|
||||
public static SaturnMod[] MODS = { new Coordinates(), new ArmorDisplay() };
|
||||
public static SaturnMod[] MODS = {
|
||||
new Coordinates(),
|
||||
new ArmorDisplay(),
|
||||
new FpsDisplay(),
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
HudRenderCallback.EVENT.register((context, _o) -> {
|
||||
|
||||
@@ -115,10 +115,6 @@ public class ArmorDisplay implements SaturnMod, HudMod {
|
||||
return Textures.getModIcon("armor");
|
||||
}
|
||||
|
||||
public void setDimensions(ModDimensions d) {
|
||||
dimensions = d;
|
||||
}
|
||||
|
||||
public ModDimensions getDimensions() {
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
@@ -73,10 +73,6 @@ public class Coordinates implements SaturnMod, HudMod {
|
||||
return Textures.getModIcon("coords");
|
||||
}
|
||||
|
||||
public void setDimensions(ModDimensions d) {
|
||||
dimensions = d;
|
||||
}
|
||||
|
||||
public ModDimensions getDimensions() {
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.saturnclient.saturnmods.mods;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||
import org.saturnclient.saturnclient.config.Property;
|
||||
import org.saturnclient.saturnmods.HudMod;
|
||||
import org.saturnclient.saturnmods.ModDimensions;
|
||||
import org.saturnclient.saturnmods.SaturnMod;
|
||||
import org.saturnclient.ui.Textures;
|
||||
|
||||
public class FpsDisplay implements SaturnMod, HudMod {
|
||||
|
||||
public static ConfigManager config = new ConfigManager("Fps Display");
|
||||
|
||||
public static Property<Boolean> enabled = config.property(
|
||||
"Enabled",
|
||||
new Property<>(false)
|
||||
);
|
||||
|
||||
public static ModDimensions dimensions = new ModDimensions(
|
||||
config,
|
||||
0,
|
||||
0,
|
||||
40,
|
||||
8
|
||||
);
|
||||
|
||||
public static Property<Integer> fgColor = config.property(
|
||||
"Foreground color",
|
||||
new Property<>(SaturnClient.WHITE, Property.PropertyType.HEX)
|
||||
);
|
||||
|
||||
@Override
|
||||
public ModDimensions getDimensions() {
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDummy(DrawContext context) {
|
||||
int fps = 128;
|
||||
|
||||
context.drawText(
|
||||
SaturnClient.textRenderer,
|
||||
String.valueOf(fps) + " FPS",
|
||||
0,
|
||||
0,
|
||||
fgColor.value,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context) {
|
||||
int fps = MinecraftClient.getInstance().getCurrentFps();
|
||||
|
||||
context.drawText(
|
||||
SaturnClient.textRenderer,
|
||||
String.valueOf(fps) + " FPS",
|
||||
0,
|
||||
0,
|
||||
fgColor.value,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean e) {
|
||||
enabled.value = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Fps Display";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getIconTexture() {
|
||||
return Textures.getModIcon("fps");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigManager getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user