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.

50 lines
1.6KB

  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. * GUI checkboxes.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include "common.h"
  14. #include "p_player.h"
  15. bool G_ChkBox_Imp(struct gui_state *g, u32 id, struct gui_arg_cbx const *a) {
  16. struct gui_pre_cbx const *pre = a->preset ? a->preset : &gui_p.cbxdef;
  17. if(!a->disabled)
  18. G_Auto(g, id, a->x, a->y, pre->w, pre->h);
  19. __with(char bgfx[30], cgfx[30];) {
  20. if(g->hot == id && pre->hot) G_Prefix(g, bgfx, pre, hot);
  21. else G_Prefix(g, bgfx, pre, gfx);
  22. /**/ if(g->active == id && pre->chkact) G_Prefix(g, cgfx, pre, chkact);
  23. else if(g->hot == id && pre->chkhot) G_Prefix(g, cgfx, pre, chkhot);
  24. else G_Prefix(g, cgfx, pre, chkgfx);
  25. if(!a->on) cgfx[0] = '\0';
  26. i32 cbx = a->x + pre->cx;
  27. i32 cby = a->y + pre->cy;
  28. if(bgfx[0]) PrintSprite(l_strdup(bgfx), a->x + g->ox,1, a->y + g->oy,1);
  29. if(cgfx[0]) PrintSprite(l_strdup(cgfx), cbx + g->ox,1, cby + g->oy,1);
  30. }
  31. if(g->hot == id && g->active == id && !g->clicklft) {
  32. if(a->on) {if(pre->snddn) ACS_LocalAmbientSound(pre->snddn, 127);}
  33. else {if(pre->sndup) ACS_LocalAmbientSound(pre->sndup, 127);}
  34. return true;
  35. } else {
  36. return false;
  37. }
  38. }
  39. /* EOF */