/
Glimmr Automap.i7x
1478 lines (953 loc) · 89.8 KB
/
Glimmr Automap.i7x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Version 2/101030 of Glimmr Automap (for Glulx only) by Erik Temple begins here.
"Provides a plug-and-play graphical automapping solution built on top of Mark Tilford's Automap extension. Can fall back to text-based map on interpreters that don't support graphics."
Chapter - Inclusions
Include version 3 of Automap by Mark Tilford.
Include Glimmr Drawing Commands by Erik Temple.
Include Glimmr Canvas-Based Drawing by Erik Temple.
Include Glimmr Graphic Hyperlinks by Erik Temple.
Chapter - Use options
Use no query functionality translates as (- Constant NO_QUERY; -).
Use no post-processing translates as (- Constant N_POST_PROCESS; -).
Use MAX_ARRAYS of 3000.
Use automap hyperlinks. [This use option is provided by the Automap extension. It must be invoked to avoid compiler errors.]
Use automap static allocation. [Prevents crashes in Spatterlight and Zoom.]
Section - Maximum map size use option
Use automap reserved area of at least 3200.
Chapter - Console settings
[This is a "macro" that allows the extension to identify itself in the Glimmr console window with fewer keystrokes on my part.]
To say GLAM:
say "[bracket]Glimmr Automap[close bracket]: ".
Chapter - ASCII map
[if the player's interpreter does not support graphics, the Automap text-based map (ASCII or Unicode) will be shown instead. This map is shown by expanding the number of lines in the status window. We can set the number of lines in the text map by using this variable. The default is 12 rows.]
The text-map depth is a number variable. The text-map depth is usually 12.
[To preview what the text-only map will look like to those using an interpreter without graphics support, paste the following into your story code:
First for constructing the status line:
shut down the map-window;
reserve automap memory of (text-map depth) rows;
fill status bar with table of ordinary status and map;
rule succeeds.]
Chapter - Configuration
When play begins:
if glulx graphics is supported:
now the current zoom is map zoomed in; [refers to Automap's zoom, which must always be set to zoomed in.]
if the current zoom level of the map-renderer is 0:
now the current zoom level of the map-renderer is the initial zoom level of the associated tileset of the map-renderer;
if the map viewport is not a map-display window:
now the map viewport is a random map-display window;
if the display-layer of the UI-frame is 0:
now the display-layer of the UI-frame is UI-layer minus 1;
if the display-layer of the UI-query-explanation is 0:
now the display-layer of the UI-query-explanation is UI-layer;
repeat with item running through the list of UI-buttons:
now the display-layer of item is UI-layer;
if the horizontal margin of the UI-frame is 999:
now the horizontal margin of the UI-frame is 5;
if the vertical margin of the UI-frame is 999:
now the vertical margin of the UI-frame is 5;
if the vertical margin of the UI-query-explanation is 999:
now the vertical margin of the UI-query-explanation is 38;
if the horizontal margin of the UI-query-explanation is 999:
now the horizontal margin of the UI-query-explanation is 0;
if the number of entries of the list of display-active UI-buttons is 2:
now the image-ID of the UI-frame is Figure of UI-frame-short.
Section - Default tileset (for use with Glimmr Automap Tileset by Erik Temple)
The associated tileset of the map-renderer is usually the Glimmr Automap Tileset.
Chapter - Hacking Automap
First for constructing the status line (this is the bypass status line map rule):
if glulx graphics is supported:
fill status bar with table of ordinary status;
rule succeeds;
else:
reserve automap memory of (text-map depth) rows;
continue the action.
[if you prefer that the MAP command toggle the ASCII version of the map rather than close the map window entirely, you can copy the following into your story file:
Chapter - Deciding (in place of Chapter - Hacking Automap in Glimmr Automap by Erik Temple)
First for constructing the status line (this is the bypass status line map rule):
if glulx graphics is supported and the map-window is g-present:
fill status bar with table of ordinary status;
rule succeeds;
else:
now current zoom is map zoomed in;
reserve automap memory of 12 rows;
fill status bar with table of ordinary status and map.]
Chapter - The map-display window kind
[We need to change Glimmr Canvas-Based Drawing's basic window-drawing behavior for the automap window. One of the most straightforward ways to do this is with a kind. A property would work as well, but we don't really want to be able to change this during play--map display would break entirely.]
A map-display window is a kind of graphlink g-window.
The map viewport is a g-window that varies.[@Tag:NotSaved] [if the author doesn't explicitly name the map viewport, we will automatically select a map-display window to be the viewport when play begins. In most cases, this will be the only existing map-display window.]
[The author may provide a maximum map size to use. This refers to the number of *tiles* to be displayed, not the maximum number of pixels, and can be used to restrict the size of the map for either performance or aesthetic reasons. For example, a fixed map size combined with a restricted number of available zoom levels can make it easier to predict the output size of the map.]
A map-display window has a number called the maximum map width. The maximum map width of a map-display window is usually 0.
A map-display window has a number called the maximum map height. The maximum map height of a map-display window is usually 0.
Chapter - Map window management
After constructing the status line (this is the graphic automap updating rule):
follow the refresh windows rule;
continue the action.
Chapter - Rules for opening and closing the map window
[We provide these as rules, so that players interested in a more complex system of windows can hook into them more easily. (For example, we might want two map windows on screen at once, one window at a different level of zoom than the other, or we might want to use Automap to display a map of the overall world, while using something like the Room and Dimension extension to render a map of the room itself in another window.)]
Section - Opening the map window
The opening up the map window rules are a rulebook.
Last opening up the map window:
open up the map viewport.
Section - Closing the map window
The shutting down the map window rules are a rulebook.
Last shutting down the map window:
shut down the map viewport.
Chapter - Extension of the tileset kind
[The tileset kind is defined in Glimmr Drawing Commands. We extend the kind here to allow for zooming.]
A tileset has a list of real numbers called the zoom-level set. The zoom-level set of a tileset is usually {1.0000}.
A tileset has a number called the initial zoom level. The initial zoom level of a tileset is usually 1.
Chapter - The map-renderer object
The map-renderer is a g-element. The map-renderer has a glulx color value called the background tint. The background tint of the map-renderer is usually g-placenullcol. The graphlink status of the map-renderer is usually g-active.
The scaling factor of the map-renderer is 1.0000. The x-scaling factor is 1.0000. The y-scaling factor is 1.0000.
The origin of the map-renderer is {0, 0}. The display-layer is 1.
The map-renderer has a tileset called the associated tileset.
The map-renderer has a number called the current zoom level. The current zoom level is usually 0.
[The map-width and map-height are set automatically by the extension. Authors will not need to set them directly unless replacing the resize canvas to map rule with one of their own devising.]
The map-renderer has a number called the map-width. The map-width is 0.
The map-renderer has a number called the map-height. The map-height is 0.
Chapter - New window scaling rule for the map window
For scaling a map-display window (called the viewport) (this is the select appropriate zoom level rule):
[say "Applying zoom level...";
say "Background color: [background tint of map-renderer].";]
now the arbitrary scaling factor of the viewport is entry (current zoom level of the map-renderer) of the zoom-level set of the associated tileset of the map-renderer;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Window [i][viewport][/i] is a map-display window. Arbitrary scaling factor set to [arbitrary scaling factor of the viewport], based on entry [current zoom level of the map-renderer] of the zoom-level set of the tileset [i][associated tileset of the map-renderer][/i].[<]";
#end if;
continue the action.
For scaling a map-display window (called the viewport) (this is the resize canvas to map rule):
let scaled tile-width be (tile-width of associated tileset of the map-renderer * arbitrary scaling factor of the viewport) to the nearest 1;
let scaled tile-height be (tile-height of associated tileset of the map-renderer * arbitrary scaling factor of the viewport) to the nearest 1;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Scaled automap tile will measure [scaled tile-width] x [scaled tile-height] pixels, based on [i]map-window[/i] scaling factor.[<]";
#end if;
let x-win be the width of the viewport / scaled tile-width;
let y-win be the height of the viewport / scaled tile-height;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Window fits [x-win] tiles wide by [y-win] tiles high.[<]";
#end if;
if maximum map width of the viewport > 0:
if x-win > maximum map width of the viewport:
now x-win is maximum map width of the viewport;
if maximum map height of the viewport > 0:
if y-win > maximum map height of the viewport:
now y-win is maximum map height of the viewport;
#if utilizing Glimmr debugging;
if maximum map height of viewport > 0 or maximum map width of viewport > 0:
say "[>console][GLAM]Number of displayed automap tiles set at [x-win] tiles wide by [y-win] tiles high, taking into account author limits.[<]";
#end if;
reserve automap memory of y-win to the nearest whole number rows by x-win to the nearest whole number columns;
if the map is drawn and the current zoom is not map absent:
do nothing; [Automap's map is drawn by the phrase "if the map is drawn"; hence this odd instruction.]
now the map-width of the map-renderer is (map width * tile-width of associated tileset of the map-renderer);
now the map-height of the map-renderer is (map height * tile-height of associated tileset of the map-renderer);
now the canvas-width of the associated canvas of the viewport is map-width of the map-renderer;
now the canvas-height of the associated canvas of the viewport is map-height of the map-renderer;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Automap data calculated ([y-win * x-win] total tiles).[<]";
#end if;
continue the action;
Chapter - Element display rule for the map-renderer
An element display rule for the map-renderer when the location is unmappable (this is the unmappable room rule):
exit.
An element display rule for the map-renderer (this is the map-renderer display rule):
let tilesetting be the associated tileset of map-renderer;
let scan be 0;
let row be the win-y of the map-renderer;
let column be the win-x of the map-renderer;
let xx be the tile-width of the tilesetting * scaling factor of the current window to the nearest whole number;
let yy be the tile-height of the tilesetting * scaling factor of the current window to the nearest whole number;
unless the background tint of the map-renderer is g-placenullcol:
dimrectdraw (color background tint of the map-renderer) in (the current window) at (column) by (row) with dimensions (map-width of map-renderer * scaling factor of the current window to the nearest whole number) by (map-height of map-renderer * scaling factor of the current window to the nearest whole number);
#if utilizing Glimmr debugging;
say "[>console][GLAM]Drawing background rectangle (glulx color-value [background tint of map-renderer]) from ([win-x], [win-y]) to ([win-x + (map-width of map-renderer * scaling factor of the current window to the nearest whole number)], [win-y + (map-height of map-renderer * scaling factor of the current window to the nearest whole number)]) for element [i][map-renderer][/i] in [i][current window][/i].[<]";
#end if;
unless the no post-processing option is active:
follow the automap post-processing rules;
repeat with count running from 1 to (map height * map width):
increase scan by 1;
if scan > map width:
increase row by yy;
now column is the win-x of the map-renderer;
let scan be 1;
let V be the map glyph of count;
if there is a char of V in the translation-table of the tilesetting:
choose row with a char of V in the translation-table of the tilesetting;
let the current tile be tile entry;
drscimage (current tile) in (current window) at (column) by (row) with dimensions (xx) by (yy);
if the graphlink status of the map-renderer is g-active:
unless linked room-ID of count is 0:
set a graphlink in the current window identified as map-renderer from column by row to (column + xx) by (row + yy) as linked room-ID of count, ignoring redundant links;
#if utilizing the image-map graphlink preview option;
boxdraw (color graphlink preview color) in (current window) from (column) by (row) to (column + xx) by (row + yy) with 1;
#end if;
increase column by xx;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Drawing element [i]map-renderer[/i] in [i][current window][/i] at origin ([win-x of map-renderer], [win-y of map-renderer]), dimensions [map width * xx] x [map height * yy] pixels ([map width] x [map height] tiles)[if the graphlink status of the map-renderer is g-active][GLAM]Hyperlinks set for linked room-ID, as provided[end if].[<]";
#end if.
Chapter - Post-processing of map data
[The automap post-processing rules are provided as a hook to any post-processing we may want to do of the map data. By default, we repair corner tiles here by filling in the gaps of diagonals with small tiles. If post-processing is not desired, we can compile using the no post-processing option to avoid checking the rulebook at all.]
The automap post-processing rules are a rulebook.
An automap post-processing rule (this is the fill diagonal corners rule):
let scan be 0;
repeat with N running from 1 to (map height * map width):
increase scan by 1;
if scan > map width:
let scan be 1;
if the map glyph of N is 53 or the map glyph of N is 70:
if (scan + 1) < map width, place glyph 73 at (N + 1);
if the map glyph of N is 36:
if (scan - 1) > 0, place glyph 71 at (N - 1);
if (scan + 1) < map width, place glyph 73 at (N + 1);
if the map glyph of N is 51 or the map glyph of N is 68:
if (scan - 1) > 0, place glyph 71 at (N - 1);
if the map glyph of N is 52 or the map glyph of N is 69:
if (scan + 1) < map width, place glyph 74 at (N + 1);
if the map glyph of N is 35:
if (scan + 1) < map width, place glyph 74 at (N + 1);
if (scan - 1) > 0, place glyph 72 at (N - 1);
if the map glyph of N is 50 or the map glyph of N is 67:
if (scan - 1) > 0, place glyph 72 at (N - 1);
if the map glyph of N is 90:
if (N - map width) > 0, place glyph 11 at (N - map width) imperiously;
if (scan + 1) < map width, place glyph 12 at (N + 1) imperiously;
if (N + map width) < (map height * map width), place glyph 13 at (N + map width) imperiously;
if (scan - 1) > 0, place glyph 14 at (N - 1) imperiously;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Automap data post-processed to correctly render corner tiles.[<]";
#end if.
Chapter - Reading and writing automap data
To decide what number is the map glyph of (N - a number):
(- Automap_Chars->( {N} - 1 ) -)
To decide what number is the linked room-ID of (N - a number):
(- Automap_Links-->( {N} - 1 ) -)
To place glyph (ch - number) at (x - a number):
(- if ( Automap_Chars -> ( {x} - 1 ) == 32 ) {
Automap_Chars -> ( {x} - 1 ) = {ch};
}
-)
To place glyph (ch - number) at (x - a number) imperiously:
(- Automap_Chars -> ( {x} - 1 ) = {ch}; -)
Chapter - Graphlinking the map
A clicking graphlink rule when the current graphlink window is a map-display window (this is the automap forward graphlinking rule):
repeat through the Table of Graphlink Glulx Replacement Commands in reverse order:
if the current graphlink window is g-win entry:
if the current graphlink x >= p-left entry and the current graphlink x <= p-right entry and the current graphlink y >= p-top entry and the current graphlink y <= p-bottom entry:
now glulx replacement command is "";
now the current graphlink is linkid entry;
if there is an alt entry:
#if utilizing Glimmr debugging;
say "[>console][GLAM]Mouse input received on graphlink '[current graphlink]' in window [italic type][current graphlink window][roman type]: ([current graphlink x], [current graphlink y]). Automap graphlink rules triggered for room [i][glulx equivalent of alt entry][/i].[<]";
#end if;
follow the automap graphlink rules for the glulx equivalent of alt entry; [the glulx equivalent is a type-casting routine. It returns a room.]
else:
#if utilizing Glimmr debugging;
say "[>console][GLAM]Mouse input received on graphlink '[current graphlink]' in window [italic type][current graphlink window][roman type]: ([current graphlink x], [current graphlink y]). Automap graphlink rules triggered.[<]";
#end if;
follow the automap graphlink rules for the current graphlink;
rule succeeds;
A clicking graphlink rule when the current graphlink window is a map-display window (this is the automap background graphlinking rule):
unless the no query functionality option is active:
deactivate the current map label;
now the image-ID of UI-query is the resting state of UI-query;
deactivate UI-query-explanation;
follow the refresh windows rule;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Mouse input received in window [i][current graphlink window][/i] (no link triggered): ([current graphlink x], [current graphlink y]). Query canceled.[<]";
#end if;
rule succeeds;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Mouse input received in window [i][current graphlink window][/i] (no link triggered): ([current graphlink x], [current graphlink y]).[<]";
#end if;
rule fails.
Chapter - The automap graphlink rulebook
The automap graphlink rules are an object-based rulebook.
The automap graphlink rules have outcomes exit (success - the default) and continue (no outcome).
The current map label is a g-element variable.
[The following phrase is defined in Mark Tilford's Automap, but in a section that only compiles when we're using Basic Hyperlinks. Basic Hyperlinks is not recommended for use with Flexible Windows, however, so we repeat the phrase here.]
To decide what room is the glulx equivalent of (n - a number):
(- {n} -)
Section - Reorder report coordinates rule (not for release)
The report coordinates rule is listed first in the automap graphlink rules.
Section - Clicking a button
First automap graphlink rule for the UI-query (this is the query button management rule):
if the image-ID of the UI-query is the depressed state of UI-query:
now the image-ID of UI-query is the resting state;
deactivate the UI-query-explanation;
else:
now the image-ID of UI-query is the depressed state;
if the maximum display-count of UI-query-explanation > 0 and (display-count of UI-query-explanation < maximum display-count of UI-query-explanation) or maximum display-count of UI-query-explanation is 999:
activate the UI-query-explanation;
increase the display-count of UI-query-explanation by 1;
follow the refresh windows rule.
Automap graphlink rule for a UI-button (called the pressee) when the image-ID of the pressee is not the inactive state of the pressee (this is the activate non-modal UI button rule):
now the image-ID of the current graphlink is the depressed state of the current graphlink;
display (image-ID of pressee) in the current window at (origin of pressee);
[set a graphlink in the current window identified as pressee from (entry 1 of the origin of pressee) by (entry 2 of the origin of the pressee) to (entry 1 of the origin of pressee plus the image-width of the image-ID of pressee) by (entry 2 of the origin of pressee plus the image-height of the image-ID of pressee) as the linked action of the pressee;]
revert the button after 0.1500 seconds;
silently try the linked action of the current graphlink.
Section - Querying a room
Automap graphlink rule for a room (called the target) when the no query functionality option is not active (this is the display queried room name rule):
if UI-query is display-active and the image-ID of UI-query is not the depressed state of UI-query:[if we're using the query button, we only want the action to proceed when the button is in its depressed state. Otherwise, we drop through to the author's rule.]
continue;
if the current map label is a rendered string:
now the text-string of the current map label is the printed name of the target;
now the origin of the current map label is the canvas equivalent of the screen coordinates (current graphlink x) by (current graphlink y) of (current graphlink window);
activate the current map label;
if the UI-query-explanation is not g-persistent:
deactivate the UI-query-explanation;
follow the refresh windows rule;
deactivate the current map label.[The map label will disappear from the map, but only after the next time the window is redrawn.]
Chapter - Popup room labels (for use with Glimmr Bitmap Font by Erik Temple)
The current map label is usually the bitmap automap label.
The bitmap automap label is a bitmap-rendered string. The tint is usually g-black. The background tint is usually g-yellow. The display-layer is usually 2. The display status is usually g-inactive. The associated font is usually Glimmr C&C.
Chapter - New functionality for Automap verbs
Understand "zoom in" or "zoom out" or "zoom" as a mistake ("[only-one-graphical-zoom-level]") when glulx graphics is supported and the number of entries of the zoom-level set of the associated tileset of the map-renderer is 1 and not the command is mouse-generated.
Section - Zooming in
Carry out zooming in when glulx graphics is supported:
if the map viewport is g-unpresent:
try opening the map window;
if the map viewport is g-present:
if current zoom level of the map-renderer < the number of entries of the zoom-level set of the associated tileset of the map-renderer:
increase current zoom level of the map-renderer by 1;
else:
say "[line break](Could not open the map window.)";
rule succeeds.
Report zooming in when glulx graphics is supported:
unless the command is mouse-generated:
say "[zoomed-in]"
Section - Zooming out
Carry out zooming out when glulx graphics is supported:
if the map viewport is g-unpresent:
try opening the map window;
if the map viewport is g-present:
if current zoom level of the map-renderer > 1:
decrease current zoom level of the map-renderer by 1;
else:
say "[map-window-failed-to-open]";
rule succeeds.
Report zooming out when glulx graphics is supported:
unless the command is mouse-generated:
say "[zoomed-out]"
Section - Toggling zoom
Graphic zoom toggling is an action out of world applying to nothing. Understand "zoom" as graphic zoom toggling when glulx graphics is supported.
Carry out graphic zoom toggling:
if the map viewport is g-unpresent:
try opening the map window;
if the map viewport is g-present:
if current zoom level of the map-renderer < the number of entries of the zoom-level set of the associated tileset of the map-renderer:
increase current zoom level of the map-renderer by 1;
else:
now current zoom level of the map-renderer is 1;
else:
say "[map-window-failed-to-open]";
rule succeeds.
Report graphic zoom toggling when glulx graphics is supported:
unless the command is mouse-generated:
say "[zoomed-in-or-out]"
Section - Opening the map window
Opening the map window is an action out of world applying to nothing. Understand "map" or "open map" or "open map window" as opening the map window when glulx graphics is supported and the map viewport is g-unpresent.
Understand "open map" or "open map window" as a mistake ("[Map-window-already-open]") when glulx graphics is supported and the map viewport is g-present.
Carry out opening the map window when glulx graphics is supported and the map viewport is g-unpresent:
now current zoom is map zoomed in;
follow the opening up the map window rules.
Report opening the map window when glulx graphics is supported and the map viewport is g-present:
say "[Map-window-open]"
Section - Closing the map window
Understand "map" or "close map" or "close map window" as zooming away when glulx graphics is supported and the map viewport is g-present.
Carry out zooming away when glulx graphics is supported and the map viewport is g-present:
now current zoom is map absent;
follow the shutting down the map window rules;
rule succeeds.
Report zooming away when glulx graphics is supported and the map viewport is g-unpresent:
say "[Map-window-closed]"
Understand "close map" or "close map window" as a mistake ("[map-window-already-closed]") when glulx graphics is supported and the map viewport is g-unpresent.
Section - Error message for using unsupported Automap commands
Understand "map unicode" or "map fancy" or "map font 3" or "map beyond zork" or "map simple/ascii/plain" or "gargoyle bug workaround" or "map auto" or "map [text]" as a mistake ("[allowed-map-commands]") when glulx graphics is supported.
Chapter - Action messages
Section - Zooming
[The odd "run paragraph on" followed by "line break" is needed to avoid a double space after this line.]
To say only-one-graphical-zoom-level:
say "Zooming the map is not allowed.[run paragraph on][line break]"
Section - Zooming in
To say zoomed-in:
say "Zoomed in to level [current zoom level of the map-renderer] of [number of entries of the zoom-level set of the associated tileset of the map-renderer]."
Section - Zooming out
To say zoomed-out:
say "Zoomed out to level [current zoom level of the map-renderer] of [number of entries of the zoom-level set of the associated tileset of the map-renderer]."
Section - Zooming either in or out
To say zoomed-in-or-out:
say "Zoomed to level [current zoom level of the map-renderer] of [number of entries of the zoom-level set of the associated tileset of the map-renderer]."
Section - Map window open
To say map-window-open:
say "Map window open."
To say map-window-already-open:
say "The map window is already open."
Section - Map window failed to open
To say map-window-failed-to-open:
say "[line break](Could not open the map window.)"
Section - Map window closed
To say map-window-closed:
say "Map window closed."
To say map-window-already-closed:
say "The map window is already closed."
Section - Allowed map commands
To say allowed-map-commands:
say "(You can ZOOM IN, ZOOM OUT, or type MAP to toggle the map window.)"
Chapter - Debugging (not for release)
Dumping automap data is an action out of world applying to nothing. Understand "automap dump" or "dump map" or "dump automap" as dumping automap data. Understand "map dump" as dumping automap data when glulx graphics is supported.
Carry out dumping automap data:
say "Map measures [map width] by [map height], totaling [map height * map width] tiles.[line break]Window measures [width of the assigned window of the map-renderer] x [height of the assigned window of the map-renderer] px.[line break]Scaled tile measures [tile-width of associated tileset of the map-renderer * arbitrary scaling factor of the assigned window of the map-renderer] x [tile-height of associated tileset of the map-renderer * arbitrary scaling factor of the assigned window of the map-renderer] px.[line break]Canvas measures [canvas-width of the associated canvas of the map-renderer] x [canvas-height of the associated canvas of the map-renderer] canvas units.";
say "Dump of automap data:[paragraph break][fixed letter spacing]";
let scan be 0;
repeat with count running from 1 to (map width * map height):
increase scan by 1;
if scan > map width:
LineBreak;
let scan be 1;
if map glyph of count is 32:
say "... ";
else if map glyph of count < 10:
say " [map glyph of count] ";
else if map glyph of count < 100:
say " [map glyph of count] ";
else:
say "[map glyph of count] ";
say "[variable letter spacing][line break]".
Dumping automap links is an action out of world applying to nothing. Understand "automap link/links dump" or "dump links" or "dump map links" or "dump automap links" as dumping automap links. Understand "map link dump" as dumping automap links when glulx graphics is supported.
Carry out dumping automap links:
say "Map measures [map width] by [map height], totaling [map height * map width] tiles.[line break]Window measures [width of the assigned window of the map-renderer] x [height of the assigned window of the map-renderer] px.[line break]Scaled tile measures [tile-width of associated tileset of the map-renderer * arbitrary scaling factor of the assigned window of the map-renderer] x [tile-height of associated tileset of the map-renderer * arbitrary scaling factor of the assigned window of the map-renderer] px.[line break]Canvas measures [canvas-width of the associated canvas of the map-renderer] x [canvas-height of the associated canvas of the map-renderer] canvas units.";
say "Dump of automap hyperlink data:[paragraph break][fixed letter spacing]";
let scan be 0;
repeat with count running from 1 to (map width * map height):
increase scan by 1;
if scan > map width:
LineBreak;
let scan be 1;
if linked room-ID of count is 0:
say ".. ";
else:
say "[glulx equivalent of the linked room-ID of count] ";
say "[variable letter spacing][line break]".
Chapter - Controls
Section - UI element figure declarations
Figure of UI-frame is the file "automapUI_frame.png".
Figure of UI-frame-short is the file "automapUI_frame_2button.png".
Figure of UI-query is the file "automapUI_query.png".
Figure of UI-zoom-in is the file "automapUI_zoomIn.png".
Figure of UI-zoom-out is the file "automapUI_zoomOut.png".
Figure of UI-query-depressed is the file "automapUI_query_depressed.png".
Figure of UI-zoomIn-disabled is the file "automapUI_zoomIn_disabled.png".
Figure of UI-zoomOut-disabled is the file "automapUI_zoomOut_disabled.png".
Figure of UI-zoomIn-depressed is the file "automapUI_zoomIn_depressed.png".
Figure of UI-zoomOut-depressed is the file "automapUI_zoomOut_depressed.png".
Figure of UI-query-explanation is the file "automapUI_explanation.png".
Section - UI element definition
[We do not want these images to be scaled by the canvas engine. The easiest way to ensure this is to assign them as direct descendants of the g-element kind, bypassing the sprite kind, which has its own scaling rules.]
A UI-element is a kind of g-element.
A UI-element has a figure-name called the image-ID.
The display-layer of a UI-element is usually 0.
A UI-button is a kind of UI-element. The graphlink status of a UI-button is g-active.
A UI-button has a figure-name called the resting state.
A UI-button has a figure-name called the depressed state.
A UI-button has a figure-name called the inactive state.
Section - UI buttons
Some UI-buttons are defined by the Table of Map Buttons.
[The UI-layer is a global variable holding the layer number on which the buttons should be placed. It should generally be at least 2 layers higher than the map layer. If no display-layer is explicitly set for the UI-frame, it will be placed one level beneath the UI-layer.]
The UI-layer is a number that varies.[@Tag:NotSaved] The UI-layer is usually 4.
Table of Map Buttons
g-element image-ID resting state depressed state inactive state
UI-zoom-in Figure of UI-zoom-in Figure of UI-zoom-in Figure of UI-zoomIn-depressed Figure of UI-zoomIn-disabled
UI-zoom-out Figure of UI-zoom-out Figure of UI-zoom-out Figure of UI-zoomOut-depressed Figure of UI-zoomOut-disabled
A UI-button has a stored action called the linked action.
The linked action of UI-zoom-in is the action of zooming in.
The linked action of UI-zoom-out is the action of zooming out.
Section - UI modal buttons
A UI-modal-button is a kind of UI-button. Some UI-modal-buttons are defined by the Table of Map Modal Buttons. The display status of a UI-modal-button is usually g-inactive.
Table of Map Modal Buttons
g-element image-ID resting state depressed state
UI-query Figure of UI-query Figure of UI-query Figure of UI-query-depressed
Section - UI anchor elements
An anchor-element is a kind of UI-element.
An anchor-element has a number called the horizontal margin. The horizontal margin is usually 999.
An anchor-element has a number called the vertical margin. The vertical margin is usually 999.
An anchor-element can be center-positioned, right-positioned, or left-positioned (this is its horizontal-positioning property).
An anchor-element can be bottom-positioned, central-positioned, or top-positioned (this is its vertical-positioning property).
Section - The UI frame
[The UI-frame is a framing element for the buttons that do the actual work. However, we use it as a hook on which to hang spacing and other information, and we also use it as a means to calculate the width and height of the UI elements taken together. It must be represented by a PNG file from which the width and height can be read.]
The UI-frame is an anchor-element.
The image-ID is usually Figure of UI-frame.
Section - The query explanatory text object
The UI-query-explanation is an anchor-element.
The image-ID is usually Figure of UI-query-explanation. The display status is usually g-inactive.
The UI-query-explanation has a number called the maximum display-count. The maximum display-count is usually 999.
The UI-query-explanation has a number called the display-count. The display-count is 0.
The UI-query-explanation can be g-persistent.
Section - UI-frame offsets
[The UI-frame offsets are pairs of numbers that give the left and top offsets from the frame or previous element for each of the UI buttons that will displayed within it.]
The UI-frame has a list of numbers called the UI-frame offsets. The UI-frame offsets are {
4, 4,[zoom in]
23, 4,[zoom out]
43, 6[query]
}
Section - UI logic
[The UI logic rules are used to decide which state should be shown for each button, and whether it should be clickable.]
The UI logic rules are an object-based rulebook.
UI logic rule for UI-zoom-in:
if current zoom level of the map-renderer < the number of entries of the zoom-level set of the associated tileset of the map-renderer:
activate graphlink for UI-zoom-in;
now the image-ID of UI-zoom-in is the resting state of UI-zoom-in;
else:
deactivate graphlink for UI-zoom-in;
now the image-ID of UI-zoom-in is the inactive state of UI-zoom-in.
UI logic rule for UI-zoom-out:
if current zoom level of the map-renderer > 1:
activate graphlink for UI-zoom-out;
now the image-ID of UI-zoom-out is the resting state of UI-zoom-out;
else:
deactivate graphlink for UI-zoom-out;
now the image-ID of UI-zoom-out is the inactive state of UI-zoom-out.
[UI logic rule for UI-query:
if the current map label is display-active:
now the image-ID of UI-query is the depressed state of UI-query;
else:
change the image-ID of UI-query to the resting state of UI-query.]
Section - Element scaling for UI elements
[The first rule bypasses the standard g-element scaling rule, which automatically scales the origin of an element to the window. Because we are calculating the origins of UI-elements based on the window itself, we have no need to scale. The second rule rule provides a handy place to do these calculations. The third rule arranges the buttons on the frame, based on the position of the frame as calculated by the second rule.]
An element scaling rule for an anchor-element (called the current-element) (this is the anchor placement rule):
if the current-element is right-positioned:
now entry 1 of the origin of the current-element is the width of the current window - (image-width of image-ID of current-element + horizontal margin of current-element);
[say "Calculated: [entry 1 of the origin of the current-element].";]
if the current-element is left-positioned:
now entry 1 of the origin of the current-element is horizontal margin of current-element;
if the current-element is center-positioned:
now entry 1 of the origin of the current-element is the (width of the current window - image-width of image-ID of current-element) / 2;
[say "[current-element]: Width of window: [width of current window]; image: [image-width of image-ID of current-element]; horizontal margin: [horizontal margin of current-element].";]
if the current-element is top-positioned:
now entry 2 of the origin of the current-element is vertical margin of current-element;
if the current-element is bottom-positioned:
now entry 2 of the origin of the current-element is the height of the current window - (image-height of image-ID of current-element + vertical margin of current-element);
[say "[current-element]: Height of window: [height of current window]; image: [image-height of image-ID of current-element]; vertical margin: [vertical margin of current-element].";]
if the current-element is central-positioned:
now entry 2 of the origin of the current-element is the (height of the current window - image-height of image-ID of current-element) / 2;
[say "[current-element] is placed at [origin of current-element].";]
continue.
Last element scaling rule for the UI-frame (this is the UI-frame arranging rule):
let instance be 0;
repeat with current-element running through display-active UI-buttons:
increase instance by 1;
now entry 1 of the origin of current-element is (entry 1 of the origin of the UI-frame) + (entry instance of the UI-frame offsets of the UI-frame);
increase instance by 1;
now entry 2 of the origin of current-element is (entry 2 of the origin of the UI-frame) + (entry instance of the UI-frame offsets of the UI-frame);
exit.
Last element scaling rule for a UI-element (this is the UI element scaling rule):
do nothing;
exit.
Section - Element drawing rules for UI elements
An element display rule for an anchor-element (called the current-element):
display (image-ID of current-element) in the current window at (origin of current-element);
#if utilizing Glimmr debugging;
say "[>console][GLAM]Drawing anchor-element [i][current-element][/i] ([image-ID of current-element]) at origin ([entry 1 of the origin of current-element],[entry 2 of the origin of the current-element]).[<]";
#end if;
An element display rule for a UI-button (called the pressee):
follow the UI logic rules for the pressee;
display (image-ID of pressee) in the current window at (origin of pressee);
set a graphlink in the current window identified as pressee from (entry 1 of the origin of pressee) by (entry 2 of the origin of the pressee) to (entry 1 of the origin of pressee plus the image-width of the image-ID of pressee) by (entry 2 of the origin of pressee plus the image-height of the image-ID of pressee) as the linked action of the pressee;
#if utilizing Glimmr debugging;
say "[>console][GLAM]Drawing UI-button [i][pressee][/i] ([image-ID of pressee]) at origin ([entry 1 of the origin of pressee],[entry 2 of the origin of the pressee]). Graphlink set from ([entry 1 of the origin of pressee],[entry 2 of the origin of the pressee]) to ([entry 1 of the origin of pressee plus the image-width of the image-ID of pressee],[entry 2 of the origin of pressee plus the image-height of the image-ID of pressee])[if the linked action of the pressee is a stored action]: [i][linked action of the pressee][/i][end if].[<]";
#end if;
Section - Animations for button response
A glulx timed activity rule (this is the redraw button from timer rule):
stop the timer;
follow the window-drawing rules for the assigned window of the current graphlink.
To revert the/-- button/-- after (T - a real number) second/seconds:
(- glk_request_timer_events({T}/10); -)
To stop the/-- timer:
(- glk_request_timer_events(0); -)
[Section - Optional undo control (for use with Undo Output Control by Erik Temple)
[This section can be uncommented should you wish to add buttons to your game that actually cause a turn to pass--none of the buttons as defined by default result in that.]
[The timer introduces a certain wild-card element. The upshot is that, when we undo, the events that happen after the timer fires are not "remembered"--so, the state of the button will still be active after we undo, and the timer event will not fire. The after undoing an action rule here requests the timer event immediately after undoing, so that the button will return to its initial state as needed. This has the added benefit of indicating to the player exactly what is being reconstructed after UNDO, the pressing of the button. This is rather primitive, in that the timer event is requested no matter the situation (i.e, regardless of whether the last turn involved a button press; however, things are structured so that this is harmless.]
After undoing an action:
revert the button after 0.1500 seconds;]
Glimmr Automap ends here.
---- DOCUMENTATION ----
Chapter: About Glimmr Automap
Glimmr Automap is, unlike most other Glimmr extensions, a solution rather than a framework. It provides a graphical map that draws a flowchart-style map to a graphics window, adding rooms dynamically to the map as the player discovers the story world. Glimmr Automap (GLAM) is a graphical frontend for Mark Tilford's Automap extension, displaying the map data generated by that extension using a graphical tileset, supplied as the Glimmr Automap Tileset extension. Users may also supply their own tilesets.
Glimmr Automap also provides easily configured user-interface elements for interacting with the map, including zooming in and out using onscreen buttons, clicking on rooms in the map to identify them onscreen, and more.
Glimmr Automap is primarily designed for use with Glulx interpreters that support graphics windows, but it will fall back to an ASCII (or Unicode) map on text-only interpreters, using the interface provided by Mark Tilford's Automap.
The extension requires most of the other Glimmr extensions in order to function, including Glimmr Canvas-Based Drawing, Glimmr Drawing Commands, and Glimmr Graphic Hyperlinks. Also required are Glimmr's dependencies, including Flexible Windows by Jon Ingold and Fixed Point Maths by Michael Callaghan.
Section: A note on terminology
Through the course of this documentation, Glimmr Automap will be referred to either using its full name, or the abbreviation "GLAM". Mark Tilford's Automap extension--the engine that actually supplies the map data--will be referred to as "Automap" or "Mark Tilford's Automap".
Chapter: Including Glimmr Automap in a project
Inform remains fairly unsophisticated in its mechanisms for organizing included extensions. When we are dealing with a complex system of modular extensions such as Glimmr, it is very easy to trip it up, and the result is usually a list of unhelpful errors. For this reason, each Glimmr extension includes a section--such as this one--about how to include it, particularly in relation to other extensions.
Glimmr Automap should be included before any font or tileset extensions, e.g.:
Include Glimmr Automap by Erik Temple.
Include Glimmr Automap Tileset by Erik Temple.
You should not include Flexible Windows, Fixed Point Maths, Glimmr Drawing Commands, Glimmr Canvas-Based Drawing, or Glimmr Graphic Hyperlinks in your project; these are included automatically, as is Mark Tilford's Automap. Fonts and tilesets *must* be included after the Glimmr Automap extension.
Chapter: Basic usage
Glimmr Automap renders the map data generated by Automap using a set of images defined by a "tileset." Tilesets are packaged as extensions, and Glimmr Automap Tileset is provided as part of Glimmr. Note that GLAM will not run properly without a tileset!
At its most basic, adding Glimmr Automap to your story involves just two steps:
1. Include the extension and a tileset extension.
2. Create a "map-display window" and an accompanying canvas.
The first step is simple. Unless we are using an alternate tileset, all we need to do is include these two sentences at the top of our story file:
*: Include Glimmr Automap by Erik Temple.
Include Glimmr Automap Tileset by Erik Temple.
We must copy the image files for the Glimmr Automap user interface into the Materials->Figures folder of our Inform project, as well as the images for our tileset. See Chapter 22 of Writing with Inform for more information on using images.
We may easily incorporate the "querying" functionality--which allows the player to click on a room in the map to reveal the room name in a tooltip--by including Glimmr Bitmap Font:
*: Include Glimmr Bitmap Font by Erik Temple.
Glimmr Automap defines a new kind of graphics g-window, the "map-display window". The automap will only appear in a map-display window. You will need to create your own map-display window and define its basic characteristics (see the Flexible Windows extension for more on windows). This code will open a window with a black background above the main text window:
*: The map-window is a map-display window spawned by the main-window. The position is g-placeabove.
We also need to associate a canvas with our window (see the docs for Glimmr Canvas-Based Drawing for more on canvases):
*: The map-canvas is a g-canvas. The associated canvas of the map-window is the map-canvas.
If we have no other graphics windows or graphic elements, this will be enough. If we do have our own g-elements, however, we will need to specify which ones belong on our automap canvas:
*: The associated canvas of the map-renderer is the map-canvas. The associated canvas of a UI-element is the map-canvas.
This is all that is required to get a fully functioning graphical automap into our game, including a set of zoom buttons. The following sections will dive into options for customizing and configuring GLAM.
Chapter: The query functionality
As mentioned above, GLAM can print the name of a room to the graphics window in the style of a tooltip when the player clicks on said room in the map. This is known as the "query" function.
Section: Querying the room name
As mentioned above, the easiest way to enable the room-querying functionality is to include the Glimmr Bitmap Font extension. This will render the room name using the Glimmr Bitmap Font. We can, however, display the name in any font we like by changing the "current map label" variable. For example, if we wanted to use Glimmr Image Font to render the map label instead, we would do something like this:
*: Include Glimmr Image Font by Erik Temple.
The current map label is the image automap label.
The image automap label is an image-rendered string. The background tint is g-Yellow. The display-layer is 2. The display status is usually g-inactive. The associated font is Glimmr Lucidex. The scaling factor is 0.4000.
(See Glimmr Canvas-Based Drawing for more on the nature and properties of rendered strings, and of g-elements more generally.)
It is also possible to change the look of the tooltip even when we are using Glimmr Bitmap Font. To change the text and tooltip colors, for example, we might set the tint and background tint properties of the "bitmap automap label" g-element:
The background tint of the bitmap automap label is g-Blue. The tint of the bitmap automap label is g-White.
Section: The query explanation
The existence of the query functionality will not be obvious to players unless we tell them about it. We can do this in our source text, but GLAM also includes a means for us to display this information to the player within the graphics window, via the g-element known as the "UI-query-explanation". This element is not displayed by default. To turn it on, we paste the following into our source text:
*: The display status of the UI-query-explanation is g-active.
A text will appear above the UI frame that says "Click to identify a room". This text is completely hardcoded--to change the text or the color, we need to create a new PNG image for it. (The reason for this is speed--rendered strings may be slow on some machines/interpreters, and it is best to limit their use.)
By default, the UI-query-explanation element will be shown only until the player clicks on a room. If we prefer to show the explanation through the entire course of the game, we can add the following to our source text:
*: The UI-query-explanation is g-persistent.
(Note that if we are using the query button--see below--then "g-persistent" will have no effect.)
We can move the query explanation text around the screen in the same way as we do the UI frame (see below).
Section: Disabling query functionality
It may be that we don't want to offer the ability to query the map. To disable the feature completely, employ a use option:
*: Use no query functionality.
Chapter: Customizing the user interface
By default, Glimmr Automap places a small toolbar at the bottom of the window, containing + and - buttons for zooming in and out. This toolbar can be easily moved or removed. (We can also add your own buttons or remove the + and - buttons, but this is beyond the scope of this documentation; you should be able to figure out how to make the changes you need by studying the source code. You may need to familiarize yourself with the workings of Glimmr Canvas-Based Drawing first, however.)
GLAM also provides a few commands for the player, such as zooming and opening/closing the map window. The game's responses to these commands can also be customized.
Section: Changing the zoom levels of the map
Any tileset that is intended for use with Glimmr Automap should provide a list of the zoom levels at which the author believes the tileset looks best. This is the tileset's "zoom-level set." Each zoom level is represented by a ratio (given as a fixed-point decimal fraction, always written to the fourth decimal place). Here is the zoom-level set for the Glimmr Automap Tileset:
{0.3600, 0.5600, 0.8000, 1.0000}
If we don't like these zoom levels, however, we are free to change them. Glimmr Automap will deal intelligently with whatever we provide, but we must always have at least one level in the list. So, for example, if we want just two levels, we might cut the list down:
The zoom-level set of the Glimmr Automap Tileset is {0.5600, 1.0000}.
Zoom levels should increase from left to right. In-game, pressing the + button really means "move one step to the right in the zoom-level set," while the - button means "move one step to the left".
We can specify which zoom level the game should start out at by setting the "initial zoom level" of the tileset. This is a number that represents the entry of the zoom-level set that we want to begin the game at. By default Glimmr Automap Tileset begins at zoom level 2 (0.5600, or 56% of full size). To change this, we can add something like this to our story file:
The initial zoom level of the Glimmr Automap Tileset is 1.
Section: Anchor elements
Glimmr Automap handles window-canvas display differently from Canvas-Based Drawing. Rather than scale the canvas so that it fits the window, GLAM resizes the canvas. Each time the window is redrawn, GLAM calculates the number of tiles that will fit in the window--up to the maximum set by the "automap reserved area" use option (see above)--and changes the size of the canvas to match. The canvas is then centered in the window as per standard Canvas-Based Drawing behavior.
This means that there is no reliable way to set the positions of other elements (such as the zoom buttons). Canvas positions aren't reliable, since the canvas dimensions can change radically at different window sizes and zoom levels. So, Glimmr Automap introduces the "anchor-element." Anchor-elements g-elements that are placed (anchored) relative to the edges of the window, rather than to the canvas grid; these elements completely ignore the canvas, and instead are placed using textual "positionings" and numerical "margins".
GLAM includes two anchor-elements: the "UI-frame", which is a box that holds the zoom and query buttons, and the query explanation text ("UI-query-explanation," actually an external image file). If we want to add other graphic elements to the map window, it will generally be easiest to make them anchor-elements.
Anchor-elements are placed using adjectives for gross positioning, and a number for fine-tuning. By default, both the UI-frame and the UI-query-explanation have the same gross positioning: they appear in the bottom center of the window (see the section on the query functionality for more on the UI-query-explanation g-element). There are nine possible positions, three each for the "horizontal-positioning" and "vertical-positioning" properties. We can move an anchor element around the window by changing these positionings. The positionings are:
horizontally: left-positioned / center-positioned / right-positioned
vertically: top-positioned / central-positioned / bottom-positioned
So, if we wanted to move the UI-frame to the upper left of the map window, we'd type something like this:
The UI-frame is top-positioned and left-positioned.
We can further tweak this positioning by setting the margins. The margin is the horizontal or vertical distance (in pixels) between the nearest edge of the window and the UI frame. So, if we want to move the UI frame farther from the top of the screen, we might add to our declaration of the UI-frame's position:
The UI-frame is top-positioned and left-positioned.
The vertical margin of the UI-frame is 50.
This will place the UI-frame so that 50 pixels separate it from the top of the map window, rather than the default 5.
Note that there will be no effect if we try to set the horizontal margin of a center-positioned anchor element, or the vertical margin of a central-positioned one: the element must be anchored to an edge of the window for the margin value to be meaningful.
Section: Removing the frame altogether
Removing the UI-frame (and its buttons) altogether is simple. Declare the UI-frame object to be display-inactive, and neither it nor the buttons it contains will be shown:
*: The display status of the UI-frame is g-inactive.
Section: Changing action messages
GLAM includes a number of actions (most of them actually reimplementations of actions defined in Automap), all of which may print both success and failure messages. These messages can be changed by writing new "to say" phrases for them. For example, to change the message that is printed when the map window is opened, write this:
To say map-window-open:
say "You give some thought to the lay of the land, calling up a mental image of all you have seen so far."
Note that any such phrases you include in your story file must be placed *after* the line that includes Glimmr Automap.
Here is a list of all of the message names and their default texts:
only-one-graphical-zoom-level
"Zooming the map is not allowed.[run paragraph on][line break]"
zoomed-in
"Zoomed in to level [current zoom level of the map-renderer] of [number of entries of the zoom-level set of the associated tileset of the map-renderer]."
zoomed-out