ZDCMP_Int.zc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //straight from gzdoom.pk3 but with SPITEMX-Y and drawLF/EF values rearranged - ozy81
  2. class ZDCMPStatusScreen : DoomStatusScreen
  3. {
  4. override int drawLF ()
  5. {
  6. bool ispatch = wbs.LName0.isValid();
  7. int oldy = TITLEY+8 * CleanYfac;
  8. int h;
  9. if (!ispatch)
  10. {
  11. let asc = mapname.mFont.GetMaxAscender(lnametexts[1]);
  12. if (asc > TITLEY - 2)
  13. {
  14. oldy = (asc+2) * CleanYfac;
  15. }
  16. }
  17. int y = DrawName(oldy, wbs.LName0, lnametexts[0]);
  18. // If the displayed info is made of patches we need some additional offsetting here.
  19. if (ispatch)
  20. {
  21. int disp = 0;
  22. // The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps.
  23. if (authortexts[0].length() == 0)
  24. {
  25. int h1 = BigFont.GetHeight() - BigFont.GetDisplacement();
  26. int h2 = (y - oldy) / CleanYfac / 4;
  27. disp = min(h1, h2);
  28. if (!TexMan.OkForLocalization(finishedPatch, "$WI_FINISHED"))
  29. {
  30. disp += finishedp.mFont.GetMaxAscender("$WI_FINISHED");
  31. }
  32. }
  33. else
  34. {
  35. disp += author.mFont.GetMaxAscender(authortexts[0]);
  36. }
  37. y += disp * CleanYfac;
  38. }
  39. y = DrawAuthor(y, authortexts[0]);
  40. // draw "Finished!"
  41. int statsy = multiplayer? NG_STATSY : SP_STATSY * CleanYFac;
  42. if (y < (statsy - finishedp.mFont.GetHeight()*3/4) * CleanYfac)
  43. {
  44. // don't draw 'finished' if the level name is too tall
  45. y = DrawPatchOrText(y, finishedp, finishedPatch, "$WI_FINISHED");
  46. }
  47. return y;
  48. }
  49. override void drawEL ()
  50. {
  51. bool ispatch = TexMan.OkForLocalization(enteringPatch, "$WI_ENTERING");
  52. int oldy = TITLEY+8 * CleanYfac;
  53. if (!ispatch)
  54. {
  55. let asc = entering.mFont.GetMaxAscender("$WI_ENTERING");
  56. if (asc > TITLEY - 2)
  57. {
  58. oldy = (asc+2) * CleanYfac;
  59. }
  60. }
  61. int y = DrawPatchOrText(oldy, entering, enteringPatch, "$WI_ENTERING");
  62. // If the displayed info is made of patches we need some additional offsetting here.
  63. if (ispatch)
  64. {
  65. int h1 = BigFont.GetHeight() - BigFont.GetDisplacement();
  66. let size = TexMan.GetScaledSize(enteringPatch);
  67. int h2 = int(size.Y);
  68. let disp = min(h1, h2) / 4;
  69. // The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps.
  70. if (!wbs.LName1.isValid())
  71. {
  72. disp += mapname.mFont.GetMaxAscender(lnametexts[1]);
  73. }
  74. y += disp * CleanYfac;
  75. }
  76. y = DrawName(y, wbs.LName1, lnametexts[1]);
  77. if (wbs.LName1.isValid() && authortexts[1].length() > 0)
  78. {
  79. // Consdider the ascender height of the following text.
  80. y += author.mFont.GetMaxAscender(authortexts[1]) * CleanYfac;
  81. }
  82. DrawAuthor(y, authortexts[1]);
  83. }
  84. override void drawStats (void)
  85. {
  86. // line height
  87. int lh = IntermissionFont.GetHeight() * 3 / 2;
  88. drawLF();
  89. // For visual consistency, only use the patches here if all are present.
  90. bool useGfx = TexMan.OkForLocalization(Kills, "$TXT_IMKILLS")
  91. && TexMan.OkForLocalization(Items, "$TXT_IMITEMS")
  92. && TexMan.OkForLocalization(P_secret, "$TXT_IMSECRETS")
  93. && TexMan.OkForLocalization(Timepic, "$TXT_IMTIME")
  94. && (!wbs.partime || TexMan.OkForLocalization(Par, "$TXT_IMPAR"));
  95. // The font color may only be used when the entire screen is printed as text.
  96. // Otherwise the text based parts should not be translated to match the other graphics patches.
  97. let tcolor = useGfx? Font.CR_UNTRANSLATED : content.mColor;
  98. Font printFont;
  99. Font textFont = generic_ui? NewSmallFont : content.mFont;
  100. int statsx = SP_STATSX;
  101. int fix = 56;
  102. int fixT = 36;
  103. if (useGfx)
  104. {
  105. printFont = IntermissionFont;
  106. screen.DrawTexture (Kills, true, statsx, SP_STATSY, DTA_Clean, true);
  107. screen.DrawTexture (Items, true, statsx, SP_STATSY+lh, DTA_Clean, true);
  108. screen.DrawTexture (P_secret, true, statsx, SP_STATSY+2*lh, DTA_Clean, true);
  109. screen.DrawTexture (Timepic, true, SP_TIMEX, SP_TIMEY-2*lh + fix, DTA_Clean, true);
  110. if (wbs.partime) screen.DrawTexture (Par, true, 160 + SP_TIMEX, SP_TIMEY-2*lh, DTA_Clean, true);
  111. }
  112. else
  113. {
  114. // Check if everything fits on the screen.
  115. String percentage = wi_percents? " 0000%" : " 0000/0000";
  116. int perc_width = textFont.StringWidth(percentage);
  117. int k_width = textFont.StringWidth("$TXT_IMKILLS");
  118. int i_width = textFont.StringWidth("$TXT_IMITEMS");
  119. int s_width = textFont.StringWidth("$TXT_IMSECRETS");
  120. int allwidth = max(k_width, i_width, s_width) + perc_width;
  121. if ((SP_STATSX*2 + allwidth) > 320) // The content does not fit so adjust the position a bit.
  122. {
  123. statsx = max(0, (320 - allwidth) / 2);
  124. }
  125. printFont = generic_ui? IntermissionFont : BigFont;
  126. screen.DrawText (textFont, tcolor, statsx, SP_STATSY, "$TXT_IMKILLS", DTA_Clean, true);
  127. screen.DrawText (textFont, tcolor, statsx, SP_STATSY+lh, "$TXT_IMITEMS", DTA_Clean, true);
  128. screen.DrawText (textFont, tcolor, statsx, SP_STATSY+2*lh, "$TXT_IMSECRETS", DTA_Clean, true);
  129. screen.DrawText (textFont, tcolor, SP_TIMEX, SP_TIMEY-2*lh + fix, "$TXT_IMTIME", DTA_Clean, true);
  130. if (wbs.partime) screen.DrawText (textFont, tcolor, 160 + SP_TIMEX, SP_TIMEY-2*lh + fix, "$TXT_IMPAR", DTA_Clean, true);
  131. }
  132. drawPercent (printFont, 320 - statsx, SP_STATSY, cnt_kills[0], wbs.maxkills, true, tcolor);
  133. drawPercent (printFont, 320 - statsx, SP_STATSY+lh, cnt_items[0], wbs.maxitems, true, tcolor);
  134. drawPercent (printFont, 320 - statsx, SP_STATSY+2*lh, cnt_secret[0], wbs.maxsecret, true, tcolor);
  135. drawTimeFont (printFont, 276 - SP_TIMEX, SP_TIMEY-2*lh + fixT, cnt_time, tcolor);
  136. // The "sucks" related code has been removed, we don't need it - ozy81
  137. if (wi_showtotaltime)
  138. {
  139. drawTimeFont (printFont, 276 - SP_TIMEX, SP_TIMEY-2*lh + lh + fixT, cnt_total_time, tcolor);
  140. }
  141. }
  142. }