Removed stupid curses files.
This commit is contained in:
parent
261950f133
commit
28ce3e07bd
2
Makefile
2
Makefile
@ -10,7 +10,6 @@ SRC_OBJECTS = ${SRC_DIR}/common.o \
|
||||
${SRC_DIR}/card.o \
|
||||
${SRC_DIR}/stack.o \
|
||||
${SRC_DIR}/deck.o \
|
||||
${SRC_DIR}/curses.o \
|
||||
${SRC_DIR}/cursor.o \
|
||||
${SRC_DIR}/keyboard.o \
|
||||
${SRC_DIR}/display.o \
|
||||
@ -23,7 +22,6 @@ TESTS_OBJECTS = ${TESTS_DIR}/frame_test.o \
|
||||
${TESTS_DIR}/card_test.o \
|
||||
${TESTS_DIR}/stack_test.o \
|
||||
${TESTS_DIR}/deck_test.o \
|
||||
${TESTS_DIR}/curses_test.o \
|
||||
${TESTS_DIR}/cursor_test.o \
|
||||
${TESTS_DIR}/keyboard_test.o \
|
||||
${TESTS_DIR}/display_test.o \
|
||||
|
31
src/curses.c
31
src/curses.c
@ -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();
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#ifndef TTY_SOLITAIRE_CURSES_H
|
||||
#define TTY_SOLITAIRE_CURSES_H
|
||||
|
||||
void initialize_curses();
|
||||
void end_curses();
|
||||
void clear_screen();
|
||||
|
||||
#endif
|
@ -21,7 +21,7 @@ static int foundation_begin_x(int x) {
|
||||
case 2: return(FOUNDATION_2_BEGIN_X); break;
|
||||
case 3: return(FOUNDATION_3_BEGIN_X); break;
|
||||
default:
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
assert(false && "invalid stack");
|
||||
}
|
||||
@ -37,7 +37,7 @@ static int maneuvre_begin_x(int x) {
|
||||
case 5: return(MANEUVRE_5_BEGIN_X); break;
|
||||
case 6: return(MANEUVRE_6_BEGIN_X); break;
|
||||
default:
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
assert(false && "maneuvre_begin_x called x < 0 || x > 6");
|
||||
}
|
||||
@ -167,7 +167,8 @@ void greet_player() {
|
||||
}
|
||||
|
||||
void initialize_game() {
|
||||
clear_screen();
|
||||
clear();
|
||||
refresh();
|
||||
|
||||
allocate_cursor(&cursor);
|
||||
initialize_cursor(cursor);
|
||||
|
@ -19,7 +19,7 @@ static struct stack **cursor_stack(struct cursor *cursor) {
|
||||
case CURSOR_FOUNDATION_3_X: return(&(deck->foundation[3]));
|
||||
case CURSOR_INVALID_SPOT_X: return(NULL);
|
||||
default:
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
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_6_X: return(&(deck->maneuvre[6]));
|
||||
default:
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
assert(false && "invalid stack");
|
||||
}
|
||||
@ -121,7 +121,7 @@ static void handle_card_movement(struct cursor *cursor) {
|
||||
return;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <ncurses.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "game.h"
|
||||
#include "keyboard.h"
|
||||
#include "curses.h"
|
||||
|
||||
const char *program_name;
|
||||
|
||||
@ -11,7 +10,20 @@ int main(int argc, const char *argv[]) {
|
||||
program_name = *argv;
|
||||
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();
|
||||
|
||||
while (key != KEY_SPACEBAR) {
|
||||
@ -21,16 +33,16 @@ int main(int argc, const char *argv[]) {
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
end_curses();
|
||||
exit(0);
|
||||
endwin();
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if ((key = getch()) == 'q' || key == 'Q') {
|
||||
end_curses();
|
||||
endwin();
|
||||
end_game();
|
||||
exit(0);
|
||||
return(0);
|
||||
} else {
|
||||
handle_keyboard_event(key);
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include "../src/curses.h"
|
||||
|
||||
void test_curses() {
|
||||
assert(true);
|
||||
}
|
@ -13,7 +13,6 @@ int main(int argc, const char *argv[]) {
|
||||
test_game();
|
||||
test_keyboard();
|
||||
test_stack();
|
||||
test_curses();
|
||||
test_test_helper();
|
||||
|
||||
return(0);
|
||||
|
@ -9,7 +9,6 @@ void test_frame();
|
||||
void test_game();
|
||||
void test_keyboard();
|
||||
void test_stack();
|
||||
void test_curses();
|
||||
void test_test_helper();
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user