- Added LocalLcPath to plugin interface

- Added enhanced Texturebrowser (ETB) by Shaderman
- Added shaderplug by Shaderman, accompanies the ETB
- Added xmltagging lib by Shaderman, accompanies the ETB
- Added new icons for ETB, Console, Entityinspector and Lighteditor
- Fixed minor warning in Sunplug Project
- Fixed PATH_MAX namecollision in ptrview plugin on Linux
- Final fix for 64 bit patch.h issue

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@107 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
namespace 2006-09-30 15:56:36 +00:00
parent 53bb8dbf01
commit c11d5da7a3
26 changed files with 2559 additions and 529 deletions

13
CHANGES
View file

@ -1,6 +1,19 @@
This is the changelog for developers, != changelog for the end user
that we distribute with the binaries. (see changelog)
30/09/2006
namespace
- Added LocalLcPath to plugin interface
- Added enhanced Texturebrowser (ETB) by Shaderman
- Added shaderplug by Shaderman, accompanies the ETB
- Added xmltagging lib by Shaderman, accompanies the ETB
- Added new icons for ETB, Console, Entityinspector and Lighteditor
- Fixed minor warning in Sunplug Project
- Fixed PATH_MAX namecollision in ptrview plugin on Linux
- Final fix for 64 bit patch.h issue
12/09/2006
namespace
- Fixed 64 Bit issue in patch.h, see http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=1109

View file

@ -5,6 +5,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "entityq3", "plugins\entity\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GtkRadiant", "radiant\GtkRadiant.vcproj", "{8E70385C-223A-4DD1-9B99-28FF2331A2B5}"
ProjectSection(ProjectDependencies) = postProject
{1C785349-866D-447D-8C55-8A51E5CA0E87} = {1C785349-866D-447D-8C55-8A51E5CA0E87}
{68E2C6B6-96CA-4BBD-A485-FEE6F2E65407} = {68E2C6B6-96CA-4BBD-A485-FEE6F2E65407}
{8845C5C1-4154-425F-8643-447FADC03449} = {8845C5C1-4154-425F-8643-447FADC03449}
{8845C5C1-4154-425F-8643-447FADC03449} = {8845C5C1-4154-425F-8643-447FADC03449}
@ -158,6 +159,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "brushexport", "contrib\brus
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaderplug", "contrib\shaderplug\shaderplug.vcproj", "{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}"
ProjectSection(ProjectDependencies) = postProject
{1C785349-866D-447D-8C55-8A51E5CA0E87} = {1C785349-866D-447D-8C55-8A51E5CA0E87}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@ -296,6 +302,10 @@ Global
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Debug.Build.0 = Debug|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Release.ActiveCfg = Release|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Release.Build.0 = Release|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Debug.ActiveCfg = Debug|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Debug.Build.0 = Debug|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Release.ActiveCfg = Release|Win32
{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View file

@ -16,6 +16,12 @@ def build_list(s_prefix, s_string):
cmdlib_lib = g_env.StaticLibrary(target='libs/cmdlib', source='libs/cmdlib/cmdlib.cpp')
xml_env = g_env.Copy()
xml_env.Prepend(CPPPATH = 'include')
xml_env.Append(CXXFLAGS='`pkg-config glib-2.0 --cflags` `xml2-config --cflags`')
xml_src = 'ixml.cpp xmlparser.cpp xmlwriter.cpp xmlelement.cpp xmltextags.cpp'
xml_lib = xml_env.StaticLibrary(target='libs/xmllib', source=build_list('libs/xml', xml_src))
mathlib_src = 'mathlib.c bbox.c line.c m4x4.c ray.c'
mathlib_lib = g_env.StaticLibrary(target='libs/mathlib', source=build_list('libs/mathlib', mathlib_src))
@ -488,6 +494,14 @@ sunplug_env.useGtk2()
sunplug_lib = sunplug_env.SharedLibrarySafe(target='sunplug', source=sunplug_lst, LIBPATH='libs')
sunplug_env.Install(INSTALL + '/plugins', sunplug_lib)
shaderplug_env = module_env.Copy()
shaderplug_lst = build_list('contrib/shaderplug', 'shaderplug.cpp')
shaderplug_env.useGlib2()
shaderplug_env.useGtk2()
shaderplug_env.useXML2()
shaderplug_lib = shaderplug_env.SharedLibrarySafe(target='shaderplug', source=shaderplug_lst, LIBS='xmllib', LIBPATH='libs')
shaderplug_env.Install(INSTALL + '/plugins', shaderplug_lib)
#gensurf_lst = build_list('contrib/gtkgensurf',
#'bitmap.cpp dec.cpp face.cpp font.cpp gendlgs.cpp genmap.cpp gensurf.cpp heretic.cpp plugin.cpp view.cpp triangle.c')
#bob_env.SharedLibrarySafe(target='gensurf', source=gensurf_lst)
@ -599,13 +613,14 @@ radiant_src = [
for i in range(len(radiant_src)):
radiant_src[i] = 'radiant/' + radiant_src[i]
radiant_libs = ['mathlib', 'cmdlib', 'l_net', 'profile', 'gtkutil']
radiant_libs = ['mathlib', 'cmdlib', 'l_net', 'profile', 'gtkutil', 'xmllib']
radiant_prog = radiant_env.Program(target='radiant.' + g_cpu, source=radiant_src, LIBS=radiant_libs, LIBPATH='libs')
radiant_env.Depends(radiant_prog, mathlib_lib)
radiant_env.Depends(radiant_prog, cmdlib_lib)
radiant_env.Depends(radiant_prog, l_net_lib)
radiant_env.Depends(radiant_prog, profile_lib)
radiant_env.Depends(radiant_prog, gtkutil_lib)
radiant_env.Depends(radiant_prog, xml_lib)
radiant_env.Install(INSTALL, radiant_prog)

1
TODO
View file

@ -42,7 +42,6 @@ This variable could then be used in a command like this:
Entity: option to filter non-world entities (e.g. not func_group or func_static)
Rotate Tool: if more than one object is selected, with different local orientations, use parent-space rotation pivot instead of local-space
Texture Browser: add a way to make large texture sets more manageable - shaderlist.txt was previously used this way
Brush: MMB+ctrl to paint texture on whole brush/patch.
Camera: add alternative highlighting styles (used to be J).
Doom3: filter func_splinemovers

View file

@ -52,7 +52,7 @@ public:
bool Build(char *def);
};
#define PATH_MAX 260
#define PRTVIEW_PATH_MAX 260
typedef guint32 PackedColour;
#define RGB(r, g, b) ((guint32)(((guint8) (r) | ((guint16) (g) << 8))|(((guint32) (guint8) (b)) << 16)))
#define GetRValue(rgb) ((guint8)(rgb))
@ -76,7 +76,7 @@ public:
void FixColors();
char fn[PATH_MAX];
char fn[PRTVIEW_PATH_MAX];
int zbuffer;
int polygons;

View file

@ -0,0 +1,263 @@
/*
Copyright (C) 2006, Stefan Greven.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "shaderplug.h"
#include "debugging/debugging.h"
#include <string>
#include <vector>
#include "string/string.h"
#include "modulesystem/singletonmodule.h"
#include "stream/stringstream.h"
#include "os/file.h"
#include <gtk/gtk.h>
#include "iplugin.h"
#include "qerplugin.h"
#include "ifilesystem.h"
#include "iarchive.h"
#include "ishaders.h"
#include "iscriplib.h"
#include "generic/callback.h"
namespace {
const char SHADERTAG_FILE[] = "shadertags.xml";
}
class ShaderPlugPluginDependencies : public GlobalRadiantModuleRef,
public GlobalFileSystemModuleRef,
public GlobalShadersModuleRef
{
public:
ShaderPlugPluginDependencies() :
GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders"))
{
}
};
namespace Shaderplug
{
GtkWindow* g_window;
std::vector<const char*> archives;
std::set<std::string> shaders;
std::set<std::string> textures;
XmlTagBuilder TagBuilder;
void CreateTagFile();
const char* init(void* hApp, void* pMainWidget)
{
g_window = GTK_WINDOW(pMainWidget);
return "";
}
const char* getName()
{
return "ShaderPlug";
}
const char* getCommandList()
{
return "About;Create tag file";
}
const char* getCommandTitleList()
{
return "";
}
void dispatch(const char* command, float* vMin, float* vMax, bool bSingleBrush)
{
if(string_equal(command, "About"))
{
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_window), "Shaderplug (1.0)\n\n"
"by Shaderman (shaderman@gmx.net)",
"About",
eMB_OK,
eMB_ICONDEFAULT);
}
if(string_equal(command, "Create tag file"))
{
CreateTagFile();
}
}
void loadArchiveFile(const char* filename)
{
archives.push_back(filename);
}
typedef FreeCaller1<const char*, loadArchiveFile> LoadArchiveFileCaller;
void LoadTextureFile(const char* filename)
{
std::string s_filename = filename;
char buffer[256];
strcpy(buffer, "textures/");
// append filename without trailing file extension (.tga or .jpg for example)
strncat(buffer, filename, s_filename.length() - 4);
std::set<std::string>::iterator iter;
iter = shaders.find(buffer);
// a shader with this name already exists
if(iter == shaders.end())
{
textures.insert(buffer);
}
}
typedef FreeCaller1<const char*, LoadTextureFile> LoadTextureFileCaller;
void GetTextures(char* extension)
{
GlobalFileSystem().forEachFile("textures/", extension, LoadTextureFileCaller(), 0);
}
void LoadShaderList(const char* filename)
{
if(string_equal_prefix(filename, "textures/"))
{
shaders.insert(filename);
}
}
typedef FreeCaller1<const char*, LoadShaderList> LoadShaderListCaller;
void GetAllShaders()
{
GlobalShaderSystem().foreachShaderName(LoadShaderListCaller());
}
void GetArchiveList()
{
GlobalFileSystem().forEachArchive(LoadArchiveFileCaller());
globalOutputStream() << "Shaderplug: " << (const Unsigned)Shaderplug::archives.size() << " archives found.\n";
}
void CreateTagFile()
{
const char* shader_type = GlobalRadiant().getGameDescriptionKeyValue("shaders");
GetAllShaders();
globalOutputStream() << "Shaderplug: " << (const Unsigned)shaders.size() << " shaders found.\n";
if(string_equal(shader_type, "quake3"))
{
GetTextures("jpg");
GetTextures("tga");
GetTextures("png");
globalOutputStream() << "Shaderplug: " << (const Unsigned)textures.size() << " textures found.\n";
}
if(shaders.size() || textures.size() != 0)
{
globalOutputStream() << "Shaderplug: Creating XML tag file.\n";
TagBuilder.CreateXmlDocument();
std::set<std::string>::reverse_iterator r_iter;
for(r_iter = textures.rbegin(); r_iter != textures.rend(); ++r_iter)
{
TagBuilder.AddShaderNode(const_cast<char*>((*r_iter).c_str()), STOCK, TEXTURE);
}
for(r_iter = shaders.rbegin(); r_iter != shaders.rend(); ++r_iter)
{
TagBuilder.AddShaderNode(const_cast<char*>((*r_iter).c_str()), STOCK, SHADER);
}
// Get the tag file
StringOutputStream tagFileStream(256);
tagFileStream << GlobalRadiant().getLocalRcPath() << SHADERTAG_FILE;
char* tagFile = tagFileStream.c_str();
char message[256];
strcpy(message, "Tag file saved to\n");
strcat(message, tagFile);
strcat(message, "\nPlease restart Radiant now.\n");
if(file_exists(tagFile))
{
EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_window),
"WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?",
eMB_NOYES,
eMB_ICONWARNING);
if(result == eIDYES)
{
TagBuilder.SaveXmlDoc(tagFile);
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_window), message, "INFO", eMB_OK, eMB_ICONASTERISK);
}
} else {
TagBuilder.SaveXmlDoc(tagFile);
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_window), message, "INFO", eMB_OK, eMB_ICONASTERISK);
}
} else {
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_window),
"No shaders or textures found. No XML tag file created!\n"
"",
"ERROR",
eMB_OK,
eMB_ICONERROR);
}
}
} // namespace
class ShaderPluginModule
{
_QERPluginTable m_plugin;
public:
typedef _QERPluginTable Type;
STRING_CONSTANT(Name, "ShaderPlug");
ShaderPluginModule()
{
m_plugin.m_pfnQERPlug_Init = &Shaderplug::init;
m_plugin.m_pfnQERPlug_GetName = &Shaderplug::getName;
m_plugin.m_pfnQERPlug_GetCommandList = &Shaderplug::getCommandList;
m_plugin.m_pfnQERPlug_GetCommandTitleList = &Shaderplug::getCommandTitleList;
m_plugin.m_pfnQERPlug_Dispatch = &Shaderplug::dispatch;
}
_QERPluginTable* getTable()
{
return &m_plugin;
}
};
typedef SingletonModule<ShaderPluginModule, ShaderPlugPluginDependencies> SingletonShaderPluginModule;
SingletonShaderPluginModule g_ShaderPluginModule;
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
initialiseModule(server);
g_ShaderPluginModule.selfRegister();
}

View file

@ -0,0 +1,7 @@
; shaderplug.def : Declares the module parameters for the DLL.
LIBRARY "SHADERPLUG"
EXPORTS
; Explicit exports can go here
Radiant_RegisterModules @1

View file

@ -0,0 +1,27 @@
/*
Copyright (C) 2006, Stefan Greven.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(INCLUDED_SHADERPLUG_H)
#define INCLUDED_SHADERPLUG_H
#include "xml/xmltextags.h"
#endif

View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="shaderplug"
ProjectGUID="{46B36F0C-5E17-458E-AE6F-AECE52F66EDE}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include;../../libs;&quot;../../../STLPort-4.6/stlport&quot;;&quot;..\..\..\gtk2-2.4\include\glib-2.0&quot;;&quot;..\..\..\gtk2-2.4\include\gtk-2.0&quot;;&quot;..\..\..\gtk2-2.4\lib\glib-2.0\include&quot;;..\..\libs\generic;&quot;..\..\..\gtk2-2.4\include\pango-1.0&quot;;&quot;..\..\..\gtk2-2.4\lib\gtk-2.0\include&quot;;&quot;..\..\..\gtk2-2.4\include\atk-1.0&quot;;..\..\plugins\shaders;&quot;..\..\..\libxml2-2.6\include&quot;;&quot;..\..\..\iconv-1.9\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SHADERPLUG_EXPORTS"
StringPooling="TRUE"
MinimalRebuild="TRUE"
ExceptionHandling="FALSE"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
BufferSecurityCheck="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
BrowseInformation="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
DisableSpecificWarnings="4610;4510;4512;4505;4100;4127"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gtk-win32-2.0.lib gobject-2.0.lib libxml2.lib glib-2.0.lib"
OutputFile="$(OutDir)/shaderplug.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="&quot;..\..\..\gtk2-2.4\lib&quot;;&quot;..\..\..\libxml2-2.6\lib&quot;"
IgnoreDefaultLibraryNames="msvcprtd.lib"
ModuleDefinitionFile="$(ProjectName).def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/shaderplug.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)install\plugins&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="TRUE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForWindowsApplication="FALSE"
AdditionalIncludeDirectories="../../include;..\..\libs;&quot;../../../STLPort-4.6/stlport&quot;;&quot;..\..\..\libxml2-2.6\include&quot;;&quot;..\..\..\iconv-1.9\include&quot;;&quot;..\..\..\gtk2-2.4\include\glib-2.0&quot;;&quot;..\..\..\gtk2-2.4\lib\glib-2.0\include&quot;;&quot;..\..\..\gtk2-2.4\include\gtk-2.0&quot;;&quot;..\..\..\gtk2-2.4\include\pango-1.0&quot;;&quot;..\..\..\gtk2-2.4\lib\gtk-2.0\include&quot;;&quot;..\..\..\gtk2-2.4\include\atk-1.0&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SHADERPLUG_EXPORTS"
StringPooling="TRUE"
ExceptionHandling="FALSE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
DisableSpecificWarnings="4610;4510;4512;4505;4100;4127"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib gtk-win32-2.0.lib gobject-2.0.lib libxml2.lib"
OutputFile="$(OutDir)/shaderplug.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="&quot;..\..\..\gtk2-2.4\lib&quot;;&quot;..\..\..\libxml2-2.6\lib&quot;"
IgnoreDefaultLibraryNames="msvcprt.lib"
ModuleDefinitionFile="$(ProjectName).def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/shaderplug.lib"
TargetMachine="1"
FixedBaseAddress="0"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)install\plugins&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="src"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{22F2852C-8177-45D5-94D0-C5255C199F7F}">
<File
RelativePath=".\shaderplug.cpp">
</File>
<File
RelativePath=".\shaderplug.h">
</File>
</Filter>
<File
RelativePath=".\shaderplug.def">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -31,7 +31,7 @@
BrowseInformation="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View file

@ -118,6 +118,7 @@ struct _QERFuncTable_1
STRING_CONSTANT(Name, "radiant");
const char* (*getEnginePath)();
const char* (*getLocalRcPath)();
const char* (*getGameToolsPath)();
const char* (*getAppPath)();
const char* (*getSettingsPath)();

View file

@ -32,7 +32,7 @@
BrowseInformation="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"
DebugInformationFormat="3"
DisableSpecificWarnings="4610;4510;4512;4505;4100;4127"/>
<Tool
Name="VCCustomBuildTool"/>
@ -233,6 +233,12 @@
<File
RelativePath=".\xml\xmlparser.h">
</File>
<File
RelativePath=".\xml\xmltextags.cpp">
</File>
<File
RelativePath=".\xml\xmltextags.h">
</File>
<File
RelativePath=".\xml\xmlwriter.cpp">
</File>

593
libs/xml/xmltextags.cpp Normal file
View file

@ -0,0 +1,593 @@
/*
Copyright (C) 2006, Stefan Greven.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xmltextags.h"
#include <string>
#include "qerplugin.h"
#include "stream/stringstream.h"
XmlTagBuilder::XmlTagBuilder()
{
}
XmlTagBuilder::~XmlTagBuilder()
{
// clean up
xmlFreeDoc(doc);
xmlXPathFreeContext(context);
}
bool XmlTagBuilder::CreateXmlDocument()
{
/* Creates an XML file
returns TRUE if the file was created successfully or FALSE when failed
*/
xmlTextWriterPtr writer;
writer = xmlNewTextWriterDoc(&doc, 0);
// begin a new UTF-8 formatted xml document
xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
// create the root node with stock and custom elements
xmlTextWriterStartElement(writer, (xmlChar*)"root");
xmlTextWriterWriteString(writer, (xmlChar*)"\n ");
xmlTextWriterStartElement(writer, (xmlChar*)"stock");
xmlTextWriterWriteString(writer, (xmlChar*)"\n ");
xmlTextWriterEndElement(writer);
xmlTextWriterWriteString(writer, (xmlChar*)"\n ");
xmlTextWriterStartElement(writer, (xmlChar*)"custom");
xmlTextWriterWriteString(writer, (xmlChar*)"\n ");
xmlTextWriterEndElement(writer);
xmlTextWriterWriteString(writer, (xmlChar*)"\n");
xmlTextWriterEndElement(writer);
// end of the xml document
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
if(!doc)
{
return false;
} else {
context = xmlXPathNewContext(doc);
return true;
}
}
bool XmlTagBuilder::OpenXmlDoc(const char* file)
{
/* Reads a XML document from a file
returns TRUE if the document was read successfully or FALSE when failed
*/
filename = file;
doc = xmlParseFile(file); // TODO error checking!
if(!doc)
{
return false;
} else {
context = xmlXPathNewContext(doc);
return true;
}
}
bool XmlTagBuilder::SaveXmlDoc(void)
{
return SaveXmlDoc(filename.c_str());
}
bool XmlTagBuilder::SaveXmlDoc(const char* file)
{
/* Writes the XML document
returns TRUE if the document was saved successfully or FALSE when saving failed
*/
xmlSaveNoEmptyTags = 1;
if(xmlSaveFile(file, doc) != -1)
{
return true;
}
return false;
}
bool XmlTagBuilder::AddShaderNode(const char* shader, TextureType textureType, NodeShaderType nodeShaderType)
{
/* Adds a shader node
char* shader - the name of the shader or texture (without trailing .tga or something)
returns TRUE if the node was added successfully or FALSE when failed
*/
xmlNodeSetPtr nodePtr = NULL;
xmlXPathObjectPtr xpathPtr = NULL;
switch(textureType)
{
case STOCK:
xpathPtr = XpathEval("/root/stock");
break;
case CUSTOM:
xpathPtr = XpathEval("/root/custom");
};
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlNodePtr newnode, newtext;
xmlNodePtr nodeParent = nodePtr->nodeTab[0];
// create a new node and set the node attribute (shader path)
switch(nodeShaderType)
{
case SHADER:
newnode = xmlNewNode(NULL, (xmlChar*)"shader");
break;
case TEXTURE:
newnode = xmlNewNode(NULL, (xmlChar*)"texture");
};
newnode = xmlDocCopyNode(newnode, doc, 1);
xmlSetProp(newnode, (xmlChar*)"path", (xmlChar*)shader);
xmlNodeSetContent(newnode, (xmlChar*)"\n ");
if(nodePtr->nodeTab[0]->children->next == NULL) // there are no shaders yet
{
// add spaces
newtext = xmlNewText((xmlChar*)" ");
xmlAddChild(nodeParent->children, newtext);
// add the new node
xmlAddNextSibling(nodeParent->children, newnode);
// append a new line
newtext = xmlNewText((xmlChar*)"\n ");
xmlAddNextSibling(nodeParent->children->next, newtext);
} else {
// add the node
xmlAddNextSibling(nodeParent->children, newnode);
// append a new line and spaces
newtext = xmlNewText((xmlChar*)"\n ");
xmlAddNextSibling(nodeParent->children->next, newtext);
}
xmlXPathFreeObject(xpathPtr);
return true;
} else {
xmlXPathFreeObject(xpathPtr);
return false;
}
}
bool XmlTagBuilder::DeleteShaderNode(const char* shader)
{
/* Deletes a shader node
char* shader - the name of the shader or texture (without trailing .tga or something)
returns TRUE if the node was deleted successfully or FALSE when failed
*/
char buffer[256];
char* expression = GetTagsXpathExpression(buffer, shader, EMPTY);
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlNodePtr ptrContent = nodePtr->nodeTab[0];
xmlNodePtr ptrWhitespace = nodePtr->nodeTab[0]->prev;
// delete the node
xmlUnlinkNode(ptrContent);
xmlFreeNode(ptrContent);
// delete leading whitespace node
xmlUnlinkNode(ptrWhitespace);
xmlFreeNode(ptrWhitespace);
xmlXPathFreeObject(xpathPtr);
return true;
}
xmlXPathFreeObject(xpathPtr);
return false;
}
bool XmlTagBuilder::CheckShaderTag(const char* shader)
{
/* Checks whether there exists an entry for a shader/texture with at least one tag
char* shader - the name of the shader or texture (without trailing .tga or something)
returns TRUE if the shader is already stored in the XML tag file and has at least one tag
*/
// build the XPath expression to search for
char buffer[256];
strcpy(buffer, "/root/*/*[@path='");
strcat(buffer, shader);
strcat(buffer, "']");
char* expression = buffer;
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlXPathFreeObject(xpathPtr);
return true;
} else {
xmlXPathFreeObject(xpathPtr);
return false;
}
}
bool XmlTagBuilder::CheckShaderTag(const char* shader, const char* content)
{
/* Checks whether a tag with content already exists
char* shader - the name of the shader or texture (without trailing .tga or something)
char* content - the node content (a tag name)
returns TRUE if the tag with content already exists or FALSE if not
*/
// build the XPath expression to search for
// example expression: "/stock/*[@path='textures/alpha/barb_wire'][child::tag='Alpha']";
char buffer[256];
strcpy(buffer, "/root/*/*[@path='");
strcat(buffer, shader);
strcat(buffer, "'][child::tag='");
strcat(buffer, content);
strcat(buffer, "']");
char* expression = buffer;
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlXPathFreeObject(xpathPtr);
return true;
} else {
xmlXPathFreeObject(xpathPtr);
return false;
}
}
bool XmlTagBuilder::AddShaderTag(const char* shader, const char* content, NodeTagType nodeTagType)
{
/* Adds a tag node to an existing shader/texture node if there's no tag with the same content yet
char* shader - the name of the shader or texture (without trailing .tga or something)
char* content - the node content (a tag name)
returns TRUE if the node was added successfully or FALSE when failed
*/
// build the XPath expression
char buffer[256];
char* expression = GetTagsXpathExpression(buffer, shader, EMPTY);
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr)) // node was found
{
xmlNodePtr newnode = xmlNewNode(NULL, (xmlChar*)"tag");
xmlNodePtr nodeParent = nodePtr->nodeTab[0];
newnode = xmlDocCopyNode(newnode, doc, 1);
xmlNodeSetContent(newnode, (xmlChar*)content);
if(nodePtr->nodeTab[0]->children->next == NULL) // shader node has NO children
{
// add spaces
xmlNodePtr newtext = xmlNewText((xmlChar*)" ");
xmlAddChild(nodeParent->children, newtext);
// add new node
xmlAddNextSibling(nodeParent->children, newnode);
// append a new line + spaces
newtext = xmlNewText((xmlChar*)"\n ");
xmlAddNextSibling(nodeParent->children->next, newtext);
} else { // shader node has children already - the new node will be the first sibling
xmlAddNextSibling(nodeParent->children, newnode);
xmlNodePtr newtext = xmlNewText((xmlChar*)"\n ");
xmlAddNextSibling(nodeParent->children->next, newtext);
}
xmlXPathFreeObject(xpathPtr);
return true;
} else {
xmlXPathFreeObject(xpathPtr);
return false;
}
}
//int XmlTagBuilder::RenameShaderTag(const char* oldtag, const char* newtag)
int XmlTagBuilder::RenameShaderTag(const char* oldtag, CopiedString newtag)
{
/* Replaces tag node contents
char* oldtag - the <tag></tag> node content that sould be changed
char* newtag - the new <tag></tag> node content
returns the number of renamed shaders
*/
int num = 0;
// build the XPath expression
char expression[256];
strcpy(expression, "/root/*/*[child::tag='");
strcat(expression, oldtag);
strcat(expression, "']/*");
xmlXPathObjectPtr result = xmlXPathEvalExpression((xmlChar*)expression, context);
if(!result)
return 0;
xmlNodeSetPtr nodePtr = result->nodesetval;
for(int i = 0; i < nodePtr->nodeNr; i++)
{
xmlNodePtr ptrContent = nodePtr->nodeTab[i];
char* content = (char*)xmlNodeGetContent(ptrContent);
if(strcmp(content, oldtag) == 0) // found a node with old content?
{
xmlNodeSetContent(ptrContent, (xmlChar*)newtag.c_str());
num++;
}
}
SaveXmlDoc();
xmlXPathFreeObject(result);// CHANGED
return num;
}
bool XmlTagBuilder::DeleteShaderTag(const char* shader, const char* tag)
{
/* Deletes a child node of a shader
char* shader - the name of the shader or texture (without trailing .tga or something)
char* tag - the tag being deleted
returns TRUE if the node was deleted successfully or FALSE when failed
*/
char buffer[256];
char* expression = GetTagsXpathExpression(buffer, shader, TAG);
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return false;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
for(int i = 0; i < nodePtr->nodeNr; i++)
{
xmlNodePtr ptrContent = nodePtr->nodeTab[i];
char* content = (char*)(xmlChar*)xmlNodeGetContent(ptrContent);
if(strcmp(content, tag) == 0) // find the node
{
xmlNodePtr ptrWhitespace = nodePtr->nodeTab[i]->prev;
// delete the node
xmlUnlinkNode(ptrContent);
xmlFreeNode(ptrContent);
// delete leading whitespace node
xmlUnlinkNode(ptrWhitespace);
xmlFreeNode(ptrWhitespace);
xmlXPathFreeObject(xpathPtr);
return true;
}
}
}
xmlXPathFreeObject(xpathPtr);
return false;
}
bool XmlTagBuilder::DeleteTag(const char* tag)
{
/* Deletes a tag from all shaders
char* tag - the tag being deleted from all shaders
returns TRUE if the tag was deleted successfully or FALSE when failed
*/
char expression[256];
strcpy(expression, "/root/*/*[child::tag='");
strcat(expression, tag);
strcat(expression, "']");
std::set<CopiedString> dellist;
TagSearch(expression, dellist);
std::set<CopiedString>::iterator iter;
for(iter = dellist.begin(); iter != dellist.end(); iter++)
{
DeleteShaderTag(iter->c_str(), tag);
}
SaveXmlDoc();
return true;
}
void XmlTagBuilder::GetShaderTags(const char* shader, std::vector<CopiedString>& tags)
{
/* Gets the tags from a shader
char* shader - the name of the shader
returns a vector containing the tags
*/
char* expression;
if(shader == NULL) // get all tags from all shaders
{
expression = "/root/*/*/tag";
} else {
char buffer[256];
expression = GetTagsXpathExpression(buffer, shader, TAG);
}
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
for(int i = 0; i < nodePtr->nodeNr; i++)
{
tags.push_back((CopiedString)(char*)xmlNodeGetContent(nodePtr->nodeTab[i]));
}
}
xmlXPathFreeObject(xpathPtr);
}
void XmlTagBuilder::GetUntagged(std::set<CopiedString>& shaders)
{
/* Gets all textures and shaders listed in the xml file that don't have any tag
returns a set containing the shaders (with path)
*/
char* expression = "/root/*/*[not(child::tag)]";
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlNodePtr ptr;
for(int i = 0; i < nodePtr->nodeNr; i++)
{
ptr = nodePtr->nodeTab[i];
shaders.insert((char*)xmlGetProp(ptr, (xmlChar*)"path"));
}
}
xmlXPathFreeObject(xpathPtr);
}
void XmlTagBuilder::GetAllTags(std::set<CopiedString>& tags)
{
/* Gets a list of all tags that are used (assigned to any shader)
returns a set containing all used tags
*/
char* expression = "/root/*/*/tag";
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
for(int i = 0; i < nodePtr->nodeNr; i++)
{
tags.insert((CopiedString)(char*)xmlNodeGetContent(nodePtr->nodeTab[i]));
}
}
xmlXPathFreeObject(xpathPtr);
}
void XmlTagBuilder::TagSearch(const char* expression, std::set<CopiedString>& paths)
{
/* Searches shaders by tags
char* expression - the XPath expression to search
returns a set containing the found shaders
*/
xmlXPathObjectPtr xpathPtr = XpathEval(expression);
xmlNodeSetPtr nodePtr;
if(xpathPtr)
nodePtr = xpathPtr->nodesetval;
else
return;
if(!xmlXPathNodeSetIsEmpty(nodePtr))
{
xmlNodePtr ptr;
xmlChar* xmlattrib;
for(int i = 0; i < nodePtr->nodeNr; i++)
{
ptr = nodePtr->nodeTab[i];
xmlattrib = xmlGetProp(ptr, (xmlChar*)"path");
paths.insert((CopiedString)(char*)xmlattrib);
}
}
xmlXPathFreeObject(xpathPtr);
}

106
libs/xml/xmltextags.h Normal file
View file

@ -0,0 +1,106 @@
/*
Copyright (C) 2006, Stefan Greven.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(INCLUDED_XMLTEXTAGS_H)
#define INCLUDED_XMLTEXTAGS_H
#include <set>
#include <string/string.h>
#include <vector>
#include "iscriplib.h"
#include <libxml/xpath.h>
#include <libxml/xmlwriter.h>
enum NodeTagType
{
TAG,
EMPTY
};
enum NodeShaderType
{
SHADER,
TEXTURE
};
enum TextureType
{
STOCK,
CUSTOM
};
class XmlTagBuilder
{
private:
CopiedString filename;
xmlDocPtr doc;
xmlXPathContextPtr context;
xmlNodeSetPtr nodePtr;
xmlXPathObjectPtr XpathEval(const char* queryString)
{
xmlChar* expression = (xmlChar*)queryString;
xmlXPathObjectPtr result = xmlXPathEvalExpression(expression, context);
return result;
};
char* GetTagsXpathExpression(char* buffer, const char* shader, NodeTagType nodeTagType)
{
strcpy(buffer, "/root/*/*[@path='");
strcat(buffer, shader);
switch(nodeTagType)
{
case TAG:
strcat(buffer, "']/tag");
break;
case EMPTY:
strcat(buffer, "']");
};
return buffer;
}
public:
XmlTagBuilder();
~XmlTagBuilder();
bool CreateXmlDocument();
bool OpenXmlDoc(const char* file);
bool SaveXmlDoc(const char* file);
bool SaveXmlDoc(void);
bool AddShaderNode(const char* shader, TextureType textureType, NodeShaderType nodeShaderType);
bool DeleteShaderNode(const char* shader);
bool CheckShaderTag(const char* shader);
bool CheckShaderTag(const char* shader, const char* content);
bool AddShaderTag(const char* shader, const char* content, NodeTagType nodeTagType);
bool DeleteTag(const char* tag);
int RenameShaderTag(const char* oldtag, CopiedString newtag);
bool DeleteShaderTag(const char* shader, const char* tag);
void GetShaderTags(const char* shader, std::vector<CopiedString>& tags);
void GetUntagged(std::set<CopiedString>& shaders);
void GetAllTags(std::set<CopiedString>& tags);
void TagSearch(const char* expression, std::set<CopiedString>& paths);
};
#endif

View file

@ -613,93 +613,6 @@ void DoAbout()
gtk_widget_destroy(GTK_WIDGET(window));
}
// =============================================================================
// Texture List dialog
void DoTextureListDlg()
{
ModalDialog dialog;
ModalDialogButton ok_button(dialog, eIDOK);
ModalDialogButton cancel_button(dialog, eIDCANCEL);
GtkWidget* texture_list;
GtkWindow* window = create_modal_dialog_window(MainFrame_getWindow(), "Textures", dialog, 400, 400);
GtkHBox* hbox = create_dialog_hbox(4, 4);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(hbox));
{
GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX (hbox), GTK_WIDGET(scr), TRUE, TRUE, 0);
{
GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
{
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
}
gtk_widget_show(view);
gtk_container_add(GTK_CONTAINER (scr), view);
{
// Initialize dialog
GSList *textures = 0;
TextureGroupsMenu_ListItems(textures);
while (textures != 0)
{
{
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
StringOutputStream name(64);
name << ConvertLocaleToUTF8(reinterpret_cast<const char*>(textures->data));
gtk_list_store_set(store, &iter, 0, name.c_str(), -1);
}
textures = g_slist_remove (textures, textures->data);
}
}
g_object_unref(G_OBJECT(store));
texture_list = view;
}
}
GtkVBox* vbox = create_dialog_vbox(4);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, TRUE, 0);
{
GtkButton* button = create_modal_dialog_button("Load", ok_button);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
}
{
GtkButton* button = create_modal_dialog_button("Close", cancel_button);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
}
if(modal_dialog_show(window, dialog) == eIDOK)
{
GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(texture_list));
GtkTreeModel* model;
GtkTreeIter iter;
if(gtk_tree_selection_get_selected(selection, &model, &iter))
{
GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
if(gtk_tree_path_get_depth(path) == 1)
TextureBrowser_ShowDirectory(GlobalTextureBrowser(), TextureGroupsMenu_GetName(gtk_tree_path_get_indices(path)[0]));
gtk_tree_path_free(path);
}
}
gtk_widget_destroy(GTK_WIDGET(window));
}
// =============================================================================
// TextureLayout dialog
@ -1025,6 +938,125 @@ EMessageBoxReturn DoLightIntensityDlg (int *intensity)
return ret;
}
// =============================================================================
// Add new shader tag dialog
EMessageBoxReturn DoShaderTagDlg (CopiedString* tag, char* title)
{
ModalDialog dialog;
GtkEntry* textentry;
ModalDialogButton ok_button(dialog, eIDOK);
ModalDialogButton cancel_button(dialog, eIDCANCEL);
GtkWindow* window = create_modal_dialog_window(MainFrame_getWindow(), title, dialog, -1, -1);
GtkAccelGroup *accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(window, accel_group);
{
GtkHBox* hbox = create_dialog_hbox(4, 4);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(hbox));
{
GtkVBox* vbox = create_dialog_vbox(4);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), TRUE, TRUE, 0);
{
//GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces"));
GtkLabel* label = GTK_LABEL(gtk_label_new("ESC to cancel, ENTER to validate"));
gtk_widget_show(GTK_WIDGET(label));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
}
{
GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
gtk_widget_show(GTK_WIDGET(entry));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(entry), TRUE, TRUE, 0);
gtk_widget_grab_focus(GTK_WIDGET(entry));
textentry = entry;
}
}
{
GtkVBox* vbox = create_dialog_vbox(4);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 0);
{
GtkButton* button = create_modal_dialog_button("OK", ok_button);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
widget_make_default(GTK_WIDGET(button));
gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
}
{
GtkButton* button = create_modal_dialog_button("Cancel", cancel_button);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
}
}
}
EMessageBoxReturn ret = modal_dialog_show(window, dialog);
if(ret == eIDOK)
{
*tag = gtk_entry_get_text(textentry);
}
gtk_widget_destroy(GTK_WIDGET(window));
return ret;
}
EMessageBoxReturn DoShaderInfoDlg (const char* name, const char* filename, char* title)
{
ModalDialog dialog;
ModalDialogButton ok_button(dialog, eIDOK);
GtkWindow* window = create_modal_dialog_window(MainFrame_getWindow(), title, dialog, -1, -1);
GtkAccelGroup *accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(window, accel_group);
{
GtkHBox* hbox = create_dialog_hbox(4, 4);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(hbox));
{
GtkVBox* vbox = create_dialog_vbox(4);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 0);
{
GtkLabel* label = GTK_LABEL(gtk_label_new("The selected shader"));
gtk_widget_show(GTK_WIDGET(label));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
}
{
GtkLabel* label = GTK_LABEL(gtk_label_new(name));
gtk_widget_show(GTK_WIDGET(label));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
}
{
GtkLabel* label = GTK_LABEL(gtk_label_new("is located in file"));
gtk_widget_show(GTK_WIDGET(label));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
}
{
GtkLabel* label = GTK_LABEL(gtk_label_new(filename));
gtk_widget_show(GTK_WIDGET(label));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
}
{
GtkButton* button = create_modal_dialog_button("OK", ok_button);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
widget_make_default(GTK_WIDGET(button));
gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
}
}
}
EMessageBoxReturn ret = modal_dialog_show(window, dialog);
gtk_widget_destroy(GTK_WIDGET(window));
return ret;
}
#ifdef WIN32
#include <gdk/gdkwin32.h>

View file

@ -32,14 +32,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_GTKDLGS_H
#include "qerplugin.h"
#include "string/string.h"
EMessageBoxReturn DoLightIntensityDlg (int *intensity);
EMessageBoxReturn DoShaderTagDlg (CopiedString *tag, char* title);
EMessageBoxReturn DoShaderInfoDlg (const char* name, const char* filename, char* title);
EMessageBoxReturn DoTextureLayout (float *fx, float *fy);
void DoTextEditor (const char* filename, int cursorpos);
void DoProjectSettings();
void DoTextureListDlg();
void DoFind();
void DoSides(int type, int axis);
void DoAbout();

View file

@ -339,6 +339,19 @@ const char* AppPath_get()
return g_strAppPath.c_str();
}
/// the path to the local rc-dir
const char* LocalRcPath_get(void)
{
static CopiedString rc_path;
if(rc_path.empty())
{
StringOutputStream stream(256);
stream << GlobalRadiant().getSettingsPath() << g_pGameDescription->mGameFile.c_str() << "/";
rc_path = stream.c_str();
}
return rc_path.c_str();
}
/// directory for temp files
/// NOTE: on *nix this is were we check for .pid
CopiedString g_strSettingsPath;
@ -2018,7 +2031,7 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
if(style == MainFrame::eFloating || style == MainFrame::eSplit)
{
create_menu_item_with_mnemonic(menu, "Console View", "ToggleConsole");
create_menu_item_with_mnemonic(menu, "Texture Browser", "ViewTextures");
create_menu_item_with_mnemonic(menu, "Texture Browser", "ToggleTextures");
create_menu_item_with_mnemonic(menu, "Entity Inspector", "ToggleEntityInspector");
}
else
@ -2183,44 +2196,6 @@ GtkMenuItem* create_grid_menu()
return grid_menu_item;
}
void RefreshShaders()
{
ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Shaders");
GlobalShaderSystem().refresh();
UpdateAllWindows();
}
GtkMenuItem* create_textures_menu()
{
// Textures menu
GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic("_Textures");
GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(textures_menu_item));
g_textures_menu = menu;
if (g_Layout_enableDetachableMenus.m_value)
menu_tearoff (menu);
create_check_menu_item_with_mnemonic(menu, "Hide _Unused", "ShowInUse");
create_menu_item_with_mnemonic(menu, "Show All", "ShowAllTextures");
menu_separator(menu);
create_check_menu_item_with_mnemonic(menu, "Show shaders", "ToggleShowShaders");
create_menu_item_with_mnemonic(menu, "Flush & Reload Shaders", "RefreshShaders");
create_menu_item_with_mnemonic(menu, "Directory list...", "TextureDirectoryList");
menu_separator(menu);
create_menu_item_with_mnemonic(menu, "Find / Replace...", "FindReplaceTextures");
menu_separator(menu);
create_check_menu_item_with_mnemonic (menu, "Shaders Only", "ToggleShowShaderlistOnly");
g_textures_menu_separator = menu_separator(menu);
TextureGroupsMenu_Construct();
return textures_menu_item;
}
GtkMenuItem* create_misc_menu()
{
// Misc menu
@ -2315,7 +2290,6 @@ GtkMenuBar* create_main_menu(MainFrame::EViewStyle style)
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_selection_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_bsp_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_grid_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_textures_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_misc_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_entity_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_brush_menu()));
@ -2507,6 +2481,21 @@ GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
toolbar_append_toggle_button(toolbar, "Texture Lock", "texture_lock.bmp", "TogTexLock");
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
GtkButton* g_view_entities_button = toolbar_append_button(toolbar, "Entities", "entities.bmp", "ToggleEntityInspector");
GtkButton* g_view_console_button = toolbar_append_button(toolbar, "Console", "console.bmp", "ToggleConsole");
GtkButton* g_view_textures_button = toolbar_append_button(toolbar, "Texture Browser", "texture_browser.bmp", "ToggleTextures");
// TODO: call light inspector
//GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.bmp", "ToggleLightInspector");
// disable the console and texture button in the regular layouts
if(style == MainFrame::eRegular || style == MainFrame::eRegularLeft)
{
gtk_widget_set_sensitive(GTK_WIDGET(g_view_console_button), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(g_view_textures_button), FALSE);
}
return toolbar;
}
@ -2980,7 +2969,6 @@ void MainFrame::Create()
GtkFrame* texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
gtk_paned_add2(GTK_PANED(vsplit2), GTK_WIDGET(texture_window));
}
}
}
@ -3164,8 +3152,6 @@ void MainFrame::Shutdown()
EntityList_destroyWindow();
g_textures_menu = 0;
delete m_pXYWnd;
m_pXYWnd = 0;
delete m_pYZWnd;
@ -3420,10 +3406,6 @@ void MainFrame_Construct()
GlobalCommands_insert("CSGMerge", FreeCaller<CSG_Merge>(), Accelerator('U', (GdkModifierType)GDK_CONTROL_MASK));
GlobalCommands_insert("CSGHollow", FreeCaller<CSG_MakeHollow>());
GlobalCommands_insert("TextureDirectoryList", FreeCaller<DoTextureListDlg>());
GlobalCommands_insert("RefreshShaders", FreeCaller<RefreshShaders>());
Grid_registerCommands();
GlobalCommands_insert("SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator('G', (GdkModifierType)GDK_CONTROL_MASK));

View file

@ -225,6 +225,8 @@ const char* AppPath_get();
extern CopiedString g_strSettingsPath;
const char* SettingsPath_get();
const char* LocalRcPath_get(void);
const char* const g_pluginsDir = "plugins/"; ///< name of plugins directory, always sub-directory of toolspath
const char* const g_modulesDir = "modules/"; ///< name of modules directory, always sub-directory of toolspath

View file

@ -116,7 +116,7 @@ struct BezierCurve
Vector3 right;
};
const std::size_t BEZIERCURVETREE_MAX_INDEX = std::numeric_limits<unsigned int>::max() / 2 + 1;
const std::size_t BEZIERCURVETREE_MAX_INDEX = std::size_t(1) << (std::numeric_limits<std::size_t>::digits - 1);
struct BezierCurveTree
{

View file

@ -130,6 +130,7 @@ public:
RadiantCoreAPI()
{
m_radiantcore.getEnginePath = &EnginePath_get;
m_radiantcore.getLocalRcPath = &LocalRcPath_get;
m_radiantcore.getAppPath = &AppPath_get;
m_radiantcore.getGameToolsPath = &GameToolsPath_get;
m_radiantcore.getSettingsPath = &SettingsPath_get;

File diff suppressed because it is too large Load diff

View file

@ -25,23 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "math/vector.h"
#include "generic/callbackfwd.h"
#include "signal/signalfwd.h"
#include "xml/xmltextags.h"
// textures menu
typedef struct _GSList GSList;
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkMenu GtkMenu;
typedef struct _GtkMenuItem GtkMenuItem;
extern GtkMenu* g_textures_menu;
extern GtkMenuItem* g_textures_menu_separator;
void TextureGroupsMenu_Construct();
void TextureGroupsMenu_Destroy();
void TextureGroupsMenu_ListItems(GSList*& items);
const char* TextureGroupsMenu_GetName(std::size_t menunum);
// texture browser
class TextureBrowser;
TextureBrowser& GlobalTextureBrowser();

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B