|
From: <sch...@us...> - 2008-12-22 23:22:32
|
Revision: 61
http://deraciel.svn.sourceforge.net/deraciel/?rev=61&view=rev
Author: schnippi001
Date: 2008-12-22 22:09:46 +0000 (Mon, 22 Dec 2008)
Log Message:
-----------
Last checkin failed, this will fix the build
Added Paths:
-----------
trunk/CMakeLists.txt
trunk/GUI.h
trunk/KeyboardReader.cpp
trunk/KeyboardReader.h
trunk/Map.h
trunk/MapWindow.h
trunk/NCursesGUI.cpp
trunk/NCursesGUI.h
trunk/NCursesMapWindow.cpp
trunk/NCursesMapWindow.h
trunk/NCursesStatusWindow.cpp
trunk/NCursesStatusWindow.h
trunk/NCursesTextWindow.cpp
trunk/NCursesTextWindow.h
trunk/StatusWindow.h
trunk/TextWindow.h
trunk/_cmake-distclean.bash
trunk/main.cpp
Removed Paths:
-------------
trunk/CMakeLists.txt
trunk/_cmake-distclean.bash
trunk/char.h
trunk/cpp/
trunk/inventory.c
trunk/inventory.h
trunk/keyboard.c
trunk/keyboard.h
trunk/main.c
trunk/map_window.c
trunk/map_window.h
trunk/obj_types.c
trunk/obj_types.h
trunk/object.c
trunk/object.h
trunk/random.c
trunk/random.h
trunk/stat.h
trunk/status_window.c
trunk/status_window.h
trunk/text_window.c
trunk/text_window.h
trunk/util.h
Deleted: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/CMakeLists.txt 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,26 +0,0 @@
-cmake_minimum_required(VERSION 2.6)
-
-project(deraciel)
-SET(CMAKE_C_FLAGS "-Wall -Werror -std=c99")
-
-# requirements
-find_library( NCURSES_LIBRARY ncurses )
-if( NCURSES_LIBRARY )
- message( STATUS "ncurses library found: ${NCURSES_LIBRARY}" )
-else( NCURSES_LIBRARY )
- message( FATAL_ERROR "ncurses library not found". )
-endif( NCURSES_LIBRARY )
-
-include_directories(
- ${NCURSES_INCLUDE_DIRS}
-)
-link_directories(
- ${NCURSES_LIBRARY_DIRS}
-)
-
-# build
-file(GLOB DERACIEL_SOURCES *.c)
-add_executable(deraciel ${DERACIEL_SOURCES})
-target_link_libraries(deraciel
- ${NCURSES_LIBRARY}
-)
Copied: trunk/CMakeLists.txt (from rev 59, trunk/cpp/CMakeLists.txt)
===================================================================
--- trunk/CMakeLists.txt (rev 0)
+++ trunk/CMakeLists.txt 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(deraciel)
+SET(CMAKE_CXX_FLAGS "-Wall -Werror -g")
+
+# requirements
+find_library( NCURSES_LIBRARY ncurses )
+if( NCURSES_LIBRARY )
+ message( STATUS "ncurses library found: ${NCURSES_LIBRARY}" )
+else( NCURSES_LIBRARY )
+ message( FATAL_ERROR "ncurses library not found". )
+endif( NCURSES_LIBRARY )
+
+include_directories(
+ ${NCURSES_INCLUDE_DIRS}
+)
+link_directories(
+ ${NCURSES_LIBRARY_DIRS}
+)
+
+# build
+file(GLOB DERACIEL_SOURCES *.cpp)
+add_executable(deraciel ${DERACIEL_SOURCES})
+target_link_libraries(deraciel
+ ${NCURSES_LIBRARY}
+)
Added: trunk/GUI.h
===================================================================
--- trunk/GUI.h (rev 0)
+++ trunk/GUI.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,26 @@
+/*
+ * File: GUI.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 22:50
+ */
+
+#ifndef _GUI_H
+#define _GUI_H
+
+#include "TextWindow.h"
+#include "MapWindow.h"
+#include "StatusWindow.h"
+
+class GUI {
+public:
+ virtual void initialize() = 0;
+ virtual void finalize() = 0;
+ virtual TextWindow *getTextWindow() = 0;
+ virtual MapWindow *getMapWindow() = 0;
+ virtual StatusWindow *getStatusWindow() = 0;
+};
+
+
+#endif /* _GUI_H */
+
Property changes on: trunk/GUI.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Copied: trunk/KeyboardReader.cpp (from rev 59, trunk/cpp/KeyboardReader.cpp)
===================================================================
--- trunk/KeyboardReader.cpp (rev 0)
+++ trunk/KeyboardReader.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,48 @@
+#include "KeyboardReader.h"
+
+#include <iostream>
+#include <ncurses.h>
+
+
+using namespace std;
+
+
+
+bool KeyboardReader::keyboardReaderActive = true;
+void (*KeyboardReader::keyboardHandler)(const int key) = NULL;
+
+void KeyboardReader::setKeyboardHandler(void (*handler)(const int key)) {
+ /* If the specified keyboard handler is not NULL set it as active keyboard handling function */
+ if (handler) {
+ keyboardHandler = handler;
+ } else {
+ cerr << "ERROR: Specified keyboard handler was NULL!" << endl;
+ }
+}
+
+
+
+void KeyboardReader::startLoop() {
+ /* This variable will hold the keycode of pressed key */
+ int key;
+
+ /* Run an infinite loop */
+ while(keyboardReaderActive) {
+ /* Fetch a key from keyboard buffer */
+ key = getch();
+
+ /* If handler callback is specified, delegate the previously
+ fetched key to it, else throw an error message */
+ if (keyboardHandler) {
+ keyboardHandler(key);
+ } else {
+ cerr << "ERROR: Handler callback was NULL!" << endl;
+ }
+ }
+}
+
+
+
+void KeyboardReader::stop() {
+ keyboardReaderActive = false;
+}
Property changes on: trunk/KeyboardReader.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: trunk/KeyboardReader.h (from rev 59, trunk/cpp/KeyboardReader.h)
===================================================================
--- trunk/KeyboardReader.h (rev 0)
+++ trunk/KeyboardReader.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,11 @@
+
+class KeyboardReader {
+public:
+ static void setKeyboardHandler(void (*handler)(const int key));
+ static void startLoop();
+ static void stop();
+
+private:
+ static void (*keyboardHandler)(const int key);
+ static bool keyboardReaderActive;
+};
\ No newline at end of file
Property changes on: trunk/KeyboardReader.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Added: trunk/Map.h
===================================================================
--- trunk/Map.h (rev 0)
+++ trunk/Map.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,16 @@
+/*
+ * File: Map.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 22:48
+ */
+
+#ifndef _MAP_H
+#define _MAP_H
+
+class Map {
+
+};
+
+#endif /* _MAP_H */
+
Property changes on: trunk/Map.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Copied: trunk/MapWindow.h (from rev 59, trunk/cpp/MapWindow.h)
===================================================================
--- trunk/MapWindow.h (rev 0)
+++ trunk/MapWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,20 @@
+/*
+ * File: MapWindow.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 20:47
+ */
+
+#ifndef _MAPWINDOW_H
+#define _MAPWINDOW_H
+
+#include "Map.h"
+
+class MapWindow {
+public:
+ virtual void resize() = 0;
+ virtual void displayMap(const Map *map) = 0;
+};
+
+#endif /* _MAPWINDOW_H */
+
Property changes on: trunk/MapWindow.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Added: trunk/NCursesGUI.cpp
===================================================================
--- trunk/NCursesGUI.cpp (rev 0)
+++ trunk/NCursesGUI.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,48 @@
+#include "NCursesGUI.h"
+#include <ncurses.h>
+#include "NCursesTextWindow.h"
+#include "NCursesMapWindow.h"
+#include "NCursesStatusWindow.h"
+
+void NCursesGUI::initialize() {
+ initscr(); /* initialize the curses library */
+ keypad(stdscr, TRUE); /* enable keyboard mapping */
+ nonl(); /* tell curses not to do NL->CR/NL on output */
+ //cbreak(); /* take input chars one at a time, no wait for \n */
+ noecho(); /* don't echo input */
+
+ curs_set(0); /* Hide the cursor */
+
+ start_color();
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ init_pair(2, COLOR_BLACK, COLOR_YELLOW);
+ init_pair(3, COLOR_WHITE, COLOR_RED);
+ init_pair(4, COLOR_WHITE, COLOR_GREEN);
+
+ clear();
+ refresh();
+
+ textWindow = new NCursesTextWindow();
+ mapWindow = new NCursesMapWindow();
+ statusWindow = new NCursesStatusWindow();
+}
+
+void NCursesGUI::finalize() {
+ delete textWindow;
+ delete mapWindow;
+ delete statusWindow;
+
+ endwin();
+}
+
+TextWindow *NCursesGUI::getTextWindow() {
+ return textWindow;
+}
+
+MapWindow *NCursesGUI::getMapWindow() {
+ return mapWindow;
+}
+
+StatusWindow *NCursesGUI::getStatusWindow() {
+ return statusWindow;
+}
Property changes on: trunk/NCursesGUI.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: trunk/NCursesGUI.h
===================================================================
--- trunk/NCursesGUI.h (rev 0)
+++ trunk/NCursesGUI.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,27 @@
+/*
+ * File: NCursesGUI.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 22:48
+ */
+
+#ifndef _NCURSESGUI_H
+#define _NCURSESGUI_H
+
+#include "GUI.h"
+
+class NCursesGUI : public GUI {
+public:
+ void initialize();
+ void finalize();
+ TextWindow *getTextWindow();
+ MapWindow *getMapWindow();
+ StatusWindow *getStatusWindow();
+
+private:
+ TextWindow *textWindow;
+ MapWindow *mapWindow;
+ StatusWindow *statusWindow;
+};
+
+#endif /* _NCURSESGUI_H */
Property changes on: trunk/NCursesGUI.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Copied: trunk/NCursesMapWindow.cpp (from rev 59, trunk/cpp/NCursesMapWindow.cpp)
===================================================================
--- trunk/NCursesMapWindow.cpp (rev 0)
+++ trunk/NCursesMapWindow.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,38 @@
+#include "NCursesMapWindow.h"
+
+#include <iostream>
+#include <string>
+#include <ncurses.h>
+
+using namespace std;
+
+NCursesMapWindow::NCursesMapWindow() {
+ window = newwin(maxHeight, maxWidth, 2, 0);
+
+ if (!window) {
+ cerr << "Error: Map window creation failed!" << endl;
+ return;
+ }
+
+ wattron(window, COLOR_PAIR(4));
+ wbkgd(window, COLOR_PAIR(4));
+
+ wrefresh(window);
+}
+
+NCursesMapWindow::~NCursesMapWindow() {
+ /* Free resources consumed by windows */
+ delwin(window);
+}
+
+void NCursesMapWindow::resize() {
+ /* Reallocate storage for resized text window */
+ wresize(window, maxHeight, maxWidth);
+}
+
+void NCursesMapWindow::displayMap(const Map *map) {
+ /* Set cursor to first position (upper left) in map window */
+ wmove(window, 0, 0);
+
+ wnoutrefresh(window);
+}
Copied: trunk/NCursesMapWindow.h (from rev 59, trunk/cpp/NCursesMapWindow.h)
===================================================================
--- trunk/NCursesMapWindow.h (rev 0)
+++ trunk/NCursesMapWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,18 @@
+#include <string>
+#include <ncurses.h>
+
+#include "MapWindow.h"
+
+class NCursesMapWindow : public MapWindow {
+public:
+ NCursesMapWindow();
+ ~NCursesMapWindow();
+ void resize();
+ void displayMap(const Map *map);
+
+private:
+ WINDOW *window; // Window handle
+ static const unsigned int maxWidth = 80; // Maximum window width
+ static const unsigned int maxHeight = 20; // Maximum window height
+ static const unsigned int screensize = maxWidth * maxHeight;
+};
Copied: trunk/NCursesStatusWindow.cpp (from rev 59, trunk/cpp/NCursesStatusWindow.cpp)
===================================================================
--- trunk/NCursesStatusWindow.cpp (rev 0)
+++ trunk/NCursesStatusWindow.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,59 @@
+#include "NCursesStatusWindow.h"
+
+#include <iostream>
+#include <string>
+#include <ncurses.h>
+
+using namespace std;
+
+NCursesStatusWindow::NCursesStatusWindow() {
+ window = newwin(maxHeight, maxWidth, 25 - maxHeight, 0);
+
+ if (!window) {
+ cerr << "Error: Status window creation failed!" << endl;
+ return;
+ }
+
+ wattron(window, COLOR_PAIR(3));
+ wbkgd(window, COLOR_PAIR(3));
+
+ if (borderIsDrawn) {
+ /* Redraw border with new dimensions */
+ drawBorder();
+ }
+
+ wrefresh(window);
+}
+
+NCursesStatusWindow::~NCursesStatusWindow() {
+ /* Free resources consumed by window */
+ delwin(window);
+}
+
+void NCursesStatusWindow::resize() {
+ /* Reallocate storage for resized text window */
+ wresize(window, maxHeight, maxWidth);
+}
+
+void NCursesStatusWindow::displayStatus() {
+ if (borderIsDrawn) {
+ /* Redraw border */
+ drawBorder();
+ }
+
+ mvwprintw(window, 1, 2, "$:%d HP:%d(%d) MP:%d(%d) St:%2d Dx:%2d Co:%2d Wi:%2d Wp:%2d Ch:%2d",
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+ mvwprintw(window, 2, 2, "%s Xp:%2d/%d T:%d S:%d",
+ "Deraciel", 0, 1, 2, 3);
+
+ wnoutrefresh(window);
+}
+
+/*
+ Private member function declarations
+ */
+
+void NCursesStatusWindow::drawBorder() {
+ wborder(window, 0, 0, 0, ' ', '/', '\\', ACS_VLINE, ACS_VLINE);
+}
Copied: trunk/NCursesStatusWindow.h (from rev 59, trunk/cpp/NCursesStatusWindow.h)
===================================================================
--- trunk/NCursesStatusWindow.h (rev 0)
+++ trunk/NCursesStatusWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,19 @@
+#include <string>
+#include <ncurses.h>
+
+#include "StatusWindow.h"
+
+class NCursesStatusWindow : public StatusWindow {
+public:
+ NCursesStatusWindow();
+ ~NCursesStatusWindow();
+ void resize();
+ void displayStatus();
+
+private:
+ WINDOW *window; // Window handle
+ static const unsigned int maxWidth = 80; // Maximum window width
+ static const unsigned int maxHeight = 3; // Maximum window height
+ static const bool borderIsDrawn = true; // Draw window borders by default
+ void drawBorder();
+};
\ No newline at end of file
Copied: trunk/NCursesTextWindow.cpp (from rev 59, trunk/cpp/NCursesTextWindow.cpp)
===================================================================
--- trunk/NCursesTextWindow.cpp (rev 0)
+++ trunk/NCursesTextWindow.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,68 @@
+#include "NCursesTextWindow.h"
+
+#include <iostream>
+#include <string>
+#include <ncurses.h>
+
+using namespace std;
+
+NCursesTextWindow::NCursesTextWindow() {
+ borderWindow = newwin(maxHeight, maxWidth, 0, 0);
+ textWindow = newwin(maxHeight - 1, maxWidth - 2, 0, 1);
+
+ if (!borderWindow || !textWindow) {
+ cerr << "Error: Text window creation failed!" << endl;
+ return;
+ }
+
+ wattron(borderWindow, COLOR_PAIR(1));
+ wbkgd(textWindow, COLOR_PAIR(1));
+
+ if (borderIsDrawn) {
+ /* Redraw border with new dimensions */
+ drawBorder();
+ }
+
+ wrefresh(borderWindow);
+ wrefresh(textWindow);
+}
+
+NCursesTextWindow::~NCursesTextWindow() {
+ /* Free resources consumed by windows */
+ delwin(borderWindow);
+ delwin(textWindow);
+}
+
+void NCursesTextWindow::resize() {
+ /* Reallocate storage for resized text window */
+ wresize(borderWindow, maxHeight, maxWidth);
+ wresize(textWindow, maxHeight - 1, maxWidth);
+}
+
+void NCursesTextWindow::clear() {
+ if (borderIsDrawn) {
+ /* Redraw border with new dimensions */
+ drawBorder();
+ }
+}
+
+void NCursesTextWindow::displayString(const string string) {
+ if (borderIsDrawn) {
+ /* Redraw border*/
+ drawBorder();
+ }
+
+ wmove(textWindow, 0, 0);
+ wprintw(textWindow, string.c_str());
+
+ wnoutrefresh(borderWindow);
+ wnoutrefresh(textWindow);
+}
+
+/*
+ Private member function declarations
+ */
+
+void NCursesTextWindow::drawBorder() {
+ wborder(borderWindow, 0, 0, ' ', 0, ACS_VLINE, ACS_VLINE, '\\', '/');
+}
\ No newline at end of file
Copied: trunk/NCursesTextWindow.h (from rev 59, trunk/cpp/NCursesTextWindow.h)
===================================================================
--- trunk/NCursesTextWindow.h (rev 0)
+++ trunk/NCursesTextWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,21 @@
+#include <string>
+#include <ncurses.h>
+
+#include "TextWindow.h"
+
+class NCursesTextWindow : public TextWindow {
+public:
+ NCursesTextWindow();
+ ~NCursesTextWindow();
+ void resize();
+ void clear();
+ void displayString(const std::string string);
+
+private:
+ WINDOW *borderWindow; // Window handle
+ WINDOW *textWindow; // Window handle
+ static const unsigned int maxWidth = 80; // Maximum window width
+ static const unsigned int maxHeight = 2; // Maximum window height
+ static const bool borderIsDrawn = true; // Draw window borders by default
+ void drawBorder();
+};
Copied: trunk/StatusWindow.h (from rev 59, trunk/cpp/StatusWindow.h)
===================================================================
--- trunk/StatusWindow.h (rev 0)
+++ trunk/StatusWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,19 @@
+/*
+ * File: StatusWindow.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 20:47
+ */
+
+#ifndef _STATUSWINDOW_H
+#define _STATUSWINDOW_H
+
+class StatusWindow {
+public:
+ virtual void resize() = 0;
+ virtual void displayStatus() = 0;
+};
+
+
+#endif /* _STATUSWINDOW_H */
+
Property changes on: trunk/StatusWindow.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: trunk/TextWindow.h (from rev 59, trunk/cpp/TextWindow.h)
===================================================================
--- trunk/TextWindow.h (rev 0)
+++ trunk/TextWindow.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,21 @@
+/*
+ * File: TextWindow.h
+ * Author: schnippi
+ *
+ * Created on 22. Dezember 2008, 04:28
+ */
+
+#ifndef _DERACIEL_TEXTWINDOW_H
+#define _DERACIEL_TEXTWINDOW_H
+
+#include <string>
+
+class TextWindow {
+public:
+ virtual void resize() = 0;
+ virtual void clear() = 0;
+ virtual void displayString(const std::string string) = 0;
+};
+
+
+#endif /* _DERACIEL_TEXTWINDOW_H */
Property changes on: trunk/TextWindow.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/_cmake-distclean.bash
===================================================================
--- trunk/_cmake-distclean.bash 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/_cmake-distclean.bash 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,27 +0,0 @@
-#!/bin/bash
-find . -name "*.cmake" |while read f; do
- echo "rm ${f}"
- rm "${f}"
-done
-
-find . -name "CMakeCache.txt" |while read f; do
- echo "rm ${f}"
- rm "${f}"
-done
-
-find . -name "Makefile" |while read f; do
- echo "rm ${f}"
- rm "${f}"
-done
-
-find . -type d -name CMakeFiles |while read d; do
- echo "rm -r ${d}"
- rm -r "${d}"
-done
-
-find . -type d -name CMakeTmp |while read d; do
- echo "rm -r ${d}"
- rm -r "${d}"
-done
-
-
Copied: trunk/_cmake-distclean.bash (from rev 59, trunk/cpp/_cmake-distclean.bash)
===================================================================
--- trunk/_cmake-distclean.bash (rev 0)
+++ trunk/_cmake-distclean.bash 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,27 @@
+#!/bin/bash
+find . -name "*.cmake" |while read f; do
+ echo "rm ${f}"
+ rm "${f}"
+done
+
+find . -name "CMakeCache.txt" |while read f; do
+ echo "rm ${f}"
+ rm "${f}"
+done
+
+find . -name "Makefile" |while read f; do
+ echo "rm ${f}"
+ rm "${f}"
+done
+
+find . -type d -name CMakeFiles |while read d; do
+ echo "rm -r ${d}"
+ rm -r "${d}"
+done
+
+find . -type d -name CMakeTmp |while read d; do
+ echo "rm -r ${d}"
+ rm -r "${d}"
+done
+
+
Deleted: trunk/char.h
===================================================================
--- trunk/char.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/char.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,31 +0,0 @@
-#ifndef DERACIEL_CHAR_H
-#define DERACIEL_CHAR_H
-
-#include <stdint.h>
-
-#include "inventory.h"
-#include "stat.h"
-
-struct char_struct
-{
- char name[32];
-
- stat_t stats[STAT_MAX_STATS];
-
- uint32_t experience;
- uint8_t level;
-
- uint32_t turns;
- uint32_t score;
-
- int16_t cur_hitpoints;
- int16_t max_hitpoints;
-
- int16_t cur_magic;
- int16_t max_magic;
-
- struct invt_struct inventory;
-};
-
-#endif // !DERACIEL_CHAR_H
-
Deleted: trunk/inventory.c
===================================================================
--- trunk/inventory.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/inventory.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,16 +0,0 @@
-#include "inventory.h"
-
-void invt_init(struct invt_struct *inventory)
-{
- memset(inventory, 0, sizeof(struct invt_struct));
-
- inventory->coins = obj_init(OBJ_DESC_COINS);
-}
-
-void invt_uninit(struct invt_struct *inventory) {
- obj_uninit(inventory->coins);
-
- for (int i = 0; i < MAX_INVENTORY_OBJECTS; ++i)
- obj_uninit(inventory->objects[i]);
-}
-
Deleted: trunk/inventory.h
===================================================================
--- trunk/inventory.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/inventory.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,19 +0,0 @@
-#ifndef DERACIEL_INVENTORY_H
-#define DERACIEL_INVENTORY_H
-
-#include "object.h"
-
-#define MAX_INVENTORY_OBJECTS 26
-
-struct invt_struct
-{
- struct obj_struct *coins;
-
- struct obj_struct *objects[MAX_INVENTORY_OBJECTS];
-};
-
-void invt_init(struct invt_struct *inventory);
-
-void invt_uninit(struct invt_struct *inventory);
-
-#endif
Deleted: trunk/keyboard.c
===================================================================
--- trunk/keyboard.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/keyboard.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,64 +0,0 @@
-#include "keyboard.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ncurses.h>
-
-#include "util.h"
-
-static void (*handler_cb)(const int key);
-static bool keyreader_is_active = false;
-/*
- The keyreader is an infinite loop that gets one character at iteration and
- passes it to a keyboard handling callback. The callback then can respond
- appropriately to the given key. This function is running inside a thread
- created by keyreader_create().
-*/
-static void keyreader()
-{
- /* This variable will hold the keycode of pressed key */
- int key;
-
- /* Run an infinite loop */
- while(keyreader_is_active) {
- /* Fetch a key from keyboard buffer */
- key = getch();
-
- /* If handler callback is specified, delegate the previously
- fetched key to it, else throw an error message */
- if (handler_cb) {
- handler_cb(key);
- } else {
- fprintf(stderr, "ERROR: Handler callback was NULL!\n");
- }
- }
-}
-
-
-/*
- Creates a thread that runs keyreader().
-*/
-void keyreader_start()
-{
- keyreader_is_active = true;
- keyreader();
-}
-
-
-
-void keyreader_stop()
-{
- keyreader_is_active = false;
-}
-
-
-
-void keyreader_set_handler(void(*cb)(const int key))
-{
- /* If the callback is not NULL set it as active keyboard handling function */
- if (cb) {
- handler_cb = cb;
- } else {
- fprintf(stderr, "ERROR: Specified callback was NULL!\n");
- }
-}
Deleted: trunk/keyboard.h
===================================================================
--- trunk/keyboard.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/keyboard.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,10 +0,0 @@
-#ifndef DERACIEL_KEYBOARD_H
-#define DERACIEL_KEYBOARD_H
-
-#include <stdint.h>
-
-void keyreader_start(void);
-void keyreader_stop(void);
-void keyreader_set_handler(void(*cb)(const int key));
-
-#endif // !DERACIEL_KEYBOARD_H
Deleted: trunk/main.c
===================================================================
--- trunk/main.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/main.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,146 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-#include <ncurses.h>
-
-#include "text_window.h"
-#include "status_window.h"
-#include "map_window.h"
-#include "random.h"
-#include "keyboard.h"
-
-
-#define KEY_ESCAPE 27
-
-static void finish(const int);
-static void test_keyhandler(const int key);
-
-static struct char_struct main_char =
-{
- "Foobar the Apprentice",
- { 16, 16, 16, 16, 16, 16 },
- 0,
- 1,
- 0,
- 0,
- 16,
- 16,
- 10,
- 10,
- { 0 }
-};
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, finish); /* arrange interrupts to terminate */
- initscr(); /* initialize the curses library */
- keypad(stdscr, TRUE); /* enable keyboard mapping */
- nonl(); /* tell curses not to do NL->CR/NL on output */
- //cbreak(); /* take input chars one at a time, no wait for \n */
- noecho(); /* don't echo input */
-
- curs_set(0); /* Hide the cursor */
-
- start_color();
- init_pair(1, COLOR_WHITE, COLOR_BLUE);
- init_pair(2, COLOR_BLACK, COLOR_YELLOW);
- init_pair(3, COLOR_WHITE, COLOR_RED);
- init_pair(4, COLOR_WHITE, COLOR_GREEN);
-
- clear();
- refresh();
-
- text_window_create();
- map_window_create();
- status_window_create();
-
- invt_init(&main_char.inventory);
-
- /* Assign keyboard handler callback */
- keyreader_set_handler(test_keyhandler);
-
- /* Start keyboard reader */
- keyreader_start();
-
- /* Let thread work */
- while(1) { sleep(5); };
-
- invt_uninit(&main_char.inventory);
-
- finish(0);
- return 0;
-}
-
-
-
-void finish(const int signum)
-{
- /* If text window is still existing, destroy it */
- text_window_destroy();
- map_window_destroy();
- status_window_destroy();
-
- /* End ncurses library */
- endwin();
-
- /* do your non-curses wrapup here */
-
- exit(0);
-}
-
-static int counter = 0;
-static chtype map[80*20];
-
-static void test_keyhandler(const int key)
-{
- text_window_clear();
-
- if (key == KEY_ESCAPE) finish(0);
-
- if (key == KEY_RESIZE) {
- endwin();
- curs_set(0); /* Hide the cursor */
-
- text_window_resize();
- map_window_resize();
- status_window_resize();
- clear();
- refresh();
- }
-
- if (key == KEY_DOWN) {
- counter++;
- if (counter == 1) {
- text_window_display_string("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmo");
- }
-
- if (counter == 2) {
- text_window_display_string("Ein etwas laengerer Text 2");
- }
-
- if (counter == 3) {
- text_window_display_string("Und Text 3");
- counter = 0;
- }
- }
-
- if (key == KEY_LEFT) {
- for (int i = 0; i < 80*20; i++) {
- map[i] = 'o';
- }
- map_window_display_map(map);
- }
-
- if (key == KEY_RIGHT) {
- for (int i = 0; i < 80*20; i++) {
- map[i] = '*';
- }
- map_window_display_map(map);
- }
-
- status_window_update(&main_char);
-
- doupdate();
-}
Copied: trunk/main.cpp (from rev 59, trunk/cpp/main.cpp)
===================================================================
--- trunk/main.cpp (rev 0)
+++ trunk/main.cpp 2008-12-22 22:09:46 UTC (rev 61)
@@ -0,0 +1,73 @@
+#include <iostream>
+#include <signal.h>
+#include <ncurses.h>
+
+#include "NCursesGUI.h"
+#include "KeyboardReader.h"
+
+using namespace std;
+
+#define KEY_ESCAPE 27
+
+static void finish(const int signum);
+static void keyhandler(const int key);
+
+GUI *gui;
+
+int main(int argc, char **argv) {
+ signal(SIGINT, finish); /* arrange interrupts to terminate */
+
+ gui = new NCursesGUI();
+ gui->initialize();
+
+ //gui->getStatusWindow->displayStatus();
+
+ /* Assign key handler callback */
+ KeyboardReader::setKeyboardHandler(keyhandler);
+
+ /* Start keyboard handler loop */
+ KeyboardReader::startLoop();
+
+ finish(0);
+ return 0;
+}
+
+void finish(const int signum) {
+ gui->finalize();
+}
+
+static void keyhandler(const int key) {
+ if (key == KEY_ESCAPE) {
+ // Stop keyboard handler loop
+ KeyboardReader::stop();
+ finish(0);
+ }
+
+ if (key == KEY_RESIZE) {
+ endwin();
+ curs_set(0); /* Hide the cursor */
+
+ clear();
+ refresh();
+ }
+
+ if (key == KEY_UP) {
+ cout << "KEY_UP" << endl;
+ }
+
+ if (key == KEY_DOWN) {
+ cout << "KEY_DOWN" << endl;
+ }
+
+ if (key == KEY_LEFT) {
+ cout << "KEY_LEFT" << endl;
+ }
+
+ if (key == KEY_RIGHT) {
+ cout << "KEY_RIGHT" << endl;
+ }
+
+ if (key == 'm') {
+ //gui->getTextWindow->displayString("Message displayed");
+ }
+}
Property changes on: trunk/main.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/map_window.c
===================================================================
--- trunk/map_window.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/map_window.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,61 +0,0 @@
-#include "map_window.h"
-
-#include <string.h>
-#include <ncurses.h>
-
-#define MAPWINDOW_MAXWIDTH (80)
-#define MAPWINDOW_MAXHEIGHT (20)
-#define MAPWINDOW_SCREENSIZE (MAPWINDOW_MAXWIDTH * MAPWINDOW_MAXHEIGHT)
-
-static WINDOW *map_wnd; /* Window handle */
-
-
-
-void map_window_create(void)
-{
- map_wnd = newwin(MAPWINDOW_MAXHEIGHT, MAPWINDOW_MAXWIDTH, 2, 0);
-
- if (!map_wnd) {
- fprintf(stderr, "map window creation failed!\n");
- return;
- }
-
- wattron(map_wnd, COLOR_PAIR(4));
- wbkgd(map_wnd, COLOR_PAIR(4));
-
- wrefresh(map_wnd);
-}
-
-
-
-void map_window_destroy()
-{
- if (map_wnd) {
- /* Free resources consumed by the window */
- delwin(map_wnd);
- map_wnd = NULL;
- }
-}
-
-
-
-void map_window_resize(void)
-{
- /* Reallocate storage for resized text window */
- wresize(map_wnd, MAPWINDOW_MAXHEIGHT, MAPWINDOW_MAXWIDTH);
-}
-
-
-
-void map_window_display_map(const chtype *map)
-{
- /* Set cursor to first position (upper left) in map window */
- wmove(map_wnd, 0, 0);
-
- /* Copy map to local map */
- for (int s = 0; s < MAPWINDOW_SCREENSIZE; s++) {
- waddch(map_wnd, map[s]);
- }
-
- wnoutrefresh(map_wnd);
-}
Deleted: trunk/map_window.h
===================================================================
--- trunk/map_window.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/map_window.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,11 +0,0 @@
-#ifndef DERACIEL_MAP_WINDOW_H
-#define DERACIEL_MAP_WINDOW_H
-
-#include <ncurses.h>
-
-void map_window_create(void);
-void map_window_destroy(void);
-void map_window_resize(void);
-void map_window_display_map(const chtype *m);
-
-#endif // !DERACIEL_MAP_WINDOW_H
Deleted: trunk/obj_types.c
===================================================================
--- trunk/obj_types.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/obj_types.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,52 +0,0 @@
-#include "obj_types.h"
-#include "object.h"
-
-// Gold piles always contain 0 coins by default
-static const uint32_t coins_default_value = 0;
-
-#define DEFINE_OBJ(ID, d, s) { ID, false, d, s }
-
-static struct obj_desc_struct obj_descs[] =
-{
- DEFINE_OBJ(OBJ_DESC_COINS, &coins_default_value, sizeof(coins_default_value)),
- DEFINE_OBJ(OBJ_DESC_INVALID, NULL, 0)
-};
-
-const struct obj_desc_struct *obj_desc_find(obj_descriptor_id id)
-{
- if (id == OBJ_DESC_INVALID)
- return NULL;
-
- for (int i = 0; obj_descs[i].id != OBJ_DESC_INVALID; ++i)
- {
- if (obj_descs[i].id == id)
- return obj_descs + i;
- }
-
- return NULL;
-}
-
-bool obj_desc_is_identified(obj_descriptor_id id)
-{
- const struct obj_desc_struct *desc = obj_desc_find(id);
- if (desc)
- return desc->is_identified;
- return false;
-}
-
-void obj_desc_mark_identified(obj_descriptor_id id)
-{
- struct obj_desc_struct *desc = (struct obj_desc_struct *)obj_desc_find(id);
- if (desc)
- {
- desc->is_identified = true;
- obj_update_names(id);
- }
-}
-
-const char *obj_desc_get_name(obj_descriptor_id id)
-{
- // TODO
- return "";
-}
-
Deleted: trunk/obj_types.h
===================================================================
--- trunk/obj_types.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/obj_types.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,45 +0,0 @@
-#ifndef DERACIEL_OBJ_TYPES_H
-#define DERACIEL_OBJ_TYPES_H
-
-#include "util.h"
-
-#include <stdint.h>
-#include <string.h>
-
-typedef uint32_t obj_descriptor_id;
-
-#define OBJ_DESC_INVALID ((obj_descriptor_id)-1)
-
-/**
- * Different object types we have
- */
-enum
-{
- /**
- * Object type for coins.
- *
- * [default_data] = uint32_t => indicating how many gold coins there are
- */
- OBJ_DESC_COINS
-};
-
-struct obj_desc_struct
-{
- obj_descriptor_id id;
-
- bool is_identified;
-
- const void *default_data;
- size_t default_data_size;
-};
-
-const struct obj_desc_struct *obj_desc_find(obj_descriptor_id id);
-
-bool obj_desc_is_identified(obj_descriptor_id id);
-
-void obj_desc_mark_identified(obj_descriptor_id id);
-
-const char *obj_desc_get_name(obj_descriptor_id id);
-
-#endif
-
Deleted: trunk/object.c
===================================================================
--- trunk/object.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/object.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,44 +0,0 @@
-#include "object.h"
-#include "util.h"
-
-#include <string.h>
-
-struct obj_struct *obj_init(obj_descriptor_id id)
-{
- struct obj_struct *obj;
- mem_alloc(struct obj_struct, obj);
- // TODO: need to put obj into a global object list
-
- obj->id = id;
-
- strncpy(obj->name, obj_desc_get_name(id), sizeof(obj->name));
- obj->name[sizeof(obj->name)-1] = 0;
-
- memset(obj->user_name, 0, sizeof(obj->user_name));
-
- const struct obj_desc_struct *obj_desc = obj_desc_find(id);
- if (obj_desc)
- {
- mem_alloc_size(obj_desc->default_data_size, void, obj->user_data);
- memcpy(obj->user_data, obj_desc->default_data, obj_desc->default_data_size);
- }
- else
- {
- obj->user_data = NULL;
- }
-
- return obj;
-}
-
-void obj_uninit(struct obj_struct *obj)
-{
- mem_dealloc(obj->user_data);
- // TODO: remove obj from global object list
- mem_dealloc(obj);
-}
-
-void obj_update_names(obj_descriptor_id id)
-{
- // TODO: implemt via global object list
-}
-
Deleted: trunk/object.h
===================================================================
--- trunk/object.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/object.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,29 +0,0 @@
-#ifndef DERACIEL_OBJECT_H
-#define DERACIEL_OBJECT_H
-
-#include "obj_types.h"
-
-#include <stdint.h>
-
-#define OBJ_NAME_LENGTH 64
-
-struct obj_struct
-{
- obj_descriptor_id id;
- char name[OBJ_NAME_LENGTH];
- char user_name[OBJ_NAME_LENGTH];
-
- void *user_data;
-};
-
-struct obj_struct *obj_init(obj_descriptor_id id);
-
-void obj_uninit(struct obj_struct *obj);
-
-// id == OBJ_DESC_INVALID would update all object names
-// TODO: define if all unidentified objects would get
-// new random names then too
-void obj_update_names(obj_descriptor_id id);
-
-#endif
-
Deleted: trunk/random.c
===================================================================
--- trunk/random.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/random.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,57 +0,0 @@
-#include "random.h"
-#include "util.h"
-
-struct rng_struct {
- uint32_t seed;
-};
-
-
-
-struct rng_struct *rng_create(const uint32_t seed)
-{
- struct rng_struct *rng = NULL;
- mem_alloc(struct rng_struct, rng);
-
- rng->seed = seed;
-
- return rng;
-}
-
-
-
-void rng_destroy(struct rng_struct *rng)
-{
- mem_dealloc(rng);
-}
-
-
-
-unsigned int rng_gen(struct rng_struct *rng, const unsigned int high)
-{
- rng->seed = 0xDE2AC1E1 * (rng->seed + 1);
- rng->seed = (rng->seed >> 13) | (rng->seed << 19);
-
- return rng->seed % (high + 1);
-}
-
-
-
-unsigned int rng_gen_from_range(struct rng_struct *rng, const unsigned int low, const unsigned int high)
-{
- unsigned int length = abs(high - low);
- unsigned int num = rng_gen(rng, length);
-
- return low + num;
-}
-
-
-
-unsigned int rng_nroll(struct rng_struct *rng, const unsigned int n, const unsigned int sides)
-{
- unsigned int sum = 0;
- for (unsigned int i = 0; i < n; i++) {
- sum += rng_roll(rng, sides);
- }
-
- return sum;
-}
Deleted: trunk/random.h
===================================================================
--- trunk/random.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/random.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,51 +0,0 @@
-#ifndef DERACIEL_RANDOM_H
-#define DERACIEL_RANDOM_H
-
-#include <stdint.h>
-
-struct rng_struct;
-
-
-
-/**
- * Creates and initializes a random number generator
- */
-struct rng_struct *rng_create(const uint32_t seed);
-
-
-
-/**
- * Deinitializes a random number generator
- */
-void rng_destroy(struct rng_struct *rng);
-
-
-
-/**
- * Returns a number of the interval [0, high]
- */
-unsigned int rng_gen(struct rng_struct *rng, const unsigned int high);
-
-
-
-/**
- * Returns a number of the interval [low, high]
- */
-unsigned int rng_gen_from_range(struct rng_struct *rng, const unsigned int low, const unsigned int high);
-
-
-
-/**
- * Rolls a sides-sided dice n times and returns the sum
- */
-unsigned int rng_nroll(struct rng_struct *rng, const unsigned int n, const unsigned int sides);
-
-
-
-#define rng_get_bit(rng) rng_gen(rng, 1)
-
-
-
-#define rng_roll(rng, sides) rng_gen_from_range(rng, 1, sides)
-
-#endif // !DERACIEL_RANDOM_H
Deleted: trunk/stat.h
===================================================================
--- trunk/stat.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/stat.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,18 +0,0 @@
-#ifndef DERACIEL_STAT_H
-#define DERACIEL_STAT_H
-
-#include <stdint.h>
-
-typedef uint32_t stat_t;
-
-enum {
- STAT_STRENGTH,
- STAT_DEXTERITY,
- STAT_WISDOM,
- STAT_WILLPOWER,
- STAT_CONSTITUTION,
- STAT_CHARISMA,
- STAT_MAX_STATS
-};
-
-#endif // !DERACIEL_STAT_H
Deleted: trunk/status_window.c
===================================================================
--- trunk/status_window.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/status_window.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,80 +0,0 @@
-#include "status_window.h"
-
-#include <string.h>
-#include <ncurses.h>
-
-#define STATUSWINDOW_MAXWIDTH (80)
-#define STATUSWINDOW_MAXHEIGHT (3)
-#define STATUSWINDOW_BORDER
-
-static WINDOW *status_wnd; /* Window handle */
-
-static void draw_border();
-
-
-void status_window_create(void)
-{
- status_wnd = newwin(STATUSWINDOW_MAXHEIGHT, STATUSWINDOW_MAXWIDTH, 25-STATUSWINDOW_MAXHEIGHT, 0);
-
- if (!status_wnd) {
- fprintf(stderr, "stat window creation failed!\n");
- return;
- }
-
- wattron(status_wnd, COLOR_PAIR(3));
- wbkgd(status_wnd, COLOR_PAIR(3));
-
-#ifdef STATUSWINDOW_BORDER
- /* Redraw border with new dimensions */
- draw_border();
-#endif // !STATUSWINDOW_BORDER
-
- wrefresh(status_wnd);
-}
-
-
-
-void status_window_destroy()
-{
- if (status_wnd) {
- /* Free resources consumed by the window */
- delwin(status_wnd);
- status_wnd = NULL;
- }
-}
-
-
-
-void status_window_resize(void)
-{
- /* Reallocate storage for resized text window */
- wresize(status_wnd, STATUSWINDOW_MAXHEIGHT, STATUSWINDOW_MAXWIDTH);
-}
-
-
-
-void draw_border()
-{
- wborder(status_wnd, 0, 0, 0, ' ', '/', '\\', ACS_VLINE, ACS_VLINE);
-}
-
-
-
-void status_window_update(const struct char_struct *ch)
-{
-#ifdef STATUSWINDOW_BORDER
- /* Redraw border with new dimensions */
- draw_border();
-#endif // !STATUSWINDOW_BORDER
-
- mvwprintw(status_wnd, 1, 2, "$:%d HP:%d(%d) MP:%d(%d) St:%2d Dx:%2d Co:%2d Wi:%2d Wp:%2d Ch:%2d",
- *(uint32_t*)(ch->inventory.coins->user_data),
- ch->cur_hitpoints, ch->max_hitpoints, ch->cur_magic, ch->max_magic,
- ch->stats[STAT_STRENGTH], ch->stats[STAT_DEXTERITY], ch->stats[STAT_CONSTITUTION],
- ch->stats[STAT_WISDOM], ch->stats[STAT_WILLPOWER], ch->stats[STAT_CHARISMA]);
-
- mvwprintw(status_wnd, 2, 2, "%s Xp:%2d/%d T:%d S:%d",
- ch->name, ch->level, ch->experience, ch->turns, ch->score);
-
- wnoutrefresh(status_wnd);
-}
Deleted: trunk/status_window.h
===================================================================
--- trunk/status_window.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/status_window.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,12 +0,0 @@
-#ifndef DERACIEL_STATUS_WINDOW_H
-#define DERACIEL_STATUS_WINDOW_H
-
-#include "char.h"
-
-void status_window_create(void);
-void status_window_destroy(void);
-void status_window_resize(void);
-void status_window_update(const struct char_struct *ch);
-
-#endif // !DERACIEL_STATUS_WINDOW_H
-
Deleted: trunk/text_window.c
===================================================================
--- trunk/text_window.c 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/text_window.c 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,93 +0,0 @@
-#include "text_window.h"
-
-#include <string.h>
-#include <ncurses.h>
-
-#define TEXTWINDOW_MAXWIDTH (80)
-#define TEXTWINDOW_MAXHEIGHT (2)
-#define TEXTWINDOW_BORDER
-
-static WINDOW *border_wnd; /* Window handle */
-static WINDOW *text_wnd; /* Window handle */
-
-static void draw_border();
-
-
-void text_window_create(void)
-{
- border_wnd = newwin(TEXTWINDOW_MAXHEIGHT, TEXTWINDOW_MAXWIDTH, 0, 0);
- text_wnd = newwin(TEXTWINDOW_MAXHEIGHT-1, TEXTWINDOW_MAXWIDTH-2, 0, 1);
-
- if (!border_wnd || !text_wnd) {
- fprintf(stderr, "text window creation failed!\n");
- return;
- }
-
- wattron(border_wnd, COLOR_PAIR(1));
- wbkgd(text_wnd, COLOR_PAIR(1));
-
-#ifdef TEXTWINDOW_BORDER
- /* Redraw border with new dimensions */
- draw_border();
-#endif // !TEXTWINDOW_BORDER
-
- wrefresh(border_wnd);
- wrefresh(text_wnd);
-}
-
-
-
-void text_window_destroy()
-{
- if (border_wnd) {
- /* Free resources consumed by the window */
- delwin(text_wnd);
- text_wnd = NULL;
-
- delwin(border_wnd);
- border_wnd = NULL;
- }
-}
-
-
-
-void text_window_resize(void)
-{
- /* Reallocate storage for resized text window */
- wresize(border_wnd, TEXTWINDOW_MAXHEIGHT, TEXTWINDOW_MAXWIDTH);
- wresize(text_wnd, TEXTWINDOW_MAXHEIGHT-1, TEXTWINDOW_MAXWIDTH-2);
-}
-
-
-
-void text_window_display_string(const char *string)
-{
-#ifdef TEXTWINDOW_BORDER
- /* Redraw border with new dimensions */
- draw_border();
-#endif // !TEXTWINDOW_BORDER
-
- wmove(text_wnd, 0, 0);
- wprintw(text_wnd, string);
-
- wnoutrefresh(border_wnd);
- wnoutrefresh(text_wnd);
-}
-
-
-void text_window_clear()
-{
-#ifdef TEXTWINDOW_BORDER
- /* Redraw border with new dimensions */
- draw_border();
-#endif // !TEXTWINDOW_BORDER
-
- wnoutrefresh(border_wnd);
- wnoutrefresh(text_wnd);
-}
-
-
-void draw_border()
-{
- wborder(border_wnd, 0, 0, ' ', 0, ACS_VLINE, ACS_VLINE, '\\', '/');
-}
Deleted: trunk/text_window.h
===================================================================
--- trunk/text_window.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/text_window.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,11 +0,0 @@
-#ifndef DERACIEL_TEXT_WINDOW_H
-#define DERACIEL_TEXT_WINDOW_H
-
-void text_window_create(void);
-void text_window_destroy(void);
-void text_window_resize(void);
-void text_window_display_string(const char *string);
-void text_window_clear(void);
-
-#endif // !DERACIEL_TEXT_WINDOW_H
-
Deleted: trunk/util.h
===================================================================
--- trunk/util.h 2008-12-22 21:40:42 UTC (rev 60)
+++ trunk/util.h 2008-12-22 22:09:46 UTC (rev 61)
@@ -1,40 +0,0 @@
-#ifndef DERACIEL_UTIL_H
-#define DERACIEL_UTIL_H
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define mem_alloc(type, var) \
- do { \
- var = (type*)malloc(sizeof(type)); \
- if (!var) { \
- fprintf(stderr, "Couldn't allocate memory for var %s of type %s in file %s line %d\n", #var, #type, __FILE__, __LINE__); \
- exit(-1); \
- } \
- } while (0)
-
-#define mem_alloc_size(size, type, var) \
- do { \
- var = (type*)malloc(size); \
- if (!var) { \
- fprintf(stderr, "Couldn't allocate memory for var %s of size %d in file %s line %d\n", #var, (int)size, __FILE__, __LINE__); \
- exit(-1); \
- } \
- } while (0)
-
-#define mem_dealloc(var) free(var)
-
-#ifndef bool
-#define bool unsigned char
-#endif // !bool
-
-#ifndef true
-#define true 1
-#endif // !true
-
-#ifndef false
-#define false 0
-#endif // !false
-
-#endif // !DERACIEL_UTIL_H
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|