Gnome updates (from <Someone> <Someone> Simon)

- fix destruction of primary game windows
- One, it makes the color of the cursor box dynamic (these are the gnmap.c
changes), based on hp/hpmax (continuous colors white -> yellow -> red ->
magenta rather than discrete like in Qt).
- Two, it adds a new window, NHW_WORN (all the other changes and new files
gnworn.[ch]), placed at the end of the first row, to the right of the status,
with tiles of all the items currently equiped.  I had to change the spacing of
the first row (no longer homogeneous) to accomodate this, but I think it still
looks okay.  It's mostly like the Qt version but the equiped items are in
slightly different places, and a bit more compactly (added quiver, ball/chain,
monster skin armor; see the definition in gnworn.c for the layout).
This commit is contained in:
cohrs
2002-04-21 17:09:34 +00:00
parent a277db8f73
commit b1055ae7c1
11 changed files with 169 additions and 9 deletions

View File

@@ -105,6 +105,9 @@ unix: install recover command into GAMEDIR by default
tty: correctly handle an empty TERM environment variable tty: correctly handle an empty TERM environment variable
tty: don't lose messages when ESC has canceled their display tty: don't lose messages when ESC has canceled their display
tty: clear topl after pickup_burden prompt tty: clear topl after pickup_burden prompt
Gnome: destroy main game windows correctly
Gnome: Dylan Alex Simon's port of KDE-style worn window
Gnome: Dylan Alex Simon's port of KDE-style hero cursor color
General New Features General New Features

View File

@@ -12,4 +12,7 @@ E struct window_procs Gnome_procs;
#undef E #undef E
#define NHW_WORN 6
extern winid WIN_WORN;
#endif /* WINGNOME_H */ #endif /* WINGNOME_H */

View File

@@ -184,10 +184,11 @@ WINGNOMESRC = ../win/gnome/gnaskstr.c ../win/gnome/gnbind.c \
../win/gnome/gnglyph.c ../win/gnome/gnmain.c ../win/gnome/gnmap.c \ ../win/gnome/gnglyph.c ../win/gnome/gnmain.c ../win/gnome/gnmap.c \
../win/gnome/gnmenu.c ../win/gnome/gnmesg.c ../win/gnome/gnopts.c \ ../win/gnome/gnmenu.c ../win/gnome/gnmesg.c ../win/gnome/gnopts.c \
../win/gnome/gnplayer.c ../win/gnome/gnsignal.c \ ../win/gnome/gnplayer.c ../win/gnome/gnsignal.c \
../win/gnome/gnstatus.c ../win/gnome/gntext.c ../win/gnome/gnyesno.c ../win/gnome/gnstatus.c ../win/gnome/gntext.c ../win/gnome/gnyesno.c \
../win/gnome/gnworn.c
WINGNOMEOBJ = gnaskstr.o gnbind.o gnglyph.o gnmain.o gnmap.o gnmenu.o \ WINGNOMEOBJ = gnaskstr.o gnbind.o gnglyph.o gnmain.o gnmap.o gnmenu.o \
gnmesg.o gnopts.o gnplayer.o gnsignal.o gnstatus.o gntext.o \ gnmesg.o gnopts.o gnplayer.o gnsignal.o gnstatus.o gntext.o \
gnyesno.o tile.o gnyesno.o gnworn.o tile.o
# #
# Files for a Gem port # Files for a Gem port
WINGEMSRC = ../win/gem/wingem.c ../win/gem/wingem1.c ../win/gem/load_img.c \ WINGEMSRC = ../win/gem/wingem.c ../win/gem/wingem1.c ../win/gem/load_img.c \
@@ -656,6 +657,9 @@ gnstatus.o: ../win/gnome/gnstatus.c ../win/gnome/gnstatus.h \
gntext.o: ../win/gnome/gntext.c ../win/gnome/gntext.h ../win/gnome/gnmain.h \ gntext.o: ../win/gnome/gntext.c ../win/gnome/gntext.h ../win/gnome/gnmain.h \
../win/gnome/gn_rip.h ../win/gnome/gn_rip.h
$(CC) $(CFLAGS) $(GNOMEINC) -c ../win/gnome/gntext.c $(CC) $(CFLAGS) $(GNOMEINC) -c ../win/gnome/gntext.c
gnworn.o: ../win/gnome/gnworn.c ../win/gnome/gnworn.h ../win/gnome/gnglyph.h \
../win/gnome/gnsignal.h ../win/gnome/gnomeprv.h
$(CC) $(CFLAGS) $(GNOMEINC) -c ../win/gnome/gnworn.c
gnyesno.o: ../win/gnome/gnyesno.c ../win/gnome/gnbind.h ../win/gnome/gnyesno.h gnyesno.o: ../win/gnome/gnyesno.c ../win/gnome/gnbind.h ../win/gnome/gnyesno.h
$(CC) $(CFLAGS) $(GNOMEINC) -c ../win/gnome/gnyesno.c $(CC) $(CFLAGS) $(GNOMEINC) -c ../win/gnome/gnyesno.c
wingem.o: ../win/gem/wingem.c $(HACK_H) ../include/func_tab.h ../include/dlb.h \ wingem.o: ../win/gem/wingem.c $(HACK_H) ../include/func_tab.h ../include/dlb.h \

View File

@@ -13,6 +13,7 @@
#include "gnyesno.h" #include "gnyesno.h"
GNHWinData gnome_windowlist[MAXWINDOWS]; GNHWinData gnome_windowlist[MAXWINDOWS];
winid WIN_WORN = WIN_ERR;
extern void tty_raw_print(const char *); extern void tty_raw_print(const char *);
extern void tty_raw_print_bold(const char *); extern void tty_raw_print_bold(const char *);
@@ -105,6 +106,9 @@ void gnome_init_nhwindows(int* argc, char** argv)
//wizard = TRUE; //wizard = TRUE;
iflags.window_inited = TRUE; iflags.window_inited = TRUE;
/* gnome-specific window creation */
WIN_WORN = gnome_create_nhwindow(NHW_WORN);
} }
@@ -434,6 +438,13 @@ gnome_create_nhwindow_by_id( int type, winid i)
ghack_main_window_add_status_window( gnome_windowlist[i].win); ghack_main_window_add_status_window( gnome_windowlist[i].win);
break; break;
} }
case NHW_WORN:
{
gnome_windowlist[i].win = ghack_init_worn_window( );
gnome_windowlist[i].type = NHW_WORN;
ghack_main_window_add_worn_window(gnome_windowlist[i].win);
break;
}
case NHW_MENU: case NHW_MENU:
{ {
gnome_windowlist[i].type = NHW_MENU; gnome_windowlist[i].type = NHW_MENU;
@@ -502,9 +513,9 @@ void gnome_display_nhwindow(winid wid, BOOLEAN_P block)
*/ */
void gnome_destroy_nhwindow(winid wid) void gnome_destroy_nhwindow(winid wid)
{ {
if ((wid == NHW_MAP) || if ((wid == WIN_MAP) ||
(wid == NHW_MESSAGE) || (wid == WIN_MESSAGE) ||
(wid == NHW_STATUS)) { (wid == WIN_STATUS)) {
/* no thanks, I'll do these myself */ /* no thanks, I'll do these myself */
return; return;
} }

View File

@@ -24,6 +24,7 @@
#include "gnmesg.h" #include "gnmesg.h"
#include "gnyesno.h" #include "gnyesno.h"
#include "gnglyph.h" #include "gnglyph.h"
#include "gnworn.h"
/* Create an array to keep track of the various windows */ /* Create an array to keep track of the various windows */

View File

@@ -750,7 +750,7 @@ void ghack_init_main_window( int argc, char** argv)
/* Put some stuff into our main window */ /* Put some stuff into our main window */
vBoxMain = gtk_vbox_new (FALSE, 0); vBoxMain = gtk_vbox_new (FALSE, 0);
hBoxFirstRow = gtk_hbox_new (TRUE, 0); hBoxFirstRow = gtk_hbox_new (FALSE, 0);
/* pack Boxes into other boxes to produce the right structure */ /* pack Boxes into other boxes to produce the right structure */
gtk_box_pack_start (GTK_BOX (vBoxMain), hBoxFirstRow, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vBoxMain), hBoxFirstRow, FALSE, TRUE, 0);
@@ -793,7 +793,14 @@ ghack_main_window_add_message_window(GtkWidget* win)
void void
ghack_main_window_add_status_window(GtkWidget* win) ghack_main_window_add_status_window(GtkWidget* win)
{ {
gtk_box_pack_start (GTK_BOX (hBoxFirstRow), win, TRUE, TRUE, 2); gtk_box_pack_start (GTK_BOX (hBoxFirstRow), win, FALSE, TRUE, 2);
gtk_widget_show_all(win);
}
void
ghack_main_window_add_worn_window(GtkWidget* win)
{
gtk_box_pack_end (GTK_BOX (hBoxFirstRow), win, FALSE, TRUE, 2);
gtk_widget_show_all(win); gtk_widget_show_all(win);
} }
@@ -812,10 +819,11 @@ ghack_main_window_remove_window(GtkWidget *win)
void void
ghack_main_window_update_inventory() ghack_main_window_update_inventory()
{ {
/* For now, do nothing. Eventually we may allow the inv. window /* For now, do very little. Eventually we may allow the inv. window
to stay active. When we do this, we'll need to implement this... to stay active. When we do this, we'll need to implement this...
g_warning("Fixme!!! updateInventory is not yet implemented"); g_warning("Fixme!!! updateInventory is not yet implemented");
*/ */
gnome_display_nhwindow(WIN_WORN, FALSE);
} }
GtkWidget* GtkWidget*

View File

@@ -14,6 +14,7 @@ void ghack_main_window_add_map_window(GtkWidget* win);
void ghack_main_window_add_message_window(GtkWidget* win); void ghack_main_window_add_message_window(GtkWidget* win);
void ghack_main_window_add_status_window(GtkWidget* win); void ghack_main_window_add_status_window(GtkWidget* win);
void ghack_main_window_add_text_window(GtkWidget *); void ghack_main_window_add_text_window(GtkWidget *);
void ghack_main_window_add_worn_window(GtkWidget* win);
void ghack_main_window_remove_window(GtkWidget *); void ghack_main_window_remove_window(GtkWidget *);
void ghack_main_window_update_inventory(); void ghack_main_window_update_inventory();
void ghack_save_game_cb(GtkWidget *widget, gpointer data); void ghack_save_game_cb(GtkWidget *widget, gpointer data);

View File

@@ -341,22 +341,30 @@ ghack_map_cursor_to( GtkWidget *win, int x, int y, gpointer data)
static GnomeCanvasRE *cursor = NULL; static GnomeCanvasRE *cursor = NULL;
double x1, y1, x2, y2; double x1, y1, x2, y2;
float hp;
guint r, g, b;
x1 = x * ghack_glyph_width() - 1; x1 = x * ghack_glyph_width() - 1;
y1 = y * ghack_glyph_height() - 1; y1 = y * ghack_glyph_height() - 1;
x2 = x1 + ghack_glyph_width() + 2; x2 = x1 + ghack_glyph_width() + 2;
y2 = y1 + ghack_glyph_height() + 2; y2 = y1 + ghack_glyph_height() + 2;
hp = u.mtimedone
? (u.mhmax ? (float)u.mh/u.mhmax : 1)
: (u.uhpmax ? (float)u.uhp/u.uhpmax : 1);
r = 255;
g = (hp >= 0.75) ? 255 : (hp >= 0.25 ? 255*2*(hp-0.25) : 0);
b = (hp >= 0.75) ? 255*4*(hp-0.75) : (hp >= 0.25 ? 0 : 255*4*(0.25-hp));
group = gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)); group = gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas));
if (!cursor) { if (!cursor) {
cursor = GNOME_CANVAS_RE (gnome_canvas_item_new (group, cursor = GNOME_CANVAS_RE (gnome_canvas_item_new (group,
gnome_canvas_rect_get_type (), gnome_canvas_rect_get_type (),
"outline_color", "antiquewhite2",
"width_units", 1.0, NULL)); "width_units", 1.0, NULL));
} }
gnome_canvas_item_set (GNOME_CANVAS_ITEM (cursor), gnome_canvas_item_set (GNOME_CANVAS_ITEM (cursor),
"outline_color_rgba", GNOME_CANVAS_COLOR(r, g, b),
"x1", x1, "x1", x1,
"y1", y1, "y1", y1,
"x2", x2, "x2", x2,

View File

@@ -10,6 +10,8 @@
#include "dlb.h" #include "dlb.h"
#include "patchlevel.h" #include "patchlevel.h"
#include "winGnome.h"
#endif /* GnomeHack_h */ #endif /* GnomeHack_h */

105
win/gnome/gnworn.c Normal file
View File

@@ -0,0 +1,105 @@
/* SCCS Id: @(#)gnbind.c 3.4 2002/04/15 */
/* Copyright (C) 2002, Dylan Alex Simon */
/* NetHack may be freely redistributed. See license for details. */
#include "gnworn.h"
#include "gnglyph.h"
#include "gnsignal.h"
#include "gnomeprv.h"
#define WORN_WIDTH 3
#define WORN_HEIGHT 6
#ifdef TOURIST
#define WORN_OBJECT_LIST /* struct obj *[WORN_HEIGHT][WORN_WIDTH] = */ { \
{ uquiver, uarmh, u.twoweap ? NULL : uswapwep }, \
{ u.twoweap ? uswapwep : NULL, ublindf, uwep }, \
{ uleft, uamul, uright }, \
{ uarms, uarmc, uarmg }, \
{ uarmu, uarm, uskin }, \
{ uball, uarmf, uchain } \
}
#else
#define WORN_OBJECT_LIST /* struct obj *[WORN_HEIGHT][WORN_WIDTH] = */ { \
{ uquiver, uarmh, u.twoweap ? NULL : uswapwep }, \
{ u.twoweap ? uswapwep : NULL, ublindf, uwep }, \
{ uleft, uamul, uright }, \
{ uarms, uarmc, uarmg }, \
{ NULL, uarm, uskin }, \
{ uball, uarmf, uchain } \
}
#endif
static GtkWidget *worn_contents[WORN_HEIGHT][WORN_WIDTH];
static struct obj *last_worn_objects[WORN_HEIGHT][WORN_WIDTH];
GdkImlibImage *image_of_worn_object(struct obj *o);
void ghack_worn_display(GtkWidget *win, boolean block, gpointer data);
GtkWidget*
ghack_init_worn_window()
{
GtkWidget *top;
GtkWidget *table;
GtkWidget *tablealign;
GtkWidget *label;
int i,j;
top = gtk_vbox_new(FALSE, 2);
table = gtk_table_new(WORN_HEIGHT, WORN_WIDTH, TRUE);
for (i = 0; i < WORN_HEIGHT; i++) {
for (j = 0; j < WORN_WIDTH; j++) {
worn_contents[i][j] =
gnome_pixmap_new_from_imlib(image_of_worn_object(NULL));
last_worn_objects[i][j] = NULL; /* a pointer that will never be */
gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(worn_contents[i][j]),
j, j+1, i, i+1, 0, 0, 0, 0);
}
}
tablealign = gtk_alignment_new(0.5, 0.0, 0.0, 1.0);
gtk_box_pack_start(GTK_BOX(top), tablealign, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(tablealign), table);
label = gtk_label_new("Equipment");
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
gtk_box_pack_start(GTK_BOX(top), label, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(top), "ghack_display",
GTK_SIGNAL_FUNC(ghack_worn_display), NULL);
return top;
}
GdkImlibImage*
image_of_worn_object(struct obj *o)
{
int glyph;
GdkImlibImage *im;
if (o)
glyph = obj_to_glyph(o);
else
glyph = cmap_to_glyph(S_stone);
im = ghack_image_from_glyph(glyph, FALSE);
return im;
}
void
ghack_worn_display(GtkWidget *win, boolean block, gpointer data)
{
int i, j;
struct obj *worn_objects[WORN_HEIGHT][WORN_WIDTH] = WORN_OBJECT_LIST;
for (i = 0; i < WORN_HEIGHT; i++) {
for (j = 0; j < WORN_WIDTH; j++) {
if (worn_objects[i][j] != last_worn_objects[i][j]) {
last_worn_objects[i][j] = worn_objects[i][j];
gnome_pixmap_load_imlib(GNOME_PIXMAP(worn_contents[i][j]),
image_of_worn_object(worn_objects[i][j]));
}
}
}
}

14
win/gnome/gnworn.h Normal file
View File

@@ -0,0 +1,14 @@
/* SCCS Id: @(#)gnbind.c 3.4 2002/04/15 */
/* Copyright (C) 2002 by Dylan Alex Simon */
/* NetHack may be freely redistributed. See license for details. */
#ifndef GnomeHackWornWindow_h
#define GnomeHackWornWindow_h
#include <gnome.h>
#include "config.h"
#include "global.h"
GtkWidget* ghack_init_worn_window();
#endif /* GnomeHackWornWindow_h */