Author Topic: Map viewer  (Read 448 times)

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Map viewer
« on: October 06, 2017, 12:15:23 PM »
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:
Code: [Select]
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
« Last Edit: October 17, 2017, 05:04:24 AM by jj2007 »

sinsi

  • Member
  • *****
  • Posts: 1005
Re: Map viewer
« Reply #1 on: October 06, 2017, 12:23:27 PM »
No indication of which part is currently selected (except by changing colour).
Name tooltip stays when changing map.
Where's Australia??? :biggrin:
I can walk on water but stagger on beer.

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #2 on: October 06, 2017, 12:32:48 PM »
No indication of which part is currently selected (except by changing colour).

This is by design 8)

Quote
Name tooltip stays when changing map.

Which Windows version? It changes on mine.

Quote
Where's Australia??? :biggrin:

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

sinsi

  • Member
  • *****
  • Posts: 1005
Re: Map viewer
« Reply #3 on: October 06, 2017, 12:38:51 PM »
Windows 10 Pro x64
I can walk on water but stagger on beer.

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #4 on: October 06, 2017, 05:35:14 PM »
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

  • Regular Member
  • *
  • Posts: 29
Re: Map viewer
« Reply #5 on: October 10, 2017, 01:12:38 PM »
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

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #6 on: October 10, 2017, 04:40:57 PM »
where are   British Nyasaland ... Rhodesia ...Tanganika ???? etc

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

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #7 on: October 16, 2017, 05:14:22 AM »
Version 2 attached, works with the maps above. Work in progress, the source is still too confused to be posted here :icon_redface:

felipe

  • Member
  • ***
  • Posts: 375
  • assemble the unassembled.
Re: Map viewer
« Reply #8 on: October 16, 2017, 10:19:00 AM »
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).
Felipe.

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #9 on: October 16, 2017, 02:47:09 PM »
Could not open
dmi

works with the maps above.

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

felipe

  • Member
  • ***
  • Posts: 375
  • assemble the unassembled.
Re: Map viewer
« Reply #10 on: October 17, 2017, 02:39:37 AM »
 :t Pretty nice, all worked fine, but the left and right arrow to change the country seems like don't.
Felipe.

jj2007

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #11 on: October 17, 2017, 05:07:30 AM »
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

  • Member
  • *****
  • Posts: 7756
  • Assembler is fun ;-)
    • MasmBasic
Re: Map viewer
« Reply #12 on: October 21, 2017, 10:01:01 PM »
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