• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader TerraUI Toolkit (Example Mod Included)

Boffin

Brain of Cthulhu
TerraUI Toolkit

Hi there! Welcome to our thread about our UI Toolkit!

What is TerraUI Toolkit?
-TerraUI toolkit is a set of files and textures that can be used to make your own UI in your own mods!
-The files provided in the download are for the UI and Textures, with a blank template window included.
-There is also an example mod download included (which is also up on the mod browser for you to download).

How do I use this toolkit?
Download and install the example mod to see how to use everything. All of the source is commented, so you can read exactly how to use it :D

Can I see some mods that have used this?
Sure! There are currently 2 mods I know about which use it:
jExo, linked here
and Insight Reborn (by @abluescarab), linked here

Have you you used this toolkit to make a mod? Let me know, I'll link to your mod here!


DOWNLOADS

Click here to Download the Example Mod .tmod file!
Click here to download the UI Starter Kit, to implement into your own mods!
Click here to download the Example Mod Source code, which is commented for you to learn how to use it!
Click here to download all 3!

CHANGELOG
1.0 - Release
1.0 (slight update, forgot to change version) updated example mod to use newer hook in tModLoader.
1.0.1 - Fix
Fixed an issue with Item Slots not animating Souls and possibly other items properly (Thanks to @abluescarab for being awesome and helping me with that/basically doing it for me :p)
Updated starter kit to show those using Visual Studio or other IDEs what each parameter in the constructors do. (Again, thanks to @abluescarab for suggesting I do that :D)


TEAM
@Boffin

@abluescarab


DISCLAIMER

You are allowed to use this toolkit in your mods (obviously) as long as your provide credit in your thread or in your Mod's Description etc. on the Mod Browser.
You are also allowed to make changes to the original UI Toolkit, to suit your own mod, as long as, again, you credit us for making the toolkit.
If you do make additions or changes, especially ones that are substantial, let us know on this thread and we may add them to the actual toolkit! :D

 
Last edited:

Boffin

Brain of Cthulhu
K, you might want to replace the GlobalItem thing with this hook: https://github.com/bluemagic123/tModLoader/wiki/Mod#public-virtual-void-postdrawinterfacespritebatch-spritebatch

The GlobalItem thing is a hack since we didn't have that method before 0.8.3.
Don't like to double post, but for some reason, some of the newer hooks say that they don't exist, it's really weird. The "No Suitable Method to Override" message keeps happening when I try to build, though only sometimes.
 

jopojelly

Retinazer
Don't like to double post, but for some reason, some of the newer hooks say that they don't exist, it's really weird. The "No Suitable Method to Override" message keeps happening when I try to build, though only sometimes.
This is usually the case where someone forgot to update the tmodloadermac.exe file when updating.
 

abluescarab

Skeletron Prime
How do I find the example interface in-game? I'd like to see it in action, but I don't see a keybinding or button in the source code that will let me see the UI. Actually, I see some code to display it when the player opens their inventory, but nothing is showing up.
 

Boffin

Brain of Cthulhu
How do I find the example interface in-game? I'd like to see it in action, but I don't see a keybinding or button in the source code that will let me see the UI. Actually, I see some code to display it when the player opens their inventory, but nothing is showing up.
You can craft an item with a dirt block and place down a tile and right click on it, or you can use Cheat Sheet / Hero's Mod to cheat it in :D
 

Subaro

Terrarian
Very nice toolkit.
I´m using it but it appears that all interactable UIObjects like the UIButton are not working on multiplayer. I tested my mod and the example mod. If more than one player are on the server the buttons, textboxes just do nothing. :confused:
 

Boffin

Brain of Cthulhu
Very nice toolkit.
I´m using it but it appears that all interactable UIObjects like the UIButton are not working on multiplayer. I tested my mod and the example mod. If more than one player are on the server the buttons, textboxes just do nothing. :confused:
One of the fundemental things I forgot to test in the original test was multiplayer. We will look look into this, thanks for letting us know.
 
I tried to use this, but came across a problem: whenever I use a text box, the game crashes.
Here's the log (obtained through try-catch statement):
Code:
System.IO.FileNotFoundException: Could not load file or assembly 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at ItemCustomizer.UI.UITextBox.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.UIObject.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.UIPanel.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.Windows.CustomizerGUI.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
Looking at the code, you're using System.Windows.Forms, which in turn uses this missing Accessibility dll.
It's missing because I'm on Linux. I've tried adding this dll as a dll reference, but I couldn't get that to work.
 

Boffin

Brain of Cthulhu
I tried to use this, but came across a problem: whenever I use a text box, the game crashes.
Here's the log (obtained through try-catch statement):
Code:
System.IO.FileNotFoundException: Could not load file or assembly 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at ItemCustomizer.UI.UITextBox.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.UIObject.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.UIPanel.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
  at ItemCustomizer.UI.Windows.CustomizerGUI.Draw (Microsoft.Xna.Framework.Graphics.SpriteBatch sb) [0x00000] in <filename unknown>:0
Looking at the code, you're using System.Windows.Forms, which in turn uses this missing Accessibility dll.
It's missing because I'm on Linux. I've tried adding this dll as a dll reference, but I couldn't get that to work.
I was only using System.Windows.Forms for the message box feature, as at the time I completely skipped over ErrorLogger's existence. There's a new version coming soon, where all of these issues should be fixed. System.Windows.Forms isn't required at all anymore.
[doublepost=1471453194,1471452857][/doublepost]Sorry for a double post, but I've come across a solution for the issues in multiplayer, there will be a complete OP thread rework, code rework (to make it look nicer and much easier to understand, courtesy of @abluescarab) and will be available on GitHub. Thanks for the patience, this should hopefully be released soon.
 
This sounds great! A Github repository makes a lot of sense for this kind of project.
Are you using Main.GetInputText(string text) by any chance? I found that to be a very easy solution to fixing the text box.
(albiet a buggy one... maybe best not to use this, or I did things wrong, i dunno)

Also, there seems to be an issue with drawing UIObjects where their parent is not the base object.
I tried to have a label with a button as its parent so that I could have the label on the button.
However, the label then appears at the top-left of the screen!
(the button's parent is the base panel, and the label is being added to the button's list of children)
 

Boffin

Brain of Cthulhu
This sounds great! A Github repository makes a lot of sense for this kind of project.
Are you using Main.GetInputText(string text) by any chance? I found that to be a very easy solution to fixing the text box.

Also, there seems to be an issue with drawing UIObjects where their parent is not the base object.
I tried to have a label with a button as its parent so that I could have the label on the button.
However, the label then appears at the top-left of the screen!
(the button's parent is the base panel, and the label is being added to the button's list of children)
That's the best way to do it, yes. I don't know why I didn't start off with that. I think I wrote most of the original code at about 3am+ in the morning.

And that's rather odd. It add's the parents position, which is done before it updates the children objects, so I can't understand why that would happen. I'm sure that the code overhaul @abluescarab has written will most likely fix these issues, or at least make it much easier to solve them. If you would like, you can peak around the code for a fix, and if you manage to, let us know :) (you don't have to ofc)
 
Top Bottom