From b8c646f748419f6896de0a68a373537ab048b4f9 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 19 Sep 2019 15:25:33 +0200 Subject: [PATCH] fix iOS text input and export ppbr --- PanoPainter/GameViewController.m | 9 ++++++--- src/app_dialogs.cpp | 21 +++++++++++---------- src/node_dialog_export_ppbr.cpp | 9 +++++---- src/node_dialog_export_ppbr.h | 2 +- src/node_panel_brush.cpp | 6 +++--- src/node_panel_brush.h | 2 +- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/PanoPainter/GameViewController.m b/PanoPainter/GameViewController.m index 0efca1a..517eaff 100644 --- a/PanoPainter/GameViewController.m +++ b/PanoPainter/GameViewController.m @@ -211,11 +211,14 @@ std::recursive_mutex lock_mutex; - (void)insertText:(NSString *)text { - if (const char* cstr = [text cStringUsingEncoding:NSASCIIStringEncoding]) + if (const char* cstr = [text cStringUsingEncoding:NSISOLatin1StringEncoding]) + { + char c = cstr[0]; App::I->ui_task_async([=] { - App::I->key_char(cstr[0]); + App::I->key_char(c); }); + } NSLog(@"%@", text); // Do something with the typed character } @@ -491,7 +494,7 @@ std::set ignored_touch; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; view.enableSetNeedsDisplay = NO; glview = view; - + App::I->width = view.frame.size.width * view.contentScaleFactor; App::I->height = view.frame.size.height * view.contentScaleFactor; App::I->zoom = Settings::value_or("ui-scale", (float)view.contentScaleFactor); diff --git a/src/app_dialogs.cpp b/src/app_dialogs.cpp index f293a0c..f6db21e 100644 --- a/src/app_dialogs.cpp +++ b/src/app_dialogs.cpp @@ -602,19 +602,20 @@ void App::dialog_ppbr_export() auto root = layout[main_id]; auto dialog = root->add_child_ref(); dialog->btn_ok->on_click = [this, dialog] (Node*) { + NodePanelBrushPreset::PPBRInfo info; + info.author = dialog->txt_author->m_text; + info.url = dialog->txt_url->m_text; + info.email = dialog->txt_email->m_text; + info.descr = dialog->txt_descr->m_text; + info.header_image = dialog->m_header_image; #if __IOS__ - App::I->pick_file_save("ppbr", [this, dialog] (std::string path) { - presets->export_ppbr(path, dialog->m_header_image); + App::I->pick_file_save("ppbr", [this, dialog, info] (std::string path) { + presets->export_ppbr(path, info); }); #else - App::I->pick_file_save({ "ppbr" }, [this, dialog] (std::string path) { - std::thread([this, path, dialog] { + App::I->pick_file_save({ "ppbr" }, [this, dialog, info] (std::string path) { + std::thread([this, path, dialog, info] { BT_SetTerminate(); - NodePanelBrushPreset::PPBRInfo info; - info.author = dialog->txt_author->m_text; - info.url = dialog->txt_url->m_text; - info.email = dialog->txt_email->m_text; - info.descr = dialog->txt_descr->m_text; presets->export_ppbr(path, info); dialog->destroy(); App::I->message_box("Export PPBR", "Brushes exported to:\n" + path); @@ -622,4 +623,4 @@ void App::dialog_ppbr_export() }); #endif }; -} \ No newline at end of file +} diff --git a/src/node_dialog_export_ppbr.cpp b/src/node_dialog_export_ppbr.cpp index 4771fa8..be2bd56 100644 --- a/src/node_dialog_export_ppbr.cpp +++ b/src/node_dialog_export_ppbr.cpp @@ -38,7 +38,7 @@ void NodeDialogExportPPBR::init_controls() }; btn_header_clear = find("header-clear"); btn_header_clear->on_click = [this] (Node*) { - m_header_image.destroy(); + m_header_image.reset(); img_header->tex.destroy(); txt_header_descr->SetVisibility(true); }; @@ -57,9 +57,10 @@ void NodeDialogExportPPBR::init_controls() void NodeDialogExportPPBR::open_header() { App::I->pick_image([this](std::string path) { - m_header_image.load(path); - m_header_image.resize(256, 128); - img_header->tex.create(m_header_image); + m_header_image = std::make_shared(); + m_header_image->load(path); + m_header_image->resize(256, 128); + img_header->tex.create(*m_header_image); txt_header_descr->SetVisibility(false); }); } diff --git a/src/node_dialog_export_ppbr.h b/src/node_dialog_export_ppbr.h index 11b2f11..137e9eb 100644 --- a/src/node_dialog_export_ppbr.h +++ b/src/node_dialog_export_ppbr.h @@ -14,7 +14,7 @@ public: NodeButton* btn_header_clear; NodeButton* btn_header_gen; NodeImageTexture* img_header; - Image m_header_image; + std::shared_ptr m_header_image; NodeText* txt_header_descr; NodeText* txt_author; NodeText* txt_descr; diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index d94ea2c..8f6250b 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -724,7 +724,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& info.class_id = "ppbr_info"; info.name = L"info header"; - bool has_header_image = info_data.header_image.m_data != nullptr; + bool has_header_image = info_data.header_image != nullptr; info.props["author"] = std::make_shared(info_data.author); info.props["email"] = std::make_shared(info_data.email); @@ -743,8 +743,8 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& // header image if (has_header_image) { - sw << info_data.header_image; - info_data.header_image.save_jpg(out_path + "/header.jpg", 75); + sw << *info_data.header_image; + info_data.header_image->save_jpg(out_path + "/header.jpg", 75); } pb->increment(); diff --git a/src/node_panel_brush.h b/src/node_panel_brush.h index 11aca4f..0712107 100644 --- a/src/node_panel_brush.h +++ b/src/node_panel_brush.h @@ -94,7 +94,7 @@ public: std::string email; std::string url; std::string descr; - Image header_image; + std::shared_ptr header_image; }; Node* m_container;