Skip to content

Commit

Permalink
Editing threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaars committed May 19, 2019
1 parent c557510 commit 86ba1f5
Showing 1 changed file with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import com.simonbaars.clonerefactor.settings.Settings;
import com.simonbaars.codearena.CloneDetection;
import com.simonbaars.codearena.common.SavePaths;
import com.simonbaars.codearena.editor.CodeEditorMaker;
Expand Down Expand Up @@ -154,7 +155,7 @@ public static class GuiWindow extends GuiContainer {
int x, y, z;
EntityPlayer entity;
GuiTextField InputProject;
//GuiTextField MinLines;
GuiTextField MinLines;

public GuiWindow(World world, int x, int y, int z, EntityPlayer entity) {
super(new GuiContainerMod(world, x, y, z, entity));
Expand Down Expand Up @@ -191,7 +192,7 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
try {
super.mouseClicked(mouseX, mouseY, mouseButton);
InputProject.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
//MinLines.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
MinLines.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
} catch (Exception ignored) {
}
}
Expand All @@ -200,15 +201,15 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
public void updateScreen() {
super.updateScreen();
InputProject.updateCursorCounter();
//MinLines.updateCursorCounter();
MinLines.updateCursorCounter();
}

@Override
protected void keyTyped(char typedChar, int keyCode) {
try {
super.keyTyped(typedChar, keyCode);
InputProject.textboxKeyTyped(typedChar, keyCode);
//MinLines.textboxKeyTyped(typedChar, keyCode);
MinLines.textboxKeyTyped(typedChar, keyCode);
} catch (Exception ignored) {
}
}
Expand All @@ -221,8 +222,8 @@ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRenderer.drawString("Please choose the clone type:", 21, 15, 0);
InputProject.drawTextBox();
this.fontRenderer.drawString("Please enter the Java project:", 22, 67, 0);
//MinLines.drawTextBox();
//this.fontRenderer.drawString("Please enter the min. amount of lines:", 22, 119, -1);
MinLines.drawTextBox();
this.fontRenderer.drawString("Please enter the min. amount of lines:", 22, 119, -1);
}

@Override
Expand All @@ -240,17 +241,17 @@ public void initGui() {
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.guiLeft + 127, this.guiTop + 170, 118, 20, "Start Battle!"));
this.buttonList.add(new GuiButton(1, this.guiLeft + 147, this.guiTop + 82, 72, 20, "Choose"));
this.buttonList.add(new GuiButton(2, this.guiLeft + 70, this.guiTop + 125, 120, 20, "Edit Metric Code"));
//this.buttonList.add(new GuiButton(2, this.guiLeft + 70, this.guiTop + 125, 120, 20, "Edit Metric Code"));
InputProject = new GuiTextField(0, this.fontRenderer, 21, 83, 120, 20);
guiinventory.put("text:InputProject", InputProject);
InputProject.setMaxStringLength(32767);
InputProject.setFocused(true);
InputProject.setText("");
/*MinLines = new GuiTextField(1, this.fontRenderer, 23, 136, 120, 20);
MinLines = new GuiTextField(1, this.fontRenderer, 23, 136, 120, 20);
guiinventory.put("text:MinLines", MinLines);
MinLines.setMaxStringLength(32767);
MinLines.setFocused(false);
MinLines.setText("6");*/
MinLines.setText("5");
}

@Override
Expand All @@ -259,6 +260,12 @@ protected void actionPerformed(GuiButton button) {
World world = server.getWorld(entity.dimension);
if (button.id == 0) {
Minecraft.getMinecraft().player.closeScreen();
String minLines = MinLines.getText();
if(!minLines.isEmpty()) {
try {
Settings.get().setMinAmountOfNodes(Integer.parseInt(minLines));
} catch(Exception e) {}
}
CloneDetection.get().eventHandler.nextTickActions.add(() -> ProblemDetectionThread.startWorker( Minecraft.getMinecraft().player, InputProject.getText()));
}
if (button.id == 1) {
Expand All @@ -272,16 +279,6 @@ protected void actionPerformed(GuiButton button) {
if(input!=null)
InputProject.setText(input);
}
if(button.id == 2) {
String[] metrics = SavePaths.getMetrics();
String input = (String) JOptionPane.showInputDialog(null, "Here you can edit the actual source code of the metrics that will be turned into monsters.\n"
+ "These metrics are stored in the following location (where you can also edit and add them in your favorite IDE): "+SavePaths.getRascalFolder()+"\n"
+ "Please choose a metric down below:",
"Choose metric", JOptionPane.QUESTION_MESSAGE, null, // Use default icon
metrics, // Array of choices
metrics[0]); // Initial choice
CodeEditorMaker.create(new File(SavePaths.getRascalFolder()+input), input);
}
}

@Override
Expand Down

0 comments on commit 86ba1f5

Please sign in to comment.