g_statusbar.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. #include <sstream>
  4. // easy statusbar wrapper
  5. struct statusbar_t
  6. {
  7. std::stringstream sb;
  8. inline auto &yb(int32_t offset) { sb << "yb " << offset << ' '; return *this; }
  9. inline auto &yt(int32_t offset) { sb << "yt " << offset << ' '; return *this; }
  10. inline auto &yv(int32_t offset) { sb << "yv " << offset << ' '; return *this; }
  11. inline auto &xl(int32_t offset) { sb << "xl " << offset << ' '; return *this; }
  12. inline auto &xr(int32_t offset) { sb << "xr " << offset << ' '; return *this; }
  13. inline auto &xv(int32_t offset) { sb << "xv " << offset << ' '; return *this; }
  14. inline auto &ifstat(player_stat_t stat) { sb << "if " << stat << ' '; return *this; }
  15. inline auto &endifstat() { sb << "endif "; return *this; }
  16. inline auto &pic(player_stat_t stat) { sb << "pic " << stat << ' '; return *this; }
  17. inline auto &picn(const char *icon) { sb << "picn " << icon << ' '; return *this; }
  18. inline auto &anum() { sb << "anum "; return *this; }
  19. inline auto &rnum() { sb << "rnum "; return *this; }
  20. inline auto &hnum() { sb << "hnum "; return *this; }
  21. inline auto &num(int32_t width, player_stat_t stat) { sb << "num " << width << ' ' << stat << ' '; return *this; }
  22. inline auto &loc_stat_string(player_stat_t stat) { sb << "loc_stat_string " << stat << ' '; return *this; }
  23. inline auto &loc_stat_rstring(player_stat_t stat) { sb << "loc_stat_rstring " << stat << ' '; return *this; }
  24. inline auto &stat_string(player_stat_t stat) { sb << "stat_string " << stat << ' '; return *this; }
  25. inline auto &loc_stat_cstring2(player_stat_t stat) { sb << "loc_stat_cstring2 " << stat << ' '; return *this; }
  26. inline auto &string2(const char *str)
  27. {
  28. if (str[0] != '"' && (strchr(str, ' ') || strchr(str, '\n')))
  29. sb << "string2 \"" << str << "\" ";
  30. else
  31. sb << "string2 " << str << ' ';
  32. return *this;
  33. }
  34. inline auto &string(const char *str)
  35. {
  36. if (str[0] != '"' && (strchr(str, ' ') || strchr(str, '\n')))
  37. sb << "string \"" << str << "\" ";
  38. else
  39. sb << "string " << str << ' ';
  40. return *this;
  41. }
  42. inline auto &loc_rstring(const char *str)
  43. {
  44. if (str[0] != '"' && (strchr(str, ' ') || strchr(str, '\n')))
  45. sb << "loc_rstring 0 \"" << str << "\" ";
  46. else
  47. sb << "loc_rstring 0 " << str << ' ';
  48. return *this;
  49. }
  50. inline auto &lives_num(player_stat_t stat) { sb << "lives_num " << stat << ' '; return *this; }
  51. inline auto &stat_pname(player_stat_t stat) { sb << "stat_pname " << stat << ' '; return *this; }
  52. inline auto &health_bars() { sb << "health_bars "; return *this; }
  53. inline auto &story() { sb << "story "; return *this; }
  54. };