@@ -7,6 +7,7 @@ Date: 11th March 2010
7
7
Amended: 15th August 2010
8
8
Amended: 2nd October 2010
9
9
Amended: 18th October 2010 to added find callback
10
+ Amended: 16th November 2010 to add symbolic constants (miniwin.xxxx)
10
11
11
12
Generic MUD mapper.
12
13
@@ -63,7 +64,7 @@ Room info should include:
63
64
64
65
module (... , package.seeall )
65
66
66
- VERSION = 2.2 -- for querying by plugins
67
+ VERSION = 2.3 -- for querying by plugins
67
68
68
69
require " movewindow"
69
70
require " copytable"
@@ -312,7 +313,7 @@ local function draw_configuration ()
312
313
local frame_width = GAP + width + GAP + rh_size + GAP -- gap / text / gap / box / gap
313
314
314
315
-- fill entire box with grey
315
- WindowRectOp (win , 2 , x , y , x + frame_width , y + font_height * lines + 10 , 0xDCDCDC )
316
+ WindowRectOp (win , miniwin . rect_fill , x , y , x + frame_width , y + font_height * lines + 10 , 0xDCDCDC )
316
317
-- frame it
317
318
draw_3d_box (win , x , y , frame_width , font_height * lines + 10 )
318
319
@@ -323,19 +324,37 @@ local function draw_configuration ()
323
324
WindowText (win , FONT_ID , " Configuration" , x , y , 0 , 0 , 0x808080 , true )
324
325
325
326
-- close box
326
- WindowRectOp (win , 1 , x + frame_width - box_size - GAP * 2 , y + 1 ,
327
- x + frame_width - GAP * 2 , y + 1 + box_size , 0x808080 )
328
- WindowLine (win , x + frame_width - box_size - GAP * 2 + 3 , y + 4 ,
329
- x + frame_width - GAP * 2 - 3 , y - 2 + box_size , 0x808080 , 0 , 1 )
330
- WindowLine (win , x - 4 + frame_width - GAP * 2 , y + 4 ,
331
- x - 1 + frame_width - box_size - GAP * 2 + 3 , y - 2 + box_size , 0x808080 , 0 , 1 )
327
+ WindowRectOp (win ,
328
+ miniwin .rect_frame ,
329
+ x + frame_width - box_size - GAP * 2 ,
330
+ y + 1 ,
331
+ x + frame_width - GAP * 2 ,
332
+ y + 1 + box_size ,
333
+ 0x808080 )
334
+ WindowLine (win ,
335
+ x + frame_width - box_size - GAP * 2 + 3 ,
336
+ y + 4 ,
337
+ x + frame_width - GAP * 2 - 3 ,
338
+ y - 2 + box_size ,
339
+ 0x808080 ,
340
+ miniwin .pen_solid , 1 )
341
+ WindowLine (win ,
342
+ x - 4 + frame_width - GAP * 2 ,
343
+ y + 4 ,
344
+ x - 1 + frame_width - box_size - GAP * 2 + 3 ,
345
+ y - 2 + box_size ,
346
+ 0x808080 ,
347
+ miniwin .pen_solid , 1 )
332
348
333
349
-- close configuration hotspot
334
350
WindowAddHotspot (win , " $<close_configure>" ,
335
- x + frame_width - box_size - GAP * 2 , y + 1 , x + frame_width - GAP * 2 , y + 1 + box_size , -- rectangle
351
+ x + frame_width - box_size - GAP * 2 ,
352
+ y + 1 ,
353
+ x + frame_width - GAP * 2 ,
354
+ y + 1 + box_size , -- rectangle
336
355
" " , " " , " " , " " , " mapper.mouseup_close_configure" , -- mouseup
337
356
" Click to close" ,
338
- 1 , 0 ) -- hand cursor
357
+ miniwin . cursor_hand , 0 ) -- hand cursor
339
358
340
359
y = y + font_height
341
360
@@ -344,15 +363,31 @@ local function draw_configuration ()
344
363
for k , v in pairsByKeys (config ) do
345
364
if v .colour then
346
365
WindowText (win , FONT_ID , v .name , x , y , 0 , 0 , 0x000000 , true )
347
- WindowRectOp (win , 2 , x + width + rh_size / 2 , y + 1 , x + width + rh_size / 2 + box_size , y + 1 + box_size , v .colour )
348
- WindowRectOp (win , 1 , x + width + rh_size / 2 , y + 1 , x + width + rh_size / 2 + box_size , y + 1 + box_size , 0x000000 )
366
+ WindowRectOp (win ,
367
+ miniwin .rect_fill ,
368
+ x + width + rh_size / 2 ,
369
+ y + 1 ,
370
+ x + width + rh_size / 2 + box_size ,
371
+ y + 1 + box_size ,
372
+ v .colour )
373
+ WindowRectOp (win ,
374
+ miniwin .rect_frame ,
375
+ x + width + rh_size / 2 ,
376
+ y + 1 ,
377
+ x + width + rh_size / 2 + box_size ,
378
+ y + 1 + box_size ,
379
+ 0x000000 )
349
380
350
381
-- colour change hotspot
351
- WindowAddHotspot (win , " $colour:" .. k ,
352
- x + GAP , y + 1 , x + width + rh_size / 2 + box_size , y + 1 + box_size , -- rectangle
382
+ WindowAddHotspot (win ,
383
+ " $colour:" .. k ,
384
+ x + GAP ,
385
+ y + 1 ,
386
+ x + width + rh_size / 2 + box_size ,
387
+ y + 1 + box_size , -- rectangle
353
388
" " , " " , " " , " " , " mapper.mouseup_change_colour" , -- mouseup
354
389
" Click to change colour" ,
355
- 1 , 0 ) -- hand cursor
390
+ miniwin . cursor_hand , 0 ) -- hand cursor
356
391
357
392
y = y + font_height
358
393
end -- a colour item
@@ -361,63 +396,83 @@ local function draw_configuration ()
361
396
362
397
-- depth
363
398
WindowText (win , FONT_ID , " Depth" , x , y , 0 , 0 , 0x000000 , true )
364
- WindowText (win , FONT_ID_UL , tostring (config .SCAN .depth ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
399
+ WindowText (win , FONT_ID_UL , tostring (config .SCAN .depth ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
365
400
366
401
-- depth hotspot
367
- WindowAddHotspot (win , " $<depth>" ,
368
- x + GAP , y , x + frame_width , y + font_height , -- rectangle
402
+ WindowAddHotspot (win ,
403
+ " $<depth>" ,
404
+ x + GAP ,
405
+ y ,
406
+ x + frame_width ,
407
+ y + font_height , -- rectangle
369
408
" " , " " , " " , " " , " mapper.mouseup_change_depth" , -- mouseup
370
409
" Click to change scan depth" ,
371
- 1 , 0 ) -- hand cursor
410
+ miniwin . cursor_hand , 0 ) -- hand cursor
372
411
y = y + font_height
373
412
374
413
-- font
375
414
WindowText (win , FONT_ID , " Font" , x , y , 0 , 0 , 0x000000 , true )
376
- WindowText (win , FONT_ID_UL , config .FONT .name .. " " .. config .FONT .size , x + width + GAP , y , 0 , 0 , 0x808080 , true )
415
+ WindowText (win , FONT_ID_UL , config .FONT .name .. " " .. config .FONT .size , x + width + GAP , y , 0 , 0 , 0x808080 , true )
377
416
378
417
-- colour font hotspot
379
- WindowAddHotspot (win , " $<font>" ,
380
- x + GAP , y , x + frame_width , y + font_height , -- rectangle
418
+ WindowAddHotspot (win ,
419
+ " $<font>" ,
420
+ x + GAP ,
421
+ y ,
422
+ x + frame_width ,
423
+ y + font_height , -- rectangle
381
424
" " , " " , " " , " " , " mapper.mouseup_change_font" , -- mouseup
382
425
" Click to change font" ,
383
- 1 , 0 ) -- hand cursor
426
+ miniwin . cursor_hand , 0 ) -- hand cursor
384
427
y = y + font_height
385
428
386
429
387
430
-- width
388
431
WindowText (win , FONT_ID , " Width" , x , y , 0 , 0 , 0x000000 , true )
389
- WindowText (win , FONT_ID_UL , tostring (config .WINDOW .width ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
432
+ WindowText (win , FONT_ID_UL , tostring (config .WINDOW .width ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
390
433
391
434
-- width hotspot
392
- WindowAddHotspot (win , " $<width>" ,
393
- x + GAP , y , x + frame_width , y + font_height , -- rectangle
435
+ WindowAddHotspot (win ,
436
+ " $<width>" ,
437
+ x + GAP ,
438
+ y ,
439
+ x + frame_width ,
440
+ y + font_height , -- rectangle
394
441
" " , " " , " " , " " , " mapper.mouseup_change_width" , -- mouseup
395
442
" Click to change window width" ,
396
- 1 , 0 ) -- hand cursor
443
+ miniwin . cursor_hand , 0 ) -- hand cursor
397
444
y = y + font_height
398
445
399
446
-- height
400
447
WindowText (win , FONT_ID , " Height" , x , y , 0 , 0 , 0x000000 , true )
401
- WindowText (win , FONT_ID_UL , tostring (config .WINDOW .height ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
448
+ WindowText (win , FONT_ID_UL , tostring (config .WINDOW .height ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
402
449
403
450
-- height hotspot
404
- WindowAddHotspot (win , " $<height>" ,
405
- x + GAP , y , x + frame_width , y + font_height , -- rectangle
451
+ WindowAddHotspot (win ,
452
+ " $<height>" ,
453
+ x + GAP ,
454
+ y ,
455
+ x + frame_width ,
456
+ y + font_height , -- rectangle
406
457
" " , " " , " " , " " , " mapper.mouseup_change_height" , -- mouseup
407
458
" Click to change window height" ,
408
- 1 , 0 ) -- hand cursor
459
+ miniwin . cursor_hand , 0 ) -- hand cursor
409
460
y = y + font_height
410
461
411
462
-- delay
412
463
WindowText (win , FONT_ID , " Walk delay" , x , y , 0 , 0 , 0x000000 , true )
413
- WindowText (win , FONT_ID_UL , tostring (config .DELAY .time ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
464
+ WindowText (win , FONT_ID_UL , tostring (config .DELAY .time ), x + width + GAP , y , 0 , 0 , 0x808080 , true )
414
465
415
466
-- height hotspot
416
- WindowAddHotspot (win , " $<delay>" ,
417
- x + GAP , y , x + frame_width , y + font_height , -- rectangle
467
+ WindowAddHotspot (win ,
468
+ " $<delay>" ,
469
+ x + GAP ,
470
+ y ,
471
+ x + frame_width ,
472
+ y + font_height , -- rectangle
418
473
" " , " " , " " , " " , " mapper.mouseup_change_delay" , -- mouseup
419
474
" Click to change speedwalk delay" ,
420
- 1 , 0 ) -- hand cursor
475
+ miniwin . cursor_hand , 0 ) -- hand cursor
421
476
y = y + font_height
422
477
423
478
end -- draw_configuration
@@ -519,7 +574,7 @@ local function draw_room (uid, path, x, y)
519
574
end -- if down
520
575
521
576
if exit_info then
522
- local linetype = 0 -- unbroken
577
+ local linetype = miniwin . pen_solid -- unbroken
523
578
local linewidth = 1 -- not recent
524
579
525
580
-- try to cache room
@@ -528,7 +583,7 @@ local function draw_room (uid, path, x, y)
528
583
end -- if
529
584
530
585
if rooms [exit_uid ].unknown then
531
- linetype = 2 -- dots
586
+ linetype = miniwin . pen_dot -- dots
532
587
end -- if
533
588
534
589
local next_x = x + exit_info .at [1 ] * (ROOM_SIZE + DISTANCE_TO_NEXT_ROOM )
@@ -548,7 +603,7 @@ local function draw_room (uid, path, x, y)
548
603
549
604
-- here if room leads back to itself
550
605
exit_info = stub_exit_info
551
- linetype = 1 -- dash
606
+ linetype = miniwin . pen_dash -- dash
552
607
553
608
else
554
609
if (not show_other_areas and rooms [exit_uid ].area ~= current_area ) or
@@ -559,7 +614,7 @@ local function draw_room (uid, path, x, y)
559
614
if plan_to_draw [exit_uid ] and plan_to_draw [exit_uid ] ~= next_coords then
560
615
-- here if room already going to be drawn
561
616
exit_info = stub_exit_info
562
- linetype = 1 -- dash
617
+ linetype = miniwin . pen_dash -- dash
563
618
else
564
619
-- remember to draw room next iteration
565
620
local new_path = copytable .deep (path )
@@ -579,7 +634,7 @@ local function draw_room (uid, path, x, y)
579
634
end -- if
580
635
end -- if
581
636
end -- if
582
- end -- f
637
+ end -- if
583
638
end -- if drawn on this spot
584
639
585
640
WindowLine (win , x + exit_info .x1 , y + exit_info .y1 , x + exit_info .x2 , y + exit_info .y2 , exit_line_colour , linetype , linewidth )
@@ -601,7 +656,10 @@ local function draw_room (uid, path, x, y)
601
656
y + arrow [6 ])
602
657
603
658
-- draw arrow
604
- WindowPolygon (win , points , exit_line_colour , 0 , 1 , exit_line_colour , 0 , true , true )
659
+ WindowPolygon (win , points ,
660
+ exit_line_colour , miniwin .pen_solid , 1 ,
661
+ exit_line_colour , miniwin .brush_solid ,
662
+ true , true )
605
663
606
664
end -- one way
607
665
@@ -612,33 +670,33 @@ local function draw_room (uid, path, x, y)
612
670
613
671
614
672
if room .unknown then
615
- WindowCircleOp (win , 2 , left , top , right , bottom ,
616
- config .UNKNOWN_ROOM_COLOUR .colour , 2 , 1 , -- dotted single pixel pen
617
- - 1 , 1 ) -- no brush
673
+ WindowCircleOp (win , miniwin . circle_rectangle , left , top , right , bottom ,
674
+ config .UNKNOWN_ROOM_COLOUR .colour , miniwin . pen_dot , 1 , -- dotted single pixel pen
675
+ - 1 , miniwin . brush_null ) -- opaque, no brush
618
676
else
619
- WindowCircleOp (win , 2 , left , top , right , bottom ,
620
- 0 , 5 , 0 , -- no pen
677
+ WindowCircleOp (win , miniwin . circle_rectangle , left , top , right , bottom ,
678
+ 0 , miniwin . pen_null , 0 , -- no pen
621
679
room .fillcolour , room .fillbrush ) -- brush
622
680
623
- WindowCircleOp (win , 2 , left , top , right , bottom ,
681
+ WindowCircleOp (win , miniwin . circle_rectangle , left , top , right , bottom ,
624
682
room .bordercolour , room .borderpen , room .borderpenwidth , -- pen
625
- - 1 , 1 ) -- no brush
683
+ - 1 , miniwin . brush_null ) -- opaque, no brush
626
684
end -- if
627
685
628
686
629
687
-- show up and down in case we can't get a line in
630
688
631
689
if room .exits .u then -- line at top
632
- WindowLine (win , left , top , left + ROOM_SIZE , top , config .EXIT_COLOUR_UP_DOWN .colour , 0 , 1 )
690
+ WindowLine (win , left , top , left + ROOM_SIZE , top , config .EXIT_COLOUR_UP_DOWN .colour , miniwin . pen_solid , 1 )
633
691
end -- if
634
692
if room .exits .d then -- line at bottom
635
- WindowLine (win , left , bottom , left + ROOM_SIZE , bottom , config .EXIT_COLOUR_UP_DOWN .colour , 0 , 1 )
693
+ WindowLine (win , left , bottom , left + ROOM_SIZE , bottom , config .EXIT_COLOUR_UP_DOWN .colour , miniwin . pen_solid , 1 )
636
694
end -- if
637
695
if room .exits [' in' ] then -- line at right
638
- WindowLine (win , left + ROOM_SIZE , top , left + ROOM_SIZE , bottom , config .EXIT_COLOUR_IN_OUT .colour , 0 , 1 )
696
+ WindowLine (win , left + ROOM_SIZE , top , left + ROOM_SIZE , bottom , config .EXIT_COLOUR_IN_OUT .colour , miniwin . pen_solid , 1 )
639
697
end -- if
640
698
if room .exits .out then -- line at left
641
- WindowLine (win , left , top , left , bottom , config .EXIT_COLOUR_IN_OUT .colour , 0 , 1 )
699
+ WindowLine (win , left , top , left , bottom , config .EXIT_COLOUR_IN_OUT .colour , miniwin . pen_solid , 1 )
642
700
end -- if
643
701
644
702
speedwalks [uid ] = path -- so we know how to get here
@@ -651,7 +709,7 @@ local function draw_room (uid, path, x, y)
651
709
" " , -- cancelmousedown
652
710
" mapper.mouseup_room" , -- mouseup
653
711
room .hovermessage ,
654
- 1 , 0 ) -- hand cursor
712
+ miniwin . cursor_hand , 0 ) -- hand cursor
655
713
656
714
end -- draw_room
657
715
@@ -706,23 +764,23 @@ local function draw_zone_exit (exit)
706
764
local offset = ROOM_SIZE
707
765
708
766
-- draw circle around us
709
- WindowCircleOp (win , 1 ,
767
+ WindowCircleOp (win , miniwin . circle_ellipse ,
710
768
x - offset , y - offset ,
711
769
x + offset , y + offset ,
712
770
ColourNameToRGB " cornflowerblue" , -- pen colour
713
- 0 , -- solid pen
771
+ miniwin . pen_solid , -- solid pen
714
772
3 , -- pen width
715
773
0 , -- brush colour
716
- 1 ) -- null brush
774
+ miniwin . brush_null ) -- null brush
717
775
718
- WindowCircleOp (win , 1 ,
776
+ WindowCircleOp (win , miniwin . circle_ellipse ,
719
777
x - offset , y - offset ,
720
778
x + offset , y + offset ,
721
779
ColourNameToRGB " cyan" , -- pen colour
722
- 0 , -- solid pen
780
+ miniwin . pen_solid , -- solid pen
723
781
1 , -- pen width
724
782
0 , -- brush colour
725
- 1 ) -- null brush
783
+ miniwin . brush_null ) -- null brush
726
784
727
785
end -- draw_zone_exit
728
786
@@ -970,7 +1028,7 @@ function draw (uid)
970
1028
" " , -- cancelmousedown
971
1029
" mapper.mouseup_configure" , -- mouseup
972
1030
" Click to configure map" ,
973
- 1 , 0 ) -- hand cursor
1031
+ miniwin . cursor_hand , 0 ) -- hand cursor
974
1032
end -- if
975
1033
976
1034
if type (show_help ) == " function" then
@@ -992,7 +1050,7 @@ function draw (uid)
992
1050
" " , -- cancelmousedown
993
1051
" mapper.show_help" , -- mouseup
994
1052
" Click for help" ,
995
- 1 , 0 ) -- hand cursor
1053
+ miniwin . cursor_hand , 0 ) -- hand cursor
996
1054
end -- if
997
1055
998
1056
-- 3D box around whole thing
@@ -1061,7 +1119,7 @@ function init (t)
1061
1119
font_height = WindowFontInfo (win , FONT_ID , 1 ) -- height
1062
1120
1063
1121
-- find where window was last time
1064
- windowinfo = movewindow .install (win , 7 )
1122
+ windowinfo = movewindow .install (win , miniwin . pos_center_right )
1065
1123
1066
1124
-- calculate box sizes, arrows, connecting lines etc.
1067
1125
build_room_info ()
@@ -1376,7 +1434,7 @@ end -- cancel_speedwalk
1376
1434
function mouseup_room (flags , hotspot_id )
1377
1435
local uid = hotspot_id
1378
1436
1379
- if bit .band (flags , 0x20 ) ~= 0 then
1437
+ if bit .band (flags , miniwin . hotspot_got_rh_mouse ) ~= 0 then
1380
1438
1381
1439
-- RH click
1382
1440
@@ -1390,7 +1448,7 @@ function mouseup_room (flags, hotspot_id)
1390
1448
-- here for LH click
1391
1449
1392
1450
-- Control key down?
1393
- if bit .band (flags , 0x02 ) ~= 0 then
1451
+ if bit .band (flags , miniwin . hotspot_got_control ) ~= 0 then
1394
1452
cancel_speedwalk ()
1395
1453
return
1396
1454
end -- if ctrl-LH click
0 commit comments