Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/editor/projectFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ProjectFile {
bool isSaveable = true;

public:
bool isEmpty = false;
ProjectFile();
ProjectFile(std::unique_ptr<FileView> view,
std::unique_ptr<VariantWrapper> variant,
Expand Down
1 change: 1 addition & 0 deletions include/editor/services/fileSystemService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class FileSystemService {
std::array<std::string, FILETYPE_MAX> &getTypeNames();
const std::string &getEditorBaseDir();
std::string getResourcePath(const std::string &path);
void openFileInDefaultApp(std::string &path);
};

#endif
4 changes: 2 additions & 2 deletions include/editor/widgets/toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void Toolbox<T>::resetToolSelection(std::string groupToReset) {
for (const auto &widgets : this->container->getWidgets()) {
if (auto btn = std::dynamic_pointer_cast<tgui::BitmapButton>(widgets)) {
ToolboxItemIdentifier<T> identifier =
btn->getUserData<ToolboxItemIdentifier<T>>();
btn->template getUserData<ToolboxItemIdentifier<T>>();
if (groupToReset == identifier.group) {
tgui::ButtonRenderer *renderer = btn->getRenderer();
tgui::ButtonRenderer *defaultRenderer =
Expand Down Expand Up @@ -171,7 +171,7 @@ void Toolbox<T>::addWidget(tgui::Widget::Ptr widget, int idx) {
template <typename T> void Toolbox<T>::removeItemById(const T &id) {
for (const auto &widget : this->container->getWidgets()) {
ToolboxItemIdentifier<T> identifier =
widget->getUserData<ToolboxItemIdentifier<T>>();
widget->template getUserData<ToolboxItemIdentifier<T>>();
if (identifier.id == id) {
this->container->remove(widget);
toolGroup[identifier.group].erase(id);
Expand Down
1 change: 1 addition & 0 deletions include/winapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions resources/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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üğü",
Expand All @@ -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",
Expand Down Expand Up @@ -100,4 +105,4 @@
"button": {
"go_back": "Geri Git"
}
}
}
6 changes: 4 additions & 2 deletions src/editor/projectFileVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ ProjectFileVisitor::codeView(const std::string &path) {
std::unique_ptr<EmptyFileView> view = std::make_unique<EmptyFileView>();
std::unique_ptr<VariantWrapper> variant =
std::make_unique<Variant<ScriptFile>>(new ScriptFile(path));
return std::make_unique<ProjectFile>(std::move(view), std::move(variant),
EngineFileType::FILE_SCRIPT);
auto res = std::make_unique<ProjectFile>(
std::move(view), std::move(variant), EngineFileType::FILE_SCRIPT);
res->isEmpty = true;
return std::move(res);
}

std::unique_ptr<ProjectFile>
Expand Down
13 changes: 11 additions & 2 deletions src/editor/screens/projectScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -190,11 +192,18 @@ void ProjectScreen::addFileView(EngineFileType fileType,
Editor::instance->getGui().gui->setTabKeyUsageEnabled(
fileType != EngineFileType::FILE_SCRIPT);

std::unique_ptr<ProjectFile> 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> projectFile =
fileVisitor->visit(fileType, path);

projectFile->initUi(fileViewGroup);
projectFile->setFilePath(path);
tgui::String id = path;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/services/editorGuiService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <TGUI/AllWidgets.hpp>
#include <TGUI/Widgets/ChildWindow.hpp>
#include <cmath>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
Expand All @@ -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();
Expand Down
27 changes: 27 additions & 0 deletions src/editor/services/fileSystemService.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#include "services/fileSystemService.hpp"
#include "TGUI/Widgets/FileDialog.hpp"
#include <array>
#include <cstdio>
#include <nfd.h>
#include <nfd.hpp>
#include <string>

#ifdef __linux__
#include <unistd.h>
#endif

#ifdef _WIN32
#include <winapi.hpp>
#endif

#include "editor.hpp"
#include "raylib.h"
#include "screens/projectScreen.hpp"
Expand Down Expand Up @@ -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
}
6 changes: 0 additions & 6 deletions src/editor/views/codeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdio>
#include <cstring>
#include <memory>
#include <string>
#include <utility>

CodeView::CodeView(ScriptFile *scriptFile) : scriptFile(scriptFile) {}

Expand Down
22 changes: 17 additions & 5 deletions src/winapi.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include "winapi.hpp"

#include <string>

#include <winapi.hpp>

#ifdef _WIN32
#include <basetsd.h>
#include <windows.h>
#endif
#include <winnt.h>
#include <winuser.h>

#include <cstdio>
#endif

#ifdef _WIN32

Expand All @@ -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];
Expand All @@ -33,7 +45,7 @@ void WinWriteToHandle(HANDLE handle, std::string str) {
bSuccess = WriteFile(handle, static_cast<char *>(str.data()), str.size(),
&dwWritten, NULL);
if (!bSuccess) {
printf("WriteFile Error: %d", GetLastError());
printf("WriteFile Error: %lu", GetLastError());
return;
}

Expand Down Expand Up @@ -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");
Expand Down
5 changes: 3 additions & 2 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading