Jump to content

Recommended Posts

Script Gui Builder
GitHub

ScriptGuiBuilder.kt
MyScriptGui.kt
BaseGui.kt

 

Anywhere inside the GuiScope you have access to:

  • navigation NavigationController
  • currentScreen GuiScreen
  • dispatchSnackbar(message, action, duration, onAction)
  • dispatchAlert(title, message, confirmButtonText, cancelButtonText, onConfirm, onCancel) ScriptGuiAlert
  • navigateTo(navigationKey)
  • navigateTo(GuiScreen)
  • toggleCurrentScreenLeftFrame()
  • toggleCurrentScreenRightFrame()
  • closeGui()

Anywhere inside the GuiScreenScope you have access to:

  • guiScope to access things throughout the Gui
  • onGuiClosed(block) for setting an action to happen within this scope when the Gui closes.
  • isLeftFrameVisible()
  • isRightFrameVisible()
  • showRightFrame()
  • hideRightFrame()
  • showLeftFrame()
  • hideLeftFrame()
  • toggleRightFrame()
  • toggleLeftFrame()

 

Building a GUI
    
Creating your GUI

buildGui("Title", ScriptIcon.fromGithubImage("Magic icon")) {
   // GuiScope inside here
}

Adding a Screen inside the GUI Builder

Screen("Title", ScriptIcon.fromGithubImage("name")) {
   
        onGuiClosed {
          // Inside these blocks you are in the GuiScreenScope
        }

        FloatingAction {
          // GuiScreenScope
        }

        MainFrame {
          // GuiScreenScope
        }

        LeftFrame {
          // GuiScreenScope
        }

        RightFrame {
          // GuiScreenScope
        }

        Screen("Title", "unique name") {
          // Same options available for nested screens
        }

    }


Creating an individual screen without the builder
 

val SettingsScreen = buildScreen("Settings", ScriptIcon.fromImageVector(Icons.TwoTone.Settings)) {
    // Same scope as shown above in the GuiBuilder use
}

 

Autocomplete

Create the state.
You can use a set list as options, or use the listBuilder parameter to create suggestions dynamically. 
It also accepts a list or list builder to determine "favorites" items if you would like that option.

val autocompleteState = rememberAutoCompleteState(
    listBuilder = { query ->
        Query.itemDefinitions().nameContains(query).isNotPlaceholder.isNotNoted.distinctByName().toList()
    },
    itemToString = { it.name },

)

Create the actual component.

SimpleAutoComplete(
    label = "Choose an Item: ",
    labelWidth = 150.dp,
    inputWidth = 200.dp,
    autoCompleteState = autocompleteState
)

 


   

Included Bonus Features

 

 📁Directory📁

Directory Interface for easily saving and loading data.

  • Paths   The following references to SCRIPT_DIRECTORY is set in the ScriptData
              Directory.TRiBot :       .../.tribot/
              Directory.Root :         .../.tribot/SCRIPTER_DIRECTORY/
              Directory.Script :       .../.tribot/SCRIPTER_DIRECTORY/script_name/
              Directory.Account :      .../.tribot/SCRIPTER_DIRECTORY/account_name/
              Directory.Settings :     .../.tribot/settings/
  • Saving
Directory.Script.save(myClass, "MySaveName")
// Saves the file in .../.tribot/SCRIPTER_DIRECTORY/script_name/MySaveName.json
  • Loading
val data = Directory.Script.load(myClass::class.java, "MyFolder", "MyLoadName") 
// Loads the file from .../.tribot/SCRIPTER_DIRECTORY/script_name/MyFolder/MyLoadName.json
  • Cleaning Directories
Directory.Script.clean() 
// Deletes all files older than 5 days in the Script directory

Directory.Script.clean(1, TimeUnit.DAYS, true) 
// Deletes all files older than 1 day in the Script directory


:octocat:GitHub:octocat:

GitHub class for easily accessing files from GitHub.

  • You can set your repository and auth key in ScriptData
  • GitHub files are saved under .../.tribot/SCRIPTER_DIRECTORY/github/directory
  • Your GitHub has to be structured accordingly. Your provided GitHub Url should lead to the directory containing these directories:
val jsonFile = GitHub.getJson("jsonName")
val fontFile = GitHub.getFont("fontName")
val imageFile = GitHub.getImageFile("imageName")
val javafxImage = GitHub.getImage("imageName")
val cssFile = GitHub.getCss("cssName")
val fxmlFile = GitHub.getFxml("fxmlName")
val file = GitHub.getFile("fileName.txt")
val fileInDirectory = GitHub.getFile("directoryName", "fileName.txt")

 

📦Asset Manager📦

AssetManager for loading and caching data to help save resources
 

val gitHubImageBitmap = AssetManager.loadGithubImageToBitmap("imageName")
val gitHubImagePainter = AssetManager.loadGithubImageToPainter("imageName")
val urlImageBitmap = AssetManager.loadUrlImageToBitmap("url")
val urlImagePainter = AssetManager.loadUrlImageToPainter("url")
val wikiImageBitmap = AssetManager.loadWikiImageToBitmap("imageName")
val wikiImagePainter = AssetManager.loadWikiImageToPainter("imageName")
// These are set up slightly different to access the item icons folder, it will only get items currently in the folder. Right now it's the latest OsrsBox list.
val itemIconByIDBitmap = AssetManager.loadGithubItemIconToBitmap(995)
val itemIconByIDPainter = AssetManager.loadGithubItemIconToPainter(995)

 


 🏹Script Icon🏹

  
  Adding icons in Jetpack Compose can be tricky/confusing to get the icon you want where you want it, in the format you need it.
This class consolidates a few into one type to make it easier to use any icon whenever you need.
    These are loaded and locally cached through the asset manager.
  

  ScriptIcon.TRiBotLogo
  ScriptIcon.None // For a placeholder and preventing null checking
  ScriptIcon.ImageNotFound // Load in place of empty images or images that weren't loaded correctly
  
  ScriptIcon.fromImageVector() // This is useful for using the compose icons
  ScriptIcon.fromImageVector(Icons.TwoTone.Home)
  
  ScriptIcon.fromGitHubImage("imageName") // Uses the GitHub class to get your image and use as an icon
  ScriptIcon.fromUrl("url") // Load any Image from the web 
  
  ScriptIcon.fromImage()
  ScriptIcon.fromPainter()
  ScriptIcon.fromImageBitmap()
  ScriptIcon.fromBufferedImage()

 

Edited by High Order
Added auto complete example
  • Like 5
  • Thanks 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Similar Content

    • By High Order
      If you downloaded Tribot Scripting Gradle Template after Aug 31, 2022 then you have the up to date build scripts. This is for those trying to update their existing projects.
      If you have not made any changes to your current build scripts, you can scroll to the bottom and just copy and paste the full templates over.

      If you are trying to add what's necessary into an existing build with changes already made, here are the important changes you don't want to miss:
       
      At the top level of your project tree find your files named build.gradle.kts and settings.gradle.kts.

         
      build.gradle.kts :
      Inside the plugins block, ensure your Kotlin version is updated, the template previously had version 1.5.31
      kotlin("jvm") version "1.6.10" Under the Kotlin version inside the plugins block the Jetpack Compose plugin is added.
      id("org.jetbrains.compose") version "1.1.0"  
      After the plugins block, a new block allprojects was added: 
      allprojects { apply(plugin = "kotlin") apply(plugin = "org.jetbrains.compose") dependencies { implementation(compose.desktop.currentOs) } } That is all for the build.gradle.kts file. 
       
      settings.gradle.kts:
      At the bottom of the file add 
      pluginManagement { repositories { gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } }
       
      That's all there is to it, now you need to refresh your Gradle in the project and let everything update, and you are ready to start using Jetpack Compose.
       
      Final Product: 
       
      build.gradle.kts:
      import org.tribot.gradle.plugin.TribotPlugin plugins { java kotlin("jvm") version "1.6.10" id("org.jetbrains.compose") version "1.1.0" } allprojects { apply(plugin = "kotlin") apply(plugin = "org.jetbrains.compose") dependencies { implementation(compose.desktop.currentOs) } } buildscript { configurations { classpath { resolutionStrategy.cacheDynamicVersionsFor(5, TimeUnit.MINUTES) } } repositories { mavenCentral() maven("https://gitlab.com/api/v4/projects/20741387/packages/maven") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") google() } dependencies { classpath("org.tribot:tribot-gradle-plugin:+") } } apply<TribotPlugin>() settings.gradle.kts:
      rootProject.name = "tribot-script-template" include("libraries:my-library") include("scripts:my-script") include("scripts") pluginManagement { repositories { gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } }  
       
    • By notsmile
      So I wanted to make a GUI for my Runecrafter and use TitledBorders instead of using tabs since it looks nicer imo.
      I can't seem to get the TitledBorder to appear fully (I think that's the problem anyway) properly in the GUI.
      It looks like this:
       
      Here is the code for it:
      JPanel runesPanel = new JPanel(); runesPanel.setBackground(Color.DARK_GRAY); TitledBorder runesBorder = BorderFactory.createTitledBorder("Runes"); runesBorder.setTitleColor(Color.lightGray); runesBorder.setTitleJustification(TitledBorder.LEFT); runesPanel.setBorder(runesBorder); JComboBox<String> runeOptions = new JComboBox<String>(new String[] { "Select Runes", "Air", "Astral*", "Blood*", "Cosmic", "Earth", "Fire", "Law", "Mud", "Nature", "Soul*", "Water", "Wrath*", "ZMI*"}); runesPanel.setBounds(20,20,200,200); runesPanel.add(runeOptions); mainGuiSettingsPanel.add(runesPanel); mainGuiFrame.setVisible(true); } }  
      Sorry for the nooby question, new to using Swing and Java
      Thanks!
    • By Chesapeake
      abstract class TreeBot : Script() { private var rootTreeTask : BranchTreeTask = this.createRootTask() override fun run() { var treeTask = rootTreeTask var currentTask = treeTask while(!currentTask.isLeaflet()) { if(treeTask.validate()) { treeTask = checkNotNull(rootTreeTask.onSuccessTask()) { "Success task cannot be null" } currentTask = treeTask } else { treeTask = checkNotNull(rootTreeTask.onFailureTask()) { "Failure task cannot be null" } currentTask = treeTask } treeTask.onExecute() } } abstract fun createRootTask() : RootTreeTask } interface BranchTreeTask { fun isLeaflet() : Boolean fun validate() : Boolean fun onExecute() fun onSuccessTask() : BranchTreeTask? fun onFailureTask() : BranchTreeTask? } interface LeafletTask : BranchTreeTask { override fun isLeaflet() : Boolean { return true } override fun validate() : Boolean { return true } override fun onSuccessTask() : BranchTreeTask? { return null } override fun onFailureTask() : BranchTreeTask? { return null } } interface RootTreeTask : BranchTreeTask { override fun isLeaflet() : Boolean { return false } }  
    • By JoeDezzy1
      Automate, Manage & Launch Any Client, Anywhere, Anytime With The Click Of A Button
       
      ------------- TRiBot CLI Client Manager ------------
       
      -------- Client Launcher (Lite version) --------

       
      ------- Client Launcher (Advanced version) -------
      -----Updated Version-----





       
      -----Old Version-----
       
       
      ------- What You Can Do With 1 Click -------
       
      Overview: Specifications & Capabilities Load Any Account on Any World with Any Script, Any Arguments, Any Proxy Monitor A Live Feed of your Running Bots! Live Locations & World Live Items on Each Bot Live Exchanges being made for Each bot View Run-time & Status's of Each Bot Control your Bots Locally or Remotely! Start Your Bots From Any Machine Shutdown Your Bots From Any Machine Automate Everything! Grand Exchanging with Customized Exchange Profiles for Your Bots Need's Trading Between Any of Your Bot's and Anytime Account Replenishment - Register, Create & Even Tutorial  
      Availability: Any Operating System Windows 7/8/10/Vista Mac OS Linux (Debian,  CentOS,  Ubuntu, Fedora, Arch, Kali)  
       
       
      These tools are fully operational.
       
      Message me on TRiBot forums for more info.
       
      THIS IS NOT FREE


  • Our picks

    • We've heard your complaints - the TRiBot API could be much easier to use. We've been dedicating our time to improving the scripter experience here and spent the past year working on a new and improved API - the TRiBot Script SDK.

       

      The TRiBot Script SDK is an easy-to-use library for building TRiBot scripts. It is the recommended approach to building scripts moving forward over the old TRiBot API. It contains all the core things you need to build a script, and a ton of additional helpful stuff to get you using your scripts quicker. See the documentation section for everything offered, and check out the brief overview link too.

       

      The SDK was announced in preview here:

       

      It is now officially released. The official release guarantees we will support backwards compatibility for some period of time. See the 'backwards compatibility' section below for more info.

       

      How to use:

      There is multiple options, listed in the order they are recommended.

      1) Use the gradle template mentioned below

      2) Obtain through gradle

      Add this dependency: api("org.tribot:tribot-script-sdk:+")

      Add this repository: maven("https://gitlab.com/api/v4/projects/20741387/packages/maven")

      3) Take from your local filesystem in your .tribot/install folder. For example, on windows, you'd find it at "C:\Users\[user]\AppData\Roaming\.tribot\install\tribot-client\lib\tribot-script-sdk-[version].jar"

       

      Documentation:

      Java docs: https://runeautomation.com/docs/sdk/javadocs/index.html?overview-summary.html

      Kotlin docs: https://runeautomation.com/docs/sdk/kdocs/index.html

       

      Backwards compatibility:

      We will be following a deprecation schedule whenever we perform a possible breaking change. We will deprecate the respective methods or classes and announce it in a topic. It will remain deprecated for some period of time (weeks or months), and then removed. This will give you time to fix anything, if we need to make a breaking change.

       

      Gradle template:

      Easily build scripts with a new pre-configured scripting gradle template

       

      Users of the current API:

      There is no plans to remove TRiBot API. It will still be available. However, non-critical bugs probably won't be fixed. The SDK does depend on some of the API so fixing some things in the SDK will indirectly fix the API. However, bugs that have existed in the API for awhile will likely not be fixed. It's recommended to use the SDK moving forward. Let us know if there's something the SDK is missing.

       

      Brief overview of the changes:

       

      Bug reports:

      Post bug reports in the bug reports section of the forums

       

       

      Let us know what your thoughts are! If you have questions, feel free to ask below or in discord.

       
        • Like
      • 0 replies
    • Support for the gradle launcher is being dropped. Read more about the new launcher here.
        • Like
      • 8 replies
    • What to expect from TRiBot moving forward.
        • Thanks
        • Like
      • 11 replies
    • TRiBot 12 Release Candidate

      The TRiBot team has been hard at work creating the last major version of TRiBot before the TRiBot X release. We've noticed many problems with TRiBot 11 with a lot of users preferring TRiBot 10 over 11. We've heard you, so we took TRiBot 10, added the new features introduced with 11, introduced some other new things, and created TRiBot 12. So without further adieu, here's TRiBot 12.
        • Sad
        • Like
      • 40 replies
    • Gradle is a build tool used to accelerate developer productivity.

      We recently setup a Maven repository (TRiBot Central) to make it easier for scripters to create scripts. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-central/-/packages

      Furthermore, we've released a simple Gradle project to make it easy to run TRiBot and develop scripts for it. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-gradle-launcher

      The goals of TRiBot Central are to:

      Deliver updates to TRiBot faster


      Better organize TRiBot's dependencies (AKA dependancies)


      Make it easier to develop scripts for TRiBot


      Make it easier to use and run TRiBot


      Note: TRiBot won't be able to run scripts from within this project until TRiBot's next release.
        • Like
      • 15 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...