New user interface

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

New user interface

Post by Expresso »

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.
User avatar
thepizzaking
Traffic Manager
Traffic Manager
Posts: 198
Joined: 08 Aug 2005 07:47
Location: Melbourne, Victoria, Australia
Contact:

Post by thepizzaking »

I know that 32 bit graphics for open ttd are on the way but I think its still a fair way off, I don't know how to code so I don't know if that would overwrite your coding
I'm A Cobra (or so the rumours go) :)
Get OpenTTD, It's awesome!!
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

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 :)
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."
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Is it possible to do it using Qt and opengl, thus being mac windows and linux compatable? Think i might see!
We Am De Best

Host of ThroughTheTube site
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Post by Expresso »

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).
Attachments
code.zip
(4.67 KiB) Downloaded 311 times
ganzpopp
Engineer
Engineer
Posts: 46
Joined: 20 Oct 2004 20:36
Location: The Netherlands

Post by ganzpopp »

can you post a screenshot?

i'm very curious....
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

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.
"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
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Post by Expresso »

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).
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

would it be able to make the tool bars "vertical"

i would love to be able to drag the building toolbars to the left, right top or bottom of the screen and have them clip onto the side. i would love to have as many cosntruction ones opne as i want, all cliped to the side...

Alltaken
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Any updates on this Expresso?
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."
User avatar
Yoeri
Route Supervisor
Route Supervisor
Posts: 470
Joined: 08 Aug 2005 13:42
Location: The Netherlands

Post by Yoeri »

Darkvater wrote:Any updates on this Expresso?
we can hardly wait :P
Image
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Post by Expresso »

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. :(
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Expresso 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. :(
We know it's spaghetti code, but it's getting unspaghettied with (almost) every commit :).

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."
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

I take development of this is put back into the fridge? ;)
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."
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Post by Expresso »

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 :cry:

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
fraker
Engineer
Engineer
Posts: 1
Joined: 04 Sep 2005 17:06

Post by fraker »

Expresso wrote: - Life cought up with me.
Heh I noticed. (",)
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

fraker, you joined just to post this :?:

anyway, is there someone willing to continue the project? (Too bad I can't understand a word of C. (I might in the future but that is a bit useless now)
MattW
Engineer
Engineer
Posts: 14
Joined: 14 Mar 2006 16:10

Post by MattW »

I'm thinking about it. No promises.

http://wiki.openttd.org/index.php/GUI_Redevelopment

and discussion on IRC.
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

'Your not authorized to view this page' message appears when clicking the link. :wink:
MattW
Engineer
Engineer
Posts: 14
Joined: 14 Mar 2006 16:10

Post by MattW »

The wiki was upgraded this afternoon, perhaps you tried it while it was down for that? It's working fine for me anyway.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests