GNOME Bugzilla – Bug 350068
iagno new version-1
Last modified: 2007-05-04 17:01:57 UTC
I made iagno new version. Please try this patch. file save, file open, sound, network supported. keyboard input supported but not compleat. resizeable window is not supported yet. diff -uNr gnome-games-2.14.1.org/iagno/gnothello.c gnome-games-2.14.1/iagno/gnothello.c --- gnome-games-2.14.1.org/iagno/gnothello.c 2006-08-05 15:32:11.000000000 +0900 +++ gnome-games-2.14.1/iagno/gnothello.c 2006-08-05 23:00:46.000000000 +0900 @@ -1,8 +1,5 @@ -/* -*- mode:C; indent-tabs-mode:t; tab-width:8; c-basic-offset:8; -*- */ - /* - * gnothello.c - Main GUI part of iagno - * written by Ian Peters <itp@gnu.org> + * gnothello.c * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,776 +18,1254 @@ * For more details see the file COPYING. */ -#include <config.h> -#include <gnome.h> -#include <libgnomeui/gnome-window-icon.h> -#include <gdk/gdkkeysyms.h> -#include <gdk-pixbuf/gdk-pixbuf.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif -#include <string.h> +#include <gnome.h> +#include <gconf/gconf-client.h> +#include <glib.h> +#include <stdio.h> +#include <fcntl.h> #include "gnothello.h" #include "othello.h" #include "properties.h" -#include "games-network.h" #include "network.h" +#include "games-network.h" +#include "games-clock.h" -GnomeAppBar *appbar; -GtkWidget *window; -GtkWidget *drawing_area; -GtkWidget *tile_dialog; -GtkWidget *black_score; -GtkWidget *white_score; +gint8 pixmaps[8][8]; +gint8 board[8][8]; +guint8 kifu[61][2]; +GtkWidget *window; +GtkWidget *propaties_dialog; +GtkWidget *file_open_dialog; +GtkWidget *file_save_dialog; GdkPixmap *buffer_pixmap = NULL; GdkPixmap *tiles_pixmap = NULL; GdkPixmap *tiles_mask = NULL; +GdkGC *gridGC[2] = { 0 }; +GtkWidget *b_timer; +GtkWidget *w_timer; + +gchar *flip_sound; +gchar *gameover_sound; +gboolean play_sound = FALSE; -gint flip_pixmaps_id = 0; -gint statusbar_id; guint black_computer_level; guint white_computer_level; +guint quick_moves; +guint animate; +gboolean animate_stagger; +guint grid; +gboolean flip_final; +gchar *tile_set; +guint computer_speed; +guint flip_speed; + +guint t_black_computer_level; +guint t_white_computer_level; +guint t_quick_moves; +guint t_animate; +gboolean t_animate_stagger; +guint t_grid; +gboolean t_flip_final; +gchar *t_tile_set; + +gboolean tiles_to_flip = FALSE; +guint context_id1 = 0; +guint context_id2 = 0; guint black_computer_id = 0; guint white_computer_id = 0; -guint computer_speed = COMPUTER_MOVE_DELAY; -gint animate; -gint animate_stagger; -gint grid = 0; -guint tiles_to_flip = 0; - -gint64 milliseconds_total = 0; -gint64 milliseconds_current_start = 0; +guint flip_pixmaps_id = 0; +guint flip_final_id = 0; guint game_in_progress; +extern guint whose_turn; -gint8 pixmaps[8][8] = {{0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}}; - -gint8 board[8][8] = {{0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}}; - -guint whose_turn; -gint8 move_count; -gint bcount; -gint wcount; - -extern guint flip_final_id; -extern gint8 squares[64]; - -int session_flag = 0; -int session_xpos = -1; -int session_ypos = -1; -int session_position = 0; - -gchar *tile_set = NULL; -gchar *tile_set_tmp = NULL; - -GdkGC *gridGC[2] = { 0 }; - -static void new_network_game_cb(GtkWidget *widget, gpointer data); - -static const struct poptOption options[] = { - {NULL, 'x', POPT_ARG_INT, &session_xpos, 0, NULL, NULL}, - {NULL, 'y', POPT_ARG_INT, &session_ypos, 0, NULL, NULL}, - {"server", 's', POPT_ARG_STRING, &game_server, 0, N_("Iagno server to use")}, - {NULL, '\0', 0, NULL, 0} -}; - -GnomeUIInfo game_menu[] = { - GNOMEUIINFO_MENU_NEW_GAME_ITEM(new_game_cb, NULL), - - GNOMEUIINFO_ITEM(N_("New Net_work Game"), NULL, new_network_game_cb, NULL), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_MENU_UNDO_MOVE_ITEM(undo_move_cb, NULL), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_MENU_QUIT_ITEM(quit_game_cb, NULL), - - GNOMEUIINFO_END -}; - -GnomeUIInfo settings_menu[] = { - GNOMEUIINFO_MENU_PREFERENCES_ITEM (properties_cb, NULL), - GNOMEUIINFO_END -}; +extern GtkWidget *drawingarea; +extern GtkWidget *b_score_status; +extern GtkWidget *w_score_status; +extern GtkWidget *info_status; +extern GtkWidget *entry; +extern GtkWidget *b_time_status; +extern GtkWidget *w_time_status; + +extern guint board0[100]; +extern guint squares[64]; +extern gint vsquares[280][2]; +extern guint hpointer; +extern guint vpointer; +extern guint s_kind; +extern guint bcount; +extern guint wcount; +extern guint move_count; + +#define KEY_TILESET "/apps/iagno/tileset" +#define KEY_BLACK_LEVEL "/apps/iagno/black_level" +#define KEY_WHITE_LEVEL "/apps/iagno/white_level" +#define KEY_QUICK_MOVES "/apps/iagno/quick_moves" +#define KEY_ANIMATE "/apps/iagno/animate" +#define KEY_ANIMATE_STAGGER "/apps/iagno/animate_stagger" +#define KEY_SHOW_GRID "/apps/iagno/show_grid" +#define KEY_FLIP_FINAL_RESULTS "/apps/iagno/flip_final_results" -GnomeUIInfo help_menu[] = { - GNOMEUIINFO_HELP("iagno"), - GNOMEUIINFO_MENU_ABOUT_ITEM(about_cb, NULL), - GNOMEUIINFO_END -}; - -GnomeUIInfo mainmenu[] = { - GNOMEUIINFO_MENU_GAME_TREE(game_menu), - GNOMEUIINFO_MENU_SETTINGS_TREE(settings_menu), - GNOMEUIINFO_MENU_HELP_TREE(help_menu), - GNOMEUIINFO_END -}; - -static void undo_set_sensitive (gboolean state) +void +on_open_activate (GtkMenuItem *menuitem, gpointer user_data) { - gtk_widget_set_sensitive (game_menu[3].widget, state); + network_stop (); + game_in_progress = FALSE; + games_clock_stop (GAMES_CLOCK(b_time_status)); + games_clock_stop (GAMES_CLOCK(w_time_status)); + games_clock_set_seconds (GAMES_CLOCK(b_time_status), 0); + games_clock_set_seconds (GAMES_CLOCK(w_time_status), 0); + kifu [0][0] = 0; + file_open_dialog = create_file_open_dialog (); + gtk_widget_show (file_open_dialog); } void -quit_game_cb (GtkWidget *widget, gpointer data) +on_save_activate (GtkMenuItem *menuitem, gpointer user_data) { - games_kill_server (); - gtk_main_quit (); + GDate *date; + gchar filename[17]; + + date = g_date_new (); + g_date_set_time_t (date, time (NULL)); + g_date_strftime (filename, 17, _("%y%m%d%H"), date); + + file_save_dialog = create_file_save_dialog (); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_save_dialog), + filename); + gtk_widget_show (file_save_dialog); + g_date_free (date); } -static void -new_network_game_cb (GtkWidget *widget, gpointer data) +void +on_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { - network_new (window); + games_kill_server (); + gtk_main_quit (); } void -new_game_cb (GtkWidget *widget, gpointer data) +on_new_game_activate (GtkMenuItem *menuitem, gpointer user_data) { network_stop (); init_new_game (); } void -undo_move_cb (GtkWidget *widget, gpointer data) +on_new_network_game_activate (GtkMenuItem *menuitem, gpointer user_data) { - gint8 which_computer, xy; - - if ((black_computer_level && white_computer_level) || move_count == 4) - return; - - if (flip_final_id) { - g_source_remove (flip_final_id); - flip_final_id = 0; - } - - game_in_progress = 1; - - which_computer = OTHER_PLAYER (whose_turn); - undo(); - board_copy(); - xy=squares[move_count]; - pixmaps[xy%10-1][xy/10-1] = 100; - if ((((whose_turn == WHITE_TURN) && white_computer_level) || - ((whose_turn == BLACK_TURN) && black_computer_level)) - && (move_count > 4)) { - undo(); - board_copy(); - xy=squares[move_count]; - pixmaps[xy%10-1][xy/10-1] = 100; - } - - if (whose_turn == WHITE_TURN) - gui_message (_("Light's move")); - else - gui_message (_("Dark's move")); - - gui_status (); - tiles_to_flip = 1; - check_computer_players (); + network_new (window); } void -black_level_cb (GtkWidget *widget, gpointer data) +on_undo_activate (GtkMenuItem *menuitem, gpointer user_data) { - int tmp; + on_undobutton_clicked (NULL, NULL); +} - tmp = atoi ((gchar *)data); +void +on_hint_activate (GtkMenuItem *menuitem, gpointer user_data) +{ + on_infobutton_clicked (NULL, NULL); +} - gnome_config_set_int ("/iagno/Preferences/blacklevel", tmp); - gnome_config_sync (); +void +on_preference_activate (GtkMenuItem *menuitem, gpointer user_data) +{ + propaties_dialog = create_propaties_dialog (); + gtk_widget_show (propaties_dialog); +} - black_computer_level = tmp; +void +on_about_activate (GtkMenuItem *menuitem, gpointer user_data) +{ + GtkWidget *about_dialog; - check_computer_players (); + about_dialog = create_about_dialog (); + gtk_widget_show (about_dialog); } void -white_level_cb (GtkWidget *widget, gpointer data) +on_newbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) { - int tmp; + on_new_game_activate (NULL, NULL); +} - tmp = atoi ((gchar *)data); +void +on_undobutton_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + guint who; - gnome_config_set_int ("/iagno/Preferences/whitelevel", tmp); - gnome_config_sync (); + if (is_network_running ()) + return; + if (!network_allow ()) + network_stop (); + if (move_count <= 4) + return; + if (black_computer_level && white_computer_level) + return; + + if (flip_final_id) + { + g_source_remove (flip_final_id); + flip_final_id = 0; + } + game_in_progress = TRUE; + games_clock_stop (GAMES_CLOCK(b_time_status)); + games_clock_stop (GAMES_CLOCK(w_time_status)); + + back (); + kifu [move_count - 4][0] = 0; + copy_board (); + who = OTHER_PLAYER (whose_turn); + while ((whose_turn != who) && (move_count > 4)) + { + back (); + kifu [move_count - 4][0] = 0; + copy_board (); + } + + gui_status (); + tiles_to_flip = TRUE; + play_sound = TRUE; + check_valid_moves (); + check_computer_players (); +} - white_computer_level = tmp; +void +on_headbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + if (is_network_running ()) + return; + if (flip_final_id) + { + g_source_remove (flip_final_id); + flip_final_id = 0; + } + game_in_progress = FALSE; + init (); + copy_board (); + copy_pixmaps (); + redraw_board (); + gui_message (_("Dark's move")); +} - check_computer_players (); +void +on_backbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + if (is_network_running ()) + return; + if (move_count <= 4) + return; + if (flip_final_id) + { + g_source_remove (flip_final_id); + flip_final_id = 0; + } + game_in_progress = FALSE; + back (); + copy_board (); + gui_status (); + tiles_to_flip = TRUE; + play_sound = TRUE; + check_valid_moves (); } void -about_cb (GtkWidget *widget, gpointer data) +on_forwardbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) { - const gchar *authors[] = {"Ian Peters", NULL}; + guint xy, me; + + if (is_network_running ()) + return; + game_in_progress = FALSE; + me = (guint) kifu[move_count - 4][0]; + if (!me) + { + if (check_valid_moves ()) + game_in_progress = TRUE; + return; + } + whose_turn = me; + xy = (guint) kifu[move_count - 4][1]; + move (xy % 10, xy / 10); + check_valid_moves (); +} - gtk_show_about_dialog (GTK_WINDOW (window), - "name", _("Iagno"), - "version", VERSION, - "copyright", "Copyright \xc2\xa9 1998-2004 Ian Peters", - "comments",_("A disk flipping game derived from Reversi."), - "authors", authors, - "translator_credits", _("translator-credits"), - NULL); +void +on_lastbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + if (is_network_running ()) + return; + game_in_progress = FALSE; + while (kifu[move_count - 4][0]) + { + whose_turn = (guint) kifu[move_count - 4][0]; + move_board ((guint) kifu[move_count - 4][1]); + } + copy_board (); + copy_pixmaps (); + redraw_board (); + if (check_valid_moves ()) + game_in_progress = TRUE; } void -properties_cb (GtkWidget *widget, gpointer data) +on_infobutton_clicked (GtkToolButton *toolbutton, gpointer user_data) { - show_properties_dialog (); + guint tmp; + + if (move_count < 4 || move_count > 63) + return; + if (!mobility (whose_turn)) + return; + + tmp = game_in_progress; + game_in_progress = FALSE; + computer_move (4); + game_in_progress = tmp; + gui_hint (vsquares[0][0], vsquares[0][1]); } -gint -expose_event (GtkWidget *widget, GdkEventExpose *event) -{ - gdk_draw_drawable (widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - buffer_pixmap, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); - return(FALSE); +void +on_quitbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + on_quit_activate (NULL, NULL); } -gint -configure_event (GtkWidget *widget, GdkEventConfigure *event) +gboolean +on_drawingarea_expose_event (GtkWidget *widget, + GdkEventExpose *event, gpointer user_data) { - static int old_width = 0, old_height = 0; - guint i, j; + gdk_draw_drawable (widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + buffer_pixmap, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height); - if (old_width == event->width && old_height == event->height) { - return TRUE; - } else { - old_width = event->width; - old_height = event->height; - } - - if (gridGC[0] != 0) { - gdk_draw_rectangle (buffer_pixmap, gridGC[0], 1, - 0, 0, BOARDWIDTH, BOARDHEIGHT); - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - gui_draw_pixmap_buffer (pixmaps[i][j], i, j); - gui_draw_grid (); - } - - return TRUE; + return FALSE; } -gint -button_press_event (GtkWidget *widget, GdkEventButton *event) +gboolean +on_drawingarea_button_press_event (GtkWidget *widget, + GdkEventButton *event, gpointer user_data) { - guint x, y; + guint x, y; - if (game_in_progress == 0) - return TRUE; + if (!network_allow ()) + return FALSE; + if (!game_in_progress) + return FALSE; + if ((whose_turn == WHITE_TURN) && white_computer_level) + return FALSE; + if ((whose_turn == BLACK_TURN) && black_computer_level) + return FALSE; - if (!network_allow ()) - return TRUE; - - if ((whose_turn == WHITE_TURN) && white_computer_level) - return TRUE; + if (event->button) + { + x = event->x / (TILEWIDTH + GRIDWIDTH) + 1; + y = event->y / (TILEHEIGHT + GRIDWIDTH) + 1; + if (is_valid_move (x, y, whose_turn)) + game_move (x, y, whose_turn); + } - if ((whose_turn == BLACK_TURN) && black_computer_level) - return TRUE; + return FALSE; +} + +void +on_entry_notify (GObject *gobject, GParamSpec *arg1, gpointer user_data) +{ + gchar *ch; + guint x, y; - if (event->button == 1) { - x = event->x / (TILEWIDTH + GRIDWIDTH); - y = event->y / (TILEHEIGHT + GRIDWIDTH); - if (is_valid_move (x, y, whose_turn)) - game_move (x, y, whose_turn); - } + ch = gtk_entry_get_text (entry); + y = (guint)(ch[0] - 0x60); + x = (guint)(ch[1] - 0x30); + if (x < 1 || x > 8 || y < 1 || y > 8) + return; + if (is_valid_move (x, y, whose_turn)) + game_move (x, y, whose_turn); - return TRUE; } void -gui_draw_pixmap (gint which, gint x, gint y) +on_bcomputer_level_changed (GtkToggleButton *togglebutton, gpointer user_data) { - gdk_draw_drawable (drawing_area->window, gridGC[0], tiles_pixmap, - (which % 8) * TILEWIDTH, (which / 8) * TILEHEIGHT, - x * (TILEWIDTH + GRIDWIDTH), - y * (TILEHEIGHT + GRIDWIDTH), - TILEWIDTH, TILEHEIGHT); - gdk_draw_drawable (buffer_pixmap, gridGC[0], tiles_pixmap, - (which % 8) * TILEWIDTH, (which / 8) * TILEHEIGHT, - x * (TILEWIDTH + GRIDWIDTH), - y * (TILEHEIGHT + GRIDWIDTH), - TILEWIDTH, TILEHEIGHT); + if (is_network_running ()) + return; + t_black_computer_level = clamp_int (GPOINTER_TO_INT(user_data), 0, 3); } void -gui_draw_pixmap_buffer (gint which, gint x, gint y) +on_wcomputer_level_changed (GtkToggleButton *togglebutton, + gpointer user_data) { - gdk_draw_drawable (buffer_pixmap, gridGC[0], tiles_pixmap, - (which % 8) * TILEWIDTH, (which / 8) * TILEHEIGHT, - x * (TILEWIDTH + GRIDWIDTH), - y * (TILEHEIGHT + GRIDWIDTH), - TILEWIDTH, TILEHEIGHT); + if (is_network_running ()) + return; + t_white_computer_level = clamp_int (GPOINTER_TO_INT(user_data), 0, 3); } void -gui_draw_grid (void) +on_quick_moves_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - int i; - - for (i = 1; i < 8; i++) { - gdk_draw_line (buffer_pixmap, gridGC[grid], - i * BOARDWIDTH / 8 - 1, 0, - i * BOARDWIDTH / 8 - 1, BOARDHEIGHT); - gdk_draw_line (buffer_pixmap, gridGC[grid], - 0, i * BOARDHEIGHT / 8 - 1, - BOARDWIDTH, i * BOARDHEIGHT / 8 - 1); - } - - gdk_draw_drawable (drawing_area->window, gridGC[0], buffer_pixmap, - 0, 0, 0, 0, BOARDWIDTH, BOARDHEIGHT); + if (togglebutton->active) + t_quick_moves = 2; + else + t_quick_moves = 1; } void -load_pixmaps (void) +on_animate_changed (GtkToggleButton *togglebutton, gpointer user_data) { - GdkPixbuf *image; - GError *error = NULL; - gchar *tmp; - gchar *fname; - - g_return_if_fail (tile_set != NULL && tile_set [0] != '0'); - - tmp = g_build_filename ("iagno", tile_set, NULL); - fname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, - tmp, FALSE, NULL); - g_free (tmp); - - if (! g_file_test (fname, G_FILE_TEST_EXISTS)) { - g_free (fname); - fname = gnome_program_locate_file (NULL, - GNOME_FILE_DOMAIN_APP_PIXMAP, - "iagno/classic.png", - FALSE, NULL); - } - - if (! g_file_test (fname, - G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - g_print (_("Could not find \'%s\' pixmap file\n"), fname); - exit (1); - } - - image = gdk_pixbuf_new_from_file (fname, &error); - if (error) { - g_warning (G_STRLOC ": gdk-pixbuf error %s\n", error->message); - g_error_free (error); - error = NULL; - } - - gdk_pixbuf_render_pixmap_and_mask_for_colormap (image, - gdk_colormap_get_system(), - &tiles_pixmap, - &tiles_mask, 127); - - gdk_pixbuf_unref (image); - g_free (fname); + t_animate = clamp_int (GPOINTER_TO_INT (user_data), 0, 2); } -gint -flip_pixmaps (gpointer data) +void +on_stagger_flips_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - guint i, j; - guint flipped_tiles = 0; - - if (! tiles_to_flip) - return TRUE; - - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) { - /* This first case only happens when undoing the "final flip". */ - if ((pixmaps[i][j] == 101) && (board[i][j] != 0)) { - pixmaps[i][j] = board[i][j]; - gui_draw_pixmap (pixmaps[i][j], i, j); - flipped_tiles = 1; - } else if ((pixmaps[i][j] == 100) - || ((pixmaps[i][j] != 101) && (board[i][j] == 0))) { - pixmaps[i][j] = 101; - gui_draw_pixmap (0, i, j); - flipped_tiles = 1; - } else if (pixmaps[i][j] < board[i][j]) { - if (animate == 0) { - if (pixmaps[i][j] == BLACK_TURN) - pixmaps[i][j] = board[i][j]; - else - pixmaps[i][j]++; - } else if (animate == 1) { - if (pixmaps[i][j] < 1) - pixmaps[i][j] += 2; - else if (pixmaps[i][j] >= 1 && pixmaps[i][j] < 8) - pixmaps[i][j] = 8; - else if (pixmaps[i][j] >= 8 && pixmaps[i][j] < 16) - pixmaps[i][j] = 16; - else if (pixmaps[i][j] >= 16 && pixmaps[i][j] < 23) - pixmaps[i][j] = 23; - else if (pixmaps[i][j] >= 23 && pixmaps[i][j] < 31) - pixmaps[i][j] = 31; - else if (pixmaps[i][j] > 31) - pixmaps[i][j] = 31; - } else if (animate == 2) - pixmaps[i][j]++; - if (pixmaps[i][j] > 0) - gui_draw_pixmap (pixmaps[i][j], i, j); - flipped_tiles = 1; - } else if (pixmaps[i][j] > board[i][j] && pixmaps[i][j] != 101) { - if (animate == 0) { - if (pixmaps[i][j] == WHITE_TURN) - pixmaps[i][j] = board[i][j]; - else - pixmaps[i][j]--; - } else if (animate == 1) { - if (pixmaps[i][j] > 31) - pixmaps[i][j] -= 2; - else if (pixmaps[i][j] <= 31 && pixmaps[i][j] > 23) - pixmaps[i][j] = 23; - else if (pixmaps[i][j] <= 23 && pixmaps[i][j] > 16) - pixmaps[i][j] = 16; - else if (pixmaps[i][j] <= 16 && pixmaps[i][j] > 8) - pixmaps[i][j] = 8; - else if (pixmaps[i][j] <= 8 && pixmaps[i][j] > 1) - pixmaps[i][j] = 1; - else if (pixmaps[i][j] < 1) - pixmaps[i][j] = 1; - } else if (animate == 2) - pixmaps[i][j]--; - if (pixmaps[i][j] < 32) - gui_draw_pixmap (pixmaps[i][j], i, j); - flipped_tiles = 1; - } - } - - if (! flipped_tiles) - tiles_to_flip = 0; - - return TRUE; + if (togglebutton->active) + t_animate_stagger = TRUE; + else + t_animate_stagger = FALSE; } -static void -redraw_board (void) +void +on_show_grid_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - guint i, j; + if (togglebutton->active) + t_grid = 1; + else + t_grid = 0; +} - gui_status(); +void +on_flip_final_results_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + if (togglebutton->active) + t_flip_final = TRUE; + else + t_flip_final = FALSE; +} - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - gui_draw_pixmap_buffer (pixmaps[i][j], i, j); +void +on_tile_set_changed (GtkComboBox *combobox, gpointer user_data) +{ + if (t_tile_set) + g_free (t_tile_set); + t_tile_set = gtk_combo_box_get_active_text (combobox); +} - gui_draw_grid (); +void +on_apply_button_clicked (GtkButton *button, gpointer user_data) +{ + apply_changes (); + save_properties (); } void -clear_board (void) +on_propaties_cancel_clicked (GtkButton *button, gpointer user_data) { - guint i, j; + reset_properties (); + gtk_widget_destroy (propaties_dialog); +} - if (flip_final_id) { - g_source_remove (flip_final_id); - flip_final_id = 0; - } - - if (black_computer_id) { - g_source_remove (black_computer_id); - black_computer_id = 0; - } - - if (white_computer_id) { - g_source_remove (white_computer_id); - white_computer_id = 0; - } - - game_in_progress = 0; - move_count = 0; - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - board[i][j] = 0; +void +on_ok_button_clicked (GtkButton *button, gpointer user_data) +{ + apply_changes (); + save_properties (); + gtk_widget_destroy (propaties_dialog); +} - memcpy (pixmaps, board, sizeof (gint8) * 8 * 8); +void +on_file_open_cancel_clicked (GtkButton *button, gpointer user_data) +{ + gtk_widget_destroy (file_open_dialog); +} - bcount = 0; - wcount = 0; +void +on_open_button_clicked (GtkButton *button, gpointer user_data) +{ + gchar *filename; + int fd; - redraw_board (); + filename = + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_open_dialog)); + fd = open (filename, 0, 0644); + if (fd) + { + read_kifu (fd); + close (fd); + } + gtk_widget_destroy (file_open_dialog); + g_free (filename); + on_headbutton_clicked (NULL, NULL); } void -init_new_game (void) +on_file_save_cancel_clicked (GtkButton *button, gpointer user_data) { - clear_board (); - game_in_progress = 1; - move_count = 4; + gtk_widget_destroy (file_save_dialog); +} - undo_set_sensitive (FALSE); - - board[3][3] = WHITE_TURN; - board[3][4] = BLACK_TURN; - board[4][3] = BLACK_TURN; - board[4][4] = WHITE_TURN; +void +on_save_button_clicked (GtkButton *button, gpointer user_data) +{ + gchar *filename; + int fd; + + filename = + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_save_dialog)); + + fd = creat (filename, 0644); + if (fd) + { + write_kifu (fd); + close (fd); + } + gtk_widget_destroy (file_save_dialog); + g_free (filename); +} - bcount = 2; - wcount = 2; - init(); +/* From here appended to callbacks.c made by glade */ +gint +clamp_int (gint input, gint low, gint high) +{ + if (input < low) + input = low; + if (input > high) + input = high; - memcpy (pixmaps, board, sizeof (gint8) * 8 * 8); + return input; +} - redraw_board (); +void +load_properties (void) +{ + GConfClient *client; + GError *error = NULL; - whose_turn = BLACK_TURN; - gui_message (_("Dark's move")); + client = gconf_client_get_default (); + black_computer_level = + gconf_client_get_int (client, KEY_BLACK_LEVEL, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + black_computer_level = clamp_int (black_computer_level, 0, 3); + + white_computer_level = + gconf_client_get_int (client, KEY_WHITE_LEVEL, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + white_computer_level = clamp_int (white_computer_level, 0, 3); + + quick_moves = gconf_client_get_int (client, KEY_QUICK_MOVES, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + quick_moves = clamp_int (quick_moves, 1, 2); + computer_speed = COMPUTER_MOVE_DELAY / quick_moves; + flip_speed = PIXMAP_FLIP_DELAY / quick_moves; + + animate = gconf_client_get_int (client, KEY_ANIMATE, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + animate = clamp_int (animate, 0, 2); + + animate_stagger = + gconf_client_get_bool (client, KEY_ANIMATE_STAGGER, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + + grid = gconf_client_get_int (client, KEY_SHOW_GRID, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + grid = clamp_int (grid, 0, 1); + + flip_final = + gconf_client_get_bool (client, KEY_FLIP_FINAL_RESULTS, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + + if (tile_set) + g_free (tile_set); + tile_set = gconf_client_get_string (client, KEY_TILESET, &error); + if (error) + { + g_warning (G_STRLOC ": gconf error: %s\n", error->message); + g_error_free (error); + error = NULL; + } + if (tile_set == NULL) + tile_set = g_strdup ("classic.png"); - check_computer_players (); + set_flip_pixmaps_id (); + g_object_unref (client); } void -create_window (void) +save_properties (void) { - GtkWidget *table; + GConfClient *client; - window = gnome_app_new ("iagno", _("Iagno")); + client = gconf_client_get_default (); - gtk_widget_realize (window); - gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (quit_game_cb), NULL); + gconf_client_set_int (client, KEY_BLACK_LEVEL, black_computer_level, NULL); + gconf_client_set_int (client, KEY_WHITE_LEVEL, white_computer_level, NULL); + gconf_client_set_int (client, KEY_QUICK_MOVES, quick_moves, NULL); + gconf_client_set_int (client, KEY_ANIMATE, animate, NULL); + gconf_client_set_bool (client, KEY_ANIMATE_STAGGER, animate_stagger, NULL); + gconf_client_set_int (client, KEY_SHOW_GRID, grid, NULL); + gconf_client_set_bool (client, KEY_FLIP_FINAL_RESULTS, flip_final, NULL); + gconf_client_set_string (client, KEY_TILESET, tile_set, NULL); +} - gnome_app_create_menus (GNOME_APP (window), mainmenu); +void +reset_properties (void) +{ + t_black_computer_level = black_computer_level; + t_white_computer_level = white_computer_level; + t_quick_moves = quick_moves; + t_animate = animate; + t_animate_stagger = animate_stagger; + t_grid = grid; + t_flip_final = flip_final; + + if (t_tile_set != NULL) + g_free (t_tile_set); + if (g_str_equal (tile_set, _("woodtrim.png"))) + t_tile_set = g_strdup ("woodtrim.png"); + else + t_tile_set = g_strdup ("classic.png"); +} - drawing_area = gtk_drawing_area_new (); +void +set_flip_pixmaps_id (void) +{ + if (flip_pixmaps_id) + g_source_remove (flip_pixmaps_id); - gtk_widget_pop_colormap (); + switch (animate) + { + case 0: + flip_pixmaps_id = g_timeout_add (100, flip_pixmaps, NULL); + break; + case 1: + flip_pixmaps_id = g_timeout_add (flip_speed * 8, flip_pixmaps, NULL); + break; + default: + case 2: + flip_pixmaps_id = g_timeout_add (flip_speed, flip_pixmaps, NULL); + break; + } +} - gnome_app_set_contents (GNOME_APP (window), drawing_area); +void +apply_changes (void) +{ + black_computer_level = t_black_computer_level; + white_computer_level = t_white_computer_level; + quick_moves = t_quick_moves; + computer_speed = COMPUTER_MOVE_DELAY / quick_moves; + flip_speed = PIXMAP_FLIP_DELAY / quick_moves; + animate = t_animate; + set_flip_pixmaps_id (); + animate_stagger = t_animate_stagger; + if (grid != t_grid) + { + grid = t_grid; + redraw_board(); + } + flip_final = t_flip_final; + if (!g_str_equal (tile_set, t_tile_set)) + { + if (tile_set) + g_free (tile_set); + tile_set = g_strdup (t_tile_set); + load_pixmaps (); + redraw_board(); + } + if (game_in_progress) + check_computer_players(); +} - gtk_widget_set_size_request (GTK_WIDGET (drawing_area), - BOARDWIDTH, BOARDHEIGHT); - g_signal_connect (G_OBJECT (drawing_area), "expose_event", - G_CALLBACK (expose_event), NULL); - g_signal_connect (G_OBJECT (window), "configure_event", - G_CALLBACK (configure_event), NULL); - g_signal_connect (G_OBJECT (drawing_area), "button_press_event", - G_CALLBACK (button_press_event), NULL); - gtk_widget_set_events (drawing_area, - GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); - gtk_widget_show (drawing_area); +void +load_pixmaps (void) +{ + GdkPixbuf *image; + gchar *fname; - appbar = GNOME_APPBAR (gnome_appbar_new (FALSE, TRUE, FALSE)); - gnome_app_set_statusbar (GNOME_APP (window), GTK_WIDGET (appbar)); - gnome_app_install_menu_hints (GNOME_APP (window), mainmenu); + fname = g_build_filename ("iagno", tile_set, NULL); + image = create_pixbuf (fname); + if (!image) + exit (1); + + if (tiles_pixmap) + g_object_unref (tiles_pixmap); + gdk_pixbuf_render_pixmap_and_mask_for_colormap (image, + gdk_colormap_get_system (), + &tiles_pixmap, + &tiles_mask, 127); - table = gtk_table_new (1, 8, FALSE); + g_object_unref (image); + g_free (fname); +} - black_score = gtk_label_new (_("Dark:")); - gtk_widget_show (black_score); +void +write_kifu (int fd) +{ + gchar buf[9]; + gint8 i; + ssize_t err; + + i = 0; + buf[2] = buf[4] = 0x20; + buf[7] = 0x0A; + buf[8] = 0; + + err = write (fd, _("iagno\n"), 6); + while (kifu[i][0] && err > 0) + { + buf[0] = (i + 1) / 10 + 0x30; + buf[1] = (i + 1) % 10 + 0x30; + buf[3] = (kifu[i][0] == BLACK_TURN)? 0x42: 0x57; + buf[5] = kifu[i][1] / 10 + 0x40; + buf[6] = kifu[i][1] % 10 + 0x30; + + err = write (fd, buf, 8); + i++; + } +} - gtk_table_attach (GTK_TABLE (table), black_score, 1, 2, 0, 1, 0, 0, 3, 1); +void +read_kifu (int fd) +{ + gchar buf[9]; + gint8 i = 0; + ssize_t err; + + err = read (fd, buf, 6); + buf[6] = 0; + if (!g_str_equal(buf, _("iagno\n"))) + { + gui_message (_("not iagno's file")); + return; + } + err = read (fd, buf, 8); + while (err > 0) + { + i = (buf[0] - 0x30) * 10 + buf[1] - 0x30 - 1; + kifu[i][0] = (buf[3] == 0x42)? BLACK_TURN : WHITE_TURN; + kifu[i][1] = (buf[5] - 0x40) * 10 + buf[6] - 0x30; + err = read (fd, buf, 8); + } + kifu[i + 1][0] = 0; +} - black_score = gtk_label_new ("00"); - gtk_widget_show (black_score); +static void +set_bg_color (void) +{ + GdkImage *tmpimage; + GdkColor bgcolor; - gtk_table_attach (GTK_TABLE (table), black_score, 2, 3, 0, 1, 0, 0, 3, 1); + tmpimage = gdk_drawable_get_image (tiles_pixmap, 0, 0, 1, 1); + bgcolor.pixel = gdk_image_get_pixel (tmpimage, 0, 0); + gdk_window_set_background (drawingarea->window, &bgcolor); + + if (gridGC[0]) + g_object_unref (gridGC[0]); + gridGC[0] = gdk_gc_new (drawingarea->window); + if (gridGC[1]) + g_object_unref (gridGC[1]); + gridGC[1] = gdk_gc_new (drawingarea->window); + + gdk_gc_copy (gridGC[0], drawingarea->style->bg_gc[0]); + gdk_gc_copy (gridGC[1], drawingarea->style->bg_gc[0]); + + gdk_gc_set_background (gridGC[0], &bgcolor); + gdk_gc_set_foreground (gridGC[0], &bgcolor); + + /* Create a complementary color to use for the ON state */ + bgcolor.pixel = 0xFFFFFF /* - bgcolor.pixel */; + gdk_gc_set_background (gridGC[1], &bgcolor); + gdk_gc_set_foreground (gridGC[1], &bgcolor); - white_score = gtk_label_new (_("Light:")); - gtk_widget_show (white_score); + gdk_gc_set_line_attributes (gridGC[1], 0, GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, GDK_JOIN_MITER); - gtk_table_attach (GTK_TABLE (table), white_score, 4, 5, 0, 1, 0, 0, 3, 1); + g_object_unref (tmpimage); +} - white_score = gtk_label_new ("00"); - gtk_widget_show (white_score); +void +gui_draw_pixmap (guint which, guint x, guint y) +{ + gdk_draw_drawable (drawingarea->window, gridGC[0], tiles_pixmap, + TILEWIDTH * (which % 8), TILEHEIGHT * (which / 8), + (TILEWIDTH + GRIDWIDTH) * x, (TILEHEIGHT + GRIDWIDTH) * y, + TILEWIDTH, TILEHEIGHT); + gdk_draw_drawable (buffer_pixmap, gridGC[0], tiles_pixmap, + TILEWIDTH * (which % 8), TILEHEIGHT * (which / 8), + (TILEWIDTH + GRIDWIDTH) * x, (TILEHEIGHT + GRIDWIDTH) * y, + TILEWIDTH, TILEHEIGHT); +} - gtk_table_attach (GTK_TABLE (table), white_score, 5, 6, 0, 1, 0, 0, 3, 1); - undo_set_sensitive (FALSE); +void +gui_draw_pixmap_buffer (guint which, guint x, guint y) +{ + gdk_draw_drawable (buffer_pixmap, gridGC[0], tiles_pixmap, + TILEWIDTH * (which % 8), TILEHEIGHT * (which / 8), + (TILEWIDTH + GRIDWIDTH) * x, (TILEHEIGHT + GRIDWIDTH) * y, + TILEWIDTH, TILEHEIGHT); +} - gtk_widget_show (table); +static void +gui_draw_grid (void) +{ + guint i; - gtk_box_pack_start (GTK_BOX (appbar), table, FALSE, TRUE, 0); + for (i = 1; i < 8; i++) + { + gdk_draw_line (buffer_pixmap, gridGC[grid], + (BOARDWIDTH / 8) * i - GRIDWIDTH, 0, + (BOARDWIDTH / 8) * i - GRIDWIDTH, BOARDHEIGHT); + gdk_draw_line (buffer_pixmap, gridGC[grid], + 0, (BOARDHEIGHT / 8) * i - GRIDWIDTH, + BOARDWIDTH, (BOARDHEIGHT / 8) * i - GRIDWIDTH); + } - gnome_appbar_set_status (GNOME_APPBAR (appbar), - _("Welcome to Iagno!")); + gdk_draw_drawable (drawingarea->window, gridGC[0], buffer_pixmap, + 0, 0, 0, 0, BOARDWIDTH, BOARDHEIGHT); } void gui_status (void) { - gchar message[3]; + gchar message[3]; - sprintf (message, _("%.2d"), bcount); - gtk_label_set_text (GTK_LABEL (black_score), message); - sprintf (message, _("%.2d"), wcount); - gtk_label_set_text (GTK_LABEL (white_score), message); - undo_set_sensitive (move_count > 0 && !is_network_running ()); + sprintf (message, _("%.2d"), bcount); + gtk_label_set_text (GTK_LABEL (b_score_status), message); + sprintf (message, _("%.2d"), wcount); + gtk_label_set_text (GTK_LABEL (w_score_status), message); } void gui_message (gchar *message) { - gnome_appbar_pop (GNOME_APPBAR (appbar)); - gnome_appbar_push (GNOME_APPBAR (appbar), message); + if (context_id1) + gtk_statusbar_pop ((GtkStatusbar *) info_status, context_id1); + context_id1 = + gtk_statusbar_get_context_id ((GtkStatusbar *) info_status, message); + gtk_statusbar_push ((GtkStatusbar *) info_status, context_id1, message); } -guint -check_computer_players (void) +void +gui_hint (gint xy, gint score) { - if (black_computer_level && whose_turn == BLACK_TURN) - switch (black_computer_level) { - case 1: - black_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_1, (gpointer) BLACK_TURN); - break; - case 2: - black_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_2, (gpointer) BLACK_TURN); - break; - case 3: - black_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_3, (gpointer) BLACK_TURN); - break; - } - - if (white_computer_level && whose_turn == WHITE_TURN) - switch (white_computer_level) { - case 1: - white_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_1, (gpointer) WHITE_TURN); - break; - case 2: - white_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_2, (gpointer) WHITE_TURN); - break; - case 3: - white_computer_id = g_timeout_add (computer_speed, (GSourceFunc)computer_move_3, (gpointer) WHITE_TURN); - break; - } - - return TRUE; + gchar message[10]; + + message[0] = (gchar) (xy / 10 + 0x40); + message[1] = (gchar) (xy % 10 + 0x30); + message[2] = 0x20; + sprintf (&message[3], _("%d"), score); + + gtk_entry_set_text (entry, message); } void -set_bg_color (void) +redraw_board (void) { - GdkImage *tmpimage; - GdkColor bgcolor; + guint i, j, which; - tmpimage = gdk_drawable_get_image (tiles_pixmap, 0, 0, 1, 1); - bgcolor.pixel = gdk_image_get_pixel (tmpimage, 0, 0); - gdk_window_set_background (drawing_area->window, &bgcolor); - - if (gridGC[0]) - g_object_unref (gridGC[0]); - gridGC[0] = gdk_gc_new (drawing_area->window); - if (gridGC[1]) - g_object_unref (gridGC[1]); - gridGC[1] = gdk_gc_new (drawing_area->window); - - gdk_gc_copy (gridGC [0],drawing_area->style->bg_gc[0]); - gdk_gc_copy (gridGC [1],drawing_area->style->bg_gc[0]); - - gdk_gc_set_background (gridGC [0],&bgcolor); - gdk_gc_set_foreground (gridGC [0],&bgcolor); - - /* Create a complementary color to use for the ON state */ - bgcolor.pixel = 0xFFFFFF - bgcolor.pixel; - gdk_gc_set_background (gridGC [1],&bgcolor); - gdk_gc_set_foreground (gridGC [1],&bgcolor); - - gdk_gc_set_line_attributes (gridGC [1], 0, - GDK_LINE_ON_OFF_DASH, - GDK_CAP_BUTT, GDK_JOIN_MITER); - - g_object_unref (tmpimage); + copy_pixmaps (); + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + { + if (pixmaps[i][j] != BLANK) + which = (guint) (pixmaps[i][j] - BLACK_TURN + 1); + else + which = 0; + gui_draw_pixmap (which, i, j); + } + gui_draw_grid (); + gui_status (); } -static int -save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, - gint shutdown, GnomeInteractStyle interact_style, - gint fast, gpointer client_data) +void +clear_board (void) { - char *argv[20]; - int i; - gint xpos, ypos; - - gdk_window_get_origin (window->window, &xpos, &ypos); + guint i, j; - i = 0; - argv[i++] = (char *)client_data; - argv[i++] = "-x"; - argv[i++] = g_strdup_printf ("%d", xpos); - argv[i++] = "-y"; - argv[i++] = g_strdup_printf ("%d", ypos); - gnome_client_set_restart_command (client, i, argv); - gnome_client_set_clone_command (client, 0, NULL); + game_in_progress = FALSE; + move_count = 0; + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + board[i][j] = BLANK; - g_free (argv[2]); - g_free (argv[4]); + bcount = 0; + wcount = 0; - return TRUE; + redraw_board (); } -int -main (int argc, char **argv) +void +init_new_game (void) { - GnomeClient *client; - - gnome_score_init ("iagno"); - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - gnome_program_init ("iagno", VERSION, - LIBGNOMEUI_MODULE, - argc, argv, - GNOME_PARAM_POPT_TABLE, options, - GNOME_PARAM_APP_DATADIR, DATADIR, NULL); - gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/iagno.png"); - client= gnome_master_client (); + if (flip_final_id) + { + g_source_remove (flip_final_id); + flip_final_id = 0; + } + if (black_computer_id) + { + g_source_remove (black_computer_id); + black_computer_id = 0; + } + if (white_computer_id) + { + g_source_remove (white_computer_id); + white_computer_id = 0; + } + kifu [0][0] = 0; + init (); + copy_board (); + games_clock_stop (GAMES_CLOCK(b_time_status)); + games_clock_stop (GAMES_CLOCK(w_time_status)); + games_clock_set_seconds (GAMES_CLOCK(b_time_status), 0); + games_clock_set_seconds (GAMES_CLOCK(w_time_status), 0); + redraw_board (); + game_in_progress = TRUE; + gui_message (_("Dark's move")); + games_clock_start (GAMES_CLOCK(b_time_status)); + check_computer_players (); +} + +gboolean +check_valid_moves (void) +{ + if (mobility (whose_turn)) + { + if (whose_turn == BLACK_TURN) + { + gui_message (_("Dark's move")); + if (game_in_progress) + games_clock_start (GAMES_CLOCK(b_time_status)); + } + else if (whose_turn == WHITE_TURN) + { + gui_message (_("Light's move")); + if (game_in_progress) + games_clock_start (GAMES_CLOCK(w_time_status)); + } + return TRUE; + } + + whose_turn = OTHER_PLAYER (whose_turn); + if (!mobility (whose_turn)) + { + if (wcount > bcount) + gui_message (_("Light player wins!")); + if (bcount > wcount) + gui_message (_("Dark player wins!")); + if (wcount == bcount) + gui_message (_("The game was a draw.")); + game_in_progress = FALSE; + + if (flip_final) + flip_final_id = g_timeout_add (computer_speed, flip_final_results, NULL); + + gnome_sound_play (gameover_sound); + return FALSE; + } + + if (whose_turn == BLACK_TURN) + { + gui_message (_("Light must pass, Dark's move")); + if (game_in_progress) + games_clock_start (GAMES_CLOCK(b_time_status)); + } + else if (whose_turn == WHITE_TURN) + { + gui_message (_("Dark must pass, Light's move")); + if (game_in_progress) + games_clock_start (GAMES_CLOCK(w_time_status)); + } + return TRUE; +} - g_object_ref (G_OBJECT (client)); +gboolean +check_computer_players (void) +{ + if (black_computer_id) + { + g_source_remove (black_computer_id); + black_computer_id = 0; + } + if (white_computer_id) + { + g_source_remove (white_computer_id); + white_computer_id = 0; + } + if (black_computer_level && whose_turn == BLACK_TURN) + black_computer_id = g_timeout_add (computer_speed, + (GSourceFunc) computer_move, + (gpointer) black_computer_level); + + else if (white_computer_level && whose_turn == WHITE_TURN) + white_computer_id = g_timeout_add (computer_speed, + (GSourceFunc) computer_move, + (gpointer) white_computer_level); + + return FALSE; +} + +gboolean +move (guint x, guint y) +{ + guint xy; + + if (!is_valid_move (x, y, whose_turn)) + return FALSE; + + xy = y * 10 + x; + + if (game_in_progress) + { + kifu [move_count - 4][0] = (guint8) whose_turn; + kifu [move_count - 4][1] = (guint8) xy; + kifu [move_count - 3][0] = 0; + if (whose_turn == BLACK_TURN) + games_clock_stop (GAMES_CLOCK(b_time_status)); + else + games_clock_stop (GAMES_CLOCK(w_time_status)); + } + move_board (xy); + copy_board (); + gui_status (); + tiles_to_flip = TRUE; + play_sound = TRUE; + check_valid_moves (); + if (game_in_progress) + return check_computer_players (); - g_signal_connect (G_OBJECT (client), "save_yourself", - G_CALLBACK (save_state), argv[0]); - g_signal_connect (G_OBJECT (client), "die", - G_CALLBACK (quit_game_cb), argv[0]); + return FALSE; +} - create_window (); - - load_properties (); +gboolean +flip_pixmaps (gpointer data) +{ + guint i, j, which; - load_pixmaps (); + if (!tiles_to_flip) + return TRUE; - if (session_xpos >= 0 && session_ypos >= 0) { - gdk_window_move (window->window, session_xpos, session_ypos); - } + if (play_sound) + { + gnome_sound_play (flip_sound); + play_sound = FALSE; + } + + tiles_to_flip = FALSE; + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + { + if (pixmaps[i][j] == BLANK && board[i][j] != BLANK) + { + pixmaps[i][j] = board[i][j]; + which = clamp_int ((gint) pixmaps[i][j], BLACK_TURN, WHITE_TURN); + gui_draw_pixmap (which - BLACK_TURN + 1, i, j); + tiles_to_flip = TRUE; + } + else if (pixmaps[i][j] != BLANK && board[i][j] == BLANK) + { + pixmaps[i][j] = BLANK; + gui_draw_pixmap (0, i, j); + tiles_to_flip = TRUE; + } + else if (pixmaps[i][j] < board[i][j] && board[i][j] != BLANK) + { + if (animate == 0) + { + if (pixmaps[i][j] == BLACK_TURN) + pixmaps[i][j] = board[i][j]; + else + pixmaps[i][j]++; + } + else if (animate == 1) + { + if (pixmaps[i][j] < BLACK_TURN) + pixmaps[i][j]++; + else if (pixmaps[i][j]>=BLACK_TURN && pixmaps[i][j]<BLACK_TURN+7) + pixmaps[i][j] = BLACK_TURN+7; + else if (pixmaps[i][j]>=BLACK_TURN+7 && pixmaps[i][j]<BLACK_TURN+15) + pixmaps[i][j] = BLACK_TURN+15; + else if (pixmaps[i][j]>=BLACK_TURN+15 && pixmaps[i][j]<BLACK_TURN+23) + pixmaps[i][j] = BLACK_TURN+23; + else if (pixmaps[i][j]>=BLACK_TURN+23 && pixmaps[i][j]<WHITE_TURN) + pixmaps[i][j] = WHITE_TURN; + else if (pixmaps[i][j]>WHITE_TURN) + pixmaps[i][j] = WHITE_TURN; + } + else if (animate == 2) + pixmaps[i][j]++; + + which = clamp_int ((gint) pixmaps[i][j], BLACK_TURN, WHITE_TURN); + gui_draw_pixmap (which - BLACK_TURN + 1, i, j); + tiles_to_flip = TRUE; + } + else if (pixmaps[i][j] > board[i][j] && pixmaps[i][j] != BLANK) + { + if (animate == 0) + { + if (pixmaps[i][j] == WHITE_TURN) + pixmaps[i][j] = board[i][j]; + else + pixmaps[i][j]--; + } + else if (animate == 1) + { + if (pixmaps[i][j] > WHITE_TURN) + pixmaps[i][j]--; + else if (pixmaps[i][j]<=WHITE_TURN && pixmaps[i][j]>BLACK_TURN+23) + pixmaps[i][j] = BLACK_TURN+23; + else if (pixmaps[i][j]<=BLACK_TURN+23 && pixmaps[i][j]>BLACK_TURN+15) + pixmaps[i][j] = BLACK_TURN+15; + else if (pixmaps[i][j]<=BLACK_TURN+15 && pixmaps[i][j]>BLACK_TURN+7) + pixmaps[i][j] = BLACK_TURN+7; + else if (pixmaps[i][j]<=BLACK_TURN+7 && pixmaps[i][j]>BLACK_TURN) + pixmaps[i][j] = BLACK_TURN; + else if (pixmaps[i][j]<BLACK_TURN) + pixmaps[i][j] = BLACK_TURN; + } + else if (animate == 2) + pixmaps[i][j]--; + + which = clamp_int ((gint) pixmaps[i][j], BLACK_TURN, WHITE_TURN); + gui_draw_pixmap (which - BLACK_TURN + 1, i, j); + tiles_to_flip = TRUE; + } + } + + return TRUE; +} + +gboolean +flip_final_results (gpointer data) +{ + guint i; + gint8 adder = 0; + + i = 0; + for (; i < bcount; i++) + { + board[i % 8][i / 8] = BLACK_TURN; + if (pixmaps[i % 8][i / 8] == BLANK) + pixmaps[i % 8][i / 8] = WHITE_TURN; + if (pixmaps[i % 8][i / 8] == WHITE_TURN) + { + pixmaps[i % 8][i / 8] += adder; + if (animate_stagger) + adder++; + } + } + for (; i < 64 - wcount; i++) + { + board[i % 8][i / 8] = BLANK; + } + for (; i < 64; i++) + { + board[i % 8][i / 8] = WHITE_TURN; + if (pixmaps[i % 8][i / 8] == BLANK) + pixmaps[i % 8][i / 8] = BLACK_TURN; + if (pixmaps[i % 8][i / 8] == BLACK_TURN) + { + pixmaps[i % 8][i / 8] -= adder; + if (animate_stagger) + adder++; + } + } - gtk_widget_show (window); + tiles_to_flip = TRUE; - buffer_pixmap = gdk_pixmap_new (drawing_area->window, - BOARDWIDTH, BOARDHEIGHT, -1); + return FALSE; +} - set_bg_color (); +int +main (int argc, char *argv[]) +{ + gchar *tmp; - init_new_game (); + gnome_score_init ("iagno"); - gtk_main (); +#ifdef ENABLE_NLS + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); +#endif + + gnome_program_init ("iagno", VERSION, LIBGNOMEUI_MODULE, + argc, argv, GNOME_PARAM_APP_DATADIR, DATADIR, NULL); + + window = create_window (); + gtk_widget_show (window); + + buffer_pixmap = gdk_pixmap_new (drawingarea->window, + BOARDWIDTH, BOARDHEIGHT, -1); + + tmp = g_build_filename ("iagno", _("flip-piece.wav"), NULL); + flip_sound = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_SOUND, + tmp, TRUE, NULL); + g_free (tmp); + tmp = g_build_filename ("iagno", _("gameover.wav"), NULL); + gameover_sound = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_SOUND, + tmp, TRUE, NULL); + g_free (tmp); + + load_properties (); + reset_properties (); + load_pixmaps (); + set_bg_color (); + grid = 0; + clear_board (); + grid = t_grid; + gui_message (_("Welcome to Iagno!")); + redraw_board (); - return 0; + gtk_main (); + return 0; } - diff -uNr gnome-games-2.14.1.org/iagno/gnothello.h gnome-games-2.14.1/iagno/gnothello.h --- gnome-games-2.14.1.org/iagno/gnothello.h 2006-08-05 15:32:11.000000000 +0900 +++ gnome-games-2.14.1/iagno/gnothello.h 2006-08-05 22:17:26.000000000 +0900 @@ -1,6 +1,5 @@ /* - * gnothello.h - Header for gnothello.c - * written by Ian Peters <itp@gnu.org> + * gnothello.h * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,53 +21,108 @@ #ifndef _GNOTHELLO_H_ #define _GNOTHELLO_H_ -#define BLACK_TURN 1 -#define WHITE_TURN 31 -#define PIXMAP_FLIP_DELAY 20 -#define PIXMAP_STAGGER_DELAY 3 -#define COMPUTER_MOVE_DELAY 1000 - -#define OTHER_PLAYER(w) (((w) == WHITE_TURN) ? BLACK_TURN : WHITE_TURN) +/* For fast CPU, set CS = 0, + for slow CPU, set CS = 1 */ +#define CS 0 +#define BEST 54 +#define VICTORY (20 - CS) +#define PERFECT (18 - CS) +#define MAX_DEPTH ( 8 - CS) + +#define BLACK_TURN 1 +#define WHITE_TURN 31 +#define BLANK 127 +#define OUTSIDE (BLACK_TURN + WHITE_TURN) +#define OTHER_PLAYER(who) (OUTSIDE - who) + +#define UL -11 +#define UU -10 +#define UR -9 +#define LL -1 +#define RR +1 +#define DL +9 +#define DD +10 +#define DR +11 +#define NDIRS 8 #define TILEWIDTH 60 #define TILEHEIGHT 60 -#define GRIDWIDTH 1 -#define BOARDWIDTH ((TILEWIDTH+GRIDWIDTH) * 8) -#define BOARDHEIGHT ((TILEHEIGHT+GRIDWIDTH) * 8) - -void new_game_cb (GtkWidget *widget, gpointer data); -void new_net_game_cb (GtkWidget *widget, gpointer data); -void quit_game_cb (GtkWidget *widget, gpointer data); -void undo_move_cb (GtkWidget *widget, gpointer data); -void redo_move_cb (GtkWidget *widget, gpointer data); -void black_level_cb (GtkWidget *widget, gpointer data); -void white_level_cb (GtkWidget *widget, gpointer data); -void about_cb (GtkWidget *widget, gpointer data); -void comp_black_cb (GtkWidget *widget, gpointer data); -void comp_white_cb (GtkWidget *widget, gpointer data); -void quick_moves_cb (GtkWidget *widget, gpointer data); -void anim_cb (GtkWidget *widget, gpointer data); -void anim_stagger_cb (GtkWidget *widget, gpointer data); -void load_tiles_cb (GtkWidget *widget, gpointer data); -void set_selection (GtkWidget *widget, void *data); -void free_str (GtkWidget *widget, void *data); -void load_tiles_callback (GtkWidget *widget, void *data); -void cancel (GtkWidget *widget, void *data); -gint expose_event (GtkWidget *widget ,GdkEventExpose *event); -gint configure_event (GtkWidget *widget, GdkEventConfigure *event); -gint button_press_event (GtkWidget *widget, GdkEventButton *event); -void gui_draw_pixmap(gint which, gint x, gint y); -void gui_draw_pixmap_buffer (gint which, gint x, gint y); -gint flip_pixmaps (gpointer data); -void init_new_game (void); -void clear_board (void); -void create_window (void); -void gui_status (void); -void gui_message (gchar *message); -guint check_computer_players (void); +#define GRIDWIDTH 1 +#define BOARDWIDTH ((TILEWIDTH + GRIDWIDTH) * 8) +#define BOARDHEIGHT ((TILEHEIGHT + GRIDWIDTH) * 8) +#define PIXMAP_FLIP_DELAY 20 +#define PIXMAP_STAGGER_DELAY 3 +#define COMPUTER_MOVE_DELAY 800 + +void on_open_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_save_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_new_game_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_new_network_game_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_undo_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_hint_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_preference_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_about_activate (GtkMenuItem *menuitem, gpointer user_data); +void on_newbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_undobutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_headbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_backbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_forwardbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_lastbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_infobutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +void on_quitbutton_clicked (GtkToolButton *toolbutton, gpointer user_data); +gboolean +on_drawingarea_expose_event (GtkWidget *widget, + GdkEventExpose *event, gpointer user_data); +gboolean +on_drawingarea_button_press_event (GtkWidget *widget, + GdkEventButton *event, gpointer user_data); +void +on_entry_notify (GObject *gobject, GParamSpec *arg1, gpointer user_data); +void +on_bcomputer_level_changed (GtkToggleButton *togglebutton, gpointer user_data); +void +on_wcomputer_level_changed (GtkToggleButton *togglebutton, gpointer user_data); +void +on_quick_moves_toggled (GtkToggleButton *togglebutton, gpointer user_data); +void +on_animate_changed (GtkToggleButton *togglebutton, gpointer user_data); +void +on_stagger_flips_toggled (GtkToggleButton *togglebutton, gpointer user_data); +void +on_show_grid_toggled (GtkToggleButton *togglebutton, gpointer user_data); +void +on_flip_final_results_toggled (GtkToggleButton *togglebutton, + gpointer user_data); +void on_tile_set_changed (GtkComboBox *combobox, gpointer user_data); +void on_apply_button_clicked (GtkButton *button, gpointer user_data); +void on_propaties_cancel_clicked (GtkButton *button, gpointer user_data); +void on_ok_button_clicked (GtkButton *button, gpointer user_data); +void on_file_open_cancel_clicked (GtkButton *button, gpointer user_data); +void on_open_button_clicked (GtkButton *button, gpointer user_data); +void on_file_save_cancel_clicked (GtkButton *button, gpointer user_data); +void on_save_button_clicked (GtkButton *button, gpointer user_data); +gint clamp_int (gint input, gint low, gint high); +void load_properties (void); +void set_flip_pixmaps_id (void); void load_pixmaps (void); -void properties_cb (GtkWidget *widget, gpointer data); -void set_bg_color (void); -void gui_draw_grid (void); +void reset_properties (void); +void save_properties (void); +void apply_changes (void); +void write_kifu (int fd); +void read_kifu (int fd); +void gui_draw_pixmap (guint which, guint x, guint y); +void gui_draw_pixmap_buffer (guint which, guint x, guint y); +void gui_message (gchar * message); +void gui_status (void); +void gui_hint (gint xy, gint score); +void redraw_board (void); +void clear_board (void); +void init_new_game (void); +gboolean check_valid_moves (void); +gboolean check_computer_players (void); +gboolean move (guint x, guint y); +gboolean flip_pixmaps (gpointer data); +gboolean flip_final_results (gpointer data); #endif
*** Bug 350070 has been marked as a duplicate of this bug. ***
*** Bug 350069 has been marked as a duplicate of this bug. ***
Hello First of all, take a look at this page for new contributors to gnome-games: http://live.gnome.org/GnomeGames/Contributing GNOME is in feature freeze at the moment, so this patch can not be accepted before after GNOME 2.16.0 has been released. And most importantly, _why_ have you created a new version of Iagno? Please give some arguments for why your version is better. I am very reluctant to change all of Iagno, with all the effort that hsa been spent on the current version. It would therefore be useful if you could discuss why you want to rewrite Iagno on the mailing lists for gnome-games, before you post a patch. It seems that you created the patch against gnome-games 2.14.1. The patch should be made against the CVS version of gnome-games.
Created attachment 70525 [details] [review] iagno cvs patch Thanks your comments and pardon my late reply. I am sorry, I feel difficult to read and write English. So I don't join in mailing list. I think Iagno should have next functions. 1. file save and file open. 2. reappearance of game. 3. hint of game. more append 4. keyboard input. 5. sound support. 6. network. 7. small board. last 8. more stronger than current version. And I send CVS version patch again. Please make small-classic.png and small-woodtrim.png. It's size are 352x176.
Comment on attachment 70525 [details] [review] iagno cvs patch I removed this patch, because this has some bugs.
Created attachment 70695 [details] [review] iagno cvs new patch I send smoe bug fixed new patch.
Created attachment 71278 [details] [review] iagno new patch I update this patch. Iagno ver.2 features. 1. file-save, file-open support. 2. reproduction of game support. 3. and it's able to replay from on the way. 4. board size resize-able. 5. background color selectable. 6. keyboard input support. 7. Hint support. 8. timer support. 9. network support. 10. sound support. 11. more stronger. Changes 1. board size resize-able. not use small-classic.png. 2. background color selectable. Please change background color of classic.png from current color to none. 3. row and column label appended. 4. more shorter source cord and more smaller object cord. Bugs 1. can not display Help I can't understand why don't display help. 2. To resize smaller board are too late. To-do 1. internationalization of preference dialog.
Created attachment 71503 [details] [review] iagno.patch Changed 1. Changed the method of resize board from configure_event to scroll_up and scroll_down. 2. Bugfixed in goto_forward, go_last and redo (append check_computer_players()). 3. Changed in properties_dialog from double loop to triple loop. 4. Changed score label display method to loop. 5. Deleted create_pixbuf () and included games-preimage.h. TO_DO 1. TO create new tiles.svg
Created attachment 72064 [details] coin.svg I created new tiles, marble.svg and coin.svg. These tiles are more beautiful and more smaller size than classic.png. Coin.svg's size are 27.4kb and marble.svg's size are 30.8kb, otherwise classic.png's size are 77.7kb. And it's possible to copy and paste, so to create new tiles are easy.
Created attachment 72065 [details] coin.svg I created new tiles, marble.svg and coin.svg. These tiles are more beautiful and more smaller size than classic.png. Coin.svg's size are 27.4kb and marble.svg's size are 30.8kb, otherwise classic.png's size are 77.7kb. And it's possible to copy and paste, so to create new tiles are easy.
Created attachment 72066 [details] marble.svg I created new tiles, marble.svg and coin.svg. These tiles are more beautiful and more smaller size than classic.png. Coin.svg's size are 27.4kb and marble.svg's size are 30.8kb, otherwise classic.png's size are 77.7kb. And it's possible to copy and paste, so to create new tiles are easy.
Hello, I will take a look at this after gnome games 2.16.0 has been released next week. Then the feature/code freeze is over, and new features can be added.
It is generally best to keep to one idea per bug report. Smaller changes are easier for developers to examine and include parts of it. The marble SVG theme looks good and I hope it can be included. I dont like the coin theme quite so much though, maybe it could be included in games-data-extras? When creating SVG try to remember to "Vacuum Defs" to clear out unused defines and to save as "Plain SVG" not Inkscape SVG otherwise you will get a bunch of (even more) unnecessary cruft. It is best not to worry too much about the size of SVG files, the XML compresses really well. Inkscape does not produce the most compact SVG, it uses paths when a circle or ellipse or other SVG markup would be a much cleaner way to represent the same information. There is also the possibility that SVG files will not load as quickly as PNG files (but more often the SVG will actually be faster since librsvg is very fast and very well written).
Hello, Now the code freeze is over, and I will begin accepting patches again. If you could update the patch to the latest CVS version of gnome-games, then I will review you patch.
Created attachment 72478 [details] sun_and_star.svg Thanks your advice. I changed tiles movement to more smooth. And I created new tiles sun_and_star.svg.
Created attachment 72479 [details] marble.svg Thanks your advice. I changed tiles movement to more smooth. And I created new tiles sun_and_star.svg.
Created attachment 72480 [details] coin.svg Thanks your advice. I changed tiles movement to more smooth. And I created new tiles sun_and_star.svg.
Created attachment 72481 [details] [review] new-iagno.patch I made new patch, but I couldn't get ggz-0.0.14, so I didn't test network game.
Hello, You _have_ to test a network game. Get ggz-0.0.14 from http://svn.ggzgamingzone.org/ Version 0.0.14 will be released this month. Can you post a screenshot also?
Also, while you are rewriting Iagno, you should change these four things: - The main window of Iagno should be resizeable, and the graphics be scaled. - Please remove the save and load feature. None of the other games have this feature, and I don't think it's a good idea at this time. - The GGZ Gtk+ connection dialog should be embedded into the main window like Gnect and Gnibbles. This means that there should be no double menus, like it is currently. - The chat widget should be embedded into the main window, like in Gnibbles and Gnect. I am very much looking forward to the next version of your patch! Nice work so far.
Created attachment 72857 [details] [review] iagno new patch I made new patch. Answer 1. screen-shots. I couldn't send screen-shots, if you want it, please do it yourself instead of me. 2. file save and file open feature. Yes, maybe to omit this feature is no problem for almost people, but Iagno players want this feature, and chess, go and shogi players too. I hope you to hear other Iagno players opinion. 3. resizeable window I changed to so. 4. scaled graphics It's possible by board_width = board_height in set_board_size function, but labels(A,B,..1,2,..) will be separate from board. I appended a hpaned at right side of window for chat and player list. I think chat and player list menu are not required. But I couldn't get ggz-0.0.14 yet, so I can't test network game mode. Computer select a square at random in first 6 turns, so sometimes computer select a very bad square. But I leaved this feature. To-Do To change server protocol from Reversi to Iagno, because now server couldn't use othello.c. I changed othello.c to independent, now I can include only othello.c. in server.c. ---- I appended up and down movement to sun_and_star.svg. I think that children like this change.
Created attachment 72858 [details] new sun_and_star.svg New sun_and_star.svg
Please test the patch with network support. If you can't get ggz-0.0.14, then using ggz-0.0.13 is also possible. I am planning to add support for version 0.0.13 soon, and it is a trivial change which involves only a few lines of code.
Created attachment 73265 [details] [review] iagno new patch I made a new patch, I tested this patch with ggz-0.0.13. And I cut parts of except iango from this patch. I changed program flow to next. network iagno flow --- 1. run ggz-gtk. | ggz-gtk -> create chat and player-list window 2. connect server. | -> ggz-config --install --modfile=iagno-client.dsc 3. certification of client 4. select room. | 5. launch table. | -> run network-mode iagno (/etc/ggz.modules) <- iagno-client.dsc 6. sit seat | --- 7. play game | network iagno 8. end game | --- 9. stand seat | ggz-gtk 10. leave table | 11. leave room. | -> shutdown network-mode iagno 12. disconnect server. | 13. shutdown ggz-gtk | --- logfile ~/.ggz/reversi-gtk.debug <- I did't use logfile. iagno server flow --- 1. run ggzd | ggzd -> /etc/ggzd/ggzd.conf ggzd.motd 2. create rooms | -> (/var/lib/ggzd/player.db) ggzduedit 3. create tables | -> run iagnod (/etc/ggzd/rooms,games) <- iagno.room, iagno-server.dsc 4. create seats | --- 5. create handler | iagnod 6. init game | 7. move game | 8. game over | 9. sync | 10. play again | --- 11. shutdown ggzd | ggzd -> shutdown iagnod logfile /var/log/ggzd/ggzd.debug, ggzd.log I changed protocol to Iagno-0.1, and fixed server computer level to 5. I couldn't test with ggz-gnome, because I couldn't connect server with ggz-gnome. Maybe ggz-gnome have bugs or I mistaked setting.
Hello math1@nifty.com :) Thanks for the improved patch. Do you have any more changes planned to Iagno? If you think your patch is ready for inclusion to CVS, then I will begin reviewing your patch, and commit it to gnome-games CVS if it is of good enough The protocol changes seem OK based on my initial overview of it. ggz-gnome is not used very much, so you should probably use ggz-gtk.
Hello again, I have had a look at your patch, and the new improved Iagno looks really good so far. I have a proposal for a small Iagno-project for you now, since you are the person knowing the "new Iagno code" best. We have for quite a long time wanted to merge the code for Iango and Ataxx. This plan involves: -Iagno and Ataxx shares the same graphic files. -Iagno and Ataxx shares the same user interface front-end. -The game-rules for the two games should not be changed from what they are now. -both games get network support through ggz, but each game has its own server. The current code for Iagno can be a good starting point. -Iagno and Ataxx still have separate menu icons in the GNOME applications menu. If this plan sounds interesting to you, then you can get an CVS account to commit patches related to Iagno and Ataxx yourself to the gnome-games CVS repository. I can help you out if you have any development related problems during this project.
To sum up, it means that we use your new Iagno code, and add Ataxx support to it, throwing the old code Ataxx away.
Created attachment 73328 [details] [review] iagno.patch I'm sorry, I forgot to test compiling without-ggz-options. I made new patch, and tested without-ggz-options compiling. I updated CVS, then I can't recompile with-ggz-options. Did you change autogen.sh? I can't test network iagno again. I wish my patch be included in CVS. Thanks for your suggestion, but I know nothing about Ataxxx.
Created attachment 73614 [details] [review] gataxx.patch I'm sorry, I mistook. I reinstalled ggz in rpm with prefix=/usr. I didn't think configure requires prefix=/usr. Now I can configure with next options. ./configure --with-libggz-dir=/usr --with-ggzmod-dir=/usr \ --with-ggzdmod-dir=/usr --with-ggzconfig=/usr/local/bin \ --with-ggz-gtk-dir=/usr --with-ggz-sever --with-ggz-client ln -s /usr/bin/ggz-config /usr/local/bin/ Pardon me. I made gataxx.patch. I don't know about gataxx, so I used only one evaluate function. but a little stronger than current. I append a counter, because game have infinity loop. So counter become 95, game stop. Gataxx have't graphic files and sound files, and use iagno's files.
Created attachment 73615 [details] [review] iagno.patch I made new iagno patch. I changed iagno interface to same as gataxx. 1. Iagno and gataxx have same user interface. 2. both game use same graphic files. 3. both game rules are same as current. (maybe) But I think it's better changing to BLACK first same as in help expressions from current WHITE first. 4. Iagno support network game. but gataxx yet. 5. Both programs size are smaller than current. I tested iagno with-ggz-options and without-ggz-options, and network game too.
Hello! I have reviewed your patch. It's a good start, but not good enough to be committed to CVS yet. There are some simple compilation errors and crashes, which are unacceptable. I expect the next version to be without any obvious errors, so please test your patch completely. My comments: 1. Compilation error, for both Iagno and Ataxx: gataxx.o: In function `on_save_activate': /home/andreas/latest/gnome-games/gataxx/gataxx.c:722: undefined reference to `g_date_set_time_t' collect2: ld returned 1 exit status make[1]: *** [gataxx] Error 1 2. Crash when changing tileset: ** (gataxx:27363): CRITICAL **: games_preimage_new_from_file: assertion `filename != NULL' failed ** (gataxx:27363): CRITICAL **: games_preimage_new_from_file: assertion `filename != NULL' failed Could not find 'iagno/sun_and_star.svg' pixmap file 3. About the menu's: The Game menu and File menu should be in a single menu, consistent with the other games in gnome-games. 4. The code for iagno and gataxx should be put in the same directory. You can put all the new code in the iagno directory, and I will remove gataxx from CVS. The two games should reuse code which is shared by both games, while only game-rules are different in the two games. 5. Toolbar: Don't use a textfield, use a proper toolbar instead. Using a textfield there is ugly. 6. Zoom out doesn't work. 7. I still think more effort could be spent on making the user inferface look better.
Created attachment 73715 [details] [review] gataxx new patch I made new gataxx patch. This patch is only gataxx parts. 1. Compilation error, I insert next a line #include <glib.h> I compiled this patch with glib-2.12.3. 2. Crash when changing tileset: I thought new gataxx are installed with new iagno. This patch are only gataxx parts. Please install with new iagno, or install sun_and_star.svg, marble.svg and coin.svg in /usr/local/share/pixmaps/iagno/ directory. 3. About the menu's: I changed to so. 4. The two games code should be shared. I'm sorry, it's impossible for me. Both games have same user interface, but both games code are different. 5. Toolbar: I changed to so. But other game's toolbar have textfield. 6. Zoom out doesn't work. I think maybe it's a gconf bug, gconf sometimes don't write immediately. Please try again. 7. User interfaces. I changed a little.
Created attachment 73716 [details] [review] iagno new patch I made iagno new patch. This patch is only iagno parts. I tested iagno with-ggz-options and without-ggz-options, and network game too.
Created attachment 73736 [details] Proposed architecture for Iagno/Gataxx About #4: See my proposed software architecture for Iagno and Ataxx, hopefully this will make it clear how to refactor the two games. There are three main components: "User Interface Frontend", "Ataxx Game Rules" and "Gataxx game rules". In a single directory (the current Iagno directory), you put all three parts. The User Interface Frontend is shared by both Ataxx and Iagno. So my opinion is that you should organize the new code for Iagno and Gataxx in this way.
Created attachment 73939 [details] [review] gataxx patch This patch are only gataxx parts. I'm sorry, I don't know the way including new files into CVS patch. (This patch don't run without /usr/local/share/pixmaps/iagno/marble.svg.)
Created attachment 73940 [details] [review] iagno patch This patch are only iagno parts. I put next gataxx files in iagno directory. ai.c ai.h gataxx.c gataxx.h gataxx.schemas.in gataxx.desktop.in properties.c -> rename to gataxx-properties.c 16x16/gnome-ataxx.png 22x22/gnome-ataxx.png 32x32/gnome-ataxx.png 48x48/gnome-ataxx.png scalable/gnome-ataxx.svg help -> rename to gataxx-help gataxx/properties.h are not required. Delete gataxx directory. And put next three files in iagno directory. coin.svg marble.svg sun_and_star.svg Delete next two files. classic.png woodtrim.png I renamed iagno/help to iagno/iagno-help. I compiled this patch without ggz-options, and with next ggz files. ggz-server-0.0.13 libggz-0.0.13 ggz-client-libs-0.0.13 ggz-gtk-client-0.0.13 ggz-gtk-games-0.0.13 ( I installed them with prefix=/usr. ) And my ./configure options are next. ./configure --with-libggz-dir=/usr --with-ggzmod-dir=/usr \ --with-ggzdmod-dir=/usr --with-ggzconfig=/usr/local/bin \ --with-ggz-gtk-dir=/usr --with-ggz-sever --with-ggz-client ( ln -s /usr/bin/ggz-config /usr/local/bin/ ) ( ln -s /etc/ggzd /usr/local/etc/ ) And I test with ggz-gtk. ------------ Two properties.c files are different only next two lines. #include "ai.h" #include "gataxx.h" And #include "othello.h" #include "gnothello.h" This lead me to when I compile gataxx, I select upper two lines, and when I compile iagno I select under two lines. But I don't know the way. If I don't include them, then only a few lines remain. Almost othello players didn't use iagno, even if they like GNOME. Because iagno hadn't the functions that they want. New iagno have the functions that they want.
Created attachment 74063 [details] [review] gataxx patch I found the way. Now I can share properties.c with iagno and gataxx. This patch are only gataxx parts. (This patch don't run without /usr/local/share/pixmaps/iagno/marble.svg.)
Created attachment 74064 [details] [review] iagno patch This patch are only iagno parts. I put next gataxx files in iagno directory. ai.c ai.h gataxx.c gataxx.h gataxx.schemas.in gataxx.desktop.in 16x16/gnome-ataxx.png 22x22/gnome-ataxx.png 32x32/gnome-ataxx.png 48x48/gnome-ataxx.png scalable/gnome-ataxx.svg help -> rename to gataxx-help gataxx/properties.h and properties.c are not required. Delete gataxx directory. And put next three files in iagno directory. coin.svg marble.svg sun_and_star.svg Delete next two files. classic.png woodtrim.png I renamed iagno/help to iagno/iagno-help. I compiled this patch without ggz-options, and with next ggz files. ggz-server-0.0.13 libggz-0.0.13 ggz-client-libs-0.0.13 ggz-gtk-client-0.0.13 ggz-gtk-games-0.0.13 ( I installed them with prefix=/usr. ) ( ln -s /usr/bin/ggz-config /usr/local/bin/ ) ( ln -s /etc/ggzd /usr/local/etc/ ) And my ./configure options are next. ./configure --with-libggz-dir=/usr --with-ggzmod-dir=/usr \ --with-ggzdmod-dir=/usr --with-ggzconfig=/usr/local/bin \ --with-ggz-gtk-dir=/usr --with-ggz-sever --with-ggz-client And I test with ggz-gtk. I hope you to change CVS to these files.
Created attachment 74292 [details] [review] iagno new patch I changed user interface for beginners. I appended "Hide Valid squares" and "Hide Last move", and deleted "Show grid" and "Stagger flips".
Created attachment 74293 [details] gataxx files For reference. If you put these files in iagno directory, you can run gataxx. (it requires to change iagno/Makefile.am.)
Created attachment 74479 [details] [review] iagno new patch Some bug fixed. In server.c and ggz_network.c I increased error check, and stability rose.
Created attachment 74480 [details] gataxx files For reference
Created attachment 74687 [details] [review] iagno patch Some bug fixed. Othello.c had a bug in victory search. I appended auto recovery in sync error. Even after one person disconnect once, if he join again, he can play again from previous point.
Created attachment 74688 [details] gataxx files For reference
Created attachment 74939 [details] [review] iagno new patch Iagno new patch
Created attachment 74940 [details] gataxx files For reference.
Created attachment 75389 [details] [review] iagno new patch Some bugs fixed.
Created attachment 75390 [details] Network gataxx For reference. Network gataxx files. "properties.c, properties.h, ggz-network.h, server.h" are same as Iagno's those files.
Hello, thanks for the update. Note that gataxx has been removed from gnome-games CVS, so there is no need to continue working on that. The Iagno parts will still be relevant.
I have applied the new graphics you made: new sun_and_star.svg It looks very good! However, I have tested the patch, and I am not satisified enough to commit it to CVS. You have not fixed many of the bugs I have pointed out eariler, and I have discovered new bugs as well. I am just not going to commit this patch which would make Iagno very unstable, when the current Iagno is so well tested and considered stable.
The patch here is obsolete now. Closing.