2 * upkg: tool for manipulating Unreal Tournament packages.
3 * Copyright (C) 2009 Nick Bowler
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <glib-object.h>
24 #include <uobject/uobject.h>
25 #include <uobject/exportable.h>
29 #define TEXTURE_GET_PRIV(o) \
30 G_TYPE_INSTANCE_GET_PRIVATE(o, ENGINE_TEXTURE_TYPE, struct texture_priv)
44 unsigned char buf[2048];
48 void exportable_init(UObjectExportable *e)
52 G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, UOBJECT_TYPE);
54 static int deserialize(UObject *o, struct upkg_file *f)
56 struct texture_priv *priv = TEXTURE_GET_PRIV(o);
57 EngineTexture *t = ENGINE_TEXTURE(o);
59 UOBJECT_CLASS(engine_texture_parent_class)->deserialize(o, f);
61 printf("Texture size: %ux%u\n", t->usize, t->vsize);
66 void texture_register(GTypeModule *m)
68 engine_texture_register_type(m);
72 set_property(GObject *o, guint id, const GValue *val, GParamSpec *spec)
74 EngineTexture *t = ENGINE_TEXTURE(o);
78 t->usize = g_value_get_uint(val);
81 t->vsize = g_value_get_uint(val);
84 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
89 get_property(GObject *o, guint id, GValue *val, GParamSpec *spec)
91 EngineTexture *t = ENGINE_TEXTURE(o);
95 g_value_set_boolean(val, t->usize);
98 g_value_set_boolean(val, t->vsize);
101 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
105 static void engine_texture_init(EngineTexture *t)
107 t->usize = t->vsize = 0;
110 static void engine_texture_class_init(EngineTextureClass *class)
112 UObjectClass *uo = UOBJECT_CLASS(class);
113 GObjectClass *go = G_OBJECT_CLASS(class);
115 g_type_class_add_private(class, sizeof (struct texture_priv));
117 uo->deserialize = deserialize;
118 go->set_property = set_property;
119 go->get_property = get_property;
121 g_object_class_install_property(go, PROP_USIZE,
122 g_param_spec_uint("USize",
124 "Width of the texture.",
127 g_object_class_install_property(go, PROP_VSIZE,
128 g_param_spec_uint("VSize",
130 "Height of the texture.",
135 static void engine_texture_class_finalize(EngineTextureClass *class)