Skip to content

Commit 9dc4883

Browse files
committedApr 10, 2022
add dragndrop instruction window
1 parent 73227cb commit 9dc4883

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
 

‎src/App.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ void App::renderImGui() {
276276
renderImGuiTabBar();
277277
renderImGuiLeftPanel();
278278
renderImGuiDepthSelector();
279+
renderImGuiInstructions();
279280
ImGui::Render();
280281

281282
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
@@ -519,9 +520,10 @@ void App::renderImGuiDepthSelector() {
519520
auto& world = *active_project.rendered_world;
520521
if (world.levels.size() > 1) {
521522
auto line_height = ImGui::GetTextLineHeightWithSpacing();
523+
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {10.f, 10.f});
524+
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.f);
522525
ImGui::SetNextWindowSize({45, 20.f + static_cast<float>(world.levels.size()) * line_height});
523526
ImGui::SetNextWindowPos({PANEL_WIDTH + 15, BAR_HEIGHT + 15});
524-
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {10.f, 10.f});
525527
ImGui::Begin("DepthSelector", nullptr, imgui_window_flags);
526528

527529
for (auto it = world.levels.rbegin(); it != world.levels.rend(); it++) {
@@ -539,6 +541,28 @@ void App::renderImGuiDepthSelector() {
539541
}
540542
ImGui::End();
541543
ImGui::PopStyleVar();
544+
ImGui::PopStyleVar();
542545
}
543546
}
544547
}
548+
549+
void App::renderImGuiInstructions() {
550+
if (!projectOpened()) {
551+
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.f);
552+
ImGui::SetNextWindowSize({400, 200});
553+
ImGui::SetNextWindowPos({PANEL_WIDTH + (static_cast<float>(m_window.getSize().x) - PANEL_WIDTH - 400) / 2,
554+
BAR_HEIGHT + (static_cast<float>(m_window.getSize().y) - BAR_HEIGHT - 200) / 2});
555+
ImGui::Begin("Instructions", nullptr, imgui_window_flags);
556+
#if defined(EMSCRIPTEN)
557+
ImGui::Pad(0, 80);
558+
ImGui::TextCentered("Drag and drop your LDtk projects");
559+
ImGui::TextCentered("and all the needed assets here");
560+
ImGui::TextCentered("(you can drop an entire folder)");
561+
#else
562+
ImGui::Pad(0, 90);
563+
ImGui::TextCentered("Drag and drop your LDtk projects here");
564+
#endif
565+
ImGui::End();
566+
ImGui::PopStyleVar();
567+
}
568+
}

‎src/App.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class App {
4040
void renderImGuiLeftPanel();
4141
void renderImGuiLeftPanel_FieldValues(const ldtk::FieldDef& field, const std::vector<std::string>& values);
4242
void renderImGuiDepthSelector();
43+
void renderImGuiInstructions();
4344
static constexpr auto imgui_window_flags = ImGuiWindowFlags_NoMove
4445
| ImGuiWindowFlags_NoResize
4546
| ImGuiWindowFlags_NoDecoration;

0 commit comments

Comments
 (0)