2 * upkg: tool for manipulating Unreal Tournament packages.
3 * Copyright © 2009-2011 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>
29 #define TEXTURE_GET_PRIV(o) \
30 G_TYPE_INSTANCE_GET_PRIVATE(o, ENGINE_TEXTURE_TYPE, struct texture_priv)
49 unsigned char buf[2048];
53 void exportable_init(UObjectExportable *e)
57 G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, U_TYPE_OBJECT);
59 static int deserialize(UObject *uo)
61 struct texture_priv *priv = TEXTURE_GET_PRIV(uo);
62 EngineTexture *t = ENGINE_TEXTURE(uo);
64 U_OBJECT_CLASS(engine_texture_parent_class)->deserialize(uo);
69 void texture_register(GTypeModule *m)
71 engine_texture_register_type(m);
75 set_property(GObject *o, guint id, const GValue *val, GParamSpec *spec)
77 EngineTexture *t = ENGINE_TEXTURE(o);
81 t->usize = g_value_get_uint(val);
84 t->vsize = g_value_get_uint(val);
87 t->uclamp = g_value_get_uint(val);
90 t->vclamp = g_value_get_uint(val);
93 t->ubits = g_value_get_uint(val);
96 t->vbits = g_value_get_uint(val);
99 t->palette = g_value_get_object(val);
102 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
107 get_property(GObject *o, guint id, GValue *val, GParamSpec *spec)
109 EngineTexture *t = ENGINE_TEXTURE(o);
113 g_value_set_uint(val, t->usize);
116 g_value_set_uint(val, t->vsize);
119 g_value_set_uint(val, t->uclamp);
122 g_value_set_uint(val, t->vclamp);
125 g_value_set_uint(val, t->ubits);
128 g_value_set_uint(val, t->vbits);
131 g_value_set_object(val, t->palette);
134 G_OBJECT_WARN_INVALID_PROPERTY_ID(o, id, spec);
138 static void engine_texture_init(EngineTexture *t)
140 t->usize = t->vsize = 0;
143 static void engine_texture_class_init(EngineTextureClass *class)
145 UObjectClass *uo = U_OBJECT_CLASS(class);
146 GObjectClass *go = G_OBJECT_CLASS(class);
148 g_type_class_add_private(class, sizeof (struct texture_priv));
150 uo->deserialize = deserialize;
151 go->set_property = set_property;
152 go->get_property = get_property;
154 g_object_class_install_property(go, PROP_USIZE,
155 g_param_spec_uint("USize",
157 "Width of the texture.",
160 g_object_class_install_property(go, PROP_VSIZE,
161 g_param_spec_uint("VSize",
163 "Height of the texture.",
166 g_object_class_install_property(go, PROP_UCLAMP,
167 g_param_spec_uint("UClamp",
172 g_object_class_install_property(go, PROP_VCLAMP,
173 g_param_spec_uint("VClamp",
178 g_object_class_install_property(go, PROP_UBITS,
179 g_param_spec_uint("UBits",
184 g_object_class_install_property(go, PROP_VBITS,
185 g_param_spec_uint("VBits",
190 g_object_class_install_property(go, PROP_PALETTE,
191 g_param_spec_object("Palette",
193 "Palette reference for the texture.",
198 static void engine_texture_class_finalize(EngineTextureClass *class)