#include "sound.h"
#include "sound_openal.h"
#include "clouds.h"
+#include "httpfetch.h"
#include <IGUIStaticText.h>
#include <ICameraSceneNode.h>
m_sound_manager = &dummySoundManager;
//create topleft header
- core::rect<s32> rect(0, 0, 500, 40);
+ core::rect<s32> rect(0, 0, 500, 20);
rect += v2s32(4, 0);
std::string t = std::string("Minetest ") + minetest_version_hash;
rect,false,true,0,-1);
//create formspecsource
- m_formspecgui = new FormspecFormSource("",&m_formspecgui);
+ m_formspecgui = new FormspecFormSource("");
/* Create menu */
m_menu =
m_menumanager,
0 /* &client */,
0 /* gamedef */,
- m_texture_source);
+ m_texture_source,
+ m_formspecgui,
+ m_buttonhandler,
+ NULL);
m_menu->allowClose(false);
m_menu->lockSize(true,v2u32(800,600));
- m_menu->setFormSource(m_formspecgui);
- m_menu->setTextDest(m_buttonhandler);
// Initialize scripting
- infostream<<"GUIEngine: Initializing Lua"<<std::endl;
+ infostream << "GUIEngine: Initializing Lua" << std::endl;
m_script = new MainMenuScripting(this);
try {
- if (m_data->errormessage != "")
- {
+ if (m_data->errormessage != "") {
m_script->setMainMenuErrorMessage(m_data->errormessage);
m_data->errormessage = "";
}
- if (!loadMainMenuScript())
- assert("no future without mainmenu" == 0);
+ if (!loadMainMenuScript()) {
+ errorstream << "No future without mainmenu" << std::endl;
+ abort();
+ }
run();
}
}
else {
infostream
- << "GUIEngine: execution of custom menu failed!"
+ << "GUIEngine: execution of custom menu: \""
+ << menuscript << "\" failed!"
<< std::endl
<< "\tfalling back to builtin menu"
<< std::endl;
cloudPostProcess();
else
sleep_ms(25);
+
+ m_script->step();
}
}
}
/******************************************************************************/
-#if USE_CURL
-static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
-{
- FILE* targetfile = (FILE*) userp;
- fwrite(contents,size,nmemb,targetfile);
- return size * nmemb;
-}
-#endif
bool GUIEngine::downloadFile(std::string url,std::string target) {
#if USE_CURL
- //download file via curl
- CURL *curl;
+ std::ofstream targetfile(target.c_str(), std::ios::out | std::ios::binary);
- curl = curl_easy_init();
+ if (!targetfile.good()) {
+ return false;
+ }
- if (curl)
- {
- CURLcode res;
- bool retval = true;
-
- FILE* targetfile = fopen(target.c_str(),"wb");
-
- if (targetfile) {
- curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
- curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, targetfile);
- curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
- res = curl_easy_perform(curl);
- if (res != CURLE_OK) {
- errorstream << "File at url \"" << url
- <<"\" not found (" << curl_easy_strerror(res) << ")" <<std::endl;
- retval = false;
- }
- fclose(targetfile);
- }
- else {
- retval = false;
- }
+ HTTPFetchRequest fetchrequest;
+ HTTPFetchResult fetchresult;
+ fetchrequest.url = url;
+ fetchrequest.caller = HTTPFETCH_SYNC;
+ httpfetch_sync(fetchrequest, fetchresult);
- curl_easy_cleanup(curl);
- return retval;
+ if (fetchresult.succeeded) {
+ targetfile << fetchresult.data;
+ } else {
+ return false;
}
-#endif
+
+ return true;
+#else
return false;
+#endif
}
/******************************************************************************/
{
m_sound_manager->stopSound(handle);
}
+
+/******************************************************************************/
+unsigned int GUIEngine::queueAsync(std::string serialized_func,
+ std::string serialized_params) {
+ return m_script->queueAsync(serialized_func, serialized_params);
+}
+