mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Change mainmenu texture handling + small misc changes
Texture names must now be escaped in formspec elements image[], background[], image_button[], image_button_exit[]. Instead of special-case handling of texture loading (and unloading which was missing) in guiFormSpecMenu.cpp, use the newly created ISimpleTextureSource interface which is a minimal subset of ITextureSource. There is an implementation of this interface used by GUIEngine (MenuTextureSource). Fix an off-by-one bug in unescape_string; it caused requests for a texture called "\0".
This commit is contained in:
parent
da9fe64851
commit
3c4734d69a
11 changed files with 150 additions and 90 deletions
46
src/tile.h
46
src/tile.h
|
@ -82,22 +82,27 @@ struct TextureFromMeshParams
|
|||
TextureSource creates and caches textures.
|
||||
*/
|
||||
|
||||
class ITextureSource
|
||||
class ISimpleTextureSource
|
||||
{
|
||||
public:
|
||||
ISimpleTextureSource(){}
|
||||
virtual ~ISimpleTextureSource(){}
|
||||
virtual video::ITexture* getTexture(
|
||||
const std::string &name, u32 *id = NULL) = 0;
|
||||
};
|
||||
|
||||
class ITextureSource : public ISimpleTextureSource
|
||||
{
|
||||
public:
|
||||
ITextureSource(){}
|
||||
virtual ~ITextureSource(){}
|
||||
virtual u32 getTextureId(const std::string &name){return 0;}
|
||||
virtual u32 getTextureIdDirect(const std::string &name){return 0;}
|
||||
virtual std::string getTextureName(u32 id){return "";}
|
||||
virtual video::ITexture* getTexture(u32 id){return NULL;}
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
virtual u32 getTextureIdDirect(const std::string &name)=0;
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(
|
||||
const std::string &name, u32 *id = NULL){
|
||||
if(id) *id = 0;
|
||||
return NULL;
|
||||
}
|
||||
virtual IrrlichtDevice* getDevice()
|
||||
{return NULL;}
|
||||
const std::string &name, u32 *id = NULL)=0;
|
||||
virtual IrrlichtDevice* getDevice()=0;
|
||||
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||
virtual video::ITexture* generateTextureFromMesh(
|
||||
const TextureFromMeshParams ¶ms)=0;
|
||||
|
@ -108,23 +113,20 @@ class IWritableTextureSource : public ITextureSource
|
|||
public:
|
||||
IWritableTextureSource(){}
|
||||
virtual ~IWritableTextureSource(){}
|
||||
virtual u32 getTextureId(const std::string &name){return 0;}
|
||||
virtual u32 getTextureIdDirect(const std::string &name){return 0;}
|
||||
virtual std::string getTextureName(u32 id){return "";}
|
||||
virtual video::ITexture* getTexture(u32 id){return NULL;}
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
virtual u32 getTextureIdDirect(const std::string &name)=0;
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(
|
||||
const std::string &name, u32 *id = NULL){
|
||||
if(id) *id = 0;
|
||||
return NULL;
|
||||
}
|
||||
virtual IrrlichtDevice* getDevice(){return NULL;}
|
||||
const std::string &name, u32 *id = NULL)=0;
|
||||
virtual IrrlichtDevice* getDevice()=0;
|
||||
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||
virtual video::ITexture* generateTextureFromMesh(
|
||||
const TextureFromMeshParams ¶ms)=0;
|
||||
|
||||
virtual void processQueue()=0;
|
||||
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
|
||||
virtual void rebuildImagesAndTextures()=0;
|
||||
virtual video::ITexture* generateTextureFromMesh(
|
||||
const TextureFromMeshParams ¶ms)=0;
|
||||
};
|
||||
|
||||
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue