Reformat all C files.
I'll push a formatting guide at some point. There may still be outstanding changes, but please feel free to resolve those as you arrive a them. To the best of my knowledge, there is no changes to the actual code content, but the formatter does have the occasional bug. If you run into an issue, please fix it!
This commit is contained in:
+28
-32
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnaskstr.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnaskstr.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 gnaskstr.c $Date: 2009/05/06 10:57:24 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)gnaskstr.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -8,56 +8,52 @@
|
||||
#include "gnmain.h"
|
||||
#include <gnome.h>
|
||||
|
||||
|
||||
static
|
||||
void ghack_ask_string_callback(gchar * string, gpointer data)
|
||||
static void
|
||||
ghack_ask_string_callback(gchar *string, gpointer data)
|
||||
{
|
||||
char **user_text = (char **) data;
|
||||
char **user_text = (char **) data;
|
||||
|
||||
g_assert(user_text != NULL);
|
||||
g_assert(user_text != NULL);
|
||||
|
||||
*user_text = string; /* note - value must be g_free'd */
|
||||
*user_text = string; /* note - value must be g_free'd */
|
||||
}
|
||||
|
||||
|
||||
int ghack_ask_string_dialog(const char *szMessageStr,
|
||||
const char *szDefaultStr, const char *szTitleStr,
|
||||
char *buffer)
|
||||
int
|
||||
ghack_ask_string_dialog(const char *szMessageStr, const char *szDefaultStr,
|
||||
const char *szTitleStr, char *buffer)
|
||||
{
|
||||
int i;
|
||||
GtkWidget* dialog;
|
||||
gchar *user_text = NULL;
|
||||
GtkWidget *dialog;
|
||||
gchar *user_text = NULL;
|
||||
|
||||
dialog = gnome_request_dialog(FALSE, szMessageStr,
|
||||
szDefaultStr, 0,
|
||||
ghack_ask_string_callback,
|
||||
&user_text, NULL);
|
||||
dialog =
|
||||
gnome_request_dialog(FALSE, szMessageStr, szDefaultStr, 0,
|
||||
ghack_ask_string_callback, &user_text, NULL);
|
||||
g_assert(dialog != NULL);
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(dialog), szTitleStr);
|
||||
|
||||
gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
|
||||
GTK_WINDOW (ghack_get_main_window ()) );
|
||||
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(dialog),
|
||||
GTK_WINDOW(ghack_get_main_window()));
|
||||
|
||||
i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
|
||||
|
||||
i = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
|
||||
|
||||
/* Quit */
|
||||
if ( i != 0 || user_text == NULL ) {
|
||||
if (user_text)
|
||||
g_free(user_text);
|
||||
return -1;
|
||||
if (i != 0 || user_text == NULL) {
|
||||
if (user_text)
|
||||
g_free(user_text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( *user_text == 0 ) {
|
||||
g_free(user_text);
|
||||
return -1;
|
||||
if (*user_text == 0) {
|
||||
g_free(user_text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_assert(strlen(user_text) > 0);
|
||||
strcpy (buffer, user_text);
|
||||
strcpy(buffer, user_text);
|
||||
g_free(user_text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+634
-638
File diff suppressed because it is too large
Load Diff
+65
-74
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnglyph.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnglyph.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
|
||||
/* NetHack 3.6 gnglyph.c $Date: 2009/05/06 10:57:29 $ $Revision: 1.6 $ */
|
||||
/* SCCS Id: @(#)gnglyph.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -10,8 +10,8 @@
|
||||
/* from tile.c */
|
||||
extern int total_tiles_used;
|
||||
|
||||
static GHackGlyphs ghack_glyphs;
|
||||
static GdkImlibImage** ghack_tiles = NULL;
|
||||
static GHackGlyphs ghack_glyphs;
|
||||
static GdkImlibImage **ghack_tiles = NULL;
|
||||
|
||||
/* NAME:
|
||||
* ghack_init_glyphs(char* xpm_file)
|
||||
@@ -53,47 +53,46 @@ int
|
||||
ghack_init_glyphs(const char *xpmFile)
|
||||
{
|
||||
ghack_glyphs.im = gdk_imlib_load_image((char *) xpmFile);
|
||||
if ( ! ghack_glyphs.im ) {
|
||||
g_error("Couldn't load required xpmFile!");
|
||||
return -1;
|
||||
if (!ghack_glyphs.im) {
|
||||
g_error("Couldn't load required xpmFile!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gdk_imlib_render(ghack_glyphs.im, ghack_glyphs.im->rgb_width,
|
||||
ghack_glyphs.im->rgb_height);
|
||||
ghack_glyphs.im->rgb_height);
|
||||
|
||||
if ((ghack_glyphs.im->rgb_width % TILES_PER_ROW) != 0 ||
|
||||
ghack_glyphs.im->rgb_width <= TILES_PER_ROW) {
|
||||
g_error("%s is not a multiple of %d (number of tiles/row) pixels wide",
|
||||
xpmFile, TILES_PER_ROW);
|
||||
return -1;
|
||||
if ((ghack_glyphs.im->rgb_width % TILES_PER_ROW) != 0
|
||||
|| ghack_glyphs.im->rgb_width <= TILES_PER_ROW) {
|
||||
g_error(
|
||||
"%s is not a multiple of %d (number of tiles/row) pixels wide",
|
||||
xpmFile, TILES_PER_ROW);
|
||||
return -1;
|
||||
}
|
||||
ghack_glyphs.count = total_tiles_used;
|
||||
if ((ghack_glyphs.count % TILES_PER_ROW) != 0) {
|
||||
ghack_glyphs.count +=
|
||||
TILES_PER_ROW - (ghack_glyphs.count % TILES_PER_ROW);
|
||||
ghack_glyphs.count +=
|
||||
TILES_PER_ROW - (ghack_glyphs.count % TILES_PER_ROW);
|
||||
}
|
||||
ghack_glyphs.width = ghack_glyphs.im->rgb_width / TILES_PER_ROW;
|
||||
ghack_glyphs.height =
|
||||
ghack_glyphs.im->rgb_height / (ghack_glyphs.count / TILES_PER_ROW);
|
||||
|
||||
ghack_glyphs.im->rgb_height / (ghack_glyphs.count / TILES_PER_ROW);
|
||||
|
||||
/* Assume the tiles are organized in rows of TILES_PER_ROW */
|
||||
ghack_tiles = g_new0( GdkImlibImage*, ghack_glyphs.count );
|
||||
ghack_tiles = g_new0(GdkImlibImage *, ghack_glyphs.count);
|
||||
return (ghack_tiles == NULL) ? -1 : 0;
|
||||
}
|
||||
|
||||
void
|
||||
ghack_free_glyphs( )
|
||||
ghack_free_glyphs()
|
||||
{
|
||||
int i;
|
||||
for ( i=0 ; i<ghack_glyphs.count ; i++)
|
||||
gdk_imlib_destroy_image(ghack_tiles[i]);
|
||||
g_free( ghack_tiles);
|
||||
for (i = 0; i < ghack_glyphs.count; i++)
|
||||
gdk_imlib_destroy_image(ghack_tiles[i]);
|
||||
g_free(ghack_tiles);
|
||||
gdk_imlib_destroy_image(ghack_glyphs.im);
|
||||
ghack_glyphs.im=NULL;
|
||||
ghack_glyphs.im = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
* ghack_glyph_count( )
|
||||
*
|
||||
@@ -108,12 +107,11 @@ ghack_free_glyphs( )
|
||||
*/
|
||||
|
||||
int
|
||||
ghack_glyph_count( )
|
||||
ghack_glyph_count()
|
||||
{
|
||||
return ghack_glyphs.count;
|
||||
return ghack_glyphs.count;
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
* ghack_glyph_height()
|
||||
*
|
||||
@@ -130,10 +128,9 @@ ghack_glyph_count( )
|
||||
int
|
||||
ghack_glyph_height()
|
||||
{
|
||||
return ghack_glyphs.height;
|
||||
return ghack_glyphs.height;
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
* ghack_glyph_width()
|
||||
*
|
||||
@@ -150,10 +147,9 @@ ghack_glyph_height()
|
||||
int
|
||||
ghack_glyph_width()
|
||||
{
|
||||
return ghack_glyphs.width;
|
||||
return ghack_glyphs.width;
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
* ghack_image_from_glyph( int glyph, gboolean force)
|
||||
*
|
||||
@@ -168,38 +164,36 @@ ghack_glyph_width()
|
||||
* Decodes the glyph into an image suitable for manipulation
|
||||
*/
|
||||
|
||||
GdkImlibImage*
|
||||
ghack_image_from_glyph( int glyph, gboolean force )
|
||||
GdkImlibImage *
|
||||
ghack_image_from_glyph(int glyph, gboolean force)
|
||||
{
|
||||
int tile = glyph2tile[glyph];
|
||||
int tile = glyph2tile[glyph];
|
||||
|
||||
if ( tile >= ghack_glyphs.count || tile < 0 )
|
||||
{
|
||||
g_warning("Aiiee! I've was asked for a tile outside the allowed range!\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning("Max tile: %d Tile asked for: %d",
|
||||
ghack_glyphs.count, tile);
|
||||
return NULL;
|
||||
if (tile >= ghack_glyphs.count || tile < 0) {
|
||||
g_warning(
|
||||
"Aiiee! I've was asked for a tile outside the allowed range!\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning("Max tile: %d Tile asked for: %d", ghack_glyphs.count,
|
||||
tile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ghack_glyphs.im == NULL)
|
||||
{
|
||||
g_warning("Aiiee! I've been asked to clone from a null image.\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning( "making image from tile %d, force=%s\n", tile,
|
||||
(force==TRUE)? "TRUE": "FALSE");
|
||||
if (ghack_glyphs.im == NULL) {
|
||||
g_warning("Aiiee! I've been asked to clone from a null image.\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning("making image from tile %d, force=%s\n", tile,
|
||||
(force == TRUE) ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
if (force == TRUE)
|
||||
{
|
||||
g_warning("Aiiee! I've been asked to force rendering.\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning( "making image from tile %d, force=%s\n", tile,
|
||||
(force==TRUE)? "TRUE" : "FALSE");
|
||||
if (force == TRUE) {
|
||||
g_warning("Aiiee! I've been asked to force rendering.\n"
|
||||
"Email this to other-gnomehack@lists.debian.org");
|
||||
g_warning("making image from tile %d, force=%s\n", tile,
|
||||
(force == TRUE) ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
if (!ghack_tiles[tile] || force) {
|
||||
int src_x, src_y;
|
||||
if (!ghack_tiles[tile] || force) {
|
||||
int src_x, src_y;
|
||||
#if 0
|
||||
fprintf( stderr, "crop_and_clone: glyph=%d, tile=%d, ptr=%p, x=%d, y=%d, w=%d, h=%d\n", glyph, tile,
|
||||
(void*)&(ghack_tiles[tile]), 0,
|
||||
@@ -207,26 +201,23 @@ ghack_image_from_glyph( int glyph, gboolean force )
|
||||
ghack_glyphs.height,
|
||||
ghack_glyphs.width);
|
||||
#endif
|
||||
if (ghack_glyphs.im->pixmap == NULL)
|
||||
g_warning( "Aiiee! ghack_glyphs.im->pixmap==NULL!!!!\n");
|
||||
src_x = (tile % TILES_PER_ROW) * ghack_glyphs.width;
|
||||
src_y = (tile / TILES_PER_ROW) * ghack_glyphs.height;
|
||||
ghack_tiles[tile] = gdk_imlib_crop_and_clone_image(ghack_glyphs.im,
|
||||
src_x, src_y,
|
||||
ghack_glyphs.width,
|
||||
ghack_glyphs.height);
|
||||
}
|
||||
if (ghack_glyphs.im->pixmap == NULL)
|
||||
g_warning("Aiiee! ghack_glyphs.im->pixmap==NULL!!!!\n");
|
||||
src_x = (tile % TILES_PER_ROW) * ghack_glyphs.width;
|
||||
src_y = (tile / TILES_PER_ROW) * ghack_glyphs.height;
|
||||
ghack_tiles[tile] = gdk_imlib_crop_and_clone_image(
|
||||
ghack_glyphs.im, src_x, src_y, ghack_glyphs.width,
|
||||
ghack_glyphs.height);
|
||||
}
|
||||
|
||||
if (ghack_tiles[tile] && (!ghack_tiles[tile]->pixmap || force))
|
||||
{
|
||||
if ( gdk_imlib_render(ghack_tiles[tile],
|
||||
ghack_tiles[tile]->rgb_width,
|
||||
ghack_tiles[tile]->rgb_height) == 0) {
|
||||
g_error("GLYPH: couldn't create tile # %d", tile);
|
||||
}
|
||||
if ( !ghack_tiles[tile]->pixmap )
|
||||
g_error("Strange, tile # %d didn't get rendered???", tile);
|
||||
}
|
||||
if (ghack_tiles[tile] && (!ghack_tiles[tile]->pixmap || force)) {
|
||||
if (gdk_imlib_render(ghack_tiles[tile], ghack_tiles[tile]->rgb_width,
|
||||
ghack_tiles[tile]->rgb_height) == 0) {
|
||||
g_error("GLYPH: couldn't create tile # %d", tile);
|
||||
}
|
||||
if (!ghack_tiles[tile]->pixmap)
|
||||
g_error("Strange, tile # %d didn't get rendered???", tile);
|
||||
}
|
||||
|
||||
return ghack_tiles[tile];
|
||||
return ghack_tiles[tile];
|
||||
}
|
||||
|
||||
+450
-604
File diff suppressed because it is too large
Load Diff
+368
-458
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnmap.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnmap.c $NHDT-Date: 1431192773 2015/05/09 17:32:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
|
||||
/* NetHack 3.6 gnmap.c $Date: 2009/05/06 10:57:34 $ $Revision: 1.6 $ */
|
||||
/* SCCS Id: @(#)gnmap.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -17,29 +17,30 @@
|
||||
|
||||
/* globals static to this file go here */
|
||||
struct {
|
||||
GnomeCanvas *canvas;
|
||||
GnomeCanvasImage *map[(ROWNO + 1) * COLNO];
|
||||
GnomeCanvasImage *overlay[(ROWNO + 1) * COLNO];
|
||||
double zoom;
|
||||
GtkWidget *frame;
|
||||
GnomeCanvas *canvas;
|
||||
GnomeCanvasImage *map[(ROWNO + 1) * COLNO];
|
||||
GnomeCanvasImage *overlay[(ROWNO + 1) * COLNO];
|
||||
double zoom;
|
||||
GtkWidget *frame;
|
||||
} ghack_map;
|
||||
|
||||
|
||||
static GdkImlibImage *background;
|
||||
static GdkImlibImage *petmark;
|
||||
static GnomeCanvasGroup *myCanvasGroup;
|
||||
|
||||
/* static function declarations -- local to this file go here */
|
||||
void ghack_map_cursor_to( GtkWidget *win, int x, int y, gpointer data);
|
||||
void ghack_map_putstr( GtkWidget *win, int attr, const char* text, gpointer data);
|
||||
void ghack_map_print_glyph( GtkObject *win, guint x, guint y, GdkImlibImage *im, gpointer data);
|
||||
void ghack_map_clear( GtkWidget *win, gpointer data);
|
||||
static void ghack_map_display( GtkWidget *win, boolean block, gpointer data);
|
||||
static void ghack_map_cliparound( GtkWidget *win, int x, int y, gpointer data);
|
||||
static void ghack_map_window_zoom( GtkAdjustment *adj, gpointer data);
|
||||
|
||||
void ghack_map_cursor_to(GtkWidget *win, int x, int y, gpointer data);
|
||||
void ghack_map_putstr(GtkWidget *win, int attr, const char *text,
|
||||
gpointer data);
|
||||
void ghack_map_print_glyph(GtkObject *win, guint x, guint y,
|
||||
GdkImlibImage *im, gpointer data);
|
||||
void ghack_map_clear(GtkWidget *win, gpointer data);
|
||||
static void ghack_map_display(GtkWidget *win, boolean block, gpointer data);
|
||||
static void ghack_map_cliparound(GtkWidget *win, int x, int y, gpointer data);
|
||||
static void ghack_map_window_zoom(GtkAdjustment *adj, gpointer data);
|
||||
|
||||
/* The following XPM is the artwork of Warwick Allison
|
||||
* <warwick@troll.no>. It has been borrowed from
|
||||
* <warwick@troll.no>. It has been borrowed from
|
||||
* the most excellent NetHackQt, until such time as
|
||||
* we can come up with something better.
|
||||
*
|
||||
@@ -49,23 +50,16 @@ static void ghack_map_window_zoom( GtkAdjustment *adj, gpointer data);
|
||||
|
||||
/* XPM */
|
||||
static char *pet_mark_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"8 7 2 1",
|
||||
/* colors */
|
||||
". c None",
|
||||
" c #FF0000",
|
||||
/* pixels */
|
||||
"........",
|
||||
".. . .",
|
||||
". ",
|
||||
". ",
|
||||
".. .",
|
||||
"... ..",
|
||||
".... ..."
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"8 7 2 1",
|
||||
/* colors */
|
||||
". c None", " c #FF0000",
|
||||
/* pixels */
|
||||
"........", ".. . .", ". ", ". ",
|
||||
".. .", "... ..", ".... ..."
|
||||
};
|
||||
|
||||
|
||||
/* NAME:
|
||||
/* NAME:
|
||||
* ghack_init_map_window( )
|
||||
*
|
||||
* ARGUMENTS:
|
||||
@@ -81,234 +75,191 @@ static char *pet_mark_xpm[] = {
|
||||
* to behave properly.
|
||||
*/
|
||||
|
||||
GtkWidget*
|
||||
ghack_init_map_window ( )
|
||||
GtkWidget *
|
||||
ghack_init_map_window()
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *w;
|
||||
GtkWidget *hSeparator;
|
||||
GtkAdjustment *adj;
|
||||
GnomeCanvasImage *bg;
|
||||
double width, height, x, y;
|
||||
int i;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *w;
|
||||
GtkWidget *hSeparator;
|
||||
GtkAdjustment *adj;
|
||||
GnomeCanvasImage *bg;
|
||||
double width, height, x, y;
|
||||
int i;
|
||||
|
||||
width = COLNO * ghack_glyph_width();
|
||||
height = ROWNO * ghack_glyph_height();
|
||||
width = COLNO * ghack_glyph_width();
|
||||
height = ROWNO * ghack_glyph_height();
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* Add in a horiz seperator */
|
||||
hSeparator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hSeparator, FALSE, FALSE, 2);
|
||||
gtk_widget_show ( hSeparator);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
vbox = gtk_vbox_new(FALSE, 4);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
/* Create the Zoom spinbutton.
|
||||
*/
|
||||
ghack_map.zoom = 1.0;
|
||||
w = gtk_label_new ("Zoom:");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (w);
|
||||
adj = GTK_ADJUSTMENT (gtk_adjustment_new (1.00, 0.5, 3.00, 0.05, 0.50, 0.50));
|
||||
w = gtk_spin_button_new (adj, 0.5, 2);
|
||||
gtk_widget_set_usize (w, 50, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (w);
|
||||
/* Add in a horiz seperator */
|
||||
hSeparator = gtk_hseparator_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hSeparator, FALSE, FALSE, 2);
|
||||
gtk_widget_show(hSeparator);
|
||||
|
||||
/* Canvas and scrollbars
|
||||
*/
|
||||
gtk_widget_push_visual (gdk_imlib_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_imlib_get_colormap ());
|
||||
ghack_map.canvas = GNOME_CANVAS (gnome_canvas_new());
|
||||
//gtk_widget_push_visual(gdk_rgb_get_visual());
|
||||
//gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
||||
//ghack_map.canvas = GNOME_CANVAS (gnome_canvas_new_aa());
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(hbox);
|
||||
|
||||
gtk_widget_pop_colormap();
|
||||
gtk_widget_pop_visual();
|
||||
gtk_widget_show (GTK_WIDGET(ghack_map.canvas));
|
||||
/* Create the Zoom spinbutton.
|
||||
*/
|
||||
ghack_map.zoom = 1.0;
|
||||
w = gtk_label_new("Zoom:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
|
||||
gtk_widget_show(w);
|
||||
adj =
|
||||
GTK_ADJUSTMENT(gtk_adjustment_new(1.00, 0.5, 3.00, 0.05, 0.50, 0.50));
|
||||
w = gtk_spin_button_new(adj, 0.5, 2);
|
||||
gtk_widget_set_usize(w, 50, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
|
||||
gtk_widget_show(w);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
ghack_map.frame = frame;
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_table_attach (GTK_TABLE (table), frame,
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
0, 0);
|
||||
gtk_widget_show (frame);
|
||||
/* Canvas and scrollbars
|
||||
*/
|
||||
gtk_widget_push_visual(gdk_imlib_get_visual());
|
||||
gtk_widget_push_colormap(gdk_imlib_get_colormap());
|
||||
ghack_map.canvas = GNOME_CANVAS(gnome_canvas_new());
|
||||
// gtk_widget_push_visual(gdk_rgb_get_visual());
|
||||
// gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
||||
// ghack_map.canvas = GNOME_CANVAS (gnome_canvas_new_aa());
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(ghack_map.canvas));
|
||||
gnome_canvas_set_scroll_region (GNOME_CANVAS(ghack_map.canvas), 0, 0,
|
||||
width+2*ghack_glyph_width(), height+2*ghack_glyph_height());
|
||||
gtk_widget_pop_colormap();
|
||||
gtk_widget_pop_visual();
|
||||
gtk_widget_show(GTK_WIDGET(ghack_map.canvas));
|
||||
|
||||
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS(ghack_map.canvas), 1.0);
|
||||
table = gtk_table_new(2, 2, FALSE);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(table), 4);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(table), 4);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
|
||||
gtk_widget_show(table);
|
||||
|
||||
w = gtk_hscrollbar_new (GTK_LAYOUT (ghack_map.canvas)->hadjustment);
|
||||
gtk_table_attach (GTK_TABLE (table), w,
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
GTK_FILL,
|
||||
0, 0);
|
||||
gtk_widget_show (w);
|
||||
frame = gtk_frame_new(NULL);
|
||||
ghack_map.frame = frame;
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
|
||||
gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
|
||||
gtk_widget_show(frame);
|
||||
|
||||
w = gtk_vscrollbar_new (GTK_LAYOUT (ghack_map.canvas)->vadjustment);
|
||||
gtk_table_attach (GTK_TABLE (table), w,
|
||||
1, 2, 0, 1, GTK_FILL,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
0, 0);
|
||||
gtk_widget_show (w);
|
||||
|
||||
myCanvasGroup = GNOME_CANVAS_GROUP ( gnome_canvas_item_new (
|
||||
gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
|
||||
gnome_canvas_group_get_type (),
|
||||
"x", 0.0,
|
||||
"y", 0.0,
|
||||
NULL) );
|
||||
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(ghack_map.canvas));
|
||||
gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
|
||||
width + 2 * ghack_glyph_width(),
|
||||
height + 2 * ghack_glyph_height());
|
||||
|
||||
/* Tile the map background with a pretty image */
|
||||
background = gdk_imlib_load_image((char *) "mapbg.xpm");
|
||||
if (background == NULL) {
|
||||
g_warning("Bummer! Failed to load the map background image (mapbg.xpm)!");
|
||||
}
|
||||
else {
|
||||
gdk_imlib_render(background, background->rgb_width,
|
||||
background->rgb_height);
|
||||
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(ghack_map.canvas), 1.0);
|
||||
|
||||
/* Tile the map background */
|
||||
for (y = 0; y < height+background->rgb_height; y+=background->rgb_height)
|
||||
{
|
||||
for (x = 0; x < width+background->rgb_width; x+=background->rgb_width)
|
||||
{
|
||||
bg = GNOME_CANVAS_IMAGE( gnome_canvas_item_new (
|
||||
myCanvasGroup, gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) background->rgb_width,
|
||||
"height", (double) background->rgb_height,
|
||||
"image", background,
|
||||
"anchor", (GtkAnchorType) GTK_ANCHOR_CENTER,
|
||||
NULL) );
|
||||
gnome_canvas_item_lower_to_bottom (GNOME_CANVAS_ITEM( bg));
|
||||
}
|
||||
}
|
||||
}
|
||||
w = gtk_hscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->hadjustment);
|
||||
gtk_table_attach(GTK_TABLE(table), w, 0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
|
||||
gtk_widget_show(w);
|
||||
|
||||
/* ghack_map.map is an array of canvas images. Each cell of
|
||||
* the array will contain one tile. Here, we create the
|
||||
* space for the cells and then create the cells for easy
|
||||
* access later.
|
||||
*/
|
||||
for (i=0, y = 0; y < height; y+=ghack_glyph_height())
|
||||
{
|
||||
for (x = 0; x < width; x+=ghack_glyph_width())
|
||||
{
|
||||
ghack_map.map[i++] = GNOME_CANVAS_IMAGE(
|
||||
gnome_canvas_item_new (
|
||||
myCanvasGroup,
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(),
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
}
|
||||
w = gtk_vscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->vadjustment);
|
||||
gtk_table_attach(GTK_TABLE(table), w, 1, 2, 0, 1, GTK_FILL,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
|
||||
gtk_widget_show(w);
|
||||
|
||||
myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
|
||||
gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));
|
||||
|
||||
/* Tile the map background with a pretty image */
|
||||
background = gdk_imlib_load_image((char *) "mapbg.xpm");
|
||||
if (background == NULL) {
|
||||
g_warning(
|
||||
"Bummer! Failed to load the map background image (mapbg.xpm)!");
|
||||
} else {
|
||||
gdk_imlib_render(background, background->rgb_width,
|
||||
background->rgb_height);
|
||||
|
||||
/* Tile the map background */
|
||||
for (y = 0; y < height + background->rgb_height;
|
||||
y += background->rgb_height) {
|
||||
for (x = 0; x < width + background->rgb_width;
|
||||
x += background->rgb_width) {
|
||||
bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x",
|
||||
(double) x, "y", (double) y, "width",
|
||||
(double) background->rgb_width, "height",
|
||||
(double) background->rgb_height, "image", background,
|
||||
"anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
|
||||
gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the pet mark image */
|
||||
petmark = gdk_imlib_create_image_from_xpm_data( pet_mark_xpm);
|
||||
if (petmark == NULL) {
|
||||
g_warning("Bummer! Failed to load the pet_mark image!");
|
||||
}
|
||||
else {
|
||||
gdk_imlib_render(petmark, petmark->rgb_width, petmark->rgb_height);
|
||||
/* ghack_map.map is an array of canvas images. Each cell of
|
||||
* the array will contain one tile. Here, we create the
|
||||
* space for the cells and then create the cells for easy
|
||||
* access later.
|
||||
*/
|
||||
for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x += ghack_glyph_width()) {
|
||||
ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
|
||||
"y", (double) y, "width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(), "anchor",
|
||||
GTK_ANCHOR_NORTH_WEST, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
/* ghack_map.overlay is an array of canvas images used to
|
||||
* overlay tile images...
|
||||
*/
|
||||
for (i=0, y = 0; y < height; y+=ghack_glyph_height())
|
||||
{
|
||||
for (x = 0; x < width; x+=ghack_glyph_width())
|
||||
{
|
||||
ghack_map.overlay[i] = GNOME_CANVAS_IMAGE(
|
||||
gnome_canvas_item_new (
|
||||
myCanvasGroup,
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) petmark->rgb_width,
|
||||
"height", (double) petmark->rgb_height,
|
||||
"image", petmark,
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
gnome_canvas_item_lower_to_bottom (
|
||||
GNOME_CANVAS_ITEM( ghack_map.overlay[i++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Set up the pet mark image */
|
||||
petmark = gdk_imlib_create_image_from_xpm_data(pet_mark_xpm);
|
||||
if (petmark == NULL) {
|
||||
g_warning("Bummer! Failed to load the pet_mark image!");
|
||||
} else {
|
||||
gdk_imlib_render(petmark, petmark->rgb_width, petmark->rgb_height);
|
||||
|
||||
/* Resize the canvas when the spinbutton changes
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (adj),
|
||||
"value_changed",
|
||||
(GtkSignalFunc) ghack_map_window_zoom,
|
||||
ghack_map.canvas);
|
||||
/* ghack_map.overlay is an array of canvas images used to
|
||||
* overlay tile images...
|
||||
*/
|
||||
for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x += ghack_glyph_width()) {
|
||||
ghack_map.overlay[i] =
|
||||
GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x",
|
||||
(double) x, "y", (double) y, "width",
|
||||
(double) petmark->rgb_width, "height",
|
||||
(double) petmark->rgb_height, "image", petmark,
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST, NULL));
|
||||
gnome_canvas_item_lower_to_bottom(
|
||||
GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Game signals
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_curs",
|
||||
GTK_SIGNAL_FUNC (ghack_map_cursor_to),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_putstr",
|
||||
GTK_SIGNAL_FUNC (ghack_map_putstr),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_print_glyph",
|
||||
GTK_SIGNAL_FUNC (ghack_map_print_glyph),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_clear",
|
||||
GTK_SIGNAL_FUNC (ghack_map_clear),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_display",
|
||||
GTK_SIGNAL_FUNC (ghack_map_display),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (vbox),
|
||||
"ghack_cliparound",
|
||||
GTK_SIGNAL_FUNC (ghack_map_cliparound),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (ghack_map.canvas),
|
||||
"button_press_event",
|
||||
GTK_SIGNAL_FUNC (ghack_handle_button_press),
|
||||
NULL);
|
||||
gtk_signal_connect(GTK_OBJECT (ghack_map.canvas),
|
||||
"gnome_delay_output",
|
||||
GTK_SIGNAL_FUNC(ghack_delay),
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET(vbox);
|
||||
/* Resize the canvas when the spinbutton changes
|
||||
*/
|
||||
gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
|
||||
(GtkSignalFunc) ghack_map_window_zoom,
|
||||
ghack_map.canvas);
|
||||
|
||||
/* Game signals
|
||||
*/
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_curs",
|
||||
GTK_SIGNAL_FUNC(ghack_map_cursor_to), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_putstr",
|
||||
GTK_SIGNAL_FUNC(ghack_map_putstr), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_print_glyph",
|
||||
GTK_SIGNAL_FUNC(ghack_map_print_glyph), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_clear",
|
||||
GTK_SIGNAL_FUNC(ghack_map_clear), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_display",
|
||||
GTK_SIGNAL_FUNC(ghack_map_display), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(vbox), "ghack_cliparound",
|
||||
GTK_SIGNAL_FUNC(ghack_map_cliparound), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "button_press_event",
|
||||
GTK_SIGNAL_FUNC(ghack_handle_button_press), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "gnome_delay_output",
|
||||
GTK_SIGNAL_FUNC(ghack_delay), NULL);
|
||||
|
||||
return GTK_WIDGET(vbox);
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
/* NAME:
|
||||
* ghack_map_window_zoom
|
||||
*
|
||||
* ARGUMENTS:
|
||||
@@ -324,67 +275,59 @@ ghack_init_map_window ( )
|
||||
*/
|
||||
|
||||
static void
|
||||
ghack_map_window_zoom( GtkAdjustment *adj, gpointer data)
|
||||
ghack_map_window_zoom(GtkAdjustment *adj, gpointer data)
|
||||
{
|
||||
if ( adj->value > 3.0 )
|
||||
adj->value = 3.0;
|
||||
if ( adj->value < 0.5 )
|
||||
adj->value = 0.5;
|
||||
ghack_map.zoom = adj->value;
|
||||
gnome_canvas_set_pixels_per_unit (data, adj->value);
|
||||
if (adj->value > 3.0)
|
||||
adj->value = 3.0;
|
||||
if (adj->value < 0.5)
|
||||
adj->value = 0.5;
|
||||
ghack_map.zoom = adj->value;
|
||||
gnome_canvas_set_pixels_per_unit(data, adj->value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ghack_map_cursor_to( GtkWidget *win, int x, int y, gpointer data)
|
||||
ghack_map_cursor_to(GtkWidget *win, int x, int y, gpointer data)
|
||||
{
|
||||
GnomeCanvasGroup *group;
|
||||
static GnomeCanvasRE *cursor = NULL;
|
||||
GnomeCanvasGroup *group;
|
||||
static GnomeCanvasRE *cursor = NULL;
|
||||
|
||||
double x1, y1, x2, y2;
|
||||
float hp;
|
||||
guint r, g, b;
|
||||
double x1, y1, x2, y2;
|
||||
float hp;
|
||||
guint r, g, b;
|
||||
|
||||
x1 = x * ghack_glyph_width() - 1;
|
||||
y1 = y * ghack_glyph_height() - 1;
|
||||
x2 = x1 + ghack_glyph_width() + 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);
|
||||
x1 = x * ghack_glyph_width() - 1;
|
||||
y1 = y * ghack_glyph_height() - 1;
|
||||
x2 = x1 + ghack_glyph_width() + 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));
|
||||
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) {
|
||||
cursor = GNOME_CANVAS_RE (gnome_canvas_item_new (group,
|
||||
gnome_canvas_rect_get_type (),
|
||||
"width_units", 1.0, NULL));
|
||||
}
|
||||
gnome_canvas_item_set (GNOME_CANVAS_ITEM (cursor),
|
||||
"outline_color_rgba", GNOME_CANVAS_COLOR(r, g, b),
|
||||
"x1", x1,
|
||||
"y1", y1,
|
||||
"x2", x2,
|
||||
"y2", y2,
|
||||
NULL);
|
||||
if (!cursor) {
|
||||
cursor = GNOME_CANVAS_RE(gnome_canvas_item_new(
|
||||
group, gnome_canvas_rect_get_type(), "width_units", 1.0, NULL));
|
||||
}
|
||||
gnome_canvas_item_set(GNOME_CANVAS_ITEM(cursor), "outline_color_rgba",
|
||||
GNOME_CANVAS_COLOR(r, g, b), "x1", x1, "y1", y1,
|
||||
"x2", x2, "y2", y2, NULL);
|
||||
|
||||
gnome_canvas_item_raise_to_top( GNOME_CANVAS_ITEM( cursor));
|
||||
gnome_canvas_item_show( GNOME_CANVAS_ITEM(cursor));
|
||||
gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(cursor));
|
||||
gnome_canvas_item_show(GNOME_CANVAS_ITEM(cursor));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ghack_map_putstr( GtkWidget *win, int attr, const char* text, gpointer data)
|
||||
ghack_map_putstr(GtkWidget *win, int attr, const char *text, gpointer data)
|
||||
{
|
||||
g_warning("Fixme!!! ghack_map_putstr is not implemented");
|
||||
}
|
||||
|
||||
/* NAME:
|
||||
/* NAME:
|
||||
* ghack_map_print_glyph( )
|
||||
*
|
||||
* ARGUMENTS:
|
||||
@@ -399,43 +342,37 @@ ghack_map_putstr( GtkWidget *win, int attr, const char* text, gpointer data)
|
||||
*/
|
||||
|
||||
void
|
||||
ghack_map_print_glyph( GtkObject *win,
|
||||
guint x,
|
||||
guint y,
|
||||
GdkImlibImage *im,
|
||||
gpointer data)
|
||||
ghack_map_print_glyph(GtkObject *win, guint x, guint y, GdkImlibImage *im,
|
||||
gpointer data)
|
||||
{
|
||||
GnomeCanvasGroup *group;
|
||||
int i = y * COLNO + x;
|
||||
int glyph = glyph_at(x,y);
|
||||
GnomeCanvasImage *canvas_image = GNOME_CANVAS_IMAGE( ghack_map.map[i]);
|
||||
GnomeCanvasGroup *group;
|
||||
int i = y * COLNO + x;
|
||||
int glyph = glyph_at(x, y);
|
||||
GnomeCanvasImage *canvas_image = GNOME_CANVAS_IMAGE(ghack_map.map[i]);
|
||||
|
||||
group = gnome_canvas_root (GNOME_CANVAS (ghack_map.canvas));
|
||||
|
||||
gnome_canvas_item_set (GNOME_CANVAS_ITEM ( canvas_image),
|
||||
"image", im, NULL);
|
||||
gnome_canvas_item_show( GNOME_CANVAS_ITEM( canvas_image));
|
||||
group = gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas));
|
||||
|
||||
canvas_image = GNOME_CANVAS_IMAGE( ghack_map.overlay[i]);
|
||||
gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_image), "image", im, NULL);
|
||||
gnome_canvas_item_show(GNOME_CANVAS_ITEM(canvas_image));
|
||||
|
||||
if (x==u.ux && y==u.uy)
|
||||
ghack_map_cliparound(NULL, x, y, NULL);
|
||||
canvas_image = GNOME_CANVAS_IMAGE(ghack_map.overlay[i]);
|
||||
|
||||
if (glyph_is_pet(glyph)
|
||||
if (x == u.ux && y == u.uy)
|
||||
ghack_map_cliparound(NULL, x, y, NULL);
|
||||
|
||||
if (glyph_is_pet(glyph)
|
||||
#ifdef TEXTCOLOR
|
||||
&& iflags.hilite_pet
|
||||
&& iflags.hilite_pet
|
||||
#endif
|
||||
) {
|
||||
gnome_canvas_item_raise_to_top( GNOME_CANVAS_ITEM( canvas_image));
|
||||
gnome_canvas_item_show( GNOME_CANVAS_ITEM( canvas_image));
|
||||
}
|
||||
else {
|
||||
gnome_canvas_item_hide( GNOME_CANVAS_ITEM( canvas_image));
|
||||
}
|
||||
) {
|
||||
gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(canvas_image));
|
||||
gnome_canvas_item_show(GNOME_CANVAS_ITEM(canvas_image));
|
||||
} else {
|
||||
gnome_canvas_item_hide(GNOME_CANVAS_ITEM(canvas_image));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* NAME:
|
||||
/* NAME:
|
||||
* ghack_map_clear( )
|
||||
*
|
||||
* ARGUMENTS:
|
||||
@@ -449,173 +386,146 @@ ghack_map_print_glyph( GtkObject *win,
|
||||
*/
|
||||
|
||||
void
|
||||
ghack_map_clear( GtkWidget *win, gpointer data)
|
||||
ghack_map_clear(GtkWidget *win, gpointer data)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ROWNO * COLNO; i++)
|
||||
{
|
||||
if (GNOME_IS_CANVAS_IMAGE(ghack_map.map[i]))
|
||||
{
|
||||
gnome_canvas_item_hide( GNOME_CANVAS_ITEM (ghack_map.map[i]));
|
||||
}
|
||||
if (GNOME_IS_CANVAS_IMAGE(ghack_map.overlay[i]))
|
||||
{
|
||||
gnome_canvas_item_hide( GNOME_CANVAS_ITEM (ghack_map.overlay[i]));
|
||||
}
|
||||
for (i = 0; i < ROWNO * COLNO; i++) {
|
||||
if (GNOME_IS_CANVAS_IMAGE(ghack_map.map[i])) {
|
||||
gnome_canvas_item_hide(GNOME_CANVAS_ITEM(ghack_map.map[i]));
|
||||
}
|
||||
if (GNOME_IS_CANVAS_IMAGE(ghack_map.overlay[i])) {
|
||||
gnome_canvas_item_hide(GNOME_CANVAS_ITEM(ghack_map.overlay[i]));
|
||||
}
|
||||
}
|
||||
gnome_canvas_update_now ( GNOME_CANVAS(ghack_map.canvas));
|
||||
gnome_canvas_update_now(GNOME_CANVAS(ghack_map.canvas));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ghack_map_display( GtkWidget *win, boolean block, gpointer data)
|
||||
ghack_map_display(GtkWidget *win, boolean block, gpointer data)
|
||||
{
|
||||
gtk_widget_show_all( GTK_WIDGET(win));
|
||||
gtk_widget_show_all(GTK_WIDGET(win));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ghack_map_cliparound( GtkWidget *win,
|
||||
int x,
|
||||
int y,
|
||||
gpointer data)
|
||||
ghack_map_cliparound(GtkWidget *win, int x, int y, gpointer data)
|
||||
{
|
||||
int map_width, map_height;
|
||||
int to_x, to_y;
|
||||
int cur_x, cur_y;
|
||||
int width, height, half_width, half_height;
|
||||
int map_width, map_height;
|
||||
int to_x, to_y;
|
||||
int cur_x, cur_y;
|
||||
int width, height, half_width, half_height;
|
||||
|
||||
x *= ghack_glyph_width() * ghack_map.zoom;
|
||||
y *= ghack_glyph_height() * ghack_map.zoom;
|
||||
map_width = COLNO * ghack_glyph_width() * ghack_map.zoom;
|
||||
map_height = ROWNO * ghack_glyph_height() * ghack_map.zoom;
|
||||
x *= ghack_glyph_width() * ghack_map.zoom;
|
||||
y *= ghack_glyph_height() * ghack_map.zoom;
|
||||
map_width = COLNO * ghack_glyph_width() * ghack_map.zoom;
|
||||
map_height = ROWNO * ghack_glyph_height() * ghack_map.zoom;
|
||||
|
||||
gdk_window_get_size( GTK_LAYOUT (ghack_map.canvas)->bin_window,
|
||||
&width, &height);
|
||||
gnome_canvas_get_scroll_offsets( ghack_map.canvas, &cur_x, &cur_y);
|
||||
gdk_window_get_size(GTK_LAYOUT(ghack_map.canvas)->bin_window, &width,
|
||||
&height);
|
||||
gnome_canvas_get_scroll_offsets(ghack_map.canvas, &cur_x, &cur_y);
|
||||
|
||||
half_width = width * 0.5;
|
||||
half_height = height * 0.5;
|
||||
half_width = width * 0.5;
|
||||
half_height = height * 0.5;
|
||||
|
||||
if ( ((x - cur_x) < (width * 0.25) ) || ( (x - cur_x) > (width * 0.75) ) ) {
|
||||
to_x = ((x-half_width) > 0)? x - half_width : 0;
|
||||
to_x = ((x+half_width) > map_width)? map_width - 2 * half_width : to_x;
|
||||
}
|
||||
else {
|
||||
to_x = cur_x;
|
||||
}
|
||||
|
||||
if ( ((y - cur_y) < (height * 0.25) ) || ( (y - cur_y) > (height * 0.75) ) ) {
|
||||
to_y = ((y-half_height) > 0)? y - half_height : 0;
|
||||
to_y = ((y+half_height) > map_height)? map_height - 2 * half_height : to_y;
|
||||
}
|
||||
else {
|
||||
to_y = cur_y;
|
||||
}
|
||||
|
||||
if (to_x != cur_x || to_y != cur_y)
|
||||
gnome_canvas_scroll_to( ghack_map.canvas, to_x, to_y);
|
||||
//gnome_canvas_update_now ( ghack_map.canvas);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ghack_reinit_map_window ( )
|
||||
{
|
||||
GnomeCanvasImage *bg;
|
||||
double width, height, x, y;
|
||||
int i;
|
||||
|
||||
/* ghack_map_clear(NULL, NULL); */
|
||||
|
||||
width = COLNO * ghack_glyph_width();
|
||||
height = ROWNO * ghack_glyph_height();
|
||||
|
||||
gnome_canvas_set_scroll_region (GNOME_CANVAS(ghack_map.canvas), 0, 0,
|
||||
width+2*ghack_glyph_width(), height+2*ghack_glyph_height());
|
||||
|
||||
/* remove everything currently in the canvas map */
|
||||
gtk_object_destroy( GTK_OBJECT (myCanvasGroup));
|
||||
|
||||
/* Put some groups back */
|
||||
myCanvasGroup = GNOME_CANVAS_GROUP ( gnome_canvas_item_new (
|
||||
gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
|
||||
gnome_canvas_group_get_type (),
|
||||
"x", 0.0,
|
||||
"y", 0.0,
|
||||
NULL) );
|
||||
|
||||
/* Tile the map background with a pretty image */
|
||||
if (background != NULL) {
|
||||
/* Tile the map background */
|
||||
for (y = 0; y < height+background->rgb_height; y+=background->rgb_height)
|
||||
{
|
||||
for (x = 0; x < width+background->rgb_width; x+=background->rgb_width)
|
||||
{
|
||||
bg = GNOME_CANVAS_IMAGE( gnome_canvas_item_new (
|
||||
myCanvasGroup, gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) background->rgb_width,
|
||||
"height", (double) background->rgb_height,
|
||||
"image", background,
|
||||
"anchor", (GtkAnchorType) GTK_ANCHOR_CENTER,
|
||||
NULL) );
|
||||
gnome_canvas_item_lower_to_bottom (GNOME_CANVAS_ITEM( bg));
|
||||
}
|
||||
if (((x - cur_x) < (width * 0.25)) || ((x - cur_x) > (width * 0.75))) {
|
||||
to_x = ((x - half_width) > 0) ? x - half_width : 0;
|
||||
to_x = ((x + half_width) > map_width) ? map_width - 2 * half_width
|
||||
: to_x;
|
||||
} else {
|
||||
to_x = cur_x;
|
||||
}
|
||||
}
|
||||
|
||||
/* ghack_map.map is an array of canvas images. Each cell of
|
||||
* the array will contain one tile. Here, we create the
|
||||
* space for the cells and then create the cells for easy
|
||||
* access later.
|
||||
*/
|
||||
for (i=0, y = 0; y < height; y+=ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x+=ghack_glyph_width()) {
|
||||
ghack_map.map[i++] = GNOME_CANVAS_IMAGE(
|
||||
gnome_canvas_item_new (
|
||||
myCanvasGroup,
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(),
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
}
|
||||
}
|
||||
|
||||
if (petmark != NULL) {
|
||||
/* ghack_map.overlay is an array of canvas images used to
|
||||
* overlay tile images...
|
||||
*/
|
||||
for (i=0, y = 0; y < height; y+=ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x+=ghack_glyph_width()) {
|
||||
ghack_map.overlay[i] = GNOME_CANVAS_IMAGE(
|
||||
gnome_canvas_item_new (
|
||||
myCanvasGroup,
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) petmark->rgb_width,
|
||||
"height", (double) petmark->rgb_height,
|
||||
"image", petmark,
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
gnome_canvas_item_lower_to_bottom (
|
||||
GNOME_CANVAS_ITEM( ghack_map.overlay[i++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((y - cur_y) < (height * 0.25)) || ((y - cur_y) > (height * 0.75))) {
|
||||
to_y = ((y - half_height) > 0) ? y - half_height : 0;
|
||||
to_y = ((y + half_height) > map_height) ? map_height - 2 * half_height
|
||||
: to_y;
|
||||
} else {
|
||||
to_y = cur_y;
|
||||
}
|
||||
|
||||
ghack_map_cliparound(NULL, u.ux, u.uy, NULL);
|
||||
ghack_map_cursor_to(NULL, u.ux, u.uy, NULL);
|
||||
gnome_canvas_update_now ( ghack_map.canvas);
|
||||
doredraw();
|
||||
if (to_x != cur_x || to_y != cur_y)
|
||||
gnome_canvas_scroll_to(ghack_map.canvas, to_x, to_y);
|
||||
// gnome_canvas_update_now ( ghack_map.canvas);
|
||||
}
|
||||
|
||||
void
|
||||
ghack_reinit_map_window()
|
||||
{
|
||||
GnomeCanvasImage *bg;
|
||||
double width, height, x, y;
|
||||
int i;
|
||||
|
||||
/* ghack_map_clear(NULL, NULL); */
|
||||
|
||||
width = COLNO * ghack_glyph_width();
|
||||
height = ROWNO * ghack_glyph_height();
|
||||
|
||||
gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
|
||||
width + 2 * ghack_glyph_width(),
|
||||
height + 2 * ghack_glyph_height());
|
||||
|
||||
/* remove everything currently in the canvas map */
|
||||
gtk_object_destroy(GTK_OBJECT(myCanvasGroup));
|
||||
|
||||
/* Put some groups back */
|
||||
myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
|
||||
gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));
|
||||
|
||||
/* Tile the map background with a pretty image */
|
||||
if (background != NULL) {
|
||||
/* Tile the map background */
|
||||
for (y = 0; y < height + background->rgb_height;
|
||||
y += background->rgb_height) {
|
||||
for (x = 0; x < width + background->rgb_width;
|
||||
x += background->rgb_width) {
|
||||
bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x",
|
||||
(double) x, "y", (double) y, "width",
|
||||
(double) background->rgb_width, "height",
|
||||
(double) background->rgb_height, "image", background,
|
||||
"anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
|
||||
gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ghack_map.map is an array of canvas images. Each cell of
|
||||
* the array will contain one tile. Here, we create the
|
||||
* space for the cells and then create the cells for easy
|
||||
* access later.
|
||||
*/
|
||||
for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x += ghack_glyph_width()) {
|
||||
ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
|
||||
"y", (double) y, "width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(), "anchor",
|
||||
GTK_ANCHOR_NORTH_WEST, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
if (petmark != NULL) {
|
||||
/* ghack_map.overlay is an array of canvas images used to
|
||||
* overlay tile images...
|
||||
*/
|
||||
for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
|
||||
for (x = 0; x < width; x += ghack_glyph_width()) {
|
||||
ghack_map.overlay[i] =
|
||||
GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
|
||||
myCanvasGroup, gnome_canvas_image_get_type(), "x",
|
||||
(double) x, "y", (double) y, "width",
|
||||
(double) petmark->rgb_width, "height",
|
||||
(double) petmark->rgb_height, "image", petmark,
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST, NULL));
|
||||
gnome_canvas_item_lower_to_bottom(
|
||||
GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ghack_map_cliparound(NULL, u.ux, u.uy, NULL);
|
||||
ghack_map_cursor_to(NULL, u.ux, u.uy, NULL);
|
||||
gnome_canvas_update_now(ghack_map.canvas);
|
||||
doredraw();
|
||||
}
|
||||
|
||||
+476
-490
File diff suppressed because it is too large
Load Diff
+37
-40
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnmesg.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnmesg.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 gnmesg.c $Date: 2009/05/06 10:57:39 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)gnmesg.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -7,69 +7,71 @@
|
||||
#include "gnmesg.h"
|
||||
#include "gnsignal.h"
|
||||
|
||||
/* Pick an arbitrary number of chars such as 80 col X 40 rows text = 3200 chars */
|
||||
#define nCharsBeforeDeletingStuff 3200
|
||||
/* Pick an arbitrary number of chars such as 80 col X 40 rows text = 3200
|
||||
* chars */
|
||||
#define nCharsBeforeDeletingStuff 3200
|
||||
|
||||
/* Message Window widgets */
|
||||
GtkWidget *MW_table;
|
||||
GtkWidget *MW_text;
|
||||
GtkWidget *MW_scrollbar;
|
||||
|
||||
|
||||
void ghack_message_window_clear(GtkWidget *widget, gpointer data)
|
||||
void
|
||||
ghack_message_window_clear(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
/* Seems nethack calls this after every move -- we don't want
|
||||
* to really clear the window at all though. Ignore the request */
|
||||
gint len;
|
||||
|
||||
len = gtk_text_get_length(GTK_TEXT(MW_text));
|
||||
|
||||
if(len < nCharsBeforeDeletingStuff)
|
||||
|
||||
if (len < nCharsBeforeDeletingStuff)
|
||||
return;
|
||||
|
||||
|
||||
gtk_text_freeze(GTK_TEXT(MW_text));
|
||||
gtk_text_set_point(GTK_TEXT(MW_text), 0);
|
||||
gtk_text_forward_delete(GTK_TEXT(MW_text), len-((guint)(nCharsBeforeDeletingStuff*0.5)));
|
||||
gtk_text_set_point(GTK_TEXT(MW_text), (guint)(nCharsBeforeDeletingStuff*0.5));
|
||||
gtk_text_forward_delete(GTK_TEXT(MW_text),
|
||||
len - ((guint)(nCharsBeforeDeletingStuff * 0.5)));
|
||||
gtk_text_set_point(GTK_TEXT(MW_text),
|
||||
(guint)(nCharsBeforeDeletingStuff * 0.5));
|
||||
gtk_text_thaw(GTK_TEXT(MW_text));
|
||||
}
|
||||
|
||||
void ghack_message_window_destroy( GtkWidget *win, gpointer data)
|
||||
void
|
||||
ghack_message_window_destroy(GtkWidget *win, gpointer data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ghack_message_window_display(GtkWidget *widget, boolean block,
|
||||
gpointer data)
|
||||
void
|
||||
ghack_message_window_display(GtkWidget *widget, boolean block, gpointer data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ghack_message_window_put_string(GtkWidget *widget, int attr,
|
||||
const char* text, gpointer data)
|
||||
void
|
||||
ghack_message_window_put_string(GtkWidget *widget, int attr, const char *text,
|
||||
gpointer data)
|
||||
{
|
||||
|
||||
if(text == NULL)
|
||||
if (text == NULL)
|
||||
return;
|
||||
|
||||
|
||||
/* Don't bother with attributes yet */
|
||||
gtk_text_insert(GTK_TEXT(MW_text), NULL, NULL, NULL, text, -1);
|
||||
gtk_text_insert(GTK_TEXT(MW_text), NULL, NULL, NULL, "\n", -1);
|
||||
}
|
||||
|
||||
void ghack_message_window_use_RIP(int how)
|
||||
void
|
||||
ghack_message_window_use_RIP(int how)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ghack_message_window_scroll(int dx, int dy)
|
||||
void
|
||||
ghack_message_window_scroll(int dx, int dy)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GtkWidget* ghack_init_message_window(void)
|
||||
GtkWidget *
|
||||
ghack_init_message_window(void)
|
||||
{
|
||||
|
||||
MW_table = gtk_table_new(2, 1, FALSE);
|
||||
gtk_table_set_row_spacing(GTK_TABLE(MW_table), 0, 2);
|
||||
|
||||
@@ -77,28 +79,23 @@ GtkWidget* ghack_init_message_window(void)
|
||||
gtk_text_set_editable(GTK_TEXT(MW_text), FALSE);
|
||||
gtk_text_set_word_wrap(GTK_TEXT(MW_text), TRUE);
|
||||
gtk_table_attach(GTK_TABLE(MW_table), MW_text, 0, 1, 0, 1,
|
||||
(GTK_EXPAND | GTK_FILL),
|
||||
(GTK_EXPAND | GTK_FILL),
|
||||
0, 0);
|
||||
(GTK_EXPAND | GTK_FILL), (GTK_EXPAND | GTK_FILL), 0, 0);
|
||||
|
||||
MW_scrollbar = gtk_vscrollbar_new(GTK_TEXT(MW_text)->vadj);
|
||||
gtk_table_attach(GTK_TABLE(MW_table), MW_scrollbar, 1, 2, 0, 1,
|
||||
GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
|
||||
|
||||
gtk_table_attach(GTK_TABLE(MW_table), MW_scrollbar, 1, 2, 0, 1, GTK_FILL,
|
||||
(GTK_EXPAND | GTK_FILL), 0, 0);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(MW_table), "ghack_putstr",
|
||||
GTK_SIGNAL_FUNC(ghack_message_window_put_string),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC(ghack_message_window_put_string),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(MW_table), "ghack_clear",
|
||||
GTK_SIGNAL_FUNC(ghack_message_window_clear),
|
||||
NULL);
|
||||
|
||||
GTK_SIGNAL_FUNC(ghack_message_window_clear), NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(MW_table), "gnome_delay_output",
|
||||
GTK_SIGNAL_FUNC(ghack_delay), NULL);
|
||||
GTK_SIGNAL_FUNC(ghack_delay), NULL);
|
||||
|
||||
gtk_widget_show_all(MW_table);
|
||||
|
||||
return GTK_WIDGET(MW_table);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+66
-69
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnopts.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnopts.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 gnopts.c $Date: 2009/05/06 10:57:40 $ $Revision: 1.5 $ */
|
||||
/* SCCS Id: @(#)gnopts.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -13,19 +13,19 @@
|
||||
#include "hack.h"
|
||||
|
||||
static gint tileset;
|
||||
static GtkWidget* clist;
|
||||
const char* tilesets[] = { "Traditional (16x16)", "Big (32x32)", 0 };
|
||||
static GtkWidget *clist;
|
||||
const char *tilesets[] = { "Traditional (16x16)", "Big (32x32)", 0 };
|
||||
|
||||
static void
|
||||
opt_sel_key_hit(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; tilesets[i] != 0; ++i) {
|
||||
if (tilesets[i][0] == toupper(event->keyval)) {
|
||||
tileset = i;
|
||||
gtk_clist_select_row( GTK_CLIST (clist), i, 0);
|
||||
}
|
||||
}
|
||||
int i;
|
||||
for (i = 0; tilesets[i] != 0; ++i) {
|
||||
if (tilesets[i][0] == toupper(event->keyval)) {
|
||||
tileset = i;
|
||||
gtk_clist_select_row(GTK_CLIST(clist), i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -38,82 +38,79 @@ void
|
||||
ghack_settings_dialog()
|
||||
{
|
||||
int i;
|
||||
static GtkWidget* dialog;
|
||||
static GtkWidget* swin;
|
||||
static GtkWidget* frame1;
|
||||
static GtkWidget *dialog;
|
||||
static GtkWidget *swin;
|
||||
static GtkWidget *frame1;
|
||||
|
||||
dialog = gnome_dialog_new (_("GnomeHack Settings"),
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
NULL);
|
||||
gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
|
||||
GTK_SIGNAL_FUNC (opt_sel_key_hit), tilesets );
|
||||
dialog = gnome_dialog_new(_("GnomeHack Settings"), GNOME_STOCK_BUTTON_OK,
|
||||
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
|
||||
gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event",
|
||||
GTK_SIGNAL_FUNC(opt_sel_key_hit), tilesets);
|
||||
|
||||
frame1 = gtk_frame_new (_("Choose one of the following tilesets:"));
|
||||
gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1);
|
||||
gtk_widget_show (frame1);
|
||||
gtk_container_border_width (GTK_CONTAINER (frame1), 3);
|
||||
frame1 = gtk_frame_new(_("Choose one of the following tilesets:"));
|
||||
gtk_object_set_data(GTK_OBJECT(dialog), "frame1", frame1);
|
||||
gtk_widget_show(frame1);
|
||||
gtk_container_border_width(GTK_CONTAINER(frame1), 3);
|
||||
|
||||
swin = gtk_scrolled_window_new (NULL, NULL);
|
||||
clist = gtk_clist_new (2);
|
||||
gtk_clist_column_titles_hide (GTK_CLIST (clist));
|
||||
gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180);
|
||||
gtk_container_add (GTK_CONTAINER (swin), clist);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
swin = gtk_scrolled_window_new(NULL, NULL);
|
||||
clist = gtk_clist_new(2);
|
||||
gtk_clist_column_titles_hide(GTK_CLIST(clist));
|
||||
gtk_widget_set_usize(GTK_WIDGET(clist), 100, 180);
|
||||
gtk_container_add(GTK_CONTAINER(swin), clist);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
|
||||
GTK_SIGNAL_FUNC (opt_sel_row_selected), NULL );
|
||||
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
|
||||
GTK_SIGNAL_FUNC(opt_sel_row_selected), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame1), swin);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1);
|
||||
gtk_container_add(GTK_CONTAINER(frame1), swin);
|
||||
gtk_box_pack_start_defaults(GTK_BOX(GNOME_DIALOG(dialog)->vbox), frame1);
|
||||
|
||||
/* Add the tilesets into the list here... */
|
||||
for (i=0; tilesets[i]; i++) {
|
||||
gchar accelBuf[BUFSZ];
|
||||
const char *text[3]={accelBuf, tilesets[i],NULL};
|
||||
sprintf( accelBuf, "%c ", tolower(tilesets[i][0]));
|
||||
gtk_clist_insert (GTK_CLIST (clist), i, (char**)text);
|
||||
for (i = 0; tilesets[i]; i++) {
|
||||
gchar accelBuf[BUFSZ];
|
||||
const char *text[3] = { accelBuf, tilesets[i], NULL };
|
||||
sprintf(accelBuf, "%c ", tolower(tilesets[i][0]));
|
||||
gtk_clist_insert(GTK_CLIST(clist), i, (char **) text);
|
||||
}
|
||||
|
||||
|
||||
gtk_clist_columns_autosize (GTK_CLIST (clist));
|
||||
gtk_widget_show_all (swin);
|
||||
gtk_clist_columns_autosize(GTK_CLIST(clist));
|
||||
gtk_widget_show_all(swin);
|
||||
|
||||
/* Center the dialog over over parent */
|
||||
gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
|
||||
GTK_WINDOW (ghack_get_main_window ()) );
|
||||
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(dialog),
|
||||
GTK_WINDOW(ghack_get_main_window()));
|
||||
|
||||
/* Run the dialog -- returning whichever button was pressed */
|
||||
i = gnome_dialog_run (GNOME_DIALOG (dialog));
|
||||
gnome_dialog_close (GNOME_DIALOG (dialog));
|
||||
i = gnome_dialog_run(GNOME_DIALOG(dialog));
|
||||
gnome_dialog_close(GNOME_DIALOG(dialog));
|
||||
|
||||
/* They hit Quit or error */
|
||||
if (i != 0 ) {
|
||||
return;
|
||||
if (i != 0) {
|
||||
return;
|
||||
}
|
||||
switch (tileset) {
|
||||
case 0:
|
||||
/* They selected traditional */
|
||||
ghack_free_glyphs();
|
||||
if (ghack_init_glyphs(HACKDIR "/x11tiles"))
|
||||
g_error ("ERROR: Could not initialize glyphs.\n");
|
||||
ghack_reinit_map_window();
|
||||
break;
|
||||
case 1:
|
||||
ghack_free_glyphs();
|
||||
if (ghack_init_glyphs(HACKDIR "/t32-1024.xpm"))
|
||||
g_error ("ERROR: Could not initialize glyphs.\n");
|
||||
ghack_reinit_map_window();
|
||||
case 0:
|
||||
/* They selected traditional */
|
||||
ghack_free_glyphs();
|
||||
if (ghack_init_glyphs(HACKDIR "/x11tiles"))
|
||||
g_error("ERROR: Could not initialize glyphs.\n");
|
||||
ghack_reinit_map_window();
|
||||
break;
|
||||
case 1:
|
||||
ghack_free_glyphs();
|
||||
if (ghack_init_glyphs(HACKDIR "/t32-1024.xpm"))
|
||||
g_error("ERROR: Could not initialize glyphs.\n");
|
||||
ghack_reinit_map_window();
|
||||
|
||||
/* They selected big */
|
||||
break;
|
||||
default:
|
||||
/* This shouldn't happen */
|
||||
g_warning("This shouldn't happen\n");
|
||||
/* They selected big */
|
||||
break;
|
||||
default:
|
||||
/* This shouldn't happen */
|
||||
g_warning("This shouldn't happen\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+53
-56
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnplayer.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnplayer.c $NHDT-Date: 1431192773 2015/05/09 17:32:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
|
||||
/* NetHack 3.6 gnplayer.c $Date: 2009/05/06 10:57:42 $ $Revision: 1.6 $ */
|
||||
/* SCCS Id: @(#)gnplayer.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -11,95 +11,92 @@
|
||||
#include "hack.h"
|
||||
|
||||
static gint role_number;
|
||||
static GtkWidget* clist;
|
||||
static GtkWidget *clist;
|
||||
|
||||
static void
|
||||
player_sel_key_hit (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
player_sel_key_hit(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
const char** roles = data;
|
||||
const char **roles = data;
|
||||
int i;
|
||||
for (i = 0; roles[i] != 0; ++i) {
|
||||
if (tolower(roles[i][0]) == tolower(event->keyval)) {
|
||||
role_number = i;
|
||||
gtk_clist_select_row( GTK_CLIST (clist), i, 0);
|
||||
if (gtk_clist_row_is_visible(GTK_CLIST(clist),
|
||||
i) != GTK_VISIBILITY_FULL)
|
||||
gtk_clist_moveto(GTK_CLIST(clist), i, 0, 0.5, 0);
|
||||
}
|
||||
if (tolower(roles[i][0]) == tolower(event->keyval)) {
|
||||
role_number = i;
|
||||
gtk_clist_select_row(GTK_CLIST(clist), i, 0);
|
||||
if (gtk_clist_row_is_visible(GTK_CLIST(clist), i)
|
||||
!= GTK_VISIBILITY_FULL)
|
||||
gtk_clist_moveto(GTK_CLIST(clist), i, 0, 0.5, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
player_sel_row_selected (GtkCList *clist, int row, int col, GdkEvent *event)
|
||||
player_sel_row_selected(GtkCList *clist, int row, int col, GdkEvent *event)
|
||||
{
|
||||
role_number = row;
|
||||
}
|
||||
|
||||
int
|
||||
ghack_player_sel_dialog(const char** choices,
|
||||
const gchar* title,
|
||||
const gchar* prompt)
|
||||
ghack_player_sel_dialog(const char **choices, const gchar *title,
|
||||
const gchar *prompt)
|
||||
{
|
||||
int i;
|
||||
static GtkWidget* dialog;
|
||||
static GtkWidget* swin;
|
||||
static GtkWidget* frame1;
|
||||
static GtkWidget *dialog;
|
||||
static GtkWidget *swin;
|
||||
static GtkWidget *frame1;
|
||||
|
||||
dialog = gnome_dialog_new(title,
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
_("Random"),
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
NULL);
|
||||
gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
|
||||
GTK_SIGNAL_FUNC (player_sel_key_hit), choices );
|
||||
dialog = gnome_dialog_new(title, GNOME_STOCK_BUTTON_OK, _("Random"),
|
||||
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
|
||||
gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event",
|
||||
GTK_SIGNAL_FUNC(player_sel_key_hit), choices);
|
||||
|
||||
frame1 = gtk_frame_new(prompt);
|
||||
gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1);
|
||||
gtk_widget_show (frame1);
|
||||
gtk_container_border_width (GTK_CONTAINER (frame1), 3);
|
||||
gtk_object_set_data(GTK_OBJECT(dialog), "frame1", frame1);
|
||||
gtk_widget_show(frame1);
|
||||
gtk_container_border_width(GTK_CONTAINER(frame1), 3);
|
||||
|
||||
swin = gtk_scrolled_window_new (NULL, NULL);
|
||||
clist = gtk_clist_new (2);
|
||||
gtk_clist_column_titles_hide (GTK_CLIST (clist));
|
||||
gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180);
|
||||
gtk_container_add (GTK_CONTAINER (swin), clist);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
swin = gtk_scrolled_window_new(NULL, NULL);
|
||||
clist = gtk_clist_new(2);
|
||||
gtk_clist_column_titles_hide(GTK_CLIST(clist));
|
||||
gtk_widget_set_usize(GTK_WIDGET(clist), 100, 180);
|
||||
gtk_container_add(GTK_CONTAINER(swin), clist);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
|
||||
GTK_SIGNAL_FUNC (player_sel_row_selected), NULL );
|
||||
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
|
||||
GTK_SIGNAL_FUNC(player_sel_row_selected), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame1), swin);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1);
|
||||
gtk_container_add(GTK_CONTAINER(frame1), swin);
|
||||
gtk_box_pack_start_defaults(GTK_BOX(GNOME_DIALOG(dialog)->vbox), frame1);
|
||||
|
||||
/* Add the roles into the list here... */
|
||||
for (i=0; choices[i]; i++) {
|
||||
gchar accelBuf[BUFSZ];
|
||||
const char *text[3]={accelBuf, choices[i],NULL};
|
||||
sprintf( accelBuf, "%c ", tolower(choices[i][0]));
|
||||
gtk_clist_insert (GTK_CLIST (clist), i, (char**)text);
|
||||
for (i = 0; choices[i]; i++) {
|
||||
gchar accelBuf[BUFSZ];
|
||||
const char *text[3] = { accelBuf, choices[i], NULL };
|
||||
sprintf(accelBuf, "%c ", tolower(choices[i][0]));
|
||||
gtk_clist_insert(GTK_CLIST(clist), i, (char **) text);
|
||||
}
|
||||
|
||||
gtk_clist_columns_autosize (GTK_CLIST (clist));
|
||||
gtk_widget_show_all (swin);
|
||||
gtk_clist_columns_autosize(GTK_CLIST(clist));
|
||||
gtk_widget_show_all(swin);
|
||||
|
||||
/* Center the dialog over over parent */
|
||||
gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
|
||||
GTK_WINDOW (ghack_get_main_window ()) );
|
||||
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(dialog),
|
||||
GTK_WINDOW(ghack_get_main_window()));
|
||||
|
||||
/* Run the dialog -- returning whichever button was pressed */
|
||||
i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
|
||||
|
||||
/* Quit on button 2 or error */
|
||||
if (i < 0 || i > 1) {
|
||||
return(ROLE_NONE);
|
||||
if (i < 0 || i > 1) {
|
||||
return (ROLE_NONE);
|
||||
}
|
||||
/* Random is button 1*/
|
||||
if (i == 1 ) {
|
||||
return(ROLE_RANDOM);
|
||||
if (i == 1) {
|
||||
return (ROLE_RANDOM);
|
||||
}
|
||||
return ( role_number);
|
||||
return (role_number);
|
||||
}
|
||||
|
||||
+191
-234
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnsignal.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnsignal.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
|
||||
/* NetHack 3.6 gnsignal.c $Date: 2009/05/06 10:57:45 $ $Revision: 1.7 $ */
|
||||
/* SCCS Id: @(#)gnsignal.c 3.5 2005/11/19 */
|
||||
/* Copyright (C) 1998 by Anthony Taylor <tonyt@ptialaska.net> */
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
GList *g_keyBuffer;
|
||||
GList *g_clickBuffer;
|
||||
int g_numKeys=0;
|
||||
int g_numClicks=0;
|
||||
int g_askingQuestion=0;
|
||||
static int s_done=FALSE;
|
||||
int g_numKeys = 0;
|
||||
int g_numClicks = 0;
|
||||
int g_askingQuestion = 0;
|
||||
static int s_done = FALSE;
|
||||
|
||||
/*
|
||||
* ghack_init_signals
|
||||
@@ -59,161 +59,102 @@ static int s_done=FALSE;
|
||||
*/
|
||||
|
||||
void
|
||||
ghack_init_signals( void)
|
||||
ghack_init_signals(void)
|
||||
{
|
||||
ghack_signals[GHSIG_CURS] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_curs",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_INT,
|
||||
GTK_TYPE_NONE,
|
||||
2,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_INT);
|
||||
ghack_signals[GHSIG_CURS] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_curs", GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_INT, GTK_TYPE_NONE, 2, GTK_TYPE_INT,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
ghack_signals[GHSIG_PUTSTR] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_putstr",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
2,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_POINTER);
|
||||
ghack_signals[GHSIG_PUTSTR] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_putstr", GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_POINTER, GTK_TYPE_NONE, 2, GTK_TYPE_INT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_PRINT_GLYPH] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_print_glyph",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_INT_POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
3,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_POINTER);
|
||||
ghack_signals[GHSIG_PRINT_GLYPH] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_print_glyph",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__INT_INT_POINTER, GTK_TYPE_NONE, 3,
|
||||
GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_CLEAR] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_clear",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
ghack_signals[GHSIG_DISPLAY] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_display",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__BOOL,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_BOOL);
|
||||
|
||||
ghack_signals[GHSIG_START_MENU] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_start_menu",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
ghack_signals[GHSIG_ADD_MENU] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_add_menu",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_END_MENU] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_end_menu",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_SELECT_MENU] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_select_menu",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__POINTER_INT_POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
3,
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_CLIPAROUND] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_cliparound",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT_INT,
|
||||
GTK_TYPE_NONE,
|
||||
2,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_INT);
|
||||
ghack_signals[GHSIG_CLEAR] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_clear", GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
|
||||
|
||||
ghack_signals[GHSIG_FADE_HIGHLIGHT] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"ghack_fade_highlight",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
ghack_signals[GHSIG_DELAY] =
|
||||
gtk_object_class_user_signal_new (gtk_type_class (gtk_widget_get_type ()),
|
||||
"gnome_delay_output",
|
||||
GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__INT,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
ghack_signals[GHSIG_DISPLAY] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_display", GTK_RUN_FIRST,
|
||||
gtk_marshal_NONE__BOOL, GTK_TYPE_NONE, 1, GTK_TYPE_BOOL);
|
||||
|
||||
ghack_signals[GHSIG_START_MENU] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_start_menu",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
|
||||
|
||||
ghack_signals[GHSIG_ADD_MENU] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_add_menu",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_END_MENU] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_end_menu",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_SELECT_MENU] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_select_menu",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__POINTER_INT_POINTER, GTK_TYPE_NONE,
|
||||
3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_POINTER);
|
||||
|
||||
ghack_signals[GHSIG_CLIPAROUND] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_cliparound",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__INT_INT, GTK_TYPE_NONE, 2,
|
||||
GTK_TYPE_INT, GTK_TYPE_INT);
|
||||
|
||||
ghack_signals[GHSIG_FADE_HIGHLIGHT] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "ghack_fade_highlight",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
|
||||
|
||||
ghack_signals[GHSIG_DELAY] = gtk_object_class_user_signal_new(
|
||||
gtk_type_class(gtk_widget_get_type()), "gnome_delay_output",
|
||||
GTK_RUN_FIRST, gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT);
|
||||
}
|
||||
|
||||
/* For want of a better place, I'm putting the delay output stuff here
|
||||
* -Erik
|
||||
*/
|
||||
static gint timeout_callback(gpointer data)
|
||||
static gint
|
||||
timeout_callback(gpointer data)
|
||||
{
|
||||
s_done=TRUE;
|
||||
s_done = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ghack_delay( GtkWidget *win, int numMillisecs, gpointer data)
|
||||
ghack_delay(GtkWidget *win, int numMillisecs, gpointer data)
|
||||
{
|
||||
s_done=FALSE;
|
||||
gtk_timeout_add( (unsigned int) numMillisecs,
|
||||
timeout_callback, NULL);
|
||||
while( s_done==FALSE)
|
||||
gtk_main_iteration();
|
||||
s_done = FALSE;
|
||||
gtk_timeout_add((unsigned int) numMillisecs, timeout_callback, NULL);
|
||||
while (s_done == FALSE)
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ghack_handle_button_press(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
void
|
||||
ghack_handle_button_press(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
GHClick *click;
|
||||
double x1, y1;
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return;
|
||||
|
||||
gnome_canvas_window_to_world( GNOME_CANVAS( widget), event->x,
|
||||
event->y, &x1, &y1);
|
||||
/*
|
||||
g_message("I got a click at %f,%f with button %d \n",
|
||||
x1, y1, event->button);
|
||||
*/
|
||||
return;
|
||||
|
||||
gnome_canvas_window_to_world(GNOME_CANVAS(widget), event->x, event->y,
|
||||
&x1, &y1);
|
||||
/*
|
||||
g_message("I got a click at %f,%f with button %d \n",
|
||||
x1, y1, event->button);
|
||||
*/
|
||||
|
||||
/* We allocate storage here, so we need to remember if (g_numClicks>0)
|
||||
* to blow this away when closing the app using something like
|
||||
* to blow this away when closing the app using something like
|
||||
* while (g_clickBuffer)
|
||||
* {
|
||||
* g_free((GHClick)g_clickBuffer->data);
|
||||
@@ -222,32 +163,31 @@ ghack_handle_button_press(GtkWidget *widget, GdkEventButton *event,
|
||||
* g_list_free( g_clickBuffer );
|
||||
*
|
||||
*/
|
||||
click = g_new( GHClick, 1);
|
||||
|
||||
click->x=(int)x1/ghack_glyph_width();
|
||||
click->y=(int)y1/ghack_glyph_height();
|
||||
click->mod=(event->button == 1)? CLICK_1 : CLICK_2;
|
||||
|
||||
g_clickBuffer = g_list_prepend (g_clickBuffer, click);
|
||||
click = g_new(GHClick, 1);
|
||||
|
||||
click->x = (int) x1 / ghack_glyph_width();
|
||||
click->y = (int) y1 / ghack_glyph_height();
|
||||
click->mod = (event->button == 1) ? CLICK_1 : CLICK_2;
|
||||
|
||||
g_clickBuffer = g_list_prepend(g_clickBuffer, click);
|
||||
/* Could use g_list_length(), but it is stupid and just
|
||||
* traverses the list while counting, so we'll just do
|
||||
* traverses the list while counting, so we'll just do
|
||||
* the counting ourselves in advance. */
|
||||
g_numClicks++;
|
||||
}
|
||||
|
||||
#ifndef M
|
||||
# ifndef NHSTDC
|
||||
# define M(c) (0x80 | (c))
|
||||
# else
|
||||
# define M(c) ((c) - 128)
|
||||
# endif /* NHSTDC */
|
||||
#ifndef NHSTDC
|
||||
#define M(c) (0x80 | (c))
|
||||
#else
|
||||
#define M(c) ((c) -128)
|
||||
#endif /* NHSTDC */
|
||||
#endif
|
||||
#ifndef C
|
||||
#define C(c) (0x1f & (c))
|
||||
#define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
ghack_handle_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
static int was_pound = 0;
|
||||
@@ -255,7 +195,7 @@ ghack_handle_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
int ctl = GDK_CONTROL_MASK;
|
||||
int alt = GDK_MOD1_MASK;
|
||||
|
||||
/* Turn this on to debug key events */
|
||||
/* Turn this on to debug key events */
|
||||
#if 0
|
||||
g_message("I got a \"%s\" key (%d) %s%s",
|
||||
gdk_keyval_name (event->keyval), event->keyval,
|
||||
@@ -263,118 +203,136 @@ ghack_handle_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
#endif
|
||||
|
||||
switch (event->keyval) {
|
||||
/* special keys to do stuff with */
|
||||
/* special keys to do stuff with */
|
||||
|
||||
/* Set up the direction keys */
|
||||
/* Set up the direction keys */
|
||||
|
||||
/* First handle the arrow keys -- these always mean move */
|
||||
/* First handle the arrow keys -- these always mean move */
|
||||
case GDK_Right:
|
||||
case GDK_rightarrow:
|
||||
key = Cmd.move_E; break;
|
||||
key = Cmd.move_E;
|
||||
break;
|
||||
case GDK_Left:
|
||||
case GDK_leftarrow:
|
||||
key = Cmd.move_W; break;
|
||||
key = Cmd.move_W;
|
||||
break;
|
||||
case GDK_Up:
|
||||
case GDK_uparrow:
|
||||
key = Cmd.move_N; break;
|
||||
key = Cmd.move_N;
|
||||
break;
|
||||
case GDK_Down:
|
||||
case GDK_downarrow:
|
||||
key = Cmd.move_S; break;
|
||||
key = Cmd.move_S;
|
||||
break;
|
||||
case GDK_Home:
|
||||
key = Cmd.move_NW; break;
|
||||
key = Cmd.move_NW;
|
||||
break;
|
||||
case GDK_End:
|
||||
key = Cmd.move_SW; break;
|
||||
key = Cmd.move_SW;
|
||||
break;
|
||||
case GDK_Page_Down:
|
||||
key = Cmd.move_SE; break;
|
||||
key = Cmd.move_SE;
|
||||
break;
|
||||
case GDK_Page_Up:
|
||||
key = Cmd.move_NE; break;
|
||||
case ' ': key='.'; break;
|
||||
key = Cmd.move_NE;
|
||||
break;
|
||||
case ' ':
|
||||
key = '.';
|
||||
break;
|
||||
|
||||
/* Now, handle the numberpad (move or numbers) */
|
||||
/* Now, handle the numberpad (move or numbers) */
|
||||
case GDK_KP_Right:
|
||||
case GDK_KP_6:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_6;
|
||||
else
|
||||
key='6';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_6;
|
||||
else
|
||||
key = '6';
|
||||
break;
|
||||
|
||||
case GDK_KP_Left:
|
||||
case GDK_KP_4:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_4;
|
||||
else
|
||||
key='4';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_4;
|
||||
else
|
||||
key = '4';
|
||||
break;
|
||||
|
||||
case GDK_KP_Up:
|
||||
case GDK_KP_8:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_8;
|
||||
else
|
||||
key='8';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_8;
|
||||
else
|
||||
key = '8';
|
||||
break;
|
||||
|
||||
case GDK_KP_Down:
|
||||
case GDK_KP_2:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_2;
|
||||
else
|
||||
key='2';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_2;
|
||||
else
|
||||
key = '2';
|
||||
break;
|
||||
|
||||
/* Move Top-Left */
|
||||
/* Move Top-Left */
|
||||
case GDK_KP_Home:
|
||||
case GDK_KP_7:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_7;
|
||||
else
|
||||
key='7';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_7;
|
||||
else
|
||||
key = '7';
|
||||
break;
|
||||
|
||||
case GDK_KP_Page_Up:
|
||||
case GDK_KP_9:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_9;
|
||||
else
|
||||
key='9';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_9;
|
||||
else
|
||||
key = '9';
|
||||
break;
|
||||
|
||||
case GDK_KP_End:
|
||||
case GDK_KP_1:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_1;
|
||||
else
|
||||
key='1';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_1;
|
||||
else
|
||||
key = '1';
|
||||
break;
|
||||
|
||||
case GDK_KP_Page_Down:
|
||||
case GDK_KP_3:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_3;
|
||||
else
|
||||
key='3';
|
||||
break;
|
||||
|
||||
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_3;
|
||||
else
|
||||
key = '3';
|
||||
break;
|
||||
|
||||
case GDK_KP_5:
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && iflags.num_pad)
|
||||
key = GDK_KP_5;
|
||||
else
|
||||
key='5';
|
||||
break;
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
|
||||
&& iflags.num_pad)
|
||||
key = GDK_KP_5;
|
||||
else
|
||||
key = '5';
|
||||
break;
|
||||
|
||||
case GDK_KP_Delete:
|
||||
case GDK_KP_Decimal:
|
||||
key='.';
|
||||
break;
|
||||
key = '.';
|
||||
break;
|
||||
|
||||
/* can't just ignore "#", it's a core feature */
|
||||
/* can't just ignore "#", it's a core feature */
|
||||
case GDK_numbersign:
|
||||
key='#';
|
||||
break;
|
||||
key = '#';
|
||||
break;
|
||||
|
||||
/* We will probably want to do something with these later... */
|
||||
/* We will probably want to do something with these later... */
|
||||
case GDK_KP_Begin:
|
||||
case GDK_KP_F1:
|
||||
case GDK_F1:
|
||||
@@ -392,8 +350,8 @@ ghack_handle_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
case GDK_F10:
|
||||
case GDK_F11:
|
||||
case GDK_F12:
|
||||
break;
|
||||
/* various keys to ignore */
|
||||
break;
|
||||
/* various keys to ignore */
|
||||
case GDK_KP_Insert:
|
||||
case GDK_Insert:
|
||||
case GDK_Delete:
|
||||
@@ -414,31 +372,30 @@ ghack_handle_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
case GDK_Meta_R:
|
||||
case GDK_Mode_switch:
|
||||
case GDK_Multi_key:
|
||||
return;
|
||||
return;
|
||||
|
||||
default:
|
||||
key = event->keyval;
|
||||
break;
|
||||
key = event->keyval;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((event->state & alt) || was_pound) {
|
||||
key=M(event->keyval);
|
||||
key = M(event->keyval);
|
||||
} else if (event->state & ctl) {
|
||||
key=C(event->keyval);
|
||||
key = C(event->keyval);
|
||||
}
|
||||
if (was_pound) {
|
||||
was_pound = 0;
|
||||
was_pound = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Ok, here is where we do clever stuff to overide the default
|
||||
* game behavior */
|
||||
if (g_askingQuestion == 0) {
|
||||
|
||||
if (key == 'S' || key == M('S') || key == C('S')) {
|
||||
ghack_save_game_cb( NULL, NULL);
|
||||
return;
|
||||
}
|
||||
if (key == 'S' || key == M('S') || key == C('S')) {
|
||||
ghack_save_game_cb(NULL, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_keyBuffer = g_list_prepend (g_keyBuffer, GINT_TO_POINTER( key));
|
||||
g_keyBuffer = g_list_prepend(g_keyBuffer, GINT_TO_POINTER(key));
|
||||
g_numKeys++;
|
||||
}
|
||||
|
||||
+647
-663
File diff suppressed because it is too large
Load Diff
+71
-78
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gntext.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gntext.c $NHDT-Date: 1431192772 2015/05/09 17:32:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 gntext.c $Date: 2009/05/06 10:58:00 $ $Revision: 1.5 $ */
|
||||
/* SCCS Id: @(#)gntext.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -21,8 +21,6 @@
|
||||
#define RIP_DRAW_X 114
|
||||
#define RIP_DRAW_Y 69
|
||||
|
||||
|
||||
|
||||
/* Text Window widgets */
|
||||
GtkWidget *RIP = NULL;
|
||||
GtkWidget *RIPlabel = NULL;
|
||||
@@ -31,130 +29,125 @@ GnomeLess *gless;
|
||||
|
||||
static int showRIP = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
void ghack_text_window_clear(GtkWidget *widget, gpointer data)
|
||||
void
|
||||
ghack_text_window_clear(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
g_assert (gless != NULL);
|
||||
gtk_editable_delete_text (GTK_EDITABLE (gless->text), 0, 0);
|
||||
g_assert(gless != NULL);
|
||||
gtk_editable_delete_text(GTK_EDITABLE(gless->text), 0, 0);
|
||||
}
|
||||
|
||||
void ghack_text_window_destroy()
|
||||
void
|
||||
ghack_text_window_destroy()
|
||||
{
|
||||
TW_window = NULL;
|
||||
}
|
||||
|
||||
void ghack_text_window_display(GtkWidget *widget, boolean block,
|
||||
gpointer data)
|
||||
void
|
||||
ghack_text_window_display(GtkWidget *widget, boolean block, gpointer data)
|
||||
{
|
||||
if(showRIP == 1) {
|
||||
gtk_widget_show (GTK_WIDGET ( RIP));
|
||||
gtk_window_set_title(GTK_WINDOW( TW_window), "Rest In Peace");
|
||||
if (showRIP == 1) {
|
||||
gtk_widget_show(GTK_WIDGET(RIP));
|
||||
gtk_window_set_title(GTK_WINDOW(TW_window), "Rest In Peace");
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (TW_window), "destroy",
|
||||
(GtkSignalFunc) ghack_text_window_destroy, NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(TW_window), "destroy",
|
||||
(GtkSignalFunc) ghack_text_window_destroy, NULL);
|
||||
if (block)
|
||||
gnome_dialog_run(GNOME_DIALOG(TW_window));
|
||||
gnome_dialog_run(GNOME_DIALOG(TW_window));
|
||||
else
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(TW_window));
|
||||
|
||||
if(showRIP == 1) {
|
||||
showRIP = 0;
|
||||
gtk_widget_hide (GTK_WIDGET ( RIP));
|
||||
gtk_window_set_title(GTK_WINDOW(TW_window), "Text Window");
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(TW_window));
|
||||
|
||||
if (showRIP == 1) {
|
||||
showRIP = 0;
|
||||
gtk_widget_hide(GTK_WIDGET(RIP));
|
||||
gtk_window_set_title(GTK_WINDOW(TW_window), "Text Window");
|
||||
}
|
||||
}
|
||||
|
||||
void ghack_text_window_put_string(GtkWidget *widget, int attr,
|
||||
const char* text, gpointer data)
|
||||
void
|
||||
ghack_text_window_put_string(GtkWidget *widget, int attr, const char *text,
|
||||
gpointer data)
|
||||
{
|
||||
if(text == NULL)
|
||||
if (text == NULL)
|
||||
return;
|
||||
|
||||
|
||||
/* Don't bother with attributes yet */
|
||||
gtk_text_insert (GTK_TEXT (gless->text), NULL, NULL, NULL, text, -1);
|
||||
gtk_text_insert (GTK_TEXT (gless->text), NULL, NULL, NULL, "\n", -1);
|
||||
gtk_text_insert(GTK_TEXT(gless->text), NULL, NULL, NULL, text, -1);
|
||||
gtk_text_insert(GTK_TEXT(gless->text), NULL, NULL, NULL, "\n", -1);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget* ghack_init_text_window ( )
|
||||
GtkWidget *
|
||||
ghack_init_text_window()
|
||||
{
|
||||
GtkWidget *pixmap;
|
||||
if(TW_window)
|
||||
return(GTK_WIDGET(TW_window));
|
||||
|
||||
if (TW_window)
|
||||
return (GTK_WIDGET(TW_window));
|
||||
|
||||
TW_window = gnome_dialog_new("Text Window", GNOME_STOCK_BUTTON_OK, NULL);
|
||||
gtk_window_set_default_size( GTK_WINDOW(TW_window), 500, 400);
|
||||
gtk_window_set_default_size(GTK_WINDOW(TW_window), 500, 400);
|
||||
gtk_window_set_policy(GTK_WINDOW(TW_window), TRUE, TRUE, FALSE);
|
||||
gtk_window_set_title(GTK_WINDOW(TW_window), "Text Window");
|
||||
|
||||
|
||||
/* create GNOME pixmap object */
|
||||
pixmap = gnome_pixmap_new_from_xpm_d (rip_xpm);
|
||||
g_assert (pixmap != NULL);
|
||||
gtk_widget_show (GTK_WIDGET (pixmap));
|
||||
pixmap = gnome_pixmap_new_from_xpm_d(rip_xpm);
|
||||
g_assert(pixmap != NULL);
|
||||
gtk_widget_show(GTK_WIDGET(pixmap));
|
||||
|
||||
/* create label with our "death message", sized to fit into the
|
||||
* tombstone */
|
||||
RIPlabel = gtk_label_new ("RIP");
|
||||
g_assert (RIPlabel != NULL);
|
||||
RIPlabel = gtk_label_new("RIP");
|
||||
g_assert(RIPlabel != NULL);
|
||||
/* gtk_label_set_justify is broken? */
|
||||
gtk_label_set_justify (GTK_LABEL (RIPlabel), GTK_JUSTIFY_CENTER);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (RIPlabel), TRUE);
|
||||
gtk_widget_set_usize (RIPlabel, RIP_DRAW_WIDTH, RIP_DRAW_HEIGHT);
|
||||
gtk_widget_show (RIPlabel);
|
||||
gtk_label_set_justify(GTK_LABEL(RIPlabel), GTK_JUSTIFY_CENTER);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(RIPlabel), TRUE);
|
||||
gtk_widget_set_usize(RIPlabel, RIP_DRAW_WIDTH, RIP_DRAW_HEIGHT);
|
||||
gtk_widget_show(RIPlabel);
|
||||
|
||||
/* create a fixed sized widget for the RIP pixmap */
|
||||
RIP = gtk_fixed_new ();
|
||||
g_assert (RIP != NULL);
|
||||
gtk_widget_set_usize (RIP, RIP_IMAGE_WIDTH, RIP_IMAGE_HEIGHT);
|
||||
gtk_fixed_put (GTK_FIXED (RIP), pixmap, 0, 0);
|
||||
gtk_fixed_put (GTK_FIXED (RIP), RIPlabel, RIP_DRAW_X, RIP_DRAW_Y);
|
||||
gtk_widget_show (RIP);
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(TW_window)->vbox), RIP,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
RIP = gtk_fixed_new();
|
||||
g_assert(RIP != NULL);
|
||||
gtk_widget_set_usize(RIP, RIP_IMAGE_WIDTH, RIP_IMAGE_HEIGHT);
|
||||
gtk_fixed_put(GTK_FIXED(RIP), pixmap, 0, 0);
|
||||
gtk_fixed_put(GTK_FIXED(RIP), RIPlabel, RIP_DRAW_X, RIP_DRAW_Y);
|
||||
gtk_widget_show(RIP);
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(TW_window)->vbox), RIP, TRUE,
|
||||
TRUE, 0);
|
||||
|
||||
/* create a gnome Less widget for the text stuff */
|
||||
gless = GNOME_LESS (gnome_less_new ());
|
||||
g_assert (gless != NULL);
|
||||
gtk_widget_show (GTK_WIDGET (gless));
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(TW_window)->vbox),
|
||||
GTK_WIDGET (gless), TRUE, TRUE, 0);
|
||||
|
||||
gless = GNOME_LESS(gnome_less_new());
|
||||
g_assert(gless != NULL);
|
||||
gtk_widget_show(GTK_WIDGET(gless));
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(TW_window)->vbox),
|
||||
GTK_WIDGET(gless), TRUE, TRUE, 0);
|
||||
|
||||
/* Hook up some signals */
|
||||
gtk_signal_connect(GTK_OBJECT(TW_window), "ghack_putstr",
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_put_string),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_put_string), NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(TW_window), "ghack_clear",
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_clear),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_clear), NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(TW_window), "ghack_display",
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_display),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC(ghack_text_window_display), NULL);
|
||||
|
||||
/* Center the dialog over over parent */
|
||||
gnome_dialog_set_parent( GNOME_DIALOG (TW_window),
|
||||
GTK_WINDOW(ghack_get_main_window()) );
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(TW_window),
|
||||
GTK_WINDOW(ghack_get_main_window()));
|
||||
|
||||
gtk_window_set_modal( GTK_WINDOW(TW_window), TRUE);
|
||||
gtk_window_set_modal(GTK_WINDOW(TW_window), TRUE);
|
||||
gtk_widget_show_all(TW_window);
|
||||
gtk_widget_hide (GTK_WIDGET ( RIP));
|
||||
gnome_dialog_close_hides (GNOME_DIALOG (TW_window), TRUE);
|
||||
gtk_widget_hide(GTK_WIDGET(RIP));
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(TW_window), TRUE);
|
||||
|
||||
return GTK_WIDGET(TW_window);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ghack_text_window_rip_string( const char* string)
|
||||
void
|
||||
ghack_text_window_rip_string(const char *string)
|
||||
{
|
||||
/* This is called to specify that the next message window will
|
||||
* be a RIP window, which will include this text */
|
||||
|
||||
showRIP = 1;
|
||||
gtk_label_set( GTK_LABEL( RIPlabel), string);
|
||||
gtk_label_set(GTK_LABEL(RIPlabel), string);
|
||||
}
|
||||
|
||||
|
||||
+37
-31
@@ -1,6 +1,6 @@
|
||||
/* NetHack 3.6 gnworn.c 2009/05/06 10:58:06 1.3 */
|
||||
/*
|
||||
* $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$
|
||||
* $NHDT-Date: 1431192771 2015/05/09 17:32:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $
|
||||
* $Date: 2012/01/10 17:47:38 $ $Revision: 1.4 $
|
||||
*/
|
||||
/* Copyright (C) 2002, Dylan Alex Simon */
|
||||
@@ -11,17 +11,21 @@
|
||||
#include "gnsignal.h"
|
||||
#include "gnomeprv.h"
|
||||
|
||||
#define WORN_WIDTH 3
|
||||
#define WORN_HEIGHT 6
|
||||
#define WORN_WIDTH 3
|
||||
#define WORN_HEIGHT 6
|
||||
|
||||
#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 } \
|
||||
}
|
||||
#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 \
|
||||
} \
|
||||
}
|
||||
|
||||
static GtkWidget *worn_contents[WORN_HEIGHT][WORN_WIDTH];
|
||||
static struct obj *last_worn_objects[WORN_HEIGHT][WORN_WIDTH];
|
||||
@@ -29,26 +33,27 @@ 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*
|
||||
GtkWidget *
|
||||
ghack_init_worn_window()
|
||||
{
|
||||
GtkWidget *top;
|
||||
GtkWidget *table;
|
||||
GtkWidget *tablealign;
|
||||
GtkWidget *label;
|
||||
int i,j;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
@@ -59,21 +64,21 @@ ghack_init_worn_window()
|
||||
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);
|
||||
GTK_SIGNAL_FUNC(ghack_worn_display), NULL);
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
GdkImlibImage*
|
||||
GdkImlibImage *
|
||||
image_of_worn_object(struct obj *o)
|
||||
{
|
||||
int glyph;
|
||||
GdkImlibImage *im;
|
||||
|
||||
if (o)
|
||||
glyph = obj_to_glyph(o);
|
||||
glyph = obj_to_glyph(o);
|
||||
else
|
||||
glyph = cmap_to_glyph(S_stone);
|
||||
glyph = cmap_to_glyph(S_stone);
|
||||
|
||||
im = ghack_image_from_glyph(glyph, FALSE);
|
||||
|
||||
@@ -87,12 +92,13 @@ ghack_worn_display(GtkWidget *win, boolean block, gpointer data)
|
||||
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]));
|
||||
}
|
||||
}
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+37
-43
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 gnyesno.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 gnyesno.c $NHDT-Date: 1431192773 2015/05/09 17:32:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 gnyesno.c $Date: 2009/05/06 10:58:06 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)gnyesno.c 3.5 2000/07/16 */
|
||||
/* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
|
||||
@@ -7,47 +7,42 @@
|
||||
#include "gnbind.h"
|
||||
#include "gnyesno.h"
|
||||
|
||||
|
||||
|
||||
int ghack_yes_no_dialog( const char *question,
|
||||
const char *choices, int def)
|
||||
int
|
||||
ghack_yes_no_dialog(const char *question, const char *choices, int def)
|
||||
{
|
||||
int i=0, ret;
|
||||
int i = 0, ret;
|
||||
gchar button_name[BUFSZ];
|
||||
GtkWidget *box;
|
||||
GtkWidget* mainWnd=NULL;
|
||||
GtkWidget *mainWnd = NULL;
|
||||
|
||||
box = gnome_message_box_new ( question, GNOME_MESSAGE_BOX_QUESTION, NULL);
|
||||
box = gnome_message_box_new(question, GNOME_MESSAGE_BOX_QUESTION, NULL);
|
||||
/* add buttons for each choice */
|
||||
if (!strcmp(GNOME_STOCK_BUTTON_OK, choices)) {
|
||||
gnome_dialog_append_button ( GNOME_DIALOG(box), GNOME_STOCK_BUTTON_OK);
|
||||
gnome_dialog_set_default( GNOME_DIALOG(box), 0);
|
||||
gnome_dialog_set_accelerator( GNOME_DIALOG(box), 0, 'o', 0);
|
||||
gnome_dialog_append_button(GNOME_DIALOG(box), GNOME_STOCK_BUTTON_OK);
|
||||
gnome_dialog_set_default(GNOME_DIALOG(box), 0);
|
||||
gnome_dialog_set_accelerator(GNOME_DIALOG(box), 0, 'o', 0);
|
||||
#if 0
|
||||
g_print("Setting accelerator '%c' for button %d\n", 'o', 0);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
for( ; choices[i]!='\0'; i++) {
|
||||
if (choices[i]=='y') {
|
||||
sprintf( button_name, GNOME_STOCK_BUTTON_YES);
|
||||
}
|
||||
else if (choices[i]=='n') {
|
||||
sprintf( button_name, GNOME_STOCK_BUTTON_NO);
|
||||
}
|
||||
else if (choices[i] == 'q') {
|
||||
sprintf( button_name, "Quit");
|
||||
} else {
|
||||
sprintf( button_name, "%c", choices[i]);
|
||||
}
|
||||
if (def==choices[i])
|
||||
gnome_dialog_set_default( GNOME_DIALOG(box), i);
|
||||
gnome_dialog_append_button ( GNOME_DIALOG(box), button_name);
|
||||
gnome_dialog_set_accelerator( GNOME_DIALOG(box), i, choices[i], 0);
|
||||
} else {
|
||||
for (; choices[i] != '\0'; i++) {
|
||||
if (choices[i] == 'y') {
|
||||
sprintf(button_name, GNOME_STOCK_BUTTON_YES);
|
||||
} else if (choices[i] == 'n') {
|
||||
sprintf(button_name, GNOME_STOCK_BUTTON_NO);
|
||||
} else if (choices[i] == 'q') {
|
||||
sprintf(button_name, "Quit");
|
||||
} else {
|
||||
sprintf(button_name, "%c", choices[i]);
|
||||
}
|
||||
if (def == choices[i])
|
||||
gnome_dialog_set_default(GNOME_DIALOG(box), i);
|
||||
gnome_dialog_append_button(GNOME_DIALOG(box), button_name);
|
||||
gnome_dialog_set_accelerator(GNOME_DIALOG(box), i, choices[i], 0);
|
||||
#if 0
|
||||
g_print("Setting accelerator '%c' for button %d\n", choices[i], i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* Perhaps add in a quit game button, like this... */
|
||||
@@ -56,23 +51,22 @@ int ghack_yes_no_dialog( const char *question,
|
||||
g_print("Setting accelerator '%c' for button %d\n", 'Q', i);
|
||||
#endif
|
||||
|
||||
gnome_dialog_set_close(GNOME_DIALOG (box), TRUE);
|
||||
mainWnd = ghack_get_main_window ();
|
||||
gtk_window_set_modal( GTK_WINDOW(box), TRUE);
|
||||
gtk_window_set_title( GTK_WINDOW(box), "GnomeHack");
|
||||
if ( mainWnd != NULL ) {
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (box),
|
||||
GTK_WINDOW ( mainWnd) );
|
||||
gnome_dialog_set_close(GNOME_DIALOG(box), TRUE);
|
||||
mainWnd = ghack_get_main_window();
|
||||
gtk_window_set_modal(GTK_WINDOW(box), TRUE);
|
||||
gtk_window_set_title(GTK_WINDOW(box), "GnomeHack");
|
||||
if (mainWnd != NULL) {
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(box), GTK_WINDOW(mainWnd));
|
||||
}
|
||||
|
||||
ret=gnome_dialog_run_and_close ( GNOME_DIALOG (box));
|
||||
|
||||
ret = gnome_dialog_run_and_close(GNOME_DIALOG(box));
|
||||
|
||||
#if 0
|
||||
g_print("You selected button %d\n", ret);
|
||||
#endif
|
||||
|
||||
if (ret==-1)
|
||||
return( '\033');
|
||||
|
||||
if (ret == -1)
|
||||
return ('\033');
|
||||
else
|
||||
return( choices[ret]);
|
||||
return (choices[ret]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user