add download progress, improbable cloud browser, lock touch when pencil is down on iOS

This commit is contained in:
2018-01-04 00:02:28 +00:00
parent 01370642a1
commit 5feb3acb1d
10 changed files with 120 additions and 37 deletions

View File

@@ -43,40 +43,90 @@ void NodeDialogCloud::loaded()
{
}
void NodeDialogCloud::removed(Node* parent)
{
closed = true;
}
void NodeDialogCloud::load_thumbs_thread()
{
CURL *curl = curl_easy_init();
std::string res;
if (curl)
{
async_start();
auto* align = container->add_child<Node>();
align->SetWidthP(100.f);
align->SetHeightP(100.f);
align->SetAlign(YGAlignCenter);
align->SetJustify(YGJustifyCenter);
auto* text = align->add_child<NodeText>();
text->set_font(kFont::Arial_30);
text->set_text("Connecting to the server...");
async_update();
async_end();
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
curl_easy_setopt(curl, CURLOPT_URL, "http://omigamedev.com/panopainter/cloud/cloud-list.php");
auto err = curl_easy_perform(curl);
if (err != CURLE_OK)
{
async_start();
auto* align = container->add_child<Node>();
align->SetWidthP(100.f);
align->SetHeightP(100.f);
align->SetAlign(YGAlignCenter);
align->SetJustify(YGJustifyCenter);
auto* t = align->add_child<NodeText>();
t->set_font(kFont::Arial_30);
t->set_text("Could not connect to the server");
text->set_text("Could not connect to the server");
async_update();
async_end();
return;
}
async_start();
align->destroy();
async_end();
LOG("CLOUD LIST: %s", res.c_str());
auto names = split(res, ',');
std::vector<NodeDialogCloudItem*> nodes;
// create slots with name
App::I.async_start();
for (const auto& n : names)
{
auto node = new NodeDialogCloudItem;
node->m_manager = m_manager;
node->init();
node->m_text->set_text(n.c_str());
node->m_path = data_path + "/" + n;
node->m_file_name = n;
container->add_child(node);
node->on_selected = [&](NodeDialogCloudItem* target) {
if (target == current)
return;
selected_path = target->m_path;
selected_file = target->m_file_name;
selected_name = selected_file.substr(0, selected_file.length() - 5);
if (current)
current->m_selected = false;
current = target;
};
nodes.push_back(node);
}
App::I.async_update();
App::I.async_end();
// load the icons
for (int i = 0; i < names.size(); i++)
{
const auto& n = names[i];
auto* node = nodes[i];
if (closed)
break;
res.clear();
std::string url = "http://omigamedev.com/panopainter/cloud/cloud-info.php?file=" + n;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
LOG("%s", url.c_str());
auto err = curl_easy_perform(curl);
if (err != CURLE_OK)
break; // TODO: handle this error with a message or something
@@ -93,29 +143,11 @@ void NodeDialogCloud::load_thumbs_thread()
thumb.copy_from((uint8_t*)rgb.data());
App::I.async_start();
auto node = new NodeDialogCloudItem;
node->m_manager = m_manager;
node->init();
node->m_text->set_text(n.c_str());
node->m_path = data_path + "/" + n;
node->m_file_name = n;
auto image_tex = node->find<NodeImageTexture>("thumb-tex");
image_tex->tex.destroy();
image_tex->tex.create(thumb);
container->add_child(node);
App::I.async_update();
App::I.async_end();
node->on_selected = [&](NodeDialogCloudItem* target) {
if (target == current)
return;
selected_path = target->m_path;
selected_file = target->m_file_name;
selected_name = selected_file.substr(0, selected_file.length() - 5);
if (current)
current->m_selected = false;
current = target;
};
}
curl_easy_cleanup(curl);
}