1 (edited by Henningstone 2016-01-04 14:40:50)

Topic: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

NetGUI embeddable network GUIs!

NOTE: This is 0.7 only yet, since it is not far away anymore and much people are porting their mods to 0.7 or creating new ones for it. But I am going to backport it to 0.6 when (nearly) out of beta if someone is using it wink


––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
28.12.2015:

Beta3-rev1

I have to apologize, I did a big mess with the Beta3 release yesterday. It is completely broken, and I have no clue why. I already reviews the complete diff, but I weren't able to see the mistake. Weird things happen…
But as a compensation, I created a patch file for you to just easily apply if you're interested in implementing NetGUI version Beta3-rev1 smile
» Download patch


27.12.2015:

Beta3 is out, the next one could be release1 wink

https://assets-cdn.github.com/images/icons/emoji/unicode/1f389.pnghttps://assets-cdn.github.com/images/icons/emoji/unicode/1f389.pnghttps://assets-cdn.github.com/images/icons/emoji/unicode/1f389.png
- New GUI elements: Listboxes, ScrollbarV/H
- Example for Listboxes
- The main changes for this release was code refractoring, therefore not so much to see…
- I also merged the latest changes from vanilla teeworlds to be up-to-date
for complete changelog, see here

Testserver yet online: »151.80.85.125:8080«, kindly provided by Schwertspize
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––


Hey fellow tees, Henritees here!

I want to present you a modification which is intended for developers, embedding it into their own mods.

NetGUI gives the ability of sending completely customized GUIs to the client, which are being displayed in the esc-menu.
It is written lightweight to be easy to implement. The server-side is only one extra class (so two files to drag and drop into your src folder) and a few lines of copy-paste code binding the class into your game. Conflicts with any other modification you may have made to the code are therefore very unlikely.
The server class provides a few functions which are kind of an API, so you don't have to understand how NetGUI works at all to make use of it.

Remember that this mod is highly in beta, and the current version is not more than a demonstration of what it might be one day. Nevertheless, it is yet powerful and worthy to use wink
Unfortunately, NetGUI needs both server and client modification to work (which is quite obvious...), but, depending on your purpose of use, you can make it optional by faking the nethash. Shouldn't cause problems at all. Clients which don't have the ability to receive and display GUIs will just not receive and display them then, but can still play on your server.

Features: (for details, see below of the screenshot!)
Currently not much (very beta!).
- UIRect, similar to the Client's RenderTools()->DrawUIRect(…), draws rectangles.
- Label, similar to the Client's TextRender()->Text(…), writes Text.
- ButtonMenu, similar to the Client's DoButton_Menu(…), draws (usable!) Buttons.
- EditBox, similar to the Client's DoEditBoxOption(…), creates EditBoxes for inputting text!
- CheckBox and CheckBoxNumber, makes checkboxes
- Scrollbar, similar to the Client's DoScrollbarV/H
- ScrollbarOption, similar to the Client's DoScrollbarOption
- InfoBox, thats a EditBox which is just not editable tongue
- ListboxHeader and ListboxStart, together they make a Listbox containing a list of items
- - ListboxItemAdd and ListboxItemRemove to manage the items they contain (a item just holds a string of your wishes)

Download: (version Beta3, v0.1-b.3-151227 ~~ master: v0.1-b.2-151227)
https://api.bintray.com/packages/henningstone/tw_netgui/tw_netgui/images/download.svg <- automatically compiled and uploaded by Schwertspize, thanks for that!
- Source
- Linux 64 bit
- Windows 32 bit CLIENT ~ SERVER
- anything else: please compile from source. (GitHub: Henningstone/tw_netgui)
The server binary is only for demonstration of a little example, so you see it's working and you are too lazy to download and compile! If you want to USE this mod, you must download and edit it and/or embed the source.

News & Updates: (kinda littly devblog)
04.01.15 «» Windows builds are available from now on!
03.01.15 «» KeySelect element implemented; optional parameters for some functions
28.12.15 «» Nope, the next one is not release1. It is Beta3-rev1, released today tongue
27.12.15 «» Beta3 is finally out! Next one could be release1... wink
25.12.15 «» Started implementing ListBoxes (you know, the ones which show a list of elements ^^), minor bugfixing
24.12.15 «» A lot of code refractoring (adding elements is a lot easier now since most code is written by the preprocessor now wink )
24.12.15 «» Added InfoBoxes (the same like EditBoxes but not editable yikes)
22.12.15 «» Fixed vanilla compatibility issue (by Redix).
20.12.15 «» Beta2 is out, yay!
15.12.15 «» Added CheckBoxes and Number-CheckBoxes + cleanup to the networking code
14.12.15 «» Wrote some quite example code for reading multiple editboxes at once (e.g. for login fields)
13.12.15 «» Added EditBoxes and the possibility to request the entered text! I also advanced the Example wink

If you find bugs or have an idea, feel free to post it into this thread. Or into my GitHub issues tracker.

You are not supposed to read everything. That is only necessary if you want to make use of this mod or are extremely interested in how it workz smile
If you don't read on, thanks for having had a look anyway!

Greez and have fun,
Henritees
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Screenshots: (below is a short how-to to get you started with implementing)
http://i.imgur.com/FtTmeRB.png

http://i.imgur.com/y9RQxFd.png

Quick-start guide for modders who want to use it in their server modification:

1. Implementing server-side:
1. First, go ahead an grab the source!
2.1 In case you haven't modified datasrc/network.py, just overwrite yours with mine.
2.2 In case you have, open my version of it and copy the bottom lines into yours. (They're labelled  "## netgui messages")
3. Drag-and-drop src/game/server/netgui.*
4. In my src/game/server/gamecontext.*, search for "netgui" using your text editor and copy-paste the lines you find into your source.
-> The server part is implemented, congratulations! tongue

Building your own custom GUI:
Building GUIs is done in src/game/server/netgui.cpp
1. You are recommended to put every set of GUI elements into their own method of CNetGui, see my usage example in the code.

2. Usage of the API functions
Most API function have quite similar arguments. The ones which all of them have will be explained in the following:
¤ 2.1¬ int ClientID: obviously, the Client to send the GUI to (-1 for all connected Clients).
¤ 2.2¬ int NetGuiElemID: This is a unique ID for the element. Every type of element (labels, buttons, etc) has it's own list, so between them IDs can double. You'll need it to remove the element again, and Client's button presses will also send back the button's ID. Using an ID twice results in overwriting the previous element with the new element. Further, the ID tells the render order of elements with the same type (e.g. Rects): higher ID will be rendered before lower IDs.
¤ 2.3¬ vec4 Dimensions: Given in percent (0-100 of the Client's screen). The first to fields of the vec4 are the x values, the 3rd and 4th are the y values. Dimensions are always given like "X-Coord1 to X-Coord2, Y-Coord1 to Y-Coord2". Example: vec4(0,100,10,50) will draw a rect with x-Dimensions from 0% to 100% and y-Dimensions from 10% to 50%.
¡¡¡ please note: I will replace them in the following documentation by just three dots (…) !!!

List of currently available API functions:
CNetGui::void UIRect(int ClientID, int NetGuiElemID, vec4 Dimensions, vec4 Color, int Corner, float Rounding);

Additional notes:
- Color: color of the element in RGBA format.
- Corner: a value of s CUI::CORNER… enum. (e.g. CUI::CORNER_ALL would be 15)
- Rounding: the rounding of the corners (a good value is 5.0f)


void Label(int ClientID, int NetGuiElemID, const char *pText, vec4 Dimensions, vec4 Color, int FontSize, int FontAlign, int MaxTextWidth);

Additional notes:
Labels are being written into a virtual rect which you can define using Dimensions.
- FontAlign: how to align the text within it's rect. Pass 0 for left-aligned, 1 for centered, 2 for right-aligned.


void ButtonMenu(int ClientID, int NetGuiElemID, const char *pText, int Checked, vec4 Dimensions);

Additional notes:
(see "How to interact with buttons")


void RemoveElement(int ClientID, int Type, int NetGuiElemID);

Additional notes:
This removes an element from the client's screen.
- Type: You must pass one of the NETMSGTYPE_SV_NETGUI_… enum values here. This defines the type of element you want to remove, because every type has it's own list of identifiers.
- NetGuiElemID: The unique ID of the element you want to remove. You previously defined it when creating the element.


These ones are new in beta2!

void EditBox(…, const char *pTitle, int SplitValue, int MaxTextWidth, bool Password);

Additional notes:
- const char *pTitle: This text will automatically be set at the left of your editbox
- int SplitValue: The ratio between text and box in percent, e.g. 50 will do half-half
- int MaxTextWidth: How many characters the user will be able to input
- bool Password: Whether the entered characters will be hidden through stars ******


void CheckBox(…, const char *pText, int Checked);

Additional notes:
This checkbox can be checked or unchecked.
- int Checked: Whether the checkbox should be checked by default or not (enter 0 or 1)


void CheckBoxNumber(…, const char *pText, int MinValue, int MaxValue, int StepValue);

Additional notes:
This checkbox holds a number, whichs range you can define yourself:
- int MinValue, MaxValue, StepValue: the minimum/maximum value; how great the step should be


void Scrollbar(…, bool Vertical = false);

Additional notes:
- bool Vertical: When set to true, the scrollbar will be drawn vertical, otherwise it will be horizontal (default)


void ScrollbarOption(int ClientID, int NetGuiElemID, vec4 Dimensions, const char *pText, float VSplitVal, int Min, int Max, bool Infinite);

Additional notes:
- bool Infinite: when set, the value 0 (zero) will be shown as ∞ (infinite) instead


These ones are new in beta3!

void ListboxHeader(…, const char *pTitle, float Height, float Spacing);

Additional notes:
- If you want to use a Header for your Listbox, send this header before you send the listbox.
- It's Dimensions must resemble the final dimensions of the listbox (they will be used)

void ListboxStart(… const char *pBottomText, float RowHeight, int ItemsPerRow, int SelectedIndex, int HeaderID=-1, bool Background=true);

Additonal notes:
- const char *pBottomText: This text will be displayed at the bottom of the listbox. Pass '0' to disable.
- float RowHeight: How high each row of elements will be
- int ItemsPerRow: How many items should appear in one row (will determine the item width of cause...)
- int SelectedIndex: The element with this index will be selected by default for the client when receiving the GUI
- int HeaderID=-1: IMPROTANT!! If you want to use a header, enter it's NetGuiElemID here!


How to interact with buttons
whenever a client clicks a button on your NetGUI, the button will send a NetMsg containing it's NetGuiElemID back to the server (the one you defined before).
CNetGui::OnMessage handles this messages for now. From switching the ID, you can determine which actions need to be taken. See my example in code and you'll understand how to do it tongue

How to interact with anything else that buttons

void RequestData(int ClientID, int Type, int NetGuiElemID);

Requests the data held by the defined GUI element
- int Type: the type (enter smth like NETMSGTYPE_SV_NETGUI_*
- int NetGuiElemID: The custom id you defined when creating the element
The client will send a appropriate message back to the server, which can be evaluated to take the steps you want.

2

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

interesting smile good job I'd say (Y)

Teeworlds [ friends ] clan
Some YouTube Stuff about Teeworlds

3

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Awesome, I really like that idea.

4

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Is this mod required a modified client, or it works with the vanilla 0.7 ?

5

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

necropotame wrote:

Is this mod required a modified client, or it works with the vanilla 0.7 ?

This mod will require a modified client.

6

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

heinrich5991 wrote:
necropotame wrote:

Is this mod required a modified client, or it works with the vanilla 0.7 ?

This mod will require a modified client.

Hopefully the next Popular modded Client will support it! excellent job Henningstone btw smile

Clan: Riot (I'm one of three leaders: Mile, Deku, pie)
Host teeworlds maps on a fng/ctf/dm/ddrace server for testing:http://riotproductions.tk/teewo/ broken-need reinstall nginx http://riotproductions.tk/bounce?whatEven, Teeworlds NA Discord chat

7

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Thanks for your feedback smile

Need to mention that the thing you can see is only a deep beta (I started coding this a few days ago); so much things will follow wink

8

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Just got edit boxes to work! The server can create one for the client, the player can enter text, and the server can then request the content of the editbox!
Pushed it into master branch, the binaries are also updated.

9

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Ok, I gotta say I love you so much for doing this big_smile. Always wanted something like that (https://github.com/teeworlds/teeworlds/ … -162983490). When it is out of beta or at least good enough I will probably make use of it for DDRaceNetwork. Oh and btw we should make this here that popular that nobody uses vanilla client and server anymore. Maybe like this devs could be convinced that they should open some more doors for nice modifications.

I will have a look at the sourcecode soon, can not wait to test it big_smile.

Luck is allowed

10

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Sounds very interesting! i will support it for h-client too when you finish a stable version tongue

11

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

thought h-client was dead ._.

Teeworlds [ friends ] clan
Some YouTube Stuff about Teeworlds

12 (edited by Henningstone 2015-12-14 22:23:31)

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Wow, if it would get implemented into some popular client (when developed further, of cause) would be very awesome indeed! The only problem is that the nethash must be faked then, or you won't be able to join servers anymore hmm

Also, I would be very happy about some kind fellow spending a bit of his spare free-time to get his hands onto this mod, fixing up a bit of my messy code where ever you may find something that could have been made in some better way... Unfortunately I don't have to much time for coding actively at the moment, only at nighttime ô_0
In near future I'm going to tell some things that I'm really not happy about like they are currently, but first I want to see how things will turn out when I add more GUI-elements smile
» GitHub: Henningstone/tw_netgui wink

13

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

have you considered making the netgui editable via config instead of just changing the code + recompile?

Clan: Riot (I'm one of three leaders: Mile, Deku, pie)
Host teeworlds maps on a fng/ctf/dm/ddrace server for testing:http://riotproductions.tk/teewo/ broken-need reinstall nginx http://riotproductions.tk/bounce?whatEven, Teeworlds NA Discord chat

14

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Yes of cause I thought about that, but for now I didn't think enough to make it working theoretically, so I can't code it practically. I may put it in practice using console commands, and maybe I'll even do it like that sometime. But for now my first aim is to get the backend working aswell as implementing more GUI elements and afterwards care about universal usability for non-dev-server-hoster big_smile

To cut a long story: you are right, it is quite inconvenient like it is now tongue

15

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

LUA + this = profit

Real programmers don't comment their code - it was hard to write, it should be hard to understand.
Proudly verkeckt since 2010.

16

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

xush wrote:

LUA + this = profit


+ GUIs not only in the Menu.

"Panos."
               -FuroS

17

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

An example "always up to date" server is online at 151.80.85.125:8080

Having troubles finding servers in the serverlist? Go to Pastebin (its a referer cause there is daily a new pastebin) and add the lines to your settings.cfg (in %APPDATA%\teeworlds). Then open teeworlds and go to the favorites tab. (Note however, standard teeworlds client can only show 256 favorites, use ddnet instead)

18 (edited by jxsl13 2015-12-15 21:29:05)

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

//deleted because ppl told me it was not funny ._.

Teeworlds [ friends ] clan
Some YouTube Stuff about Teeworlds

19 (edited by Henningstone 2015-12-15 21:48:37)

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

@Schwertspize: Hosting an example server is very kind of you, thanks a lot! Are you using the source of my master branch? I update it every day so that people can see always the latest progress smile

@jxsl13: I saw it anyway tongue Was funny. But way too big <(^_^(<

@FuroS: I also wanted the GUIs to be not only in the menu, but you won't be able to interact with them without your mouse unlocked yikes additionally, they may mess up your screen (especially for low-res). Or what'd you say to solve it?

20 (edited by Schwertspize 2015-12-15 22:20:51)

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

@Henningstone I think I messed it up. Btw you should not bring binaries into git.

Updates on this post following

Edit 1: I think the following happened. As I was talking to Neko (from TeeworldsNetwork) I set up your server and messed things up. I told him to set up a webhook so that auto-updates the server. Basically every push to TeeworldsNetwork would update your server. Creepy

Edit 2: I think I fixed it. Yes I am using the master branch but Henningstone look at your pm

Having troubles finding servers in the serverlist? Go to Pastebin (its a referer cause there is daily a new pastebin) and add the lines to your settings.cfg (in %APPDATA%\teeworlds). Then open teeworlds and go to the favorites tab. (Note however, standard teeworlds client can only show 256 favorites, use ddnet instead)

21 (edited by Henningstone 2015-12-15 23:07:08)

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

@Schwertspize: I am pushing binaries because I hate file hosters. So I'm abusing GitHub for it ^^ But they'll get removed when the mod gets really professional. Currently, I update them so that you can just quickly download 'em and try it out wink
// EDIT: If binaries mess up things with your webhooks or something, pls tell me and they'll get (re)moved instantly. I have no clue if something like this can happen...

2: Unfortunately, I don't have any pm' s in my inbox yikes Do you bother adding me to skype instead? Seems easier... (my skype name is also "henningstone", but searching for "Henritees" should work either.)

// EDIT 2: Ok, everything works fine now! You can now connect to 151.80.85.125:8080, kindly provided by Schwertspize, to test the latest stuff that had been done!
I am also looking to get some deploy service working to provide convenient and automatically updated executables (maybe even cross-platform, who knows… wink )

22

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Why don't you add the binaries always here: https://github.com/Henningstone/tw_netgui/releases

Luck is allowed

23

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Because I push updates every day, but making a release every day sucks >.<

24

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

- CLIENT Windows 32 bit <- coming soon! okay.....
http://troll-face.ru/static/images/okay_guy.jpg

YouTube channel -  http://www.youtube.com/c/TeeworldsnoFuny
Fun, Fun, Fun,Fun - more Fun big_smile
Rus Kanal Pe69ITki smile

25

Re: [MOD/0.7] NetGUI - embeddable networking GUIs! [new/beta]

Yeah, I wrote this 4 days ago, and I will NOT buy windows because you are too dumb to compile yourself... or just too lazy, who knows. Since I never came to the need of cross-compiling, that would also take me some time to get into it. So I decided to setup a CI + deploy when time has come, so that you can conveniently download the executables.
I hope you understand this.