diff --git a/include/editor/projectFile.hpp b/include/editor/projectFile.hpp index f423856..12fd0f3 100644 --- a/include/editor/projectFile.hpp +++ b/include/editor/projectFile.hpp @@ -16,6 +16,7 @@ class ProjectFile { bool isSaveable = true; public: + bool isEmpty = false; ProjectFile(); ProjectFile(std::unique_ptr view, std::unique_ptr variant, diff --git a/include/editor/services/fileSystemService.hpp b/include/editor/services/fileSystemService.hpp index eaf4a06..87a6d5a 100644 --- a/include/editor/services/fileSystemService.hpp +++ b/include/editor/services/fileSystemService.hpp @@ -37,6 +37,7 @@ class FileSystemService { std::array &getTypeNames(); const std::string &getEditorBaseDir(); std::string getResourcePath(const std::string &path); + void openFileInDefaultApp(std::string &path); }; #endif diff --git a/include/editor/widgets/toolbox.hpp b/include/editor/widgets/toolbox.hpp index 463163d..19e7274 100644 --- a/include/editor/widgets/toolbox.hpp +++ b/include/editor/widgets/toolbox.hpp @@ -98,7 +98,7 @@ void Toolbox::resetToolSelection(std::string groupToReset) { for (const auto &widgets : this->container->getWidgets()) { if (auto btn = std::dynamic_pointer_cast(widgets)) { ToolboxItemIdentifier identifier = - btn->getUserData>(); + btn->template getUserData>(); if (groupToReset == identifier.group) { tgui::ButtonRenderer *renderer = btn->getRenderer(); tgui::ButtonRenderer *defaultRenderer = @@ -171,7 +171,7 @@ void Toolbox::addWidget(tgui::Widget::Ptr widget, int idx) { template void Toolbox::removeItemById(const T &id) { for (const auto &widget : this->container->getWidgets()) { ToolboxItemIdentifier identifier = - widget->getUserData>(); + widget->template getUserData>(); if (identifier.id == id) { this->container->remove(widget); toolGroup[identifier.group].erase(id); diff --git a/include/winapi.hpp b/include/winapi.hpp index cdec95a..9a9f897 100644 --- a/include/winapi.hpp +++ b/include/winapi.hpp @@ -9,6 +9,7 @@ struct VsInfo { std::string auxiliaryPath; }; +bool WinOpenFileAssociate(std::string operation, std::string file); void WinCreateProc(std::string cmdLine); VsInfo WinVsWhere(std::string path); VsInfo ParseVsWhereData(std::string output); diff --git a/resources/translations/tr.json b/resources/translations/tr.json index 03d7592..5be3277 100644 --- a/resources/translations/tr.json +++ b/resources/translations/tr.json @@ -29,7 +29,8 @@ }, "options": { "language": "Dil", - "theme": "Tema" + "theme": "Tema", + "theme_notice": "Tema değiştirdikten sonra düzenleyici yeniden başlatmanız önerilir!" }, "project": { "create_new_resource": "Yeni Kaynak", @@ -48,7 +49,9 @@ "roomview": { "mapwidth": "Harita Genişliği", "mapheight": "Harita Yüksekliği", - "tileset_file": "Kare Seti Dosyası" + "tileset_file": "Kare Seti Dosyası", + "enable_brush": "Fırça Modunu Aktifleştir", + "bg_music_file": "Arkaplan Müziği" }, "propview": { "atlas": "Atlas Büyüklüğü", @@ -68,7 +71,9 @@ "dir7": "Sağ", "play": "Oynat", "pause": "Duraklat", - "is_non_idle": "Boşta Olmayan Animasyon Mu?" + "is_non_idle": "Boşta Olmayan Animasyon Mu?", + "delete": "Kare Sil", + "edit_anim_data": "Animasyon Verisini Düzenle" }, "toolbar": { "play": "Oyna", @@ -100,4 +105,4 @@ "button": { "go_back": "Geri Git" } -} +} \ No newline at end of file diff --git a/src/editor/projectFileVisitor.cpp b/src/editor/projectFileVisitor.cpp index 82ec1aa..09a0b4d 100644 --- a/src/editor/projectFileVisitor.cpp +++ b/src/editor/projectFileVisitor.cpp @@ -75,8 +75,10 @@ ProjectFileVisitor::codeView(const std::string &path) { std::unique_ptr view = std::make_unique(); std::unique_ptr variant = std::make_unique>(new ScriptFile(path)); - return std::make_unique(std::move(view), std::move(variant), - EngineFileType::FILE_SCRIPT); + auto res = std::make_unique( + std::move(view), std::move(variant), EngineFileType::FILE_SCRIPT); + res->isEmpty = true; + return std::move(res); } std::unique_ptr diff --git a/src/editor/screens/projectScreen.cpp b/src/editor/screens/projectScreen.cpp index f12facb..3fe28e7 100644 --- a/src/editor/screens/projectScreen.cpp +++ b/src/editor/screens/projectScreen.cpp @@ -182,6 +182,8 @@ void ProjectScreen::initItems(tgui::Group::Ptr layout) { // Maximize when a project is opened SetWindowState(FLAG_WINDOW_MAXIMIZED); + + // FIXME: fix scaling issue on windows! } void ProjectScreen::addFileView(EngineFileType fileType, @@ -190,11 +192,18 @@ void ProjectScreen::addFileView(EngineFileType fileType, Editor::instance->getGui().gui->setTabKeyUsageEnabled( fileType != EngineFileType::FILE_SCRIPT); + std::unique_ptr projectFile = + fileVisitor->visit(fileType, path); + if (projectFile->isEmpty) { + std::string mutPath = std::string(path); + Editor::instance->getFs().openFileInDefaultApp(mutPath); + return; + } + size_t idx = fileTabs->addFileTab(path, GetFileName(path.c_str())); if (idx != -1) { fileViewGroup->removeAllWidgets(); - std::unique_ptr projectFile = - fileVisitor->visit(fileType, path); + projectFile->initUi(fileViewGroup); projectFile->setFilePath(path); tgui::String id = path; diff --git a/src/editor/services/editorGuiService.cpp b/src/editor/services/editorGuiService.cpp index b6cf189..00be0d0 100644 --- a/src/editor/services/editorGuiService.cpp +++ b/src/editor/services/editorGuiService.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,7 @@ EditorGuiService::EditorGuiService() { void EditorGuiService::init() { currentCursor = MOUSE_CURSOR_DEFAULT; + SetConfigFlags(FLAG_WINDOW_RESIZABLE); InitWindow(BASE_WINDOW_WIDTH, BASE_WINDOW_HEIGHT, "RPG++ Editor"); InitAudioDevice(); diff --git a/src/editor/services/fileSystemService.cpp b/src/editor/services/fileSystemService.cpp index 37d9164..27ce788 100644 --- a/src/editor/services/fileSystemService.cpp +++ b/src/editor/services/fileSystemService.cpp @@ -1,10 +1,19 @@ #include "services/fileSystemService.hpp" #include "TGUI/Widgets/FileDialog.hpp" #include +#include #include #include #include +#ifdef __linux__ +#include +#endif + +#ifdef _WIN32 +#include +#endif + #include "editor.hpp" #include "raylib.h" #include "screens/projectScreen.hpp" @@ -63,3 +72,21 @@ std::string FileSystemService::getResourcePath(const std::string &path) { return result.string(); } + +void FileSystemService::openFileInDefaultApp(std::string &path) { +#ifdef __linux__ + auto proc = fork(); + if (proc == 0) { + printf("%s \n", path.c_str()); + std::string command = "xdg-open"; + char *args[] = {command.data(), path.data(), nullptr}; + execvp(command.data(), args); + } +#endif + +#ifdef _WIN32 + if (!WinOpenFileAssociate("", path.c_str())) { + printf("failure to open file...\n"); + } +#endif +} diff --git a/src/editor/views/codeView.cpp b/src/editor/views/codeView.cpp index 40c9cc2..c97ae7a 100644 --- a/src/editor/views/codeView.cpp +++ b/src/editor/views/codeView.cpp @@ -2,15 +2,9 @@ #include "TGUI/Vector2.hpp" #include "raylib.h" #include "scriptFile.h" -#include "syntaxHighlighter.hpp" #include "tree_sitter/api.h" -#include "tree_sitter/tree-sitter-lua.h" #include "views/worldView.hpp" -#include -#include #include -#include -#include CodeView::CodeView(ScriptFile *scriptFile) : scriptFile(scriptFile) {} diff --git a/src/winapi.cpp b/src/winapi.cpp index 2542e08..f61b3ce 100644 --- a/src/winapi.cpp +++ b/src/winapi.cpp @@ -1,10 +1,15 @@ -#include "winapi.hpp" + +#include + +#include #ifdef _WIN32 +#include #include -#endif +#include +#include -#include +#endif #ifdef _WIN32 @@ -25,6 +30,13 @@ char *WinReadFromHandle(HANDLE handle) { return charBuf; } +bool WinOpenFileAssociate(std::string operation, std::string file) { + printf("opening file with path %s (Win32)\n", file.c_str()); + INT_PTR hInstance = (INT_PTR)ShellExecuteA( + NULL, operation.c_str(), file.c_str(), NULL, NULL, SW_SHOWNORMAL); + return hInstance != SE_ERR_NOASSOC; +} + void WinWriteToHandle(HANDLE handle, std::string str) { DWORD dwWritten; CHAR charBuf[4096]; @@ -33,7 +45,7 @@ void WinWriteToHandle(HANDLE handle, std::string str) { bSuccess = WriteFile(handle, static_cast(str.data()), str.size(), &dwWritten, NULL); if (!bSuccess) { - printf("WriteFile Error: %d", GetLastError()); + printf("WriteFile Error: %lu", GetLastError()); return; } @@ -81,7 +93,7 @@ void WinCreateProcEx(std::string cmdLine, HANDLE outHandle, HANDLE inHandle, if (inHandle != NULL) CloseHandle(inHandle); } else { - printf("WinCreateProc: CreateProcess failed (%d).\n", GetLastError()); + printf("WinCreateProc: CreateProcess failed (%lu).\n", GetLastError()); } #else printf("This is for Windows API only"); diff --git a/xmake.lua b/xmake.lua index f5171e2..0eb63d0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,8 +8,9 @@ set_license("Zlib") if is_plat("mingw", "linux", "macosx") then add_syslinks("raylib") end - -if is_plat("mingw", "windows") then +if is_plat("macosx") then + add_frameworks("CoreVideo", "CoreGraphics", "AppKit", "IOKit", "CoreFoundation", "Foundation") +elseif is_plat("mingw", "windows") then add_syslinks("gdi32", "opengl32", "winmm", "shell32", "user32") end