Smallmap screenshot (r18747)

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

Post Reply
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Smallmap screenshot (r18747)

Post 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...
Last edited by Roujin on 07 Jan 2010 04:29, edited 4 times in total.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

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

Post 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.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

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

Post 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...
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Trying to make a "smallmap screenshot"

Post 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.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Trying to make a "smallmap screenshot"

Post 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 360 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 7685 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
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Smallmap screenshot (r18747)

Post by Roujin »

I updated the patch on request to current trunk (r18747).

Have fun.
Attachments
map_screen_r18747.diff
smallmap screenshot for r18747
(8.13 KiB) Downloaded 353 times
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Smallmap screenshot (r18747)

Post by petert »

Here is an update:
Attachments
map_screen_r18862.diff
(8.13 KiB) Downloaded 240 times
map_screen_0.7.5.diff
(8.78 KiB) Downloaded 246 times
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: Smallmap screenshot (r18747)

Post 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
Attachments
smallmap-screenshot-r27358.patch
(8.89 KiB) Downloaded 173 times
Ex TTDPatch Coder
Patch Pack, Github
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests