News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Map viewer

Started by jj2007, October 06, 2017, 12:15:23 PM

Previous topic - Next topic

jj2007

Extract all files to a tmp folder, then start ArrayPlotMaps.exe and press F1 for help. So far tested on Win7-64 and XP. I am curious if it works on all systems ::)

Caution the maps are very old, I hope nobody is politically offended :bgrin:

The source is included (*.asc) but it won't build with the current MB version. The absolute minimum source would be as follows:include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyMap, "canvas"              ; create a dedicated new control ;-)
  GetFiles *.dmi
  ArrayLoadMap 0, Files$(0)

Event CanvasPaint
  ArrayPlot hWnd, RgbCol(100, 240, 255)         ; init with window (or control) handle and background colour
  PaintMap RgbCol(127, 127, 127), lines=2       ; display map with grey borders 2px thick
  ArrayPlot exit, "Map of "+Left$(Files$(0), Rinstr(Files$(0), ".")-1)       ; finish with a title

Event Message
  If_ uMsg==WM_MOUSEMOVE || uMsg==WM_LBUTTONDOWN Then <ArrayMapRegion(uMsg-WM_MOUSEMOVE)>         ; show tooltip
GuiEnd

sinsi

No indication of which part is currently selected (except by changing colour).
Name tooltip stays when changing map.
Where's Australia??? :biggrin:

jj2007

Quote from: sinsi on October 06, 2017, 12:23:27 PM
No indication of which part is currently selected (except by changing colour).

This is by design 8)

QuoteName tooltip stays when changing map.

Which Windows version? It changes on mine.

QuoteWhere's Australia??? :biggrin:

Oops, corrected above. Oceania.dmi was included but .map was missing :icon_redface:

sinsi


jj2007

Yep, I can reproduce that one on Win10-64 Home, and, with some luck, also on Win7-64. But it's only temporary, as soon as you move on to the next region, the correct name shows up. A non-issue imho but thanks for flagging it :icon14:

Will see if I find a "reset tooltips" command.

mikeburr

win 7 64   old HP keyboard [but quite feature rich]
map selection not working on mine [ie selection keys not working ]
could only get Africa ...the countries incidentally were not correct either ... where are   British Nyasaland ... Rhodesia ...Tanganika ???? etc 
tried various other methods of associating the DMI as well
couldn't run it under Linux/Wine either but thats not surprising ..
regards   mike b

jj2007

Quote from: mikeburr on October 10, 2017, 01:12:38 PMwhere are   British Nyasaland ... Rhodesia ...Tanganika ???? etc

When I wrote "the maps are very old", I meant the year 2000, not 1900 :P

jj2007

Version 2 attached, works with the maps above. Work in progress, the source is still too confused to be posted here :icon_redface:

felipe

i Get an error when tried to execute it:

FATAL ERROR:
Could not open
dmi
for Recall,FileRead$,etc.


:icon_exclaim: Windows 8.1 64 bits...(Don't have masmbasic installed). I downloaded the last version (v2).

jj2007

Quote from: felipe on October 16, 2017, 10:19:00 AMCould not open
dmi

Quote from: jj2007 on October 16, 2017, 05:14:22 AMworks with the maps above.

I didn't want to post the maps twice. Extract them to the folder where the new exe sits.

felipe

 :t Pretty nice, all worked fine, but the left and right arrow to change the country seems like don't.

jj2007

Thanks :P

I dropped the left-right thing because now you can select the country simply by clicking on it. Afterwards, the up-down arrays change the colour.

First post is updated with new version, including the source - 48 lines of code :biggrin:

jj2007

One more... needs the maps in the top post.

GuiParas equ "Two maps side by side - press F1 for help", x500, w766, h400, bcol white
include \masm32\MasmBasic\Res\MbGui.asm        ; requires MasmBasic[/url]; OPT_Icon Globe      ; RichMasm sets the icon
  GuiControl Left, "canvas", w500, +WS_EX_STATICEDGE
  GuiControl Right, "canvas", x500, w500, +WS_EX_STATICEDGE
  CanvasMap(0, 3)               ; Italy; canvas 0 gets initially map 5
  CanvasMap(1, 2)               ; Europe; canvas 1 gets map 2 (change with +/-)
  SetGlobals SDWORD currentMap, currentColour  ; two global variables for playing with colours
  GetFiles Cat$(CurDir$()+"*.dmi")
  For_ ecx=0 To Files$(?)-1
        ArrayLoadMap ecx, Files$(ecx), cbMaps   ; the callback function can, for example, modify the tooltips
  Next
  MapColours(3, String$(20, "abceghi"))         ; the abc... sets colours from the internal palette
  MapColours(3, 25, 27)         ; Italy, blue, Cuneo

Event CanvasPaint
  ArrayPlot hWnd_, RgbCol(0, 240, 255)  ; init with control handle and background colour
  PaintMap RgbCol(127, 127, 127), lines=2      ; display map with grey borders 2px thick
  ArrayPlot exit, "Map of "+Extract$(Files$(CanvasMap(hWnd_)), "\", ".", xsRinstrL)     ; finish with a title

Event Key
  Clr currentColour, currentMap
  .if VKey==VK_DOWN
        dec currentColour
  .elseif VKey==VK_UP
        inc currentColour
  .elseif VKey==VK_ADD
        inc currentMap
  .elseif VKey==VK_SUBTRACT
        dec currentMap
  .elseif VKey==VK_F1
        MsgBox 0, cfm$("click on a region to select it\n+, -\tnext map\nup, down\tchange colour\n\nhover over regions to see their names"), "Map viewer:", MB_OK or MB_TOPMOST
  .endif
  add currentMap, CanvasMap()
  .if currentMap>=0 && currentMap<Files$(?)
        CanvasMap(-1, currentMap)       ; -1: set map to active canvas control
        add currentColour, MapColours(currentMap, ?)
        movsx eax, Maps(currentMap, apRgnSelect)
        .if currentColour>=0 && currentColour<=31 && sdword ptr eax>=0
                MapColours(currentMap, currentColour, eax)
        .endif
        GuiRefresh
  .endif
EndOfEvents    ; **** any user procs below this line ****

cbMaps proc    ; current tooltip text passed in eax
  .if CurMap.mapIndex==3        ; map #3 is Italy (on my machine at least...)
        void Cat$(eax+" รจ una bella provincia")
  .else
        void Cat$(eax+" is a beautiful country")
  .endif
  ret
cbMaps endp
GuiEnd