Made GuiNumberInput a subclass of GuiAdvancedTextField and removed unneccessary IDs from Constructor and GuiConstants

This commit is contained in:
CrushedPixel
2015-07-08 11:54:47 +02:00
parent 8a973fa3e9
commit 54f35eca03
8 changed files with 122 additions and 43 deletions

View File

@@ -15,7 +15,6 @@ public class GuiConstants {
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011; public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012; public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012;
public static final int CENTER_SEARCH_ACTION_BUTTON = 2013; public static final int CENTER_SEARCH_ACTION_BUTTON = 2013;
public static final int CENTER_SEARCH_GAMETYPE_ENABLE = 2014;
public static final int CENTER_SEARCH_GAMETYPE_TOGGLE = 2015; public static final int CENTER_SEARCH_GAMETYPE_TOGGLE = 2015;
public static final int CENTER_SEARCH_ORDER_TOGGLE = 2016; public static final int CENTER_SEARCH_ORDER_TOGGLE = 2016;
public static final int CENTER_SEARCH_CATEGORY_DROPDOWN = 2017; public static final int CENTER_SEARCH_CATEGORY_DROPDOWN = 2017;
@@ -61,7 +60,6 @@ public class GuiConstants {
public static final int REPLAY_EDITOR_REMOVE_BUTTON = 5008; public static final int REPLAY_EDITOR_REMOVE_BUTTON = 5008;
public static final int REPLAY_EDITOR_ADD_BUTTON = 5009; public static final int REPLAY_EDITOR_ADD_BUTTON = 5009;
public static final int KEYFRAME_REPOSITORY_LIST = 1234;
public static final int KEYFRAME_REPOSTORY_NAME_INPUT = 2345; public static final int KEYFRAME_REPOSTORY_NAME_INPUT = 2345;
public static final int KEYFRAME_REPOSITORY_ADD_BUTTON = 3456; public static final int KEYFRAME_REPOSITORY_ADD_BUTTON = 3456;
public static final int KEYFRAME_REPOSITORY_REMOVE_BUTTON = 4567; public static final int KEYFRAME_REPOSITORY_REMOVE_BUTTON = 4567;
@@ -71,14 +69,6 @@ public class GuiConstants {
public static final int KEYFRAME_EDITOR_CANCEL_BUTTON = 6001; public static final int KEYFRAME_EDITOR_CANCEL_BUTTON = 6001;
public static final int KEYFRAME_EDITOR_RIGHT_BUTTON = 6002; public static final int KEYFRAME_EDITOR_RIGHT_BUTTON = 6002;
public static final int KEYFRAME_EDITOR_LEFT_BUTTON = 6003; public static final int KEYFRAME_EDITOR_LEFT_BUTTON = 6003;
public static final int KEYFRAME_EDITOR_X_INPUT = 6004;
public static final int KEYFRAME_EDITOR_Y_INPUT = 6005;
public static final int KEYFRAME_EDITOR_Z_INPUT = 6006;
public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007;
public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008;
public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009;
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014;
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010; public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
public static final int PLAYER_OVERVIEW_SHOW_ALL = 101; public static final int PLAYER_OVERVIEW_SHOW_ALL = 101;
@@ -88,12 +78,9 @@ public class GuiConstants {
public static final int RENDER_SETTINGS_RENDER_BUTTON = 9002; public static final int RENDER_SETTINGS_RENDER_BUTTON = 9002;
public static final int RENDER_SETTINGS_CANCEL_BUTTON = 9003; public static final int RENDER_SETTINGS_CANCEL_BUTTON = 9003;
public static final int RENDER_SETTINGS_RESOLUTION_CHECKBOX = 9004; public static final int RENDER_SETTINGS_RESOLUTION_CHECKBOX = 9004;
public static final int RENDER_SETTINGS_RESOLUTION_X = 9005;
public static final int RENDER_SETTINGS_RESOLUTION_Y = 9006;
public static final int RENDER_SETTINGS_INTERPOLATION_BUTTON = 9007; public static final int RENDER_SETTINGS_INTERPOLATION_BUTTON = 9007;
public static final int RENDER_SETTINGS_FORCECHUNKS_BUTTON = 9008; public static final int RENDER_SETTINGS_FORCECHUNKS_BUTTON = 9008;
public static final int RENDER_SETTINGS_FRAMERATE_SLIDER = 9009; public static final int RENDER_SETTINGS_FRAMERATE_SLIDER = 9009;
public static final int RENDER_SETTINGS_BITRATE_INPUT = 9010;
public static final int RENDER_SETTINGS_STATIC_CAMERA = 9012; public static final int RENDER_SETTINGS_STATIC_CAMERA = 9012;
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013; public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014; public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
@@ -110,6 +97,4 @@ public class GuiConstants {
public static final int REPLAY_EDITING_CANCEL_BUTTON = 1234; public static final int REPLAY_EDITING_CANCEL_BUTTON = 1234;
public static final int REPLAY_DOWNLOADING_CANCEL_BUTTON = 2345; public static final int REPLAY_DOWNLOADING_CANCEL_BUTTON = 2345;
public static final int ASSET_ADDER_REMOVE_BUTTON = 10;
} }

View File

@@ -97,9 +97,9 @@ public class GuiEditKeyframe extends GuiScreen {
//Real Time Input //Real Time Input
int timestamp = keyframe.getRealTimestamp(); int timestamp = keyframe.getRealTimestamp();
min = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_MIN_INPUT, fontRendererObj, 0, 0, 30, 0, 9, TimestampUtils.getMinutesFromTimestamp(timestamp), false); min = new GuiNumberInput(fontRendererObj, 0, 0, 30, 0, 9, TimestampUtils.getMinutesFromTimestamp(timestamp), false);
sec = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 25, 0, 59, TimestampUtils.getSecondsFromTimestamp(timestamp), false); sec = new GuiNumberInput(fontRendererObj, 0, 0, 25, 0, 59, TimestampUtils.getSecondsFromTimestamp(timestamp), false);
ms = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 35, 0, 999, TimestampUtils.getMillisecondsFromTimestamp(timestamp), false); ms = new GuiNumberInput(fontRendererObj, 0, 0, 35, 0, 999, TimestampUtils.getMillisecondsFromTimestamp(timestamp), false);
inputs.add(min); inputs.add(min);
inputs.add(sec); inputs.add(sec);
@@ -108,12 +108,12 @@ public class GuiEditKeyframe extends GuiScreen {
//Position/Virtual Time Input //Position/Virtual Time Input
if(posKeyframe) { if(posKeyframe) {
Position pos = ((Keyframe<Position>)keyframe).getValue(); Position pos = ((Keyframe<Position>)keyframe).getValue();
xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getX()), true); xCoord = new GuiNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getX()), true);
yCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Y_INPUT, fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getY()), true); yCoord = new GuiNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getY()), true);
zCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Z_INPUT, fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getZ()), true); zCoord = new GuiNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getZ()), true);
yaw = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_YAW_INPUT, fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round(pos.getYaw()), true); yaw = new GuiNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round(pos.getYaw()), true);
pitch = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_PITCH_INPUT, fontRendererObj, 0, 0, 100, -180d, 180d, RoundUtils.round(pos.getPitch()), true); pitch = new GuiNumberInput(fontRendererObj, 0, 0, 100, -180d, 180d, RoundUtils.round(pos.getPitch()), true);
roll = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_ROLL_INPUT, fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getRoll()), true); roll = new GuiNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getRoll()), true);
posInputs.add(xCoord); posInputs.add(xCoord);
posInputs.add(yCoord); posInputs.add(yCoord);

View File

@@ -0,0 +1,45 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.gui.GuiScreen;
import java.io.IOException;
public class GuiObjectManager extends GuiScreen {
private boolean initialized = false;
@Override
public void initGui() {
super.initGui();
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
}
@Override
public void updateScreen() {
super.updateScreen();
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
}
}

View File

@@ -71,7 +71,7 @@ public class GuiRenderSettings extends GuiScreen {
customResolution = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX, 0, 0, I18n.format("replaymod.gui.rendersettings.customresolution"), false); customResolution = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX, 0, 0, I18n.format("replaymod.gui.rendersettings.customresolution"), false);
xRes = new GuiNumberInput(GuiConstants.RENDER_SETTINGS_RESOLUTION_X, fontRendererObj, 0, 0, 50, 1, 100000, mc.displayWidth, false) { xRes = new GuiNumberInput(fontRendererObj, 0, 0, 50, 1, 100000, mc.displayWidth, false) {
@Override @Override
public void moveCursorBy(int move) { public void moveCursorBy(int move) {
super.moveCursorBy(move); super.moveCursorBy(move);
@@ -88,7 +88,7 @@ public class GuiRenderSettings extends GuiScreen {
yRes.setCursorPositionEnd(); yRes.setCursorPositionEnd();
} }
}; };
yRes = new GuiNumberInput(GuiConstants.RENDER_SETTINGS_RESOLUTION_Y, fontRendererObj, 0, 0, 50, 1, 10000, mc.displayHeight, false) { yRes = new GuiNumberInput(fontRendererObj, 0, 0, 50, 1, 10000, mc.displayHeight, false) {
@Override @Override
public void moveCursorBy(int move) { public void moveCursorBy(int move) {
super.moveCursorBy(move); super.moveCursorBy(move);
@@ -106,7 +106,7 @@ public class GuiRenderSettings extends GuiScreen {
} }
}; };
bitrateInput = new GuiNumberInputWithText(GuiConstants.RENDER_SETTINGS_BITRATE_INPUT, fontRendererObj, 0, 0, 50, 1D, null, 10000D, false, " kbps"); bitrateInput = new GuiNumberInputWithText(fontRendererObj, 0, 0, 50, 1D, null, 10000D, false, " kbps");
xRes.setEnabled(false); xRes.setEnabled(false);
yRes.setEnabled(false); yRes.setEnabled(false);

View File

@@ -0,0 +1,50 @@
package eu.crushedpixel.replaymod.gui.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public class GuiDraggingNumberInput extends GuiNumberInput {
public GuiDraggingNumberInput(FontRenderer fontRenderer,
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue, boolean acceptFloats) {
super(fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats);
}
private int prevMouseX;
private boolean dragging;
@Override
public void mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
dragging = false;
prevMouseX = mouseX;
}
@Override
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
if(mouseX != prevMouseX) {
dragging = true;
int diff = mouseX - prevMouseX;
prevMouseX = mouseX;
int bounds = 100;
if(minimum != null && maximum != null) {
bounds = (int)(maximum-minimum);
}
double value = getPreciseValue();
double valueDiff = (diff/200) * bounds;
this.setValue(value+valueDiff);
}
super.mouseDrag(mc, mouseX, mouseY, button);
}
@Override
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
if(!dragging) {
super.mouseClick(mc, mouseX, mouseY, button);
}
super.mouseRelease(mc, mouseX, mouseY, button);
}
}

View File

@@ -1,17 +1,16 @@
package eu.crushedpixel.replaymod.gui.elements; package eu.crushedpixel.replaymod.gui.elements;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class GuiNumberInput extends GuiTextField { public class GuiNumberInput extends GuiAdvancedTextField {
private Double minimum, maximum; protected Double minimum, maximum;
private boolean acceptFloats = false; protected boolean acceptFloats = false;
public GuiNumberInput(int id, FontRenderer fontRenderer, public GuiNumberInput(FontRenderer fontRenderer,
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue, boolean acceptFloats) { int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue, boolean acceptFloats) {
super(id, fontRenderer, xPos, yPos, width, 20); super(fontRenderer, xPos, yPos, width, 20);
this.minimum = minimum; this.minimum = minimum;
this.maximum = maximum; this.maximum = maximum;
this.acceptFloats = acceptFloats; this.acceptFloats = acceptFloats;
@@ -21,9 +20,9 @@ public class GuiNumberInput extends GuiTextField {
} }
} }
public GuiNumberInput(int id, FontRenderer fontRenderer, public GuiNumberInput(FontRenderer fontRenderer,
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) { int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats); this(fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
} }
public void setValue(double value) { public void setValue(double value) {

View File

@@ -9,11 +9,11 @@ public class GuiNumberInputWithText extends GuiNumberInput {
private String suffix; private String suffix;
public GuiNumberInputWithText(int id, FontRenderer fontRenderer, public GuiNumberInputWithText(FontRenderer fontRenderer,
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue, int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue,
boolean acceptFloats, String suffix) { boolean acceptFloats, String suffix) {
super(id, fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats); super(fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats);
if(suffix == null) suffix = ""; if(suffix == null) suffix = "";
this.suffix = suffix; this.suffix = suffix;

View File

@@ -96,13 +96,13 @@ public class GuiTrimPart extends GuiStudioPart {
@Override @Override
public void initGui() { public void initGui() {
if(!initialized) { if(!initialized) {
startMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos, 30, null, 999d, null, false); startMinInput = new GuiNumberInput(fontRendererObj, 70, yPos, 30, null, 999d, null, false);
startSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos, 25, null, 99d, null, false); startSecInput = new GuiNumberInput(fontRendererObj, 120, yPos, 25, null, 99d, null, false);
startMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos, 30, null, 999d, null, false); startMsInput = new GuiNumberInput(fontRendererObj, 165, yPos, 30, null, 999d, null, false);
endMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos + 30, 30, null, 999d, null, false); endMinInput = new GuiNumberInput(fontRendererObj, 70, yPos + 30, 30, null, 999d, null, false);
endSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos + 30, 25, null, 99d, null, false); endSecInput = new GuiNumberInput(fontRendererObj, 120, yPos + 30, 25, null, 99d, null, false);
endMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos + 30, 30, null, 999d, null, false); endMsInput = new GuiNumberInput(fontRendererObj, 165, yPos + 30, 30, null, 999d, null, false);
inputOrder.clear(); inputOrder.clear();