From 5e7edf766d5defd7a70a96996a351262526c2522 Mon Sep 17 00:00:00 2001 From: Maxim Kolganov Date: Sun, 24 Apr 2016 16:45:02 +0300 Subject: [PATCH] start compiling editor * fix printf-like function calls * move platform_interface.cpp to 'pc' folder * fix linking lua * fix stb int typedefs --- projects/genie.lua | 6 ++++-- src/editor/asset_browser.cpp | 8 ++++---- src/editor/editor_icon.cpp | 3 ++- src/editor/imgui/imconfig.h | 15 ++++++++++++--- src/editor/import_asset_dialog.cpp | 16 ++++++++-------- src/editor/log_ui.cpp | 4 ++-- src/editor/{ => pc}/platform_interface.cpp | 0 src/editor/profiler_ui.cpp | 10 +++++----- src/editor/property_grid.cpp | 4 ++-- src/editor/settings.cpp | 2 +- src/editor/stb/stb_image.h | 8 ++++---- src/editor/studio_app.cpp | 6 +++--- 12 files changed, 47 insertions(+), 35 deletions(-) rename src/editor/{ => pc}/platform_interface.cpp (100%) diff --git a/projects/genie.lua b/projects/genie.lua index a9e596edcf..1f84454cad 100644 --- a/projects/genie.lua +++ b/projects/genie.lua @@ -132,8 +132,10 @@ end function useLua() if _OPTIONS["static-plugins"] then linkLib("lua") - else - defines { "LUA_BUILD_AS_DLL" } + else + configuration "windows" + defines { "LUA_BUILD_AS_DLL" } + configuration {} end includedirs { "../external/lua/include" } end diff --git a/src/editor/asset_browser.cpp b/src/editor/asset_browser.cpp index 98dbf67203..8233e6bf30 100644 --- a/src/editor/asset_browser.cpp +++ b/src/editor/asset_browser.cpp @@ -302,7 +302,7 @@ bool AssetBrowser::resourceInput(const char* label, const char* str_id, char* bu m_wanted_resource = buf; } ImGui::SameLine(); - ImGui::Text(label); + ImGui::Text("%s", label); ImGui::PopItemWidth(); if (ImGui::BeginResizablePopup(popup_name, ImVec2(300, 300))) @@ -363,7 +363,7 @@ void AssetBrowser::onGUIResource() const char* path = m_selected_resource->getPath().c_str(); ImGui::Separator(); - ImGui::LabelText("Selected resource", path); + ImGui::LabelText("Selected resource", "%s", path); if (!m_history.empty() && ImGui::Button("Back")) { selectResource(m_history.back()); @@ -383,7 +383,7 @@ void AssetBrowser::onGUIResource() if (m_metadata.getString( m_selected_resource->getPath().getHash(), SOURCE_HASH, source, Lumix::lengthOf(source))) { - ImGui::LabelText("Source", source); + ImGui::LabelText("Source", "%s", source); } auto resource_type = getResourceType(path); @@ -475,4 +475,4 @@ void AssetBrowser::findResources() processDir(base_path, Lumix::stringLength(base_path)); auto* patch_device = m_editor.getEngine().getPatchFileDevice(); if (patch_device) processDir(patch_device->getBasePath(), Lumix::stringLength(patch_device->getBasePath())); -} \ No newline at end of file +} diff --git a/src/editor/editor_icon.cpp b/src/editor/editor_icon.cpp index 4170492dd3..e5b2fc34f5 100644 --- a/src/editor/editor_icon.cpp +++ b/src/editor/editor_icon.cpp @@ -227,7 +227,8 @@ struct EditorIconsImpl : public EditorIcons { for (int i = 0; i < lengthOf(ICONS); ++i) { - m_models[i] = m_render_interface->loadModel(Path(ICONS[i])); + Path path(ICONS[i]); + m_models[i] = m_render_interface->loadModel(path); } } } diff --git a/src/editor/imgui/imconfig.h b/src/editor/imgui/imconfig.h index b2ae2a1a80..9248ed08d7 100644 --- a/src/editor/imgui/imconfig.h +++ b/src/editor/imgui/imconfig.h @@ -7,16 +7,25 @@ #pragma once //---- Define assertion handler. Defaults to calling assert(). -#define IM_ASSERT(_EXPR) do { if(!(_EXPR)) __debugbreak(); } while(false) +#ifdef _WIN32 + #define IM_ASSERT(_EXPR) do { if(!(_EXPR)) __debugbreak(); } while(false) +#endif //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. #ifdef STATIC_PLUGINS #define IMGUI_API #else + #ifdef _WIN32 + #define IMGUI_LIBRARY_EXPORT __declspec(dllexport) + #define IMGUI_LIBRARY_IMPORT __declspec(dllimport) + #else + #define IMGUI_LIBRARY_EXPORT __attribute__((visibility("default"))) + #define IMGUI_LIBRARY_IMPORT + #endif #ifdef BUILDING_EDITOR - #define IMGUI_API __declspec( dllexport ) + #define IMGUI_API IMGUI_LIBRARY_EXPORT #else - #define IMGUI_API __declspec( dllimport ) + #define IMGUI_API IMGUI_LIBRARY_IMPORT #endif #endif diff --git a/src/editor/import_asset_dialog.cpp b/src/editor/import_asset_dialog.cpp index 07bd0aeaeb..d7657598bf 100644 --- a/src/editor/import_asset_dialog.cpp +++ b/src/editor/import_asset_dialog.cpp @@ -2064,7 +2064,7 @@ void ImportAssetDialog::onMaterialsGUI() { aiString material_name; mat.material->Get(AI_MATKEY_NAME, material_name); - if (ImGui::TreeNode(mat.material, material_name.C_Str())) + if (ImGui::TreeNode(mat.material, "%s", material_name.C_Str())) { ImGui::Checkbox("Import material", &mat.import); ImGui::Checkbox("Alpha cutout material", &mat.alpha_cutout); @@ -2081,7 +2081,7 @@ void ImportAssetDialog::onMaterialsGUI() ImGui::Separator(); for (int i = 0; i < mat.texture_count; ++i) { - ImGui::Text(mat.textures[i].path); + ImGui::Text("%s", mat.textures[i].path); ImGui::NextColumn(); ImGui::Checkbox(Lumix::StaticString<20>("###imp", i), &mat.textures[i].import); ImGui::NextColumn(); @@ -2096,7 +2096,7 @@ void ImportAssetDialog::onMaterialsGUI() } } ImGui::SameLine(); - ImGui::Text(mat.textures[i].src); + ImGui::Text("%s", mat.textures[i].src); } ImGui::Columns(); @@ -2151,13 +2151,13 @@ void ImportAssetDialog::onMeshesGUI() { const char* name = mesh.mesh->mName.C_Str(); if (name[0] == 0) name = getMeshName(mesh.scene, mesh.mesh).C_Str(); - ImGui::Text(name); + ImGui::Text("%s", name); ImGui::NextColumn(); auto* material = mesh.scene->mMaterials[mesh.mesh->mMaterialIndex]; aiString material_name; material->Get(AI_MATKEY_NAME, material_name); - ImGui::Text(material_name.C_Str()); + ImGui::Text("%s", material_name.C_Str()); ImGui::NextColumn(); ImGui::Checkbox(Lumix::StaticString<30>("###mesh", (Lumix::uint64)&mesh), &mesh.import); @@ -2479,7 +2479,7 @@ void ImportAssetDialog::onGUI() { char msg[1024]; getMessage(msg, sizeof(msg)); - ImGui::Text(msg); + ImGui::Text("%s", msg); if (ImGui::Button("OK")) { setMessage(""); @@ -2506,7 +2506,7 @@ void ImportAssetDialog::onGUI() { Lumix::MT::SpinLock lock(m_mutex); - ImGui::Text(m_import_message); + ImGui::Text("%s", m_import_message); if (m_progress_fraction >= 0) ImGui::ProgressBar(m_progress_fraction); } ImGui::EndDock(); @@ -2623,4 +2623,4 @@ void ImportAssetDialog::onGUI() } } ImGui::EndDock(); -} \ No newline at end of file +} diff --git a/src/editor/log_ui.cpp b/src/editor/log_ui.cpp index c05cbdf2ee..f55a58e154 100644 --- a/src/editor/log_ui.cpp +++ b/src/editor/log_ui.cpp @@ -126,7 +126,7 @@ void LogUI::showNotifications() for (int i = 0; i < m_notifications.size(); ++i) { if (i > 0) ImGui::Separator(); - ImGui::Text(m_notifications[i].message.c_str()); + ImGui::Text("%s", m_notifications[i].message.c_str()); } ImGui::End(); } @@ -197,7 +197,7 @@ void LogUI::onGUI() const char* msg = (*messages)[i].c_str(); if (filter[0] == '\0' || strstr(msg, filter) != nullptr) { - ImGui::Text(msg); + ImGui::Text("%s", msg); } } } diff --git a/src/editor/platform_interface.cpp b/src/editor/pc/platform_interface.cpp similarity index 100% rename from src/editor/platform_interface.cpp rename to src/editor/pc/platform_interface.cpp diff --git a/src/editor/profiler_ui.cpp b/src/editor/profiler_ui.cpp index f386777ac2..75b9ec9957 100644 --- a/src/editor/profiler_ui.cpp +++ b/src/editor/profiler_ui.cpp @@ -280,7 +280,7 @@ struct ProfilerUIImpl : public ProfilerUI { if (m_filter[0] == 0 || Lumix::stristr(log.path, m_filter) != 0) { - ImGui::Text(log.path); + ImGui::Text("%s", log.path); ImGui::NextColumn(); ImGui::Text("%f", log.time * 1000.0f); ImGui::NextColumn(); @@ -801,12 +801,12 @@ void ProfilerUIImpl::onGUIResources() continue; } - ImGui::Text(iter.value()->getPath().c_str()); + ImGui::Text("%s", iter.value()->getPath().c_str()); ImGui::NextColumn(); ImGui::Text("%.3fKB", iter.value()->size() / 1024.0f); sum += iter.value()->size(); ImGui::NextColumn(); - ImGui::Text(getResourceStateString(iter.value()->getState())); + ImGui::Text("%s", getResourceStateString(iter.value()->getState())); ImGui::NextColumn(); ImGui::Text("%u", iter.value()->getRefCount()); ImGui::NextColumn(); @@ -916,7 +916,7 @@ void ProfilerUIImpl::showAllocationTree(AllocationStackNode* node, int column) Lumix::copyString(fn_name, "N/A"); } - if (ImGui::TreeNode(node, fn_name)) + if (ImGui::TreeNode(node, "%s", fn_name)) { node->m_opened = true; for (auto* child : node->m_children) @@ -995,7 +995,7 @@ static void showThreadColumn(ProfilerUIImpl& profiler, Column column) } else { - if (ImGui::TreeNode(root, thread_name)) + if (ImGui::TreeNode(root, "%s", thread_name)) { profiler.m_threads[i].opened = true; profiler.showProfileBlock(root, column); diff --git a/src/editor/property_grid.cpp b/src/editor/property_grid.cpp index c35b447559..5f24464bd5 100644 --- a/src/editor/property_grid.cpp +++ b/src/editor/property_grid.cpp @@ -460,7 +460,7 @@ bool PropertyGrid::entityInput(const char* label, const char* str_id, Lumix::Ent item_w - ImGui::CalcTextSize("...").x - style.FramePadding.x * 2 - style.ItemSpacing.x); char buf[50]; getEntityListDisplayName(m_editor, buf, sizeof(buf), entity); - ImGui::LabelText("", buf); + ImGui::LabelText("", "%s", buf); ImGui::SameLine(); Lumix::StaticString<30> popup_name("pu", str_id); if (ImGui::Button(Lumix::StaticString<30>("...###br", str_id))) @@ -469,7 +469,7 @@ bool PropertyGrid::entityInput(const char* label, const char* str_id, Lumix::Ent } ImGui::SameLine(); - ImGui::Text(label); + ImGui::Text("%s", label); ImGui::PopItemWidth(); if (ImGui::BeginPopup(popup_name)) diff --git a/src/editor/settings.cpp b/src/editor/settings.cpp index 4b968e2de6..61a389272e 100644 --- a/src/editor/settings.cpp +++ b/src/editor/settings.cpp @@ -313,7 +313,7 @@ void Settings::showShortcutSettings(Action** actions, int actions_count) Action& a = *actions[i]; if (m_filter[0] == 0 || Lumix::stristr(a.label, m_filter) != 0) { - ImGui::Text(a.label); + ImGui::Text("%s", a.label); ImGui::NextColumn(); shortcutInput(a.shortcut[0]); ImGui::NextColumn(); diff --git a/src/editor/stb/stb_image.h b/src/editor/stb/stb_image.h index 224d8a2748..5f221f2d63 100644 --- a/src/editor/stb/stb_image.h +++ b/src/editor/stb/stb_image.h @@ -594,10 +594,10 @@ typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include -typedef uint16 stbi__uint16; -typedef int16 stbi__int16; -typedef uint32 stbi__uint32; -typedef int32 stbi__int32; +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong diff --git a/src/editor/studio_app.cpp b/src/editor/studio_app.cpp index 594f7fc390..4013d647b0 100644 --- a/src/editor/studio_app.cpp +++ b/src/editor/studio_app.cpp @@ -735,7 +735,7 @@ class StudioAppImpl : public StudioApp if (!PlatformInterface::isWindowActive()) stats << " - inactive window"; auto stats_size = ImGui::CalcTextSize(stats); ImGui::SameLine(ImGui::GetContentRegionMax().x - stats_size.x); - ImGui::Text(stats); + ImGui::Text("%s", (const char*)stats); if (m_log_ui->getUnreadErrorCount() == 1) { @@ -750,7 +750,7 @@ class StudioAppImpl : public StudioApp ImGui::SameLine(ImGui::GetContentRegionMax().x - stats_size.x); auto error_stats_size = ImGui::CalcTextSize(error_stats); ImGui::SameLine(ImGui::GetContentRegionMax().x - stats_size.x - error_stats_size.x); - ImGui::TextColored(ImVec4(1, 0, 0, 1), error_stats); + ImGui::TextColored(ImVec4(1, 0, 0, 1), "%s", (const char*)error_stats); } ImGui::EndMainMenuBar(); @@ -1730,4 +1730,4 @@ void StudioApp::StaticPluginRegister::create(const char* name, StudioApp& app) } i = i->next; } -} \ No newline at end of file +}