From 4ccaa6d0af852d0aada01f341a61290a3760cffa Mon Sep 17 00:00:00 2001 From: sapier Date: Wed, 11 Dec 2013 23:07:38 +0100 Subject: Implement search tab and version picker --- src/convert_json.cpp | 2 +- src/guiEngine.cpp | 2 +- src/guiFormSpecMenu.cpp | 17 ++++++++++------- src/script/lua_api/l_mainmenu.cpp | 25 ++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/convert_json.cpp b/src/convert_json.cpp index e8eede0b1..0b69f43a3 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -210,7 +210,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } if (retval.versions.size() < 1) { - errorstream << "readModStoreModDetails: not a single version specified!" << std::endl; + infostream << "readModStoreModDetails: not a single version specified!" << std::endl; retval.valid = false; } diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index 7acc00ef1..d008b2568 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -156,7 +156,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev, m_sound_manager = &dummySoundManager; //create topleft header - core::rect rect(0, 0, 500, 40); + core::rect rect(0, 0, 500, 20); rect += v2s32(4, 0); std::string t = std::string("Minetest ") + minetest_version_hash; diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 82def7411..87a46d9c9 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -1856,7 +1856,7 @@ void GUIFormSpecMenu::drawMenu() v2u32 screenSize = driver->getScreenSize(); core::rect allbg(0, 0, screenSize.X , screenSize.Y); - if (m_bgfullscreen) + if (m_bgfullscreen) driver->draw2DRectangle(m_bgcolor, allbg, &allbg); else driver->draw2DRectangle(m_bgcolor, AbsoluteRect, &AbsoluteClippingRect); @@ -1959,7 +1959,7 @@ void GUIFormSpecMenu::drawMenu() IItemDefManager *idef = m_gamedef->idef(); ItemStack item; item.deSerialize(spec.name, idef); - video::ITexture *texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_gamedef); + video::ITexture *texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_gamedef); // Image size on screen core::rect imgrect(0, 0, spec.geom.X, spec.geom.Y); // Image rectangle on screen @@ -1998,7 +1998,7 @@ void GUIFormSpecMenu::drawMenu() if (spec.tooltip != "") { core::rect rect = spec.rect; - if (rect.isPointInside(m_pointer)) + if (rect.isPointInside(m_pointer)) { m_tooltip_element->setVisible(true); this->bringToFront(m_tooltip_element); @@ -2168,7 +2168,7 @@ void GUIFormSpecMenu::acceptInput(bool quit=false) for(u32 i=0; igetType() == gui::EGUIET_COMBO_BOX)) { e = static_cast(element); } - fields[wide_to_narrow(s.fname.c_str())] = - wide_to_narrow(e->getItem(e->getSelected())); + s32 selected = e->getSelected(); + if (selected >= 0) { + fields[wide_to_narrow(s.fname.c_str())] = + wide_to_narrow(e->getItem(selected)); + } } else if (s.ftype == f_TabHeader) { // no dynamic cast possible due to some distributions shipped @@ -2662,7 +2665,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) for(u32 i=0; igetID())) diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 42ddd0b14..ba8a09747 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -336,6 +336,26 @@ int ModApiMainMenu::l_get_modstore_details(lua_State *L) lua_pushstring(L,current_mod.versions[0].file.c_str()); lua_settable(L, top); + lua_pushstring(L,"versions"); + lua_newtable(L); + int versionstop = lua_gettop(L); + for (unsigned int i=0;i < current_mod.versions.size(); i++) { + lua_pushnumber(L,i+1); + lua_newtable(L); + int current_element = lua_gettop(L); + + lua_pushstring(L,"date"); + lua_pushstring(L,current_mod.versions[i].date.c_str()); + lua_settable(L,current_element); + + lua_pushstring(L,"download_url"); + lua_pushstring(L,current_mod.versions[i].file.c_str()); + lua_settable(L,current_element); + + lua_settable(L,versionstop); + } + lua_settable(L, top); + lua_pushstring(L,"screenshot_url"); lua_pushstring(L,current_mod.titlepic.file.c_str()); lua_settable(L, top); @@ -782,7 +802,10 @@ int ModApiMainMenu::l_extract_zip(lua_State *L) io::IFileSystem* fs = engine->m_device->getFileSystem(); - fs->addFileArchive(zipfile,true,false,io::EFAT_ZIP); + if (!fs->addFileArchive(zipfile,true,false,io::EFAT_ZIP)) { + lua_pushboolean(L,false); + return 1; + } assert(fs->getFileArchiveCount() > 0); -- cgit v1.2.3