1 const char *
const rcsid_gtk2_main_c =
"$Id: main.c 10739 2008-11-26 19:50:37Z kbulgrien $";
41 #include <glade/glade.h>
112 #define PACKAGE_DATA_DIR "."
114 int do_scriptout(
void)
169 LOG(
LOG_INFO,
"main.c::client_exit",
"Exiting with return value 0.");
193 pollret = select(
maxfd, &tmp_read, NULL, NULL, &
timeout);
196 "Got errno %d on select call.", errno);
197 }
else if ( pollret>0 ) {
251 fleep = gtk_timeout_add (10, (GtkFunction) do_timeout, NULL);
254 gtk_timeout_add (25, (GtkFunction) do_scriptout, NULL);
271 gtk_timeout_remove(tag);
274 "gtk_main exited, returning from event_loop");
300 puts(
"Usage of crossfire-client-gtk2:\n");
301 puts(
"-cache - Cache images for future use.");
302 puts(
"-nocache - Do not cache images (default action).");
303 puts(
"-darkness - Enables darkness code (default)");
304 puts(
"-nodarkness - Disables darkness code");
305 puts(
"-display <name> - Use <name> instead if DISPLAY environment variable.");
306 puts(
"-download_all_faces - Download all needed faces before play starts");
307 puts(
"-echo - Echo the bound commands");
308 puts(
"-noecho - Do not echo the bound commands (default)");
309 puts(
"-faceset <name> - Use faceset <name> if available");
310 puts(
"-fasttcpsend - Send data immediately to server, may increase bandwidth");
311 puts(
"-nofasttcpsend - Disables fasttcpsend");
312 puts(
"-fog - Enable fog of war code");
313 puts(
"-help - Display this message.");
314 puts(
"-loglevel <val> - Set default logging level (0 is most verbose)");
315 puts(
"-iconscale %% - Set icon scale percentage");
316 puts(
"-mapscale %% - Set map scale percentage");
317 puts(
"-mapsize xXy - Set the mapsize to be X by Y spaces. (default 11x11)");
318 puts(
"-splash - Display the splash screen (default)");
319 puts(
"-nosplash - Don't display the splash screen (startup logo)");
320 puts(
"-opengl - Use opengl drawing code");
321 puts(
"-pixmap - Use pixmap drawing code");
322 puts(
"-port <number> - Use port <number> instead of the standard port number");
323 puts(
"-sdl - Use sdl for drawing png (may not work on all hardware");
324 puts(
"-server <name> - Connect to <name> instead of localhost.");
325 puts(
"-showicon - Print status icons in inventory window");
326 puts(
"-smooth - Enable smooth");
327 puts(
"-nosmooth - Disable smooth (default)");
328 puts(
"-sound - Enable sound output (default).");
329 puts(
"-nosound - Disable sound output.");
330 puts(
"-sound_server <path> - Executable to use to play sounds.");
331 puts(
"-resists <val> - Control look of resistances.");
332 puts(
"-split - Use split windows.");
333 puts(
"-splitinfo - Use two information windows, segregated by information type.");
334 puts(
"-timemapredraw - Print out timing information for map generation");
335 puts(
"-triminfowindow - Trims size of information window(s)");
336 puts(
"-notriminfowindow - Do not trims size of information window(s) (default)");
337 puts(
"-updatekeycodes - Update the saved bindings for this keyboard.");
338 puts(
"-window_xml <file> - Glade Designer client UI layout XML file.");
339 puts(
"-dialog_xml <file> - Glade Designer popup dialog XML file.");
353 char *display_name=
"";
367 for (on_arg=1; on_arg<argc; on_arg++) {
368 if (!strcmp(argv[on_arg],
"-cache")) {
371 }
else if (!strcmp(argv[on_arg],
"-nocache")) {
374 }
else if (!strcmp(argv[on_arg],
"-darkness")) {
377 }
else if (!strcmp(argv[on_arg],
"-nodarkness")) {
380 }
else if (!strcmp(argv[on_arg],
"-display")) {
381 if (++on_arg == argc) {
383 "-display requires a display name");
386 display_name = argv[on_arg];
388 }
else if (!strcmp(argv[on_arg],
"-download_all_faces")) {
391 }
else if (!strcmp(argv[on_arg],
"-echo")) {
394 }
else if (!strcmp(argv[on_arg],
"-noecho")) {
397 }
else if (!strcmp(argv[on_arg],
"-faceset")) {
398 if (++on_arg == argc) {
400 "-faceset requires a faceset name/number");
405 }
else if (!strcmp(argv[on_arg],
"-fog")) {
408 }
else if (!strcmp(argv[on_arg],
"-nofog")) {
411 }
else if (!strcmp(argv[on_arg],
"-help")) {
414 }
else if (!strcmp(argv[on_arg],
"-iconscale")) {
415 if (++on_arg == argc) {
417 "-iconscale requires a percentage value");
423 "Valid range for -iconscale is 25 through 200");
428 }
else if (!strcmp(argv[on_arg],
"-mapscale")) {
429 if (++on_arg == argc) {
431 "-mapscale requires a percentage value");
437 "Valid range for -mapscale is 25 through 200");
442 }
else if (!strcmp(argv[on_arg],
"-mapsize")) {
445 if (++on_arg == argc) {
447 "-mapsize requires a XxY value");
450 x = atoi(argv[on_arg]);
451 for (cp = argv[on_arg]; *cp!=
'\0'; cp++)
452 if (*cp ==
'x' || *cp ==
'X')
break;
456 "both X and Y values (ie, XxY - note the\nx in between.");
462 "Map size must be positive values of at least 9");
472 }
else if (!strcmp(argv[on_arg],
"-fasttcpsend")) {
475 }
else if (!strcmp(argv[on_arg],
"-nofasttcpsend")) {
478 }
else if (!strcmp(argv[on_arg],
"-opengl")) {
481 "with opengl support. Ignoring -opengl");
486 }
else if (!strcmp(argv[on_arg],
"-pixmap")) {
488 }
else if (!strcmp(argv[on_arg],
"-port")) {
489 if (++on_arg == argc) {
491 "-port requires a port number");
496 }
else if (!strcmp(argv[on_arg],
"-sdl")) {
499 "client not compiled with sdl support. Ignoring -sdl");
504 }
else if (!strcmp(argv[on_arg],
"-server")) {
505 if (++on_arg == argc) {
507 "-server requires a host name");
512 }
else if (!strcmp(argv[on_arg],
"-showicon")) {
515 }
else if (!strcmp(argv[on_arg],
"-smooth")) {
517 }
else if (!strcmp(argv[on_arg],
"-nosmooth")) {
519 }
else if (!strcmp(argv[on_arg],
"-sound")) {
522 }
else if (!strcmp(argv[on_arg],
"-nosound")) {
525 }
else if (!strcmp(argv[on_arg],
"-sound_server")) {
526 if (++on_arg == argc) {
528 "-sound_server requires an executable pathname");
533 }
else if (!strcmp(argv[on_arg],
"-split")) {
536 }
else if (!strcmp(argv[on_arg],
"-nosplit")) {
539 }
else if (!strcmp(argv[on_arg],
"-resists")) {
540 if (++on_arg == argc) {
542 "-resists requires a value");
547 }
else if (!strcmp(argv[on_arg],
"-loglevel")) {
550 if (++on_arg == argc) {
552 "-loglevel requires a value");
555 MINLOG = atoi(argv[on_arg]);
557 }
else if (!strcmp(argv[on_arg],
"-splitinfo")) {
560 }
else if (!strcmp(argv[on_arg],
"-timemapredraw")) {
563 }
else if (!strcmp(argv[on_arg],
"-triminfowindow")) {
566 }
else if (!strcmp(argv[on_arg],
"-notriminfowindow")) {
569 }
else if (!strcmp(argv[on_arg],
"-updatekeycodes")) {
572 }
else if (!strcmp(argv[on_arg],
"-splash")) {
575 }
else if (!strcmp(argv[on_arg],
"-nosplash")) {
578 }
else if (!strcmp(argv[on_arg],
"-window_xml")) {
579 if (++on_arg == argc) {
581 "-window_xml requires a glade xml file name");
586 }
else if (!strcmp(argv[on_arg],
"-dialog_xml")) {
587 if (++on_arg == argc) {
589 "-dialog_xml requires a glade xml file name");
596 "Do not understand option %s", argv[on_arg]);
640 gtk_init(NULL, NULL);
642 gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
643 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Crossfire %s\n%s",
645 gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),
647 gtk_dialog_run(GTK_DIALOG(dialog));
648 gtk_widget_destroy(dialog);
661 static char file_cache[
MAX_BUF ];
662 GdkGeometry geometry;
666 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
667 bind_textdomain_codeset (GETTEXT_PACKAGE,
"UTF-8");
668 textdomain (GETTEXT_PACKAGE);
672 gtk_init (&argc, &argv);
690 WORD Version = 0x0202;
693 if (WSAStartup( Version, &wsaData ) != 0) {
701 maxfd = sysconf(_SC_OPEN_MAX);
703 maxfd = getdtablesize();
756 g_signal_connect_swapped ((gpointer)
window_root,
"key_press_event",
757 G_CALLBACK (
keyfunc), GTK_OBJECT (window_root));
758 g_signal_connect_swapped ((gpointer) window_root,
"key_release_event",
759 G_CALLBACK (
keyrelfunc), GTK_OBJECT (window_root));
760 g_signal_connect ((gpointer) window_root,
"destroy",
764 geometry.min_width=640;
765 geometry.min_height=480;
767 gtk_window_set_geometry_hints(GTK_WINDOW(window_root), window_root,
768 &geometry, GDK_HINT_MIN_SIZE);
773 fprintf(stderr,
"gdk_color_parse failed (%s)\n",
colorname[i]);
775 if ( !gdk_color_alloc (gtk_widget_get_colormap (window_root),
777 fprintf(stderr,
"gdk_color_alloc failed\n");
796 gtk_widget_show (window_root);
800 xml_tree = glade_get_widget_tree(GTK_WIDGET(window_root));
801 magic_map = glade_xml_get_widget(xml_tree,
"drawingarea_magic_map");
803 g_signal_connect ((gpointer)
magic_map,
"expose_event",
806 snprintf( file_cache,
MAX_BUF,
"%s/.crossfire/servers.cache", getenv(
"HOME" ) );
892 gdk_window_get_geometry (win->window, x, y, w, h, NULL);
894 gdk_window_get_origin (win->window, wx, wy);
char dialog_xml_file[MAX_BUF]
void negotiate_connection(int sound)
void update_spell_information(void)
int main(int argc, char *argv[])
static void usage(char *progname)
void load_window_positions(GtkWidget *window_root)
char dialog_xml_path[MAX_BUF]
#define DEFAULT_IMAGE_SIZE
void mapdata_animation(void)
void init_client_vars(void)
void inventory_init(GtkWidget *window_root)
static void init_cache_data(void)
char window_xml_file[MAX_BUF]
void magic_map_flash_pos(void)
void keyfunc(GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
void stats_init(GtkWidget *window_root)
void enable_menu_items(int enable)
void config_init(GtkWidget *window_root)
GdkColor root_color[NUM_COLORS]
void clear_stat_mapping(void)
Face_Information face_info
const char *const colorname[NUM_COLORS]
sint16 want_config[CONFIG_NUMS]
void pickup_init(GtkWidget *window_root)
void inventory_tick(void)
#define WINDOW_XML_FILENAME
const char *const rcsid_gtk2_main_c
void client_tick(uint32 tick)
int init_connection(char *host, int port)
void LOG(LogLevel level, const char *origin, const char *format,...)
void reset_client_vars(void)
void reset_image_data(void)
static void sigpipe_handler(int sig)
char * get_metaserver(void)
sint16 use_config[CONFIG_NUMS]
void on_window_destroy_event(GtkObject *object, gpointer user_data)
void info_init(GtkWidget *window_root)
#define DIALOG_XML_FILENAME
gboolean on_drawingarea_magic_map_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
void keys_init(GtkWidget *window_root)
static GtkWidget * description
char window_xml_path[MAX_BUF]
void get_window_coord(GtkWidget *win, int *x, int *y, int *wx, int *wy, int *w, int *h)
void map_init(GtkWidget *window_root)
item * locate_item(sint32 tag)
void draw_look_list(void)
static uint8 updatekeycodes
static void error_dialog(char *description, char *information)
void script_fdset(int *maxfd, fd_set *set)
void remove_item_inventory(item *op)
void cleanup_connection(void)
void load_theme(int reload)
void opengl_gen_map(int redraw)
int parse_args(int argc, char **argv)
void DoClient(ClientSocket *csocket)
#define CONFIG_DISPLAYMODE
const char *const usercolorname[NUM_COLORS]
void script_process(fd_set *set)
void sdl_gen_map(int redraw)
void draw_map(int redraw)
void keyrelfunc(GtkWidget *widget, GdkEventKey *event, GtkWidget *window)