Game Development Community

dev|Pro Game Development Curriculum

T3D GUI Template - XML Saving

by Jesse Allen · 10/12/2014 (2:56 pm) · 10 comments

Are you ready for an improved look for your game template GUI's? Do you want to get started with saving and retrieving data on your T3D server quickly? Look no further, with this addition to your Full Template you will be able to choose a skin for your soldiers, login to your server, and have all that data saved in XML. 2 easy steps and you are on your way:


  1. Download the .zip file from GitHub: T3D-GUI-Template
  2. Extract the /game folder from the .zip to your project's /game folder and overwrite the files as prompted.

Do this with a new Full Template project!
Use the provided update at your own risk.
I can't be held responsible for any problems.
Find the list of added/changed files at the bottom of this post if you need to customize your install.

Host Character Pane with Skin Selection:
i1213.photobucket.com/albums/cc466/rockoutsolid/Development/skinSelect.png
Join Server GUI with Skin Selection:
i1213.photobucket.com/albums/cc466/rockoutsolid/Development/JoinSelect.png
How it Works:
When you choose to play single player, host, or join a server you will be presented with some text entry boxes for:
  • Character Name
  • Login
  • Password
  • Choose a skin color and launch, host, or join the server. Enjoy your skin selection. If it is a newly created character and login you will find this in the console:
    i1213.photobucket.com/albums/cc466/rockoutsolid/Development/newChar.pngWhere the skin color will be your color of choice.

    If you are a returning player to the same server, the server has written an .xml file with your character's name, login, password, and server information:
    i1213.photobucket.com/albums/cc466/rockoutsolid/Development/serverTest.png
    In this case, you will find the following in the console:
    i1213.photobucket.com/albums/cc466/rockoutsolid/Development/CharLoadSuccess.pngWhere the skin color will be your color of choice, of course.

    This has been tested:
  • Using the current 3.6.1 Master branch of T3D.
  • Under Windows 8.1 and Windows 7.
  • SinglePlayer, Hosting, and Joining servers.

  • Here you can see the results of the above testing, where the HOSTGUY chose the 'Teal' skin and the GUY joining chose 'Orange':
    i1213.photobucket.com/albums/cc466/rockoutsolid/Development/tdm.png
    Because it was quite an extensive modification of the default Full Template, I have included a list of added/changed files for your further study or convenience(you can search the files for -Jesse to find changes):

    Added Files:
    game/art/gui:
    DeathmatchImage.png
    HostGui.gui
    HostOrJoinGui.gui
    LoginGui.gui - *see note below
    metalPad.png
    PlaySinglePlayerGui.gui
    TDMimage.png

    game/core/art/gui/images:
    frame-border.png
    hudfill_inv.png
    hudfill_light.png

    game/core/fonts:
    Orbitron 14(ansi).uft
    Orbitron 16(ansi).uft
    Orbitron 18(ansi).uft
    *Fonts are licensed under SIL Open Font License by Matt McInerey.

    game/scripts/server/dedicated:(New folder)
    armorSkins.xml
    characterData.xml
    clientData.xml -*see note below
    XML.cs

    Replaced Files:
    game/art/gui:
    joinServerDlg.gui
    mainMenuGui.gui
    optionsDlg.gui

    game/core/art/gui:
    profiles.cs

    game/core/art/gui/images:
    button.png
    buttontab.png
    selector-button.png
    tab-border.png
    window.png

    game/core/scripts/server:
    clientConnection.cs
    server.cs

    game/scripts/client:
    game.cs
    init.cs

    game/scripts/gui:
    optionsDlg.cs

    game/scripts/server:
    gameCore.cs
    scriptExec.cs

    *The loginGui.gui and clientData.xml files are not enabled or used by default. However, if you want to enable them you can exec them for a window with only a Login Box that accesses the clientData.xml. This could be useful if all you really want to do is add server login functionality.

    I hope this resource finds usefulness for you in your projects or study of Torque! The SimXMLDocument class in Torque is a powerful tool, and can be used in a myriad of ways besides what I've shown here. Data stored in .xml can be encrypted and is compatible with database structures, to name a couple strong points of the format.

    Oh, and it may seem a bit redundant to use Login and PW on SinglePlayer games. This only ensures the character save will be compatible in both single and multiplayer games (if hosted on the same PC). You can, of course, forego the logins altogether and just hit play and let the game choose your skin randomly. There are no 'catches' included in the login scripts, so if a login/pw are provided that don't exist on the server etc. nothing is going to prevent you from testing. All that stuff should be customized for your project, and I didn't feel it was beneficial to include for a testing template.

    There is plenty of room for improvement with the scripts and examples provided. This resource is provided as a convenience and a lesson on SimXMLDocument. Much of the core functionality and usefulness of it will be project-specific so it will be up to you to customize it to your liking. If you find this resource useful, some target areas for improvement I'd suggest to start with are:
  • Creating a Manager system to handle the read/writes of your .xml data.
  • Create a new .xml file for each client/character separately(information in T3D Script Manual).
  • Depending on the amount of clients this will handle for your project, consider a C++ solution for your custom SimXMLDocument functions.

  • Enjoy the resource guys, I had a ton of fun learning with Torque making it!

    Special Thanks
    Richard Ranft - For getting me started on GUI in the first place back when I started with T2D.
    Daniel Buckmaster - For strengthening my faith in community.
    Andrew Mac - For slapping sense into me at a time when I had lost my sense of direction.
    Aswin Shrestha - For inspiring me to improve and do great things with Torque's GUI.

    Thanks to each and every one of you, I feel that this could have never happened without your inspirations!

    #1
    10/13/2014 (4:20 am)
    Thanks for sharing Jesse!
    #2
    10/13/2014 (4:43 am)
    Awesome work! Thank you very much! :D
    #3
    10/13/2014 (8:27 am)
    Awesome work Jesse!
    #4
    10/13/2014 (8:46 am)
    Nice. Keep up the good work Jesse!
    #5
    10/14/2014 (2:57 pm)
    Thanks Jesse, this is great stuff -- going to use it myself to learn a bit about it as well.

    will save a few steps too, when prototyping LAN games ...

    Already thinking about updating it to work with models other than the default soldier as well.
    #6
    10/15/2014 (3:57 am)
    @All: Thanks for the kind words!

    @Jeff: Yes, of course! You'll find most of this resource's usefulness will be project specific :)

    Update:
    • Updated the Host, Join, and SinglePlayer GUI's to remember the last entered Character Name, Login, and Password on wake.
    • Removed the World Editor button from the MainMenu, just a temp removal since it won't doing anything until I update the tools/worldEditor function to push the proper (new) GUI. In any event, just Host, Join, or launch SinglePlayer and hit F11 for the WorldEditor for now until I find time to update it properly.
    #7
    10/20/2014 (2:53 pm)
    Cool! Suggestion: figure out how to access the user's directory rather than writing to the game directory. Unless you already do that :).
    #8
    10/21/2014 (7:02 pm)
    Actually, the main benefit of this resource is that it saves the data 'server-side'. It was designed with .xml saving to the server specifically in mind. In this case, it's probably best that the data is saved within the game directory (or at least that's how I've seen other game servers do it). Either that or the data is being saved to a database. Good suggestion for single player games though :) In any of these cases, though, it's a simple matter of changing the directory of the .xml file where the data is stored and pointing to that in the xml.cs file I've provided. Might have to jump through some hoops in Windows though if you want to bypass some of the User Account settings for single player games. /shrug
    #9
    10/22/2014 (12:27 am)
    Oh that's the idea - if your game's installed in Program Files, it won't let the game write local files there. Gotta write them to some user-specific directory or require UAC privileges.

    But if it's for the server then fair enough!
    #10
    10/22/2014 (8:59 am)
    This resource by Steve Acaster takes care of that. Good ol' Steve resources for the win!