[Freeciv-Dev] Re: (PR#15112) embedded GGZ
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15112 >
Here's an updated version of the patch.
-jason
Index: configure.ac
===================================================================
--- configure.ac (revision 11432)
+++ configure.ac (working copy)
@@ -443,6 +443,10 @@
dnl Check for GGZ
AC_GGZ_CHECK
+if test "$client" = "gtk-2.0" ; then
+ AC_CHECK_LIB(ggz-gtk, ggz_gtk_create_main_area,
+ CLIENT_LIBS="-lggz-gtk $CLIENT_LIBS")
+fi
AC_SUBST(gui_sources)
AC_SUBST(CLIENT_CFLAGS)
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c (revision 11434)
+++ client/gui-gtk-2.0/gui_main.c (working copy)
@@ -32,6 +32,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <ggz-gtk.h>
+
#include "dataio.h"
#include "fciconv.h"
#include "fcintl.h"
@@ -807,6 +809,8 @@
create_network_page(), NULL);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
create_nation_page(), NULL);
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
+ ggz_gtk_create_main_area(toplevel), NULL);
main_tips = gtk_tooltips_new();
@@ -1136,11 +1140,33 @@
}
}
+static void ggz_connected(GGZServer *server)
+{
+ in_ggz = (server != NULL);
+ set_client_page(in_ggz ? PAGE_GGZ : PAGE_MAIN);
+}
+
+static void ggz_game_launched(void)
+{
+ // set_client_page(PAGE_START);
+ ggz_initialize();
+}
+
/**************************************************************************
called from main().
**************************************************************************/
void ui_init(void)
{
+ char protocol_version[128];
+
+ /* Engine and version match what is provided in civclient.dsc.in and
+ * civserver.dsc.in. */
+ my_snprintf(protocol_version, sizeof(protocol_version),
+ "%d.%d", MAJOR_VERSION, MINOR_VERSION);
+ ggz_gtk_initialize(FALSE,
+ ggz_connected, ggz_game_launched,
+ "Freeciv", protocol_version);
+
log_set_callback(log_callback_utf8);
}
Index: client/gui-gtk-2.0/pages.c
===================================================================
--- client/gui-gtk-2.0/pages.c (revision 11432)
+++ client/gui-gtk-2.0/pages.c (working copy)
@@ -22,6 +22,8 @@
#include <gtk/gtk.h>
+#include <ggz-gtk.h>
+
#include "dataio.h"
#include "fcintl.h"
#include "game.h"
@@ -120,7 +122,7 @@
if (aconnection.used) {
disconnect_from_server();
} else {
- set_client_page(PAGE_MAIN);
+ set_client_page(in_ggz ? PAGE_GGZ : PAGE_MAIN);
}
}
@@ -218,6 +220,12 @@
g_signal_connect(button, "clicked",
G_CALLBACK(set_page_callback), GUINT_TO_POINTER(PAGE_NETWORK));
+ button = gtk_button_new_with_mnemonic(_("Connect to Gaming _Zone"));
+ gtk_size_group_add_widget(size, button);
+ gtk_container_add(GTK_CONTAINER(bbox), button);
+ g_signal_connect(button, "clicked",
+ G_CALLBACK(ggz_gtk_login_raise), NULL);
+
bbox = gtk_vbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(sbox), bbox);
@@ -1880,6 +1888,7 @@
switch (new_page) {
case PAGE_MAIN:
+ case PAGE_GGZ:
break;
case PAGE_START:
if (is_server_running()) {
@@ -1923,6 +1932,7 @@
switch (new_page) {
case PAGE_MAIN:
case PAGE_START:
+ case PAGE_GGZ:
break;
case PAGE_NATION:
gtk_tree_view_focus(gtk_tree_selection_get_tree_view(nation_selection));
Index: client/include/pages_g.h
===================================================================
--- client/include/pages_g.h (revision 11432)
+++ client/include/pages_g.h (working copy)
@@ -23,6 +23,7 @@
PAGE_LOAD, /* Load saved game page. */
PAGE_NETWORK, /* Connect to network page. */
PAGE_NATION, /* Select a nation page. */
+ PAGE_GGZ,
PAGE_GAME /* In game page. */
};
Index: client/packhand.c
===================================================================
--- client/packhand.c (revision 11432)
+++ client/packhand.c (working copy)
@@ -184,7 +184,9 @@
update_menus();
- if (get_client_page() == PAGE_MAIN || get_client_page() == PAGE_NETWORK) {
+ if (get_client_page() == PAGE_MAIN
+ || get_client_page() == PAGE_NETWORK
+ || get_client_page() == PAGE_GGZ) {
set_client_page(PAGE_START);
}
@@ -199,7 +201,7 @@
freelog(LOG_NORMAL, "%s", msg);
}
gui_server_connect();
- set_client_page(PAGE_MAIN);
+ set_client_page(in_ggz ? PAGE_MAIN : PAGE_GGZ);
}
if (strcmp(s_capability, our_capability) == 0) {
return;
Index: client/clinet.c
===================================================================
--- client/clinet.c (revision 11434)
+++ client/clinet.c (working copy)
@@ -58,6 +58,8 @@
#include <winsock.h>
#endif
+#include <ggz-embed.h>
+
#include "capstr.h"
#include "dataio.h"
#include "fcintl.h"
@@ -101,14 +103,17 @@
**************************************************************************/
static void close_socket_nomessage(struct connection *pc)
{
- if (with_ggz) {
+ if (with_ggz || with_ggz) {
remove_ggz_input();
}
+ if (in_ggz) {
+ ggz_embed_leave_table();
+ }
connection_common_close(pc);
remove_net_input();
popdown_races_dialog();
close_connection_dialog();
- set_client_page(PAGE_MAIN);
+ set_client_page(in_ggz ? PAGE_GGZ : PAGE_MAIN);
reports_force_thaw();
Index: client/civclient.c
===================================================================
--- client/civclient.c (revision 11432)
+++ client/civclient.c (working copy)
@@ -88,6 +88,7 @@
char metaserver[512] = "\0";
int server_port = -1;
bool auto_connect = FALSE; /* TRUE = skip "Connect to Freeciv Server" dialog */
+bool in_ggz = FALSE;
static enum client_states client_state = CLIENT_BOOT_STATE;
@@ -545,7 +546,7 @@
}
client_game_init();
if (!aconnection.established) {
- set_client_page(PAGE_MAIN);
+ set_client_page(in_ggz ? PAGE_GGZ : PAGE_MAIN);
} else {
set_client_page(PAGE_START);
}
Index: client/civclient.h
===================================================================
--- client/civclient.h (revision 11432)
+++ client/civclient.h (working copy)
@@ -50,6 +50,7 @@
extern bool auto_connect;
extern bool waiting_for_end_turn;
extern bool turn_done_sent;
+extern bool in_ggz;
void wait_till_request_got_processed(int request_id);
bool client_is_observer(void);
- [Freeciv-Dev] Re: (PR#15112) embedded GGZ,
Jason Short <=
|
|