Page 1 of 1

Smallmap screenshot (r18747)

Posted: 02 Aug 2009 15:35
by Roujin
This patch adds a new screenshot option - the smallmap screenshot.

It can be found in the menu where the normal and giant screenshot are also located, or invoked through the console with the command "screenshot smallmap [optional filename]".

This will produce a screenshot that looks like this:
Image

The latest version of the patch can be found here: [todo] (r18747)


-----
original post:

I'm currently trying to make a patch that introduces a new screenshot type that just creates a screenshot of the smallmap.
However, the graphics stuff is for me a pretty confusing mess right now. Documentation is scarce and I can only guess what some functions exactly do / parameters are exactly for.

Did someone already make such a patch previously that I'm not aware of?
Or, is there someone experienced with the graphics internals of OpenTTD that can and wants to help me out?

Currently, I have a compiling (but not working) WIP patch that's supposed to
* on "giant screenshot" click, call the new function for the smallmap screenshot (just for testing)
* create a new SmallMapWindow
* call its "DrawSmallMap" function that is supposed to draw the map onto the buffer that is written to file later

Unfortunately something seems to be way off, I'm getting an error in Memset, and I don't really know what went wrong where :( So if anyone wants to jump in and enlighten me, I'd be grateful :)
The patch (against 0.7.2):
EDIT: removed unfinished version. See below for working version of this patch


A bit of background info, I'm trying to do this so I can run another AI tournament without spending so much time on fitting together multiple pieces of the smallmap to one map...

Re: [Help needed] Trying to make a "smallmap screenshot"

Posted: 02 Aug 2009 17:18
by Terkhen
This patch does something similar, but the output does not look like an OpenTTD smallmap at all. I hope it helps, this feature is very interesting.

Re: [Help needed] Trying to make a "smallmap screenshot"

Posted: 02 Aug 2009 17:34
by Roujin
Thanks for the link, maybe I can make use of some parts of it. However for now I've solved the memset issue. Appearently it was caused by the program using one too many global variables for my taste, and me forgetting to set it to something appropriate beforehand.
For now I did manage to make a screenshot of a part of the smallmap, let's see if I can resolve the remaining issues soon :)
As soon as it's usable, I'm going to make it available for all to use...

However I regard this patch more as a "hack" than a proper patch - first of all there are some GUI questions I don't know how to address. e.g. the user should be able to select what kind of smallmap mode he wants to have a screenshot of. Right now I'm gonna hardcode it to the one I want.
Also where to put the new screenshot option? Where the current ones are? Or as a button in the smallmap window? Both? Neither? I dunno...

Re: Trying to make a "smallmap screenshot"

Posted: 02 Aug 2009 21:23
by Terkhen
In my opinion the best option is to put the new screenshot buttons directly in the smallmap window; that way you can use the current state of the smallmap to create the screenshot accordingly. These new buttons can't be too close to other buttons, though... if a user clicks accidentally in the giant smallmap screenshot button, he will waste a lot of time.

Re: Trying to make a "smallmap screenshot"

Posted: 02 Aug 2009 22:13
by Roujin
Hm, again I am too late reading your comment. :( I've been hacking over the last hours without internet access and only now checked back here and read your post.
For now I've added it to the dropdown where the other screenshot options already are, and added a keyboard shortcut similar to the others: Ctrl+M. I've also added a flag 'smallmap' to the existing console command 'screenshot'.

Here's the patch (against 0.7.2). A good point about it is that it doesn't change anything about the game state or the save format, so it should be completely multiplayer / save compatible with vanilla 0.7.2.

EDIT: I've made a v2 with a small bug fixed. As nobody has downloaded v1 yet I'll just put it here instead.
map_screen_0.7.2_v2.diff
smallmap screenshot v2 for 0.7.2
(8.78 KiB) Downloaded 172 times
known "issues":
* Using it opens a smallmap window or brings it to front if already opened.

Changelog:
v2:
Fix: Smallmap was not positioned correctly on non-quadratic map.

---
Have fun anyone who can use it. :)
Here's an example screenshot (of a 128x128 map with some AIs)
smallmap_screenshot.png
smallmap_screenshot.png (4.22 KiB) Viewed 4731 times
Another example screenshot that's trivial to make with my patch, but not so trivial without: a smallmap of a 2048x2048 map ;)
smallmap_screenshot_2.png
who can tell which color corresponds to which AI? ;)
(255.4 KiB) Downloaded 78 times

Re: Smallmap screenshot (r18747)

Posted: 07 Jan 2010 04:34
by Roujin
I updated the patch on request to current trunk (r18747).

Have fun.

Re: Smallmap screenshot (r18747)

Posted: 18 Jan 2010 17:59
by petert
Here is an update:

Re: Smallmap screenshot (r18747)

Posted: 04 Aug 2015 01:08
by JGR
This is a slight bump, however I've adapted the patch from the previous post to trunk (r27358), and made a few adjustments.
Changes include:
  • This uses an extra button in the smallmap window, instead of a console command
  • This uses the current zoom level and display mode of the smallmap window
The branch is here
An SVN diff is attached