Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old May 4, 2016, 16:00   #1
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
x11 major code cleanup

Hi Guys,

I've spent the last few days cleaning up the x11 front-end. You can find the changes here (it's not on a branch - I'll be paying the price for that later I'm sure)

In a nutshell:
  • MAJOR update of the coding style - the code is barely recognisable, but how it actually works has barely changed
  • Split the core X11 handling (anything to do with Display or Window) into x11-util.[h,c] - most of the functions here are x11_[display, window, color, font]_xxx(). There are a few ragedy names that still need a little finessing
  • All those ugly global have been removed
  • The Angband Term interface functions are now all x11_term_xxx()
  • Saving of window positions has been restored
  • The ALT modifier now works!!!
  • Lots of redundant/spurious/legacy code has been stripped out completely

The double-linked mapping between the Angband term structure and the x11 term data structure has been removed (this is a fairly significant change) - Now, an x11_term_data structure is allocated and assigned to term->data during term_data_init() - I believe this to be a much cleaner (and more in the spirit of having the data pointer in the term structure). The Angband term structures themselves are allocated in init_x11().

The x11 frontend is poised for a complete removal of the ANGBAND_TERM_MAX window limit, but that is going to impact violently on the Mac and SDL front ends (but not Windows???)

Anyway, take a look at what I've done - I'm more than happy to take the reigns of the x11 front end and fixing any bugs in it
calris is offline   Reply With Quote
Old May 5, 2016, 00:19   #2
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,832
Donated: $60
Nick is on a distinguished road
The general thrust of this is looking good. I haven't looked through it very closely, I'm afraid - I'm knee-deep in the curses feature branch, and RL is also a bit intrusive.

I will await others' comments, but all your changes seem to me to be heading in the right direction. Beyond the front ends, he main implications for removing ANGBAND_TERM_MAX are on the subwindow options screen, I think - the general idea of removing hardcoded limits I am strongly in favour of. And I certainly like making the x11 structures more like the other front ends - it has always been a pain having to re-learn the x11 stuff to make one small change.

If you are taking charge of this front end, here are a couple of things to think about:
  1. Graphics had to be removed because the code was not GPL compliant - takkaria knows the details of this better than me. Having them back in would be nice.
  2. Back around version 3.0.3, when the borg was still operational, a colleague of mine did some hacks to make the borg tie into xscreensaver. I have the basics of this here, based on roughly 3.3.0 code - possibly useless because of changes to input handling. It would be kind of nice to have xscreensaver support code in the x11 front end (a bit like the screensaver code in main-win.c) for if/when we have a functioning borg again, but this is really very speculative.

Don't take particularly number 2 too seriously
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old May 5, 2016, 06:33   #3
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Nick View Post
(Bits about sxscreensaver)

Don't take particularly number 2 too seriously
I would be amazed if anyone is actually using a screensaver these days -- other than "blank", obviously. I would even go so far as to argue that it would in fact morally wrong to do so given the amount of electrical power you would be wasting[1]. The only screensavers that this argument would (perhaps) not apply to would be Folding@Home and such.

[1] Obviously, this would mean that Angband would be morally wrong to include support for it.

Likewise, please take this as tongue-in-cheek. Though I actually do mean the underlying point seriously, I'm perhaps being a bit hyperbolic .
AnonymousHero is offline   Reply With Quote
Old May 5, 2016, 10:26   #4
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
OK, I did a naughty - I moved the x11 patches to a new branch (x11-rework) and did a forced push into my github repo. So if you pulled my repo, sorry, but I busted your copy.

From now on, you can get any x11 changes from here
calris is offline   Reply With Quote
Old May 5, 2016, 12:21   #5
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
Quote:
Originally Posted by Nick View Post
  • Graphics had to be removed because the code was not GPL compliant - takkaria knows the details of this better than me. Having them back in would be nice.
Just having a look at this now - If I get this working, somebody is going to owe me a beer - A very, very good beer - definitely NOT a VB or Fosters!
calris is offline   Reply With Quote
Old May 5, 2016, 23:07   #6
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,832
Donated: $60
Nick is on a distinguished road
Quote:
Originally Posted by calris View Post
OK, I did a naughty - I moved the x11 patches to a new branch (x11-rework) and did a forced push into my github repo. So if you pulled my repo, sorry, but I busted your copy.

From now on, you can get any x11 changes from here
Excellent. I'll wait and see how you go with the graphics
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old May 6, 2016, 07:41   #7
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
Quote:
Originally Posted by Nick View Post
Excellent. I'll wait and see how you go with the graphics
Don't hold your breath - I've got no idea what I'm doing

Well not entirely true - I've got code in the x11 front end to process the tile preference files and activating the term->pict_hook() function. But from here I'm a bit lost... Two things I need to sort out
  • Figuring out how the x and y coordinates x11_term_pict() relate to the term window. I've got the main window still drawing the text for the basic player stats on the left, but x11_term_pict() [i]appears[i] to use a new x=0,y=0 origin (which kind of makes sense, since the tiles will not be the same size as the fonts). My problem is, when a window is resized, we call Term_resize(cols, rows) which simply does not make sense when we have rows and columns with elements of two different sizes (fonts and tiles)
  • Loading the PNG, converting into a bitmap, and drawing a tile from the PNG onto the screen - This I think I can work out. The Windows front end uses the cross-platform libpng, so I can recycle code there and I'm sure there are plenty of x11 examples of copying images from one window to another. Colour palette may be an issue

EDIT: this seems to imply we just give the term dimensions in tile sizes and then place text according to the tile grid - I can do better than that

Last edited by calris; May 6, 2016 at 07:54.
calris is offline   Reply With Quote
Old May 6, 2016, 16:58   #8
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
Progress

EDIT: So the forum compressed the bejesus out of my screenshot... Basically I have the x11 front end processing the tile pref files, loading the select tileset, converting it to an XImage, and then plastering on the main window every time the term code asks to draw a tile. Now all I need to do is extract the x/y position of the request tile and past it on the right spot
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2016-05-07_00-56-13.jpg
Views:	140
Size:	19.4 KB
ID:	1410  
calris is offline   Reply With Quote
Old May 6, 2016, 18:10   #9
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
OK, I've pushed what I've done so far for x11 tile support into my x11-rework repo

There is a small change to main.c to get the -g arg working properly

I'm actually pretty impressed with myself - It's a patchwork of main-win.c and the pngbook files readpng2.c and rpng2-x.c

So far I've got the PNG file load and converted into an XImage and a rudimentary attempt at a t->pict_hook function. But something is seriously wrong with my understanding of how Angband term code maps to drawing tiles - the screenshot is of the town after I took a few steps - I was actually able to walk into a store

I think it is REALLY close

Hold the fort! - I just used another tileset (#1) and got the second screenshot! And tileset 3 gives me the third screenshot

Know I know it's close.

Can someone have a look at what I've done and see what needs to be done to make it 'perfect'

Cheers
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2016-05-07_02-01-58.jpg
Views:	116
Size:	9.9 KB
ID:	1412   Click image for larger version

Name:	Screenshot_2016-05-07_02-05-23.jpg
Views:	136
Size:	14.4 KB
ID:	1413   Click image for larger version

Name:	Screenshot_2016-05-07_02-07-16.jpg
Views:	127
Size:	21.0 KB
ID:	1414  
calris is offline   Reply With Quote
Old May 6, 2016, 18:42   #10
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,935
Donated: $40
takkaria is on a distinguished road
Hmm. I think the problem is that you're using the tile width and height instead of the text grid width and height to plot here. I think you should be using td->tile_width and td->tile_height instead to set w2/h2.
__________________
takkaria whispers something about options. -more-

Last edited by takkaria; May 7, 2016 at 03:38. Reason: fixed incorrect variable names
takkaria is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code (style) cleanup patches calris Development 5 April 24, 2016 04:33
major ood drop at 550 feet tynan Vanilla 5 April 20, 2014 11:10
Angband under X11 Magnate Vanilla 3 December 13, 2009 22:56
[Dev] I've located the cause of this major bug with fear. Irashtar Vanilla 0 August 31, 2008 12:04
[Dev] major Fear bug. Irashtar Vanilla 1 August 31, 2008 04:03


All times are GMT +1. The time now is 04:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.