From 06782215b22f4ae10f576ee2b9c2021cc129722c Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Fri, 3 Jun 2011 03:22:48 -0300 Subject: [PATCH] s/display/draw. --- Makefile | 4 ++-- src/{display.c => draw.c} | 8 +++++++- src/{display.h => draw.h} | 5 +++-- src/game.c | 8 +------- src/keyboard.c | 2 +- src/ttysolitaire.c | 3 ++- tests/{display_test.c => draw_test.c} | 4 ++-- tests/ttysolitaire_test.c | 2 +- tests/ttysolitaire_test.h | 2 +- 9 files changed, 20 insertions(+), 18 deletions(-) rename src/{display.c => draw.c} (91%) rename src/{display.h => draw.h} (83%) rename tests/{display_test.c => draw_test.c} (54%) diff --git a/Makefile b/Makefile index 951b9ca..e7d290c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ SRC_OBJECTS = ${SRC_DIR}/common.o \ ${SRC_DIR}/deck.o \ ${SRC_DIR}/cursor.o \ ${SRC_DIR}/keyboard.o \ - ${SRC_DIR}/display.o \ + ${SRC_DIR}/draw.o \ ${SRC_DIR}/game.o \ TESTS_EXECUTABLE = ttysolitaire_test @@ -24,7 +24,7 @@ TESTS_OBJECTS = ${TESTS_DIR}/frame_test.o \ ${TESTS_DIR}/deck_test.o \ ${TESTS_DIR}/cursor_test.o \ ${TESTS_DIR}/keyboard_test.o \ - ${TESTS_DIR}/display_test.o \ + ${TESTS_DIR}/draw_test.o \ ${TESTS_DIR}/game_test.o \ ${TESTS_DIR}/test_helper.o \ ${TESTS_DIR}/test_helper_test.o \ diff --git a/src/display.c b/src/draw.c similarity index 91% rename from src/display.c rename to src/draw.c index 8c308c5..02c699b 100644 --- a/src/display.c +++ b/src/draw.c @@ -3,7 +3,7 @@ #include #include -#include "display.h" +#include "draw.h" #include "deck.h" #include "game.h" @@ -12,6 +12,12 @@ static const char *card_values[13] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; +void draw_greeting() { + mvprintw(10, 27, "Welcome to tty-solitaire."); + mvprintw(11, 8, "Move with \u2190\u2191\u2192\u2193 or hjkl. Use the space bar to mark and move cards."); + mvprintw(12, 19, "Press the space bar to play or q to quit."); +} + static void draw_value(struct card *card) { mvwprintw(card->frame->window, 0, 0, card_values[card->value]); mvwprintw(card->frame->window, diff --git a/src/display.h b/src/draw.h similarity index 83% rename from src/display.h rename to src/draw.h index 2b304ce..8030735 100644 --- a/src/display.h +++ b/src/draw.h @@ -1,5 +1,5 @@ -#ifndef DISPLAY_H -#define DISPLAY_H +#ifndef TTY_SOLITAIRE_DRAW_H +#define TTY_SOLITAIRE_DRAW_H #include "card.h" #include "stack.h" @@ -11,6 +11,7 @@ #define WHITE_ON_BLUE 3 #define WHITE_ON_GREEN 4 +void draw_greeting(); void draw_card(struct card *); void draw_stack(struct stack *); void draw_deck(struct deck *); diff --git a/src/game.c b/src/game.c index 9cd1eaf..9e49592 100644 --- a/src/game.c +++ b/src/game.c @@ -9,7 +9,7 @@ #include "card.h" #include "stack.h" #include "deck.h" -#include "display.h" +#include "draw.h" #include "cursor.h" #include "curses.h" #include "common.h" @@ -160,12 +160,6 @@ static void deal_cards(struct deck *deck) { } } -void greet_player() { - mvprintw(10, 27, "Welcome to tty-solitaire."); - mvprintw(11, 8, "Move with \u2190\u2191\u2192\u2193 or hjkl. Use the space bar to mark and move cards."); - mvprintw(12, 19, "Press the space bar to play or q to quit."); -} - void initialize_game() { clear(); refresh(); diff --git a/src/keyboard.c b/src/keyboard.c index 2193efd..8a7b87f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5,7 +5,7 @@ #include "stack.h" #include "game.h" #include "cursor.h" -#include "display.h" +#include "draw.h" #include "curses.h" static struct stack **cursor_stack(struct cursor *cursor) { diff --git a/src/ttysolitaire.c b/src/ttysolitaire.c index ec06a60..0c2ab88 100644 --- a/src/ttysolitaire.c +++ b/src/ttysolitaire.c @@ -1,6 +1,7 @@ #include #include +#include "draw.h" #include "game.h" #include "keyboard.h" @@ -24,7 +25,7 @@ int main(int argc, const char *argv[]) { init_pair(3, COLOR_WHITE, COLOR_BLUE); init_pair(4, COLOR_WHITE, COLOR_GREEN); - greet_player(); + draw_greeting(); while (key != KEY_SPACEBAR) { switch (key = getch()) { diff --git a/tests/display_test.c b/tests/draw_test.c similarity index 54% rename from tests/display_test.c rename to tests/draw_test.c index f17d4e2..c778e1b 100644 --- a/tests/display_test.c +++ b/tests/draw_test.c @@ -1,7 +1,7 @@ #include #include -#include "../src/display.h" +#include "../src/draw.h" -void test_display() { +void test_draw() { assert(true); } diff --git a/tests/ttysolitaire_test.c b/tests/ttysolitaire_test.c index 17b1836..ca35929 100644 --- a/tests/ttysolitaire_test.c +++ b/tests/ttysolitaire_test.c @@ -8,7 +8,7 @@ int main(int argc, const char *argv[]) { test_card(); test_cursor(); test_deck(); - test_display(); + test_draw(); test_frame(); test_game(); test_keyboard(); diff --git a/tests/ttysolitaire_test.h b/tests/ttysolitaire_test.h index 231a7b4..1b174dd 100644 --- a/tests/ttysolitaire_test.h +++ b/tests/ttysolitaire_test.h @@ -4,7 +4,7 @@ void test_card(); void test_cursor(); void test_deck(); -void test_display(); +void test_draw(); void test_frame(); void test_game(); void test_keyboard();