You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

p_log.c 5.3KB

2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
Changes 2/1/2017 through 3/1/2017 Forgot to commit for a while, sorry! Fix combat rifle sprites conflicting with DRLA monsters Add impact sounds to cannoballs Add quit sounds Add a title map Add confirmation text for extra hard/nightmare difficulties Add cluster intermission texts Add finale sequence Make the cannon easier to use (again) Add unfinished Game Nanhai shop "weapon" Fix the sniper rifle making things fly away and gib Make the shotgun slightly weaker (again) Make the laser shotgun slightly stronger (again) Balance the knife a bit Add loading screen Upgr::VitalScan: Make names and text flip out at stronger enemies CBI: Stretch the GUI to 320x240 from 320x200 GUI: Implement checkboxes GUI: Add width/height parameters for whole GUI GUI: Add color parameter to button GUI: Add new list button presets World: Add enemy compatibility checks Upgrades: Generalize upgrade group types Upgrades: Switch buying over to shopdef system Upgrades: Add auto-groups Upgrades: Move function defs into their own header CBI::Settings: Add missing cvars Player: Split player_t data into several structures Player: Generalize GUI switching code Player: Split p_player.c over several files Upgr::HeadsUpDisp: Add a small fade when switching weapons TurboHitler: Change upgrade setup parameters to strings Upgr::AutoReload: Add description Shop: Remove some items from the shop Info: Fix pistol's description Info: Add missing descriptions Info: Fix arachnotron/mastermind names Update package.bat Add NetFile module Add Games module Add SaveData module Add ShopDef module Rename C files for categorization Bump version number Add miscallaneous text changes
4 years ago
Changes 2/1/2017 through 3/1/2017 Forgot to commit for a while, sorry! Fix combat rifle sprites conflicting with DRLA monsters Add impact sounds to cannoballs Add quit sounds Add a title map Add confirmation text for extra hard/nightmare difficulties Add cluster intermission texts Add finale sequence Make the cannon easier to use (again) Add unfinished Game Nanhai shop "weapon" Fix the sniper rifle making things fly away and gib Make the shotgun slightly weaker (again) Make the laser shotgun slightly stronger (again) Balance the knife a bit Add loading screen Upgr::VitalScan: Make names and text flip out at stronger enemies CBI: Stretch the GUI to 320x240 from 320x200 GUI: Implement checkboxes GUI: Add width/height parameters for whole GUI GUI: Add color parameter to button GUI: Add new list button presets World: Add enemy compatibility checks Upgrades: Generalize upgrade group types Upgrades: Switch buying over to shopdef system Upgrades: Add auto-groups Upgrades: Move function defs into their own header CBI::Settings: Add missing cvars Player: Split player_t data into several structures Player: Generalize GUI switching code Player: Split p_player.c over several files Upgr::HeadsUpDisp: Add a small fade when switching weapons TurboHitler: Change upgrade setup parameters to strings Upgr::AutoReload: Add description Shop: Remove some items from the shop Info: Fix pistol's description Info: Add missing descriptions Info: Fix arachnotron/mastermind names Update package.bat Add NetFile module Add Games module Add SaveData module Add ShopDef module Rename C files for categorization Bump version number Add miscallaneous text changes
4 years ago
1 year ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* ---------------------------------------------------------------------------|
  2. *
  3. * Distributed under the CC0 public domain license.
  4. * By Alison G. Watson. Attribution is encouraged, though not required.
  5. * See licenses/cc0.txt for more information.
  6. *
  7. * ---------------------------------------------------------------------------|
  8. *
  9. * Log UI and logging functions.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include "common.h"
  14. #include "p_log.h"
  15. #include "p_player.h"
  16. #include "m_list.h"
  17. #include "p_hudid.h"
  18. #include "w_world.h"
  19. /* Static Functions -------------------------------------------------------- */
  20. static void LogV(i32 levl) {
  21. ACS_BeginPrint();
  22. if(levl) {
  23. for(i32 i = 0; i < levl; i++) ACS_PrintChar('>');
  24. ACS_PrintChar(' ');
  25. }
  26. }
  27. static void LogPop(struct player *p) {
  28. p->log.hudC--;
  29. fastmemmove(&p->log.hudV[0], &p->log.hudV[1], sizeof p->log.hudV[0] * p->log.hudC);
  30. }
  31. static void LogH(struct player *p, struct logdat *ld) {
  32. ld->ftim = 5;
  33. ld->time = 140 - p->log.curtime;
  34. p->log.curtime = 140;
  35. if(p->log.hudC >= countof(p->log.hudV)) LogPop(p);
  36. p->log.hudV[p->log.hudC++] = *ld;
  37. }
  38. static void LogF(struct player *p, struct logfdt *lf) {
  39. Vec_GrowN(p->log.curmap->data, 1, 8, _tag_logs);
  40. Vec_Next(p->log.curmap->data) = *lf;
  41. }
  42. /* Extern Functions -------------------------------------------------------- */
  43. void P_Log_Both(struct player *p, i32 levl, cstr fmt, ...) {
  44. struct logdat ld = {};
  45. LogV(levl);
  46. va_list vl;
  47. va_start(vl, fmt);
  48. __vnprintf(fmt, vl);
  49. va_end(vl);
  50. ld.inf = ACS_EndStrParam();
  51. LogF(p, &ld.fdta);
  52. LogH(p, &ld);
  53. }
  54. void P_Log_HUDs(struct player *p, i32 levl, cstr fmt, ...) {
  55. struct logdat ld = {};
  56. LogV(levl);
  57. va_list vl;
  58. va_start(vl, fmt);
  59. __vnprintf(fmt, vl);
  60. va_end(vl);
  61. ld.inf = ACS_EndStrParam();
  62. LogH(p, &ld);
  63. }
  64. void P_Log_Full(struct player *p, cstr fmt, ...) {
  65. struct logfdt lf = {};
  66. ACS_BeginPrint();
  67. va_list vl;
  68. va_start(vl, fmt);
  69. __vnprintf(fmt, vl);
  70. va_end(vl);
  71. lf.inf = ACS_EndStrParam();
  72. LogF(p, &lf);
  73. }
  74. void P_Log_Entry(struct player *p) {
  75. struct logmap *lm = nil;
  76. i32 lnum = MapNum;
  77. for(i32 i = 0; i < p->log.mapsC; i++)
  78. if(p->log.mapsV[i].lnum == lnum) {lm = &p->log.mapsV[i]; break;}
  79. if(!lm)
  80. {
  81. Vec_GrowN(p->log.maps, 1, 32, _tag_logs);
  82. lm = &Vec_Next(p->log.maps);
  83. lm->name = (ACS_BeginPrint(), ACS_PrintName(PRINTNAME_LEVELNAME), ACS_EndStrParam());
  84. lm->lnum = lnum;
  85. }
  86. p->log.curmap = lm;
  87. p->logF(LC(LANG "ENTER_FMT"), lm->name, CanonTime(ct_full, ticks));
  88. }
  89. script void P_Log_PTick(struct player *p) {
  90. if(p->log.curtime == 0) {
  91. if(p->log.hudC) {
  92. LogPop(p);
  93. p->log.curtime = p->log.hudV[p->log.hudC - 1].time;
  94. }
  95. } else {
  96. p->log.curtime--;
  97. }
  98. for(i32 i = 0; i < p->log.hudC; i++) {
  99. if(p->log.hudV[i].ftim) {
  100. p->log.hudV[i].ftim--;
  101. }
  102. }
  103. }
  104. void P_CBI_TabLog(struct gui_state *g, struct player *p) {
  105. static i32 const ht = 10;
  106. if(G_Button(g, .x = 25, 38, Pre(btnprev)))
  107. if(--CBIState(g)->logsel < 0) CBIState(g)->logsel = p->log.mapsC - 1;
  108. if(G_Button(g, .x = 25 + gui_p.btnprev.w, 38, Pre(btnnext)))
  109. if(++CBIState(g)->logsel >= p->log.mapsC) CBIState(g)->logsel = 0;
  110. struct logmap *lm = &p->log.mapsV[CBIState(g)->logsel];
  111. PrintText_str(lm->name, s_lmidfont, g->defcr, 28+gui_p.btnprev.w+gui_p.btnnext.w,1, 40,1);
  112. G_ScrBeg(g, &CBIState(g)->logscr, 15, 50, 280, 175, lm->dataC * ht);
  113. for(i32 i = 0; i < lm->dataC; i++) {
  114. i32 const y = ht * i;
  115. if(G_ScrOcc(g, &CBIState(g)->logscr, y, ht)) continue;
  116. PrintSprite(sp_UI_LogList, g->ox,1, y + g->oy,1);
  117. PrintText_str(lm->dataV[i].inf, s_smallfnt, CR_GREEN, g->ox + 2,1, y + g->oy + 1,1);
  118. }
  119. G_ScrEnd(g, &CBIState(g)->logscr);
  120. }
  121. script void HUD_Log(struct player *p, i32 cr, i32 x, i32 yy) {
  122. if(p->getCVarI(sc_hud_showlog)) {
  123. k32 scale = p->getCVarK(sc_hud_logsize);
  124. i32 yo = 200 / scale;
  125. i32 xs = 320 / scale;
  126. i32 ys = 240 / scale;
  127. SetSize(xs, ys);
  128. SetClipW(0, 0, xs, ys, xs);
  129. i32 i = 0;
  130. for(i32 i = 0; i < p->log.hudC; i++) {
  131. struct logdat const *const ld = &p->log.hudV[i];
  132. i32 y = 10 * i;
  133. i32 ya;
  134. if(p->getCVarI(sc_hud_logfromtop)) {ya = 1; y = 20 + y;}
  135. else {ya = 2; y = (yo - y) + yy;}
  136. PrintText_str(ld->inf, s_lmidfont, cr, x,1, y,ya);
  137. if(ld->ftim) SetFade(fid_logadS + i, 1, 8);
  138. if(CheckFade(fid_logadS + i)) {
  139. cstr s = RemoveTextColors_str(ld->inf, ACS_StrLen(ld->inf));
  140. PrintTextChS(s);
  141. PrintTextFX(s_lmidfont, CR_WHITE, x,1, y,ya, fid_logadS + i, ptf_add);
  142. }
  143. }
  144. SetSize(320, 240);
  145. }
  146. }
  147. /* Scripts ----------------------------------------------------------------- */
  148. script_str ext("ACS") addr(OBJ "LogS")
  149. void Sc_Log(i32 levl, i32 type) {
  150. str name = ServCallS(sm_GetLogName);
  151. if(name[0] == '_') name = Language(LANG "LOG%S", name);
  152. with_player(LocalPlayer) switch(type) {
  153. case msg_ammo: if(p->getCVarI(sc_player_ammolog))
  154. case msg_huds: p->logH(levl, "%S", name); break;
  155. case msg_full: p->logF( "%S", name); break;
  156. case msg_both: p->logB(levl, "%S", name); break;
  157. }
  158. }
  159. /* EOF */