aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-08-02 15:18:48 +0200
committerPilzAdam <pilzadam@minetest.net>2013-08-04 16:52:30 +0200
commit383153419bef744af4bfa5f5d54c4bee663a5ce6 (patch)
tree6630c6c9075246991d2575b1631205097e2591c5 /src
parentfe1fe1b1e42d24dc87a75ef8cc27c5c1dd1cfa4d (diff)
downloadminetest-383153419bef744af4bfa5f5d54c4bee663a5ce6.tar.gz
minetest-383153419bef744af4bfa5f5d54c4bee663a5ce6.tar.bz2
minetest-383153419bef744af4bfa5f5d54c4bee663a5ce6.zip
Add texture pack selection to main menu
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp1
-rw-r--r--src/guiLuaApi.cpp10
-rw-r--r--src/guiLuaApi.h2
-rw-r--r--src/server.cpp3
-rw-r--r--src/tile.cpp17
-rw-r--r--src/tile.h2
-rw-r--r--src/util/container.h5
7 files changed, 26 insertions, 14 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 205c34515..cb2a50823 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3482,6 +3482,7 @@ void the_game(
infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str()
<< std::endl;
}
+ clearTextureNameCache();
infostream << "\tRemaining materials: "
<< driver-> getMaterialRendererCount ()
<< " (note: irrlicht doesn't support removing renderers)"<< std::endl;
diff --git a/src/guiLuaApi.cpp b/src/guiLuaApi.cpp
index 485cab883..5d3e9dc12 100644
--- a/src/guiLuaApi.cpp
+++ b/src/guiLuaApi.cpp
@@ -82,6 +82,7 @@ void guiLuaApi::initialize(lua_State* L,GUIEngine* engine)
retval &= API_FCT(set_topleft_text);
retval &= API_FCT(get_modpath);
retval &= API_FCT(get_gamepath);
+ retval &= API_FCT(get_texturepath);
retval &= API_FCT(get_dirlist);
retval &= API_FCT(create_dir);
retval &= API_FCT(delete_dir);
@@ -830,6 +831,15 @@ int guiLuaApi::l_get_gamepath(lua_State *L)
}
/******************************************************************************/
+int guiLuaApi::l_get_texturepath(lua_State *L)
+{
+ std::string gamepath
+ = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "textures");
+ lua_pushstring(L, gamepath.c_str());
+ return 1;
+}
+
+/******************************************************************************/
int guiLuaApi::l_get_dirlist(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
bool dironly = lua_toboolean(L, 2);
diff --git a/src/guiLuaApi.h b/src/guiLuaApi.h
index 11b94ba75..9555f00c5 100644
--- a/src/guiLuaApi.h
+++ b/src/guiLuaApi.h
@@ -164,6 +164,8 @@ private:
static int l_get_modpath(lua_State *L);
static int l_get_gamepath(lua_State *L);
+
+ static int l_get_texturepath(lua_State *L);
static int l_get_dirlist(lua_State *L);
diff --git a/src/server.cpp b/src/server.cpp
index 4099d9997..f5f6645a2 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4273,8 +4273,7 @@ void Server::fillMediaCache()
paths.push_back(mod.path + DIR_DELIM + "media");
paths.push_back(mod.path + DIR_DELIM + "models");
}
- std::string path_all = "textures";
- paths.push_back(path_all + DIR_DELIM + "all");
+ paths.push_back(porting::path_user + DIR_DELIM + "textures" + DIR_DELIM + "server");
// Collect media file information from paths into cache
for(std::list<std::string>::iterator i = paths.begin();
diff --git a/src/tile.cpp b/src/tile.cpp
index 6e4fde011..726f7f602 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -131,18 +131,6 @@ std::string getTexturePath(const std::string &filename)
// Check all filename extensions. Returns "" if not found.
fullpath = getImagePath(testpath);
}
-
- /*
- Check from $user/textures/all
- */
- if(fullpath == "")
- {
- std::string texture_path = porting::path_user + DIR_DELIM
- + "textures" + DIR_DELIM + "all";
- std::string testpath = texture_path + DIR_DELIM + filename;
- // Check all filename extensions. Returns "" if not found.
- fullpath = getImagePath(testpath);
- }
/*
Check from default data directory
@@ -163,6 +151,11 @@ std::string getTexturePath(const std::string &filename)
return fullpath;
}
+void clearTextureNameCache()
+{
+ g_texturename_to_path_cache.clear();
+}
+
/*
Stores internal information about a texture.
*/
diff --git a/src/tile.h b/src/tile.h
index 8008d2127..23c214350 100644
--- a/src/tile.h
+++ b/src/tile.h
@@ -57,6 +57,8 @@ std::string getImagePath(std::string path);
*/
std::string getTexturePath(const std::string &filename);
+void clearTextureNameCache();
+
/*
ITextureSource::generateTextureFromMesh parameters
*/
diff --git a/src/util/container.h b/src/util/container.h
index 9bb388f0e..84616d2db 100644
--- a/src/util/container.h
+++ b/src/util/container.h
@@ -118,6 +118,11 @@ public:
}
return result;
}
+
+ void clear ()
+ {
+ m_values.clear();
+ }
private:
std::map<Key, Value> m_values;