sounds WAV -> OPUS
This commit is contained in:
parent
103e4d35f5
commit
93f98f9984
11 changed files with 367 additions and 554 deletions
|
@ -63,6 +63,7 @@ import game.entity.npc.EntityNPC;
|
|||
import game.entity.types.EntityLiving;
|
||||
import game.gui.Font;
|
||||
import game.gui.Gui;
|
||||
import game.gui.GuiConnect;
|
||||
import game.gui.GuiConsole;
|
||||
import game.gui.GuiGameOver;
|
||||
import game.gui.GuiInfo;
|
||||
|
@ -119,6 +120,7 @@ import game.renderer.texture.EntityTexManager;
|
|||
import game.renderer.texture.TextureManager;
|
||||
import game.renderer.texture.TextureMap;
|
||||
import game.rng.Random;
|
||||
import game.util.CharValidator;
|
||||
import game.util.ExtMath;
|
||||
import game.util.FileCallback;
|
||||
import game.util.FileUtils;
|
||||
|
@ -137,6 +139,8 @@ import game.vars.FloatVar;
|
|||
import game.vars.FloatVar.FloatFunction;
|
||||
import game.vars.IntVar;
|
||||
import game.vars.IntVar.IntFunction;
|
||||
import game.vars.StringVar;
|
||||
import game.vars.StringVar.StringFunction;
|
||||
import game.vars.Variable;
|
||||
import game.vars.Variable.IntType;
|
||||
import game.window.Bind;
|
||||
|
@ -294,13 +298,13 @@ public class Game implements IThreadListener {
|
|||
public EntityNPC thePlayer;
|
||||
public HitPosition pointed;
|
||||
|
||||
@Variable(name = "chunk_view_distance", category = CVarCategory.WORLD, min = 2, max = 16 /* 128 */, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
||||
@Variable(name = "chunk_view_distance", category = CVarCategory.RENDER, min = 2, max = 16 /* 128 */, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
||||
public int renderDistance = 8;
|
||||
@Variable(name = "chunk_build_time", category = CVarCategory.WORLD, min = 1, max = 100, display = "Max. Zeit für Chunk-Bau pro Frame", unit = "ms")
|
||||
@Variable(name = "chunk_build_time", category = CVarCategory.RENDER, min = 1, max = 100, display = "Max. Zeit für Chunk-Bau pro Frame", unit = "ms")
|
||||
public int maxBuildTime = 8;
|
||||
@Variable(name = "gl_fov", category = CVarCategory.RENDER, min = 1.0f, max = 179.0f, display = "Sichtfeld (FOV)", unit = "°", precision = 1)
|
||||
public float fov = 70.0f;
|
||||
@Variable(name = "gl_wireframe", category = CVarCategory.RENDER)
|
||||
@Variable(name = "gl_wireframe", category = CVarCategory.RENDER, display = "Gitter-Render-Modus")
|
||||
public boolean wireframe = false;
|
||||
|
||||
@Variable(name = "con_timestamps", category = CVarCategory.CONSOLE, display = "Zeiten")
|
||||
|
@ -308,32 +312,32 @@ public class Game implements IThreadListener {
|
|||
@Variable(name = "con_loglevel", category = CVarCategory.CONSOLE, display = "Ausgabe")
|
||||
public LogLevel level = LogLevel.INFO;
|
||||
|
||||
@Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class)
|
||||
@Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class, display = "Maximale Bildrate")
|
||||
public int sync = 0;
|
||||
|
||||
public int width;
|
||||
public int height;
|
||||
public int mouse_x;
|
||||
public int mouse_y;
|
||||
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536)
|
||||
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterbreite")
|
||||
public int xsize = 1280;
|
||||
@Variable(name = "win_height", category = CVarCategory.WINDOW, min = 1, max = 65536)
|
||||
@Variable(name = "win_height", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterhöhe")
|
||||
public int ysize = 800;
|
||||
@Variable(name = "win_pos_x", category = CVarCategory.WINDOW, min = -65536, max = 65536)
|
||||
@Variable(name = "win_pos_x", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster X-Position")
|
||||
public int saved_xpos = 0x80000000;
|
||||
@Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536)
|
||||
@Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position")
|
||||
public int saved_ypos = 0x80000000;
|
||||
public int fb_x;
|
||||
public int fb_y;
|
||||
|
||||
@Variable(name = "phy_sensitivity", category = CVarCategory.PHYSICS, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
|
||||
@Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
|
||||
public float sensitivity = 1.0f;
|
||||
public boolean fullscreen;
|
||||
public long syncLimit;
|
||||
public boolean mouseFirst;
|
||||
public boolean nograb = System.getProperty("mouse.nograb") != null;
|
||||
public DisplayMode vidMode;
|
||||
@Variable(name = "gui_dclick_delay", category = CVarCategory.GUI, min = 150, max = 750, display = "Doppelklick bei", unit = "ms")
|
||||
@Variable(name = "gui_dclick_delay", category = CVarCategory.INPUT, min = 150, max = 750, display = "Doppelklick bei", unit = "ms")
|
||||
public int dclickDelay = 250;
|
||||
@Variable(name = "con_size", category = CVarCategory.CONSOLE, min = 0, max = 128, callback = ConFunction.class, display = "Nachrichten im Overlay")
|
||||
public int hudSize = 32;
|
||||
|
@ -341,7 +345,7 @@ public class Game implements IThreadListener {
|
|||
public int hudFadeout = 5000;
|
||||
@Variable(name = "con_overlay", category = CVarCategory.CONSOLE, display = "Konsolen-Overlay")
|
||||
public boolean hudOverlay = true;
|
||||
@Variable(name = "con_position", category = CVarCategory.CONSOLE, display = "Position")
|
||||
@Variable(name = "con_position", category = CVarCategory.CONSOLE, display = "Position des Overlays")
|
||||
public ConsolePos hudPos = ConsolePos.TOP;
|
||||
@Variable(name = "con_opacity", category = CVarCategory.CONSOLE, min = 0x00, max = 0xff, display = "Deckkraft Hintergrund")
|
||||
public int hudOpacity = 0x40;
|
||||
|
@ -358,20 +362,20 @@ public class Game implements IThreadListener {
|
|||
public boolean interrupted;
|
||||
public List<DisplayMode> vid_modes = Lists.newArrayList();
|
||||
public List<Message> messages = Lists.newArrayList();
|
||||
@Variable(name = "gui_theme", category = CVarCategory.STYLE)
|
||||
@Variable(name = "gui_theme", category = CVarCategory.GUI, display = "Oberflächen-Design")
|
||||
public Style style = Style.DEFAULT;
|
||||
public List<Style> themes;
|
||||
@Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen#")
|
||||
@Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen")
|
||||
public int scrollLines = 3;
|
||||
|
||||
|
||||
|
||||
@Variable(name = "tic_target", category = CVarCategory.PHYSICS, min = 1.0f, max = 1200.0f, callback = TickFunction.class)
|
||||
@Variable(name = "tic_target", category = CVarCategory.SYSTEM, min = 1.0f, max = 1200.0f, callback = TickFunction.class, display = "Tickrate")
|
||||
public float tpsTarget = 20.0f;
|
||||
@Variable(name = "tic_timeout", category = CVarCategory.PHYSICS, min = 1, max = 60000)
|
||||
@Variable(name = "tic_timeout", category = CVarCategory.SYSTEM, min = 1, max = 60000, display = "Tick-Timeout-Zeit")
|
||||
public int tickTimeout = 2000;
|
||||
|
||||
@Variable(name = "srv_port", category = CVarCategory.WORLD, min = 0, max = 65535)
|
||||
@Variable(name = "srv_port", category = CVarCategory.SYSTEM, min = 0, max = 65535, display = "Standard Hosting-Port")
|
||||
public int port = Config.PORT;
|
||||
public int bind = -1;
|
||||
|
||||
|
@ -389,6 +393,16 @@ public class Game implements IThreadListener {
|
|||
private String buffer = "";
|
||||
private boolean crashed;
|
||||
|
||||
private final int[] tickTimes = new int[240];
|
||||
private final long[] frames = new long[240];
|
||||
private int tickIndex;
|
||||
private int lastIndex;
|
||||
private int frameCounter;
|
||||
private int frameIndex;
|
||||
private long frameLast;
|
||||
private long frameWait;
|
||||
private long startNanoTime = System.nanoTime();
|
||||
|
||||
private static final Game INSTANCE = new Game();
|
||||
|
||||
private final Bind[] keyBindsHotbar = new Bind[] {
|
||||
|
@ -945,6 +959,7 @@ public class Game implements IThreadListener {
|
|||
if(this.drawFps) { // && !(this.open instanceof GuiConsole)
|
||||
if(this.drawDebug && this.open == null) {
|
||||
this.renderStats();
|
||||
this.renderLagometer();
|
||||
}
|
||||
else {
|
||||
Drawing.drawText(String.format("%s%.2f", framecode(), Timing.framerate), 0, 0, 0xffffffff);
|
||||
|
@ -2000,6 +2015,39 @@ public class Game implements IThreadListener {
|
|||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
||||
}
|
||||
|
||||
private void addFrame(long runningTime)
|
||||
{
|
||||
this.frames[this.frameIndex] = runningTime;
|
||||
++this.frameIndex;
|
||||
|
||||
if (this.frameIndex == 240)
|
||||
{
|
||||
this.frameIndex = 0;
|
||||
}
|
||||
|
||||
if (this.frameCounter < 240)
|
||||
{
|
||||
this.lastIndex = 0;
|
||||
++this.frameCounter;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastIndex = (this.frameIndex + 1) % 240;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTick() {
|
||||
long n = System.nanoTime();
|
||||
if(n < this.frameLast + this.frameWait)
|
||||
return;
|
||||
this.frameWait = 50000000L - ((n - (this.frameLast + this.frameWait)) < 50000000L ? (n - (this.frameLast + this.frameWait)) : 0L);
|
||||
this.frameLast = n;
|
||||
this.tickTimes[this.tickIndex++] = this.server != null ? (int)this.server.getLastTick() : 0;
|
||||
if(this.tickIndex == 240) {
|
||||
this.tickIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
start = Window.getTime();
|
||||
|
@ -2020,11 +2068,12 @@ public class Game implements IThreadListener {
|
|||
GlState.enableBlend();
|
||||
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.initConsole();
|
||||
this.startSound(true);
|
||||
this.vidMode = Window.getDisplayMode();
|
||||
Window.initWindow(this.saved_xpos, this.saved_ypos, this.xsize, this.ysize);
|
||||
Window.setIcon(genTriwave(64, 64, 0x00000000, 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff7f00ff, 0xff000000), 64, 64);
|
||||
this.sync(this.sync);
|
||||
this.startSound(true);
|
||||
// this.startSound(true);
|
||||
this.getVar("tic_target").setDefault();
|
||||
this.displayGuiScreen(GuiMenu.INSTANCE);
|
||||
|
||||
|
@ -2067,6 +2116,9 @@ public class Game implements IThreadListener {
|
|||
Log.flushLog();
|
||||
this.poll();
|
||||
PerfSection.WAIT.enter();
|
||||
long now = System.nanoTime();
|
||||
this.addFrame(now - this.startNanoTime);
|
||||
this.startNanoTime = now;
|
||||
while(this.syncLimited && (rtime() - Timing.tmr_current) < (1000000L / this.syncLimit)) {
|
||||
;
|
||||
}
|
||||
|
@ -2753,6 +2805,7 @@ public class Game implements IThreadListener {
|
|||
Variable value = field.getAnnotation(Variable.class);
|
||||
if(value.name().isEmpty())
|
||||
throw new IllegalArgumentException("Variablenname von " + field + " kann nicht leer sein!");
|
||||
field.setAccessible(true);
|
||||
CVar cv;
|
||||
VarFunction func = null;
|
||||
if(value.callback() != VarFunction.class) {
|
||||
|
@ -2764,6 +2817,16 @@ public class Game implements IThreadListener {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
CharValidator validator = null;
|
||||
if(value.validator() != CharValidator.class) {
|
||||
try {
|
||||
validator = value.validator().getConstructor().newInstance();
|
||||
}
|
||||
catch(InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
||||
| NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if(field.getType() == int.class)
|
||||
cv = value.type() != IntType.INT ? new ColorVar(value.name(), value.display(), field, object, value.category(), value.type() == IntType.ALPHA, (IntFunction)func) :
|
||||
new IntVar(value.name(), value.display(), field, object, value.category(), (int)value.min(), (int)value.max(), (IntFunction)func, value.unit(), value.precision());
|
||||
|
@ -2771,6 +2834,8 @@ public class Game implements IThreadListener {
|
|||
cv = new FloatVar(value.name(), value.display(), field, object, value.category(), value.min(), value.max(), (FloatFunction)func, value.unit(), value.precision());
|
||||
else if(field.getType() == boolean.class)
|
||||
cv = new BoolVar(value.name(), value.display(), field, object, value.category(), (BoolFunction)func);
|
||||
else if(field.getType() == String.class)
|
||||
cv = new StringVar(value.name(), value.display(), field, object, value.category(), (int)value.max(), (StringFunction)func, validator, (int)value.min() <= 0);
|
||||
else if(field.getType().isEnum())
|
||||
cv = new EnumVar(value.name(), value.display(), field, object, value.category(), (EnumFunction)func);
|
||||
else
|
||||
|
@ -2798,6 +2863,7 @@ public class Game implements IThreadListener {
|
|||
}
|
||||
regVars(this);
|
||||
regVars(Style.CUSTOM);
|
||||
regVars(GuiConnect.INSTANCE);
|
||||
|
||||
if(!config.exists())
|
||||
return;
|
||||
|
@ -2964,6 +3030,40 @@ public class Game implements IThreadListener {
|
|||
return base + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s");
|
||||
}
|
||||
|
||||
/*
|
||||
private void drawPing(int width, int xPos, int yPos, int ping) {
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.gm.getTextureManager().bindTexture(icons);
|
||||
int rectX = 0;
|
||||
int rectWidth = 0;
|
||||
if(ping < 0 || ping >= 20000) {
|
||||
rectWidth = 5;
|
||||
}
|
||||
else if(ping < 150) {
|
||||
rectWidth = 0;
|
||||
}
|
||||
else if(ping < 300) {
|
||||
rectWidth = 1;
|
||||
}
|
||||
else if(ping < 600) {
|
||||
rectWidth = 2;
|
||||
}
|
||||
else if(ping < 1000) {
|
||||
rectWidth = 3;
|
||||
}
|
||||
else {
|
||||
rectWidth = 4;
|
||||
}
|
||||
|
||||
String str = this.formatPing(ping);
|
||||
|
||||
this.zLevel += 100.0F;
|
||||
this.drawTexturedModalRect(xPos + width - 11, yPos, 0 + rectX * 10, 176 + rectWidth * 8, 10, 8);
|
||||
SKC.drawString(str, xPos + width - (11 + 1 + SKC.getStringWidth(str)), yPos, -1);
|
||||
this.zLevel -= 100.0F;
|
||||
}
|
||||
*/
|
||||
|
||||
public void drawInfo() {
|
||||
NetHandlerPlayClient netHandler = this.getNetHandler();
|
||||
if(netHandler != null) {
|
||||
|
@ -3009,6 +3109,78 @@ public class Game implements IThreadListener {
|
|||
GlState.enableTexture2D();
|
||||
GlState.disableBlend();
|
||||
}
|
||||
|
||||
private int blendColors(int color1, int color2, float value) {
|
||||
int i = color1 >> 24 & 255;
|
||||
int j = color1 >> 16 & 255;
|
||||
int k = color1 >> 8 & 255;
|
||||
int l = color1 & 255;
|
||||
int i1 = color2 >> 24 & 255;
|
||||
int j1 = color2 >> 16 & 255;
|
||||
int k1 = color2 >> 8 & 255;
|
||||
int l1 = color2 & 255;
|
||||
int i2 = ExtMath.clampi((int)((float)i + (float)(i1 - i) * value), 0, 255);
|
||||
int j2 = ExtMath.clampi((int)((float)j + (float)(j1 - j) * value), 0, 255);
|
||||
int k2 = ExtMath.clampi((int)((float)k + (float)(k1 - k) * value), 0, 255);
|
||||
int l2 = ExtMath.clampi((int)((float)l + (float)(l1 - l) * value), 0, 255);
|
||||
return i2 << 24 | j2 << 16 | k2 << 8 | l2;
|
||||
}
|
||||
|
||||
private int getFrameColor(int value, int base, int mid, int high) {
|
||||
value = ExtMath.clampi(value, base, high);
|
||||
return value < mid ? this.blendColors(-16711936, -256, (float)value / (float)mid)
|
||||
: this.blendColors(-256, -65536, (float)(value - mid) / (float)(high - mid));
|
||||
}
|
||||
|
||||
private void renderLagometer() {
|
||||
// GlState.disableDepth();
|
||||
int w = this.fb_x;
|
||||
int h = this.fb_y;
|
||||
int shifted = this.lastIndex;
|
||||
int x = 0;
|
||||
Drawing.drawRect(0, h - 74, 240, 60, 0x90505050);
|
||||
|
||||
Drawing.drawRect(0, h - 44, 240, 1, 0x5fffffff);
|
||||
Drawing.drawRect(0, h - 74, 240, 1, 0x5fffffff);
|
||||
|
||||
while(shifted != this.frameIndex) {
|
||||
int value = (int) (this.frames[shifted] / 1000000L); // , 30);
|
||||
int color = this.getFrameColor(value, 0, 17, 67);
|
||||
if(value > 0)
|
||||
Drawing.drawRect(x, h - 14 - value, 1, value, color & 0xc0ffffff);
|
||||
++x;
|
||||
shifted = (shifted + 1) % 240;
|
||||
}
|
||||
|
||||
Drawing.drawText("30ms", 2, h - 30 - 14, 0xffE0E0E0);
|
||||
Drawing.drawText("60ms", 2, h - 60 - 14, 0xffE0E0E0);
|
||||
Drawing.drawTextRight("ms/Frame", 238, h - 60 - 14, 0xffE0E0E0);
|
||||
|
||||
if(this.server != null) {
|
||||
this.updateTick();
|
||||
Drawing.drawRect(w - 240, h - 74, 240, 60, 0x90505050);
|
||||
x = w - 240;
|
||||
|
||||
Drawing.drawRect(w - 240, h - 44, 240, 1, 0x5fffffff);
|
||||
Drawing.drawRect(w - 240, h - 74, 240, 1, 0x5fffffff);
|
||||
|
||||
for (int n = 0; n < 240; ++n)
|
||||
{
|
||||
int value = this.tickTimes[(n + this.tickIndex) % 240];
|
||||
int color = this.getFrameColor(value, 0, 50, 250);
|
||||
if(value > 0)
|
||||
Drawing.drawRect(x, h - 14 - value, 1, value, color & 0xc0ffffff);
|
||||
++x;
|
||||
shifted = (shifted + 1) % 240;
|
||||
}
|
||||
|
||||
Drawing.drawText("30ms", w - 240 + 2, h - 30 - 14, 0xffE0E0E0);
|
||||
Drawing.drawText("60ms", w - 240 + 2, h - 60 - 14, 0xffE0E0E0);
|
||||
Drawing.drawTextRight("ms/Tick", w - 2, h - 60 - 14, 0xffE0E0E0);
|
||||
}
|
||||
|
||||
// GlState.enableDepth();
|
||||
}
|
||||
|
||||
public void showDirDialog(final String title, final String def, final FileCallback callback) {
|
||||
new Thread(new Runnable() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue