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 3 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, see <http://www.gnu.org/licenses/>.
21 #include <glib-object.h>
23 #include <uobject/uobject.h>
24 #include <uobject/exportable.h>
28 #define TEXTURE_GET_PRIV(o) \
29 G_TYPE_INSTANCE_GET_PRIVATE(o, ENGINE_TEXTURE_TYPE, struct texture_priv)
43 unsigned char buf[2048];
47 void exportable_init(UObjectExportable *e)
51 G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, U_OBJECT_TYPE);
53 static int deserialize(UObject *o, struct upkg_file *f)
55 struct texture_priv *priv = TEXTURE_GET_PRIV(o);
56 EngineTexture *t = ENGINE_TEXTURE(o);
58 U_OBJECT_CLASS(engine_texture_parent_class)->deserialize(o, f);
60 printf("Texture size: %ux%u\n", t->usize, t->vsize);
65 void texture_register(GTypeModule *m)
67 engine_texture_register_type(m);
71 set_property(GObject *o, guint id, const GValue *val, GParamSpec *spec)
73 EngineTexture *t = ENGINE_TEXTURE(o);
77 t->usize = g_value_get_uint(val);
80 t->vsize = g_value_get_uint(val);
83 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
88 get_property(GObject *o, guint id, GValue *val, GParamSpec *spec)
90 EngineTexture *t = ENGINE_TEXTURE(o);
94 g_value_set_boolean(val, t->usize);
97 g_value_set_boolean(val, t->vsize);
100 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
104 static void engine_texture_init(EngineTexture *t)
106 t->usize = t->vsize = 0;
109 static void engine_texture_class_init(EngineTextureClass *class)
111 UObjectClass *uo = U_OBJECT_CLASS(class);
112 GObjectClass *go = G_OBJECT_CLASS(class);
114 g_type_class_add_private(class, sizeof (struct texture_priv));
116 uo->deserialize = deserialize;
117 go->set_property = set_property;
118 go->get_property = get_property;
120 g_object_class_install_property(go, PROP_USIZE,
121 g_param_spec_uint("USize",
123 "Width of the texture.",
126 g_object_class_install_property(go, PROP_VSIZE,
127 g_param_spec_uint("VSize",
129 "Height of the texture.",
134 static void engine_texture_class_finalize(EngineTextureClass *class)