示例#1
1
  @Override
  protected void actionPerformed(GuiButton button) throws IOException {
    switch (button.id) {
      case 0: // Means Done
        ErrorHandling.CleanErrors();
        /* Closes the text editor, saves the .oc file and attempts to compile and load it */
        mc.thePlayer.closeScreen();
        text.deleteCharAt(cursorLocation);
        saveFile();
        try {
          Compiler.main(
              String.format(System.getProperty("user.dir") + "/ObsidiCode/Test/SimpleMiner.oc"));
        } catch (Exception e) {
          e.printStackTrace();
        }
        ArrayList<String> currentErrors = (ArrayList<String>) ErrorHandling.GetErrors().clone();
        if (currentErrors.size() == 0) {
          loadRobot();
        } else {
          ErrorBook eb = ObsidiSkriveMaskineMod.errorBook();
          ObsidiCodingMachine.dropErrorLog(eb);
        }
        break;
      case 1: // Means reset
        // Resets the text on the screen.
        text = text.delete(0, text.toString().length());
        cursorLocation = 0;
        break;
      default:
        break;
    }

    super.actionPerformed(button);
  }
示例#2
1
 @Override
 public void initGui() {
   obsidiFile = new File(System.getProperty("user.dir") + "/ObsidiCode/Test/SimpleMiner.oc");
   this.buttonList.add(
       new GuiButton(
           saveButton, this.width / 2 + 5, this.height / 2 + 125, 100, 20, "Save and Exit"));
   this.buttonList.add(
       new GuiButton(resetButton, this.width / 2 - 105, this.height / 2 + 125, 100, 20, "Reset"));
   loadFile();
   if (!text.toString().contains("_") && text.toString().equals("")) text.append(cursor);
   cursorLocation = text.length() - 1;
   super.initGui();
 }
示例#3
0
 void loadRobot() {
   // Creates new ClassLoader for whenever the class needs to be reloaded.
   ClassLoader parentClassLoader = DynamicClassLoader.class.getClassLoader();
   DynamicClassLoader newClassLoader = new DynamicClassLoader(parentClassLoader);
   String classFile =
       String.format(System.getProperty("user.dir") + "/" + robotName + "Robot.class");
   // A new instance is created of the main Robot class in order to start the normal and hear
   // threads
   try {
     Class<? extends SyncRobot> sr = newClassLoader.loadClass(robotName + "Robot", classFile);
     classFile =
         String.format(
             System.getProperty("user.dir")
                 + "/"
                 + robotName
                 + "Robot$"
                 + robotName
                 + "HearThread.class");
     newClassLoader.loadClass(robotName + "Robot$" + robotName + "HearThread", classFile);
     sr.newInstance().StartThreads();
   } catch (Exception e) {
     e.printStackTrace();
     System.out.println("Failed to load Robot class");
   }
 }