Created fully functional scrollable List GUI Element
Added GuiConnect Tab to Replay Studio
This commit is contained in:
@@ -12,7 +12,7 @@ import net.minecraft.client.gui.GuiTextField;
|
|||||||
|
|
||||||
public class GuiDropdown extends GuiTextField {
|
public class GuiDropdown extends GuiTextField {
|
||||||
|
|
||||||
private int selectionIndex = 0;
|
private int selectionIndex = -1;
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
|
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
@@ -30,8 +30,7 @@ public class GuiDropdown extends GuiTextField {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTextBox() {
|
public void drawTextBox() {
|
||||||
setCursorPositionZero();
|
if(elements.size() > selectionIndex && selectionIndex >= 0) {
|
||||||
if(elements.size() > selectionIndex) {
|
|
||||||
setText(mc.fontRendererObj.trimStringToWidth(
|
setText(mc.fontRendererObj.trimStringToWidth(
|
||||||
elements.get(selectionIndex).toString(), width-8));
|
elements.get(selectionIndex).toString(), width-8));
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +102,7 @@ public class GuiDropdown extends GuiTextField {
|
|||||||
float posPerc = ((float)upperIndex)/elements.size();
|
float posPerc = ((float)upperIndex)/elements.size();
|
||||||
int barY = (int)(posPerc*(requiredHeight-1));
|
int barY = (int)(posPerc*(requiredHeight-1));
|
||||||
|
|
||||||
drawRect(xPosition+width-3, yPosition+height+1+barY, xPosition+width, yPosition+height+2+barY+barHeight, -6250336);
|
drawRect(xPosition+width-3, yPosition+height+barY, xPosition+width, yPosition+height+2+barY+barHeight, -6250336);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,18 +136,26 @@ public class GuiDropdown extends GuiTextField {
|
|||||||
|
|
||||||
private void select(int index) {
|
private void select(int index) {
|
||||||
this.selectionIndex = index;
|
this.selectionIndex = index;
|
||||||
|
if(selectionIndex < 0) selectionIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElements(List<Object> elements) {
|
public void setElements(List<Object> elements) {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
|
if(selectionIndex == -1 && elements.size() > 0) {
|
||||||
|
selectionIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearElements() {
|
public void clearElements() {
|
||||||
this.elements = new ArrayList<Object>();
|
this.elements = new ArrayList<Object>();
|
||||||
|
selectionIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addElement(Object element) {
|
public void addElement(Object element) {
|
||||||
this.elements.add(element);
|
this.elements.add(element);
|
||||||
|
if(selectionIndex == -1) {
|
||||||
|
selectionIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getElement(int index) {
|
public Object getElement(int index) {
|
||||||
|
|||||||
121
src/main/java/eu/crushedpixel/replaymod/gui/GuiEntryList.java
Normal file
121
src/main/java/eu/crushedpixel/replaymod/gui/GuiEntryList.java
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
|
||||||
|
public class GuiEntryList extends GuiTextField {
|
||||||
|
|
||||||
|
private int selectionIndex = -1;
|
||||||
|
|
||||||
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
private int visibleElements;
|
||||||
|
public final static int elementHeight = 14;
|
||||||
|
|
||||||
|
private int upperIndex = 0;
|
||||||
|
|
||||||
|
public GuiEntryList(int id, FontRenderer fontRenderer,
|
||||||
|
int xPos, int yPos, int width, int visibleEntries) {
|
||||||
|
super(id, fontRenderer, xPos, yPos, width, elementHeight*visibleEntries-1);
|
||||||
|
this.visibleElements = visibleEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisibleElements(int rows) {
|
||||||
|
this.visibleElements = rows;
|
||||||
|
this.height = elementHeight*visibleElements-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTextBox() {
|
||||||
|
super.drawTextBox();
|
||||||
|
//drawing the entries
|
||||||
|
for(int i=0; i-upperIndex<visibleElements; i++) {
|
||||||
|
if(i<upperIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == selectionIndex) {
|
||||||
|
drawRect(xPosition, yPosition+(i-upperIndex)*elementHeight, xPosition+width,
|
||||||
|
yPosition+(i+1-upperIndex)*elementHeight-1, Color.GRAY.getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
drawRect(xPosition, yPosition+(i+1-upperIndex)*elementHeight-1, xPosition+width,
|
||||||
|
yPosition+(i+1-upperIndex)*elementHeight, -6250336);
|
||||||
|
drawString(mc.fontRendererObj, mc.fontRendererObj.trimStringToWidth(elements.get(i).toString(), width-4),
|
||||||
|
xPosition+2, yPosition+(i-upperIndex)*elementHeight+3, Color.WHITE.getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
//drawing the scroll bar
|
||||||
|
if(elements.size() > visibleElements) {
|
||||||
|
//handle scroll events
|
||||||
|
int dw = Mouse.getDWheel();
|
||||||
|
if(dw > 0) {
|
||||||
|
dw = -1;
|
||||||
|
} else if(dw < 0) {
|
||||||
|
dw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
upperIndex = Math.max(Math.min(upperIndex+dw, elements.size()-visibleElements), 0);
|
||||||
|
|
||||||
|
float visiblePerc = ((float)visibleElements)/elements.size();
|
||||||
|
int barHeight = (int)(visiblePerc*(height-1));
|
||||||
|
|
||||||
|
float posPerc = ((float)upperIndex)/elements.size();
|
||||||
|
int barY = (int)(posPerc*(height-1));
|
||||||
|
|
||||||
|
drawRect(xPosition+width-3, yPosition, xPosition+width, yPosition+height, Color.DARK_GRAY.getRGB());
|
||||||
|
drawRect(xPosition+width-3, yPosition+barY, xPosition+width, yPosition+1+barY+barHeight, -6250336);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
||||||
|
int clickedIndex = (int)Math.floor((yPos-yPosition) / elementHeight) + upperIndex;
|
||||||
|
if(clickedIndex < elements.size()) selectionIndex = clickedIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setText(String text) {}
|
||||||
|
|
||||||
|
private List<Object> elements = new ArrayList<Object>();
|
||||||
|
|
||||||
|
private void select(int index) {
|
||||||
|
this.selectionIndex = index;
|
||||||
|
if(selectionIndex < 0) selectionIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElements(List<Object> elements) {
|
||||||
|
this.elements = elements;
|
||||||
|
if(selectionIndex == -1 && elements.size() > 0) {
|
||||||
|
selectionIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearElements() {
|
||||||
|
this.elements = new ArrayList<Object>();
|
||||||
|
selectionIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addElement(Object element) {
|
||||||
|
this.elements.add(element);
|
||||||
|
if(selectionIndex == -1) {
|
||||||
|
selectionIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElement(int index) {
|
||||||
|
return elements.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectionIndex() {
|
||||||
|
return selectionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package eu.crushedpixel.replaymod.gui.replaystudio;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.gui.GuiEntryList;
|
||||||
|
|
||||||
|
public class GuiConnectPart extends GuiStudioPart {
|
||||||
|
|
||||||
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
private static final String DESCRIPTION = "Connects multiple Replays in the same order as the list.";
|
||||||
|
private static final String TITLE = "Connect Replays";
|
||||||
|
|
||||||
|
private boolean initialized = false;
|
||||||
|
|
||||||
|
private GuiEntryList concatList;
|
||||||
|
|
||||||
|
public GuiConnectPart(int yPos) {
|
||||||
|
super(yPos);
|
||||||
|
fontRendererObj = mc.fontRendererObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyFilters() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
if(!initialized) {
|
||||||
|
concatList = new GuiEntryList(1, fontRendererObj, 30, yPos, 200, 0);
|
||||||
|
concatList.addElement(FilenameUtils.getBaseName(GuiReplayStudio.instance.getSelectedFile().getAbsolutePath()));
|
||||||
|
|
||||||
|
concatList.addElement("test1");
|
||||||
|
concatList.addElement("test2");
|
||||||
|
concatList.addElement("test3");
|
||||||
|
concatList.addElement("test4");
|
||||||
|
concatList.addElement("test5");
|
||||||
|
concatList.addElement("test6");
|
||||||
|
concatList.addElement("test7");
|
||||||
|
concatList.addElement("test8");
|
||||||
|
concatList.addElement("test9");
|
||||||
|
concatList.addElement("test10");
|
||||||
|
concatList.addElement("test11");
|
||||||
|
}
|
||||||
|
int h = GuiReplayStudio.instance.height-yPos-20;
|
||||||
|
int rows = (int)(h / (float)GuiEntryList.elementHeight);
|
||||||
|
concatList.setVisibleElements(rows);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
|
concatList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
concatList.drawTextBox();
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
if(!initialized) initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(char typedChar, int keyCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,22 +18,30 @@ import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|||||||
|
|
||||||
public class GuiReplayStudio extends GuiScreen {
|
public class GuiReplayStudio extends GuiScreen {
|
||||||
|
|
||||||
|
public static GuiReplayStudio instance = null;
|
||||||
|
|
||||||
|
private static final int tabYPos = 110;
|
||||||
|
|
||||||
private enum StudioTab {
|
private enum StudioTab {
|
||||||
TRIM(new GuiTrimPart(110)), CONNECT(null), MODIFY(null);
|
TRIM(new GuiTrimPart(tabYPos)), CONNECT(new GuiConnectPart(tabYPos)), MODIFY(new GuiConnectPart(tabYPos));
|
||||||
|
|
||||||
private GuiStudioPart studioPart;
|
private GuiStudioPart studioPart;
|
||||||
|
|
||||||
public GuiStudioPart getStudioPart() {
|
public GuiStudioPart getStudioPart() {
|
||||||
return studioPart;
|
return studioPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StudioTab(GuiStudioPart part) {
|
private StudioTab(GuiStudioPart part) {
|
||||||
this.studioPart = part;
|
this.studioPart = part;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GuiReplayStudio() {
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
private StudioTab currentTab = StudioTab.TRIM;
|
private StudioTab currentTab = StudioTab.TRIM;
|
||||||
|
|
||||||
private GuiDropdown replayDropdown;
|
private GuiDropdown replayDropdown;
|
||||||
private GuiButton saveModeButton, saveButton;
|
private GuiButton saveModeButton, saveButton;
|
||||||
|
|
||||||
@@ -43,6 +51,14 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
|
|
||||||
private List<File> replayFiles = new ArrayList<File>();
|
private List<File> replayFiles = new ArrayList<File>();
|
||||||
|
|
||||||
|
public File getSelectedFile() {
|
||||||
|
try {
|
||||||
|
return replayFiles.get(replayDropdown.getSelectionIndex());
|
||||||
|
} catch(ArrayIndexOutOfBoundsException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshReplayDropdown() {
|
private void refreshReplayDropdown() {
|
||||||
replayDropdown.clearElements();
|
replayDropdown.clearElements();
|
||||||
replayFiles = ReplayFileIO.getAllReplayFiles();
|
replayFiles = ReplayFileIO.getAllReplayFiles();
|
||||||
@@ -75,14 +91,14 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int modeWidth = tabButtons.get(0).width;
|
int modeWidth = tabButtons.get(0).width;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 15+2+1+80, 60, this.width-30-8-80-modeWidth-4);
|
replayDropdown = new GuiDropdown(1, fontRendererObj, 15+2+1+80, 60, this.width-30-8-80-modeWidth-4);
|
||||||
refreshReplayDropdown();
|
refreshReplayDropdown();
|
||||||
} else {
|
} else {
|
||||||
replayDropdown.width = this.width-30-8-80-modeWidth-4;
|
replayDropdown.width = this.width-30-8-80-modeWidth-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
saveModeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON, width-15-modeWidth-3, 60, getSaveModeLabel());
|
saveModeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON, width-15-modeWidth-3, 60, getSaveModeLabel());
|
||||||
} else {
|
} else {
|
||||||
@@ -91,15 +107,18 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
saveModeButton.width = modeWidth;
|
saveModeButton.width = modeWidth;
|
||||||
buttonList.add(saveModeButton);
|
buttonList.add(saveModeButton);
|
||||||
|
|
||||||
|
|
||||||
GuiButton backButton = new GuiButton(GuiConstants.REPLAY_EDITOR_BACK_BUTTON, width-70-18, height-20-5, "Back");
|
GuiButton backButton = new GuiButton(GuiConstants.REPLAY_EDITOR_BACK_BUTTON, width-70-18, height-20-5, "Back");
|
||||||
backButton.width = 70;
|
backButton.width = 70;
|
||||||
buttonList.add(backButton);
|
buttonList.add(backButton);
|
||||||
|
|
||||||
saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width-70-18, height-(2*20)-5-3, "Save");
|
saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width-70-18, height-(2*20)-5-3, "Save");
|
||||||
saveButton.width = 70;
|
saveButton.width = 70;
|
||||||
buttonList.add(saveButton);
|
buttonList.add(saveButton);
|
||||||
|
|
||||||
|
for(StudioTab tab : StudioTab.values()) {
|
||||||
|
tab.getStudioPart().initGui();
|
||||||
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
};
|
};
|
||||||
@@ -116,6 +135,12 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
button.displayString = getSaveModeLabel();
|
button.displayString = getSaveModeLabel();
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_BACK_BUTTON) {
|
} else if(button.id == GuiConstants.REPLAY_EDITOR_BACK_BUTTON) {
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
|
} else if(button.id == GuiConstants.REPLAY_EDITOR_TRIM_TAB) {
|
||||||
|
currentTab = StudioTab.TRIM;
|
||||||
|
} else if(button.id == GuiConstants.REPLAY_EDITOR_CONNECT_TAB) {
|
||||||
|
currentTab = StudioTab.CONNECT;
|
||||||
|
} else if(button.id == GuiConstants.REPLAY_EDITOR_MODIFY_TAB) {
|
||||||
|
currentTab = StudioTab.MODIFY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +157,8 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
drawDefaultBackground();
|
drawDefaultBackground();
|
||||||
currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks);
|
currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
drawCenteredString(fontRendererObj, currentTab.getStudioPart().getTitle(), width/2, 92, Color.WHITE.getRGB());
|
drawCenteredString(fontRendererObj, "§n"+currentTab.getStudioPart().getTitle(), width/2, 92, Color.WHITE.getRGB());
|
||||||
|
|
||||||
List<String> rows = new ArrayList<String>();
|
List<String> rows = new ArrayList<String>();
|
||||||
String remaining = currentTab.getStudioPart().getDescription();
|
String remaining = currentTab.getStudioPart().getDescription();
|
||||||
while(remaining.length() > 0) {
|
while(remaining.length() > 0) {
|
||||||
@@ -158,7 +183,7 @@ public class GuiReplayStudio extends GuiScreen {
|
|||||||
drawString(fontRendererObj, row, 30, height-(15*(rows.size()-i)), Color.WHITE.getRGB());
|
drawString(fontRendererObj, row, 30, height-(15*(rows.size()-i)), Color.WHITE.getRGB());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawCenteredString(fontRendererObj, "Replay Studio", this.width / 2, 10, 16777215);
|
drawCenteredString(fontRendererObj, "Replay Studio", this.width / 2, 10, 16777215);
|
||||||
drawString(fontRendererObj, "Replay File:", 30, 67, Color.WHITE.getRGB());
|
drawString(fontRendererObj, "Replay File:", 30, 67, Color.WHITE.getRGB());
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ package eu.crushedpixel.replaymod.gui.replaystudio;
|
|||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
||||||
public abstract class GuiStudioPart extends GuiScreen {
|
public abstract class GuiStudioPart extends GuiScreen {
|
||||||
|
|
||||||
|
public GuiStudioPart(int yPos) {
|
||||||
|
this.yPos = yPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int yPos = 0;
|
||||||
|
|
||||||
public abstract void applyFilters();
|
public abstract void applyFilters();
|
||||||
|
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
|
|||||||
@@ -12,11 +12,9 @@ import eu.crushedpixel.replaymod.gui.GuiNumberInput;
|
|||||||
|
|
||||||
public class GuiTrimPart extends GuiStudioPart {
|
public class GuiTrimPart extends GuiStudioPart {
|
||||||
|
|
||||||
private int yPos = 0;
|
|
||||||
|
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
private static final String DESCRIPTION = "Removes the beginning and end of a Replay File and only keeps the Replay between the given Timestamps";
|
private static final String DESCRIPTION = "Removes the beginning and end of a Replay File and only keeps the Replay between the given timestamps.";
|
||||||
private static final String TITLE = "Trim Replay";
|
private static final String TITLE = "Trim Replay";
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
@@ -27,15 +25,8 @@ public class GuiTrimPart extends GuiStudioPart {
|
|||||||
private List<GuiNumberInput> inputOrder = new ArrayList<GuiNumberInput>();
|
private List<GuiNumberInput> inputOrder = new ArrayList<GuiNumberInput>();
|
||||||
|
|
||||||
public GuiTrimPart(int yPos) {
|
public GuiTrimPart(int yPos) {
|
||||||
this.yPos = yPos;
|
super(yPos);
|
||||||
fontRendererObj = mc.fontRendererObj;
|
fontRendererObj = mc.fontRendererObj;
|
||||||
initGui();
|
|
||||||
inputOrder.add(startMinInput);
|
|
||||||
inputOrder.add(startSecInput);
|
|
||||||
inputOrder.add(startMsInput);
|
|
||||||
inputOrder.add(endMinInput);
|
|
||||||
inputOrder.add(endSecInput);
|
|
||||||
inputOrder.add(endMsInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,6 +34,30 @@ public class GuiTrimPart extends GuiStudioPart {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int valueOf(String text) {
|
||||||
|
try {
|
||||||
|
return Integer.valueOf(text);
|
||||||
|
} catch(NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getStartTimestamp() {
|
||||||
|
int mins = valueOf(startMinInput.getText());
|
||||||
|
int secs = valueOf(startSecInput.getText());
|
||||||
|
int ms = valueOf(startMsInput.getText());
|
||||||
|
|
||||||
|
return (mins*60*1000)+(secs*1000)+ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getEndTimestamp() {
|
||||||
|
int mins = valueOf(endMinInput.getText());
|
||||||
|
int secs = valueOf(endSecInput.getText());
|
||||||
|
int ms = valueOf(endMsInput.getText());
|
||||||
|
|
||||||
|
return (mins*60*1000)+(secs*1000)+ms;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return DESCRIPTION;
|
return DESCRIPTION;
|
||||||
@@ -63,6 +78,15 @@ public class GuiTrimPart extends GuiStudioPart {
|
|||||||
endMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos+30, 30, 3);
|
endMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos+30, 30, 3);
|
||||||
endSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos+30, 25, 2);
|
endSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos+30, 25, 2);
|
||||||
endMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos+30, 30, 3);
|
endMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos+30, 30, 3);
|
||||||
|
|
||||||
|
inputOrder.clear();
|
||||||
|
|
||||||
|
inputOrder.add(startMinInput);
|
||||||
|
inputOrder.add(startSecInput);
|
||||||
|
inputOrder.add(startMsInput);
|
||||||
|
inputOrder.add(endMinInput);
|
||||||
|
inputOrder.add(endSecInput);
|
||||||
|
inputOrder.add(endMsInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@@ -70,12 +94,9 @@ public class GuiTrimPart extends GuiStudioPart {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
startMinInput.mouseClicked(mouseX, mouseY, mouseButton);
|
for(GuiNumberInput input: inputOrder) {
|
||||||
startSecInput.mouseClicked(mouseX, mouseY, mouseButton);
|
input.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
startMsInput.mouseClicked(mouseX, mouseY, mouseButton);
|
}
|
||||||
endMinInput.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
endSecInput.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
endMsInput.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,25 +110,24 @@ public class GuiTrimPart extends GuiStudioPart {
|
|||||||
drawString(mc.fontRendererObj, "ms", 200, yPos+7, Color.WHITE.getRGB());
|
drawString(mc.fontRendererObj, "ms", 200, yPos+7, Color.WHITE.getRGB());
|
||||||
drawString(mc.fontRendererObj, "ms", 200, yPos+7+30, Color.WHITE.getRGB());
|
drawString(mc.fontRendererObj, "ms", 200, yPos+7+30, Color.WHITE.getRGB());
|
||||||
|
|
||||||
startMinInput.drawTextBox();
|
drawString(mc.fontRendererObj, "Timestamp: "+getStartTimestamp(), 230, yPos+7, Color.WHITE.getRGB());
|
||||||
startSecInput.drawTextBox();
|
drawString(mc.fontRendererObj, "Timestamp: "+getEndTimestamp(), 230, yPos+30+7, Color.WHITE.getRGB());
|
||||||
startMsInput.drawTextBox();
|
|
||||||
endMinInput.drawTextBox();
|
for(GuiNumberInput input: inputOrder) {
|
||||||
endSecInput.drawTextBox();
|
input.drawTextBox();
|
||||||
endMsInput.drawTextBox();
|
}
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
if(initialized) {
|
if(!initialized) {
|
||||||
startMinInput.updateCursorCounter();
|
initGui();
|
||||||
startSecInput.updateCursorCounter();
|
} else {
|
||||||
startMsInput.updateCursorCounter();
|
for(GuiNumberInput input: inputOrder) {
|
||||||
endMinInput.updateCursorCounter();
|
input.updateCursorCounter();
|
||||||
endSecInput.updateCursorCounter();
|
}
|
||||||
endMsInput.updateCursorCounter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user