Merge branch 'illwieckz/vfs' fix !101
authorThomas Debesse <dev@illwieckz.net>
Wed, 3 Oct 2018 00:01:40 +0000 (02:01 +0200)
committerThomas Debesse <dev@illwieckz.net>
Wed, 3 Oct 2018 00:01:40 +0000 (02:01 +0200)
include/defaults.h [new file with mode: 0644]
include/ishaders.h
libs/shaderlib.h
plugins/shaders/shaders.cpp
radiant/map.cpp
radiant/qe3.cpp
radiant/texwindow.cpp
setup/data/tools/base/textures/radiant/notex.png [new file with mode: 0644]
setup/data/tools/base/textures/radiant/shadernotex.png [new file with mode: 0644]
setup/data/tools/bitmaps/notex.png [deleted file]
setup/data/tools/bitmaps/shadernotex.png [deleted file]

diff --git a/include/defaults.h b/include/defaults.h
new file mode 100644 (file)
index 0000000..96cb241
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+   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_DEFAULTS_H )
+#define INCLUDED_DEFAULTS_H
+
+#define DEFAULT_EDITORVFS_DIRNAME "base/"
+#define DEFAULT_TEXTURE_DIRNAME "textures/"
+#define DEFAULT_NOTEX_DIRNAME DEFAULT_TEXTURE_DIRNAME "radiant/"
+#define DEFAULT_NOTEX_BASENAME "notex"
+#define DEFAULT_SHADERNOTEX_BASENAME "shadernotex"
+#define DEFAULT_NOTEX_NAME DEFAULT_NOTEX_DIRNAME DEFAULT_NOTEX_BASENAME
+#define DEFAULT_SHADERNOTEX_NAME DEFAULT_NOTEX_DIRNAME DEFAULT_SHADERNOTEX_BASENAME
+
+#endif // INCLUDED_DEFAULTS_H
index f88c8ce..f588c28 100644 (file)
@@ -80,7 +80,6 @@ virtual float alphaTest() const = 0;
 
 typedef Callback<void(const ShaderLayer&)> ShaderLayerCallback;
 
-
 class IShader
 {
 public:
@@ -183,7 +182,6 @@ inline ShaderSystem& GlobalShaderSystem(){
        return GlobalShadersModule::getTable();
 }
 
-
 #define QERApp_Shader_ForName GlobalShaderSystem().getShaderForName
 #define QERApp_ActiveShaders_IteratorBegin GlobalShaderSystem().beginActiveShadersIterator
 #define QERApp_ActiveShaders_IteratorAtEnd GlobalShaderSystem().endActiveShadersIterator
index ee97243..b73d596 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined ( INCLUDED_SHADERLIB_H )
 #define INCLUDED_SHADERLIB_H
 
+#include "defaults.h"
 #include "string/string.h"
 #include "character.h"
 #include "ishaders.h"
@@ -77,8 +78,8 @@ inline bool texdef_name_valid( const char* name ){
 }
 
 inline const char* texdef_name_default(){
-       return GlobalTexturePrefix_get();
+       const char* notex = DEFAULT_NOTEX_NAME;
+       return notex;
 }
 
-
 #endif
index 99dac81..a88fe2e 100644 (file)
@@ -34,6 +34,7 @@
 // Leonardo Zide (leo@lokigames.com)
 //
 
+#include "defaults.h"
 #include "shaders.h"
 #include "globaldefs.h"
 
@@ -76,7 +77,7 @@ bool g_enableDefaultShaders = true;
 ShaderLanguage g_shaderLanguage = SHADERLANGUAGE_QUAKE3;
 bool g_useShaderList = true;
 _QERPlugImageTable *g_bitmapModule = 0;
-const char *g_texturePrefix = "textures/";
+const char *g_texturePrefix = DEFAULT_TEXTURE_DIRNAME;
 
 void ActiveShaders_IteratorBegin();
 
@@ -209,20 +210,6 @@ Image *loadHeightmap(void *environment, const char *name)
     return 0;
 }
 
-
-Image *loadSpecial(void *environment, const char *name)
-{
-    if (*name == '_') { // special image
-        StringOutputStream bitmapName(256);
-        bitmapName << GlobalRadiant().getAppPath() << "bitmaps/" << name + 1 << ".png";
-        Image *image = loadBitmap(environment, bitmapName.c_str());
-        if (image != 0) {
-            return image;
-        }
-    }
-    return GlobalTexturesCache().loadImage(name);
-}
-
 class ShaderPoolContext {
 };
 
@@ -995,9 +982,7 @@ public:
             m_notfound = m_pTexture;
 
             {
-                StringOutputStream name(256);
-                name << GlobalRadiant().getAppPath() << "bitmaps/" << (IsDefault() ? "notex.png" : "shadernotex.png");
-                m_pTexture = GlobalTexturesCache().capture(LoadImageCallback(0, loadBitmap), name.c_str());
+                m_pTexture = GlobalTexturesCache().capture(IsDefault() ? DEFAULT_NOTEX_NAME : DEFAULT_SHADERNOTEX_NAME);
             }
         }
 
index d83f42c..978d83d 100644 (file)
@@ -1001,6 +1001,12 @@ CopiedString g_strLastMapFolder = "";
 
 void Map_LoadFile(const char *filename)
 {
+    g_map.m_name = filename;
+
+    // refresh VFS to apply new pak filtering based on mapname
+    // needed for daemon DPK VFS
+    VFS_Refresh();
+
     globalOutputStream() << "Loading map from " << filename << "\n";
     ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Map");
 
@@ -1021,8 +1027,8 @@ void Map_LoadFile(const char *filename)
                 Map_Free();
             }
             Brush_toggleFormat(i);
-            g_map.m_name = filename;
             Map_UpdateTitle(g_map);
+
             g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str());
             if (format) {
                 format->wrongFormat = false;
@@ -1052,10 +1058,6 @@ void Map_LoadFile(const char *filename)
     Map_StartPosition();
 
     g_currentMap = &g_map;
-
-    // refresh VFS to apply new pak filtering based on mapname
-    // needed for daemon DPK VFS
-    VFS_Refresh();
 }
 
 class Excluder {
index 789cdf1..af0f8f9 100644 (file)
@@ -32,6 +32,7 @@
 // Leonardo Zide (leo@lokigames.com)
 //
 
+#include "defaults.h"
 #include "qe3.h"
 #include "globaldefs.h"
 
@@ -84,6 +85,11 @@ void QE_InitVFS()
     const char *userRoot = g_qeglobals.m_userEnginePath.c_str();
     const char *globalRoot = EnginePath_get();
 
+       // editor builtin VFS
+       StringOutputStream editorGamePath(256);
+       editorGamePath << GlobalRadiant().getAppPath() << DEFAULT_EDITORVFS_DIRNAME;
+       GlobalFileSystem().initDirectory(editorGamePath.c_str());
+
     // if we have a mod dir
     if (!string_equal(gamename, basegame)) {
         // ~/.<gameprefix>/<fs_game>
index d088c0d..5190370 100644 (file)
@@ -31,7 +31,8 @@
 
 #include "debugging/debugging.h"
 #include "warnings.h"
-
+#include "defaults.h"
 #include "ifilesystem.h"
 #include "iundo.h"
 #include "igl.h"
@@ -86,9 +87,6 @@
 #include "shaders.h"
 #include "commands.h"
 
-#define NOTEX_BASENAME "notex"
-#define SHADERNOTEX_BASENAME "shadernotex"
-
 bool TextureBrowser_showWads()
 {
     return !string_empty(g_pGameDescription->getKeyValue("show_wads"));
@@ -145,10 +143,10 @@ bool isMissing(const char *name)
 
 bool isNotex(const char *name)
 {
-    if (string_equal_suffix(name, "/" NOTEX_BASENAME)) {
+    if (string_equal_suffix(name, "/" DEFAULT_NOTEX_BASENAME)) {
         return true;
     }
-    if (string_equal_suffix(name, "/" SHADERNOTEX_BASENAME)) {
+    if (string_equal_suffix(name, "/" DEFAULT_SHADERNOTEX_BASENAME)) {
         return true;
     }
     return false;
@@ -2091,13 +2089,14 @@ void TextureBrowser_checkTagFile()
 
 void TextureBrowser_SetNotex()
 {
-    StringOutputStream name(256);
-    name << GlobalRadiant().getAppPath() << "bitmaps/" NOTEX_BASENAME ".png";
-    g_notex = name.c_str();
+       IShader *notex = QERApp_Shader_ForName(DEFAULT_NOTEX_NAME);
+       IShader *shadernotex = QERApp_Shader_ForName(DEFAULT_SHADERNOTEX_NAME);
+
+    g_notex = notex->getTexture()->name;
+    g_shadernotex = shadernotex->getTexture()->name;
 
-    name = StringOutputStream(256);
-    name << GlobalRadiant().getAppPath() << "bitmaps/" SHADERNOTEX_BASENAME " .png";
-    g_shadernotex = name.c_str();
+       notex->DecRef();
+       shadernotex->DecRef();
 }
 
 ui::Widget TextureBrowser_constructWindow(ui::Window toplevel)
diff --git a/setup/data/tools/base/textures/radiant/notex.png b/setup/data/tools/base/textures/radiant/notex.png
new file mode 100644 (file)
index 0000000..e09df39
Binary files /dev/null and b/setup/data/tools/base/textures/radiant/notex.png differ
diff --git a/setup/data/tools/base/textures/radiant/shadernotex.png b/setup/data/tools/base/textures/radiant/shadernotex.png
new file mode 100644 (file)
index 0000000..0eab827
Binary files /dev/null and b/setup/data/tools/base/textures/radiant/shadernotex.png differ
diff --git a/setup/data/tools/bitmaps/notex.png b/setup/data/tools/bitmaps/notex.png
deleted file mode 100644 (file)
index e09df39..0000000
Binary files a/setup/data/tools/bitmaps/notex.png and /dev/null differ
diff --git a/setup/data/tools/bitmaps/shadernotex.png b/setup/data/tools/bitmaps/shadernotex.png
deleted file mode 100644 (file)
index 0eab827..0000000
Binary files a/setup/data/tools/bitmaps/shadernotex.png and /dev/null differ