1. Rust UI Extension

    This is my first release of the UI extension that I have been working on. I made this into an extension instead of a plug-in because of the amount of classes and features that I have created and are planning on adding in the future. No more JSON required to create your UI, you now only need to use C#. (Not supporting other languages)

    I simplified it as much as possible and it's a lot easier to position your controls.

    You can find the extension attached below and also a simple plug-in example to help you get started.

    The first thing you need to do is get the instance of the extension.
    Code:
    private readonly Ext.RUI.RustUI _rustUI = Interface.GetMod().GetLibrary<Ext.RUI.RustUI>();
    you then need to create an unassigned WindowUI to be able to create the UI.
    Code:
    private WindowUI testWindow;
    You now only need to create the window Properties and then start building your UI.
    Code:
    WindowProperties windowProperties = new WindowProperties("MainWindowName");
    testWindow = _rustUI.CreateNewWindow(windowProperties, new Image(new Grid(GridType.Small), new ColorData("1", "1", "1", "0.5")));
    So each button, text, image, rawimage is called a control. So now you can start adding your controls.
    Code:
    // Create Close Button
    testWindow.AddControl("btn_CloseWindow", new Button(new Grid(10, 10, 1, 1, GridType.Small), new ColorData("0.5", "0.5", "0.5", "0.5"), new ButtonData("MainWindow" + counter), new TextData("X")));
    // Row of Buttons
    testWindow.AddControl("btn_one", new Button(new Grid(2, 9, 2, 1, GridType.Small), new ColorData("0.5", "0.5", "0.5", "0.5"), new TextData("one", 20, TextAnchor.MiddleCenter)));
    testWindow.AddControl("btn_two", new Button(new Grid(4, 9, 2, 1, GridType.Small), new ColorData("0.5", "0.5", "0.5", "0.5"), new TextData("two", 20, TextAnchor.MiddleCenter)));
    testWindow.AddControl("btn_three", new Button(new Grid(6, 9, 2, 1, GridType.Small), new ColorData("0.5", "0.5", "0.5", "0.5"), new TextData("three", 20, TextAnchor.MiddleCenter)));
    Once you are done creating your UI, you can now send the window to the player by doing this.
    Code:
    testWindow.SendWindow(player);
    You can also remove the window from the player by doing this.
    Code:
    testWindow.DestroyWindow(player);
    The positioning of your controls is done by using the Grid class. I made it work similar to how unity GUI works.

    So a Grid constructor takes 5 parameters. x start position, y start position, width of the control, height of the control, and then lastly is the GridType.

    GridType has 4 options.
    • Small = 10x10 Grid
    • Medium = 50x50 Grid
    • Large = 100x100 Grid
    • Ultra = 250x250 Grid
    So positioning of a control is done by using a grid system. I will be using Excel to explain how you can use it.

    So lets say you wanted to work with a GridType Small. That means the grid will be using a (10 x 10) row/column space.

    http://gyazo.com/bbb10f37865d7856cf6ab005a17f8b35

    So using that Grid size, lets say you wanted to have your control at the top right. with a height of 2 and width of 3. It will basically look like this.

    http://gyazo.com/b323073892636e7e77e67495455c8158

    so in code it will be...

    Code:
    new Grid(8, 10, 3, 2, GridType.Small)
    X and Y will be the value of the TOP RIGHT block. so x = 8 and y = 10.

    The reason that I have different types of grid sizes, is if you wanted to create a detailed UI with a lot of buttons and text and w/e you need.

    Sending a Notification
    I have 3 types of ways to send a notification. You can access them by using...
    Code:
    _rustUI.SendNotification(1, "Notification Message Here")
    _rustUI.SendPlayerNotification(player, "Notification Message Here")
    _rustUI.SendNotificationAll("Notification Message Here")
    
    Code:
    public void SendNotification(int authLevel, string message)
    This sends a notification to a specified auth level. This is best used for when you want send something ot only auth 1 or w/e you like

    Code:
    public void SendPlayerNotification(BasePlayer player, string message)
    This sends a notification to only one specific player.

    Code:
    public void SendNotificationAll(string message)
    This sends a notification to all active players on the server. :)

    For debugging purposes, you can access the raw JSON by using...
    Code:
    testWindow.GetJSON();

    My explanation is a bit short, so PLEASE do not hesitate to ask me. I will be extended this tutorial A LOT in the near future. I would first like to see who is interested in using this Extension.

    P.S. Can a mod perhaps pin this if they thinks it's a useful extension for the community. Also ignore the grammar errors for now :D

    Love,
    ZuenTheMan
     

    Attached Files:

    Last edited by a moderator: Jul 13, 2015
  2. Wulf

    Wulf Community Admin

    Note: Keep in mind that this is a community provided extension, and with it we have no control over what it can do. It is not an official extension, so use at your own risk.
     
  3. Yes this is true, Once I see some fame catching on with this extension. I am more than willing to share the code to the public, so they can not only see what is going on in the background, but also do their own changes to it.
     
  4. nice good job, but i still find the json just as easy
     
  5. Wulf

    Wulf Community Admin

    I would still provide configs for plugins though, as editing the plugins isn't doable for good portion of people.
     
  6. yeah its wise but i already spent alot of time splitting them (alot of them used reference each other to like the coloured name support in pms ect), in my server i just have 1 big plugin handling all the custom stuff i've done, at some point ill provide configs for my plugins when i can be asked to look up how to use oxides config loader and saver i know its simple im just lazy :)
     
  7. Still no feedback on the extension for any issues or if it is useful D: #SadPanda
     
  8. i guess a lot people lack knowledge to even use this let alone the json way (yeah i know yours is just a wrapper for creating json) or can't be asked to spend time and want a quick plugin already made, this should help a lot of new developers you did a good thing even if it helps one person it matters.
     
  9. Good Job Bro! :)
     
  10. Hello ! I have this error :
    Code:
    [Oxide] 4:34 AM [Error] Oxide.Ext.RUI is referenced by RustUITest plugin but is not loaded! An appropriate include file needs to be saved to Plugins\Include\Ext.RUI.cs if this extension is not required.
     
  11. Did you include the extension? - I might have to look into it and see if the extension is not outdated. Never received any feedback since July, so never took the time to update it.
     
  12. Have you the instructions for installation? I've just put the dll in "/RustDedicated_Data/Managed". You share the SourceCode for Update?
     
  13. Thanks will give this a try soon!
     
  14. You know how to install it?
     
  15. You should just place it in your managed folder of the server files ... I will try and find some time to see if I need to do any updating on it.