diff --git a/catacurse.h b/catacurse.h index b35268c09ce7c..96a8d79d5eb10 100644 --- a/catacurse.h +++ b/catacurse.h @@ -60,6 +60,7 @@ typedef struct { int cursorx;//x location of the cursor int cursory;//y location of the cursor curseline *line; + } WINDOW; #define A_NORMAL __NORMAL diff --git a/color.h b/color.h index cf53b7c8ea8c2..7a92a8c1917f7 100644 --- a/color.h +++ b/color.h @@ -1,18 +1,11 @@ #ifndef _COLOR_H_ #define _COLOR_H -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" - -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #ifndef _COLOR_LIST_ #define _COLOR_LIST_ +#include "cursesdef.h" + void init_colors(); enum col_attribute { diff --git a/cursesdef.h b/cursesdef.h new file mode 100644 index 0000000000000..928cc6a6bcf9b --- /dev/null +++ b/cursesdef.h @@ -0,0 +1,12 @@ +#ifndef _CURSES_DEF_H_ +#define _CURSES_DEF_H_ + +#if (defined _WIN32 || defined WINDOWS) + #include "catacurse.h" +#elif (defined __CYGWIN__) + #include "ncurses/curses.h" +#else + #include +#endif + +#endif // CURSES_DEF_H diff --git a/game.cpp b/game.cpp index 8c6c782fb39ed..eb1bfc982cc15 100644 --- a/game.cpp +++ b/game.cpp @@ -68,20 +68,31 @@ game::game() : init_vehicles(); // Set up vehicles (SEE veh_typedef.cpp) init_autosave(); // Set up autosave load_keyboard_settings(); + + VIEWX = OPTIONS[OPT_VIEWPORT_X]; + VIEWY = OPTIONS[OPT_VIEWPORT_Y]; + if (VIEWX <= 0) { + VIEWX = 1; + } + if (VIEWY <= 0) { + VIEWY = 1; + } + TERRAIN_WINDOW_WIDTH = (VIEWX * 2) + 1; + TERRAIN_WINDOW_HEIGHT = (VIEWY * 2) + 1; // Set up the main UI windows. - w_terrain = newwin(SEEY * 2 + 1, SEEX * 2 + 1, 0, 0); + w_terrain = newwin(TERRAIN_WINDOW_HEIGHT, TERRAIN_WINDOW_WIDTH, 0, 0); werase(w_terrain); - w_minimap = newwin(7, 7, 0, SEEX * 2 + 1); + w_minimap = newwin(7, 7, 0, TERRAIN_WINDOW_WIDTH); werase(w_minimap); - w_HP = newwin(14, 7, 7, SEEX * 2 + 1); + w_HP = newwin(14, 7, 7, TERRAIN_WINDOW_WIDTH); werase(w_HP); - w_moninfo = newwin(12, 48, 0, SEEX * 2 + 8); + w_moninfo = newwin(12, 48, 0, VIEWX * 2 + 8); werase(w_moninfo); - w_messages = newwin(8, 48, 12, SEEX * 2 + 8); + w_messages = newwin(8, 48, 12, VIEWX * 2 + 8); werase(w_messages); - w_location = newwin(1, 48, 20, SEEX * 2 + 8); + w_location = newwin(1, 48, 20, VIEWX * 2 + 8); werase(w_location); - w_status = newwin(4, 55, 21, SEEX * 2 + 1); + w_status = newwin(4, 55, 21, TERRAIN_WINDOW_WIDTH); werase(w_status); gamemode = new special_game; // Nothing, basically. @@ -2775,32 +2786,32 @@ void game::draw_ter(int posx, int posy) for (int i = 0; i < z.size(); i++) { disty = abs(z[i].posy - posy); distx = abs(z[i].posx - posx); - if (distx <= SEEX && disty <= SEEY && u_see(&(z[i]), t)) + if (distx <= VIEWX && disty <= VIEWY && u_see(&(z[i]), t)) z[i].draw(w_terrain, posx, posy, false); - else if (z[i].has_flag(MF_WARM) && distx <= SEEX && disty <= SEEY && + else if (z[i].has_flag(MF_WARM) && distx <= VIEWX && disty <= VIEWY && (u.has_active_bionic(bio_infrared) || u.has_trait(PF_INFRARED))) - mvwputch(w_terrain, SEEY + z[i].posy - posy, SEEX + z[i].posx - posx, + mvwputch(w_terrain, VIEWY + z[i].posy - posy, VIEWX + z[i].posx - posx, c_red, '?'); } // Draw NPCs for (int i = 0; i < active_npc.size(); i++) { disty = abs(active_npc[i].posy - posy); distx = abs(active_npc[i].posx - posx); - if (distx <= SEEX && disty <= SEEY && + if (distx <= VIEWX && disty <= VIEWY && u_see(active_npc[i].posx, active_npc[i].posy, t)) active_npc[i].draw(w_terrain, posx, posy, false); } if (u.has_active_bionic(bio_scent_vision)) { - for (int realx = posx - SEEX; realx <= posx + SEEX; realx++) { - for (int realy = posy - SEEY; realy <= posy + SEEY; realy++) { + for (int realx = posx - VIEWX; realx <= posx + VIEWX; realx++) { + for (int realy = posy - VIEWY; realy <= posy + VIEWY; realy++) { if (scent(realx, realy) != 0) { int tempx = posx - realx, tempy = posy - realy; if (!(isBetween(tempx, -2, 2) && isBetween(tempy, -2, 2))) { if (mon_at(realx, realy) != -1) - mvwputch(w_terrain, realy + SEEY - posy, realx + SEEX - posx, + mvwputch(w_terrain, realy + VIEWY - posy, realx + VIEWX - posx, c_white, '?'); else - mvwputch(w_terrain, realy + SEEY - posy, realx + SEEX - posx, + mvwputch(w_terrain, realy + VIEWY - posy, realx + VIEWX - posx, c_magenta, '#'); } } @@ -2990,11 +3001,11 @@ void game::draw_minimap() void game::hallucinate(const int x, const int y) { - for (int i = 0; i <= SEEX * 2 + 1; i++) { - for (int j = 0; j <= SEEY * 2 + 1; j++) { + for (int i = 0; i <= TERRAIN_WINDOW_WIDTH; i++) { + for (int j = 0; j <= TERRAIN_WINDOW_HEIGHT; j++) { if (one_in(10)) { - char ter_sym = terlist[m.ter(i + x - SEEX + rng(-2, 2), j + y - SEEY + rng(-2, 2))].sym; - nc_color ter_col = terlist[m.ter(i + x - SEEX + rng(-2, 2), j + y - SEEY+ rng(-2, 2))].color; + char ter_sym = terlist[m.ter(i + x - VIEWX + rng(-2, 2), j + y - VIEWY + rng(-2, 2))].sym; + nc_color ter_col = terlist[m.ter(i + x - VIEWX + rng(-2, 2), j + y - VIEWY+ rng(-2, 2))].color; mvwputch(w_terrain, j, i, ter_col, ter_sym); } } @@ -3285,7 +3296,7 @@ void game::mon_info() } dir_to_mon = direction_from(u.posx, u.posy, z[i].posx, z[i].posy); - int index = (rl_dist(u.posx, u.posy, z[i].posx, z[i].posy) <= SEEX ? + int index = (rl_dist(u.posx, u.posy, z[i].posx, z[i].posy) <= VIEWX ? 8 : dir_to_mon); if (mon_dangerous && index < 8) dangerous[index] = true; @@ -3300,7 +3311,7 @@ void game::mon_info() newseen++; point npcp(active_npc[i].posx, active_npc[i].posy); dir_to_npc = direction_from ( u.posx, u.posy, npcp.x, npcp.y ); - int index = (rl_dist(u.posx, u.posy, npcp.x, npcp.y) <= SEEX ? + int index = (rl_dist(u.posx, u.posy, npcp.x, npcp.y) <= VIEWX ? 8 : dir_to_npc); unique_types[index].push_back(-1 - i); } @@ -3703,8 +3714,8 @@ void game::add_footstep(int x, int y, int volume, int distance) void game::draw_footsteps() { for (int i = 0; i < footsteps.size(); i++) { - mvwputch(w_terrain, SEEY + footsteps[i].y - u.posy - u.view_offset_y, - SEEX + footsteps[i].x - u.posx - u.view_offset_x, c_yellow, '?'); + mvwputch(w_terrain, VIEWY + footsteps[i].y - u.posy - u.view_offset_y, + VIEWX + footsteps[i].x - u.posx - u.view_offset_x, c_yellow, '?'); } footsteps.clear(); wrefresh(w_terrain); @@ -3783,23 +3794,23 @@ void game::explosion(int x, int y, int power, int shrapnel, bool fire) } // Draw the explosion for (int i = 1; i <= radius; i++) { - mvwputch(w_terrain, y - i + SEEY - u.posy - u.view_offset_y, - x - i + SEEX - u.posx - u.view_offset_x, c_red, '/'); - mvwputch(w_terrain, y - i + SEEY - u.posy - u.view_offset_y, - x + i + SEEX - u.posx - u.view_offset_x, c_red,'\\'); - mvwputch(w_terrain, y + i + SEEY - u.posy - u.view_offset_y, - x - i + SEEX - u.posx - u.view_offset_x, c_red,'\\'); - mvwputch(w_terrain, y + i + SEEY - u.posy - u.view_offset_y, - x + i + SEEX - u.posx - u.view_offset_x, c_red, '/'); + mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y, + x - i + VIEWX - u.posx - u.view_offset_x, c_red, '/'); + mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y, + x + i + VIEWX - u.posx - u.view_offset_x, c_red,'\\'); + mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y, + x - i + VIEWX - u.posx - u.view_offset_x, c_red,'\\'); + mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y, + x + i + VIEWX - u.posx - u.view_offset_x, c_red, '/'); for (int j = 1 - i; j < 0 + i; j++) { - mvwputch(w_terrain, y - i + SEEY - u.posy - u.view_offset_y, - x + j + SEEX - u.posx - u.view_offset_x, c_red,'-'); - mvwputch(w_terrain, y + i + SEEY - u.posy - u.view_offset_y, - x + j + SEEX - u.posx - u.view_offset_x, c_red,'-'); - mvwputch(w_terrain, y + j + SEEY - u.posy - u.view_offset_y, - x - i + SEEX - u.posx - u.view_offset_x, c_red,'|'); - mvwputch(w_terrain, y + j + SEEY - u.posy - u.view_offset_y, - x + i + SEEX - u.posx - u.view_offset_x, c_red,'|'); + mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y, + x + j + VIEWX - u.posx - u.view_offset_x, c_red,'-'); + mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y, + x + j + VIEWX - u.posx - u.view_offset_x, c_red,'-'); + mvwputch(w_terrain, y + j + VIEWY - u.posy - u.view_offset_y, + x - i + VIEWX - u.posx - u.view_offset_x, c_red,'|'); + mvwputch(w_terrain, y + j + VIEWY - u.posy - u.view_offset_y, + x + i + VIEWX - u.posx - u.view_offset_x, c_red,'|'); } wrefresh(w_terrain); nanosleep(&ts, NULL); @@ -3824,8 +3835,8 @@ void game::explosion(int x, int y, int power, int shrapnel, bool fire) if (j > 0 && u_see(traj[j - 1].x, traj[j - 1].y, ijunk)) m.drawsq(w_terrain, u, traj[j - 1].x, traj[j - 1].y, false, true); if (u_see(traj[j].x, traj[j].y, ijunk)) { - mvwputch(w_terrain, traj[j].y + SEEY - u.posy - u.view_offset_y, - traj[j].x + SEEX - u.posx - u.view_offset_x, c_red, '`'); + mvwputch(w_terrain, traj[j].y + VIEWY - u.posy - u.view_offset_y, + traj[j].x + VIEWX - u.posx - u.view_offset_x, c_red, '`'); wrefresh(w_terrain); nanosleep(&ts, NULL); } @@ -3913,8 +3924,8 @@ void game::resonance_cascade(int x, int y) minglow = 0; if (maxglow > 0) u.add_disease(DI_TELEGLOW, rng(minglow, maxglow) * 100, this); - int startx = (x < 8 ? 0 : x - 8), endx = (x+8 >= SEEX*3 ? SEEX*3 - 1 : x + 8); - int starty = (y < 8 ? 0 : y - 8), endy = (y+8 >= SEEY*3 ? SEEY*3 - 1 : y + 8); + int startx = (x < 8 ? 0 : x - 8), endx = (x+8 >= VIEWX*3 ? VIEWX*3 - 1 : x + 8); + int starty = (y < 8 ? 0 : y - 8), endy = (y+8 >= VIEWY*3 ? VIEWY*3 - 1 : y + 8); for (int i = startx; i <= endx; i++) { for (int j = starty; j <= endy; j++) { switch (rng(1, 80)) { @@ -5233,7 +5244,7 @@ point game::look_around() int lx = u.posx + u.view_offset_x, ly = u.posy + u.view_offset_y; int mx, my, junk; char ch; - WINDOW* w_look = newwin(13, 48, 12, SEEX * 2 + 8); + WINDOW* w_look = newwin(13, 48, 12, VIEWX * 2 + 8); wborder(w_look, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); mvwprintz(w_look, 1, 1, c_white, "Looking Around"); @@ -5244,7 +5255,7 @@ point game::look_around() DebugLog() << __FUNCTION__ << "calling input() \n"; ch = input(); if (!u_see(lx, ly, junk)) - mvwputch(w_terrain, ly - u.posy + SEEY, lx - u.posx + SEEX, c_black, ' '); + mvwputch(w_terrain, ly - u.posy + VIEWY, lx - u.posx + VIEWX, c_black, ' '); get_direction(this, mx, my, ch); if (mx != -2 && my != -2) { // Directional key pressed lx += mx; @@ -5308,7 +5319,7 @@ point game::look_around() m.drawsq(w_terrain, u, lx, ly, true, true, lx, ly); } else if (lx == u.posx && ly == u.posy) { - mvwputch_inv(w_terrain, SEEX, SEEY, u.color(), '@'); + mvwputch_inv(w_terrain, VIEWX, VIEWY, u.color(), '@'); mvwprintw(w_look, 1, 1, "You (%s)", u.name.c_str()); if (veh) { mvwprintw(w_look, 3, 1, "There is a %s there. Parts:", veh->name.c_str()); @@ -5320,12 +5331,12 @@ point game::look_around() rl_dist(u.posx, u.posy, lx, ly) < u.unimpaired_range() && m.sees(u.posx, u.posy, lx, ly, u.unimpaired_range(), junk)) { if (u.has_disease(DI_BOOMERED)) - mvwputch_inv(w_terrain, ly - u.posy + SEEY, lx - u.posx + SEEX, c_pink, '#'); + mvwputch_inv(w_terrain, ly - u.posy + VIEWY, lx - u.posx + VIEWX, c_pink, '#'); else - mvwputch_inv(w_terrain, ly - u.posy + SEEY, lx - u.posx + SEEX, c_ltgray, '#'); + mvwputch_inv(w_terrain, ly - u.posy + VIEWY, lx - u.posx + VIEWX, c_ltgray, '#'); mvwprintw(w_look, 1, 1, "Bright light."); } else { - mvwputch(w_terrain, SEEY, SEEX, c_white, 'x'); + mvwputch(w_terrain, VIEWY, VIEWX, c_white, 'x'); mvwprintw(w_look, 1, 1, "Unseen."); } if (m.graffiti_at(lx, ly).contents) @@ -5423,11 +5434,13 @@ void game::list_items() switch(ch) { case KEY_UP: + case 'k': iActive--; if (iActive < 0) iActive = 0; break; case KEY_DOWN: + case 'j': iActive++; if (iActive >= iItemNum - iFilter) iActive = iItemNum - iFilter-1; @@ -5517,8 +5530,8 @@ void game::list_items() if (u_see(trajectory[i].x, trajectory[i].y, junk)) { char bullet = 'X'; - mvwputch(w_terrain, trajectory[i].y + SEEY - u.posy - u.view_offset_y, - trajectory[i].x + SEEX - u.posx - u.view_offset_x, c_white, bullet); + mvwputch(w_terrain, trajectory[i].y + VIEWY - u.posy - u.view_offset_y, + trajectory[i].x + VIEWX - u.posx - u.view_offset_x, c_white, bullet); } } @@ -5667,8 +5680,8 @@ void game::pickup(int posx, int posy, int min) return; } // Otherwise, we have 2 or more items and should list them, etc. - WINDOW* w_pickup = newwin(12, 48, 0, SEEX * 2 + 8); - WINDOW* w_item_info = newwin(12, 48, 12, SEEX * 2 + 8); + WINDOW* w_pickup = newwin(12, 48, 0, VIEWX * 2 + 8); + WINDOW* w_item_info = newwin(12, 48, 12, VIEWX * 2 + 8); int maxitems = 9; // Number of items to show at one time. std::vector here = from_veh? veh->parts[veh_part].items : m.i_at(posx, posy); bool getitem[here.size()]; @@ -6305,14 +6318,14 @@ void game::plthrow() int y1 = y + range; int junk; - for (int j = u.posx - SEEX; j <= u.posx + SEEX; j++) { - for (int k = u.posy - SEEY; k <= u.posy + SEEY; k++) { + for (int j = u.posx - VIEWX; j <= u.posx + VIEWX; j++) { + for (int k = u.posy - VIEWY; k <= u.posy + VIEWY; k++) { if (u_see(j, k, junk)) { if (k >= y0 && k <= y1 && j >= x0 && j <= x1) m.drawsq(w_terrain, u, j, k, false, true); else - mvwputch(w_terrain, k + SEEY - u.posy - u.view_offset_y, - j + SEEX - u.posx - u.view_offset_x, c_dkgray, '#'); + mvwputch(w_terrain, k + VIEWY - u.posy - u.view_offset_y, + j + VIEWX - u.posx - u.view_offset_x, c_dkgray, '#'); } } } @@ -6407,13 +6420,13 @@ void game::plfire(bool burst) int y0 = y - range; int x1 = x + range; int y1 = y + range; - for (int j = x - SEEX; j <= x + SEEX; j++) { - for (int k = y - SEEY; k <= y + SEEY; k++) { + for (int j = x - VIEWX; j <= x + VIEWX; j++) { + for (int k = y - VIEWY; k <= y + VIEWY; k++) { if (u_see(j, k, junk)) { if (k >= y0 && k <= y1 && j >= x0 && j <= x1) m.drawsq(w_terrain, u, j, k, false, true); else - mvwputch(w_terrain, k + SEEY - y, j + SEEX - x, c_dkgray, '#'); + mvwputch(w_terrain, k + VIEWY - y, j + VIEWX - x, c_dkgray, '#'); } } } diff --git a/game.h b/game.h index fbd94590f8c08..38d571722fe78 100644 --- a/game.h +++ b/game.h @@ -236,6 +236,11 @@ class game bool debugmon; bool no_npc; // Display data... TODO: Make this more portable? + int VIEWX; + int VIEWY; + int TERRAIN_WINDOW_WIDTH; + int TERRAIN_WINDOW_HEIGHT; + WINDOW *w_terrain; WINDOW *w_minimap; WINDOW *w_HP; diff --git a/item.cpp b/item.cpp index 0566142f33078..9a5c8935f63ce 100644 --- a/item.cpp +++ b/item.cpp @@ -4,14 +4,7 @@ #include "skill.h" #include "game.h" #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" bool is_flammable(material m); diff --git a/keypress.h b/keypress.h index 4c2519a072e02..c54777d155928 100644 --- a/keypress.h +++ b/keypress.h @@ -1,14 +1,8 @@ #ifndef _KEYPRESS_H_ #define _KEYPRESS_H_ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif #include +#include "cursesdef.h" class game; diff --git a/main.cpp b/main.cpp index e9ac131cd6a51..c6c9801630a54 100644 --- a/main.cpp +++ b/main.cpp @@ -4,14 +4,7 @@ * Who knows */ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - +#include "cursesdef.h" #include #include "game.h" #include "color.h" @@ -46,6 +39,7 @@ int main(int argc, char *argv[]) } // ncurses stuff + load_options(); // For getting size options initscr(); // Initialize ncurses noecho(); // Don't echo keypresses cbreak(); // C-style breaks (e.g. ^C to SIGINT) @@ -60,7 +54,6 @@ int main(int argc, char *argv[]) game *g = new game; MAPBUFFER.set_game(g); MAPBUFFER.load(); - load_options(); #if (!(defined _WIN32 || defined WINDOWS)) struct sigaction sigIntHandler; diff --git a/map.cpp b/map.cpp index 942430533fec0..11ee0d6493325 100644 --- a/map.cpp +++ b/map.cpp @@ -11,8 +11,6 @@ #include #include "debug.h" -#include "debug.h" - #define SGN(a) (((a)<0) ? -1 : 1) #define INBOUNDS(x, y) \ (x >= 0 && x < SEEX * my_MAPSIZE && y >= 0 && y < SEEY * my_MAPSIZE) @@ -2366,8 +2364,8 @@ void map::draw(game *g, WINDOW* w, const point center) char trans_buf[my_MAPSIZE*SEEX][my_MAPSIZE*SEEY]; memset(trans_buf, -1, sizeof(trans_buf)); - for (int realx = center.x - SEEX; realx <= center.x + SEEX; realx++) { - for (int realy = center.y - SEEY; realy <= center.y + SEEY; realy++) { + for (int realx = center.x - getmaxx(w)/2; realx <= center.x + getmaxx(w)/2; realx++) { + for (int realy = center.y - getmaxy(w)/2; realy <= center.y + getmaxy(w)/2; realy++) { const int dist = rl_dist(g->u.posx, g->u.posy, realx, realy); int sight_range = light_sight_range; @@ -2419,26 +2417,26 @@ void map::draw(game *g, WINDOW* w, const point center) (lit == LL_DARK || (u_sight_impaired && lit != LL_BRIGHT)))) { if (u_is_boomered) - mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_magenta, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_magenta, '#'); else - mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_dkgray, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_dkgray, '#'); } else if (dist > light_sight_range && u_sight_impaired && lit == LL_BRIGHT) { if (u_is_boomered) - mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_pink, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_pink, '#'); else - mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_ltgray, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_ltgray, '#'); } else if (dist <= u_clairvoyance || can_see) { drawsq(w, g->u, realx, realy, false, true, center.x, center.y, (dist > lowlight_sight_range && LL_LIT > lit) || (dist > sight_range && LL_LOW == lit), LL_BRIGHT == lit); } else { - mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_black,'#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_black,'#'); } } } - int atx = SEEX + g->u.posx - center.x, aty = SEEY + g->u.posy - center.y; - if (atx >= 0 && atx < SEEX * 2 + 1 && aty >= 0 && aty < SEEY * 2 + 1) + int atx = getmaxx(w)/2 + g->u.posx - center.x, aty = getmaxy(w)/2 + g->u.posy - center.y; + if (atx >= 0 && atx < g->TERRAIN_WINDOW_WIDTH && aty >= 0 && aty < g->TERRAIN_WINDOW_HEIGHT) mvwputch(w, aty, atx, g->u.color(), '@'); } @@ -2456,8 +2454,8 @@ void map::drawsq(WINDOW* w, player &u, const int x, const int y, const bool inve cx = u.posx; if (cy == -1) cy = u.posy; - const int k = x + SEEX - cx; - const int j = y + SEEY - cy; + const int k = x + getmaxx(w)/2 - cx; + const int j = y + getmaxy(w)/2 - cy; nc_color tercol; long sym = terlist[ter(x, y)].sym; bool hi = false; diff --git a/map.h b/map.h index ef1042379a19e..96e1dc32e6193 100644 --- a/map.h +++ b/map.h @@ -1,13 +1,7 @@ #ifndef _MAP_H_ #define _MAP_H_ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #include #include diff --git a/melee.cpp b/melee.cpp index c1b0b2ce14627..ad0dc2e88cced 100644 --- a/melee.cpp +++ b/melee.cpp @@ -5,13 +5,7 @@ #include #include -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" void hit_message(game *g, std::string subject, std::string verb, std::string target, int dam, bool crit); diff --git a/monmove.cpp b/monmove.cpp index 7a7d24cdccf79..85c51adacd008 100644 --- a/monmove.cpp +++ b/monmove.cpp @@ -7,14 +7,7 @@ #include "rng.h" #include "pldata.h" #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #ifndef SGN #define SGN(a) (((a)<0) ? -1 : 1) diff --git a/monster.cpp b/monster.cpp index 34d768ba3813f..31e9f41b79564 100644 --- a/monster.cpp +++ b/monster.cpp @@ -8,14 +8,7 @@ #include #include #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #define SGN(a) (((a)<0) ? -1 : 1) #define SQR(a) ((a)*(a)) @@ -221,8 +214,8 @@ char monster::symbol() void monster::draw(WINDOW *w, int plx, int ply, bool inv) { - int x = SEEX + posx - plx; - int y = SEEY + posy - ply; + int x = getmaxx(w)/2 + posx - plx; + int y = getmaxy(w)/2 + posy - ply; nc_color color = type->color; if (friendly != 0 && !inv) mvwputch_hi(w, y, x, color, type->sym); diff --git a/npc.cpp b/npc.cpp index 5f5fa1fe8d0c9..4c10e89c4182b 100644 --- a/npc.cpp +++ b/npc.cpp @@ -1795,8 +1795,8 @@ int npc::speed_estimate(int speed) void npc::draw(WINDOW* w, int ux, int uy, bool inv) { - int x = SEEX + posx - ux; - int y = SEEY + posy - uy; + int x = getmaxx(w)/2 + posx - ux; + int y = getmaxy(w)/2 + posy - uy; nc_color col = c_pink; if (attitude == NPCATT_KILL) col = c_red; diff --git a/options.cpp b/options.cpp index 4c2f35b90866e..e428964557e46 100644 --- a/options.cpp +++ b/options.cpp @@ -88,6 +88,10 @@ option_key lookup_option_key(std::string id) return OPT_DELETE_WORLD; if (id == "initial_points") return OPT_INITIAL_POINTS; + if (id == "viewport_x") + return OPT_VIEWPORT_X; + if (id == "viewport_y") + return OPT_VIEWPORT_Y; return OPT_NULL; } @@ -109,6 +113,8 @@ std::string option_string(option_key key) case OPT_SKILL_RUST: return "skill_rust"; case OPT_DELETE_WORLD: return "delete_world"; case OPT_INITIAL_POINTS: return "initial_points"; + case OPT_VIEWPORT_X: return "viewport_x"; + case OPT_VIEWPORT_Y: return "viewport_y"; default: return "unknown_option"; } return "unknown_option"; @@ -132,6 +138,8 @@ std::string option_desc(option_key key) case OPT_SKILL_RUST: return "Set the level of skill rust\n0 - vanilla Cataclysm\n1 - capped at skill levels\n2 - none at all"; case OPT_DELETE_WORLD: return "Delete saves upon player death\n0 - no\n1 - yes\n2 - query"; case OPT_INITIAL_POINTS: return "Initial points available on character generation.\nDefault is 6"; + case OPT_VIEWPORT_X: return "Set the expansion of the viewport along the X axis\nMust restart for changes to take effect\nDefault is 11"; + case OPT_VIEWPORT_Y: return "Set the expansion of the viewport along the Y axis\nMust restart for changes to take effect\nDefault is 11"; default: return " "; } return "Big ol Bug"; @@ -155,6 +163,8 @@ std::string option_name(option_key key) case OPT_SKILL_RUST: return "Skill Rust"; case OPT_DELETE_WORLD: return "Delete World"; case OPT_INITIAL_POINTS: return "Initial points"; + case OPT_VIEWPORT_X: return "Viewport width"; + case OPT_VIEWPORT_Y: return "Viewport height"; default: return "Unknown Option (BUG)"; } return "Big ol Bug"; @@ -167,7 +177,9 @@ bool option_is_bool(option_key id) case OPT_DROP_EMPTY: case OPT_DELETE_WORLD: case OPT_INITIAL_POINTS: - return false; + case OPT_VIEWPORT_X: + case OPT_VIEWPORT_Y: + return false; break; default: return true; @@ -191,6 +203,10 @@ char option_max_options(option_key id) case OPT_SKILL_RUST: ret = 3; break; + case OPT_VIEWPORT_X: + case OPT_VIEWPORT_Y: + ret = 61; // TODO Set up min/max values so weird numbers don't have to be used. + break; default: ret = 2; break; @@ -239,6 +255,10 @@ skill_rust 0\n\ delete_world 0\n\ # Initial points available in character generation\n\ initial_points 6\n\ +# How far to expand the viewport's width in each direction.\n\ +viewport_x 11\n\ +# Same as viewport_x, but in height.\n\ +viewport_y 11\n\ "; fout.close(); } diff --git a/options.h b/options.h index 233912a1d0f9b..e268dba8e7347 100644 --- a/options.h +++ b/options.h @@ -20,6 +20,8 @@ OPT_DROP_EMPTY, // auto drop empty containers after use OPT_SKILL_RUST, // level of skill rust OPT_DELETE_WORLD, OPT_INITIAL_POINTS, +OPT_VIEWPORT_X, +OPT_VIEWPORT_Y, NUM_OPTION_KEYS }; @@ -27,7 +29,16 @@ struct option_table { double options[NUM_OPTION_KEYS]; - option_table() { for (int i = 0; i < NUM_OPTION_KEYS; i++) options[i] = 0; }; + option_table() { + for (int i = 0; i < NUM_OPTION_KEYS; i++) { + if(i == OPT_VIEWPORT_X || i == OPT_VIEWPORT_Y) { + options[i] = 11; + } + else { + options[i] = 0; + } + } + }; double& operator[] (option_key i) { return options[i]; }; double& operator[] (int i) { return options[i]; }; diff --git a/output.cpp b/output.cpp index 797896e2eadd2..4fdd4e9152b04 100644 --- a/output.cpp +++ b/output.cpp @@ -1,12 +1,3 @@ - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #include #include #include @@ -21,6 +12,7 @@ #include "rng.h" #include "keypress.h" #include "options.h" +#include "cursesdef.h" #define LINE_XOXO 4194424 #define LINE_OXOX 4194417 diff --git a/overmap.cpp b/overmap.cpp index 10bb558013dda..20ce5096857ad 100644 --- a/overmap.cpp +++ b/overmap.cpp @@ -1,11 +1,3 @@ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #include #include #include @@ -22,6 +14,7 @@ #include #include #include "debug.h" +#include "cursesdef.h" #define STREETCHANCE 2 #define NUM_FOREST 250 diff --git a/overmap.h b/overmap.h index aa8fc7b14043a..222cec282e744 100644 --- a/overmap.h +++ b/overmap.h @@ -8,15 +8,7 @@ #include "output.h" #include #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - +#include "cursesdef.h" class npc; struct settlement; diff --git a/player.cpp b/player.cpp index b71160a218a0c..b3a0f913ce9a3 100644 --- a/player.cpp +++ b/player.cpp @@ -13,14 +13,7 @@ #include #include "name.h" - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" nc_color encumb_color(int level); bool activity_is_suspendable(activity_type type); diff --git a/ranged.cpp b/ranged.cpp index e752446a1d67f..0c17200eb46f0 100644 --- a/ranged.cpp +++ b/ranged.cpp @@ -283,8 +283,8 @@ void game::fire(player &p, int tarx, int tary, std::vector &trajectory, char bullet = '*'; if (effects & mfb(AMMO_FLAME)) bullet = '#'; - mvwputch(w_terrain, trajectory[i].y + SEEY - u.posy, - trajectory[i].x + SEEX - u.posx, c_red, bullet); + mvwputch(w_terrain, trajectory[i].y + VIEWY - u.posy, + trajectory[i].x + VIEWX - u.posx, c_red, bullet); wrefresh(w_terrain); if (&p == &u) nanosleep(&ts, NULL); @@ -547,7 +547,7 @@ std::vector game::target(int &x, int &y, int lowx, int lowy, int hix, } else target = -1; // No monsters in range, don't use target, reset to -1 - WINDOW* w_target = newwin(13, 48, 12, SEEX * 2 + 8); + WINDOW* w_target = newwin(13, 48, 12, TERRAIN_WINDOW_WIDTH + 7); wborder(w_target, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); if (!relevent) // currently targetting vehicle to refill with fuel @@ -602,8 +602,8 @@ std::vector game::target(int &x, int &y, int lowx, int lowy, int hix, m.drawsq(w_terrain, u, ret[i].x, ret[i].y, false, true, center.x, center.y); */ // Draw the player - int atx = SEEX + u.posx - center.x, aty = SEEY + u.posy - center.y; - if (atx >= 0 && atx < SEEX * 2 + 1 && aty >= 0 && aty < SEEY * 2 + 1) + int atx = VIEWX + u.posx - center.x, aty = VIEWY + u.posy - center.y; + if (atx >= 0 && atx < TERRAIN_WINDOW_WIDTH && aty >= 0 && aty < TERRAIN_WINDOW_HEIGHT) mvwputch(w_terrain, aty, atx, u.color(), '@'); if (m.sees(u.posx, u.posy, x, y, -1, tart)) {// Selects a valid line-of-sight @@ -635,9 +635,9 @@ std::vector game::target(int &x, int &y, int lowx, int lowy, int hix, if (mon_at(x, y) == -1) { mvwprintw(w_status, 0, 9, " "); if (snap_to_target) - mvwputch(w_terrain, SEEY, SEEX, c_red, '*'); + mvwputch(w_terrain, VIEWY, VIEWX, c_red, '*'); else - mvwputch(w_terrain, y + SEEY - u.posy, x + SEEX - u.posx, c_red, '*'); + mvwputch(w_terrain, y + VIEWY - u.posy, x + VIEWX - u.posx, c_red, '*'); } else if (u_see(&(z[mon_at(x, y)]), tart)) z[mon_at(x, y)].print_info(this, w_target); } @@ -656,7 +656,7 @@ std::vector game::target(int &x, int &y, int lowx, int lowy, int hix, else if (m.sees(u.posx, u.posy, x, y, -1, junk)) m.drawsq(w_terrain, u, x, y, false, true, center.x, center.y); else - mvwputch(w_terrain, SEEY, SEEX, c_black, 'X'); + mvwputch(w_terrain, VIEWY, VIEWX, c_black, 'X'); x += tarx; y += tary; if (x < lowx) diff --git a/tutorial.h b/tutorial.h index 9c4300ed76963..b105c1f83e7fd 100644 --- a/tutorial.h +++ b/tutorial.h @@ -116,7 +116,7 @@ another attack. Your dexterity and melee skills are used to determine\n\ whether an attack hits, while strength affects damage.", "\ Taking damage often causes pain. Small amounts of pain are tolerable, but as\n\ -it gets worse youre stats will drop and you will move much slower. To reduce\n\ +it gets worse you're stats will drop and you will move much slower. To reduce\n\ pain, take painkillers like codeine, or simply wait it out.", "\ When you kill a monster it will often leave behind a corpse. Corpses can be\n\ diff --git a/vehicle.cpp b/vehicle.cpp index c4f0b29e0f160..1d33b4a06dcaa 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -5,13 +5,7 @@ #include "item.h" #include #include -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" enum vehicle_controls { toggle_cruise_control,