1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00
inform7/inter/codegen-module/Chapter 6/Map Element.w

246 lines
7.9 KiB
OpenEdge ABL
Raw Normal View History

2021-06-03 01:10:13 +03:00
[IXPhysicalWorld::] Map Element.
2019-02-05 02:44:07 +02:00
This section masterminds the creation of the World and Kinds index
pages, though it delegates much of the work elsewhere. Though it does belong
to core Inform, these indexes will look pretty sparse if the spatial Plugins
aren't plugged in.
@h The World page.
=
int suppress_panel_changes = FALSE;
void IXPhysicalWorld::render(OUTPUT_STREAM, int test_only) {
2021-06-22 22:37:53 +03:00
PL::SpatialMap::initialise_page_directions();
2021-06-22 01:37:27 +03:00
IXInstances::make_faux();
2019-02-05 02:44:07 +02:00
PL::SpatialMap::establish_spatial_coordinates();
if (test_only) {
PL::SpatialMap::perform_map_internal_test(OUT);
} else {
PL::HTMLMap::render_map_as_HTML(OUT);
PL::HTMLMap::add_region_key(OUT);
IXBackdrops::index_object_further(OUT, NULL, 0, FALSE, 1);
Index::anchor(OUT, I"MDETAILS");
int unruly = FALSE;
@<Mark parts, directions and kinds as ineligible for listing in the World index@>;
@<Give room details within each region in turn in the World index@>;
@<Give room details for rooms outside any region in the World index@>;
@<Give details of everything still unmentioned in the World index@>;
}
2019-02-05 02:44:07 +02:00
}
@<Mark parts, directions and kinds as ineligible for listing in the World index@> =
2021-06-22 01:37:27 +03:00
faux_instance *I;
LOOP_OVER_OBJECTS(I)
2021-02-25 02:15:09 +02:00
if ((IXSpatial::no_detail_index(I))
2021-06-22 01:37:27 +03:00
|| (IXInstances::is_a_direction(I)))
2021-02-13 01:46:18 +02:00
IXInstances::increment_indexing_count(I);
2019-02-05 02:44:07 +02:00
@<Give room details within each region in turn in the World index@> =
2021-06-22 01:37:27 +03:00
faux_instance *reg;
LOOP_OVER_OBJECTS(reg)
if (IXInstances::is_a_region(reg)) {
2019-02-05 02:44:07 +02:00
int subheaded = FALSE;
2021-02-13 01:46:18 +02:00
IXInstances::increment_indexing_count(reg);
2021-06-22 01:37:27 +03:00
faux_instance *rm;
LOOP_OVER_ROOMS(rm)
if (IXInstances::region_of(rm) == reg) {
2019-02-05 02:44:07 +02:00
if (subheaded == FALSE) {
@<Start a new details panel on the World index@>;
@<Index the name and super-region of the region@>;
2021-02-25 02:15:09 +02:00
IXBackdrops::index_object_further(OUT, reg, 0, FALSE, 2);
2019-02-05 02:44:07 +02:00
HTML_OPEN("p");
subheaded = TRUE;
}
PL::HTMLMap::render_single_room_as_HTML(OUT, rm);
2021-02-13 01:46:18 +02:00
IXInstances::increment_indexing_count(rm);
2019-02-05 02:44:07 +02:00
}
}
@<Index the name and super-region of the region@> =
2021-06-22 12:53:56 +03:00
WRITE("<b>The <i>%S</i> region", IXInstances::get_name(reg));
2021-06-22 01:37:27 +03:00
faux_instance *within = IXInstances::region_of(reg);
2021-06-22 12:53:56 +03:00
if (within) WRITE(" within the <i>%S</i> region", IXInstances::get_name(within));
2019-02-05 02:44:07 +02:00
WRITE("</b>");
@<Give room details for rooms outside any region in the World index@> =
2021-06-22 01:37:27 +03:00
faux_instance *I;
LOOP_OVER_ROOMS(I)
if (IXInstances::indexed_yet(I) == FALSE) {
2019-02-05 02:44:07 +02:00
@<Start a new details panel on the World index@>;
PL::HTMLMap::render_single_room_as_HTML(OUT, I);
}
@ By this point we've accounted for rooms (and their contents and any parts
thereof), directions (which we excluded), regions (ditto), and the player
object (which the Player plugin put in the right place). The only remainder
will be things which are offstage (and their contents and any parts thereof):
@<Give details of everything still unmentioned in the World index@> =
int out_of_play_count = 0;
2021-06-22 01:37:27 +03:00
faux_instance *I;
LOOP_OVER_OBJECTS(I)
2021-02-13 01:46:18 +02:00
if ((IXInstances::indexed_yet(I) == FALSE) &&
2021-06-22 01:37:27 +03:00
(IXInstances::progenitor(I) == NULL)) {
2019-02-05 02:44:07 +02:00
@<Start a new details panel on the World index@>;
if (++out_of_play_count == 1) {
suppress_panel_changes = TRUE;
WRITE("<b>Nowhere (that is, initially not in any room):</b>");
HTML_TAG("br");
}
2021-06-17 00:34:33 +03:00
IXPhysicalWorld::index(OUT, I, 2, FALSE);
2019-02-05 02:44:07 +02:00
}
suppress_panel_changes = FALSE;
@<Start a new details panel on the World index@> =
if ((unruly) && (suppress_panel_changes == FALSE)) HTML_TAG("hr");
unruly = TRUE;
@h Indexing individual objects.
2021-06-15 01:29:45 +03:00
@default MAX_OBJECT_INDEX_DEPTH 10000
2019-02-05 02:44:07 +02:00
=
2021-06-22 01:37:27 +03:00
faux_instance *indexing_room = NULL;
2019-02-05 02:44:07 +02:00
int xtras_count = 0;
2021-06-22 01:37:27 +03:00
faux_instance *IXPhysicalWorld::room_being_indexed(void) {
2020-08-26 12:52:50 +03:00
return indexing_room;
}
2021-06-22 01:37:27 +03:00
void IXPhysicalWorld::set_room_being_indexed(faux_instance *I) {
2021-06-14 11:00:18 +03:00
indexing_room = I;
}
2021-06-22 01:37:27 +03:00
void IXPhysicalWorld::index(OUTPUT_STREAM, faux_instance *I, int depth, int details) {
2019-02-05 02:44:07 +02:00
if (depth == MAX_OBJECT_INDEX_DEPTH) internal_error("MAX_OBJECT_INDEX_DEPTH exceeded");
if (I) {
2021-06-22 01:37:27 +03:00
if (depth > NUMBER_CREATED(faux_instance) + 1) return; /* to recover from errors */
2021-02-13 01:46:18 +02:00
IXInstances::increment_indexing_count(I);
2021-06-22 01:37:27 +03:00
if (IXInstances::is_a_room(I)) indexing_room = I;
2019-02-05 02:44:07 +02:00
}
@<Begin the object citation line@>;
int xtra = -1;
if (I) xtra = xtras_count++;
if (xtra >= 0) Index::extra_link(OUT, xtra);
@<Index the name part of the object citation@>;
if (I) @<Index the kind attribution part of the object citation@>;
@<Index the link icons part of the object citation@>;
@<End the object citation line@>;
if (details) @<Add a subsidiary paragraph of details about this object@>;
if (xtra >= 0) {
Index::extra_div_open(OUT, xtra, depth+1, "e0e0e0");
@<Add the chain of kinds@>;
@<Add the catalogue of specific properties@>;
2021-06-23 02:23:35 +03:00
@<Add details depending on the kind@>;
2021-06-21 12:54:37 +03:00
IXPhysicalWorld::index_usages(OUT, I);
2019-02-05 02:44:07 +02:00
Index::extra_div_close(OUT, "e0e0e0");
}
@<Recurse the index citation for the object as necessary@>;
}
@<Begin the object citation line@> =
if (details) {
2020-05-10 19:33:41 +03:00
HTML::open_indented_p(OUT, depth, "halftight");
2021-06-22 01:37:27 +03:00
if (I != indexing_room) Index::anchor(OUT, I->anchor_text);
2019-02-05 02:44:07 +02:00
} else {
#ifdef IF_MODULE
2021-02-25 02:15:09 +02:00
if (I) IXSpatial::index_spatial_relationship(OUT, I);
2019-02-05 02:44:07 +02:00
#endif
}
@<End the object citation line@> =
2021-06-17 00:34:33 +03:00
if (details) HTML_CLOSE("p");
2019-02-05 02:44:07 +02:00
@<Index the name part of the object citation@> =
2021-06-17 00:34:33 +03:00
@<Quote the name of the object being indexed@>;
2019-02-05 02:44:07 +02:00
@<Quote the name of the object being indexed@> =
2021-06-22 01:37:27 +03:00
TEMPORARY_TEXT(name)
IXInstances::write_name(name, I);
if ((Str::len(name) == 0) && (I)) IXInstances::write_kind(name, I);
if (Str::len(name) == 0) {
2019-02-05 02:44:07 +02:00
WRITE("nameless");
} else {
int embolden = details;
2021-06-22 01:37:27 +03:00
if (IXInstances::is_a_room(I)) embolden = TRUE;
2019-02-05 02:44:07 +02:00
if (embolden) WRITE("<b>");
2021-06-22 01:37:27 +03:00
WRITE("%S", name);
2019-02-05 02:44:07 +02:00
if (embolden) WRITE("</b>");
if (details) @<Elaborate the name of the object being indexed@>;
}
@<Elaborate the name of the object being indexed@> =
if (I) {
2021-06-22 01:37:27 +03:00
WRITE(", a kind of ");
IXInstances::write_kind(OUT, I);
2019-02-05 02:44:07 +02:00
}
@<Index the kind attribution part of the object citation@> =
2021-06-23 02:23:35 +03:00
if ((IXMap::annotate_in_World_index(OUT, I) == FALSE) &&
(IXPlayer::annotate_in_World_index(OUT, I) == FALSE)) {
2021-06-22 01:37:27 +03:00
if (I->specify_kind) {
WRITE(" - <i>");
IXInstances::write_kind(OUT, I);
WRITE("</i>");
2019-02-05 02:44:07 +02:00
}
}
@<Index the link icons part of the object citation@> =
2021-06-22 01:37:27 +03:00
if (I->created_at > 0) Index::link(OUT, I->created_at);
2019-02-05 02:44:07 +02:00
@ This either recurses down through subkinds or through the spatial hierarchy.
@<Recurse the index citation for the object as necessary@> =
2021-06-17 00:34:33 +03:00
#ifdef IF_MODULE
IXSpatial::index_object_further(OUT, I, depth, details);
#endif
2019-02-05 02:44:07 +02:00
@<Add a subsidiary paragraph of details about this object@> =
2020-05-10 19:33:41 +03:00
HTML::open_indented_p(OUT, depth, "tight");
2021-06-27 16:56:29 +03:00
text_stream *material = Metadata::read_optional_textual(I->package, I"^brief_inferences");
WRITE("%S", material);
2019-02-05 02:44:07 +02:00
@<Add the chain of kinds@> =
2020-05-10 19:33:41 +03:00
HTML::open_indented_p(OUT, 1, "tight");
2021-06-22 01:37:27 +03:00
IXInstances::write_kind_chain(OUT, I);
if (I->kind_set_at > 0) Index::link(OUT, I->kind_set_at);
2019-02-05 02:44:07 +02:00
WRITE(" &gt; <b>");
2021-06-22 01:37:27 +03:00
IXInstances::write_name(OUT, I);
2019-02-05 02:44:07 +02:00
WRITE("</b>");
HTML_CLOSE("p");
@<Add the catalogue of specific properties@> =
2021-06-27 16:56:29 +03:00
text_stream *material = Metadata::read_optional_textual(I->package, I"^specific_inferences");
WRITE("%S", material);
2021-06-21 12:54:37 +03:00
2021-06-23 02:23:35 +03:00
@<Add details depending on the kind@> =
IXMap::add_to_World_index(OUT, I);
IXRegions::add_to_World_index(OUT, I);
IXSpatial::add_to_World_index(OUT, I);
2021-06-21 12:54:37 +03:00
@
=
2021-06-22 01:37:27 +03:00
void IXPhysicalWorld::index_usages(OUTPUT_STREAM, faux_instance *I) {
2021-06-21 12:54:37 +03:00
int k = 0;
2021-06-27 16:56:29 +03:00
inter_package *pack = I->package;
inter_tree_node *P = Metadata::read_optional_list(pack, I"^backdrop_presences");
if (P) {
int offset = DATA_CONST_IFLD;
while (offset < P->W.extent) {
inter_ti v1 = P->W.data[offset], v2 = P->W.data[offset+1];
if (v1 == LITERAL_IVAL) {
k++;
if (k == 1) {
HTML::open_indented_p(OUT, 1, "tight");
WRITE("<i>mentioned in rules:</i> ");
} else WRITE("; ");
Index::link(OUT, (int) v2);
} else internal_error("malformed usage metadata");
offset += 2;
2021-06-21 12:54:37 +03:00
}
}
if (k > 0) HTML_CLOSE("p");
}