/*! \brief Draws the main menu * * Draw the menu when the player hits ENTER * 20040911 PH Added an extra line in the menu for "Quest Info" */ void draw_mainmenu(int swho) { size_t fighter_index; timer_count = 0; for (fighter_index = 0; fighter_index < PSIZE; fighter_index++) { menubox(double_buffer, 44 + xofs, fighter_index * 64 + 64 + yofs, 18, 6, (size_t)swho == fighter_index ? DARKBLUE : BLUE); } menubox(double_buffer, 204 + xofs, 64 + yofs, 7, 6, BLUE); menubox(double_buffer, 204 + xofs, 128 + yofs, 7, 6, BLUE); print_font(double_buffer, 220 + xofs, 72 + yofs, _("Items"), FGOLD); print_font(double_buffer, 220 + xofs, 80 + yofs, _("Magic"), FGOLD); print_font(double_buffer, 220 + xofs, 88 + yofs, _("Equip"), FGOLD); print_font(double_buffer, 220 + xofs, 96 + yofs, _("Spec."), FGOLD); print_font(double_buffer, 220 + xofs, 104 + yofs, _("Stats"), FGOLD); print_font(double_buffer, 220 + xofs, 112 + yofs, _("Quest"), FGOLD); print_font(double_buffer, 212 + xofs, 136 + yofs, _("Time:"), FGOLD); print_font(double_buffer, 212 + xofs, 164 + yofs, _("Gold:"), FGOLD); /* PH: print time as h:mm */ sprintf(strbuf, "%d:%02d", khr, kmin); print_font(double_buffer, 268 - (strlen(strbuf) * 8) + xofs, 144 + yofs, strbuf, FNORMAL); sprintf(strbuf, "%d", gp); print_font(double_buffer, 268 - (strlen(strbuf) * 8) + xofs, 172 + yofs, strbuf, FNORMAL); if (swho != -1) { menubox(double_buffer, 44 + xofs, swho * 64 + 64 + yofs, 18, 6, DARKBLUE); } for (fighter_index = 0; fighter_index < numchrs; fighter_index++) { draw_playerstat(double_buffer, pidx[fighter_index], 52 + xofs, fighter_index * 64 + 76 + yofs); } }
/*! \brief Confirm save * * If the save slot selected already has a saved game in it, confirm that we * want to overwrite it. * * \returns 0 if cancelled, 1 if confirmed */ static int confirm_action (void) { int stop = 0; int pointer_offset = (save_ptr - top_pointer) * 48; if (snc[save_ptr] == 0) return 1; fullblit(double_buffer, back); menubox (double_buffer, 128, pointer_offset + 12, 14, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("Confirm/Cancel"), FNORMAL); blit2screen (0, 0); fullblit(back, double_buffer); while (!stop) { readcontrols (); if (balt) { unpress (); return 1; } if (bctrl) { unpress (); return 0; } kq_yield (); } return 0; }
/*! \brief Get value for option * * Display a bar and allow the user to adjust between fixed limits * * \param capt Caption * \param minu Minimum value of option * \param maxu Maximum vlaue of option * \param cv Current value (initial value) * \param sp Show percent. If sp==1, show as a percentage of maxu * \returns the new value for option, or -1 if cancelled. */ static int getavalue (const char *capt, int minu, int maxu, int cv, int sp) { int stop = 0, a, b; if (maxu == 0) return -1; while (!stop) { check_animation (); menubox (double_buffer, 148 - (maxu * 4) + xofs, 100 + yofs, maxu + 1, 3, DARKBLUE); print_font (double_buffer, 160 - (strlen (capt) * 4) + xofs, 108 + yofs, capt, FGOLD); print_font (double_buffer, 152 - (maxu * 4) + xofs, 116 + yofs, "<", FNORMAL); print_font (double_buffer, 160 + (maxu * 4) + xofs, 116 + yofs, ">", FNORMAL); b = 160 - (maxu * 4) + xofs; for (a = 0; a < cv; a++) { rectfill (double_buffer, a * 8 + b + 1, 117 + yofs, a * 8 + b + 7, 123 + yofs, 50); rectfill (double_buffer, a * 8 + b, 116 + yofs, a * 8 + b + 6, 122 + yofs, 21); } if (sp == 1) sprintf (strbuf, "%d%%", cv * 100 / maxu); else sprintf (strbuf, "%d", cv); print_font (double_buffer, 160 - (strlen (strbuf) * 4) + xofs, 124 + yofs, strbuf, FGOLD); blit2screen (xofs, yofs); readcontrols (); if (left) { unpress (); cv--; if (cv < minu) cv = minu; IF_VOLUME_ALERT (); } if (right) { unpress (); cv++; if (cv > maxu) cv = maxu; IF_VOLUME_ALERT (); } if (balt) { unpress (); stop = 1; } if (bctrl) { unpress (); return -1; } } return cv; }
/*! \brief Delete game * * You guessed it... delete the game. */ static void delete_game (void) { int a, stop = 0; int pointer_offset = (save_ptr - top_pointer) * 48; sprintf (strbuf, "sg%d.sav", save_ptr); a = remove (kqres (SAVE_DIR, strbuf)); if (a == 0) { menubox (double_buffer, 128, pointer_offset + 12, 12, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("File Deleted"), FNORMAL); snc[save_ptr] = 0; sgp[save_ptr] = 0; shr[save_ptr] = 0; smin[save_ptr] = 0; for (a = 0; a < PSIZE; a++) { sid[save_ptr][a] = 0; shp[save_ptr][a] = 0; smp[save_ptr][a] = 0; slv[save_ptr][a] = 0; } } else { menubox (double_buffer, 128, pointer_offset + 12, 16, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("File Not Deleted"), FNORMAL); } blit2screen (0, 0); blit (back, double_buffer, 0, 0, 0, 0, 352, 280); while (!stop) { readcontrols (); if (balt || bctrl) { unpress (); stop = 1; } kq_yield (); } }
/*! \brief Show keys help * Show a screen with the keys listed, and other helpful info * \author PH * \date 20030527 */ void show_help (void) { menubox (double_buffer, 116 + xofs, yofs, 9, 1, BLUE); print_font (double_buffer, 132 + xofs, 8 + yofs, _("KQ Help"), FGOLD); menubox (double_buffer, 32 + xofs, 32 + yofs, 30, 20, BLUE); menubox (double_buffer, xofs, 216 + yofs, 38, 1, BLUE); print_font (double_buffer, 16 + xofs, 224 + yofs, _("Press CONFIRM to exit this screen"), FNORMAL); citem (72, _("Up Key:"), kq_keyname (kup), FNORMAL); citem (80, _("Down Key:"), kq_keyname (kdown), FNORMAL); citem (88, _("Left Key:"), kq_keyname (kleft), FNORMAL); citem (96, _("Right Key:"), kq_keyname (kright), FNORMAL); citem (104, _("Confirm Key:"), kq_keyname (kalt), FNORMAL); citem (112, _("Cancel Key:"), kq_keyname (kctrl), FNORMAL); citem (120, _("Menu Key:"), kq_keyname (kenter), FNORMAL); citem (128, _("System Menu Key:"), kq_keyname (kesc), FNORMAL); do { blit2screen (xofs, yofs); readcontrols (); } while (!balt && !bctrl); unpress (); }
/*! \brief Enemies defeated the player * \author Josh Bolduc * \date created ???????? * \date updated * * Play some sad music and set the dead flag so that the game * will return to the main menu. */ static void enemies_win (void) { play_music ("rain.s3m", 0); battle_render (0, 0, 0); /* RB FIXME: rest()? */ blit2screen (0, 0); kq_wait (1000); sprintf (strbuf, _("%s was defeated!"), party[pidx[0]].name); menubox (double_buffer, 152 - (strlen (strbuf) * 4), 48, strlen (strbuf), 1, BLUE); print_font (double_buffer, 160 - (strlen (strbuf) * 4), 56, strbuf, FNORMAL); blit2screen (0, 0); wait_enter (); do_transition (TRANS_FADE_OUT, 4); alldead = 1; }
/*! \brief Process keypresses when mapping new keys * * This grabs whatever key is being pressed and returns it to the caller. * PH 20030527 Removed call to keypressed() and added poll_music() * * \returns the key being pressed, 0 if error (or cancel?) */ static int getakey (void) { int a; clear_keybuf (); menubox (double_buffer, 108 + xofs, 108 + yofs, 11, 1, DARKBLUE); print_font (double_buffer, 116 + xofs, 116 + yofs, _("Press a key"), FNORMAL); blit2screen (xofs, yofs); while (1) { poll_music (); for (a = 0; a < KEY_MAX; a++) if (key[a] != 0) return a; } return 0; }
/*! \brief Draw the battle screen * \author Josh Bolduc * \date Created ???????? * \date Updated 20020914 - 16:16 (RB) * * Draw the battle screen. * * \param plyr Player * \param hl Highlighted * \param sall Select all */ void battle_render (int plyr, int hl, int sall) { int a = 0; int b = 0; int sz; int t; int z; if (plyr > 0) { curw = fighter[plyr - 1].cw; curx = fighter[plyr - 1].cx; cury = fighter[plyr - 1].cy; } else { curx = -1; cury = -1; } clear_bitmap (double_buffer); blit ((BITMAP *) backart->dat, double_buffer, 0, 0, 0, 0, 320, 240); #ifdef DEBUGMODE if (debugging > 1) { rectfill (double_buffer, 0, 0, rcount / 2, 9, 15); sprintf (strbuf, "%d", rcount); print_font (double_buffer, 0, 20, strbuf, FNORMAL); sprintf (strbuf, "0: %d - %d", fighter[0].sts[S_POISON], fighter[0].sts[S_REGEN]); print_font (double_buffer, 0, 28, strbuf, FNORMAL); sprintf (strbuf, "1: %d - %d", fighter[1].sts[S_POISON], fighter[1].sts[S_REGEN]); print_font (double_buffer, 0, 36, strbuf, FNORMAL); } #endif if ((sall == 0) && (curx > -1) && (cury > -1)) { draw_sprite (double_buffer, bptr, curx + (curw / 2) - 8, cury - 8); if (plyr - 1 >= PSIZE) { t = curx + (curw / 2); t -= (strlen (fighter[plyr - 1].name) * 4); z = fighter[plyr - 1].cy - 32; if (z < 0) z = fighter[plyr - 1].cy + fighter[plyr - 1].cl; menubox (double_buffer, t - 8, z, strlen (fighter[plyr - 1].name), 1, BLUE); print_font (double_buffer, t, z + 8, fighter[plyr - 1].name, FNORMAL); } #ifdef DEBUGMODE if (debugging > 1) { /* RB TODO: Check this out. */ sprintf (strbuf, _("HP:%d (%d)"), fighter[plyr - 1].hp, fighter[plyr - 1].mhp); print_font (double_buffer, 0, 8, strbuf, FNORMAL); sprintf (strbuf, _("MP:%d (%d)"), fighter[plyr - 1].mp, fighter[plyr - 1].mmp); print_font (double_buffer, 0, 16, strbuf, FNORMAL); print_font (double_buffer, 0, 24, _("Str"), FNORMAL); print_font (double_buffer, 0, 32, _("Agi"), FNORMAL); print_font (double_buffer, 0, 40, _("Vit"), FNORMAL); print_font (double_buffer, 0, 48, _("Int"), FNORMAL); print_font (double_buffer, 0, 56, _("Sag"), FNORMAL); print_font (double_buffer, 0, 64, _("Spd"), FNORMAL); print_font (double_buffer, 0, 72, _("Aura"), FNORMAL); print_font (double_buffer, 0, 80, _("Spir"), FNORMAL); print_font (double_buffer, 0, 88, _("Att"), FNORMAL); print_font (double_buffer, 0, 96, _("Hit%"), FNORMAL); print_font (double_buffer, 0, 104, _("Def"), FNORMAL); print_font (double_buffer, 0, 112, _("Evd%"), FNORMAL); print_font (double_buffer, 0, 120, _("Mdef"), FNORMAL); sprintf (strbuf, "%d, %d, %d, %d", fighter[plyr - 1].cwt, fighter[plyr - 1].welem, fighter[plyr - 1].unl, fighter[plyr - 1].crit); print_font (double_buffer, 0, 128, strbuf, FNORMAL); sprintf (strbuf, "i -> %d,%d,%d,%d", fighter[plyr - 1].imb_s, fighter[plyr - 1].imb_a, fighter[plyr - 1].imb[0], fighter[plyr - 1].imb[1]); print_font (double_buffer, 0, 136, strbuf, FNORMAL); for (t = 0; t < 13; t++) { sprintf (strbuf, "%d", fighter[plyr - 1].stats[t]); print_font (double_buffer, 40, t * 8 + 24, strbuf, FNORMAL); } } #endif } for (z = 0; z < numchrs; z++) { b = z * 216; if (fighter[z].sts[S_DEAD] == 0) { draw_fighter (z, (sall == 1)); } else { fighter[z].aframe = 3; draw_fighter (z, 0); } menubox (double_buffer, b, 184, 11, 5, BLUE); if (fighter[z].sts[S_DEAD] == 0) { sz = bspeed[z] * 88 / ROUND_MAX; if (sz > 88) sz = 88; a = 116; if (fighter[z].sts[S_TIME] == 1) a = 83; if (fighter[z].sts[S_TIME] == 2) a = 36; a += (sz / 11); hline (double_buffer, b + 8, 229, b + sz + 8, a + 1); hline (double_buffer, b + 8, 230, b + sz + 8, a); hline (double_buffer, b + 8, 231, b + sz + 8, a - 1); } print_font (double_buffer, b + 8, 192, fighter[z].name, (hl == z + 1) ? FGOLD : FNORMAL); sprintf (strbuf, _("HP: %3d/%3d"), fighter[z].hp, fighter[z].mhp); /* RB IDEA: If the character has less than 1/5 of his/her max */ /* health points, it shows the amount with red (the */ /* character is in danger). I suggest setting that '5' */ /* as a '#define WARNING_LEVEL 5' or something like */ /* that, so we can change it easily (maybe we can let */ /* the player choose when it should be turned red). */ /* TT TODO: I like this idea; maybe somewhere in the Options */ /* menu? I find that when the bar flashes red/yellow */ /* to warn the player, it's much more eye-pleasing than */ /* just a solid color (and not too hard to implement). */ print_font (double_buffer, b + 8, 208, strbuf, (fighter[z].hp < (fighter[z].mhp / 5)) ? FRED : FNORMAL); hline (double_buffer, b + 8, 216, b + 95, 21); sz = (fighter[z].hp > 0) ? fighter[z].hp * 88 / fighter[z].mhp : 88; hline (double_buffer, b + 8, 216, b + 8 + sz, 12); sprintf (strbuf, _("MP: %3d/%3d"), fighter[z].mp, fighter[z].mmp); /* RB IDEA: Same suggestion as with health, just above. */ print_font (double_buffer, b + 8, 218, strbuf, (fighter[z].mp < (fighter[z].mmp / 5)) ? FRED : FNORMAL); hline (double_buffer, b + 8, 226, b + 95, 21); sz = (fighter[z].mp > 0) ? fighter[z].mp * 88 / fighter[z].mmp : 88; hline (double_buffer, b + 8, 226, b + 8 + sz, 12); draw_stsicon (double_buffer, 1, z, 17, b + 8, 200); } for (t = PSIZE; t < PSIZE + numens; t++) { if (fighter[t].sts[S_DEAD] == 0) { draw_fighter (t, (sall == 2)); } } if (dct == 1) { menubox (double_buffer, 152 - (strlen (ctext) * 4), 8, strlen (ctext), 1, BLUE); print_font (double_buffer, 160 - (strlen (ctext) * 4), 16, ctext, FNORMAL); } }
/*! \brief Player defeated the enemies * \author Josh Bolduc * \date Created ???????? * \date Updated * * Distribute the booty! */ static void heroes_win (void) { int tgp = 0; int index; int b; int c; int z; int nc = 0; int txp = 0; int found_item = 0; int nr = 0; int ent = 0; s_fighter t1; s_fighter t2; play_music ("rend5.s3m", 0); kq_wait (500); revert_equipstats (); for (index = 0; index < numchrs; index++) fighter[index].aframe = 4; battle_render (0, 0, 0); blit2screen (0, 0); kq_wait (250); for (index = 0; index < numchrs; index++) { if ((fighter[index].sts[S_STONE] == 0) && (fighter[index].sts[S_DEAD] == 0)) nc++; ta[index] = 0; } for (index = PSIZE; index < PSIZE + numens; index++) { txp += fighter[index].xp; tgp += fighter[index].gp; } /* JB: nc should never be zero if we won, but whatever */ if (nc > 0) txp /= nc; gp += tgp; if (tgp > 0) sprintf (strbuf, _("Gained %d xp and found %d gp."), txp, tgp); else sprintf (strbuf, _("Gained %d xp."), txp); menubox (double_buffer, 152 - (strlen (strbuf) * 4), 8, strlen (strbuf), 1, BLUE); print_font (double_buffer, 160 - (strlen (strbuf) * 4), 16, strbuf, FNORMAL); blit2screen (0, 0); blit (double_buffer, back, 0, 0, 0, 0, 352, 280); for (index = 0; index < numens; index++) { /* PH bug: (?) should found_item be reset to zero at the start of this loop? * If you defeat 2 enemies, you should (possibly) get 2 items, right? */ if ((rand () % 100) < fighter[index + PSIZE].dip) { if (fighter[index + PSIZE].defeat_item_common > 0) found_item = fighter[index + PSIZE].defeat_item_common; if (fighter[index + PSIZE].defeat_item_rare > 0) { if ((rand () % 100) < 5) found_item = fighter[index + PSIZE].defeat_item_rare; } if (found_item > 0) { if (check_inventory (found_item, 1) != 0) { sprintf (strbuf, _("%s found!"), items[found_item].name); menubox (double_buffer, 148 - (strlen (strbuf) * 4), nr * 24 + 48, strlen (strbuf) + 1, 1, BLUE); draw_icon (double_buffer, items[found_item].icon, 156 - (strlen (strbuf) * 4), nr * 24 + 56); print_font (double_buffer, 164 - (strlen (strbuf) * 4), nr * 24 + 56, strbuf, FNORMAL); nr++; } } } } if (nr > 0) { blit2screen (0, 0); wait_enter (); blit (back, double_buffer, 0, 0, 0, 0, 352, 280); } nr = 0; for (c = 0; c < numchrs; c++) { if ((party[pidx[c]].sts[S_STONE] == 0) && (party[pidx[c]].sts[S_DEAD] == 0)) { b = c * 160; player2fighter (pidx[c], &t1); if (give_xp (pidx[c], txp, 0) == 1) { menubox (double_buffer, b, 40, 18, 9, BLUE); player2fighter (pidx[c], &t2); print_font (double_buffer, b + 8, 48, _("Level up!"), FGOLD); print_font (double_buffer, b + 8, 56, _("Max HP"), FNORMAL); print_font (double_buffer, b + 8, 64, _("Max MP"), FNORMAL); print_font (double_buffer, b + 8, 72, _("Strength"), FNORMAL); print_font (double_buffer, b + 8, 80, _("Agility"), FNORMAL); print_font (double_buffer, b + 8, 88, _("Vitality"), FNORMAL); print_font (double_buffer, b + 8, 96, _("Intellect"), FNORMAL); print_font (double_buffer, b + 8, 104, _("Sagacity"), FNORMAL); sprintf (strbuf, "%3d>", t1.mhp); print_font (double_buffer, b + 96, 56, strbuf, FNORMAL); sprintf (strbuf, "%3d", t2.mhp); print_font (double_buffer, b + 128, 56, strbuf, FGREEN); sprintf (strbuf, "%3d>", t1.mmp); print_font (double_buffer, b + 96, 64, strbuf, FNORMAL); sprintf (strbuf, "%3d", t2.mmp); print_font (double_buffer, b + 128, 64, strbuf, FGREEN); for (z = 0; z < 5; z++) { sprintf (strbuf, "%3d>", t1.stats[z]); print_font (double_buffer, b + 96, z * 8 + 72, strbuf, FNORMAL); sprintf (strbuf, "%3d", t2.stats[z]); if (t2.stats[z] > t1.stats[z]) print_font (double_buffer, b + 128, z * 8 + 72, strbuf, FGREEN); else print_font (double_buffer, b + 128, z * 8 + 72, strbuf, FNORMAL); } nr++; } else menubox (double_buffer, b, 104, 18, 1, BLUE); sprintf (strbuf, _("Next level %7d"), party[pidx[c]].next - party[pidx[c]].xp); print_font (double_buffer, b + 8, 112, strbuf, FGOLD); } } blit2screen (0, 0); for (c = 0; c < numchrs; c++) if ((party[pidx[c]].sts[S_STONE] == 0) && (party[pidx[c]].sts[S_DEAD] == 0)) ent += learn_new_spells (pidx[c]); if (ent == 0) wait_enter (); }
/*! \brief Do the Quest Info menu * * Show the current list of quest information items * \sa ILIST * \author PH * \date 20050429 */ static void quest_info(void) { int ii = 0; int i, base; /* Call into the script */ ilist_clear(&quest_list); do_questinfo(); if (quest_list.count == 0) { /* There was nothing.. */ play_effect(SND_BAD, 128); return; } while (1) { timer_count = 0; drawmap(); base = ii - ii % 10; menubox(double_buffer, 88 + xofs, 92 + yofs, 18, 10, BLUE); menubox(double_buffer, 88 + xofs, 188 + yofs, 18, 3, BLUE); for (i = 0; i < 10; ++i) { if (i + base < quest_list.count) { print_font(double_buffer, 104 + xofs, 100 + 8 * i + yofs, quest_list.root[i + base].key, FNORMAL); } } draw_sprite(double_buffer, menuptr, 88 + xofs, 100 + 8 * (ii - base) + yofs); if (ii < quest_list.count) { print_font(double_buffer, 96 + xofs, 196 + yofs, quest_list.root[ii].text, FNORMAL); } blit2screen(xofs, yofs); readcontrols(); if (PlayerInput.up) { --ii; play_effect(SND_CLICK, 128); unpress(); } if (PlayerInput.down) { ++ii; play_effect(SND_CLICK, 128); unpress(); } if (PlayerInput.left) { ii -= 10; play_effect(SND_CLICK, 128); unpress(); } if (PlayerInput.right) { ii += 10; play_effect(SND_CLICK, 128); unpress(); } if (ii < 0) { ii = quest_list.count - 1; } if (ii >= quest_list.count) { ii = 0; } if (PlayerInput.balt || PlayerInput.bctrl) { unpress(); return; } } }
/*! \brief Display system menu * * This is the system menu that is invoked from within the game. * From here you can save, load, configure a couple of options or * exit the game altogether. * \date 20040229 PH added 'Save anytime' facility when cheat mode is ON * * \returns 0 if cancelled or nothing happened, 1 otherwise */ int system_menu (void) { int stop = 0, ptr = 0; char save_str[10]; int text_color = FNORMAL; strcpy (save_str, _("Save ")); if (cansave == 0) { text_color = FDARK; #ifdef KQ_CHEATS if (cheat) { strcpy (save_str, _("[Save]")); text_color = FNORMAL; } #endif /* KQ_CHEATS */ } while (!stop) { check_animation (); drawmap (); menubox (double_buffer, xofs, yofs, 8, 4, BLUE); print_font (double_buffer, 16 + xofs, 8 + yofs, save_str, text_color); print_font (double_buffer, 16 + xofs, 16 + yofs, _("Load"), FNORMAL); print_font (double_buffer, 16 + xofs, 24 + yofs, _("Config"), FNORMAL); print_font (double_buffer, 16 + xofs, 32 + yofs, _("Exit"), FNORMAL); draw_sprite (double_buffer, menuptr, 0 + xofs, ptr * 8 + 8 + yofs); blit2screen (xofs, yofs); readcontrols (); // TT: // When pressed, 'up' or 'down' == 1. Otherwise, they equal 0. So: // ptr = ptr - up + down; // will correctly modify the pointer, but with less code. if (up || down) { ptr = ptr + up - down; if (ptr < 0) ptr = 3; else if (ptr > 3) ptr = 0; play_effect (SND_CLICK, 128); unpress (); } if (balt) { unpress (); if (ptr == 0) { // Pointer is over the SAVE option #ifdef KQ_CHEATS if (cansave == 1 || cheat) #else if (cansave == 1) #endif /* KQ_CHEATS */ { saveload (1); stop = 1; } else play_effect (SND_BAD, 128); } if (ptr == 1) { if (saveload (0) != 0) stop = 1; } if (ptr == 2) config_menu (); if (ptr == 3) return confirm_quit (); } if (bctrl) { stop = 1; unpress (); } } return 0; }
/*! \brief Main menu screen * * This is the main menu... just display the opening and then the menu and * then wait for input. Also handles loading a saved game, and the config menu. * * \param c zero if the splash (the bit with the staff and the eight heroes) * should be displayed. * \returns 1 if new game, 0 if continuing, 2 if exit */ int start_menu (int skip_splash) { int stop = 0, ptr = 0, redraw = 1, a, b; DATAFILE *bg; BITMAP *staff, *dudes, *tdudes; #ifdef DEBUGMODE if (debugging == 0) { #endif play_music ("oxford.s3m", 0); /* Play splash (with the staff and the heroes in circle */ if (skip_splash == 0) { bg = load_datafile_object (PCX_DATAFILE, "KQT_PCX"); staff = create_bitmap_ex (8, 72, 226); dudes = create_bitmap_ex (8, 112, 112); tdudes = create_bitmap_ex (8, 112, 112); blit ((BITMAP *) bg->dat, staff, 0, 7, 0, 0, 72, 226); blit ((BITMAP *) bg->dat, dudes, 80, 0, 0, 0, 112, 112); clear_bitmap (double_buffer); blit (staff, double_buffer, 0, 0, 124, 22, 72, 226); blit2screen (0, 0); kq_wait (1000); for (a = 0; a < 42; a++) { stretch_blit (staff, double_buffer, 0, 0, 72, 226, 124 - (a * 32), 22 - (a * 96), 72 + (a * 64), 226 + (a * 192)); blit2screen (0, 0); kq_wait (100); } for (a = 0; a < 5; a++) { color_scale (dudes, tdudes, 53 - a, 53 + a); draw_sprite (double_buffer, tdudes, 106, 64); blit2screen (0, 0); kq_wait (100); } draw_sprite (double_buffer, dudes, 106, 64); blit2screen (0, 0); kq_wait (1000); destroy_bitmap (staff); destroy_bitmap (dudes); destroy_bitmap (tdudes); unload_datafile_object(bg); /* TODO: this fade should actually be to white if (_color_depth == 8) fade_from (pal, whp, 1); else */ do_transition (TRANS_FADE_WHITE, 1); } clear_to_color (double_buffer, 15); blit2screen (0, 0); set_palette (pal); bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX"); for (a = 0; a < 16; a++) { clear_to_color (double_buffer, 15 - a); masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 60 - (a * 4), 320, 124); blit2screen (0, 0); kq_wait (a == 0 ? 500 : 100); } if (skip_splash == 0) kq_wait (500); #ifdef DEBUGMODE } else { set_palette (pal); bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX"); } #endif reset_world (); /* Draw menu and handle menu selection */ while (!stop) { if (redraw) { clear_bitmap (double_buffer); masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 0, 320, 124); menubox (double_buffer, 112, 116, 10, 4, BLUE); print_font (double_buffer, 128, 124, _("Continue"), FNORMAL); print_font (double_buffer, 128, 132, _("New Game"), FNORMAL); print_font (double_buffer, 136, 140, _("Config"), FNORMAL); print_font (double_buffer, 144, 148, _("Exit"), FNORMAL); draw_sprite (double_buffer, menuptr, 112, ptr * 8 + 124); redraw = 0; } display_credits (); blit2screen (0, 0); readcontrols (); if (bhelp) { unpress (); show_help (); redraw = 1; } if (up) { unpress (); if (ptr > 0) ptr--; else ptr = 3; play_effect (SND_CLICK, 128); redraw = 1; } if (down) { unpress (); if (ptr < 3) ptr++; else ptr = 0; play_effect (SND_CLICK, 128); redraw = 1; } if (balt) { unpress (); if (ptr == 0) { /* User selected "Continue" */ if (snc[0] == 0 && snc[1] == 0 && snc[2] == 0 && snc[3] == 0 && snc[4] == 0) stop = 2; else if (saveload (0) == 1) stop = 1; redraw = 1; } else if (ptr == 1) { /* User selected "New Game" */ stop = 2; } else if (ptr == 2) { /* Config */ clear (double_buffer); config_menu (); redraw = 1; /* TODO: Save Global Settings Here */ } else if (ptr == 3) { /* Exit */ unload_datafile_object (bg); klog (_("Then exit you shall!")); return 2; } } } unload_datafile_object (bg); if (stop == 2) { /* New game init */ for (a = 0; a < MAXCHRS; a++) memcpy (&party[a], &players[a].plr, sizeof (s_player)); init_players (); memset (progress, 0, SIZE_PROGRESS); memset (treasure, 0, SIZE_TREASURE); numchrs = 0; for (a = 0; a < NUMSHOPS; a++) { for (b = 0; b < SHOPITEMS; b++) shops[a].items_current[b] = shops[a].items_max[b]; } for (b = 0; b < 2; b++) { for (a = 0; a < MAX_INV; a++) g_inv[a][b] = 0; } } return stop - 1; }
/*! \brief Display saved game statistics * * This is the routine that displays the information about * each saved game for the save/load screen. * * \param saving 0 if loading, 1 if saving. */ static void show_sgstats (int saving) { int a, sg, hx, hy, b; int pointer_offset; /* TT UPDATE: * More than 5 save states! Hooray! * * Details of changes: * * If we want to have, say, 10 save games instead of 5, we can only show * 5 on the screen at any given time. Therefore, we will need to print the * menuboxes 0..4 and have an up/down arrow indicator to show there are * more selections to choose from. * * To draw the menuboxes, we need to keep track of the TOP visible savegame * (0..5), and alter the rest accordingly. * * When the 5th on-screen box is selected and DOWN is pressed, move down by * one menubox (shift all savegames up one) so 1..5 are showing (vs 0..4). * When the 5th on-screen box is SG9 (10th savegame), loop up to the top of * the savegames (save_ptr=0, top_pointer=0). */ pointer_offset = (save_ptr - top_pointer) * 48; if (saving == 0) { menubox (double_buffer, 0, pointer_offset + 12, 7, 1, BLUE); print_font (double_buffer, 8, pointer_offset + 20, _("Loading"), FGOLD); } else if (saving == 1) { menubox (double_buffer, 8, pointer_offset + 12, 6, 1, BLUE); print_font (double_buffer, 16, pointer_offset + 20, _("Saving"), FGOLD); } else if (saving == 2 || saving == 3) { menubox (double_buffer, 8, pointer_offset + 12, 6, 1, BLUE); print_font (double_buffer, 16, pointer_offset + 20, _("Delete"), FRED); } if (top_pointer > 0) draw_sprite (double_buffer, upptr, 32, 0); if (top_pointer < NUMSG - max_onscreen) draw_sprite (double_buffer, dnptr, 32, 240 - 8); for (sg = top_pointer; sg < top_pointer + max_onscreen; sg++) { pointer_offset = (sg - top_pointer) * 48; if (sg == save_ptr) menubox (double_buffer, 72, pointer_offset, 29, 4, DARKBLUE); else menubox (double_buffer, 72, pointer_offset, 29, 4, BLUE); if (snc[sg] == -1) print_font (double_buffer, 136, pointer_offset + 20, _("Wrong version"), FNORMAL); else { if (snc[sg] == 0) print_font (double_buffer, 168, pointer_offset + 20, _("Empty"), FNORMAL); else { for (a = 0; a < snc[sg]; a++) { hx = a * 72 + 84; hy = pointer_offset + 12; draw_sprite (double_buffer, frames[sid[sg][a]][1], hx, hy + 4); sprintf (strbuf, _("L: %02d"), slv[sg][a]); print_font (double_buffer, hx + 16, hy, strbuf, FNORMAL); print_font (double_buffer, hx + 16, hy + 8, _("H:"), FNORMAL); print_font (double_buffer, hx + 16, hy + 16, _("M:"), FNORMAL); rectfill (double_buffer, hx + 33, hy + 9, hx + 65, hy + 15, 2); rectfill (double_buffer, hx + 32, hy + 8, hx + 64, hy + 14, 35); rectfill (double_buffer, hx + 33, hy + 17, hx + 65, hy + 23, 2); rectfill (double_buffer, hx + 32, hy + 16, hx + 64, hy + 22, 19); b = shp[sg][a] * 32 / 100; rectfill (double_buffer, hx + 32, hy + 9, hx + 32 + b, hy + 13, 41); b = smp[sg][a] * 32 / 100; rectfill (double_buffer, hx + 32, hy + 17, hx + 32 + b, hy + 21, 25); } sprintf (strbuf, _("T %d:%02d"), shr[sg], smin[sg]); print_font (double_buffer, 236, pointer_offset + 12, strbuf, FNORMAL); sprintf (strbuf, _("G %d"), sgp[sg]); print_font (double_buffer, 236, pointer_offset + 28, strbuf, FNORMAL); } } } }
/*! \brief Display configuration menu * * This is the config menu that is called from the system * menu. Here you can adjust the music or sound volume, or * the speed that the battle gauge moves at. */ void config_menu (void) { int stop = 0, ptr = 0, p; int temp_key = 0; #ifdef DEBUGMODE #define MENU_SIZE 18 #else #define MENU_SIZE 17 #endif static const char *dc[MENU_SIZE]; /* Define rows with appropriate spacings for breaks between groups */ int row[MENU_SIZE]; for (p = 0; p < 4; p++) row[p] = (p + 4) * 8; // (p * 8) + 32 for (p = 4; p < 12; p++) row[p] = (p + 5) * 8; // (p * 8) + 40 for (p = 12; p < 15; p++) row[p] = (p + 6) * 8; // (p * 8) + 48 for (p = 15; p < MENU_SIZE; p++) row[p] = (p + 7) * 8; // (p * 8) + 56 /* Helper strings */ dc[0]=_("Display KQ in a window."); dc[1]=_("Stretch to fit 640x480 resolution."); dc[2]=_("Display the frame rate during play."); dc[3]=_("Wait for vertical retrace."); dc[4]=_("Key used to move up."); dc[5]=_("Key used to move down."); dc[6]=_("Key used to move left."); dc[7]=_("Key used to move right."); dc[8]=_("Key used to confirm action."); dc[9]=_("Key used to cancel action."); dc[10]=_("Key used to call character menu."); dc[11]=_("Key used to call system menu."); dc[12]=_("Toggle sound and music on/off."); dc[13]=_("Overall sound volume (affects music)."); dc[14]=_("Music volume."); dc[15]=_("Animation speed-ups for slow machines."); dc[16]=_("Toggle how to allocate CPU usage."); #ifdef DEBUGMODE dc[17]=_("Things you can do only in DebugMode."); #endif unpress (); push_config_state (); set_config_file (kqres (SETTINGS_DIR, "kq.cfg")); while (!stop) { check_animation (); drawmap (); menubox (double_buffer, 88 + xofs, yofs, 16, 1, BLUE); print_font (double_buffer, 96 + xofs, 8 + yofs, _("KQ Configuration"), FGOLD); menubox (double_buffer, 32 + xofs, 24 + yofs, 30, MENU_SIZE + 3, BLUE); citem (row[0], _("Windowed mode:"), windowed == 1 ? _("YES") : _("NO"), FNORMAL); citem (row[1], _("Stretch Display:"), stretch_view == 1 ? _("YES") : _("NO"), FNORMAL); citem (row[2], _("Show Frame Rate:"), show_frate == 1 ? _("YES") : _("NO"), FNORMAL); citem (row[3], _("Wait for Retrace:"), wait_retrace == 1 ? _("YES") : _("NO"), FNORMAL); citem (row[4], _("Up Key:"), kq_keyname (kup), FNORMAL); citem (row[5], _("Down Key:"), kq_keyname (kdown), FNORMAL); citem (row[6], _("Left Key:"), kq_keyname (kleft), FNORMAL); citem (row[7], _("Right Key:"), kq_keyname (kright), FNORMAL); citem (row[8], _("Confirm Key:"), kq_keyname (kalt), FNORMAL); citem (row[9], _("Cancel Key:"), kq_keyname (kctrl), FNORMAL); citem (row[10], _("Menu Key:"), kq_keyname (kenter), FNORMAL); citem (row[11], _("System Menu Key:"), kq_keyname (kesc), FNORMAL); citem (row[12], _("Sound System:"), is_sound ? _("ON") : _("OFF"), FNORMAL); p = FNORMAL; /* TT: This needs to check for ==0 because 1 means sound init */ if (is_sound == 0) p = FDARK; sprintf (strbuf, "%3d%%", gsvol * 100 / 250); citem (row[13], _("Sound Volume:"), strbuf, p); sprintf (strbuf, "%3d%%", gmvol * 100 / 250); citem (row[14], _("Music Volume:"), strbuf, p); citem (row[15], _("Slow Computer:"), slow_computer ? _("YES") : _("NO"), FNORMAL); if (cpu_usage) sprintf (strbuf, _("rest(%d)"), cpu_usage - 1); else sprintf (strbuf, "yield_timeslice()"); citem (row[16], _("CPU Usage:"), strbuf, FNORMAL); #ifdef DEBUGMODE if (debugging) sprintf (strbuf, "%d", debugging); citem (row[17], _("DebugMode Stuff:"), debugging ? strbuf : _("OFF"), FNORMAL); #endif /* This affects the VISUAL placement of the arrow */ p = ptr; if (ptr > 3) p++; if (ptr > 11) p++; if (ptr > 14) p++; draw_sprite (double_buffer, menuptr, 32 + xofs, p * 8 + 32 + yofs); /* This is the bottom window, where the description goes */ menubox (double_buffer, xofs, 216 + yofs, 38, 1, BLUE); print_font (double_buffer, 8 + xofs, 224 + yofs, dc[ptr], FNORMAL); blit2screen (xofs, yofs); readcontrols (); if (up) { unpress (); // "jump" over unusable options if (ptr == 15 && is_sound == 0) ptr -= 2; ptr--; if (ptr < 0) ptr = MENU_SIZE - 1; play_effect (SND_CLICK, 128); } if (down) { unpress (); // "jump" over unusable options if (ptr == 12 && is_sound == 0) ptr += 2; ptr++; if (ptr > MENU_SIZE - 1) ptr = 0; play_effect (SND_CLICK, 128); } if (balt) { unpress (); switch (ptr) { case 0: #ifdef __DJGPP__ text_ex (B_TEXT, 255, _("This version of KQ was compiled for DOS and does not support windowed mode")); #else text_ex (B_TEXT, 255, _("Changing the display mode to or from windowed view could have serious ramifications. It is advised that you save first.")); if (windowed == 0) sprintf (strbuf, _("Switch to windowed mode?")); else sprintf (strbuf, _("Switch to full screen?")); p = prompt (255, 2, B_TEXT, strbuf, _(" no"), _(" yes"), ""); if (p == 1) { if (windowed == 0) windowed = 1; else windowed = 0; set_config_int (NULL, "windowed", windowed); set_graphics_mode (); } #endif break; case 1: #ifdef __DJGPP__ text_ex (B_TEXT, 255, _("This version of KQ was compiled for DOS and does not support stretching")); #else text_ex (B_TEXT, 255, _("Changing the stretched view option could have serious ramifications. It is advised that you save your game before trying this.")); if (stretch_view == 0) sprintf (strbuf, _("Try to stretch the display?")); else sprintf (strbuf, _("Switch to unstretched display?")); p = prompt (255, 2, B_TEXT, strbuf, _(" no"), _(" yes"), ""); if (p == 1) { if (stretch_view == 0) stretch_view = 1; else stretch_view = 0; set_config_int (NULL, "stretch_view", stretch_view); set_graphics_mode (); } #endif break; case 2: if (show_frate == 0) show_frate = 1; else show_frate = 0; set_config_int (NULL, "show_frate", show_frate); break; case 3: if (wait_retrace == 0) wait_retrace = 1; else wait_retrace = 0; set_config_int (NULL, "wait_retrace", wait_retrace); break; case 4: while ((temp_key = getakey ()) == 0); kup = temp_key; unpress (); set_config_int (NULL, "kup", kup); break; case 5: while ((temp_key = getakey ()) == 0); kdown = temp_key; unpress (); set_config_int (NULL, "kdown", kdown); break; case 6: while ((temp_key = getakey ()) == 0); kleft = temp_key; unpress (); set_config_int (NULL, "kleft", kleft); break; case 7: while ((temp_key = getakey ()) == 0); kright = temp_key; unpress (); set_config_int (NULL, "kright", kright); break; case 8: while ((temp_key = getakey ()) == 0); kalt = temp_key; unpress (); set_config_int (NULL, "kalt", kalt); break; case 9: while ((temp_key = getakey ()) == 0); kctrl = temp_key; unpress (); set_config_int (NULL, "kctrl", kctrl); break; case 10: while ((temp_key = getakey ()) == 0); kenter = temp_key; unpress (); set_config_int (NULL, "kenter", kenter); break; case 11: while ((temp_key = getakey ()) == 0); kesc = temp_key; unpress (); set_config_int (NULL, "kesc", kesc); break; case 12: if (is_sound == 2) sound_init (); else { if (is_sound == 0) { is_sound = 1; print_font (double_buffer, 92 + 2 + xofs, 204 + yofs, _("...please wait..."), FNORMAL); blit2screen (xofs, yofs); sound_init (); play_music (g_map.song_file, 0); } } set_config_int (NULL, "is_sound", is_sound != 0); break; case 13: if (is_sound == 2) { p = getavalue (_("Sound Volume"), 0, 25, gsvol / 10, 1); if (p != -1) gsvol = p * 10; /* make sure to set it no matter what */ set_volume (gsvol, 0); set_config_int (NULL, "gsvol", gsvol); } else /* Not as daft as it seems, SND_BAD also wobbles the screen */ play_effect (SND_BAD, 128); break; case 14: if (is_sound == 2) { p = getavalue (_("Music Volume"), 0, 25, gmvol / 10, 1); if (p != -1) gmvol = p * 10; /* make sure to set it no matter what */ set_music_volume (gmvol / 250.0); set_config_int (NULL, "gmvol", gmvol); } else play_effect (SND_BAD, 128); break; case 15: /* TT: toggle slow_computer */ slow_computer = !slow_computer; set_config_int (NULL, "slow_computer", slow_computer); break; case 16: /* TT: Adjust the CPU usage:yield_timeslice() or rest() */ cpu_usage++; if (cpu_usage > 2) cpu_usage = 0; break; #ifdef DEBUGMODE case 17: /* TT: Things we only have access to when we're in debug mode */ if (debugging < 4) debugging++; else debugging = 0; break; #endif } } if (bctrl) { unpress (); stop = 1; } } pop_config_state (); }
/*! \brief Process the item menu * * This screen displays the list of items that the character has, then * waits for the player to select one. */ void camp_item_menu(void) { int stop = 0, ptr = 0, pptr = 0, sel = 0; item_act = 0; play_effect(SND_MENU, 128); while (!stop) { check_animation(); drawmap(); draw_itemmenu(ptr, pptr, sel); blit2screen(xofs, yofs); readcontrols(); if (sel == 0) { if (down) { unpress(); ptr++; if (ptr > 15) { ptr = 0; } play_effect(SND_CLICK, 128); } if (up) { unpress(); ptr--; if (ptr < 0) { ptr = 15; } play_effect(SND_CLICK, 128); } } if (right) { unpress(); if (sel == 0) { /* One of the 16 items in the list */ pptr++; if (pptr > MAX_INV / 16 - 1) { pptr = 0; } } else { /* Use / Sort / Drop */ item_act++; if (item_act > 2) { item_act = 0; } } play_effect(SND_CLICK, 128); } if (left) { unpress(); if (sel == 0) { /* One of the 16 items in the list */ pptr--; if (pptr < 0) { pptr = MAX_INV / 16 - 1; } } else { /* Use / Sort / Drop */ item_act--; if (item_act < 0) { item_act = 2; } } play_effect(SND_CLICK, 128); } if (balt) { unpress(); if (sel == 1) { if (item_act == 1) { sort_items(); } else { sel = 0; } } else { if (g_inv[pptr * 16 + ptr][0] > 0) { // Player's cursor was over the USE menu if (item_act == 0) { camp_item_targetting(pptr * 16 + ptr); } // Player's curor was over the DROP menu else { if (item_act == 2) { int stop2 = 0; /* Make sure the player really wants to drop the item specified. */ while (!stop2) { check_animation(); drawmap(); draw_itemmenu(ptr, pptr, sel); menubox(double_buffer, 72 + xofs, 204 + yofs, 20, 1, DARKBLUE); print_font(double_buffer, 104 + xofs, 212 + yofs, _("Confirm/Cancel"), FNORMAL); blit2screen(xofs, yofs); readcontrols(); if (balt) { unpress(); stop2 = 2; } if (bctrl) { unpress(); stop2 = 1; } } if (stop2 == 2) { // Drop ALL of the selected items remove_item(pptr * 16 + ptr, g_inv[pptr * 16 + ptr][1]); } } } } } } if (bctrl) { unpress(); if (sel == 0) { sel = 1; } else { stop = 1; } } } }
/*! \brief Show special items * * List any special items that the party has. * * WK: This function would be more appropriate in a script, such as global.lua. * This function is preventing me from completely removing progress.h */ void spec_items(void) { int a, num_items = 0, stop = 0, ptr = 0; short list_item_which[MAX_PLAYER_SPECIAL_ITEMS]; short list_item_quantity[MAX_PLAYER_SPECIAL_ITEMS]; /* Set number of items here */ for (a = 0; a < MAX_SPECIAL_ITEMS; a++) { if (player_special_items[a]) { list_item_which[num_items] = a; list_item_quantity[num_items] = player_special_items[a]; num_items++; } } if (num_items == 0) { play_effect(SND_BAD, 128); return; } play_effect(SND_MENU, 128); while (!stop) { check_animation(); drawmap(); menubox(double_buffer, 72 + xofs, 12 + yofs, 20, 1, BLUE); print_font(double_buffer, 108 + xofs, 20 + yofs, _("Special Items"), FGOLD); menubox(double_buffer, 72 + xofs, 36 + yofs, 20, 19, BLUE); for (a = 0; a < num_items; a++) { draw_icon(double_buffer, special_items[list_item_which[a]].icon, 88 + xofs, a * 8 + 44 + yofs); print_font(double_buffer, 96 + xofs, a * 8 + 44 + yofs, special_items[list_item_which[a]].name, FNORMAL); if (list_item_quantity[a] > 1) { sprintf(strbuf, "^%d", list_item_quantity[a]); print_font(double_buffer, 224 + xofs, a * 8 + 44 + yofs, strbuf, FNORMAL); } } menubox(double_buffer, 72 + xofs, 204 + yofs, 20, 1, BLUE); a = strlen(special_items[list_item_which[ptr]].description) * 4; print_font(double_buffer, 160 - a + xofs, 212 + yofs, special_items[list_item_which[ptr]].description, FNORMAL); draw_sprite(double_buffer, menuptr, 72 + xofs, ptr * 8 + 44 + yofs); blit2screen(xofs, yofs); readcontrols(); if (PlayerInput.down) { unpress(); ptr = (ptr + 1) % num_items; play_effect(SND_CLICK, 128); } if (PlayerInput.up) { unpress(); ptr = (ptr - 1 + num_items) % num_items; play_effect(SND_CLICK, 128); } if (PlayerInput.bctrl) { unpress(); stop = 1; } } }
/*! \brief Draw a player's status screen * * Draw the verbose stats of a single player. * \param fighter_index - Character to draw (index in pidx array) */ static void status_screen(size_t fighter_index) { int stop = 0; int bc = 0; unsigned int rect_fill_amount = 0, curr_fill, res_index, stats_y, equipment_index; size_t pidx_index, stats_index; play_effect(SND_MENU, 128); pidx_index = pidx[fighter_index]; update_equipstats(); while (!stop) { check_animation(); // Redraw the map, clearing any menus under this new window drawmap(); // Box around top-left square menubox(double_buffer, xofs, 16 + yofs, 18, 5, BLUE); draw_playerstat(double_buffer, pidx_index, 8 + xofs, 24 + yofs); // Box around bottom-left square menubox(double_buffer, xofs, 72 + yofs, 18, 17, BLUE); print_font(double_buffer, 8 + xofs, 80 + yofs, _("Exp:"), FGOLD); sprintf(strbuf, "%d", party[pidx_index].xp); print_font(double_buffer, 152 - (strlen(strbuf) * 8) + xofs, 80 + yofs, strbuf, FNORMAL); print_font(double_buffer, 8 + xofs, 88 + yofs, _("Next:"), FGOLD); // TT: Does this mean we can only level up to 50? if (party[pidx_index].lvl < 50) { sprintf(strbuf, "%d", party[pidx_index].next - party[pidx_index].xp); } else { sprintf(strbuf, "%d", 0); } print_font(double_buffer, 152 - (strlen(strbuf) * 8) + xofs, 88 + yofs, strbuf, FNORMAL); print_font(double_buffer, 8 + xofs, 104 + yofs, _("Strength"), FGOLD); print_font(double_buffer, 8 + xofs, 112 + yofs, _("Agility"), FGOLD); print_font(double_buffer, 8 + xofs, 120 + yofs, _("Vitality"), FGOLD); print_font(double_buffer, 8 + xofs, 128 + yofs, _("Intellect"), FGOLD); print_font(double_buffer, 8 + xofs, 136 + yofs, _("Sagacity"), FGOLD); print_font(double_buffer, 8 + xofs, 144 + yofs, _("Speed"), FGOLD); print_font(double_buffer, 8 + xofs, 152 + yofs, _("Aura"), FGOLD); print_font(double_buffer, 8 + xofs, 160 + yofs, _("Spirit"), FGOLD); // Blank space on display of 16 pixels print_font(double_buffer, 8 + xofs, 176 + yofs, _("Attack"), FGOLD); print_font(double_buffer, 8 + xofs, 184 + yofs, _("Hit"), FGOLD); print_font(double_buffer, 8 + xofs, 192 + yofs, _("Defense"), FGOLD); print_font(double_buffer, 8 + xofs, 200 + yofs, _("Evade"), FGOLD); print_font(double_buffer, 8 + xofs, 208 + yofs, _("Mag.Def"), FGOLD); for (stats_index = 0; stats_index < NUM_STATS; stats_index++) { // Coordinates of stats on display stats_y = stats_index * 8 + 104; // Add an extra 8-pixel space to separate these from the others if (stats_index > A_SPI) { stats_y += 8; } print_font(double_buffer, 96 + xofs, stats_y + yofs, "$", FGOLD); sprintf(strbuf, "%d", fighter[fighter_index].stats[stats_index]); print_font(double_buffer, 152 - (strlen(strbuf) * 8) + xofs, stats_y + yofs, strbuf, FNORMAL); } menubox(double_buffer, 160 + xofs, 16 + yofs, 18, 16, BLUE); print_font(double_buffer, 168 + xofs, 24 + yofs, _("Earth"), FNORMAL); print_font(double_buffer, 168 + xofs, 32 + yofs, _("Black"), FNORMAL); print_font(double_buffer, 168 + xofs, 40 + yofs, _("Fire"), FNORMAL); print_font(double_buffer, 168 + xofs, 48 + yofs, _("Thunder"), FNORMAL); print_font(double_buffer, 168 + xofs, 56 + yofs, _("Air"), FNORMAL); print_font(double_buffer, 168 + xofs, 64 + yofs, _("White"), FNORMAL); print_font(double_buffer, 168 + xofs, 72 + yofs, _("Water"), FNORMAL); print_font(double_buffer, 168 + xofs, 80 + yofs, _("Ice"), FNORMAL); print_font(double_buffer, 168 + xofs, 88 + yofs, _("Poison"), FNORMAL); print_font(double_buffer, 168 + xofs, 96 + yofs, _("Blind"), FNORMAL); print_font(double_buffer, 168 + xofs, 104 + yofs, _("Charm"), FNORMAL); print_font(double_buffer, 168 + xofs, 112 + yofs, _("Paralyze"), FNORMAL); print_font(double_buffer, 168 + xofs, 120 + yofs, _("Petrify"), FNORMAL); print_font(double_buffer, 168 + xofs, 128 + yofs, _("Silence"), FNORMAL); print_font(double_buffer, 168 + xofs, 136 + yofs, _("Sleep"), FNORMAL); print_font(double_buffer, 168 + xofs, 144 + yofs, _("Time"), FNORMAL); for (res_index = 0; res_index < R_TOTAL_RES; res_index++) { rectfill(double_buffer, 240 + xofs, res_index * 8 + 25 + yofs, 310 + xofs, res_index * 8 + 31 + yofs, 3); if (fighter[fighter_index].res[res_index] < 0) { bc = 18; // bright red, meaning WEAK defense rect_fill_amount = abs(fighter[fighter_index].res[res_index]); } else if (fighter[fighter_index].res[res_index] >= 0 && fighter[fighter_index].res[res_index] <= 10) { bc = 34; // bright green, meaning so-so defense rect_fill_amount = fighter[fighter_index].res[res_index]; } else if (fighter[fighter_index].res[res_index] > 10) { bc = 50; // bright blue, meaning STRONG defense rect_fill_amount = fighter[fighter_index].res[res_index] - 10; } if (rect_fill_amount > 0) { for (curr_fill = 0; curr_fill < rect_fill_amount; curr_fill++) { rectfill(double_buffer, curr_fill * 7 + 241 + xofs, res_index * 8 + 26 + yofs, curr_fill * 7 + 246 + xofs, res_index * 8 + 30 + yofs, bc + curr_fill); } } } menubox(double_buffer, 160 + xofs, 160 + yofs, 18, 6, BLUE); for (equipment_index = 0; equipment_index < NUM_EQUIPMENT; equipment_index++) { draw_icon(double_buffer, items[party[pidx_index].eqp[equipment_index]].icon, 168 + xofs, equipment_index * 8 + 168 + yofs); print_font(double_buffer, 176 + xofs, equipment_index * 8 + 168 + yofs, items[party[pidx_index].eqp[equipment_index]].name, FNORMAL); } blit2screen(xofs, yofs); readcontrols(); if (PlayerInput.left && fighter_index > 0) { unpress(); fighter_index--; pidx_index = pidx[fighter_index]; play_effect(SND_MENU, 128); } if (PlayerInput.right && fighter_index < numchrs - 1) { unpress(); fighter_index++; pidx_index = pidx[fighter_index]; play_effect(SND_MENU, 128); } if (PlayerInput.bctrl) { unpress(); play_effect(SND_MENU, 128); stop = 1; } } }
void TitleScene::processMenu() { if(doExit) return; if(!menu.isSelected()) return; if(menu.isAccepted()) { menustates[_currentMenu].first = menu.currentItemI(); menustates[_currentMenu].second = menu.offset(); QString value = menu.currentItem().value; switch(_currentMenu) { case menu_main: if(value=="game1p") { numOfPlayers=1; menuChain.push(_currentMenu); setMenu(menu_playepisode); } else if(value=="game2p") { numOfPlayers=2; menuChain.push(_currentMenu); setMenu(menu_playepisode); } else if(value=="gamebt") { menuChain.push(_currentMenu); setMenu(menu_playlevel); } else if(value=="Options") { menuChain.push(_currentMenu); setMenu(menu_options); } else if(value=="Exit") { ret = ANSWER_EXIT; fader.setNull(); doExit=true; } else { PGE_MsgBox msgBox(this, QString("Sorry, is not implemented yet..."), PGE_MsgBox::msg_warn); fader.setRatio(0.5); PGE_Window::setCursorVisibly(true); msgBox.exec(); PGE_Window::setCursorVisibly(false); fader.setNull(); menu.resetState(); } break; case menu_playepisode: { if(value=="noworlds") { //do nothing! menu.resetState(); } else { result_episode.worldfile = value; result_episode.character = 0; result_episode.savefile = "save1.savx"; if(numOfPlayers>1) ret = ANSWER_PLAYEPISODE_2P; else ret = ANSWER_PLAYEPISODE; fader.setFade(10, 1.0f, 0.06f); doExit=true; menu.resetState(); } } break; case menu_playlevel: if(value=="nolevel") { //do nothing! menu.resetState(); } else { result_level.levelfile = value; ret = ANSWER_PLAYLEVEL; fader.setFade(10, 1.0f, 0.06f); doExit=true; menu.resetState(); } break; case menu_options: if(value=="tests") { menuChain.push(_currentMenu); setMenu(menu_tests); } else if(value=="testboxes") { menuChain.push(_currentMenu); setMenu(menu_testboxes); } else if(value=="controls") { menuChain.push(_currentMenu); setMenu(menu_controls); } else if(value=="videosetup") { menuChain.push(_currentMenu); setMenu(menu_videosettings); } else { PGE_MsgBox msgBox(this, QString("Dummy"), PGE_MsgBox::msg_warn); msgBox.exec(); menu.resetState(); } break; case menu_controls: if(value=="control_plr1") { menuChain.push(_currentMenu); setMenu(menu_controls_plr1); } else if(value=="control_plr2") { menuChain.push(_currentMenu); setMenu(menu_controls_plr2); } break; case menu_controls_plr1: break; case menu_controls_plr2: break; case menu_tests: if(value=="credits") { ret = ANSWER_CREDITS; doExit=true; } else if(value=="loading") { ret = ANSWER_LOADING; doExit=true; } else if(value=="gameover") { ret = ANSWER_GAMEOVER; doExit=true; } break; case menu_testboxes: if(value=="messagebox") { PGE_MsgBox msg(this, "This is a small message box without texture\nЭто маленкая коробочка-сообщение без текстуры", PGE_BoxBase::msg_info_light); msg.exec(); PGE_MsgBox msg2(this, "This is a small message box with texture\nЭто маленкая коробочка-сообщение с текстурой", PGE_BoxBase::msg_info, PGE_Point(-1,-1), ConfigManager::setup_message_box.box_padding, ConfigManager::setup_message_box.sprite); msg2.exec(); menu.resetState(); } else if(value=="menubox") { PGE_MenuBox menubox(this, "Select something", PGE_MenuBox::msg_info, PGE_Point(-1,-1), ConfigManager::setup_menu_box.box_padding, ConfigManager::setup_message_box.sprite); QStringList items; items<<"Menuitem 1"; items<<"Menuitem 2"; items<<"Menuitem 3"; items<<"Menuitem 4"; items<<"Menuitem 5"; items<<"Menuitem 6"; items<<"Menuitem 7"; items<<"Menuitem 8"; items<<"Menuitem 9"; items<<"Menuitem 10"; items<<"Menuitem 11"; menubox.addMenuItems(items); menubox.setRejectSnd(obj_sound_role::MenuPause); menubox.setMaxMenuItems(5); menubox.exec(); if(menubox.answer()>=0) { PGE_MsgBox msg(this, "Your answer is:\n"+items[menubox.answer()], PGE_BoxBase::msg_info_light, PGE_Point(-1,-1), ConfigManager::setup_message_box.box_padding, ConfigManager::setup_message_box.sprite); msg.exec(); } menu.resetState(); } else if(value=="inputbox") { PGE_TextInputBox text(this, "Type a text", PGE_BoxBase::msg_info_light); text.exec(); PGE_MsgBox msg(this, "Typed a text:\n"+text.inputText(), PGE_BoxBase::msg_info_light); msg.exec(); menu.resetState(); } else if (value=="questionbox") { PGE_QuestionBox hor(this, "AHHHH?", PGE_MenuBox::msg_info, PGE_Point(-1,-1), ConfigManager::setup_menu_box.box_padding, ConfigManager::setup_message_box.sprite); QStringList items; items<<"One"; items<<"Two"; items<<"Three"; items<<"Four"; items<<"Five"; items<<"Six"; items<<"Seven"; hor.addMenuItems(items); hor.setRejectSnd(obj_sound_role::BlockSmashed); hor.exec(); if(hor.answer()>=0) { PGE_MsgBox msg(this, "Answer on so dumb question is:\n"+items[hor.answer()], PGE_BoxBase::msg_info_light, PGE_Point(-1,-1), ConfigManager::setup_message_box.box_padding, ConfigManager::setup_message_box.sprite); msg.exec(); } menu.resetState(); } break; case menu_dummy_and_big: menu.resetState(); break; default: break; } } else { switch(_currentMenu) { case menu_main: menu.reset(); menu.setCurrentItem(4); break; case menu_options: AppSettings.apply(); AppSettings.save(); PGE_Audio::playSoundByRole(obj_sound_role::Bonus1up); default: if(menu.isKeyGrabbing()) menu.reset(); else if(menuChain.size()>0) { menu.reset(); setMenu((CurrentMenu)menuChain.pop()); } break; } } }
/*! \brief Display menu * * This displays the party's list of items. * * \param ptr Location of the cursor * \param pg Item menu page number * \param sl 1 if selecting an action, 0 if selecting an item to use/drop */ static void draw_itemmenu(int ptr, int pg, int sl) { int z, j, k, a, ck; menubox(double_buffer, 72 + xofs, 12 + yofs, 20, 1, BLUE); print_font(double_buffer, 140 + xofs, 20 + yofs, _("Items"), FGOLD); menubox(double_buffer, 72 + xofs, 36 + yofs, 20, 1, BLUE); if (sl == 1) { menubox(double_buffer, item_act * 56 + 72 + xofs, 36 + yofs, 6, 1, DARKBLUE); print_font(double_buffer, 92 + xofs, 44 + yofs, _("Use"), FGOLD); print_font(double_buffer, 144 + xofs, 44 + yofs, _("Sort Drop"), FGOLD); } else { if (item_act == 0) { print_font(double_buffer, 148 + xofs, 44 + yofs, _("Use"), FGOLD); } else { print_font(double_buffer, 144 + xofs, 44 + yofs, _("Drop"), FGOLD); } } menubox(double_buffer, 72 + xofs, 60 + yofs, 20, 16, BLUE); for (k = 0; k < 16; k++) { // j == item index # j = g_inv[pg * 16 + k][0]; // z == quantity of item z = g_inv[pg * 16 + k][1]; draw_icon(double_buffer, items[j].icon, 88 + xofs, k * 8 + 68 + yofs); if (items[j].use >= USE_ANY_ONCE && items[j].use <= USE_CAMP_INF) { ck = FNORMAL; } else { ck = FDARK; } if (j == I_SSTONE && use_sstone == 0) { ck = FDARK; } print_font(double_buffer, 96 + xofs, k * 8 + 68 + yofs, items[j].name, ck); if (z > 1) { sprintf(strbuf, "^%d", z); print_font(double_buffer, 224 + xofs, k * 8 + 68 + yofs, strbuf, ck); } } menubox(double_buffer, 72 + xofs, 204 + yofs, 20, 1, BLUE); if (sl == 0) { a = strlen(items[g_inv[pg * 16 + ptr][0]].desc) * 4; print_font(double_buffer, 160 - a + xofs, 212 + yofs, items[g_inv[pg * 16 + ptr][0]].desc, FNORMAL); draw_sprite(double_buffer, menuptr, 72 + xofs, ptr * 8 + 68 + yofs); } draw_sprite(double_buffer, pgb[pg], 238 + xofs, 194 + yofs); }