int SpinButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2) { int rtn; CTLWINDOW *ct = GetControl(wnd); if (ct != NULL) { switch (msg) { case CREATE_WINDOW: wnd->wd -= 2; wnd->rc.rt -= 2; break; case SETFOCUS: rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2); if (!(int)p1) SendMessage(NULL, HIDE_CURSOR, 0, 0); SetFocusCursor(wnd); return rtn; case PAINT: foreground = WndBackground(wnd); background = WndForeground(wnd); wputch(wnd,UPSCROLLBOX,WindowWidth(wnd), 0); wputch(wnd,DOWNSCROLLBOX,WindowWidth(wnd)+1,0); SetFocusCursor(wnd); break; case LEFT_BUTTON: if (p1 == GetRight(wnd) + 1) SendMessage(wnd, KEYBOARD, UP, 0); else if (p1 == GetRight(wnd) + 2) SendMessage(wnd, KEYBOARD, DN, 0); if (wnd != inFocus) SendMessage(wnd, SETFOCUS, TRUE, 0); return TRUE; case LB_SETSELECTION: rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2); wnd->wtop = (int) p1; SendMessage(wnd, PAINT, 0, 0); return rtn; default: break; } } return BaseWndProc(SPINBUTTON, wnd, msg, p1, p2); }
WORLDPTR worldfactory::pick_world( bool show_prompt ) { std::map<std::string, WORLDPTR> worlds = get_all_worlds(); std::vector<std::string> world_names = all_worldnames; // Filter out special worlds (TUTORIAL | DEFENSE) from world_names. for (std::vector<std::string>::iterator it = world_names.begin(); it != world_names.end();) { if (*it == "TUTORIAL" || *it == "DEFENSE") { it = world_names.erase(it); } else if (world_need_lua_build(*it)) { it = world_names.erase(it); } else { ++it; } } // If there is only one world to pick from, autoreturn it. if (world_names.size() == 1) { return worlds[world_names[0]]; } // If there are no worlds to pick from, immediately try to make one. else if (world_names.empty()) { return make_new_world( show_prompt ); } // If we're skipping prompts, just return the first one. else if( !show_prompt ) { return worlds[world_names[0]]; } const int iTooltipHeight = 3; const int iContentHeight = FULL_SCREEN_HEIGHT - 3 - iTooltipHeight; const unsigned int num_pages = world_names.size() / iContentHeight + 1; // at least 1 page const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0; std::map<int, bool> mapLines; mapLines[3] = true; std::map<int, std::vector<std::string> > world_pages; unsigned int worldnum = 0; for (size_t i = 0; i < num_pages; ++i) { for (int j = 0; j < iContentHeight && worldnum < world_names.size(); ++j) { world_pages[i].push_back(world_names[worldnum++]); } } unsigned int sel = 0, selpage = 0; WINDOW *w_worlds_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX); WINDOW *w_worlds_tooltip = newwin(iTooltipHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY, 1 + iOffsetX); WINDOW *w_worlds_header = newwin(1, FULL_SCREEN_WIDTH - 2, 1 + iTooltipHeight + iOffsetY, 1 + iOffsetX); WINDOW *w_worlds = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iTooltipHeight + 2 + iOffsetY, 1 + iOffsetX); draw_border(w_worlds_border); mvwputch(w_worlds_border, 4, 0, BORDER_COLOR, LINE_XXXO); // |- mvwputch(w_worlds_border, 4, FULL_SCREEN_WIDTH - 1, BORDER_COLOR, LINE_XOXX); // -| for( auto &mapLine : mapLines ) { mvwputch( w_worlds_border, FULL_SCREEN_HEIGHT - 1, mapLine.first + 1, BORDER_COLOR, LINE_XXOX ); // _|_ } center_print(w_worlds_border, 0, c_ltred, _(" WORLD SELECTION ")); wrefresh(w_worlds_border); for (int i = 0; i < 78; i++) { if (mapLines[i]) { mvwputch(w_worlds_header, 0, i, BORDER_COLOR, LINE_OXXX); } else { mvwputch(w_worlds_header, 0, i, BORDER_COLOR, LINE_OXOX); // Draw header line } } wrefresh(w_worlds_header); input_context ctxt("PICK_WORLD_DIALOG"); ctxt.register_updown(); ctxt.register_action("HELP_KEYBINDINGS"); ctxt.register_action("QUIT"); ctxt.register_action("NEXT_TAB"); ctxt.register_action("PREV_TAB"); ctxt.register_action("CONFIRM"); std::stringstream sTemp; while(true) { //Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { if (mapLines[j]) { mvwputch(w_worlds, i, j, BORDER_COLOR, LINE_XOXO); } else { mvwputch(w_worlds, i, j, c_black, ' '); } if (i < iTooltipHeight) { mvwputch(w_worlds_tooltip, i, j, c_black, ' '); } } } //Draw World Names for (size_t i = 0; i < world_pages[selpage].size(); ++i) { sTemp.str(""); sTemp << i + 1; mvwprintz(w_worlds, i, 0, c_white, "%s", sTemp.str().c_str()); mvwprintz(w_worlds, i, 4, c_white, ""); std::string world_name = (world_pages[selpage])[i]; size_t saves_num = world_generator->all_worlds[world_name]->world_saves.size(); if (i == sel) { wprintz(w_worlds, c_yellow, ">> "); } else { wprintz(w_worlds, c_yellow, " "); } if (world_need_lua_build(world_name)) { wprintz(w_worlds, c_dkgray, "%s (%i)", world_name.c_str(), saves_num); } else { wprintz(w_worlds, c_white, "%s (%i)", world_name.c_str(), saves_num); } } //Draw Tabs mvwprintz(w_worlds_header, 0, 7, c_white, ""); for (size_t i = 0; i < num_pages; ++i) { nc_color tabcolor = (selpage == i) ? hilite(c_white) : c_white; if (!world_pages[i].empty()) { //skip empty pages wprintz(w_worlds_header, c_white, "["); wprintz(w_worlds_header, tabcolor, _("Page %d"), i + 1); wprintz(w_worlds_header, c_white, "]"); wputch(w_worlds_header, BORDER_COLOR, LINE_OXOX); } } wrefresh(w_worlds_header); fold_and_print(w_worlds_tooltip, 0, 0, 78, c_white, _("Pick a world to enter game")); wrefresh(w_worlds_tooltip); wrefresh(w_worlds); const std::string action = ctxt.handle_input(); if (action == "QUIT") { break; } else if (!world_pages[selpage].empty() && action == "DOWN") { sel++; if (sel >= world_pages[selpage].size()) { sel = 0; } } else if (!world_pages[selpage].empty() && action == "UP") { if (sel == 0) { sel = world_pages[selpage].size() - 1; } else { sel--; } } else if (action == "NEXT_TAB") { sel = 0; do { //skip empty pages selpage++; if (selpage >= world_pages.size()) { selpage = 0; } } while(world_pages[selpage].empty()); } else if (action == "PREV_TAB") { sel = 0; do { //skip empty pages if (selpage != 0) { selpage--; } else { selpage = world_pages.size() - 1; } } while(world_pages[selpage].empty()); } else if (action == "CONFIRM") { if (world_need_lua_build(world_pages[selpage][sel])) { popup(_("Can't start in world [%s]. Some of mods require Lua support."), world_pages[selpage][sel].c_str()); continue; } // we are wanting to get out of this by confirmation, so ask if we want to load the level [y/n prompt] and if yes exit if (query_yn(_("Do you want to start the game in world [%s]?"), world_pages[selpage][sel].c_str())) { werase(w_worlds); werase(w_worlds_border); werase(w_worlds_header); werase(w_worlds_tooltip); return all_worlds[world_pages[selpage][sel]];//sel + selpage * iContentHeight; } } } werase(w_worlds); werase(w_worlds_border); werase(w_worlds_header); werase(w_worlds_tooltip); return NULL; }
void game::show_options() { std::map<std::string, cOpt> OPTIONS_OLD = OPTIONS; const int iTooltipHeight = 3; const int iContentHeight = FULL_SCREEN_HEIGHT-3-iTooltipHeight; const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0; std::map<int, bool> mapLines; mapLines[3] = true; mapLines[60] = true; //mapLines[68] = true; WINDOW* w_options_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX); WINDOW* w_options_tooltip = newwin(iTooltipHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY, 1 + iOffsetX); WINDOW* w_options_header = newwin(1, FULL_SCREEN_WIDTH - 2, 1 + iTooltipHeight + iOffsetY, 1 + iOffsetX); WINDOW* w_options = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iTooltipHeight + 2 + iOffsetY, 1 + iOffsetX); wborder(w_options_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX); mvwputch(w_options_border, 4, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_options_border, 4, 79, c_ltgray, LINE_XOXX); // -| for (std::map<int, bool>::iterator iter = mapLines.begin(); iter != mapLines.end(); ++iter) { mvwputch(w_options_border, FULL_SCREEN_HEIGHT-1, iter->first + 1, c_ltgray, LINE_XXOX); // _|_ } mvwprintz(w_options_border, 0, 36, c_ltred, _(" OPTIONS ")); wrefresh(w_options_border); for (int i = 0; i < 78; i++) { if (mapLines[i]) { mvwputch(w_options_header, 0, i, c_ltgray, LINE_OXXX); } else { mvwputch(w_options_header, 0, i, c_ltgray, LINE_OXOX); // Draw header line } } //mvwprintz(w_options_header, 3, 0, c_white, "#"); //mvwprintz(w_options_header, 3, 7, c_white, _("Option")); //mvwprintz(w_options_header, 3, 52, c_white, _("Value")); wrefresh(w_options_header); int iCurrentPage = 0; int iCurrentLine = 0; int iStartPos = 0; bool bStuffChanged = false; char ch = ' '; std::stringstream sTemp; do { //Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { if (mapLines[j]) { mvwputch(w_options, i, j, c_ltgray, LINE_XOXO); } else { mvwputch(w_options, i, j, c_black, ' '); } if (i < iTooltipHeight) { mvwputch(w_options_tooltip, i, j, c_black, ' '); } } } if (mPageItems[iCurrentPage].size() > iContentHeight) { iStartPos = iCurrentLine - (iContentHeight - 1) / 2; if (iStartPos < 0) { iStartPos = 0; } else if (iStartPos + iContentHeight > mPageItems[iCurrentPage].size()) { iStartPos = mPageItems[iCurrentPage].size() - iContentHeight; } } //Draw options for (int i = iStartPos; i < mPageItems[iCurrentPage].size(); i++) { if (i >= iStartPos && i < iStartPos + ((iContentHeight > mPageItems[iCurrentPage].size()) ? mPageItems[iCurrentPage].size() : iContentHeight)) { nc_color cLineColor = c_ltgreen; sTemp.str(""); sTemp << i + 1; mvwprintz(w_options, i - iStartPos, 0, c_white, sTemp.str().c_str()); mvwprintz(w_options, i - iStartPos, 4, c_white, ""); if (iCurrentLine == i) { wprintz(w_options, c_yellow, ">> "); } else { wprintz(w_options, c_yellow, " "); } wprintz(w_options, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getMenuText()).c_str()); if (OPTIONS[mPageItems[iCurrentPage][i]].getValue() == "False") { cLineColor = c_ltred; } mvwprintz(w_options, i - iStartPos, 62, (iCurrentLine == i) ? hilite(cLineColor) : cLineColor, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getValue()).c_str()); } } //Draw Tabs mvwprintz(w_options_header, 0, 7, c_white, ""); for (int i = 0; i < vPages.size(); i++) { if (mPageItems[i].size() > 0) { //skip empty pages wprintz(w_options_header, c_white, "["); wprintz(w_options_header, (iCurrentPage == i) ? hilite(c_white) : c_white, vPages[i].c_str()); wprintz(w_options_header, c_white, "]"); wputch(w_options_header, c_white, LINE_OXOX); } } wrefresh(w_options_header); fold_and_print(w_options_tooltip, 0, 0, 78, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getTooltip() + " #Default: " + OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getDefaultText()).c_str()); wrefresh(w_options_tooltip); wrefresh(w_options); ch = input(); if (mPageItems[iCurrentPage].size() > 0 || ch == '\t') { switch(ch) { case 'j': //move down iCurrentLine++; if (iCurrentLine >= mPageItems[iCurrentPage].size()) { iCurrentLine = 0; } break; case 'k': //move up iCurrentLine--; if (iCurrentLine < 0) { iCurrentLine = mPageItems[iCurrentPage].size()-1; } break; case 'l': //set to prev value OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setNext(); bStuffChanged = true; break; case 'h': //set to next value OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setPrev(); bStuffChanged = true; break; case '>': case '\t': //Switch to next Page iCurrentLine = 0; do { //skip empty pages iCurrentPage++; if (iCurrentPage >= vPages.size()) { iCurrentPage = 0; } } while(mPageItems[iCurrentPage].size() == 0); break; case '<': iCurrentLine = 0; do { //skip empty pages iCurrentPage--; if (iCurrentPage < 0) { iCurrentPage = vPages.size()-1; } } while(mPageItems[iCurrentPage].size() == 0); break; } } } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE); if (bStuffChanged) { if(query_yn(_("Save changes?"))) { save_options(); } else { OPTIONS = OPTIONS_OLD; } } werase(w_options); werase(w_options_border); werase(w_options_header); werase(w_options_tooltip); }
void robot_finds_kitten::draw_robot(WINDOW *w) /* Draws robot at current position */ { wputch(w, robot.color, robot.character); }
void robot_finds_kitten::draw_kitten(WINDOW *w) /* Draws kitten at current position */ { wputch(w, kitten.color, kitten.character); }
void robot_finds_kitten::process_input(int input, WINDOW *w) { timespec ts; ts.tv_sec = 1; ts.tv_nsec = 0; int check_x = robot.x; int check_y = robot.y; switch (input) { case KEY_UP: /* up */ check_y--; break; case KEY_DOWN: /* down */ check_y++; break; case KEY_LEFT: /* left */ check_x--; break; case KEY_RIGHT: /* right */ check_x++; break; case 0: break; default: { /* invalid command */ for (int c = 0; c < rfkCOLS; c++) { mvwputch (w, 0, c, c_white, ' '); mvwputch (w, 1, c, c_white, ' '); } mvwprintz (w, 0, 0, c_white, _("Invalid command: Use direction keys or press 'q'.")); return; } } if (check_y < 3 || check_y > rfkLINES - 1 || check_x < 0 || check_x > rfkCOLS - 1) { return; } if (rfkscreen[check_x][check_y] != EMPTY) { switch (rfkscreen[check_x][check_y]) { case ROBOT: /* We didn't move. */ break; case KITTEN: {/* Found it! */ for (int c = 0; c < rfkCOLS; c++) { mvwputch (w, 0, c, c_white, ' '); } /* The grand cinema scene. */ for (int c = 0; c <= 3; c++) { wmove(w, 1, (rfkCOLS / 2) - 5 + c); wputch(w, c_white, ' '); wmove(w, 1, (rfkCOLS / 2) + 4 - c); wputch(w, c_white, ' '); wmove(w, 1, (rfkCOLS / 2) - 4 + c); if (input == KEY_LEFT || input == KEY_UP) { draw_kitten(w); } else { draw_robot(w); } wmove(w, 1, (rfkCOLS / 2) + 3 - c); if (input == KEY_LEFT || input == KEY_UP) { draw_robot(w); } else { draw_kitten(w); } wrefresh (w); nanosleep(&ts, NULL); } /* They're in love! */ mvwprintz(w, 0, ((rfkCOLS - 6) / 2) - 1, c_ltred, "<3<3<3"); wrefresh(w); nanosleep(&ts, NULL); for (int c = 0; c < rfkCOLS; c++) { mvwputch (w, 0, c, c_white, ' '); mvwputch (w, 1, c, c_white, ' '); } mvwprintz (w, 0, 0, c_white, _("You found kitten! Way to go, robot!")); wrefresh(w); ret = true; int ech = input; do { ech = getch (); } while ( ech == input ); } break; default: { for (int c = 0; c < rfkCOLS; c++) { mvwputch (w, 0, c, c_white, ' '); mvwputch (w, 1, c, c_white, ' '); } std::vector<std::string> bogusvstr = foldstring( getmessage( bogus_messages[rfkscreen[check_x][check_y] - 2]), rfkCOLS); for (size_t c = 0; c < bogusvstr.size(); c++) { mvwprintw (w, c, 0, "%s", bogusvstr[c].c_str()); } wrefresh(w); } break; } wmove(w, 2, 0); return; } /* Otherwise, move the robot. */ robot.x = check_x; robot.y = check_y; }
robot_finds_kitten::robot_finds_kitten(WINDOW *w) { ret = false; char ktile[83] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#&()*+./:;=?![]{|}y"; int used_messages[MAXMESSAGES]; rfkLINES = 20; rfkCOLS = 60; const int numbogus = 20; nummessages = 201; empty.x = -1; empty.y = -1; empty.color = (nc_color)0; empty.character = ' '; for (int c = 0; c < rfkCOLS; c++) { for (int c2 = 0; c2 < rfkLINES; c2++) { rfkscreen[c][c2] = EMPTY; } } /* Create an array to ensure we don't get duplicate messages. */ for (int c = 0; c < nummessages; c++) { used_messages[c] = 0; bogus_messages[c] = 0; bogus[c] = empty; } /* Now we initialize the various game OBJECTs. * Assign a position to the player. */ robot.x = rand() % rfkCOLS; robot.y = rand() % (rfkLINES - 3) + 3; robot.character = '#'; robot.color = c_white; rfkscreen[robot.x][robot.y] = ROBOT; /* Assign the kitten a unique position. */ do { kitten.x = rand() % rfkCOLS; kitten.y = rand() % (rfkLINES - 3) + 3; } while (rfkscreen[kitten.x][kitten.y] != EMPTY); /* Assign the kitten a character and a color. */ do { kitten.character = ktile[rand() % 82]; } while (kitten.character == '#' || kitten.character == ' '); do { kitten.color = all_colors.get_random(); } while ( kitten.color == c_black ); rfkscreen[kitten.x][kitten.y] = KITTEN; /* Now, initialize non-kitten OBJECTs. */ for (int c = 0; c < numbogus; c++) { /* Assign a unique position. */ do { bogus[c].x = rand() % rfkCOLS; bogus[c].y = (rand() % (rfkLINES - 3)) + 3; } while (rfkscreen[bogus[c].x][bogus[c].y] != EMPTY); rfkscreen[bogus[c].x][bogus[c].y] = c + 2; /* Assign a character. */ do { bogus[c].character = ktile[rand() % 82]; } while (bogus[c].character == '#' || bogus[c].character == ' '); do { bogus[c].color = all_colors.get_random(); } while ( bogus[c].color == c_black ); /* Assign a unique message. */ int index = 0; do { index = rand() % nummessages; } while (used_messages[index] != 0); bogus_messages[c] = index; used_messages[index] = 1; } instructions(w); werase(w); mvwprintz (w, 0, 0, c_white, _("robotfindskitten v22July2008 - press q to quit.")); for (int c = 0; c < rfkCOLS; c++) { mvwputch (w, 2, c, BORDER_COLOR, '_'); } wmove(w, kitten.y, kitten.x); draw_kitten(w); for (int c = 0; c < numbogus; c++) { mvwputch(w, bogus[c].y, bogus[c].x, bogus[c].color, bogus[c].character); } wmove(w, robot.y, robot.x); draw_robot(w); int old_x = robot.x; int old_y = robot.y; wrefresh(w); /* Now the fun begins. */ int input = '.'; input = getch(); while (input != 'q' && input != 'Q' && input != 27 /*escape*/) { process_input(input, w); if(ret == true) { break; } /* Redraw robot, where avaliable */ if (!(old_x == robot.x && old_y == robot.y)) { wmove(w, old_y, old_x); wputch(w, c_white, ' '); wmove(w, robot.y, robot.x); draw_robot(w); rfkscreen[old_x][old_y] = EMPTY; rfkscreen[robot.x][robot.y] = ROBOT; old_x = robot.x; old_y = robot.y; } wrefresh(w); input = getch(); } }
WORLDPTR worldfactory::pick_world() { std::map<std::string, WORLDPTR> worlds = get_all_worlds(); std::vector<std::string> world_names = all_worldnames; // filter out special worlds (TUTORIAL | DEFENSE) from world_names for (std::vector<std::string>::iterator it = world_names.begin(); it != world_names.end();) { if (*it == "TUTORIAL" || *it == "DEFENSE") { it = world_names.erase(it); } else { ++it; } } // if there is only one world to pick from, autoreturn it if (world_names.size() == 1) { return worlds[world_names[0]]; } // if there are no worlds to pick from, immediately try to make one else if (world_names.empty()) { return make_new_world(); } const int iTooltipHeight = 3; const int iContentHeight = FULL_SCREEN_HEIGHT - 3 - iTooltipHeight; const int num_pages = world_names.size() / iContentHeight + 1; // at least 1 page const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0; std::map<int, bool> mapLines; mapLines[3] = true; std::map<int, std::vector<std::string> > world_pages; int worldnum = 0; for (int i = 0; i < num_pages; ++i) { world_pages[i] = std::vector<std::string>(); for (int j = 0; j < iContentHeight; ++j) { world_pages[i].push_back(world_names[worldnum++]); if (worldnum == world_names.size()) { break; } } } int sel = 0, selpage = 0; WINDOW *w_worlds_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX); WINDOW *w_worlds_tooltip = newwin(iTooltipHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY, 1 + iOffsetX); WINDOW *w_worlds_header = newwin(1, FULL_SCREEN_WIDTH - 2, 1 + iTooltipHeight + iOffsetY, 1 + iOffsetX); WINDOW *w_worlds = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iTooltipHeight + 2 + iOffsetY, 1 + iOffsetX); draw_border(w_worlds_border); mvwputch(w_worlds_border, 4, 0, c_dkgray, LINE_XXXO); // |- mvwputch(w_worlds_border, 4, 79, c_dkgray, LINE_XOXX); // -| for (std::map<int, bool>::iterator iter = mapLines.begin(); iter != mapLines.end(); ++iter) { mvwputch(w_worlds_border, FULL_SCREEN_HEIGHT - 1, iter->first + 1, c_dkgray, LINE_XXOX); // _|_ } mvwprintz(w_worlds_border, 0, 31, c_ltred, _(" WORLD SELECTION ")); wrefresh(w_worlds_border); for (int i = 0; i < 78; i++) { if (mapLines[i]) { mvwputch(w_worlds_header, 0, i, c_dkgray, LINE_OXXX); } else { mvwputch(w_worlds_header, 0, i, c_dkgray, LINE_OXOX); // Draw header line } } wrefresh(w_worlds_header); char ch = ' '; std::stringstream sTemp; do { //Clear the lines for (int i = 0; i < iContentHeight; i++) { for (int j = 0; j < 79; j++) { if (mapLines[j]) { mvwputch(w_worlds, i, j, c_dkgray, LINE_XOXO); } else { mvwputch(w_worlds, i, j, c_black, ' '); } if (i < iTooltipHeight) { mvwputch(w_worlds_tooltip, i, j, c_black, ' '); } } } //Draw World Names for (unsigned i = 0; i < world_pages[selpage].size(); ++i) { sTemp.str(""); sTemp << i + 1; mvwprintz(w_worlds, i, 0, c_white, sTemp.str().c_str()); mvwprintz(w_worlds, i, 4, c_white, ""); if (i == sel) { wprintz(w_worlds, c_yellow, ">> "); } else { wprintz(w_worlds, c_yellow, " "); } wprintz(w_worlds, c_white, "%s", (world_pages[selpage])[i].c_str()); } //Draw Tabs mvwprintz(w_worlds_header, 0, 7, c_white, ""); for (int i = 0; i < num_pages; ++i) { nc_color tabcolor = (selpage == i) ? hilite(c_white):c_white; if (world_pages[i].size() > 0) { //skip empty pages wprintz(w_worlds_header, c_white, "["); wprintz(w_worlds_header, tabcolor, _("Page %d"), i + 1); wprintz(w_worlds_header, c_white, "]"); wputch(w_worlds_header, c_dkgray, LINE_OXOX); } } wrefresh(w_worlds_header); fold_and_print(w_worlds_tooltip, 0, 0, 78, c_white, _("Pick a world to enter game")); wrefresh(w_worlds_tooltip); wrefresh(w_worlds); ch = input(); if (world_pages[selpage].size() > 0 || ch == '\t') { switch(ch) { case 'j': //move down sel++; if (sel >= world_pages[selpage].size()) { sel = 0; } break; case 'k': //move up sel--; if (sel < 0) { sel = world_pages[selpage].size() - 1; } break; case '>': case '\t': //Switch to next Page sel = 0; do { //skip empty pages selpage++; if (selpage >= world_pages.size()) { selpage = 0; } } while(world_pages[selpage].size() == 0); break; case '<': sel = 0; do { //skip empty pages selpage--; if (selpage < 0) { selpage = world_pages.size() - 1; } } while(world_pages[selpage].size() == 0); break; case '\n': // we are wanting to get out of this by confirmation, so ask if we want to load the level [y/n prompt] and if yes exit std::string querystring = string_format(_("Do you want to start the game in world [%s]?"), world_pages[selpage][sel].c_str()); if (query_yn(querystring.c_str())) { werase(w_worlds); werase(w_worlds_border); werase(w_worlds_header); werase(w_worlds_tooltip); return all_worlds[world_pages[selpage][sel]];//sel + selpage * iContentHeight; } break; } } } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE); werase(w_worlds); werase(w_worlds_border); werase(w_worlds_header); werase(w_worlds_tooltip); return NULL; }
void robot_finds_kitten::draw_kitten( const catacurses::window &w ) /* Draws kitten at current position */ { wputch( w, kitten.color, kitten.character ); }
void robot_finds_kitten::draw_robot( const catacurses::window &w ) /* Draws robot at current position */ { wputch( w, robot.color, robot.character ); }