OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
mattexview.h File Reference
#include <gtk/gtk.h>
#include "mape/forward.h"
#include "mape/group.h"
#include "mape/material.h"
#include "mape/texture.h"
Include dependency graph for mattexview.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MapeMatTexView_
 

Functions

MapeMatTexViewmape_mat_tex_view_new (MapeFileIconSet *icon_set, GError **error)
 
void mape_mat_tex_view_destroy (MapeMatTexView *view)
 
gboolean mape_mat_tex_view_reload (MapeMatTexView *view, MapeTextureMap *new_tex_map, MapeGroup *base_group, gboolean overload_materials, gboolean overload_textures, MapeGroup *overload_from, GError **error)
 

Class Documentation

struct MapeMatTexView_

Definition at line 26 of file mattexview.h.

Collaboration diagram for MapeMatTexView_:
[legend]
Class Members
MapeFileIconSet * icon_set
MapeMaterialMap * mat_map
GtkWidget * notebook
MapeTextureMap * tex_map
MapeIconView * view_mat
MapeIconView * view_tex

Function Documentation

void mape_mat_tex_view_destroy ( MapeMatTexView view)

Definition at line 80 of file mattexview.c.

References mape_icon_view_destroy(), MapeMatTexView_::mat_map, MapeMatTexView_::tex_map, MapeMatTexView_::view_mat, and MapeMatTexView_::view_tex.

Referenced by mape_window_destroy(), and mape_window_new().

81 {
82  if(view->mat_map != NULL)
83  g_object_unref(view->mat_map);
84  if(view->tex_map != NULL)
85  g_object_unref(view->tex_map);
86 
89 
90  free(view);
91 }
MapeTextureMap * tex_map
Definition: mattexview.h:33
void mape_icon_view_destroy(MapeIconView *view)
Definition: iconview.c:102
MapeMaterialMap * mat_map
Definition: mattexview.h:32
MapeIconView * view_tex
Definition: mattexview.h:30
MapeIconView * view_mat
Definition: mattexview.h:29

Here is the call graph for this function:

Here is the caller graph for this function:

MapeMatTexView* mape_mat_tex_view_new ( MapeFileIconSet icon_set,
GError **  error 
)

Definition at line 24 of file mattexview.c.

References MapeMatTexView_::icon_set, mape_icon_view_destroy(), mape_icon_view_new(), MapeMatTexView_::mat_map, MapeMatTexView_::notebook, MapeMatTexView_::tex_map, MapeMatTexView_::view_mat, MapeMatTexView_::view_tex, and MapeIconView_::window.

Referenced by mape_window_new().

26 {
27  MapeMatTexView* view;
28  view = malloc(sizeof(MapeMatTexView) );
29 
30  view->mat_map = NULL;
31  view->tex_map = NULL;
32  view->icon_set = icon_set;
33 
34  view->view_mat = mape_icon_view_new(error);
35  if(view->view_mat == NULL)
36  {
37  free(view);
38  return NULL;
39  }
40 
41  view->view_tex = mape_icon_view_new(error);
42  if(view->view_tex == NULL)
43  {
45  free(view);
46  return NULL;
47  }
48 
49  view->notebook = gtk_notebook_new();
50 
51  gtk_notebook_append_page(
52  GTK_NOTEBOOK(view->notebook),
53  view->view_mat->window,
54  NULL
55  );
56 
57  gtk_notebook_set_tab_label_text(
58  GTK_NOTEBOOK(view->notebook),
59  view->view_mat->window,
60  "Materials"
61  );
62 
63  gtk_notebook_append_page(
64  GTK_NOTEBOOK(view->notebook),
65  view->view_tex->window,
66  NULL
67  );
68 
69  gtk_notebook_set_tab_label_text(
70  GTK_NOTEBOOK(view->notebook),
71  view->view_tex->window,
72  "Textures"
73  );
74 
75  gtk_widget_set_size_request(view->notebook, -1, 150);
76  gtk_widget_show(view->notebook);
77  return view;
78 }
MapeTextureMap * tex_map
Definition: mattexview.h:33
void mape_icon_view_destroy(MapeIconView *view)
Definition: iconview.c:102
GtkWidget * window
Definition: iconview.h:30
MapeFileIconSet * icon_set
Definition: mattexview.h:35
MapeIconView * mape_icon_view_new(GError **error)
Definition: iconview.c:19
MapeMaterialMap * mat_map
Definition: mattexview.h:32
MapeIconView * view_tex
Definition: mattexview.h:30
GtkWidget * notebook
Definition: mattexview.h:27
MapeIconView * view_mat
Definition: mattexview.h:29

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean mape_mat_tex_view_reload ( MapeMatTexView view,
MapeTextureMap new_tex_map,
MapeGroup base_group,
gboolean  overload_materials,
gboolean  overload_textures,
MapeGroup overload_from,
GError **  error 
)

Definition at line 93 of file mattexview.c.

References MapeMatTexView_::icon_set, MAPE_FILE_ICON_C4MATERIAL, mape_file_icon_get(), mape_file_icon_set_lookup(), mape_icon_view_add(), mape_icon_view_clear(), mape_material_get_name(), mape_material_map_get_material(), mape_material_map_get_material_count(), mape_material_map_load(), mape_material_map_new(), mape_material_map_set_default_textures(), mape_texture_map_get_texture_count(), mape_texture_map_get_texture_name(), mape_texture_map_load_map(), mape_texture_map_load_textures(), mape_texture_map_lookup_texture(), MapeMatTexView_::mat_map, MapeMatTexView_::tex_map, MapeMatTexView_::view_mat, and MapeMatTexView_::view_tex.

100 {
101  MapeMaterialMap* new_mat_map;
102  MapeFileIcon* icon;
103  const MapeMaterial* mat;
104  unsigned int i;
105 
106  new_mat_map = mape_material_map_new();
107  if(!mape_material_map_load(new_mat_map, base_group, error))
108  {
109  g_object_unref(new_mat_map);
110  return FALSE;
111  }
112 
113  if(overload_materials && overload_from != NULL)
114  {
115  if(!mape_material_map_load(new_mat_map, overload_from, error))
116  {
117  g_object_unref(new_mat_map);
118  return FALSE;
119  }
120  }
121 
122  if(!mape_texture_map_load_textures(new_tex_map, base_group, error))
123  {
124  g_object_unref(new_mat_map);
125  return FALSE;
126  }
127 
128  if(overload_textures && overload_from != NULL)
129  {
130  if(!mape_texture_map_load_textures(new_tex_map, overload_from, error))
131  {
132  g_object_unref(new_mat_map);
133  return FALSE;
134  }
135  }
136 
137  /* Load the texture map again, because now that we have materials
138  * and textures loaded, we can actually assign the indices in the
139  * texture map. */
140  if (!mape_texture_map_load_map(new_tex_map, base_group, error))
141  {
142  g_object_unref(new_mat_map);
143  return FALSE;
144  }
145 
146  mape_material_map_set_default_textures(new_mat_map, new_tex_map);
147 
148  if(view->mat_map != NULL) g_object_unref(view->mat_map);
149  if(view->tex_map != NULL) g_object_unref(view->tex_map);
150  view->mat_map = new_mat_map; view->tex_map = new_tex_map;
151  g_object_ref(new_tex_map);
152 
154  for(i = 0; i < mape_material_map_get_material_count(new_mat_map); ++ i)
155  {
156  mat = mape_material_map_get_material(new_mat_map, i);
157 
159  view->icon_set,
161  );
162 
164  view->view_mat,
165  mape_file_icon_get(icon),
167  );
168  }
169 
171  for(i = 0; i < mape_texture_map_get_texture_count(new_tex_map); ++ i)
172  {
174  view->view_tex,
176  new_tex_map,
177  mape_texture_map_get_texture_name(new_tex_map, i)
178  ),
179  mape_texture_map_get_texture_name(new_tex_map, i)
180  );
181  }
182 
183  return TRUE;
184 }
void mape_icon_view_clear(MapeIconView *view)
Definition: iconview.c:108
MapeFileIcon * mape_file_icon_set_lookup(MapeFileIconSet *set, MapeFileIconType type)
Definition: fileicon.c:129
GdkPixbuf * mape_file_icon_get(MapeFileIcon *icon)
Definition: fileicon.c:137
guint mape_material_map_get_material_count(MapeMaterialMap *map)
Definition: material.c:274
gboolean mape_material_map_load(MapeMaterialMap *map, MapeGroup *from, GError **error)
Definition: material.c:242
MapeTextureMap * tex_map
Definition: mattexview.h:33
gboolean mape_texture_map_load_map(MapeTextureMap *texture_map, MapeGroup *group, GError **error)
Definition: texture.c:265
MapeFileIconSet * icon_set
Definition: mattexview.h:35
void mape_material_map_set_default_textures(MapeMaterialMap *matmap, MapeTextureMap *texmap)
Definition: material.c:290
MapeMaterialMap * mape_material_map_new(void)
Definition: material.c:223
MapeMaterialMap * mat_map
Definition: mattexview.h:32
MapeIconView * view_tex
Definition: mattexview.h:30
gboolean mape_texture_map_load_textures(MapeTextureMap *texture_map, MapeGroup *group, GError **error)
Definition: texture.c:304
GdkPixbuf * mape_texture_map_lookup_texture(MapeTextureMap *texture_map, const gchar *name)
Definition: texture.c:504
guint mape_texture_map_get_texture_count(MapeTextureMap *texture_map)
Definition: texture.c:459
const gchar * mape_texture_map_get_texture_name(MapeTextureMap *texture_map, guint index)
Definition: texture.c:478
const MapeMaterial * mape_material_map_get_material(MapeMaterialMap *map, guint index)
Definition: material.c:310
const gchar * mape_material_get_name(const MapeMaterial *material)
Definition: material.c:371
struct _MapeMaterial MapeMaterial
Definition: material.h:35
MapeIconView * view_mat
Definition: mattexview.h:29
void mape_icon_view_add(MapeIconView *view, GdkPixbuf *icon, const char *name)
Definition: iconview.c:113

Here is the call graph for this function: