static int next_enter(struct state *st, struct state *prev) { int id, jd; char str[MAXSTR]; sprintf(str, _("Hole %02d"), curr_hole()); if ((id = gui_vstack(0))) { gui_label(id, str, GUI_MED, 0, 0); gui_space(id); if ((jd = gui_vstack(id))) { gui_label(jd, _("Player"), GUI_SML, 0, 0); switch (curr_player()) { case 1: gui_label(jd, "1", GUI_LRG, gui_red, gui_wht); if (curr_party() > 1) audio_play(AUD_PLAYER1, 1.f); break; case 2: gui_label(jd, "2", GUI_LRG, gui_grn, gui_wht); if (curr_party() > 1) audio_play(AUD_PLAYER2, 1.f); break; case 3: gui_label(jd, "3", GUI_LRG, gui_blu, gui_wht); if (curr_party() > 1) audio_play(AUD_PLAYER3, 1.f); break; case 4: gui_label(jd, "4", GUI_LRG, gui_yel, gui_wht); if (curr_party() > 1) audio_play(AUD_PLAYER4, 1.f); break; } gui_set_rect(jd, GUI_ALL); } gui_layout(id, 0, 0); } hud_init(); game_set_fly(1.f); if (paused) paused = 0; return id; }
static int score_card(const char *title, const float *c0, const float *c1) { int id, jd, kd, ld; int p1 = (curr_party() >= 1) ? 1 : 0, l1 = (curr_party() == 1) ? 1 : 0; int p2 = (curr_party() >= 2) ? 1 : 0, l2 = (curr_party() == 2) ? 1 : 0; int p3 = (curr_party() >= 3) ? 1 : 0, l3 = (curr_party() == 3) ? 1 : 0; int p4 = (curr_party() >= 4) ? 1 : 0, l4 = (curr_party() == 4) ? 1 : 0; int i; int n = curr_count() - 1; int m = curr_count() / 2; if ((id = gui_vstack(0))) { gui_label(id, title, GUI_MED, GUI_ALL, c0, c1); gui_space(id); if ((jd = gui_hstack(id))) { if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("O"), 0, GUI_NE, 0, 0); if (p1) gui_label(kd, hole_out(0), 0, 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_out(1), 0, GUI_SE * l1, gui_red, gui_wht); if (p2) gui_label(kd, hole_out(2), 0, GUI_SE * l2, gui_grn, gui_wht); if (p3) gui_label(kd, hole_out(3), 0, GUI_SE * l3, gui_blu, gui_wht); if (p4) gui_label(kd, hole_out(4), 0, GUI_SE * l4, gui_yel, gui_wht); } if ((kd = gui_harray(jd))) for (i = m; i > 0; i--) if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, number(i), 0, (i == 1) ? GUI_NW : 0, 0, 0); if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht); if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht); if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht); if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht); if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht); } if ((kd = gui_varray(jd))) { gui_filler(kd); if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht); if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht); if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht); if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht); if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht); } } gui_space(id); if ((jd = gui_hstack(id))) { if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("Tot"), 0, GUI_TOP, 0, 0); if (p1) gui_label(kd, hole_tot(0), 0, 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_tot(1), 0, GUI_BOT * l1, gui_red, gui_wht); if (p2) gui_label(kd, hole_tot(2), 0, GUI_BOT * l2, gui_grn, gui_wht); if (p3) gui_label(kd, hole_tot(3), 0, GUI_BOT * l3, gui_blu, gui_wht); if (p4) gui_label(kd, hole_tot(4), 0, GUI_BOT * l4, gui_yel, gui_wht); } if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("I"), 0, GUI_NE, 0, 0); if (p1) gui_label(kd, hole_in(0), 0, 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_in(1), 0, GUI_SE * l1, gui_red, gui_wht); if (p2) gui_label(kd, hole_in(2), 0, GUI_SE * l2, gui_grn, gui_wht); if (p3) gui_label(kd, hole_in(3), 0, GUI_SE * l3, gui_blu, gui_wht); if (p4) gui_label(kd, hole_in(4), 0, GUI_SE * l4, gui_yel, gui_wht); } if ((kd = gui_harray(jd))) for (i = n; i > m; i--) if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, number(i), 0, (i == m+1) ? GUI_NW : 0, 0, 0); if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht); if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht); if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht); if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht); if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht); } if ((kd = gui_varray(jd))) { gui_filler(kd); if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht); if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht); if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht); if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht); if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht); } } gui_layout(id, 0, 0); } return id; }
static void game_draw_balls(struct s_rend *rend, const struct s_vary *fp, const float *bill_M, float t) { static const GLfloat color[5][4] = { { 1.0f, 1.0f, 1.0f, 0.7f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f }, { 1.0f, 1.0f, 0.0f, 1.0f }, }; int ui; sol_color_mtrl(rend, 1); for (ui = curr_party(); ui > 0; ui--) { if (ui == ball) { float ball_M[16]; float pend_M[16]; m_basis(ball_M, fp->uv[ui].e[0], fp->uv[ui].e[1], fp->uv[ui].e[2]); m_basis(pend_M, fp->uv[ui].E[0], fp->uv[ui].E[1], fp->uv[ui].E[2]); glPushMatrix(); { glTranslatef(fp->uv[ui].p[0], fp->uv[ui].p[1] + BALL_FUDGE, fp->uv[ui].p[2]); glScalef(fp->uv[ui].r, fp->uv[ui].r, fp->uv[ui].r); glColor4f(color[ui][0], color[ui][1], color[ui][2], color[ui][3]); ball_draw(rend, ball_M, pend_M, bill_M, t); } glPopMatrix(); } else { glPushMatrix(); { glTranslatef(fp->uv[ui].p[0], fp->uv[ui].p[1] - fp->uv[ui].r + BALL_FUDGE, fp->uv[ui].p[2]); glScalef(fp->uv[ui].r, fp->uv[ui].r, fp->uv[ui].r); glColor4f(color[ui][0], color[ui][1], color[ui][2], 0.5f); mark_draw(rend); } glPopMatrix(); } } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); sol_color_mtrl(rend, 0); }
static int score_card(const char *title, const GLubyte *c0, const GLubyte *c1) { int id, jd, kd, ld; int p1 = (curr_party() >= 1) ? 1 : 0; int p2 = (curr_party() >= 2) ? 1 : 0; int p3 = (curr_party() >= 3) ? 1 : 0; int p4 = (curr_party() >= 4) ? 1 : 0; int i; int n = curr_count() - 1; int m = curr_count() / 2; if ((id = gui_vstack(0))) { gui_label(id, title, GUI_MED, c0, c1); gui_space(id); if ((jd = gui_hstack(id))) { if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("O"), 0, 0, 0); if (p1) gui_label(kd, hole_out(0), 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_out(1), 0, gui_red, gui_wht); if (p2) gui_label(kd, hole_out(2), 0, gui_grn, gui_wht); if (p3) gui_label(kd, hole_out(3), 0, gui_blu, gui_wht); if (p4) gui_label(kd, hole_out(4), 0, gui_yel, gui_wht); gui_set_rect(kd, GUI_RGT); } if ((kd = gui_harray(jd))) { for (i = m; i > 0; i--) if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, number(i), 0, 0, 0); if (p1) gui_label(ld, hole_score(i, 0), 0, gui_wht, gui_wht); if (p1) gui_label(ld, hole_score(i, 1), 0, gui_red, gui_wht); if (p2) gui_label(ld, hole_score(i, 2), 0, gui_grn, gui_wht); if (p3) gui_label(ld, hole_score(i, 3), 0, gui_blu, gui_wht); if (p4) gui_label(ld, hole_score(i, 4), 0, gui_yel, gui_wht); } gui_set_rect(kd, GUI_LFT); } if ((kd = gui_vstack(jd))) { gui_space(kd); if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, _("Par"), 0, gui_wht, gui_wht); if (p1) gui_label(ld, _("P1"), 0, gui_red, gui_wht); if (p2) gui_label(ld, _("P2"), 0, gui_grn, gui_wht); if (p3) gui_label(ld, _("P3"), 0, gui_blu, gui_wht); if (p4) gui_label(ld, _("P4"), 0, gui_yel, gui_wht); gui_set_rect(ld, GUI_ALL); } } } gui_space(id); if ((jd = gui_hstack(id))) { if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("Tot"), 0, 0, 0); if (p1) gui_label(kd, hole_tot(0), 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_tot(1), 0, gui_red, gui_wht); if (p2) gui_label(kd, hole_tot(2), 0, gui_grn, gui_wht); if (p3) gui_label(kd, hole_tot(3), 0, gui_blu, gui_wht); if (p4) gui_label(kd, hole_tot(4), 0, gui_yel, gui_wht); gui_set_rect(kd, GUI_ALL); } if ((kd = gui_varray(jd))) { if (p1) gui_label(kd, _("I"), 0, 0, 0); if (p1) gui_label(kd, hole_in(0), 0, gui_wht, gui_wht); if (p1) gui_label(kd, hole_in(1), 0, gui_red, gui_wht); if (p2) gui_label(kd, hole_in(2), 0, gui_grn, gui_wht); if (p3) gui_label(kd, hole_in(3), 0, gui_blu, gui_wht); if (p4) gui_label(kd, hole_in(4), 0, gui_yel, gui_wht); gui_set_rect(kd, GUI_RGT); } if ((kd = gui_harray(jd))) { for (i = n; i > m; i--) if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, number(i), 0, 0, 0); if (p1) gui_label(ld, hole_score(i, 0), 0, gui_wht, gui_wht); if (p1) gui_label(ld, hole_score(i, 1), 0, gui_red, gui_wht); if (p2) gui_label(ld, hole_score(i, 2), 0, gui_grn, gui_wht); if (p3) gui_label(ld, hole_score(i, 3), 0, gui_blu, gui_wht); if (p4) gui_label(ld, hole_score(i, 4), 0, gui_yel, gui_wht); } gui_set_rect(kd, GUI_LFT); } if ((kd = gui_vstack(jd))) { gui_space(kd); if ((ld = gui_varray(kd))) { if (p1) gui_label(ld, _("Par"), 0, gui_wht, gui_wht); if (p1) gui_label(ld, _("P1"), 0, gui_red, gui_wht); if (p2) gui_label(ld, _("P2"), 0, gui_grn, gui_wht); if (p3) gui_label(ld, _("P3"), 0, gui_blu, gui_wht); if (p4) gui_label(ld, _("P4"), 0, gui_yel, gui_wht); gui_set_rect(ld, GUI_ALL); } } } gui_layout(id, 0, 0); } return id; }
static void game_draw_balls(const struct s_file *fp, const float *bill_M, float t) { static const GLfloat color[5][4] = { { 1.0f, 1.0f, 1.0f, 0.7f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f }, { 1.0f, 1.0f, 0.0f, 1.0f }, }; int ui; for (ui = curr_party(); ui > 0; ui--) { if (ui == ball) { float ball_M[16]; float pend_M[16]; m_basis(ball_M, fp->uv[ui].e[0], fp->uv[ui].e[1], fp->uv[ui].e[2]); m_basis(pend_M, fp->uv[ui].E[0], fp->uv[ui].E[1], fp->uv[ui].E[2]); glPushMatrix(); { glTranslatef(fp->uv[ui].p[0], fp->uv[ui].p[1] + BALL_FUDGE, fp->uv[ui].p[2]); glScalef(fp->uv[ui].r, fp->uv[ui].r, fp->uv[ui].r); glEnable(GL_COLOR_MATERIAL); glColor4fv(color[ui]); ball_draw(ball_M, pend_M, bill_M, t); glDisable(GL_COLOR_MATERIAL); } glPopMatrix(); } else { glPushMatrix(); { glTranslatef(fp->uv[ui].p[0], fp->uv[ui].p[1] - fp->uv[ui].r + BALL_FUDGE, fp->uv[ui].p[2]); glScalef(fp->uv[ui].r, fp->uv[ui].r, fp->uv[ui].r); glColor4f(color[ui][0], color[ui][1], color[ui][2], 0.5f); mark_draw(); } glPopMatrix(); } } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }