Skip to content

Commit 6ec7871

Browse files
committed
Add side images to pad the large map
This makes the large map shown with the MAP command look nicer when the window is wide, especially the nautical map. It simply adds two filler images to the left and right.
1 parent 0f4a8b9 commit 6ec7871

6 files changed

Lines changed: 45 additions & 6 deletions

File tree

Counterfeit Monkey.materials/Extensions/Counterfeit Monkey/Map Declarations.i7x

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ Figure of Turret is the file "map-turret.png" ("A city map.").
9292
Figure of Webster Court is the file "map-webster-court.png" ("A city map.").
9393
Figure of Winding Path is the file "map-winding-path.png" ("A city map.").
9494

95+
["Padding" side images]
96+
Figure of padding left is the file "map-extend-left.png".
97+
Figure of padding right is the file "map-extend-right.png".
98+
9599
A room has a figure-name called the local map.
96100

97101
The local map of Back Alley is the figure of back-alley.
@@ -231,6 +235,10 @@ Figure of Brock-Bunk is the file "map-brock-bunk.png" ("The floor plan of a yach
231235
Figure of Brock-head is the file "map-brock-head.png" ("The floor plan of a yacht.").
232236
Figure of Crew-Bunk is the file "map-crew-bunk.png" ("The floor plan of a yacht.").
233237

238+
["Padding" side images]
239+
Figure of nautical padding left is the file "map-navigation-extend-left.png".
240+
Figure of nautical padding right is the file "map-navigation-extend-right.png".
241+
234242
The local map of Sunning Deck is the Figure of Sunning Deck.
235243
The local map of Galley is the Figure of Galley.
236244
The local map of Navigation Area is the Figure of Navigation.

Counterfeit Monkey.materials/Extensions/Counterfeit Monkey/Multimedia.i7x

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ Include (-
553553
width_quarter
554554
height_sixth
555555
vertical_offset
556+
left_image
557+
right_image
558+
nautical
556559
;
557560
558561
map_top = 0;
@@ -569,15 +572,16 @@ Include (-
569572
glk_window_get_size(graphwin, 0, gg_arguments);
570573
fullheight = gg_arguments-->0;
571574
572-
! let real-height be the height of the graphics window * 1.21
575+
! let real-height be the height of the graphics window * 1.16
573576
574-
! This value is hand tuned (along with the 0.02 vertical_offset below
577+
! This value is hand tuned (along with the 0.01 vertical_offset below)
575578
! to minimize wasteful space at the top and bottom of the map
576579
! while still looking reasonably good at all sizes and ratios.
577580
! Looks less good on the yacht maps, though.
578581
579-
! REAL_NUMBER_TY_Divide(1210, 1000) is 1067114824
580-
real_height = REAL_NUMBER_TY_Times(NUMBER_TY_to_REAL_NUMBER_TY(fullheight), 1067114824);
582+
! REAL_NUMBER_TY_Divide(1160, 1000) is 1066695393
583+
real_height =
584+
REAL_NUMBER_TY_Times(NUMBER_TY_to_REAL_NUMBER_TY(fullheight), 1066695393);
581585
ratio = REAL_NUMBER_TY_Divide(real_ideal, real_height);
582586
583587
! REAL_NUMBER_TY_Divide(722, 860) is 1062660473
@@ -604,13 +608,40 @@ Include (-
604608
{
605609
! The window is wider than the map
606610
607-
! 0.02 REAL_NUMBER_TY_Divide(2, 100) is 1017370378
608-
vertical_offset = REAL_NUMBER_TY_to_NUMBER_TY(REAL_NUMBER_TY_Times(scaled_height_real, 1017370378));
611+
! 0.01 REAL_NUMBER_TY_Divide(1, 100) is 1008981770
612+
vertical_offset =
613+
REAL_NUMBER_TY_to_NUMBER_TY(REAL_NUMBER_TY_Times(scaled_height_real, 1008981770));
614+
615+
nautical = GetEitherOrProperty( real_location, (+ nautical +) );
616+
617+
! the nautical map looks better if we nudge it down instead of up
618+
if (nautical)
619+
vertical_offset = -vertical_offset;
609620
610621
map_top = map_top - vertical_offset;
611622
612623
! fill window with blue background colour
613624
glk_image_draw_scaled(graphwin, ResourceIDsOfFigures-->( (+ figure of background colour +) ), 0, 0, fullwidth, fullheight);
625+
626+
! draw the padding images at the sides
627+
if (nautical)
628+
{
629+
left_image =
630+
ResourceIDsOfFigures-->( (+ Figure of nautical padding left +) );
631+
right_image =
632+
ResourceIDsOfFigures-->( (+ Figure of nautical padding right +) );
633+
}
634+
else
635+
{
636+
left_image = ResourceIDsOfFigures-->( (+ Figure of padding left +) );
637+
right_image = ResourceIDsOfFigures-->( (+ Figure of padding right +) );
638+
639+
}
640+
641+
glk_image_draw_scaled(graphwin, left_image, IntegerDivide(fullwidth - ideal_width, 2) - ideal_width, map_top, ideal_width, scaled_height);
642+
643+
glk_image_draw_scaled(graphwin, right_image, ideal_width + IntegerDivide(fullwidth - ideal_width, 2), map_top, ideal_width, scaled_height);
644+
614645
} else {
615646
616647
! The window is narrower than the map
2.72 KB
Loading
2.49 KB
Loading
1.61 KB
Loading
1.48 KB
Loading

0 commit comments

Comments
 (0)