diff options
-rw-r--r-- | src/net_gui.c | 10 | ||||
-rw-r--r-- | textscreen/Makefile.am | 1 | ||||
-rw-r--r-- | textscreen/guitest.c | 6 | ||||
-rw-r--r-- | textscreen/txt_desktop.c | 133 | ||||
-rw-r--r-- | textscreen/txt_desktop.h | 37 | ||||
-rw-r--r-- | textscreen/txt_gui.c | 6 | ||||
-rw-r--r-- | textscreen/txt_gui.h | 6 | ||||
-rw-r--r-- | textscreen/txt_window.c | 64 | ||||
-rw-r--r-- | textscreen/txt_window.h | 2 |
9 files changed, 191 insertions, 74 deletions
diff --git a/src/net_gui.c b/src/net_gui.c index d7a6f175..e9222d33 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_gui.c 455 2006-03-30 19:08:37Z fraggle $ +// $Id: net_gui.c 483 2006-05-19 19:57:59Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -123,10 +123,10 @@ static void DrawScreen(void) char buf[40]; int i; - TXT_DrawDesktop(PACKAGE_STRING); - TXT_DrawWindow("Waiting for game start...", - WINDOW_X, WINDOW_Y, - WINDOW_W, WINDOW_H); + TXT_DrawDesktopBackground(PACKAGE_STRING); + TXT_DrawWindowFrame("Waiting for game start...", + WINDOW_X, WINDOW_Y, + WINDOW_W, WINDOW_H); TXT_BGColor(TXT_COLOR_BLUE, 0); diff --git a/textscreen/Makefile.am b/textscreen/Makefile.am index 2c7903f1..c00f6179 100644 --- a/textscreen/Makefile.am +++ b/textscreen/Makefile.am @@ -5,6 +5,7 @@ noinst_LIBRARIES=libtextscreen.a bin_PROGRAMS=guitest libtextscreen_a_SOURCES = \ + txt_desktop.c txt_desktop.h \ txt_gui.c txt_gui.h \ txt_io.c txt_io.h \ txt_main.c txt_main.h \ diff --git a/textscreen/guitest.c b/textscreen/guitest.c index d65aa67c..7fc19df8 100644 --- a/textscreen/guitest.c +++ b/textscreen/guitest.c @@ -4,6 +4,7 @@ #include "txt_main.h" #include "txt_button.h" +#include "txt_desktop.h" #include "txt_separator.h" #include "txt_window.h" @@ -45,7 +46,7 @@ void Window2(void) txt_window_t *window; int i; - window = TXT_NewWindow("Another test", 30, 7); + window = TXT_NewWindow("Another test", 50, 7); for (i=0; i<5; ++i) { @@ -65,8 +66,7 @@ int main() { firstwin->selected = (firstwin->selected + 1) % firstwin->num_widgets; - TXT_DrawAllWindows(); - + TXT_DrawDesktop(); } } diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c new file mode 100644 index 00000000..a2ec5c56 --- /dev/null +++ b/textscreen/txt_desktop.c @@ -0,0 +1,133 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id$ +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2006 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// + +#include <stdlib.h> +#include <string.h> + +#include "txt_desktop.h" +#include "txt_gui.h" +#include "txt_main.h" +#include "txt_separator.h" +#include "txt_window.h" + +#define MAXWINDOWS 128 + +static char *desktop_title; +static txt_window_t *all_windows[MAXWINDOWS]; +static int num_windows = 0; + +void TXT_AddDesktopWindow(txt_window_t *win) +{ + all_windows[num_windows] = win; + ++num_windows; +} + +void TXT_RemoveDesktopWindow(txt_window_t *win) +{ + int from, to; + + for (from=0, to=0; from<num_windows; ++from) + { + if (all_windows[from] != win) + { + all_windows[to] = all_windows[from]; + ++to; + } + } + + num_windows = to; +} + +static void DrawDesktopBackground(char *title) +{ + int i; + unsigned char *screendata; + unsigned char *p; + + screendata = TXT_GetScreenData(); + + // Fill the screen with gradient characters + + p = screendata; + + for (i=0; i<TXT_SCREEN_W * TXT_SCREEN_H; ++i) + { + *p++ = 0xb1; + *p++ = TXT_COLOR_GREY | (TXT_COLOR_BLUE << 4); + } + + // Draw the top and bottom banners + + p = screendata; + + for (i=0; i<TXT_SCREEN_W; ++i) + { + *p++ = ' '; + *p++ = TXT_COLOR_BLACK | (TXT_COLOR_GREY << 4); + } + + p = screendata + (TXT_SCREEN_H - 1) * TXT_SCREEN_W * 2; + + for (i=0; i<TXT_SCREEN_W; ++i) + { + *p++ = ' '; + *p++ = TXT_COLOR_BLACK | (TXT_COLOR_GREY << 4); + } + + // Print the title + + TXT_GotoXY(0, 0); + TXT_FGColor(TXT_COLOR_BLACK); + TXT_BGColor(TXT_COLOR_GREY, 0); + + TXT_PutChar(' '); + TXT_Puts(title); +} + +void TXT_SetDesktopTitle(char *title) +{ + free(desktop_title); + desktop_title = strdup(title); +} + +void TXT_DrawDesktop(void) +{ + int i; + char *title; + + if (desktop_title == NULL) + title = ""; + else + title = desktop_title; + + DrawDesktopBackground(title); + + for (i=0; i<num_windows; ++i) + { + TXT_DrawWindow(all_windows[i]); + } + + TXT_UpdateScreen(); +} + diff --git a/textscreen/txt_desktop.h b/textscreen/txt_desktop.h new file mode 100644 index 00000000..79597039 --- /dev/null +++ b/textscreen/txt_desktop.h @@ -0,0 +1,37 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id$ +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2006 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// + +#ifndef TXT_DESKTOP_H +#define TXT_DESKTOP_H + +#include "txt_window.h" + +void TXT_AddDesktopWindow(txt_window_t *win); +void TXT_RemoveDesktopWindow(txt_window_t *win); +void TXT_SetDesktopTitle(char *title); +void TXT_DrawDesktop(void); + +#endif /* #ifndef TXT_DESKTOP_T */ + + diff --git a/textscreen/txt_gui.c b/textscreen/txt_gui.c index ee581fee..0b0c602d 100644 --- a/textscreen/txt_gui.c +++ b/textscreen/txt_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: txt_gui.c 291 2006-01-13 23:56:00Z fraggle $ +// $Id: txt_gui.c 483 2006-05-19 19:57:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -48,7 +48,7 @@ static int borders[4][4] = {0xc0, 0xc4, 0xc1, 0xd9}, }; -void TXT_DrawDesktop(char *title) +void TXT_DrawDesktopBackground(char *title) { int i; unsigned char *screendata; @@ -114,7 +114,7 @@ void TXT_DrawShadow(int x, int y, int w, int h) } } -void TXT_DrawWindow(char *title, int x, int y, int w, int h) +void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h) { int x1, y1; int bx, by; diff --git a/textscreen/txt_gui.h b/textscreen/txt_gui.h index 84d3334d..d9c3c8e6 100644 --- a/textscreen/txt_gui.h +++ b/textscreen/txt_gui.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: txt_gui.h 291 2006-01-13 23:56:00Z fraggle $ +// $Id: txt_gui.h 483 2006-05-19 19:57:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -42,8 +42,8 @@ #ifndef TXT_GUI_H #define TXT_GUI_H -void TXT_DrawDesktop(char *title); -void TXT_DrawWindow(char *title, int x, int y, int w, int h); +void TXT_DrawDesktopBackground(char *title); +void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h); void TXT_DrawSeparator(int x, int y, int w); #endif /* #ifndef TXT_GUI_H */ diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index cc467192..819bdc34 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -25,38 +25,12 @@ #include <stdlib.h> #include <string.h> +#include "txt_desktop.h" #include "txt_gui.h" +#include "txt_main.h" #include "txt_separator.h" #include "txt_window.h" -#define MAXWINDOWS 128 - -static char *desktop_title; -static txt_window_t *all_windows[MAXWINDOWS]; -static int num_windows = 0; - -static void AddWindow(txt_window_t *win) -{ - all_windows[num_windows] = win; - ++num_windows; -} - -static void RemoveWindow(txt_window_t *win) -{ - int from, to; - - for (from=0, to=0; from<num_windows; ++from) - { - if (all_windows[from] != win) - { - all_windows[to] = all_windows[from]; - ++to; - } - } - - num_windows = to; -} - txt_window_t *TXT_NewWindow(char *title, int x, int y) { txt_window_t *win; @@ -70,7 +44,7 @@ txt_window_t *TXT_NewWindow(char *title, int x, int y) win->num_widgets = 0; win->selected = 0; - AddWindow(win); + TXT_AddDesktopWindow(win); return win; } @@ -92,7 +66,7 @@ void TXT_CloseWindow(txt_window_t *window) free(window->title); free(window); - RemoveWindow(window); + TXT_RemoveDesktopWindow(window); } static void TXT_WindowSize(txt_window_t *window, int *w, int *h) @@ -115,7 +89,7 @@ static void TXT_WindowSize(txt_window_t *window, int *w, int *h) *h = window->num_widgets; } -static void DrawWindow(txt_window_t *window) +void TXT_DrawWindow(txt_window_t *window) { int widgets_w, widgets_h; int window_w, window_h; @@ -138,7 +112,7 @@ static void DrawWindow(txt_window_t *window) // Draw the window - TXT_DrawWindow(window->title, window_x, window_y, window_w, window_h); + TXT_DrawWindowFrame(window->title, window_x, window_y, window_w, window_h); // Draw all widgets @@ -153,32 +127,6 @@ static void DrawWindow(txt_window_t *window) TXT_DrawSeparator(window_x, window_y + 2 + window->num_widgets, window_w); } -void TXT_SetDesktopTitle(char *title) -{ - free(desktop_title); - desktop_title = strdup(title); -} - -void TXT_DrawAllWindows(void) -{ - int i; - char *title; - - if (desktop_title == NULL) - title = ""; - else - title = desktop_title; - - TXT_DrawDesktop(title); - - for (i=0; i<num_windows; ++i) - { - DrawWindow(all_windows[i]); - } - - TXT_UpdateScreen(); -} - void TXT_AddWidget(txt_window_t *window, void *uncast_widget) { txt_widget_t *widget; diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h index dc38926f..327bc06a 100644 --- a/textscreen/txt_window.h +++ b/textscreen/txt_window.h @@ -52,8 +52,6 @@ struct txt_window_s txt_window_t *TXT_NewWindow(char *title, int x, int y); void TXT_CloseWindow(txt_window_t *window); void TXT_AddWidget(txt_window_t *window, void *widget); -void TXT_SetDesktopTitle(char *title); -void TXT_DrawAllWindows(void); #endif /* #ifndef TXT_WINDOW_T */ |