Commit 017a444d authored by Colomban Wendling's avatar Colomban Wendling
Browse files

GTK client: port to the new libovcc

The client now build and starts, though it crashes easily. Next step
is to fix these crashes and make it really work as expected.
parent e8bdd726
......@@ -21,7 +21,7 @@
#include <math.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <ovcc/board.h>
#include <ovcc/ovcc.h>
#include "tiles.h"
......@@ -148,7 +148,7 @@ static void ovccgtk_board_class_init (OVCCGtkBoardClass *klass)
"cursor-position",
"Cursor position",
"The current cursor position",
OVCC_TYPE_POS,
OVCC_TYPE_POSITION,
G_PARAM_READWRITE
)
);
......
......@@ -23,7 +23,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <ovcc/board.h>
#include <ovcc/ovcc.h>
G_BEGIN_DECLS
......
......@@ -3,7 +3,7 @@
#include <gtk/gtk.h>
#include "utils.h"
#include "tiles.h"
#include <ovcc/game.h>
#include <ovcc/ovcc.h>
#include "board-widget.h"
......@@ -26,17 +26,17 @@ do_try_place_tile (OVCCBoard *board,
g_return_val_if_fail (new_tile != NULL, FALSE);
for (i = 0; keep_doing && i < OVCC_TILE_SIDE_NUM; i++) {
for (i = 0; keep_doing && i < 4; i++) {
OVCCPosition npos = *pos;
int r;
switch (i) {
case OVCC_TILE_SIDE_POS_TOP: npos.y--; break;
case OVCC_TILE_SIDE_POS_BOTTOM: npos.y++; break;
case OVCC_TILE_SIDE_POS_LEFT: npos.x--; break;
case OVCC_TILE_SIDE_POS_RIGHT: npos.x++; break;
case 0: npos.y--; break;
case 1: npos.y++; break;
case 2: npos.x--; break;
case 3: npos.x++; break;
}
for (r = 0; keep_doing && r < OVCC_TILE_SIDE_NUM; r++) {
for (r = 0; keep_doing && r < 4; r++) {
ovcc_tile_rotate (new_tile, 1);
if (ovcc_board_add_tile_check (board, new_tile, &npos)) {
ovcc_board_add_tile (board, new_tile, &npos);
......@@ -93,17 +93,17 @@ game_do_try_place_tile (OVCCBoard *board,
g_return_val_if_fail (new_tile != NULL, FALSE);
for (i = 0; keep_doing && i < OVCC_TILE_SIDE_NUM; i++) {
for (i = 0; keep_doing && i < 4; i++) {
OVCCPosition npos = *pos;
int r;
switch (i) {
case OVCC_TILE_SIDE_POS_TOP: npos.y--; break;
case OVCC_TILE_SIDE_POS_BOTTOM: npos.y++; break;
case OVCC_TILE_SIDE_POS_LEFT: npos.x--; break;
case OVCC_TILE_SIDE_POS_RIGHT: npos.x++; break;
case 0: npos.y--; break;
case 1: npos.y++; break;
case 2: npos.x--; break;
case 3: npos.x++; break;
}
for (r = 0; keep_doing && r < OVCC_TILE_SIDE_NUM; r++) {
for (r = 0; keep_doing && r < 4; r++) {
ovcc_tile_rotate (new_tile, 1);
if (ovcc_game_place_tile (game, ovcc_game_get_current_player (game), &npos)) {
keep_doing = FALSE;
......@@ -165,29 +165,29 @@ create_stack (void)
OVCCStack *stack = NULL;
GError *err = NULL;
tiles = ovcc_tilesdef_new ();
tiles = ovcc_tiles_def_new ();
path = data_get_path (GAME_TILES);
tiles_file = g_file_new_for_path (path);
g_free (path);
if (! ovcc_tilesdef_load (tiles, tiles_file, &err)) {
if (! ovcc_tiles_def_load (tiles, tiles_file, &err)) {
msg_error (_("Failed to load tiles: %s"), err->message);
g_error_free (err);
} else {
set = ovcc_tileset_new ();
set = ovcc_tile_set_new ();
path = data_get_path (GAME_TILESET);
set_file = g_file_new_for_path (path);
g_free (path);
if (! ovcc_tileset_load (set, tiles, set_file, &err)) {
if (! ovcc_tile_set_load (set, tiles, set_file, &err)) {
msg_error (_("Failed to load tile set: %s"), err->message);
g_error_free (err);
} else {
stack = ovcc_stack_new_from_tileset (set);
}
g_object_unref (set_file);
ovcc_tileset_unref (set);
g_object_unref (set);
}
g_object_unref (tiles_file);
ovcc_tilesdef_unref (tiles);
g_object_unref (tiles);
return stack;
}
......@@ -200,7 +200,7 @@ create_board (void)
stack = create_stack ();
if (stack) {
board = ovcc_board_new (stack);
board = ovcc_board_new_from_stack (stack);
test_board (board, stack);
}
g_object_unref (stack);
......@@ -227,33 +227,33 @@ create_game (void)
OVCCGame *game = NULL;
GError *err = NULL;
tiles = ovcc_tilesdef_new ();
tiles = ovcc_tiles_def_new ();
path = data_get_path (GAME_TILES);
tiles_file = g_file_new_for_path (path);
g_free (path);
if (! ovcc_tilesdef_load (tiles, tiles_file, &err)) {
if (! ovcc_tiles_def_load (tiles, tiles_file, &err)) {
msg_error (_("Failed to load tiles: %s"), err->message);
g_error_free (err);
} else {
set = ovcc_tileset_new ();
set = ovcc_tile_set_new ();
path = data_get_path (GAME_TILESET);
set_file = g_file_new_for_path (path);
g_free (path);
if (! ovcc_tileset_load (set, tiles, set_file, &err)) {
if (! ovcc_tile_set_load (set, tiles, set_file, &err)) {
msg_error (_("Failed to load tile set: %s"), err->message);
g_error_free (err);
} else {
game = ovcc_game_new (set);
game = ovcc_game_new_from_tileset (set);
g_signal_connect (game, "unplaceable-tile",
G_CALLBACK (on_unplaceable_tile), NULL);
ovcc_game_add_player (game, ovcc_player_new ("A"), NULL);
ovcc_game_add_player (game, ovcc_player_new ("B"), NULL);
}
g_object_unref (set_file);
ovcc_tileset_unref (set);
g_object_unref (set);
}
g_object_unref (tiles_file);
ovcc_tilesdef_unref (tiles);
g_object_unref (tiles);
return game;
}
......
......@@ -144,6 +144,7 @@ load_tile (OVCCTileID id)
return pixbuf;
}
#if 0
static GdkPixbuf *
tile_get_procedural (const OVCCTile *tile,
gint size)
......@@ -263,6 +264,7 @@ tile_get_procedural (const OVCCTile *tile,
return pixbuf;
}
#endif
/**
......
......@@ -22,7 +22,7 @@
#include <glib.h>
#include <gdk/gdk.h>
#include "ovcc/tile.h"
#include <ovcc/ovcc.h>
G_BEGIN_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment