mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-10 03:51:18 +00:00
- Added material-support to brushexport-plugin (Shaderman)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@172 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
83f709aa55
commit
0c07d03e26
9 changed files with 981 additions and 805 deletions
3
CHANGES
3
CHANGES
|
@ -1,6 +1,9 @@
|
||||||
This is the changelog for developers, != changelog for the end user
|
This is the changelog for developers, != changelog for the end user
|
||||||
that we distribute with the binaries. (see changelog)
|
that we distribute with the binaries. (see changelog)
|
||||||
|
|
||||||
|
28/06/2007
|
||||||
|
- Added material-support to brushexport-plugin (Shaderman)
|
||||||
|
|
||||||
26/04/2007
|
26/04/2007
|
||||||
- Disabled auto-search for texbrowser and entityinspector even when the option
|
- Disabled auto-search for texbrowser and entityinspector even when the option
|
||||||
is turned on in the gtkrc
|
is turned on in the gtkrc
|
||||||
|
|
|
@ -1,104 +1,148 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "qerplugin.h"
|
#include "qerplugin.h"
|
||||||
#include "debugging/debugging.h"
|
#include "debugging/debugging.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
|
||||||
// stuff from interface.cpp
|
// stuff from interface.cpp
|
||||||
void DestroyWindow();
|
void DestroyWindow();
|
||||||
|
|
||||||
|
|
||||||
namespace callbacks {
|
namespace callbacks {
|
||||||
|
|
||||||
void OnDestroy(GtkWidget* w, gpointer data)
|
void OnDestroy(GtkWidget* w, gpointer data)
|
||||||
{
|
{
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnExportClicked(GtkButton* button, gpointer user_data)
|
void OnExportClicked(GtkButton* button, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget* window = lookup_widget(GTK_WIDGET(button), "w_plugplug2");
|
GtkWidget* window = lookup_widget(GTK_WIDGET(button), "w_plugplug2");
|
||||||
ASSERT_NOTNULL(window);
|
ASSERT_NOTNULL(window);
|
||||||
const char* path = GlobalRadiant().m_pfnFileDialog(window, false, "Save as Obj", 0, 0);
|
const char* cpath = GlobalRadiant().m_pfnFileDialog(window, false, "Save as Obj", 0, 0);
|
||||||
if(!path)
|
if(!cpath)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get ignore list from ui
|
std::string path(cpath);
|
||||||
std::set<std::string> ignore;
|
|
||||||
|
// get ignore list from ui
|
||||||
GtkTreeView* view = GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"));
|
std::set<std::string> ignore;
|
||||||
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
|
|
||||||
|
GtkTreeView* view = GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"));
|
||||||
GtkTreeIter iter;
|
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
|
||||||
gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list), &iter);
|
|
||||||
while(valid)
|
GtkTreeIter iter;
|
||||||
{
|
gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list), &iter);
|
||||||
gchar* data;
|
while(valid)
|
||||||
gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, 0, &data, -1);
|
{
|
||||||
globalOutputStream() << data << "\n";
|
gchar* data;
|
||||||
ignore.insert(std::string(data));
|
gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, 0, &data, -1);
|
||||||
g_free(data);
|
globalOutputStream() << data << "\n";
|
||||||
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list), &iter);
|
ignore.insert(std::string(data));
|
||||||
}
|
g_free(data);
|
||||||
|
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list), &iter);
|
||||||
for(std::set<std::string>::iterator it(ignore.begin()); it != ignore.end(); ++it)
|
}
|
||||||
globalOutputStream() << it->c_str() << "\n";
|
|
||||||
|
for(std::set<std::string>::iterator it(ignore.begin()); it != ignore.end(); ++it)
|
||||||
// collapse mode
|
globalOutputStream() << it->c_str() << "\n";
|
||||||
collapsemode mode = COLLAPSE_NONE;
|
|
||||||
|
// collapse mode
|
||||||
GtkWidget* radio = lookup_widget(GTK_WIDGET(button), "r_collapse");
|
collapsemode mode = COLLAPSE_NONE;
|
||||||
ASSERT_NOTNULL(radio);
|
|
||||||
|
GtkWidget* radio = lookup_widget(GTK_WIDGET(button), "r_collapse");
|
||||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
ASSERT_NOTNULL(radio);
|
||||||
mode = COLLAPSE_ALL;
|
|
||||||
else
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||||
{
|
mode = COLLAPSE_ALL;
|
||||||
radio = lookup_widget(GTK_WIDGET(button), "r_collapsebymaterial");
|
else
|
||||||
ASSERT_NOTNULL(radio);
|
{
|
||||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
radio = lookup_widget(GTK_WIDGET(button), "r_collapsebymaterial");
|
||||||
mode = COLLAPSE_BY_MATERIAL;
|
ASSERT_NOTNULL(radio);
|
||||||
else
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||||
{
|
mode = COLLAPSE_BY_MATERIAL;
|
||||||
radio = lookup_widget(GTK_WIDGET(button), "r_nocollapse");
|
else
|
||||||
ASSERT_NOTNULL(radio);
|
{
|
||||||
ASSERT_NOTNULL(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)));
|
radio = lookup_widget(GTK_WIDGET(button), "r_nocollapse");
|
||||||
mode = COLLAPSE_NONE;
|
ASSERT_NOTNULL(radio);
|
||||||
}
|
ASSERT_NOTNULL(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)));
|
||||||
}
|
mode = COLLAPSE_NONE;
|
||||||
|
}
|
||||||
// export
|
}
|
||||||
ExportSelection(ignore, mode, path);
|
|
||||||
}
|
// export materials?
|
||||||
|
GtkWidget* toggle = lookup_widget(GTK_WIDGET(button), "t_exportmaterials");
|
||||||
void OnAddMaterial(GtkButton* button, gpointer user_data)
|
ASSERT_NOTNULL(toggle);
|
||||||
{
|
|
||||||
GtkEntry* edit = GTK_ENTRY(lookup_widget(GTK_WIDGET(button), "ed_materialname"));
|
bool exportmat = FALSE;
|
||||||
ASSERT_NOTNULL(edit);
|
|
||||||
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)))
|
||||||
const gchar* name = gtk_entry_get_text(edit);
|
exportmat = TRUE;
|
||||||
if(g_utf8_strlen(name, -1) > 0)
|
|
||||||
{
|
// limit material names?
|
||||||
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"))));
|
toggle = lookup_widget(GTK_WIDGET(button), "t_limitmatnames");
|
||||||
GtkTreeIter iter;
|
ASSERT_NOTNULL(toggle);
|
||||||
gtk_list_store_append(list, &iter);
|
|
||||||
gtk_list_store_set(list, &iter, 0, name, -1);
|
bool limitMatNames = FALSE;
|
||||||
gtk_entry_set_text(edit, "");
|
|
||||||
}
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat)
|
||||||
}
|
limitMatNames = TRUE;
|
||||||
|
|
||||||
void OnRemoveMaterial(GtkButton* button, gpointer user_data)
|
// create objects instead of groups?
|
||||||
{
|
toggle = lookup_widget(GTK_WIDGET(button), "t_objects");
|
||||||
GtkTreeView* view = GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"));
|
ASSERT_NOTNULL(toggle);
|
||||||
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
|
|
||||||
GtkTreeSelection* sel = gtk_tree_view_get_selection(view);
|
bool objects = FALSE;
|
||||||
|
|
||||||
GtkTreeIter iter;
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat)
|
||||||
if(gtk_tree_selection_get_selected(sel, 0, &iter))
|
objects = TRUE;
|
||||||
gtk_list_store_remove(list, &iter);
|
|
||||||
}
|
// export
|
||||||
|
ExportSelection(ignore, mode, exportmat, path, limitMatNames, objects);
|
||||||
}// callbacks
|
}
|
||||||
|
|
||||||
|
void OnAddMaterial(GtkButton* button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkEntry* edit = GTK_ENTRY(lookup_widget(GTK_WIDGET(button), "ed_materialname"));
|
||||||
|
ASSERT_NOTNULL(edit);
|
||||||
|
|
||||||
|
const gchar* name = gtk_entry_get_text(edit);
|
||||||
|
if(g_utf8_strlen(name, -1) > 0)
|
||||||
|
{
|
||||||
|
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"))));
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, name, -1);
|
||||||
|
gtk_entry_set_text(edit, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnRemoveMaterial(GtkButton* button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkTreeView* view = GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(button), "t_materialist"));
|
||||||
|
GtkListStore* list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
|
||||||
|
GtkTreeSelection* sel = gtk_tree_view_get_selection(view);
|
||||||
|
|
||||||
|
GtkTreeIter iter;
|
||||||
|
if(gtk_tree_selection_get_selected(sel, 0, &iter))
|
||||||
|
gtk_list_store_remove(list, &iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnExportMatClicked(GtkButton* button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget* toggleLimit = lookup_widget(GTK_WIDGET(button), "t_limitmatnames");
|
||||||
|
GtkWidget* toggleObject = lookup_widget(GTK_WIDGET(button), "t_objects");
|
||||||
|
|
||||||
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
|
||||||
|
{
|
||||||
|
gtk_widget_set_sensitive(GTK_WIDGET(toggleLimit), TRUE);
|
||||||
|
gtk_widget_set_sensitive(GTK_WIDGET(toggleObject), TRUE);
|
||||||
|
} else {
|
||||||
|
gtk_widget_set_sensitive(GTK_WIDGET(toggleLimit), FALSE);
|
||||||
|
gtk_widget_set_sensitive(GTK_WIDGET(toggleObject), FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}// callbacks
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
typedef struct _GtkWidget GtkWidget;
|
typedef struct _GtkWidget GtkWidget;
|
||||||
typedef struct _GtkButton GtkButton;
|
typedef struct _GtkButton GtkButton;
|
||||||
|
|
||||||
namespace callbacks {
|
namespace callbacks {
|
||||||
|
|
||||||
void OnDestroy(GtkWidget*, gpointer);
|
void OnDestroy(GtkWidget*, gpointer);
|
||||||
void OnExportClicked(GtkButton*, gpointer);
|
void OnExportClicked(GtkButton*, gpointer);
|
||||||
void OnAddMaterial(GtkButton*, gpointer);
|
void OnAddMaterial(GtkButton*, gpointer);
|
||||||
void OnRemoveMaterial(GtkButton*, gpointer);
|
void OnRemoveMaterial(GtkButton*, gpointer);
|
||||||
|
void OnExportMatClicked(GtkButton* button, gpointer);
|
||||||
}// callbacks
|
|
||||||
|
}// callbacks
|
||||||
|
|
|
@ -1,274 +1,373 @@
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "debugging/debugging.h"
|
#include "debugging/debugging.h"
|
||||||
#include "ibrush.h"
|
#include "ibrush.h"
|
||||||
#include "iscenegraph.h"
|
#include "iscenegraph.h"
|
||||||
#include "iselection.h"
|
#include "iselection.h"
|
||||||
#include "stream/stringstream.h"
|
#include "stream/stringstream.h"
|
||||||
#include "stream/textfilestream.h"
|
#include "stream/textfilestream.h"
|
||||||
|
|
||||||
// this is very evil, but right now there is no better way
|
#include <map>
|
||||||
#include "../../radiant/brush.h"
|
|
||||||
|
// this is very evil, but right now there is no better way
|
||||||
/*
|
#include "../../radiant/brush.h"
|
||||||
Abstract baseclass for modelexporters
|
|
||||||
the class collects all the data which then gets
|
/*
|
||||||
exported through the WriteToFile method.
|
Abstract baseclass for modelexporters
|
||||||
*/
|
the class collects all the data which then gets
|
||||||
class ExportData
|
exported through the WriteToFile method.
|
||||||
{
|
*/
|
||||||
public:
|
class ExportData
|
||||||
ExportData(const std::set<std::string>& ignorelist, collapsemode mode);
|
{
|
||||||
virtual ~ExportData(void);
|
public:
|
||||||
|
ExportData(const std::set<std::string>& ignorelist, collapsemode mode, bool limNames, bool objs);
|
||||||
virtual void BeginBrush(Brush& b);
|
virtual ~ExportData(void);
|
||||||
virtual void AddBrushFace(Face& f);
|
|
||||||
virtual void EndBrush(void);
|
virtual void BeginBrush(Brush& b);
|
||||||
|
virtual void AddBrushFace(Face& f);
|
||||||
virtual bool WriteToFile(const std::string& path) const = 0;
|
virtual void EndBrush(void);
|
||||||
|
|
||||||
protected:
|
virtual bool WriteToFile(const std::string& path, collapsemode mode) const = 0;
|
||||||
|
|
||||||
// a group of faces
|
protected:
|
||||||
class group
|
|
||||||
{
|
// a group of faces
|
||||||
public:
|
class group
|
||||||
std::string name;
|
{
|
||||||
std::list<const Face*> faces;
|
public:
|
||||||
};
|
std::string name;
|
||||||
|
std::list<const Face*> faces;
|
||||||
std::list<group> groups;
|
};
|
||||||
|
|
||||||
private:
|
std::list<group> groups;
|
||||||
|
|
||||||
// "textures/common/caulk" -> "caulk"
|
private:
|
||||||
void GetShaderNameFromShaderPath(const char* path, std::string& name);
|
|
||||||
|
// "textures/common/caulk" -> "caulk"
|
||||||
group* current;
|
void GetShaderNameFromShaderPath(const char* path, std::string& name);
|
||||||
collapsemode mode;
|
|
||||||
const std::set<std::string>& ignorelist;
|
group* current;
|
||||||
};
|
collapsemode mode;
|
||||||
|
const std::set<std::string>& ignorelist;
|
||||||
ExportData::ExportData(const std::set<std::string>& _ignorelist, collapsemode _mode)
|
};
|
||||||
: mode(_mode),
|
|
||||||
ignorelist(_ignorelist)
|
ExportData::ExportData(const std::set<std::string>& _ignorelist, collapsemode _mode, bool _limNames, bool _objs)
|
||||||
{
|
: mode(_mode),
|
||||||
current = 0;
|
ignorelist(_ignorelist)
|
||||||
|
{
|
||||||
// in this mode, we need just one group
|
current = 0;
|
||||||
if(mode == COLLAPSE_ALL)
|
|
||||||
{
|
// in this mode, we need just one group
|
||||||
groups.push_back(group());
|
if(mode == COLLAPSE_ALL)
|
||||||
current = &groups.back();
|
{
|
||||||
current->name = "all";
|
groups.push_back(group());
|
||||||
}
|
current = &groups.back();
|
||||||
}
|
current->name = "all";
|
||||||
|
}
|
||||||
ExportData::~ExportData(void)
|
}
|
||||||
{
|
|
||||||
|
ExportData::~ExportData(void)
|
||||||
}
|
{
|
||||||
|
|
||||||
void ExportData::BeginBrush(Brush& b)
|
}
|
||||||
{
|
|
||||||
// create a new group for each brush
|
void ExportData::BeginBrush(Brush& b)
|
||||||
if(mode == COLLAPSE_NONE)
|
{
|
||||||
{
|
// create a new group for each brush
|
||||||
groups.push_back(group());
|
if(mode == COLLAPSE_NONE)
|
||||||
current = &groups.back();
|
{
|
||||||
|
groups.push_back(group());
|
||||||
StringOutputStream str(256);
|
current = &groups.back();
|
||||||
str << "Brush" << (const unsigned int)groups.size();
|
|
||||||
current->name = str.c_str();
|
StringOutputStream str(256);
|
||||||
}
|
str << "Brush" << (const unsigned int)groups.size();
|
||||||
}
|
current->name = str.c_str();
|
||||||
|
}
|
||||||
void ExportData::EndBrush(void)
|
}
|
||||||
{
|
|
||||||
// all faces of this brush were on the ignorelist, discard the emptygroup
|
void ExportData::EndBrush(void)
|
||||||
if(mode == COLLAPSE_NONE)
|
{
|
||||||
{
|
// all faces of this brush were on the ignorelist, discard the emptygroup
|
||||||
ASSERT_NOTNULL(current);
|
if(mode == COLLAPSE_NONE)
|
||||||
if(current->faces.empty())
|
{
|
||||||
{
|
ASSERT_NOTNULL(current);
|
||||||
groups.pop_back();
|
if(current->faces.empty())
|
||||||
current = 0;
|
{
|
||||||
}
|
groups.pop_back();
|
||||||
}
|
current = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void ExportData::AddBrushFace(Face& f)
|
}
|
||||||
{
|
|
||||||
std::string shadername;
|
void ExportData::AddBrushFace(Face& f)
|
||||||
GetShaderNameFromShaderPath(f.GetShader(), shadername);
|
{
|
||||||
|
std::string shadername;
|
||||||
// faces mit materials auf der ignoreliste ignorieren
|
GetShaderNameFromShaderPath(f.GetShader(), shadername);
|
||||||
if(ignorelist.find(shadername) != ignorelist.end())
|
|
||||||
return;
|
// ignore faces from ignore list
|
||||||
|
if(ignorelist.find(shadername) != ignorelist.end())
|
||||||
if(mode == COLLAPSE_BY_MATERIAL)
|
return;
|
||||||
{
|
|
||||||
// find a group for this material
|
if(mode == COLLAPSE_BY_MATERIAL)
|
||||||
current = 0;
|
{
|
||||||
const std::list<group>::iterator end(groups.end());
|
// find a group for this material
|
||||||
for(std::list<group>::iterator it(groups.begin()); it != end; ++it)
|
current = 0;
|
||||||
{
|
const std::list<group>::iterator end(groups.end());
|
||||||
if(it->name == shadername)
|
for(std::list<group>::iterator it(groups.begin()); it != end; ++it)
|
||||||
current = &(*it);
|
{
|
||||||
}
|
if(it->name == shadername)
|
||||||
|
current = &(*it);
|
||||||
// no group found, create one
|
}
|
||||||
if(!current)
|
|
||||||
{
|
// no group found, create one
|
||||||
groups.push_back(group());
|
if(!current)
|
||||||
current = &groups.back();
|
{
|
||||||
current->name = shadername;
|
groups.push_back(group());
|
||||||
}
|
current = &groups.back();
|
||||||
}
|
current->name = shadername;
|
||||||
|
}
|
||||||
ASSERT_NOTNULL(current);
|
}
|
||||||
|
|
||||||
// add face to current group
|
ASSERT_NOTNULL(current);
|
||||||
current->faces.push_back(&f);
|
|
||||||
|
// add face to current group
|
||||||
#ifdef _DEBUG
|
current->faces.push_back(&f);
|
||||||
globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n";
|
|
||||||
#endif
|
#ifdef _DEBUG
|
||||||
}
|
globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n";
|
||||||
|
#endif
|
||||||
void ExportData::GetShaderNameFromShaderPath(const char* path, std::string& name)
|
}
|
||||||
{
|
|
||||||
std::string tmp(path);
|
void ExportData::GetShaderNameFromShaderPath(const char* path, std::string& name)
|
||||||
|
{
|
||||||
size_t last_slash = tmp.find_last_of("/");
|
std::string tmp(path);
|
||||||
|
|
||||||
if(last_slash != std::string::npos && last_slash == (tmp.length() - 1))
|
size_t last_slash = tmp.find_last_of("/");
|
||||||
name = path;
|
|
||||||
else
|
if(last_slash != std::string::npos && last_slash == (tmp.length() - 1))
|
||||||
name = tmp.substr(last_slash + 1, tmp.length() - last_slash);
|
name = path;
|
||||||
|
else
|
||||||
globalOutputStream() << "Last: " << last_slash << " " << "lenght: " << (const unsigned int)tmp.length() << "Name: " << name.c_str() << "\n";
|
name = tmp.substr(last_slash + 1, tmp.length() - last_slash);
|
||||||
}
|
|
||||||
|
#ifdef _DEBUG
|
||||||
/*
|
globalOutputStream() << "Last: " << last_slash << " " << "length: " << (const unsigned int)tmp.length() << "Name: " << name.c_str() << "\n";
|
||||||
Exporter writing facedata as wavefront object
|
#endif
|
||||||
*/
|
}
|
||||||
class ExportDataAsWavefront : public ExportData
|
|
||||||
{
|
/*
|
||||||
public:
|
Exporter writing facedata as wavefront object
|
||||||
ExportDataAsWavefront(const std::set<std::string>& _ignorelist, collapsemode _mode)
|
*/
|
||||||
: ExportData(_ignorelist, _mode)
|
class ExportDataAsWavefront : public ExportData
|
||||||
{
|
{
|
||||||
}
|
private:
|
||||||
|
bool expmat;
|
||||||
bool WriteToFile(const std::string& path) const;
|
bool limNames;
|
||||||
};
|
bool objs;
|
||||||
|
|
||||||
bool ExportDataAsWavefront::WriteToFile(const std::string& path) const
|
public:
|
||||||
{
|
ExportDataAsWavefront(const std::set<std::string>& _ignorelist, collapsemode _mode, bool _expmat, bool _limNames, bool _objs)
|
||||||
TextFileOutputStream out(path.c_str());
|
: ExportData(_ignorelist, _mode, _limNames, _objs)
|
||||||
|
{
|
||||||
if(out.failed())
|
expmat = _expmat;
|
||||||
{
|
limNames = _limNames;
|
||||||
globalErrorStream() << "Unable to open file\n";
|
objs = _objs;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
bool WriteToFile(const std::string& path, collapsemode mode) const;
|
||||||
out << "# Wavefront Objectfile exported with radiants brushexport plugin 2.0 by Thomas 'namespace' Nitschke, spam@codecreator.net\n\n";
|
};
|
||||||
|
|
||||||
unsigned int vertex_count = 0;
|
bool ExportDataAsWavefront::WriteToFile(const std::string& path, collapsemode mode) const
|
||||||
|
{
|
||||||
const std::list<ExportData::group>::const_iterator gend(groups.end());
|
std::string objFile = path.substr(0, path.length() -4) + ".obj";
|
||||||
for(std::list<ExportData::group>::const_iterator git(groups.begin()); git != gend; ++git)
|
std::string mtlFile = path.substr(0, path.length() -4) + ".mtl";
|
||||||
{
|
|
||||||
const std::list<const Face*>::const_iterator end(git->faces.end());
|
std::set<std::string> materials;
|
||||||
|
|
||||||
// submesh starts here
|
TextFileOutputStream out(objFile.c_str());
|
||||||
out << "\ng " << git->name.c_str() << "\n";
|
|
||||||
|
if(out.failed())
|
||||||
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
{
|
||||||
{
|
globalErrorStream() << "Unable to open file\n";
|
||||||
const Winding& w((*it)->getWinding());
|
return false;
|
||||||
|
}
|
||||||
// vertices
|
|
||||||
for(size_t i = 0; i < w.numpoints; ++i)
|
out << "# Wavefront Objectfile exported with radiants brushexport plugin 3.0 by Thomas 'namespace' Nitschke, spam@codecreator.net\n\n";
|
||||||
out << "v " << FloatFormat(w[i].vertex.x(), 1, 6) << " " << FloatFormat(w[i].vertex.y(), 1, 6) << " " << FloatFormat(w[i].vertex.z(), 1, 6) << "\n";
|
|
||||||
}
|
if(expmat)
|
||||||
out << "\n";
|
{
|
||||||
|
size_t last = mtlFile.find_last_of("//");
|
||||||
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
std::string mtllib = mtlFile.substr(last + 1, mtlFile.size() - last).c_str();
|
||||||
{
|
out << "mtllib " << mtllib.c_str() << "\n";
|
||||||
const Winding& w((*it)->getWinding());
|
}
|
||||||
|
|
||||||
// texcoords
|
unsigned int vertex_count = 0;
|
||||||
for(size_t i = 0; i < w.numpoints; ++i)
|
|
||||||
out << "vt " << FloatFormat(w[i].texcoord.x(), 1, 6) << " " << FloatFormat(w[i].texcoord.y(), 1, 6) << "\n";
|
const std::list<ExportData::group>::const_iterator gend(groups.end());
|
||||||
}
|
for(std::list<ExportData::group>::const_iterator git(groups.begin()); git != gend; ++git)
|
||||||
|
{
|
||||||
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
typedef std::multimap<std::string, std::string> bm;
|
||||||
{
|
bm brushMaterials;
|
||||||
const Winding& w((*it)->getWinding());
|
typedef std::pair<std::string, std::string> String_Pair;
|
||||||
|
|
||||||
// faces
|
const std::list<const Face*>::const_iterator end(git->faces.end());
|
||||||
out << "\nf";
|
|
||||||
for(size_t i = 0; i < w.numpoints; ++i, ++vertex_count)
|
// submesh starts here
|
||||||
{
|
if(objs)
|
||||||
out << " " << vertex_count+1 << "/" << vertex_count+1;
|
{
|
||||||
}
|
out << "\no ";
|
||||||
}
|
} else {
|
||||||
out << "\n";
|
out << "\ng ";
|
||||||
}
|
}
|
||||||
|
out << git->name.c_str() << "\n";
|
||||||
return true;
|
|
||||||
}
|
// material
|
||||||
|
if(expmat && mode == COLLAPSE_ALL)
|
||||||
|
{
|
||||||
class ForEachFace : public BrushVisitor
|
out << "usemtl material" << "\n\n";
|
||||||
{
|
materials.insert("material");
|
||||||
public:
|
}
|
||||||
ForEachFace(ExportData& _exporter)
|
|
||||||
: exporter(_exporter)
|
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
||||||
{}
|
{
|
||||||
|
const Winding& w((*it)->getWinding());
|
||||||
void visit(Face& face) const
|
|
||||||
{
|
// vertices
|
||||||
exporter.AddBrushFace(face);
|
for(size_t i = 0; i < w.numpoints; ++i)
|
||||||
}
|
out << "v " << FloatFormat(w[i].vertex.x(), 1, 6) << " " << FloatFormat(w[i].vertex.z(), 1, 6) << " " << FloatFormat(w[i].vertex.y(), 1, 6) << "\n";
|
||||||
|
}
|
||||||
private:
|
out << "\n";
|
||||||
ExportData& exporter;
|
|
||||||
};
|
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
||||||
|
{
|
||||||
class ForEachSelected : public SelectionSystem::Visitor
|
const Winding& w((*it)->getWinding());
|
||||||
{
|
|
||||||
public:
|
// texcoords
|
||||||
ForEachSelected(ExportData& _exporter)
|
for(size_t i = 0; i < w.numpoints; ++i)
|
||||||
: exporter(_exporter)
|
out << "vt " << FloatFormat(w[i].texcoord.x(), 1, 6) << " " << FloatFormat(w[i].texcoord.y(), 1, 6) << "\n";
|
||||||
{}
|
}
|
||||||
|
|
||||||
void visit(scene::Instance& instance) const
|
for(std::list<const Face*>::const_iterator it(git->faces.begin()); it != end; ++it)
|
||||||
{
|
{
|
||||||
BrushInstance* bptr = InstanceTypeCast<BrushInstance>::cast(instance);
|
const Winding& w((*it)->getWinding());
|
||||||
if(bptr)
|
|
||||||
{
|
// faces
|
||||||
Brush& brush(bptr->getBrush());
|
StringOutputStream faceLine(256);
|
||||||
|
faceLine << "\nf";
|
||||||
exporter.BeginBrush(brush);
|
for(size_t i = 0; i < w.numpoints; ++i, ++vertex_count)
|
||||||
ForEachFace face_vis(exporter);
|
{
|
||||||
brush.forEachFace(face_vis);
|
faceLine << " " << vertex_count+1 << "/" << vertex_count+1;
|
||||||
exporter.EndBrush();
|
}
|
||||||
}
|
|
||||||
}
|
if(mode != COLLAPSE_ALL)
|
||||||
|
{
|
||||||
private:
|
materials.insert((*it)->getShader().getShader());
|
||||||
ExportData& exporter;
|
brushMaterials.insert(String_Pair((*it)->getShader().getShader(), faceLine.c_str()));
|
||||||
};
|
} else {
|
||||||
|
out << faceLine.c_str();
|
||||||
bool ExportSelection(const std::set<std::string>& ignorelist, collapsemode m, const std::string& path)
|
}
|
||||||
{
|
}
|
||||||
ExportDataAsWavefront exporter(ignorelist, m);
|
|
||||||
|
if(mode != COLLAPSE_ALL)
|
||||||
ForEachSelected vis(exporter);
|
{
|
||||||
GlobalSelectionSystem().foreachSelected(vis);
|
std::string lastMat;
|
||||||
|
std::string mat;
|
||||||
return exporter.WriteToFile(path);
|
std::string faces;
|
||||||
}
|
|
||||||
|
for(bm::iterator iter = brushMaterials.begin(); iter != brushMaterials.end(); iter++)
|
||||||
|
{
|
||||||
|
mat = (*iter).first.c_str();
|
||||||
|
faces = (*iter).second.c_str();
|
||||||
|
|
||||||
|
if(mat != lastMat)
|
||||||
|
{
|
||||||
|
if(limNames && mat.size() > 20)
|
||||||
|
{
|
||||||
|
out << "\nusemtl " << mat.substr(mat.size() - 20, mat.size()).c_str();
|
||||||
|
} else {
|
||||||
|
out << "\nusemtl " << mat.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out << faces.c_str();
|
||||||
|
lastMat = mat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(expmat)
|
||||||
|
{
|
||||||
|
TextFileOutputStream outMtl(mtlFile.c_str());
|
||||||
|
if(outMtl.failed())
|
||||||
|
{
|
||||||
|
globalErrorStream() << "Unable to open material file\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
outMtl << "# Wavefront material file exported with GtkRadiants brushexport plugin.\n";
|
||||||
|
outMtl << "# Material Count: " << (const Unsigned)materials.size() << "\n\n";
|
||||||
|
for(std::set<std::string>::const_iterator it(materials.begin()); it != materials.end(); ++it)
|
||||||
|
{
|
||||||
|
if(limNames && it->size() > 20)
|
||||||
|
{
|
||||||
|
outMtl << "newmtl " << it->substr(it->size() - 20, it->size()).c_str() << "\n";
|
||||||
|
} else {
|
||||||
|
outMtl << "newmtl " << it->c_str() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ForEachFace : public BrushVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ForEachFace(ExportData& _exporter)
|
||||||
|
: exporter(_exporter)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void visit(Face& face) const
|
||||||
|
{
|
||||||
|
exporter.AddBrushFace(face);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExportData& exporter;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ForEachSelected : public SelectionSystem::Visitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ForEachSelected(ExportData& _exporter)
|
||||||
|
: exporter(_exporter)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void visit(scene::Instance& instance) const
|
||||||
|
{
|
||||||
|
BrushInstance* bptr = InstanceTypeCast<BrushInstance>::cast(instance);
|
||||||
|
if(bptr)
|
||||||
|
{
|
||||||
|
Brush& brush(bptr->getBrush());
|
||||||
|
|
||||||
|
exporter.BeginBrush(brush);
|
||||||
|
ForEachFace face_vis(exporter);
|
||||||
|
brush.forEachFace(face_vis);
|
||||||
|
exporter.EndBrush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExportData& exporter;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ExportSelection(const std::set<std::string>& ignorelist, collapsemode m, bool exmat, const std::string& path, bool limNames, bool objs)
|
||||||
|
{
|
||||||
|
ExportDataAsWavefront exporter(ignorelist, m, exmat, limNames, objs);
|
||||||
|
|
||||||
|
ForEachSelected vis(exporter);
|
||||||
|
GlobalSelectionSystem().foreachSelected(vis);
|
||||||
|
|
||||||
|
return exporter.WriteToFile(path, m);
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#ifndef EXPORT_H
|
#ifndef EXPORT_H
|
||||||
#define EXPORT_H
|
#define EXPORT_H
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
enum collapsemode
|
enum collapsemode
|
||||||
{
|
{
|
||||||
COLLAPSE_ALL,
|
COLLAPSE_ALL,
|
||||||
COLLAPSE_BY_MATERIAL,
|
COLLAPSE_BY_MATERIAL,
|
||||||
COLLAPSE_NONE
|
COLLAPSE_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ExportSelection(const std::set<std::string>& ignorelist, collapsemode m, const std::string& path);
|
bool ExportSelection(const std::set<std::string>& ignorelist, collapsemode m, bool exmat, const std::string& path, bool limitMatNames, bool objects);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,212 +1,241 @@
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "debugging/debugging.h"
|
#include "debugging/debugging.h"
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
|
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
|
||||||
g_object_set_data_full (G_OBJECT (component), name, \
|
g_object_set_data_full (G_OBJECT (component), name, \
|
||||||
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
|
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
|
||||||
|
|
||||||
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
|
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
|
||||||
g_object_set_data (G_OBJECT (component), name, widget)
|
g_object_set_data (G_OBJECT (component), name, widget)
|
||||||
|
|
||||||
// created by glade
|
// created by glade
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
create_w_plugplug2 (void)
|
create_w_plugplug2 (void)
|
||||||
{
|
{
|
||||||
GtkWidget *w_plugplug2;
|
GtkWidget *w_plugplug2;
|
||||||
GtkWidget *vbox1;
|
GtkWidget *vbox1;
|
||||||
GtkWidget *hbox2;
|
GtkWidget *hbox2;
|
||||||
GtkWidget *vbox4;
|
GtkWidget *vbox4;
|
||||||
GtkWidget *r_collapse;
|
GtkWidget *r_collapse;
|
||||||
GSList *r_collapse_group = NULL;
|
GSList *r_collapse_group = NULL;
|
||||||
GtkWidget *r_collapsebymaterial;
|
GtkWidget *r_collapsebymaterial;
|
||||||
GtkWidget *r_nocollapse;
|
GtkWidget *r_nocollapse;
|
||||||
GtkWidget *vbox3;
|
GtkWidget *vbox3;
|
||||||
GtkWidget *b_export;
|
GtkWidget *b_export;
|
||||||
GtkWidget *b_close;
|
GtkWidget *b_close;
|
||||||
GtkWidget *vbox2;
|
GtkWidget *vbox2;
|
||||||
GtkWidget *label1;
|
GtkWidget *label1;
|
||||||
GtkWidget *scrolledwindow1;
|
GtkWidget *scrolledwindow1;
|
||||||
GtkWidget *t_materialist;
|
GtkWidget *t_materialist;
|
||||||
GtkWidget *ed_materialname;
|
GtkWidget *ed_materialname;
|
||||||
GtkWidget *hbox1;
|
GtkWidget *hbox1;
|
||||||
GtkWidget *b_addmaterial;
|
GtkWidget *b_addmaterial;
|
||||||
GtkWidget *b_removematerial;
|
GtkWidget *b_removematerial;
|
||||||
|
GtkWidget *t_exportmaterials;
|
||||||
w_plugplug2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
GtkWidget *t_limitmatnames;
|
||||||
gtk_widget_set_name (w_plugplug2, "w_plugplug2");
|
GtkWidget *t_objects;
|
||||||
gtk_window_set_title (GTK_WINDOW (w_plugplug2), "BrushExport-Plugin 2.0 by namespace");
|
GtkTooltips *tooltips;
|
||||||
gtk_window_set_position (GTK_WINDOW (w_plugplug2), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (w_plugplug2), TRUE);
|
tooltips = gtk_tooltips_new();
|
||||||
|
|
||||||
vbox1 = gtk_vbox_new (FALSE, 0);
|
w_plugplug2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_set_name (vbox1, "vbox1");
|
gtk_widget_set_name (w_plugplug2, "w_plugplug2");
|
||||||
gtk_widget_show (vbox1);
|
gtk_window_set_title (GTK_WINDOW (w_plugplug2), "BrushExport-Plugin 3.0 by namespace");
|
||||||
gtk_container_add (GTK_CONTAINER (w_plugplug2), vbox1);
|
gtk_window_set_position (GTK_WINDOW (w_plugplug2), GTK_WIN_POS_CENTER);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (w_plugplug2), TRUE);
|
||||||
|
|
||||||
hbox2 = gtk_hbox_new (TRUE, 5);
|
vbox1 = gtk_vbox_new (FALSE, 0);
|
||||||
gtk_widget_set_name (hbox2, "hbox2");
|
gtk_widget_set_name (vbox1, "vbox1");
|
||||||
gtk_widget_show (hbox2);
|
gtk_widget_show (vbox1);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
|
gtk_container_add (GTK_CONTAINER (w_plugplug2), vbox1);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);
|
||||||
|
|
||||||
vbox4 = gtk_vbox_new (TRUE, 0);
|
hbox2 = gtk_hbox_new (TRUE, 5);
|
||||||
gtk_widget_set_name (vbox4, "vbox4");
|
gtk_widget_set_name (hbox2, "hbox2");
|
||||||
gtk_widget_show (vbox4);
|
gtk_widget_show (hbox2);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox2), vbox4, TRUE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
|
||||||
r_collapse = gtk_radio_button_new_with_mnemonic (NULL, "Collapse mesh");
|
|
||||||
gtk_widget_set_name (r_collapse, "r_collapse");
|
vbox4 = gtk_vbox_new (TRUE, 0);
|
||||||
gtk_widget_show (r_collapse);
|
gtk_widget_set_name (vbox4, "vbox4");
|
||||||
gtk_box_pack_start (GTK_BOX (vbox4), r_collapse, FALSE, FALSE, 0);
|
gtk_widget_show (vbox4);
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_collapse), r_collapse_group);
|
gtk_box_pack_start (GTK_BOX (hbox2), vbox4, TRUE, FALSE, 0);
|
||||||
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_collapse));
|
|
||||||
|
r_collapse = gtk_radio_button_new_with_mnemonic (NULL, "Collapse mesh");
|
||||||
r_collapsebymaterial = gtk_radio_button_new_with_mnemonic (NULL, "Collapse by material");
|
gtk_widget_set_name (r_collapse, "r_collapse");
|
||||||
gtk_widget_set_name (r_collapsebymaterial, "r_collapsebymaterial");
|
gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltips), r_collapse, "Collapse all brushes into a single group", "Collapse all brushes into a single group");
|
||||||
gtk_widget_show (r_collapsebymaterial);
|
gtk_widget_show (r_collapse);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox4), r_collapsebymaterial, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox4), r_collapse, FALSE, FALSE, 0);
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_collapsebymaterial), r_collapse_group);
|
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_collapse), r_collapse_group);
|
||||||
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_collapsebymaterial));
|
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_collapse));
|
||||||
|
|
||||||
r_nocollapse = gtk_radio_button_new_with_mnemonic (NULL, "Don't collapse");
|
r_collapsebymaterial = gtk_radio_button_new_with_mnemonic (NULL, "Collapse by material");
|
||||||
gtk_widget_set_name (r_nocollapse, "r_nocollapse");
|
gtk_widget_set_name (r_collapsebymaterial, "r_collapsebymaterial");
|
||||||
gtk_widget_show (r_nocollapse);
|
gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltips), r_collapsebymaterial, "Collapse into groups by material", "Collapse into groups by material");
|
||||||
gtk_box_pack_start (GTK_BOX (vbox4), r_nocollapse, FALSE, FALSE, 0);
|
gtk_widget_show (r_collapsebymaterial);
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_nocollapse), r_collapse_group);
|
gtk_box_pack_start (GTK_BOX (vbox4), r_collapsebymaterial, FALSE, FALSE, 0);
|
||||||
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_nocollapse));
|
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_collapsebymaterial), r_collapse_group);
|
||||||
|
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_collapsebymaterial));
|
||||||
vbox3 = gtk_vbox_new (FALSE, 0);
|
|
||||||
gtk_widget_set_name (vbox3, "vbox3");
|
r_nocollapse = gtk_radio_button_new_with_mnemonic (NULL, "Don't collapse");
|
||||||
gtk_widget_show (vbox3);
|
gtk_widget_set_name (r_nocollapse, "r_nocollapse");
|
||||||
gtk_box_pack_start (GTK_BOX (hbox2), vbox3, FALSE, FALSE, 0);
|
gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltips), r_nocollapse, "Every brush is stored in its own group", "Every brush is stored in its own group");
|
||||||
|
gtk_widget_show (r_nocollapse);
|
||||||
b_export = gtk_button_new_from_stock ("gtk-save");
|
gtk_box_pack_start (GTK_BOX (vbox4), r_nocollapse, FALSE, FALSE, 0);
|
||||||
gtk_widget_set_name (b_export, "b_export");
|
gtk_radio_button_set_group (GTK_RADIO_BUTTON (r_nocollapse), r_collapse_group);
|
||||||
gtk_widget_show (b_export);
|
r_collapse_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (r_nocollapse));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox3), b_export, TRUE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (b_export), 5);
|
vbox3 = gtk_vbox_new (FALSE, 0);
|
||||||
|
gtk_widget_set_name (vbox3, "vbox3");
|
||||||
b_close = gtk_button_new_from_stock ("gtk-cancel");
|
gtk_widget_show (vbox3);
|
||||||
gtk_widget_set_name (b_close, "b_close");
|
gtk_box_pack_start (GTK_BOX (hbox2), vbox3, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (b_close);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox3), b_close, TRUE, FALSE, 0);
|
b_export = gtk_button_new_from_stock ("gtk-save");
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (b_close), 5);
|
gtk_widget_set_name (b_export, "b_export");
|
||||||
|
gtk_widget_show (b_export);
|
||||||
vbox2 = gtk_vbox_new (FALSE, 5);
|
gtk_box_pack_start (GTK_BOX (vbox3), b_export, TRUE, FALSE, 0);
|
||||||
gtk_widget_set_name (vbox2, "vbox2");
|
gtk_container_set_border_width (GTK_CONTAINER (b_export), 5);
|
||||||
gtk_widget_show (vbox2);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0);
|
b_close = gtk_button_new_from_stock ("gtk-cancel");
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
|
gtk_widget_set_name (b_close, "b_close");
|
||||||
|
gtk_widget_show (b_close);
|
||||||
label1 = gtk_label_new ("Ignored materials:");
|
gtk_box_pack_start (GTK_BOX (vbox3), b_close, TRUE, FALSE, 0);
|
||||||
gtk_widget_set_name (label1, "label1");
|
gtk_container_set_border_width (GTK_CONTAINER (b_close), 5);
|
||||||
gtk_widget_show (label1);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0);
|
vbox2 = gtk_vbox_new (FALSE, 5);
|
||||||
|
gtk_widget_set_name (vbox2, "vbox2");
|
||||||
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
|
gtk_widget_show (vbox2);
|
||||||
gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
|
gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (scrolledwindow1);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0);
|
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
label1 = gtk_label_new ("Ignored materials:");
|
||||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
|
gtk_widget_set_name (label1, "label1");
|
||||||
|
gtk_widget_show (label1);
|
||||||
t_materialist = gtk_tree_view_new ();
|
gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0);
|
||||||
gtk_widget_set_name (t_materialist, "t_materialist");
|
|
||||||
gtk_widget_show (t_materialist);
|
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_container_add (GTK_CONTAINER (scrolledwindow1), t_materialist);
|
gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (t_materialist), FALSE);
|
gtk_widget_show (scrolledwindow1);
|
||||||
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (t_materialist), FALSE);
|
gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
ed_materialname = gtk_entry_new ();
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
|
||||||
gtk_widget_set_name (ed_materialname, "ed_materialname");
|
|
||||||
gtk_widget_show (ed_materialname);
|
t_materialist = gtk_tree_view_new ();
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), ed_materialname, FALSE, FALSE, 0);
|
gtk_widget_set_name (t_materialist, "t_materialist");
|
||||||
|
gtk_widget_show (t_materialist);
|
||||||
hbox1 = gtk_hbox_new (TRUE, 0);
|
gtk_container_add (GTK_CONTAINER (scrolledwindow1), t_materialist);
|
||||||
gtk_widget_set_name (hbox1, "hbox1");
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (t_materialist), FALSE);
|
||||||
gtk_widget_show (hbox1);
|
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (t_materialist), FALSE);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
|
|
||||||
|
ed_materialname = gtk_entry_new ();
|
||||||
b_addmaterial = gtk_button_new_from_stock ("gtk-add");
|
gtk_widget_set_name (ed_materialname, "ed_materialname");
|
||||||
gtk_widget_set_name (b_addmaterial, "b_addmaterial");
|
gtk_widget_show (ed_materialname);
|
||||||
gtk_widget_show (b_addmaterial);
|
gtk_box_pack_start (GTK_BOX (vbox2), ed_materialname, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox1), b_addmaterial, FALSE, FALSE, 0);
|
|
||||||
|
hbox1 = gtk_hbox_new (TRUE, 0);
|
||||||
b_removematerial = gtk_button_new_from_stock ("gtk-remove");
|
gtk_widget_set_name (hbox1, "hbox1");
|
||||||
gtk_widget_set_name (b_removematerial, "b_removematerial");
|
gtk_widget_show (hbox1);
|
||||||
gtk_widget_show (b_removematerial);
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox1), b_removematerial, FALSE, FALSE, 0);
|
|
||||||
|
b_addmaterial = gtk_button_new_from_stock ("gtk-add");
|
||||||
using namespace callbacks;
|
gtk_widget_set_name (b_addmaterial, "b_addmaterial");
|
||||||
g_signal_connect(G_OBJECT(w_plugplug2), "destroy", G_CALLBACK(OnDestroy), NULL);
|
gtk_widget_show (b_addmaterial);
|
||||||
g_signal_connect_swapped(G_OBJECT(b_close), "clicked", G_CALLBACK (OnDestroy), NULL);
|
gtk_box_pack_start (GTK_BOX (hbox1), b_addmaterial, FALSE, FALSE, 0);
|
||||||
|
|
||||||
g_signal_connect ((gpointer) b_export, "clicked", G_CALLBACK (OnExportClicked), NULL);
|
b_removematerial = gtk_button_new_from_stock ("gtk-remove");
|
||||||
g_signal_connect ((gpointer) b_addmaterial, "clicked", G_CALLBACK (OnAddMaterial), NULL);
|
gtk_widget_set_name (b_removematerial, "b_removematerial");
|
||||||
g_signal_connect ((gpointer) b_removematerial, "clicked", G_CALLBACK (OnRemoveMaterial), NULL);
|
gtk_widget_show (b_removematerial);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox1), b_removematerial, FALSE, FALSE, 0);
|
||||||
/* Store pointers to all widgets, for use by lookup_widget(). */
|
|
||||||
GLADE_HOOKUP_OBJECT_NO_REF (w_plugplug2, w_plugplug2, "w_plugplug2");
|
t_limitmatnames = gtk_check_button_new_with_mnemonic ("Use short material names (max. 20 chars)");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox1, "vbox1");
|
gtk_widget_set_name (t_limitmatnames, "t_limitmatnames");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, hbox2, "hbox2");
|
gtk_widget_show (t_limitmatnames);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox4, "vbox4");
|
gtk_box_pack_end (GTK_BOX (vbox2), t_limitmatnames, FALSE, FALSE, 0);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, r_collapse, "r_collapse");
|
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, r_collapsebymaterial, "r_collapsebymaterial");
|
t_objects = gtk_check_button_new_with_mnemonic ("Create (o)bjects instead of (g)roups");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, r_nocollapse, "r_nocollapse");
|
gtk_widget_set_name (t_objects, "t_objects");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox3, "vbox3");
|
gtk_widget_show (t_objects);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, b_export, "b_export");
|
gtk_box_pack_end (GTK_BOX (vbox2), t_objects, FALSE, FALSE, 0);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, b_close, "b_close");
|
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox2, "vbox2");
|
t_exportmaterials = gtk_check_button_new_with_mnemonic ("Create material information (.mtl file)");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, label1, "label1");
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_exportmaterials), true);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, scrolledwindow1, "scrolledwindow1");
|
gtk_widget_set_name (t_exportmaterials, "t_exportmaterials");
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, t_materialist, "t_materialist");
|
gtk_widget_show (t_exportmaterials);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, ed_materialname, "ed_materialname");
|
gtk_box_pack_end (GTK_BOX (vbox2), t_exportmaterials, FALSE, FALSE, 10);
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, hbox1, "hbox1");
|
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, b_addmaterial, "b_addmaterial");
|
using namespace callbacks;
|
||||||
GLADE_HOOKUP_OBJECT (w_plugplug2, b_removematerial, "b_removematerial");
|
g_signal_connect(G_OBJECT(w_plugplug2), "destroy", G_CALLBACK(OnDestroy), NULL);
|
||||||
|
g_signal_connect_swapped(G_OBJECT(b_close), "clicked", G_CALLBACK (OnDestroy), NULL);
|
||||||
return w_plugplug2;
|
|
||||||
}
|
g_signal_connect ((gpointer) b_export, "clicked", G_CALLBACK (OnExportClicked), NULL);
|
||||||
|
g_signal_connect ((gpointer) b_addmaterial, "clicked", G_CALLBACK (OnAddMaterial), NULL);
|
||||||
// global main window, is 0 when not created
|
g_signal_connect ((gpointer) b_removematerial, "clicked", G_CALLBACK (OnRemoveMaterial), NULL);
|
||||||
GtkWidget* g_brushexp_window = 0;
|
g_signal_connect ((gpointer) t_exportmaterials, "clicked", G_CALLBACK (OnExportMatClicked), NULL);
|
||||||
|
|
||||||
// spawn plugin window (and make sure it got destroyed first or never created)
|
/* Store pointers to all widgets, for use by lookup_widget(). */
|
||||||
void CreateWindow(void)
|
GLADE_HOOKUP_OBJECT_NO_REF (w_plugplug2, w_plugplug2, "w_plugplug2");
|
||||||
{
|
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox1, "vbox1");
|
||||||
ASSERT_NOTNULL(!g_brushexp_window);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, hbox2, "hbox2");
|
||||||
|
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox4, "vbox4");
|
||||||
GtkWidget* wnd = create_w_plugplug2();
|
GLADE_HOOKUP_OBJECT (w_plugplug2, r_collapse, "r_collapse");
|
||||||
|
GLADE_HOOKUP_OBJECT (w_plugplug2, r_collapsebymaterial, "r_collapsebymaterial");
|
||||||
// column & renderer
|
GLADE_HOOKUP_OBJECT (w_plugplug2, r_nocollapse, "r_nocollapse");
|
||||||
GtkTreeViewColumn* col = gtk_tree_view_column_new();
|
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox3, "vbox3");
|
||||||
gtk_tree_view_column_set_title(col, "materials");
|
GLADE_HOOKUP_OBJECT (w_plugplug2, b_export, "b_export");
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), col);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, b_close, "b_close");
|
||||||
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
|
GLADE_HOOKUP_OBJECT (w_plugplug2, vbox2, "vbox2");
|
||||||
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), -1, "", renderer, "text", 0, NULL);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, label1, "label1");
|
||||||
|
GLADE_HOOKUP_OBJECT (w_plugplug2, scrolledwindow1, "scrolledwindow1");
|
||||||
// list store
|
GLADE_HOOKUP_OBJECT (w_plugplug2, t_materialist, "t_materialist");
|
||||||
GtkListStore* ignorelist = gtk_list_store_new(1, G_TYPE_STRING);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, ed_materialname, "ed_materialname");
|
||||||
gtk_tree_view_set_model(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), GTK_TREE_MODEL(ignorelist));
|
GLADE_HOOKUP_OBJECT (w_plugplug2, hbox1, "hbox1");
|
||||||
g_object_unref(ignorelist);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, b_addmaterial, "b_addmaterial");
|
||||||
|
GLADE_HOOKUP_OBJECT (w_plugplug2, b_removematerial, "b_removematerial");
|
||||||
gtk_widget_show_all(wnd);
|
GLADE_HOOKUP_OBJECT (w_plugplug2, t_exportmaterials, "t_exportmaterials");
|
||||||
g_brushexp_window = wnd;
|
GLADE_HOOKUP_OBJECT (w_plugplug2, t_limitmatnames, "t_limitmatnames");
|
||||||
}
|
GLADE_HOOKUP_OBJECT (w_plugplug2, t_objects, "t_objects");
|
||||||
|
|
||||||
void DestroyWindow(void)
|
return w_plugplug2;
|
||||||
{
|
}
|
||||||
ASSERT_NOTNULL(g_brushexp_window);
|
|
||||||
gtk_widget_destroy(g_brushexp_window);
|
// global main window, is 0 when not created
|
||||||
g_brushexp_window = 0;
|
GtkWidget* g_brushexp_window = 0;
|
||||||
}
|
|
||||||
|
// spawn plugin window (and make sure it got destroyed first or never created)
|
||||||
bool IsWindowOpen(void)
|
void CreateWindow(void)
|
||||||
{
|
{
|
||||||
return g_brushexp_window != 0;
|
ASSERT_NOTNULL(!g_brushexp_window);
|
||||||
}
|
|
||||||
|
GtkWidget* wnd = create_w_plugplug2();
|
||||||
|
|
||||||
|
// column & renderer
|
||||||
|
GtkTreeViewColumn* col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_column_set_title(col, "materials");
|
||||||
|
gtk_tree_view_append_column(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), col);
|
||||||
|
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), -1, "", renderer, "text", 0, NULL);
|
||||||
|
|
||||||
|
// list store
|
||||||
|
GtkListStore* ignorelist = gtk_list_store_new(1, G_TYPE_STRING);
|
||||||
|
gtk_tree_view_set_model(GTK_TREE_VIEW(lookup_widget(wnd, "t_materialist")), GTK_TREE_MODEL(ignorelist));
|
||||||
|
g_object_unref(ignorelist);
|
||||||
|
|
||||||
|
gtk_widget_show_all(wnd);
|
||||||
|
g_brushexp_window = wnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyWindow(void)
|
||||||
|
{
|
||||||
|
ASSERT_NOTNULL(g_brushexp_window);
|
||||||
|
gtk_widget_destroy(g_brushexp_window);
|
||||||
|
g_brushexp_window = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsWindowOpen(void)
|
||||||
|
{
|
||||||
|
return g_brushexp_window != 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,134 +1,134 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006, Thomas Nitschke.
|
Copyright (C) 2006, Thomas Nitschke.
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
This file is part of GtkRadiant.
|
This file is part of GtkRadiant.
|
||||||
|
|
||||||
GtkRadiant is free software; you can redistribute it and/or modify
|
GtkRadiant is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
GtkRadiant is distributed in the hope that it will be useful,
|
GtkRadiant is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with GtkRadiant; if not, write to the Free Software
|
along with GtkRadiant; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#include "iplugin.h"
|
#include "iplugin.h"
|
||||||
#include "qerplugin.h"
|
#include "qerplugin.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtk/gtktreeview.h>
|
#include <gtk/gtktreeview.h>
|
||||||
|
|
||||||
#include "debugging/debugging.h"
|
#include "debugging/debugging.h"
|
||||||
#include "string/string.h"
|
#include "string/string.h"
|
||||||
#include "modulesystem/singletonmodule.h"
|
#include "modulesystem/singletonmodule.h"
|
||||||
#include "stream/textfilestream.h"
|
#include "stream/textfilestream.h"
|
||||||
#include "stream/stringstream.h"
|
#include "stream/stringstream.h"
|
||||||
#include "gtkutil/messagebox.h"
|
#include "gtkutil/messagebox.h"
|
||||||
#include "gtkutil/filechooser.h"
|
#include "gtkutil/filechooser.h"
|
||||||
|
|
||||||
#include "ibrush.h"
|
#include "ibrush.h"
|
||||||
#include "iscenegraph.h"
|
#include "iscenegraph.h"
|
||||||
#include "iselection.h"
|
#include "iselection.h"
|
||||||
#include "ifilesystem.h"
|
#include "ifilesystem.h"
|
||||||
#include "ifiletypes.h"
|
#include "ifiletypes.h"
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
#include "typesystem.h"
|
#include "typesystem.h"
|
||||||
|
|
||||||
void CreateWindow (void);
|
void CreateWindow (void);
|
||||||
void DestroyWindow(void);
|
void DestroyWindow(void);
|
||||||
bool IsWindowOpen(void);
|
bool IsWindowOpen(void);
|
||||||
|
|
||||||
namespace BrushExport
|
namespace BrushExport
|
||||||
{
|
{
|
||||||
GtkWindow* g_mainwnd;
|
GtkWindow* g_mainwnd;
|
||||||
|
|
||||||
const char* init(void* hApp, void* pMainWidget)
|
const char* init(void* hApp, void* pMainWidget)
|
||||||
{
|
{
|
||||||
g_mainwnd = (GtkWindow*)pMainWidget;
|
g_mainwnd = (GtkWindow*)pMainWidget;
|
||||||
ASSERT_NOTNULL(g_mainwnd);
|
ASSERT_NOTNULL(g_mainwnd);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
const char* getName()
|
const char* getName()
|
||||||
{
|
{
|
||||||
return "Brush export Plugin";
|
return "Brush export Plugin";
|
||||||
}
|
}
|
||||||
const char* getCommandList()
|
const char* getCommandList()
|
||||||
{
|
{
|
||||||
return "Export selected as Wavefront Object;About";
|
return "Export selected as Wavefront Object;About";
|
||||||
}
|
}
|
||||||
const char* getCommandTitleList()
|
const char* getCommandTitleList()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch(const char* command, float* vMin, float* vMax, bool bSingleBrush)
|
void dispatch(const char* command, float* vMin, float* vMax, bool bSingleBrush)
|
||||||
{
|
{
|
||||||
if(string_equal(command, "About"))
|
if(string_equal(command, "About"))
|
||||||
{
|
{
|
||||||
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n"
|
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n"
|
||||||
"Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...",
|
"Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...",
|
||||||
eMB_OK,
|
eMB_OK,
|
||||||
eMB_ICONDEFAULT);
|
eMB_ICONDEFAULT);
|
||||||
}
|
}
|
||||||
else if(string_equal(command, "Export selected as Wavefront Object"))
|
else if(string_equal(command, "Export selected as Wavefront Object"))
|
||||||
{
|
{
|
||||||
if(IsWindowOpen())
|
if(IsWindowOpen())
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
CreateWindow();
|
CreateWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BrushExportDependencies :
|
class BrushExportDependencies :
|
||||||
public GlobalRadiantModuleRef,
|
public GlobalRadiantModuleRef,
|
||||||
public GlobalFiletypesModuleRef,
|
public GlobalFiletypesModuleRef,
|
||||||
public GlobalBrushModuleRef,
|
public GlobalBrushModuleRef,
|
||||||
public GlobalFileSystemModuleRef,
|
public GlobalFileSystemModuleRef,
|
||||||
public GlobalSceneGraphModuleRef,
|
public GlobalSceneGraphModuleRef,
|
||||||
public GlobalSelectionModuleRef
|
public GlobalSelectionModuleRef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BrushExportDependencies(void)
|
BrushExportDependencies(void)
|
||||||
: GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes"))
|
: GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes"))
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BrushExportModule : public TypeSystemRef
|
class BrushExportModule : public TypeSystemRef
|
||||||
{
|
{
|
||||||
_QERPluginTable m_plugin;
|
_QERPluginTable m_plugin;
|
||||||
public:
|
public:
|
||||||
typedef _QERPluginTable Type;
|
typedef _QERPluginTable Type;
|
||||||
STRING_CONSTANT(Name, "brushexport2");
|
STRING_CONSTANT(Name, "brushexport2");
|
||||||
|
|
||||||
BrushExportModule()
|
BrushExportModule()
|
||||||
{
|
{
|
||||||
m_plugin.m_pfnQERPlug_Init = &BrushExport::init;
|
m_plugin.m_pfnQERPlug_Init = &BrushExport::init;
|
||||||
m_plugin.m_pfnQERPlug_GetName = &BrushExport::getName;
|
m_plugin.m_pfnQERPlug_GetName = &BrushExport::getName;
|
||||||
m_plugin.m_pfnQERPlug_GetCommandList = &BrushExport::getCommandList;
|
m_plugin.m_pfnQERPlug_GetCommandList = &BrushExport::getCommandList;
|
||||||
m_plugin.m_pfnQERPlug_GetCommandTitleList = &BrushExport::getCommandTitleList;
|
m_plugin.m_pfnQERPlug_GetCommandTitleList = &BrushExport::getCommandTitleList;
|
||||||
m_plugin.m_pfnQERPlug_Dispatch = &BrushExport::dispatch;
|
m_plugin.m_pfnQERPlug_Dispatch = &BrushExport::dispatch;
|
||||||
}
|
}
|
||||||
_QERPluginTable* getTable()
|
_QERPluginTable* getTable()
|
||||||
{
|
{
|
||||||
return &m_plugin;
|
return &m_plugin;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SingletonModule<BrushExportModule, BrushExportDependencies> SingletonBrushExportModule;
|
typedef SingletonModule<BrushExportModule, BrushExportDependencies> SingletonBrushExportModule;
|
||||||
SingletonBrushExportModule g_BrushExportModule;
|
SingletonBrushExportModule g_BrushExportModule;
|
||||||
|
|
||||||
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
|
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
|
||||||
{
|
{
|
||||||
initialiseModule(server);
|
initialiseModule(server);
|
||||||
g_BrushExportModule.selfRegister();
|
g_BrushExportModule.selfRegister();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
lookup_widget (GtkWidget *widget,
|
lookup_widget (GtkWidget *widget,
|
||||||
const gchar *widget_name)
|
const gchar *widget_name)
|
||||||
{
|
{
|
||||||
GtkWidget *parent, *found_widget;
|
GtkWidget *parent, *found_widget;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (GTK_IS_MENU (widget))
|
if (GTK_IS_MENU (widget))
|
||||||
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
||||||
else
|
else
|
||||||
parent = widget->parent;
|
parent = widget->parent;
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
|
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
|
||||||
if (parent == NULL)
|
if (parent == NULL)
|
||||||
break;
|
break;
|
||||||
widget = parent;
|
widget = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
|
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
|
||||||
widget_name);
|
widget_name);
|
||||||
if (!found_widget)
|
if (!found_widget)
|
||||||
g_warning ("Widget not found: %s", widget_name);
|
g_warning ("Widget not found: %s", widget_name);
|
||||||
return found_widget;
|
return found_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public Functions.
|
* Public Functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function returns a widget in a component created by Glade.
|
* This function returns a widget in a component created by Glade.
|
||||||
* Call it with the toplevel widget in the component (i.e. a window/dialog),
|
* Call it with the toplevel widget in the component (i.e. a window/dialog),
|
||||||
* or alternatively any widget in the component, and the name of the widget
|
* or alternatively any widget in the component, and the name of the widget
|
||||||
* you want returned.
|
* you want returned.
|
||||||
*/
|
*/
|
||||||
GtkWidget* lookup_widget (GtkWidget *widget,
|
GtkWidget* lookup_widget (GtkWidget *widget,
|
||||||
const gchar *widget_name);
|
const gchar *widget_name);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue