+/*
+ * 2ooM: The Master of Orion II Reverse Engineering Project
+ * Graphical tool for inspecting LBX archives.
+ * Copyright (C) 2010 Nick Bowler
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include "bg.xbm"
+extern char lbxgui_xml[];
+
static GtkTreeStore *archives;
static GtkBuilder *builder;
static GtkWidget *canvas;
static GdkGC *bg_gc;
-static LBX_IMG *image;
+static LBXimg *image;
static GdkPixbuf *framebuf;
{
unsigned frame = gtk_spin_button_get_value_as_int(spin);
- if (image)
+ if (image && framebuf)
render_to_pixbuf(image, framebuf, frame);
gdk_window_invalidate_rect(canvas->window, NULL, FALSE);
}
struct lbx_imginfo info;
GtkSpinButton *spin;
GtkToggleButton *play;
- unsigned frame;
+ unsigned frame, newframe;
if (!image)
return;
return;
elapsed += delta;
+ newframe = frame;
while (elapsed > seconds_per_frame) {
elapsed -= seconds_per_frame;
- if (++frame >= info.nframes) {
+ if (++newframe >= info.nframes) {
if (!info.looping) {
gtk_toggle_button_set_active(play, FALSE);
break;
}
- frame = info.loopstart;
+ newframe = info.loopstart;
}
-
- gtk_spin_button_set_value(spin, frame);
}
+
+ if (frame != newframe)
+ gtk_spin_button_set_value(spin, newframe);
}
static gboolean timeout(gpointer data)
return TRUE;
}
-static int alloc_framebuffer(LBX_IMG *image)
+static int alloc_framebuffer(LBXimg *image)
{
struct lbx_imginfo info;
GtkSpinButton *spin;
return 0;
}
-static LBX_IMG *
-load_lbx_image(LBX *archive, unsigned index)
+static LBXimg *load_lbx_image(LBX *archive, unsigned index)
{
LBXfile *file;
- LBX_IMG *image;
+ LBXimg *image;
file = lbx_file_open(archive, index);
g_return_val_if_fail(file, NULL);
GtkTreeIter iter;
gpointer lbx;
guint index;
- LBX_IMG *img;
+ LBXimg *img;
memset(palette_override, 0, sizeof palette_override);
if (!gtk_combo_box_get_active_iter(combo, &iter))
GtkTreeIter iter;
gpointer lbx;
guint index;
- LBX_IMG *img;
+ LBXimg *img;
if (image) {
lbximg_close(image);
for (unsigned i = 0; i < nfiles; i++) {
struct lbx_statbuf stat;
- lbx_stat(lbx, i, &stat);
+ lbx_file_stat(lbx, i, &stat);
gtk_tree_store_append(archives, &iter2, &iter1);
gtk_tree_store_set(archives, &iter2,
0, stat.name,
bg_gc = gdk_gc_new(canvas->window);
- bitmap = gdk_bitmap_create_from_data(drawable, bg_bits,
+ bitmap = gdk_bitmap_create_from_data(drawable, (gchar *)bg_bits,
bg_width, bg_height);
gdk_gc_set_stipple(bg_gc, bitmap);
load_archive(*argv++);
builder = gtk_builder_new();
- if (!gtk_builder_add_from_file(builder, "src/gui/lbxgui.glade", &err)) {
+ if (!gtk_builder_add_from_string(builder, lbxgui_xml, -1, &err)) {
fprintf(stderr, "%s\n", err->message);
return EXIT_FAILURE;
}
init_interface();
gtk_builder_connect_signals(builder, window);
- g_timeout_add(10, timeout, NULL);
+ g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 10, timeout, NULL, NULL);
gtk_widget_show_all(window);
init_background(canvas->window);