News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

rather large gui translate patch

Started by kierongreen, October 21, 2013, 12:35:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kierongreen

http://simutrans-germany.com/files/upload/6844-gui-translate.zip

This arose from my patch to have clipping for scr_coord. However latest gui_theme updates means that adding those meant changing another bit of code and so on... So eventually I ended up with this - all (on screen) koords in gui are now scr_coord, zeichnen is draw, gr(oesse) is size, fenstergroesse is windowsize. The clipping is still buried in there somewhere too :p

Dwachs

I also thought of doing this.

One thought: should window size rather translate to scr_size instead of scr_coord? Would make the patch larger as the x and y fields have to change to w and h...
Parsley, sage, rosemary, and maggikraut.

kierongreen


prissi

I think it should indeed do size for most groesse and hence w and h instead x and y

Anyway, as most of the dialogue changes are out, please go ahead.

kierongreen

Ok new version this uses scr_size for almost all sizes - it's not actually that much bigger as most code was around parts already being patched.

I'm not entirely happy with the resulting code though - whereas scr_coord = scr_coord + scr_coord is fairly obvious, code now has scr_size + scr_coord = scr_size and scr_size + scr_size = scr_size (neither of which seem quite right to me, scr_size + scr_delta_size = scr_size seems most logical but that's yet another type which I'm certainly not suggesting!). There's also some parts where some hacks have to be used to convert back and forth between scr_size and scr coord. In some ways I wonder why scr_size was necessary at all but anyway...

http://simutrans-germany.com/files/upload/6848-gui-translate.zip

If people are happy with this then I'll commit.

prissi

If you have a scr_rect, operator magic allows you to extend its size by adding sizes and shift origins by adding coord. That obviously assumes that componenets and frames use scr_rect instead coor and sizes ...

Dwachs

#6
Imho These types naturally lend to the following operators

size + size = size
coord + size = coord
coord - coord = size

anything else should be not allowed:

coord + coord = ?? - at least one of them is an offset - aka size
size + coord = coord ???


Edit: I see the difficulty. Technically all the positions of gui elements are just offsets (not actual screen coordinates). In order to get this 'right', the element's positions need to an offset/size type instead of a coord type. But then all the + and - operations are sensible, so changing position to be scr_size does not offer any gain over the current implementation: which would be compiler-side checks whether certain stunts with coordinates are allowed...
Parsley, sage, rosemary, and maggikraut.

kierongreen

Quoteso changing position to be scr_size does not offer any gain over the current implementation: which would be compiler-side checks whether certain stunts with coordinates are allowed...
Indeed. However changing pairs of coordinates (pos, size) to rect does offer potential to tidy code.

I think I'll remove the scr_size changes by reverting to my 6844 patch and just add scr_rect instead where appropriate. Another thing I'm interested in is maybe merging clip_dimension with scr_rect. This might mean adding xx and yy to scr_rect but would allow considerable code tidying.

Dwachs

Why revert?

I took your patch further to completely get rid of the mix of koord and scr_*, see patch below.

http://simutrans-germany.com/files/upload/6849-gui-translate.zip
Parsley, sage, rosemary, and maggikraut.

prissi

Maybe the gui?... stuff should remove pos and groesse in favour of a scr_rect. get_pos() and set_pos() would still work, but think like getroffen would be much easier.

kierongreen

Quote from: prissi on October 23, 2013, 12:08:32 PM
Maybe the gui?... stuff should remove pos and groesse in favour of a scr_rect. get_pos() and set_pos() would still work, but think like getroffen would be much easier.
Yes that's what I was thinking. There's a few other places where code could be significantly tidied.

Quote from: Dwachs on October 23, 2013, 09:23:59 AM
Why revert?

I took your patch further to completely get rid of the mix of koord and scr_*, see patch below.

http://simutrans-germany.com/files/upload/6849-gui-translate.zip
Just wasn't especially happy with some bits of scr_size but if you've managed to sort that fantastic :) Will try to complete the rectangle conversion now...

Dwachs

any progress?

Should we throw in this patch?
Parsley, sage, rosemary, and maggikraut.

kierongreen


Dwachs

Then I would like to update the patch and commit it.

Any opinions?
Parsley, sage, rosemary, and maggikraut.

prissi

Well, I think the submission of the scaleable GUI might have broke this patch but no, please go ahead.

Dwachs

This is now in r6911. I hope, nothing is broken...
Parsley, sage, rosemary, and maggikraut.

prissi


kierongreen