add message when failed to load thumbs from cloud
This commit is contained in:
@@ -112,18 +112,31 @@ void App::cloud_browse()
|
||||
|
||||
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||
{
|
||||
dialog->destroy();
|
||||
std::thread([this, dialog] {
|
||||
async_start();
|
||||
auto* m = layout[main_id]->add_child<NodeMessageBox>();
|
||||
m->m_title->set_text("Downloading");
|
||||
m->m_message->set_text("Download in progress, please wait...");
|
||||
async_update();
|
||||
async_end();
|
||||
|
||||
download(dialog->selected_file);
|
||||
|
||||
async_start();
|
||||
canvas->reset_camera();
|
||||
layers->clear();
|
||||
async_end();
|
||||
|
||||
canvas->m_canvas->project_open_thread(dialog->selected_path);
|
||||
|
||||
async_start();
|
||||
doc_name = dialog->selected_name;
|
||||
title_update(doc_name, canvas->m_canvas->m_width);
|
||||
for (auto& i : canvas->m_canvas->m_order)
|
||||
layers->add_layer(canvas->m_canvas->m_layers[i].m_name.c_str());
|
||||
dialog->destroy();
|
||||
ActionManager::clear();
|
||||
m->destroy();
|
||||
async_update();
|
||||
async_end();
|
||||
}).detach();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
#include "log.h"
|
||||
#include "node.h"
|
||||
#include "layout.h"
|
||||
@@ -28,6 +29,21 @@
|
||||
#include "node_dialog_cloud.h"
|
||||
#include "node_combobox.h"
|
||||
|
||||
void Node::async_start()
|
||||
{
|
||||
App::I.async_start();
|
||||
}
|
||||
|
||||
void Node::async_update()
|
||||
{
|
||||
App::I.async_update();
|
||||
}
|
||||
|
||||
void Node::async_end()
|
||||
{
|
||||
App::I.async_end();
|
||||
}
|
||||
|
||||
void Node::watch(std::function<void(Node*)> observer)
|
||||
{
|
||||
observer(this);
|
||||
|
||||
@@ -173,6 +173,16 @@ public:
|
||||
return static_cast<T*>(found);
|
||||
return nullptr;
|
||||
}
|
||||
template<class T> T* add_child()
|
||||
{
|
||||
auto* n = new T;
|
||||
n->init();
|
||||
n->create();
|
||||
n->loaded();
|
||||
add_child(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
virtual kEventResult on_event(Event* e);
|
||||
virtual kEventResult handle_event(Event* e);
|
||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size);;
|
||||
@@ -180,6 +190,9 @@ public:
|
||||
virtual void init();
|
||||
virtual void loaded();
|
||||
const Node* init_template(const char* id);
|
||||
void async_start();
|
||||
void async_update();
|
||||
void async_end();
|
||||
void add_child(Node* n);
|
||||
void add_child(Node* n, int index);
|
||||
void add_child(std::shared_ptr<Node> n);
|
||||
|
||||
@@ -53,6 +53,22 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://omigamedev.ddns.net:8080/panoview/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");
|
||||
async_update();
|
||||
async_end();
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("CLOUD LIST: %s", res.c_str());
|
||||
|
||||
auto names = split(res, ',');
|
||||
@@ -62,6 +78,8 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
std::string url = "http://omigamedev.ddns.net:8080/panoview/cloud-info.php?file=" + n;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
auto err = curl_easy_perform(curl);
|
||||
if (err != CURLE_OK)
|
||||
break; // TODO: handle this error with a message or something
|
||||
auto info = split(res, ',', 3);
|
||||
int width = atoi(info[0].c_str());
|
||||
int height = atoi(info[1].c_str());
|
||||
|
||||
@@ -23,9 +23,20 @@ void NodeText::clone_copy(Node* dest) const
|
||||
|
||||
void NodeText::create()
|
||||
{
|
||||
char font[64];
|
||||
sprintf(font, "%s-%d", m_font.c_str(), m_font_size);
|
||||
font_id = (kFont)const_hash(font);
|
||||
if (!m_font.empty())
|
||||
{
|
||||
char font[64];
|
||||
sprintf(font, "%s-%d", m_font.c_str(), m_font_size);
|
||||
font_id = (kFont)const_hash(font);
|
||||
m_text_mesh.create();
|
||||
m_text_mesh.update(font_id, m_text.c_str());
|
||||
SetSize(m_text_mesh.bb);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeText::set_font(kFont fontID)
|
||||
{
|
||||
font_id = fontID;
|
||||
m_text_mesh.create();
|
||||
m_text_mesh.update(font_id, m_text.c_str());
|
||||
SetSize(m_text_mesh.bb);
|
||||
|
||||
@@ -17,5 +17,6 @@ public:
|
||||
virtual void restore_context() override;
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override;
|
||||
void set_text(const char* s);
|
||||
void set_font(kFont fontID);
|
||||
virtual void draw() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user