New user interface
Moderator: OpenTTD Developers
New user interface
I've just started coding on openttd and discovered the user interface is quite static and hackish, so I decided to try to whip up a replaced for the current user interface.
But...
there are a few issues at hand here:
The first is that I don't know if any attempt to replace that blob of spaghetti code is already on its way and my efforts would be wasted on this.
The 2nd issue:
In its current implementation my code uses dynamic arrays quite often. This has the advantage of (in theory) allowing infinite child widgets. This also has the disadvantage of (possibly) causing memory fragmentation.
Now, I could redesign my code to use the memory pool, but I'm not sure about the impact that would have on performance (the struct wouldn't need modification, but the code adding and/or deleteing widgets would).
The code I created would increase flexebility of the user interface dramatically, but would also require a complete redesign of (nearly) everything makeing use of the user interface, since its quite different from what's in use now.
I'm not posting the code yet, since it's at a very early stage - it currently only manages the widgets and passes events through to the right widget.
But...
there are a few issues at hand here:
The first is that I don't know if any attempt to replace that blob of spaghetti code is already on its way and my efforts would be wasted on this.
The 2nd issue:
In its current implementation my code uses dynamic arrays quite often. This has the advantage of (in theory) allowing infinite child widgets. This also has the disadvantage of (possibly) causing memory fragmentation.
Now, I could redesign my code to use the memory pool, but I'm not sure about the impact that would have on performance (the struct wouldn't need modification, but the code adding and/or deleteing widgets would).
The code I created would increase flexebility of the user interface dramatically, but would also require a complete redesign of (nearly) everything makeing use of the user interface, since its quite different from what's in use now.
I'm not posting the code yet, since it's at a very early stage - it currently only manages the widgets and passes events through to the right widget.
- thepizzaking
- Traffic Manager
- Posts: 198
- Joined: 08 Aug 2005 07:47
- Location: Melbourne, Victoria, Australia
- Contact:
Well 32bpp won't change much on the widget system itself. If it does it'll only change how the drawing is done (perhaps using graphics/images instead of the drawing routines done now).
Dynamic arrays are nice but they always carry the surplus riscs of memory problems, etc. The memorypool is pretty fast (remember it is used for vehicles, station, etc.).
What you could do is get the framwork done and change one example GUI and leave all the others alone. This will show off capabilities while not needing an insane amount of work just to get it to work. Perhaps a newwidgethandler and an oldwidgethandler (instead of commenting out things).
I wanted to do some widget coding myself as well, but haven't had the time. So if you have time, could you perhaps add the feature that click events are only transmitted on mouse-up? Eg when the button is released.
I'd love to see screenshot, but I don't think anything changes externally
Dynamic arrays are nice but they always carry the surplus riscs of memory problems, etc. The memorypool is pretty fast (remember it is used for vehicles, station, etc.).
What you could do is get the framwork done and change one example GUI and leave all the others alone. This will show off capabilities while not needing an insane amount of work just to get it to work. Perhaps a newwidgethandler and an oldwidgethandler (instead of commenting out things).
I wanted to do some widget coding myself as well, but haven't had the time. So if you have time, could you perhaps add the feature that click events are only transmitted on mouse-up? Eg when the button is released.
I'd love to see screenshot, but I don't think anything changes externally

TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Well, here's the code I have until now... not much, but at least something (it doesn't do much though).
This code should help get my idea across, although it doesn't do anything productive atm (has some errors, no main function, etc.)
In other words: this is far from finished.
also, I put it in a seperate directory, since the UI seemed to be the next logical thing to give its own directory (there are currently about 30 files dealing with the user interface).
This code should help get my idea across, although it doesn't do anything productive atm (has some errors, no main function, etc.)
In other words: this is far from finished.
also, I put it in a seperate directory, since the UI seemed to be the next logical thing to give its own directory (there are currently about 30 files dealing with the user interface).
- Attachments
-
- code.zip
- (4.67 KiB) Downloaded 311 times
You're probably making progress faster than anybody else (I don't even know if anybody else is actively working on it), so I say go ahead and finish it.
Edit: And don't worry about speed too much, OpenTTD doesn't have any speed problems at all except for the AI.
Edit: And don't worry about speed too much, OpenTTD doesn't have any speed problems at all except for the AI.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
Well, it's proving more difficult as I thought.
Creating and destroying widgets didn't seem to be the problem - that's done now.
But there are areas which need thought and I'm getting at those now... will probably take a while to get that right.
Actually implementing graphics functionality is the final stage. There are things which need to be worked out first... if I start posting screenshots it'll probably be at the final stage (will probably take a while until I'm there, though).
Creating and destroying widgets didn't seem to be the problem - that's done now.
But there are areas which need thought and I'm getting at those now... will probably take a while to get that right.
Actually implementing graphics functionality is the final stage. There are things which need to be worked out first... if I start posting screenshots it'll probably be at the final stage (will probably take a while until I'm there, though).
We know it's spaghetti code, but it's getting unspaghettied with (almost) every commitExpresso wrote:Well, this may take quite a bit longer then I thought it would take.
I've currently got two words left for openttd: "spaghetti code" (sorry, devs). I've been trying to unravel it and understand what's happening in there, but... well, that's not easy (understatement). Sorry it's taking that long.

C is just more prone to spaghetti code than object oriented languages.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
The issue at hand for me is twofold:
- Life cought up with me.
- Started codeing and discovered I set my mind on a too big project (foolish me).
I'm sorry for keeping you ppl in the dark on this, but I was uncertain if I would be able to continue or not. As it turns out, I'm unable to continue
If somebody else wants to pick this up it's fine with me.
Contents of the attachment:
user_input.{c,h} was intended to handle mouse and keyboard input, as well as their bindings (key/button x binds to event/widget y). Currently it only handles x mousebuttons... but it defines a mouse button release event and is able to handle multiple buttons gracefully
new_widget.{c,h} This one implements the basic widget manager. The actual widgets themselves should be put in seperate files to keep things readable. Code might need some syntactic correction and tweaking, but should function fine.
Note: I didn't make a link to the rest of the code yet, since it is still at a too early stage (mouse handling might be implemented, though... not much work).
The code is stuffed with comments, so that'll help you along.
Wish I was able to see this through to the end
- Life cought up with me.
- Started codeing and discovered I set my mind on a too big project (foolish me).
I'm sorry for keeping you ppl in the dark on this, but I was uncertain if I would be able to continue or not. As it turns out, I'm unable to continue

If somebody else wants to pick this up it's fine with me.
Contents of the attachment:
user_input.{c,h} was intended to handle mouse and keyboard input, as well as their bindings (key/button x binds to event/widget y). Currently it only handles x mousebuttons... but it defines a mouse button release event and is able to handle multiple buttons gracefully

new_widget.{c,h} This one implements the basic widget manager. The actual widgets themselves should be put in seperate files to keep things readable. Code might need some syntactic correction and tweaking, but should function fine.
Note: I didn't make a link to the rest of the code yet, since it is still at a too early stage (mouse handling might be implemented, though... not much work).
The code is stuffed with comments, so that'll help you along.
Wish I was able to see this through to the end

- Attachments
-
- code.tar.bz2
- (3.22 KiB) Downloaded 270 times
-
- Tycoon
- Posts: 11501
- Joined: 20 Sep 2004 22:45
I'm thinking about it. No promises.
http://wiki.openttd.org/index.php/GUI_Redevelopment
and discussion on IRC.
http://wiki.openttd.org/index.php/GUI_Redevelopment
and discussion on IRC.
-
- Tycoon
- Posts: 11501
- Joined: 20 Sep 2004 22:45
Who is online
Users browsing this forum: No registered users and 2 guests