#include "scripting_mainmenu.h"
#include "config.h"
+#include "version.h"
#include "porting.h"
#include "filesys.h"
#include "main.h"
#include "guiMainMenu.h"
#include "sound.h"
#include "sound_openal.h"
+#include "clouds.h"
#include <IGUIStaticText.h>
#include <ICameraSceneNode.h>
#include <curl/curl.h>
#endif
+/******************************************************************************/
+/** TextDestGuiEngine */
/******************************************************************************/
TextDestGuiEngine::TextDestGuiEngine(GUIEngine* engine)
{
m_engine->getScriptIface()->handleMainMenuEvent(wide_to_narrow(text));
}
+/******************************************************************************/
+/** MenuTextureSource */
+/******************************************************************************/
+MenuTextureSource::MenuTextureSource(video::IVideoDriver *driver)
+{
+ m_driver = driver;
+}
+
+/******************************************************************************/
+MenuTextureSource::~MenuTextureSource()
+{
+ for (std::set<std::string>::iterator it = m_to_delete.begin();
+ it != m_to_delete.end(); ++it) {
+ const char *tname = (*it).c_str();
+ video::ITexture *texture = m_driver->getTexture(tname);
+ m_driver->removeTexture(texture);
+ }
+}
+
+/******************************************************************************/
+video::ITexture* MenuTextureSource::getTexture(const std::string &name, u32 *id)
+{
+ if(id)
+ *id = 0;
+ if(name.empty())
+ return NULL;
+ m_to_delete.insert(name);
+ return m_driver->getTexture(name.c_str());
+}
+
+/******************************************************************************/
+/** MenuMusicFetcher */
/******************************************************************************/
void MenuMusicFetcher::fetchSounds(const std::string &name,
std::set<std::string> &dst_paths,
dst_paths.insert(base + DIR_DELIM + name + "."+itos(i)+".ogg");
}
+/******************************************************************************/
+/** GUIEngine */
/******************************************************************************/
GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
gui::IGUIElement* parent,
m_menumanager(menumgr),
m_smgr(smgr),
m_data(data),
+ m_texture_source(NULL),
m_sound_manager(NULL),
m_formspecgui(0),
m_buttonhandler(0),
// is deleted by guiformspec!
m_buttonhandler = new TextDestGuiEngine(this);
+ //create texture source
+ m_texture_source = new MenuTextureSource(m_device->getVideoDriver());
+
//create soundmanager
MenuMusicFetcher soundfetcher;
#if USE_SOUND
//create topleft header
core::rect<s32> rect(0, 0, 500, 40);
rect += v2s32(4, 0);
- std::string t = "Minetest " VERSION_STRING;
+ std::string t = std::string("Minetest ") + minetest_version_hash;
m_irr_toplefttext =
m_device->getGUIEnvironment()->addStaticText(narrow_to_wide(t).c_str(),
-1,
m_menumanager,
0 /* &client */,
- 0 /* gamedef */);
+ 0 /* gamedef */,
+ m_texture_source);
m_menu->allowClose(false);
m_menu->lockSize(true,v2u32(800,600));
m_irr_toplefttext->setText(L"");
- //initialize texture pointers
+ //clean up texture pointers
for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) {
if (m_textures[i] != 0)
driver->removeTexture(m_textures[i]);
}
+
+ delete m_texture_source;
if (m_cloud.clouds)
m_cloud.clouds->drop();
/******************************************************************************/
void GUIEngine::setTopleftText(std::string append) {
- std::string toset = "Minetest " VERSION_STRING;
+ std::string toset = std::string("Minetest ") + minetest_version_hash;
if (append != "") {
toset += " / ";