1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tutorial Implementing Embeddable UI

Discussion in 'Tutorials & Resources' started by SlashnHax, Apr 7, 2016.

  1. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041

    Feel free to ask any questions.
     
    TheVTM and Derk like this.
  2. Derk

    Derk 12 year old normie

    Joined:
    Jan 8, 2015
    Messages:
    2,766
    Likes Received:
    1,339
    Thanks mayte, I will take a look at it as soon as I get home.
     
  3. blisterz

    Joined:
    Nov 2, 2015
    Messages:
    302
    Likes Received:
    119
    Great video.

    Any chance you could make a #2 that demonstrates the a gui controller for EmbeddableUI that has a few config buttons and a bot status update ?
     
  4. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    There is nothing RuneMate specific about the JavaFX controller. You should be able to find plenty of tutorials online on how to set up and use JavaFX controllers online.
     
  5. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    Scene Builder can also generate a controller for your design.
     
  6. blisterz

    Joined:
    Nov 2, 2015
    Messages:
    302
    Likes Received:
    119
    I followed the video and got this error
    Gyazo - 9fec431ad6da5e31e016d0e2e15dc08c.png

    I'm assuming its because my controller was made without embeddableUI in mind.

    EDIT: I got my controller working now. But would be nice to know how to do all that spiffy stuff like show profit /xp now that there is no paint. Or even a status
     
    #6 blisterz, Apr 25, 2016
    Last edited: Apr 25, 2016
  7. Party

    Party Client Developer

    Joined:
    Oct 12, 2015
    Messages:
    3,708
    Likes Received:
    1,606
    new guiController(this)
     
  8. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    Why is botInterfaceProperty never called? I do see the UI in Spectre, but that's about it.
    Code (Java):
    1. package com.skelware.runemate.script.staking;
    2.  
    3. import com.runemate.game.api.client.embeddable.EmbeddableUI;
    4. import com.runemate.game.api.hybrid.util.Resources;
    5. import com.runemate.game.api.script.framework.LoopingScript;
    6. import com.skelware.runemate.script.staking.ui.UIController;
    7. import javafx.beans.property.ObjectProperty;
    8. import javafx.beans.property.SimpleObjectProperty;
    9. import javafx.fxml.FXMLLoader;
    10. import javafx.scene.Node;
    11. import javafx.scene.Parent;
    12.  
    13. import java.io.IOException;
    14. import java.io.InputStream;
    15.  
    16. public class StakingSalvation extends LoopingScript implements EmbeddableUI {
    17.  
    18.     private ObjectProperty<? extends Node> ui;
    19.  
    20.     public StakingSalvation() {
    21.         this.setEmbeddableUI(this);
    22.     }
    23.  
    24.     @Override
    25.     public void onLoop() {
    26.  
    27.     }
    28.  
    29.     @Override
    30.     public void onStop() {
    31.         System.out.println("stop");
    32.     }
    33.  
    34.     @Override
    35.     public ObjectProperty<? extends Node> botInterfaceProperty() {
    36.         System.out.println("botInterfaceProperty");
    37.  
    38.         if (ui == null) {
    39.             try {
    40.                 final FXMLLoader loader = new FXMLLoader();
    41.                 final InputStream input = Resources.getAsStream("com/skelware/runemate/script/staking/ui/UIDocument.fxml");
    42.                 final Parent document = loader.load(input);
    43.  
    44.                 loader.setController(new UIController());
    45.                 ui = new SimpleObjectProperty<>(document);
    46.             } catch (final IOException e) {
    47.                 e.printStackTrace();
    48.             }
    49.         }
    50.  
    51.         return ui;
    52.     }
    53. }
    54.  
     
  9. Savior

    Savior Java Warlord

    Joined:
    Nov 17, 2014
    Messages:
    4,906
    Likes Received:
    2,748
    If you can see it, the method must have been called.
     
  10. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    Well system out did not log anything to the console, but the "stop" is logged to the console. So it most definitely is not called, unless system out is suppressed at certain stages, @Cloud?
     
  11. Savior

    Savior Java Warlord

    Joined:
    Nov 17, 2014
    Messages:
    4,906
    Likes Received:
    2,748
    What else would load the fxml then? Welp I know nothing further so I will leave this here :rolleyes:
     
  12. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    262
    Likes Received:
    68
    Yeah it just seems like system out is not passed through. If I create a deliberate error in my controller's constructor it logs the error correctly with the expected stack trace.
     
  13. Serene

    Serene ( ͡° ͜ʖ ͡°)

    Joined:
    Mar 30, 2015
    Messages:
    2,408
    Likes Received:
    508
    When I first tried the tutorial, I had the same problem as this Gyazo - 9fec431ad6da5e31e016d0e2e15dc08c.png, since my controller is looking for a botand stage to be passed in. Probably because it wasn't made with EmbeddableUI in mind. I changed the constructor on that to not require those and not pass in or set a script bot & stage (not sure if that was the right thing to do but all errors cleared) and now when I run the bot my UI doesn't pop up and I run into

    Code (Text):
    1.  
    2. javafx.fxml.LoadException:
    3. unknown path
    4.  
    5.    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    6.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
    7.    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
    8.    at com.deathizpro.bots.EmbeddableUITutorial.EmbeddableUITutorial.botInterfaceProperty(EmbeddableUITutorial.java:28)
    9.    at nul.iIIiiIiIIIii.initialize(nvb:233)
    10.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    11.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    12.    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    13.    at nul.IiiIIiiiiiii.try(gp:140)
    14.    at nul.IiiIIiiiiiii.try(gp:146)
    15.    at nul.iIIiiIiIIIii.<init>(nvb:150)
    16.    at nul.iIiiIIiIIIiI.try(vgc:78)
    17.    at nul.IIIiIIiIIiii.try(bub:1)
    18.    at nul.IiIiiIiiIiiI.try(ltb:17782)
    19.    at nul.IiIiiIiiIiiI.call(ltb:1177)
    20.    at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
    21.    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    22.    at java.lang.Thread.run(Thread.java:745)
    23. Caused by: java.lang.NullPointerException
    24.    at com.deathizpro.bots.EmbeddableUITutorial.TestUIController.initialize(TestUIController.java:21)
    25.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    26.    ... 16 more
    27.  
    which is the same problem I have here Question - javafx.fxml.LoadException: unknown path
     
  14. Party

    Party Client Developer

    Joined:
    Oct 12, 2015
    Messages:
    3,708
    Likes Received:
    1,606
    One or more of your FXML elements isn't properly declared, most likely.
    --- Double Post Merged, May 28, 2016, Original Post Date: May 28, 2016 ---
    Use this to make sure you're declaring all your elements.

    [​IMG]
     
  15. Serene

    Serene ( ͡° ͜ʖ ͡°)

    Joined:
    Mar 30, 2015
    Messages:
    2,408
    Likes Received:
    508
    Should I be declaring the anchorpane and label as well? My Gui only has 1 label, 1 button, 1 combobox, and the anchorpane itself. Without the anchorpane and label declared my skeleton looks like

    [​IMG]

    And my controller class looks like

    [​IMG]
     
  16. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,937
    Likes Received:
    1,266
    You're missing the @FXML annotations.
     
    Serene likes this.
  17. Serene

    Serene ( ͡° ͜ʖ ͡°)

    Joined:
    Mar 30, 2015
    Messages:
    2,408
    Likes Received:
    508
    Gotcha. I'll try that.
    --- Double Post Merged, May 28, 2016 ---
    That fixed it. Thanks guys.
     

Share This Page

Loading...