Skip to content

Commit

Permalink
Merge pull request #1 from BurnZeZ/catacurses_fixup
Browse files Browse the repository at this point in the history
Catacurses fixup
  • Loading branch information
BurnZeZ authored and BurnZeZ committed Feb 24, 2013
2 parents ca1187f + ba34a04 commit 6e1a45d
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 122 deletions.
1 change: 1 addition & 0 deletions catacurse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions color.h
Original file line number Diff line number Diff line change
@@ -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 <curses.h>
#endif

#ifndef _COLOR_LIST_
#define _COLOR_LIST_

#include "cursesdef.h"

void init_colors();

enum col_attribute {
Expand Down
12 changes: 12 additions & 0 deletions cursesdef.h
Original file line number Diff line number Diff line change
@@ -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 <curses.h>
#endif

#endif // CURSES_DEF_H
10 changes: 8 additions & 2 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ game::game() :
init_autosave(); // Set up autosave
load_keyboard_settings();

VIEWX = OPTIONS[OPT_VIEWPORT_X] + 1;
VIEWY = OPTIONS[OPT_VIEWPORT_Y] + 1;
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.
Expand Down
9 changes: 1 addition & 8 deletions item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
#include "skill.h"
#include "game.h"
#include <sstream>

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

bool is_flammable(material m);

Expand Down
8 changes: 1 addition & 7 deletions keypress.h
Original file line number Diff line number Diff line change
@@ -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 <curses.h>
#endif

#include <string>
#include "cursesdef.h"

class game;

Expand Down
9 changes: 1 addition & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
* Who knows
*/

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif

#include "cursesdef.h"
#include <ctime>
#include "game.h"
#include "color.h"
Expand Down
20 changes: 10 additions & 10 deletions map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2364,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 - w->_maxx/2; realx <= center.x + g->VIEWX; realx++) {
for (int realy = center.y - w->_maxy/2; realy <= center.y + w->_maxy/2; 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;

Expand Down Expand Up @@ -2417,25 +2417,25 @@ 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+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_magenta, '#');
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_magenta, '#');
else
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - 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+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_pink, '#');
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_pink, '#');
else
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - 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+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_black,'#');
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_black,'#');
}
}
}
int atx = w->_maxx/2 + g->u.posx - center.x, aty = w->_maxy/2 + g->u.posy - center.y;
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(), '@');
}
Expand All @@ -2454,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 + w->_maxx/2 - cx;
const int j = y + w->_maxy/2 - 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;
Expand Down
8 changes: 1 addition & 7 deletions map.h
Original file line number Diff line number Diff line change
@@ -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 <curses.h>
#endif
#include "cursesdef.h"

#include <stdlib.h>
#include <vector>
Expand Down
8 changes: 1 addition & 7 deletions melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
#include <sstream>
#include <stdlib.h>

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

void hit_message(game *g, std::string subject, std::string verb,
std::string target, int dam, bool crit);
Expand Down
9 changes: 1 addition & 8 deletions monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
#include "rng.h"
#include "pldata.h"
#include <stdlib.h>

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

#ifndef SGN
#define SGN(a) (((a)<0) ? -1 : 1)
Expand Down
13 changes: 3 additions & 10 deletions monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
#include <sstream>
#include <fstream>
#include <stdlib.h>

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

#define SGN(a) (((a)<0) ? -1 : 1)
#define SQR(a) ((a)*(a))
Expand Down Expand Up @@ -221,8 +214,8 @@ char monster::symbol()

void monster::draw(WINDOW *w, int plx, int ply, bool inv)
{
int x = w->_maxx/2 + posx - plx;
int y = w->_maxy/2 + 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);
Expand Down
4 changes: 2 additions & 2 deletions npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,8 @@ int npc::speed_estimate(int speed)

void npc::draw(WINDOW* w, int ux, int uy, bool inv)
{
int x = w->_maxx/2 + posx - ux;
int y = w->_maxy/2 + 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;
Expand Down
2 changes: 1 addition & 1 deletion options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ char option_max_options(option_key id)
break;
case OPT_VIEWPORT_X:
case OPT_VIEWPORT_Y:
ret = 60;
ret = 61; // TODO Set up min/max values so weird numbers don't have to be used.
break;
default:
ret = 2;
Expand Down
11 changes: 10 additions & 1 deletion options.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,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]; };
Expand Down
10 changes: 1 addition & 9 deletions output.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif

#include <string>
#include <vector>
#include <cstdarg>
Expand All @@ -21,6 +12,7 @@
#include "rng.h"
#include "keypress.h"
#include "options.h"
#include "cursesdef.h"

#define LINE_XOXO 4194424
#define LINE_OXOX 4194417
Expand Down
9 changes: 1 addition & 8 deletions overmap.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif

#include <stdlib.h>
#include <time.h>
#include <math.h>
Expand All @@ -22,6 +14,7 @@
#include <cstring>
#include <ostream>
#include "debug.h"
#include "cursesdef.h"

#define STREETCHANCE 2
#define NUM_FOREST 250
Expand Down
10 changes: 1 addition & 9 deletions overmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
#include "output.h"
#include <vector>
#include <iosfwd>

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif

#include "cursesdef.h"

class npc;
struct settlement;
Expand Down
9 changes: 1 addition & 8 deletions player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
#include <stdlib.h>

#include "name.h"

#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

nc_color encumb_color(int level);
bool activity_is_suspendable(activity_type type);
Expand Down
2 changes: 1 addition & 1 deletion tutorial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
8 changes: 1 addition & 7 deletions vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
#include "item.h"
#include <sstream>
#include <stdlib.h>
#if (defined _WIN32 || defined WINDOWS)
#include "catacurse.h"
#elif (defined __CYGWIN__)
#include "ncurses/curses.h"
#else
#include <curses.h>
#endif
#include "cursesdef.h"

enum vehicle_controls {
toggle_cruise_control,
Expand Down

0 comments on commit 6e1a45d

Please sign in to comment.