1. The dev blog update said that he was working on GUI for plugin usage... And posted his github source... Any idea oh how to use it?
     
  2. Maybe
    Code:
    CommunityEntity.ServerInstance.ClientRPCEx( new Network.SendInfo() { connection = args.connection }, null, "AddUI", json );
    Json u can find at https://github.com/Facepunch/rust-community/blob/master/CommunityEntity.UI.cs
    [DOUBLEPOST=1433519476][/DOUBLEPOST]Wow, it's working perfect! http://savepic.ru/7216319.png
    Test code (copy from github):
    Code:
    using UnityEngine;
    using Rust;namespace Oxide.Plugins
    {
        [Info("GUI", "Bombardir", "0.0.1")]
        class GUI : RustPlugin
        {
            #region JSON
            const string json = @"[  
                            {
                                ""parent"": ""Overlay"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Text"",
                                        ""text"":""Is it from plugin?"",
                                        ""fontSize"":32,
                                        ""align"": ""MiddleCenter"",
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0 0.5"",
                                        ""anchormax"": ""1 0.9""
                                    }
                                ]
                            },
                            {
                                ""name"": ""Button88"",
                                ""parent"": ""Overlay"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Button"",
                                        ""close"":""TestPanel7766"",
                                        ""command"":""status"",
                                        ""color"": ""0.9 0.8 0.3 0.8"",
                                        ""imagetype"": ""Tiled""
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0.3 0.15"",
                                        ""anchormax"": ""0.7 0.2""
                                    }
                                ]
                            },
                            {
                                ""parent"": ""Button88"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Text"",
                                        ""text"":""YES!!!!"",
                                        ""fontSize"":20,
                                        ""align"": ""MiddleCenter""
                                    }
                                ]
                            }
                        ]
                        ";
            #endregion        [ChatCommand("gui")]
            void gui_test(BasePlayer player, string command, string[] args)
            {
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", json);
            }
        }
    }
     
    Last edited by a moderator: Jun 5, 2015
  3. I was trying it, and it is working.
    You only need to call the line of Bombardir´s post with an json string like in the example on the github.
    the "args.connection" must be an instance of Network.Connection.

    You get this object, in example, in the "OnUserApprove" hook.
    Not really sure how to get this connection object from an BasePlayer object, therefore i was assigning it to an internal array of my plugin class to be able to acccess it later in an other hooks where i only have the BasePlayer object.

    But i still need a list of "parent" Panels, and some example how to define the size and possition of the elements.
    For now parent "Overlay" looks like the the main Window/Area (visibile in all cases), i was also trying some other names and found "Inventory".
    But i like to know the name of the Panel of the complete Window after using tab ( where Inventory, Player and Craftmenu is ) to add some new buttons...
     
  4. I played a bit .. and all i can say at the moment it is tooo-o much pain in positioning of the components :(
    [DOUBLEPOST=1433520410,1433510521][/DOUBLEPOST]EDIT:
    Spent some time and created this small panel (online/sleepers/time).
    Good thing that Garry decided to advance the client modding, but currently possibilities is very and very limited.
    [​IMG]
     
  5. It's not so hard after some tests)
    [​IMG] [DOUBLEPOST=1433536961][/DOUBLEPOST]
    I don't think so. We can do a lot of good plugins with it since we can use buttons that will call console commands (console cmds will call other gui stuff etc)...
     
  6. Maybe you're right. This panel is centered?
    Been trying to do this, can i look at the definition?
     
  7. How do I get out of using that dreaded string bullcrap with the json? I tried formatting it, and it was the same every which way... But it still does NOT like my formatting... I can't insert non-static information like the Level of the character and such....


    Nevermind... Fixed it... Stupid string... Who uses @ anymore anyway...
    [DOUBLEPOST=1433565571,1433542584][/DOUBLEPOST]Anybody figure out how to make it refresh information on the screen? Or is it still static?
     
  8. Refresh possible only through complete UI redrawing. Use DestroyUI RPC.
     
  9. Yeah, but it's horribly refreshed. it doesn't destroy very quickly... Takes about 100ms to actually do anything on the client's screen... The way I had to do it was this...
    Code:
                PluginTimers t = new PluginTimers(this);
                if (gui != null)
                    gui.ProfileGUI_remove(player);
                if (args != null && args.Length >= 1 && args[0].ToLower() == "hide") return;
                t.Once(0.100f, () => InsertNewGUI(PanelName, player));
     
  10. I have attempted to create an UI builder extension for my needs (instead of working with json by hands, hate it).
    Here is some result for the moment:
    Sample Plugin (Usage)

    [​IMG]

    The code of extension is a bit complicated, but seems now easier to maintain the UI.
    Will this have any interest or pure json is better? :)
     
  11. Wulf

    Wulf Community Admin

    Instead of making an extension that everyone may not be able to install, you could create a CuiHelper.cs plugin and then let authors decide how to use that.
     
  12. It really depends in how intuitive Rust gets with it's Custom UI... Right now making a builder for the UI might be pointless... Since it's so early thing's will change. Honestly idk why he is using Json... Xml would be better honestly. Lol
    [DOUBLEPOST=1433612730][/DOUBLEPOST]And the use of PluginTimer to refresh information is a pain in the ass... Having to reload the information by destroying it and rewriting it is a horrible method :/ but it's what works right now... And the only way I could get it to refresh was to add a slight delay on when it redraw's itself
     
  13. Well, I think I might actually work on some library/class to help simplify the json crap. it should be fairly easy once the basics is written up. It's an Alpha game and the UI is very early but possesses a lot of potential. From what I can see with the example codes so-far is that Garry has a very flexible system in-mind for the future. I don't think he should really change the json part, we are suppose to be modders, so we should write up our own system to work with json.

    Also json uses up a lot less bytes over xml. Network optimization also needs to be taken into consideration.
     
  14. I suppose that is true... There's also another flaw I've seen... It logs itself to the users console... Which is very taxing on the server if refreshing multiple times....
     
  15. Ive read in the last devblog that garry added a possibility to put UI elements on a players screen, how would that be possible to for example show a picture or a text? [Lel this got moved xD, ill try what I've seen on the top (looks difficult to me on the first sight ^^)]
    [DOUBLEPOST=1433881355,1433855402][/DOUBLEPOST]Wow I don't understand json xD
    propably... or im just confused
     
  16. What are you struggling to understand about the JSON format?
     
  17. Well actually I wrote bullshit, its not really the JSON format i don't understand, I don't really understand how that JSON part works, for example how I can make that button do something like close the UI again and that stuff ^^
    Also how to even set an Button etc. just copied Bombardirs code right now and playing around with it
    Also im trying to remove the UI which doesnt really work like I tried ^^
    Code:
    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI");
     
    Last edited by a moderator: Jun 9, 2015
  18. Replace "LevelBar" string at the end with your Panel Name... So if your panel name is "TestPanel7766" You would put that there... Works for me... I have working UI on my server.
    Code:
    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", "LevelBar");
     
  19. And how would I call that by clicking a button? :eek: