Removed stupid curses files.

This commit is contained in:
Murilo Pereira 2011-06-03 03:09:14 -03:00
parent 261950f133
commit 28ce3e07bd
9 changed files with 26 additions and 63 deletions

View File

@ -10,7 +10,6 @@ SRC_OBJECTS = ${SRC_DIR}/common.o \
${SRC_DIR}/card.o \ ${SRC_DIR}/card.o \
${SRC_DIR}/stack.o \ ${SRC_DIR}/stack.o \
${SRC_DIR}/deck.o \ ${SRC_DIR}/deck.o \
${SRC_DIR}/curses.o \
${SRC_DIR}/cursor.o \ ${SRC_DIR}/cursor.o \
${SRC_DIR}/keyboard.o \ ${SRC_DIR}/keyboard.o \
${SRC_DIR}/display.o \ ${SRC_DIR}/display.o \
@ -23,7 +22,6 @@ TESTS_OBJECTS = ${TESTS_DIR}/frame_test.o \
${TESTS_DIR}/card_test.o \ ${TESTS_DIR}/card_test.o \
${TESTS_DIR}/stack_test.o \ ${TESTS_DIR}/stack_test.o \
${TESTS_DIR}/deck_test.o \ ${TESTS_DIR}/deck_test.o \
${TESTS_DIR}/curses_test.o \
${TESTS_DIR}/cursor_test.o \ ${TESTS_DIR}/cursor_test.o \
${TESTS_DIR}/keyboard_test.o \ ${TESTS_DIR}/keyboard_test.o \
${TESTS_DIR}/display_test.o \ ${TESTS_DIR}/display_test.o \

View File

@ -1,31 +0,0 @@
#include <stdio.h>
#include <ncurses.h>
#include <locale.h>
#include "curses.h"
void initialize_curses() {
setlocale(LC_ALL, "en_US.utf-8"); /* Support unicode characters. */
initscr();
raw(); /* Disable line buffers. */
noecho();
keypad(stdscr, TRUE); /* Enable arrow keys. */
start_color(); /* I want colors. */
curs_set(FALSE); /* Invisible cursor. */
set_escdelay(0);
assume_default_colors(COLOR_WHITE, COLOR_GREEN);
init_pair(1, COLOR_BLACK, COLOR_WHITE);
init_pair(2, COLOR_RED, COLOR_WHITE);
init_pair(3, COLOR_WHITE, COLOR_BLUE);
init_pair(4, COLOR_WHITE, COLOR_GREEN);
}
void end_curses() {
endwin();
puts("Game finished.");
}
void clear_screen() {
clear();
refresh();
}

View File

@ -1,8 +0,0 @@
#ifndef TTY_SOLITAIRE_CURSES_H
#define TTY_SOLITAIRE_CURSES_H
void initialize_curses();
void end_curses();
void clear_screen();
#endif

View File

@ -21,7 +21,7 @@ static int foundation_begin_x(int x) {
case 2: return(FOUNDATION_2_BEGIN_X); break; case 2: return(FOUNDATION_2_BEGIN_X); break;
case 3: return(FOUNDATION_3_BEGIN_X); break; case 3: return(FOUNDATION_3_BEGIN_X); break;
default: default:
end_curses(); endwin();
end_game(); end_game();
assert(false && "invalid stack"); assert(false && "invalid stack");
} }
@ -37,7 +37,7 @@ static int maneuvre_begin_x(int x) {
case 5: return(MANEUVRE_5_BEGIN_X); break; case 5: return(MANEUVRE_5_BEGIN_X); break;
case 6: return(MANEUVRE_6_BEGIN_X); break; case 6: return(MANEUVRE_6_BEGIN_X); break;
default: default:
end_curses(); endwin();
end_game(); end_game();
assert(false && "maneuvre_begin_x called x < 0 || x > 6"); assert(false && "maneuvre_begin_x called x < 0 || x > 6");
} }
@ -167,7 +167,8 @@ void greet_player() {
} }
void initialize_game() { void initialize_game() {
clear_screen(); clear();
refresh();
allocate_cursor(&cursor); allocate_cursor(&cursor);
initialize_cursor(cursor); initialize_cursor(cursor);

View File

@ -19,7 +19,7 @@ static struct stack **cursor_stack(struct cursor *cursor) {
case CURSOR_FOUNDATION_3_X: return(&(deck->foundation[3])); case CURSOR_FOUNDATION_3_X: return(&(deck->foundation[3]));
case CURSOR_INVALID_SPOT_X: return(NULL); case CURSOR_INVALID_SPOT_X: return(NULL);
default: default:
end_curses(); endwin();
end_game(); end_game();
assert(false && "invalid stack"); assert(false && "invalid stack");
} }
@ -33,7 +33,7 @@ static struct stack **cursor_stack(struct cursor *cursor) {
case CURSOR_MANEUVRE_5_X: return(&(deck->maneuvre[5])); case CURSOR_MANEUVRE_5_X: return(&(deck->maneuvre[5]));
case CURSOR_MANEUVRE_6_X: return(&(deck->maneuvre[6])); case CURSOR_MANEUVRE_6_X: return(&(deck->maneuvre[6]));
default: default:
end_curses(); endwin();
end_game(); end_game();
assert(false && "invalid stack"); assert(false && "invalid stack");
} }
@ -121,7 +121,7 @@ static void handle_card_movement(struct cursor *cursor) {
return; return;
case 'q': case 'q':
case 'Q': case 'Q':
end_curses(); endwin();
end_game(); end_game();
exit(0); exit(0);
} }

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <ncurses.h> #include <ncurses.h>
#include <locale.h>
#include "game.h" #include "game.h"
#include "keyboard.h" #include "keyboard.h"
#include "curses.h"
const char *program_name; const char *program_name;
@ -11,7 +10,20 @@ int main(int argc, const char *argv[]) {
program_name = *argv; program_name = *argv;
int key; int key;
initialize_curses(); setlocale(LC_ALL, "en_US.utf-8"); /* Support unicode characters. */
initscr();
raw(); /* Disable line buffers. */
noecho();
keypad(stdscr, TRUE); /* Enable arrow keys. */
start_color(); /* I want colors. */
curs_set(FALSE); /* Invisible cursor. */
set_escdelay(0);
assume_default_colors(COLOR_WHITE, COLOR_GREEN);
init_pair(1, COLOR_BLACK, COLOR_WHITE);
init_pair(2, COLOR_RED, COLOR_WHITE);
init_pair(3, COLOR_WHITE, COLOR_BLUE);
init_pair(4, COLOR_WHITE, COLOR_GREEN);
greet_player(); greet_player();
while (key != KEY_SPACEBAR) { while (key != KEY_SPACEBAR) {
@ -21,16 +33,16 @@ int main(int argc, const char *argv[]) {
break; break;
case 'q': case 'q':
case 'Q': case 'Q':
end_curses(); endwin();
exit(0); return(0);
} }
} }
while (1) { while (1) {
if ((key = getch()) == 'q' || key == 'Q') { if ((key = getch()) == 'q' || key == 'Q') {
end_curses(); endwin();
end_game(); end_game();
exit(0); return(0);
} else { } else {
handle_keyboard_event(key); handle_keyboard_event(key);
} }

View File

@ -1,7 +0,0 @@
#include <assert.h>
#include <stdbool.h>
#include "../src/curses.h"
void test_curses() {
assert(true);
}

View File

@ -13,7 +13,6 @@ int main(int argc, const char *argv[]) {
test_game(); test_game();
test_keyboard(); test_keyboard();
test_stack(); test_stack();
test_curses();
test_test_helper(); test_test_helper();
return(0); return(0);

View File

@ -9,7 +9,6 @@ void test_frame();
void test_game(); void test_game();
void test_keyboard(); void test_keyboard();
void test_stack(); void test_stack();
void test_curses();
void test_test_helper(); void test_test_helper();
#endif #endif