| | @@ -335,12 +335,7 @@ |
| 335 | 335 | |
| 336 | 336 | info.save = [&]() { |
| 337 | 337 | if (info.shaderId == 0) { |
| 338 | | - gui::LogEntry entry; |
| 339 | | - entry.type = gui::LogType::Warning; |
| 340 | | - std::cout << entry.text << std::endl; |
| 341 | | - entry.text = "TODO: 保存ダイアログボックス関数は開発中・・・"; |
| 342 | | - info.cmd->Add(entry); |
| 343 | | - std::cout << entry.text << std::endl; |
| 338 | + info.showSaveAsShaderPopup = true; |
| 344 | 339 | return; |
| 345 | 340 | } |
| 346 | 341 | |
| | @@ -391,6 +386,64 @@ |
| 391 | 386 | } |
| 392 | 387 | }; |
| 393 | 388 | |
| 389 | + info.open = [&]() { |
| 390 | + static i32 selectedId = -1; |
| 391 | + ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 392 | + if (ImGui::BeginPopupModal(info.i18n->GetWord("fileopenshader").c_str(), nullptr)) { |
| 393 | + vector <db::ShaderData > shdrs = db::GetAllShaders(db); |
| 394 | + ImGui::BeginChild("ShaderList", ImVec2(0, 300), true); |
| 395 | + |
| 396 | + for (const auto &s : shdrs) { |
| 397 | + bool sel = (selectedId == s.id); |
| 398 | + |
| 399 | + if (ImGui::Selectable(s.name.c_str(), sel)) { |
| 400 | + selectedId = s.id; |
| 401 | + } |
| 402 | + } |
| 403 | + |
| 404 | + ImGui::EndChild(); |
| 405 | + ImGui::Separator(); |
| 406 | + |
| 407 | + if (ImGui::Button(info.i18n->GetWord("cancel").c_str())) { |
| 408 | + ImGui::CloseCurrentPopup(); |
| 409 | + } |
| 410 | + |
| 411 | + ImGui::SameLine(); |
| 412 | + |
| 413 | + if (ImGui::Button(info.i18n->GetWord("fileopen").c_str())) { |
| 414 | + if (selectedId != -1) { |
| 415 | + db::ShaderData shaderData = db::GetShader(db, selectedId); |
| 416 | + info.shaderId = shaderData.id; |
| 417 | + info.shaderName = shaderData.name; |
| 418 | + info.VERT = shaderData.vertexShader; |
| 419 | + info.FRAG = shaderData.fragmentShader; |
| 420 | + info.LUA = shaderData.luaCode; |
| 421 | + |
| 422 | + vertEditor.SetCode(info.VERT.code); |
| 423 | + fragEditor.SetCode(info.FRAG.code); |
| 424 | + luaEditor.SetCode(info.LUA.code); |
| 425 | + |
| 426 | + vertEditor.SetCode(info.VERT.code); |
| 427 | + string nTit = info.shaderName + "(" + info.i18n->GetWord("editorvertshader") + ")"; |
| 428 | + vertEditor.SetTitle(nTit + "###VertexEditor"); |
| 429 | + |
| 430 | + fragEditor.SetCode(info.FRAG.code); |
| 431 | + nTit = info.shaderName + "(" + info.i18n->GetWord("editorfragshader") + ")"; |
| 432 | + fragEditor.SetTitle(nTit + "###FragmentEditor"); |
| 433 | + |
| 434 | + luaEditor.SetCode(info.LUA.code); |
| 435 | + nTit = info.shaderName + "(" + info.i18n->GetWord("editorlua") + ")"; |
| 436 | + luaEditor.SetTitle(nTit + "###LuaEditor"); |
| 437 | + |
| 438 | + info.pendingCompile = true; |
| 439 | + } |
| 440 | + ImGui::CloseCurrentPopup(); |
| 441 | + } |
| 442 | + |
| 443 | + ImGui::EndPopup(); |
| 444 | + } |
| 445 | + }; |
| 446 | + |
| 394 | 447 | info.saveAs = [&]() { |
| 395 | 448 | if (ImGui::BeginPopupModal(info.i18n->GetWord("filesaveasshader").c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { |
| 396 | 449 | ImGui::Text(info.i18n->GetWord("fileshadername").c_str()); |
| | @@ -539,6 +592,8 @@ |
| 539 | 592 | bool isManualKey = window.GetKey(GLFW_KEY_F1); |
| 540 | 593 | bool isCompileKey = window.GetKey(GLFW_KEY_F5); |
| 541 | 594 | |
| 595 | + bool isEscKey = window.GetKey(GLFW_KEY_ESCAPE); |
| 596 | + |
| 542 | 597 | bool ctrlMod = (window.GetKey(GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS); |
| 543 | 598 | bool shiftMod = (window.GetKey(GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS); |
| 544 | 599 | //bool altMod = (window.GetKey(GLFW_KEY_LEFT_ALT) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_ALT) == GLFW_PRESS); |
| | @@ -560,7 +615,9 @@ |
| 560 | 615 | info.showNewShaderPopup = true; |
| 561 | 616 | } |
| 562 | 617 | |
| 563 | | - if (isOpenKey) {} |
| 618 | + if (isOpenKey) { |
| 619 | + info.showOpenShaderPopup = true; |
| 620 | + } |
| 564 | 621 | |
| 565 | 622 | if (isSaveAsKey) { |
| 566 | 623 | info.showSaveAsShaderPopup = true; |
| | @@ -571,6 +628,10 @@ |
| 571 | 628 | else info.save(); |
| 572 | 629 | } |
| 573 | 630 | |
| 631 | + if (isEscKey) { |
| 632 | + info.closePopup = true; |
| 633 | + } |
| 634 | + |
| 574 | 635 | if (isManualKey) { |
| 575 | 636 | info.isManual = true; |
| 576 | 637 | } |
| | @@ -619,12 +680,18 @@ |
| 619 | 680 | info.showSaveAsShaderPopup = false; |
| 620 | 681 | } |
| 621 | 682 | |
| 683 | + if (info.showOpenShaderPopup) { |
| 684 | + ImGui::OpenPopup(info.i18n->GetWord("fileopenshader").c_str()); |
| 685 | + info.showOpenShaderPopup = false; |
| 686 | + } |
| 687 | + |
| 622 | 688 | if (info.showNewShaderPopup) { |
| 623 | 689 | ImGui::OpenPopup(info.i18n->GetWord("filenewcreateshader").c_str()); |
| 624 | 690 | info.showNewShaderPopup = false; |
| 625 | 691 | } |
| 626 | 692 | |
| 627 | 693 | info.create(); |
| 694 | + info.open(); |
| 628 | 695 | info.saveAs(); |
| 629 | 696 | info.compile(); |
| 630 | 697 | |