trinitystat.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. ! Trinitystat.h
  2. ! This library gives the ability to switch between the normal statusline and a
  3. ! Trinity style statusline. It works for both the Z-Machine and Glulx, and
  4. ! should work on all three compilers. (G.N.'s Z-Machine compiler, A.P.'s Glulx
  5. ! compiler, and A.P.'s biplatform compiler.) It has only been tested on the
  6. ! biplatform compiler, though.
  7. ! You must, of course, Replace DrawStatusLine; for this to work.
  8. ! An object is supplied, statline, with a property trinity. If trinity is true,
  9. ! then you will have a Trinity-style line. Guess what happens if trinity is
  10. ! false?
  11. ! If you have defined Constant DEBUG;, then you get an extra debugging verb.
  12. ! Typing "trinity" will switch statusline styles.
  13. ! Copyright (C) 2000 by Jonathan Rosebaugh. Released under GPL version 2.
  14. ! see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  15. ! This is necessary to compile with Graham's current Inform 6.21 compiler.
  16. #ifndef WORDSIZE;
  17. Constant TARGET_ZCODE;
  18. Constant WORDSIZE 2;
  19. #endif;
  20. ! Debugging verb
  21. #ifdef DEBUG;
  22. Object statline with trinity 0;
  23. Verb meta "trinity"
  24. * -> Trinity;
  25. [TrinitySub;
  26. statline.trinity = (~~(statline.trinity));
  27. ];
  28. #endif;
  29. ! Z-Code version
  30. #ifdef TARGET_ZCODE;
  31. Array printed_text table 64;
  32. #IFV5;
  33. [ DrawStatusLine width posa posb i j;
  34. if (statline.trinity)
  35. {
  36. i = 0->33; if (i==0) i=80;
  37. font off;
  38. @split_window 1; @buffer_mode 0; @set_window 1;
  39. style reverse; @set_cursor 1 1; spaces(i);
  40. printed_text-->0 = 64;
  41. @output_stream 3 printed_text;
  42. if (location == thedark) print (name) location;
  43. else
  44. { FindVisibilityLevels();
  45. if (visibility_ceiling == location)
  46. print (name) location;
  47. else print (The) visibility_ceiling;
  48. }
  49. @output_stream -3;
  50. j=(i-(printed_text-->0))/2;
  51. @set_cursor 1 j; print (name) location; spaces(j-1);
  52. style roman;
  53. @buffer_mode 1; @set_window 0; font on;
  54. }
  55. else { @split_window 1; @set_window 1; @set_cursor 1 1; style reverse;
  56. width = 0->33; posa = width-26; posb = width-13;
  57. spaces width;
  58. @set_cursor 1 2;
  59. if (location == thedark) print (name) location;
  60. else
  61. { FindVisibilityLevels();
  62. if (visibility_ceiling == location)
  63. print (name) location;
  64. else print (The) visibility_ceiling;
  65. }
  66. if ((0->1)&2 == 0)
  67. { if (width > 76)
  68. { @set_cursor 1 posa; print (string) SCORE__TX, sline1;
  69. @set_cursor 1 posb; print (string) MOVES__TX, sline2;
  70. }
  71. if (width > 63 && width <= 76)
  72. { @set_cursor 1 posb; print sline1, "/", sline2;
  73. }
  74. }
  75. else
  76. { @set_cursor 1 posa;
  77. print (string) TIME__TX;
  78. LanguageTimeOfDay(sline1, sline2);
  79. }
  80. @set_cursor 1 1; style roman; @set_window 0;
  81. }
  82. ];
  83. #ENDIF;
  84. #endif; ! TARGET_ZCODE
  85. ! Glulx version
  86. #ifdef TARGET_GLULX;
  87. Array bluelalablankage-->1;
  88. [ DrawStatusLine width height posa posb centerarea;
  89. ! If we have no status window, we must not try to redraw it.
  90. if (gg_statuswin == 0)
  91. return;
  92. ! If there is no player location, we shouldn't try either.
  93. if (location == nothing || parent(player) == nothing)
  94. return;
  95. glk($002F, gg_statuswin); ! set_window
  96. StatusLineHeight(gg_statuswin_size);
  97. glk($0025, gg_statuswin, gg_arguments, gg_arguments+4);
  98. ! window_get_size
  99. width = gg_arguments-->0;
  100. height = gg_arguments-->1;
  101. posa = width-26; posb = width-13;
  102. glk($002A, gg_statuswin); ! window_clear
  103. if (statline.trinity)
  104. {
  105. if (location == thedark) {
  106. centerarea = (width/2) - (PrintAnyToArray(bluelalablankage,0, location)/2);
  107. }
  108. else {
  109. FindVisibilityLevels();
  110. if (visibility_ceiling == location)
  111. centerarea = (width/2) - ((PrintAnyToArray(bluelalablankage,0,
  112. location)) / 2);
  113. else
  114. centerarea = (width/2) - (PrintAnyToArray(bluelalablankage,0,
  115. visibility_ceiling)/2);
  116. }
  117. glk_window_move_cursor( gg_statuswin, centerarea, 0);
  118. if (visibility_ceiling == location)
  119. print (name) location;
  120. else
  121. print (The) visibility_ceiling;
  122. }
  123. else {
  124. glk($002B, gg_statuswin, 1, 0); ! window_move_cursor
  125. if (location == thedark) {
  126. print (name) location;
  127. }
  128. else {
  129. FindVisibilityLevels();
  130. if (visibility_ceiling == location)
  131. print (name) location;
  132. else
  133. print (The) visibility_ceiling;
  134. }
  135. if (width > 66) {
  136. glk($002B, gg_statuswin, posa-1, 0); ! window_move_cursor
  137. print (string) SCORE__TX, sline1;
  138. glk($002B, gg_statuswin, posb-1, 0); ! window_move_cursor
  139. print (string) MOVES__TX, sline2;
  140. }
  141. if (width > 53 && width <= 66) {
  142. glk($002B, gg_statuswin, posb-1, 0); ! window_move_cursor
  143. print sline1, "/", sline2;
  144. }
  145. }
  146. glk($002F, gg_mainwin); ! set_window
  147. ];
  148. #endif; ! TARGET_GLULX