FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.71k stars 395 forks source link

What would be the best method to implement collapsible GUI components? #603

Closed NilanthAnimosus closed 6 years ago

NilanthAnimosus commented 6 years ago

I figure there isn't too much of a bad reason to ask such a question so:

short of creating the GUI components from complete scratch it might not be such a bad idea to ask if there may be a simpler method to achieving this, essentially though I have an idea on something I might want to try implementing into vanilla if I can manage to redesign it (I have yet to fully theorize how I will go about that though yet).

Essentially though to put this into a more understanding visual (Picture this as a list of elements in the GUI):

[+] text item
[+] text item 2
[+] text item 3

and once expanded:

[+] text item
[-] text item 2
   this is the text for text item 2
   expanded out for reading without having paragraphs of information displayed at once

   The later elements in the list shift while its expanded.
[+] text item 3

I suppose a class with a frame containing a second frame (?) with two text block items with a bool to expand it and a click handler to toggle it from a "top frame" (or the + -) would be the fastest and best approach to this?

I feel such an expandable component could be used in various areas of the game where text is stored, especially info panels, crew summaries, characters in the lists of summaries and such.

Regalis11 commented 6 years ago

I'd probably do this with a listbox that holds all the text items and expanded texts as separate text blocks, hide the expanded texts (Visible = false), and create a button with a callback that toggles the visibility of the expanded texts. You might run into a bunch of issues with this though, the old GUI system is quite buggy and doesn't handle changes in the UI layout very well.

With the rewritten GUI system (again something that's not released yet) this would be much easier, you can for example change the scale of the components dynamically and use unity-style layout groups that automatically position the child components.

NilanthAnimosus commented 6 years ago

Yeah, I was planning to try to implement something for master than dev, I imagine it'd be a pain to implement into dev itself but I literally have not used or looked at dev's code.

Was thinking of redesigning parts of the mission system to allow for less linear structures, mixing and matching mission types in the same mission and in general more customization since I feel the mission system is one of the most lacking aspects of the current game (along with dev branch too).

Almost all the missions can just be defined as "A to B" with a singular task, the gameplay is nice but some nice mission structures I think would improve barotrauma a lot on modding and gameplay. been talking to other modders to get a better looking refinement of how the XMLs would look so after i've pushed out my mods code I could perhaps give this a little focus instead.

I think the listbox with 2 text blocks / item and a button is a fairly simple way of handling this though, thanks for the idea (saves me writing components just to handle it). I'd have to have the info tab able to display more information without displaying too much to do that though so this helps.