[Patch] Enhanced minimap

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
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

[Patch] Enhanced minimap

Post by adf88 »

I merged and upgraded two patches:
- "Toggle terrain on minimap" by 3D_Grabber
- "Smallmap zoom/Minimap zoom" by NukeBuster

and that's how arose "Enhanced minimap" patch.
enhanced_minimap.png
enhanced_minimap.png (21.06 KiB) Viewed 7838 times
Features:
- zooming in and out
- show land height on every type of view

Changes to original "Toggle terrain on minimap":
- disabled industries are not shown
- contour view is enabled (by "unclicking" current view)
- height legend
Changes to original "Smallmap zoom/Minimap zoom":
- mouse scroll support
- enlarged vehicles are not just a dots
- every industry on "Industry" view is visible as at least two pixels (industries do not disappear when zooming out)
- zoom in/out buttons become disabled when reached maximum zoom level
Attachments
enhanced_minimap-r16579.patch
Patch for OTTD r16579 and latter
(36.77 KiB) Downloaded 166 times
enhanced_minimap-0.7.1.patch
Patch for OTTD 0.7.1
(34.74 KiB) Downloaded 199 times
Last edited by adf88 on 24 Jun 2009 08:04, edited 4 times in total.
:] don't worry, be happy and checkout my patches
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch] Enhenced minimap

Post by Terkhen »

Even if for my personal use I prefer both patches in a single file (trying to apply both patches without having to resolve rejects by hand has been one of the biggest problem I had with my latest patchpacks), probably they should be kept as separate files because they do different things. I love the new features, specially being able to scroll with the mouse. Also, you have a typo in the title: the correct name should be "Enhanced minimap".
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: [Patch] Enhenced minimap

Post by Eddi »

Terkhen wrote:they should be kept as separate files
one would typically handle that with a hg/git repository, patch queues, etc.

that way, one can update each patch individually, but easily generate a full patch(pack).
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [Patch] Enhanced minimap

Post by HackaLittleBit »

I just compiled this and it looks very nice. :bow:

Question though.
Would it not be possible to simply flip between normal game play and small map when changing amplification?
Yah Yah that would be perfect. :)
HackaLittleBit
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

But what exactly you mean ? Please, give more precise description.
:] don't worry, be happy and checkout my patches
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [Patch] Enhanced minimap

Post by HackaLittleBit »

Would it not be possible to simply flip between normal game play and small map when changing amplification?
Well the moment you loose usefull data. that is about the most zoomed in of the main screen. Automaticaly the zooming in (eg map getting smaller) would continue in full screen mode "small map" and then continue smaller and smaller (I use my mouse scroll button).

I hope you understand but simply zooming in and out continuous.
EDIT: And switching modes automatically

Regards
User avatar
Thief^
Route Supervisor
Route Supervisor
Posts: 469
Joined: 10 Oct 2004 00:11

Re: [Patch] Enhanced minimap

Post by Thief^ »

Now I have to unmerge smallmap zoom from my patchpack, so I can merge this in...

Thanks for this patch!
Melt with the Shadows,
Embrace your destiny...
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

Thief^ wrote:Now I have to unmerge smallmap zoom from my patchpack, so I can merge this in...
Unless other patch modified smallmap_gui.cpp this shouldn't be hard. Just revert this file to original and apply Enhanced Minimap. After that you'll need only revert changes made by "smallmap zoom" in other files. If you used this version you need only revert changes made to "ZoomLevel" enum in zoom_type.h.
I decided not to modify it. These modifications didn't fit there, and wasn't necessary. Instead of declaring new negative values I used original enum with negation operator in my code.
:] don't worry, be happy and checkout my patches
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

I found a bug, and fixed it. By mistake I changed two lines of "viewport" code. Scrolling zoomed out viewport was slower instead of faster - it was scrolling very slowly. Patches in the first post of this topic are fixed now. For those who applied a patch before this fix, I give only-bug-fix patches:
Attachments
emm_bugfix-0.7.1.patch
(604 Bytes) Downloaded 137 times
emm_bugfix-r16579.patch
(604 Bytes) Downloaded 163 times
:] don't worry, be happy and checkout my patches
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: [Patch] Enhanced minimap

Post by ic111 »

Hello,

I have just seen your patch.

I am currently trying to make the minimap support more heightlevels, i.e. if you click somewhere in the minimap the real map should scroll north according to the height at the point I clicked in minimap. With the current implementation of the minimap, if you click on the peak of some height mountain, you land somewhere on its ridge :-(

However, I have not yet found the link between minimap and the tiles - how can I determine which tile I clicked? Can you give me some hint?

Thanks.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

Hi.
I knew that Enhanced Minimap would collide with "more height levels". I even planned to write special implementation for this patch :) . I can do it if you want.

However, if you want do it by yourself, then do it :) .

You had to break something, Enhanced Minimap works fine alone. This is that piece of code (minimap click handle):
original:

Code: Select all

Point pt = RemapCoords(this->scroll_x, this->scroll_y, 0);
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
w->viewport->follow_vehicle = INVALID_VEHICLE;
w->viewport->dest_scrollpos_x = pt.x + ((_cursor.pos.x - this->left + 2) << 4) - (w->viewport->virtual_width >> 1);
w->viewport->dest_scrollpos_y = pt.y + ((_cursor.pos.y - this->top - 16) << 4) - (w->viewport->virtual_height >> 1); 
patched:

Code: Select all

Point pt = RemapCoords(this->scroll_x, this->scroll_y, 0);
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
w->viewport->follow_vehicle = INVALID_VEHICLE;
w->viewport->dest_scrollpos_x = pt.x + ScaleByZoom(((_cursor.pos.x - this->left + 2) << 4), this->zoom) - (w->viewport->virtual_width >> 1);
w->viewport->dest_scrollpos_y = pt.y + ScaleByZoom(((_cursor.pos.y - this->top - 16) << 4), this->zoom) - (w->viewport->virtual_height >> 1); 
And give me a link to the latest "more height levels" patch. I can't find it, your thread has 20 pages !
It's a good practice to keep latest patch in the first post of thread.
:] don't worry, be happy and checkout my patches
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Enhanced minimap

Post by ChillCore »

And give me a link to the latest "more height levels" patch. I can't find it, your thread has 20 pages !
It's a good practice to keep latest patch in the first post of thread.
Try the last page.
I have no access to the first post and I do not want to start a seperate branch so I hope we can keep it there for a while to come.
Current version is v15.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
2007Alain2007
Chief Executive
Chief Executive
Posts: 658
Joined: 11 Nov 2007 12:06
Contact:

Re: [Patch] Enhanced minimap

Post by 2007Alain2007 »

Great team work from you two i see keep up the good work
For Community Integrated Version http://code.google.com/p/civopenttd/
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: [Patch] Enhanced minimap

Post by ic111 »

adf88 wrote:Hi.
And give me a link to the latest "more height levels" patch. I can't find it, your thread has 20 pages !
It's a good practice to keep latest patch in the first post of thread.
I solved the problem I described here. Minimap should work with more heightlevels now.

You can find the patch (1) on the first page of the more heightlevels thread now (with the problem of ChillCore not being able to edit this) and (2) near the end of that thread. You are right, it contains more than 20 pages, but the last version is always near the end, so having a look at the last one or two pages should almost always suffice.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch] Enhanced minimap

Post by Terkhen »

I found a little bug, adf88. When using both the "Show vegetation" and "Show contours" buttons, the height legend is not shown.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

It's not a bug. Every tile has some vegetation, so there is no place for showing height. Grass could be replaced with height color, but what about other land types ? Snow, sand, I would have to make a special height palette for them, or leave them unchanged. So finally I decided to leave all types of land and do not show height on vegetation map.
What do you think about it ? Should it be done in other way ?
I realised now, that I should disable "show height" button when switching to vegetation view.
:] don't worry, be happy and checkout my patches
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch] Enhanced minimap

Post by Terkhen »

That sounds very logical: I should have checked "the bug" more before posting it. Your solution is good, disabling the height button when the vegetation is active should be enough.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [Patch] Enhanced minimap

Post by adf88 »

Actually you found a bug. You could expect that height should be displayed if the button can be pressed ;)
Patches are fixed now. Added one line to smallmap_gui.cpp:

---------------------------------------------------------------------
  • this->map_type = (SmallMapType)(widget - SM_WIDGET_CONTOUR);
    this->LowerWidget(widget);
}
this->SetWidgetDisabledState(SM_WIDGET_CONTOUR, this->map_type == SMT_VEGETATION);
this->ResizeLegend();

this->SetDirty();
---------------------------------------------------------------------
:] don't worry, be happy and checkout my patches
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 21 guests