GuiAssetAdder now allows to add/remove/edit Assets in a Replay. These Assets are not being saved yet.
This commit is contained in:
@@ -1,20 +1,24 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
package eu.crushedpixel.replaymod.gui;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiAdvancedTextField;
|
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiEntryList;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiFileChooser;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
||||||
|
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||||
import eu.crushedpixel.replaymod.holders.CustomImageObject;
|
import eu.crushedpixel.replaymod.holders.CustomImageObject;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Position;
|
||||||
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiAssetAdder extends GuiScreen {
|
public class GuiAssetAdder extends GuiScreen {
|
||||||
|
|
||||||
@@ -32,6 +36,8 @@ public class GuiAssetAdder extends GuiScreen {
|
|||||||
private GuiNumberInput xInput, yInput, zInput, yawInput, pitchInput, rollInput, scaleInput;
|
private GuiNumberInput xInput, yInput, zInput, yawInput, pitchInput, rollInput, scaleInput;
|
||||||
private GuiCheckBox backVisibleCheckBox;
|
private GuiCheckBox backVisibleCheckBox;
|
||||||
|
|
||||||
|
private List<GuiTextField> textFields = new ArrayList<GuiTextField>();
|
||||||
|
|
||||||
public GuiAssetAdder() {
|
public GuiAssetAdder() {
|
||||||
ReplayMod.replaySender.setReplaySpeed(0);
|
ReplayMod.replaySender.setReplaySpeed(0);
|
||||||
}
|
}
|
||||||
@@ -42,6 +48,12 @@ public class GuiAssetAdder extends GuiScreen {
|
|||||||
screenTitle = I18n.format("replaymod.gui.assets.title");
|
screenTitle = I18n.format("replaymod.gui.assets.title");
|
||||||
|
|
||||||
objectList = new GuiEntryList<CustomImageObject>(0, fontRendererObj, 0, 0, 0, 0);
|
objectList = new GuiEntryList<CustomImageObject>(0, fontRendererObj, 0, 0, 0, 0);
|
||||||
|
objectList.setEmptyMessage(I18n.format("replaymod.gui.assets.emptylist"));
|
||||||
|
|
||||||
|
for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
||||||
|
objectList.addElement(object);
|
||||||
|
}
|
||||||
|
|
||||||
removeButton = new GuiButton(GuiConstants.ASSET_ADDER_REMOVE_BUTTON, 0, 0, I18n.format("replaymod.gui.remove"));
|
removeButton = new GuiButton(GuiConstants.ASSET_ADDER_REMOVE_BUTTON, 0, 0, I18n.format("replaymod.gui.remove"));
|
||||||
|
|
||||||
addButton = new GuiFileChooser(1, 0, 0, I18n.format("replaymod.gui.add"), null, ImageIO.getReaderFileSuffixes()) {
|
addButton = new GuiFileChooser(1, 0, 0, I18n.format("replaymod.gui.add"), null, ImageIO.getReaderFileSuffixes()) {
|
||||||
@@ -51,16 +63,89 @@ public class GuiAssetAdder extends GuiScreen {
|
|||||||
addButton.registerListener(new FileChooseListener() {
|
addButton.registerListener(new FileChooseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFileChosen(File file) {
|
public void onFileChosen(File file) {
|
||||||
|
try {
|
||||||
|
objectList.addElement(new CustomImageObject(new Position(mc.getRenderViewEntity()),
|
||||||
|
I18n.format("replaymod.gui.assets.defaultname"), file, true));
|
||||||
|
} catch(IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
guiFileChooser = new GuiFileChooser(2, 0, 0, I18n.format("replaymod.gui.assets.filechooser")+": ", null, ImageIO.getReaderFileSuffixes());
|
nameInput = new GuiAdvancedTextField(fontRendererObj, 2, 0, 0, 20);
|
||||||
|
nameInput.hint = I18n.format("replaymod.gui.assets.namehint");
|
||||||
|
|
||||||
|
xInput = new GuiNumberInput(3, fontRendererObj, 0, 0, 0, null, null, 0d, true);
|
||||||
|
yInput = new GuiNumberInput(4, fontRendererObj, 0, 0, 0, null, null, 0d, true);
|
||||||
|
zInput = new GuiNumberInput(5, fontRendererObj, 0, 0, 0, null, null, 0d, true);
|
||||||
|
|
||||||
|
yawInput = new GuiNumberInput(6, fontRendererObj, 0, 0, 0, -360d, 360d, 0d, true);
|
||||||
|
pitchInput = new GuiNumberInput(7, fontRendererObj, 0, 0, 0, -360d, 360d, 0d, true);
|
||||||
|
rollInput = new GuiNumberInput(8, fontRendererObj, 0, 0, 0, -360d, 360d, 0d, true);
|
||||||
|
|
||||||
|
scaleInput = new GuiNumberInputWithText(9, fontRendererObj, 0, 0, 0, 0d, 10000d, 100d, true, "%");
|
||||||
|
backVisibleCheckBox = new GuiCheckBox(10, 0, 0, I18n.format("replaymod.gui.assets.backvisible"), true);
|
||||||
|
|
||||||
|
guiFileChooser = new GuiFileChooser(3, 0, 0, I18n.format("replaymod.gui.assets.filechooser")+": ", null, ImageIO.getReaderFileSuffixes());
|
||||||
|
guiFileChooser.registerListener(new FileChooseListener() {
|
||||||
|
@Override
|
||||||
|
public void onFileChosen(File file) {
|
||||||
|
try {
|
||||||
|
objectList.getElement(objectList.getSelectionIndex()).setImageFile(file);
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
guiFileChooser.enabled = false;
|
||||||
|
|
||||||
|
textFields.add(objectList);
|
||||||
|
textFields.add(nameInput);
|
||||||
|
textFields.add(xInput);
|
||||||
|
textFields.add(yInput);
|
||||||
|
textFields.add(zInput);
|
||||||
|
textFields.add(pitchInput);
|
||||||
|
textFields.add(yawInput);
|
||||||
|
textFields.add(rollInput);
|
||||||
|
textFields.add(scaleInput);
|
||||||
|
|
||||||
|
objectList.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onSelectionChanged(int selectionIndex) {
|
||||||
|
CustomImageObject object = objectList.getElement(selectionIndex);
|
||||||
|
if(object == null) {
|
||||||
|
guiFileChooser.enabled = false;
|
||||||
|
for(GuiTextField tf : textFields) {
|
||||||
|
tf.setEnabled(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
guiFileChooser.enabled = true;
|
||||||
|
for(GuiTextField tf : textFields) {
|
||||||
|
tf.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
nameInput.setText(object.getName());
|
||||||
|
guiFileChooser.setSelectedFile(object.getImageFile());
|
||||||
|
xInput.setValue(object.getPosition().getX());
|
||||||
|
yInput.setValue(object.getPosition().getY());
|
||||||
|
zInput.setValue(object.getPosition().getZ());
|
||||||
|
pitchInput.setValue(object.getPosition().getPitch());
|
||||||
|
yawInput.setValue(object.getPosition().getYaw());
|
||||||
|
rollInput.setValue(object.getPosition().getRoll());
|
||||||
|
scaleInput.setValue(object.getPosition().getScale()*100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(objectList.getEntryCount() > 0) {
|
||||||
|
objectList.setSelectionIndex(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int h = (int)Math.floor(((double)this.height-(45+20+15+20))/14);
|
int h = (int)Math.floor(((double)this.height-(45+20+15+20))/14);
|
||||||
|
|
||||||
objectList.width = guiFileChooser.width = 150;
|
objectList.width = guiFileChooser.width = nameInput.width = 150;
|
||||||
objectList.xPosition = width/2 - objectList.width - 5;
|
objectList.xPosition = width/2 - objectList.width - 5;
|
||||||
objectList.setVisibleElements(h);
|
objectList.setVisibleElements(h);
|
||||||
objectList.yPosition = 45;
|
objectList.yPosition = 45;
|
||||||
@@ -70,8 +155,21 @@ public class GuiAssetAdder extends GuiScreen {
|
|||||||
removeButton.xPosition = addButton.xPosition+addButton.width;
|
removeButton.xPosition = addButton.xPosition+addButton.width;
|
||||||
addButton.yPosition = removeButton.yPosition = objectList.yPosition + objectList.height + 2;
|
addButton.yPosition = removeButton.yPosition = objectList.yPosition + objectList.height + 2;
|
||||||
|
|
||||||
|
nameInput.xPosition = this.width/2 + 5;
|
||||||
|
nameInput.yPosition = 45;
|
||||||
|
|
||||||
guiFileChooser.xPosition = this.width/2 + 5;
|
guiFileChooser.xPosition = this.width/2 + 5;
|
||||||
guiFileChooser.yPosition = 45;
|
guiFileChooser.yPosition = nameInput.yPosition + 20 + 5;
|
||||||
|
|
||||||
|
xInput.yPosition = yInput.yPosition = zInput.yPosition = guiFileChooser.yPosition + 20 + 5 + 15;
|
||||||
|
yawInput.yPosition = pitchInput.yPosition = rollInput.yPosition = xInput.yPosition + 20 + 5 + 15;
|
||||||
|
scaleInput.yPosition = yawInput.yPosition + 20 + 5 + 15;
|
||||||
|
|
||||||
|
xInput.xPosition = scaleInput.xPosition = pitchInput.xPosition = this.width/2 + 8;
|
||||||
|
yInput.xPosition = yawInput.xPosition = xInput.xPosition + 50;
|
||||||
|
zInput.xPosition = rollInput.xPosition = yInput.xPosition + 50;
|
||||||
|
|
||||||
|
xInput.width = yInput.width = zInput.width = yawInput.width = pitchInput.width = rollInput.width = scaleInput.width = 43;
|
||||||
|
|
||||||
buttonList.add(removeButton);
|
buttonList.add(removeButton);
|
||||||
buttonList.add(addButton);
|
buttonList.add(addButton);
|
||||||
@@ -89,13 +187,74 @@ public class GuiAssetAdder extends GuiScreen {
|
|||||||
|
|
||||||
drawGradientRect(leftBorder, topBorder, width - leftBorder, this.height - 10, -1072689136, -804253680);
|
drawGradientRect(leftBorder, topBorder, width - leftBorder, this.height - 10, -1072689136, -804253680);
|
||||||
|
|
||||||
objectList.drawTextBox();
|
for(GuiTextField textField : textFields) {
|
||||||
|
textField.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCenteredString(fontRendererObj, "X", xInput.xPosition + (xInput.width/2), xInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
drawCenteredString(fontRendererObj, "Y", yInput.xPosition + (yInput.width/2), yInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
drawCenteredString(fontRendererObj, "Z", zInput.xPosition + (zInput.width/2), zInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
drawCenteredString(fontRendererObj, "Yaw", yawInput.xPosition + (yawInput.width/2), yawInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
drawCenteredString(fontRendererObj, "Pitch", pitchInput.xPosition + (pitchInput.width/2), pitchInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
drawCenteredString(fontRendererObj, "Roll", rollInput.xPosition + (rollInput.width/2), rollInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
drawCenteredString(fontRendererObj, "Scale", scaleInput.xPosition + (scaleInput.width/2), scaleInput.yPosition - 12, Color.WHITE.getRGB());
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
super.updateScreen();
|
for(GuiTextField textField : textFields) {
|
||||||
|
textField.updateCursorCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
|
for(GuiTextField textField : textFields) {
|
||||||
|
textField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||||
|
for(GuiTextField textField : textFields) {
|
||||||
|
textField.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
super.keyTyped(typedChar, keyCode);
|
||||||
|
|
||||||
|
if(guiFileChooser.enabled) {
|
||||||
|
CustomImageObject current = objectList.getElement(objectList.getSelectionIndex());
|
||||||
|
if(current == null) return;
|
||||||
|
|
||||||
|
current.setName(nameInput.getText().trim());
|
||||||
|
current.getPosition().setX(xInput.getPreciseValue());
|
||||||
|
current.getPosition().setY(yInput.getPreciseValue());
|
||||||
|
current.getPosition().setZ(zInput.getPreciseValue());
|
||||||
|
current.getPosition().setPitch((float) pitchInput.getPreciseValue());
|
||||||
|
current.getPosition().setYaw((float) yawInput.getPreciseValue());
|
||||||
|
current.getPosition().setRoll((float) rollInput.getPreciseValue());
|
||||||
|
current.getPosition().setScale((float)scaleInput.getPreciseValue()/100f);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
ReplayHandler.setCustomImageObjects(objectList.getCopyOfElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
if(!button.enabled) return;
|
||||||
|
|
||||||
|
if(button.id == GuiConstants.ASSET_ADDER_REMOVE_BUTTON) {
|
||||||
|
CustomImageObject current = objectList.getElement(objectList.getSelectionIndex());
|
||||||
|
if(current == null) return;
|
||||||
|
|
||||||
|
objectList.removeElement(objectList.getSelectionIndex());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import eu.crushedpixel.replaymod.gui.elements.GuiArrowButton;
|
|||||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
||||||
import eu.crushedpixel.replaymod.holders.*;
|
import eu.crushedpixel.replaymod.holders.*;
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
|
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
||||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@@ -113,12 +114,12 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
//Position/Virtual Time Input
|
//Position/Virtual Time Input
|
||||||
if(posKeyframe) {
|
if(posKeyframe) {
|
||||||
Position pos = ((PositionKeyframe)keyframe).getPosition();
|
Position pos = ((PositionKeyframe)keyframe).getPosition();
|
||||||
xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getX()), true);
|
xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, 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, round(pos.getY()), true);
|
yCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Y_INPUT, 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, round(pos.getZ()), true);
|
zCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Z_INPUT, 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, round(pos.getYaw()), true);
|
yaw = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_YAW_INPUT, 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, round(pos.getPitch()), true);
|
pitch = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_PITCH_INPUT, 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, round(pos.getRoll()), true);
|
roll = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_ROLL_INPUT, fontRendererObj, 0, 0, 100, null, null, RoundUtils.round(pos.getRoll()), true);
|
||||||
|
|
||||||
posInputs.add(xCoord);
|
posInputs.add(xCoord);
|
||||||
posInputs.add(yCoord);
|
posInputs.add(yCoord);
|
||||||
@@ -267,10 +268,6 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double round(double val) {
|
|
||||||
return Math.round(val*100.0) / 100.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
if(!button.enabled) return;
|
if(!button.enabled) return;
|
||||||
|
|||||||
@@ -106,18 +106,7 @@ public class GuiRenderSettings extends GuiScreen {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bitrateInput = new GuiNumberInput(GuiConstants.RENDER_SETTINGS_BITRATE_INPUT, fontRendererObj, 0, 0, 50, 1D, null, 10000D, false) {
|
bitrateInput = new GuiNumberInputWithText(GuiConstants.RENDER_SETTINGS_BITRATE_INPUT, fontRendererObj, 0, 0, 50, 1D, null, 10000D, false, " kbps");
|
||||||
@Override
|
|
||||||
public void drawTextBox() {
|
|
||||||
int index = getCursorPosition();
|
|
||||||
String textBefore = getText();
|
|
||||||
setText(textBefore+" kbps");
|
|
||||||
setCursorPosition(index);
|
|
||||||
super.drawTextBox();
|
|
||||||
setText(textBefore);
|
|
||||||
setCursorPosition(index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
xRes.setEnabled(false);
|
xRes.setEnabled(false);
|
||||||
yRes.setEnabled(false);
|
yRes.setEnabled(false);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class GuiAdvancedTextField extends GuiTextField implements GuiElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTextBox() {
|
public void drawTextBox() {
|
||||||
if (text.isEmpty() && !isFocused()) {
|
if (text.isEmpty() && !isFocused() && hint.length() > 0) {
|
||||||
super.setEnabled(false);
|
super.setEnabled(false);
|
||||||
super.setDisabledTextColour(hintTextColor);
|
super.setDisabledTextColour(hintTextColor);
|
||||||
text = hint;
|
text = hint;
|
||||||
|
|||||||
@@ -120,10 +120,10 @@ public class GuiEntryList<T extends GuiEntryListEntry> extends GuiTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addElement(T element) {
|
public void addElement(T element) {
|
||||||
|
if(element == null) return;
|
||||||
this.elements.add(element);
|
this.elements.add(element);
|
||||||
if(selectionIndex == -1) {
|
selectionIndex = elements.size()-1;
|
||||||
selectionIndex = 0;
|
fireSelectionChangeEvent();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getElement(int index) {
|
public T getElement(int index) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.gui.elements;
|
|||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
|
||||||
@@ -15,9 +14,13 @@ import java.util.List;
|
|||||||
public class GuiFileChooser extends GuiButton {
|
public class GuiFileChooser extends GuiButton {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
private File selectedFile;
|
private File selectedFile;
|
||||||
|
|
||||||
|
public void setSelectedFile(File selectedFile) {
|
||||||
|
this.selectedFile = selectedFile;
|
||||||
|
updateDisplayString();
|
||||||
|
}
|
||||||
|
|
||||||
private String baseString;
|
private String baseString;
|
||||||
|
|
||||||
private String[] allowedExtensions = null;
|
private String[] allowedExtensions = null;
|
||||||
@@ -70,8 +73,9 @@ public class GuiFileChooser extends GuiButton {
|
|||||||
fileDialog.setVisible(true);
|
fileDialog.setVisible(true);
|
||||||
|
|
||||||
String filename = fileDialog.getFile();
|
String filename = fileDialog.getFile();
|
||||||
|
String directory = fileDialog.getDirectory();
|
||||||
if(filename != null) {
|
if(filename != null) {
|
||||||
selectedFile = new File(filename);
|
selectedFile = new File(directory, filename);
|
||||||
|
|
||||||
updateDisplayString();
|
updateDisplayString();
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,9 @@ public class GuiNumberInput extends GuiTextField {
|
|||||||
this.minimum = minimum;
|
this.minimum = minimum;
|
||||||
this.maximum = maximum;
|
this.maximum = maximum;
|
||||||
this.acceptFloats = acceptFloats;
|
this.acceptFloats = acceptFloats;
|
||||||
|
setCursorPositionZero();
|
||||||
if(defaultValue != null) {
|
if(defaultValue != null) {
|
||||||
if(acceptFloats) {
|
setValue(defaultValue);
|
||||||
setText("" + defaultValue);
|
|
||||||
} else {
|
|
||||||
setText("" + (int)Math.round(defaultValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +26,15 @@ public class GuiNumberInput extends GuiTextField {
|
|||||||
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
|
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValue(double value) {
|
||||||
|
if(acceptFloats) {
|
||||||
|
setText("" + value);
|
||||||
|
} else {
|
||||||
|
setText("" + (int)Math.round(value));
|
||||||
|
}
|
||||||
|
setCursorPositionZero();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeText(String text) {
|
public void writeText(String text) {
|
||||||
String textBefore = getText();
|
String textBefore = getText();
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui.elements;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
|
||||||
|
public class GuiNumberInputWithText extends GuiNumberInput {
|
||||||
|
|
||||||
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
private String suffix;
|
||||||
|
|
||||||
|
public GuiNumberInputWithText(int id, FontRenderer fontRenderer,
|
||||||
|
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue,
|
||||||
|
boolean acceptFloats, String suffix) {
|
||||||
|
|
||||||
|
super(id, fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats);
|
||||||
|
if(suffix == null) suffix = "";
|
||||||
|
|
||||||
|
this.suffix = suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTextBox() {
|
||||||
|
int index = getCursorPosition();
|
||||||
|
String textBefore = getText();
|
||||||
|
setText(textBefore + suffix);
|
||||||
|
setCursorPosition(index);
|
||||||
|
super.drawTextBox();
|
||||||
|
setText(textBefore);
|
||||||
|
setCursorPosition(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||||
|
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -14,8 +15,25 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class CustomImageObject implements GuiEntryListEntry {
|
public class CustomImageObject implements GuiEntryListEntry {
|
||||||
|
|
||||||
public CustomImageObject(Position position, String name, File imageSource, boolean backVisible) throws IOException {
|
public CustomImageObject(Position position, String name, final File imageSource, boolean backVisible) throws IOException {
|
||||||
BufferedImage bufferedImage = ImageIO.read(imageSource);
|
|
||||||
|
this.position = new ExtendedPosition(RoundUtils.round(position.getX()), RoundUtils.round(position.getY()), RoundUtils.round(position.getZ()), 0, 0);
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.backVisible = backVisible;
|
||||||
|
|
||||||
|
setImageFile(imageSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter @Setter private ExtendedPosition position;
|
||||||
|
@Getter @Setter private String name;
|
||||||
|
@Getter @Setter private boolean backVisible;
|
||||||
|
@Getter private File imageFile;
|
||||||
|
|
||||||
|
public void setImageFile(final File imageSource) throws IOException {
|
||||||
|
this.imageFile = imageSource;
|
||||||
|
|
||||||
|
final BufferedImage bufferedImage = ImageIO.read(imageSource);
|
||||||
|
|
||||||
this.textureWidth = bufferedImage.getWidth();
|
this.textureWidth = bufferedImage.getWidth();
|
||||||
this.textureHeight = bufferedImage.getHeight();
|
this.textureHeight = bufferedImage.getHeight();
|
||||||
@@ -31,19 +49,18 @@ public class CustomImageObject implements GuiEntryListEntry {
|
|||||||
h = 1;
|
h = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.position = new ExtendedPosition(position.getX(), position.getY(), position.getZ(), w, h);
|
this.position.setWidth(w);
|
||||||
this.name = name;
|
this.position.setHeight(h);
|
||||||
|
|
||||||
this.resourceLocation = new ResourceLocation("customImages/"+imageSource.getAbsolutePath());
|
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
||||||
this.dynamicTexture = new DynamicTexture(bufferedImage);
|
@Override
|
||||||
|
public void run() {
|
||||||
this.backVisible = backVisible;
|
resourceLocation = new ResourceLocation("customImages/"+imageSource.getAbsolutePath());
|
||||||
|
dynamicTexture = new DynamicTexture(bufferedImage);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter @Setter private ExtendedPosition position;
|
|
||||||
@Getter @Setter private String name;
|
|
||||||
@Getter @Setter private boolean backVisible;
|
|
||||||
|
|
||||||
private ResourceLocation resourceLocation;
|
private ResourceLocation resourceLocation;
|
||||||
private DynamicTexture dynamicTexture;
|
private DynamicTexture dynamicTexture;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ package eu.crushedpixel.replaymod.holders;
|
|||||||
|
|
||||||
public interface GuiEntryListEntry {
|
public interface GuiEntryListEntry {
|
||||||
|
|
||||||
public String getDisplayString();
|
String getDisplayString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,12 @@ public class CustomObjectRenderer {
|
|||||||
renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
||||||
renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
||||||
|
|
||||||
renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
if(customImageObject.isBackVisible()) {
|
||||||
renderer.addVertexWithUV(minX, maxY, 0, 1, 0);
|
renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
||||||
renderer.addVertexWithUV(minX, minY, 0, 1, 1);
|
renderer.addVertexWithUV(minX, maxY, 0, 1, 0);
|
||||||
renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
renderer.addVertexWithUV(minX, minY, 0, 1, 1);
|
||||||
|
renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
renderer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
|
|||||||
@@ -744,4 +744,8 @@ public class ReplayHandler {
|
|||||||
public static void addCustomImageObject(CustomImageObject object) {
|
public static void addCustomImageObject(CustomImageObject object) {
|
||||||
customImageObjects.add(object);
|
customImageObjects.add(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setCustomImageObjects(List<CustomImageObject> objects) {
|
||||||
|
customImageObjects = objects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package eu.crushedpixel.replaymod.utils;
|
||||||
|
|
||||||
|
public class RoundUtils {
|
||||||
|
|
||||||
|
public static double round(double val) { return Math.round(val*100.0) / 100.0; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -359,4 +359,8 @@ replaymod.gui.clearcallback.message=This Callback can be disabled in the Replay
|
|||||||
|
|
||||||
#Asset Adder Gui
|
#Asset Adder Gui
|
||||||
replaymod.gui.assets.title=Asset Manager
|
replaymod.gui.assets.title=Asset Manager
|
||||||
replaymod.gui.assets.filechooser=Image File
|
replaymod.gui.assets.filechooser=Image File
|
||||||
|
replaymod.gui.assets.defaultname=New Asset
|
||||||
|
replaymod.gui.assets.emptylist=No Assets available
|
||||||
|
replaymod.gui.assets.namehint=Asset Name
|
||||||
|
replaymod.gui.assets.backvisible=Visible from behind
|
||||||
Reference in New Issue
Block a user