Skip to content

Commit 69c4ce6

Browse files
committed
feat: Better modules API and content browser improvements
1 parent f45255c commit 69c4ce6

File tree

10 files changed

+77
-49
lines changed

10 files changed

+77
-49
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC")
88
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
99
set(VORTEX_VERSION "1.0")
1010
set(VORTEX_FULL_VERSION "1.0.1")
11+
set(VORTEX_BUILDID "1")
1112
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/build/dist/${VORTEX_VERSION} CACHE PATH "Installation directory" FORCE)
1213

1314
set(VORTEX_DIST "beta")

build/handle_crash.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,53 @@
11
#!/bin/bash
22

33
if [ $# -lt 2 ]; then
4-
echo "Usage: $0 <path_to_output_file> <command_to_execute> [<end_command>]"
4+
echo "Usage: $0 <path_to_output_file> <command_to_execute> [::END:: <end_command>]"
55
exit 1
66
fi
77

88
OUTPUT_FILE="$1"
9-
shift 1
9+
shift
1010

11+
OUTPUT_DIR=$(dirname "$OUTPUT_FILE")
12+
mkdir -p "$OUTPUT_DIR"
13+
14+
# Build main command until "::END::"
1115
COMMAND=()
12-
while [[ $# -gt 1 ]]; do
13-
COMMAND+=("\"$1\"")
16+
while [[ $# -gt 0 ]]; do
17+
if [[ "$1" == "::END::" ]]; then
18+
shift
19+
break
20+
fi
21+
COMMAND+=("$1")
1422
shift
1523
done
1624

17-
END_COMMAND="$1"
25+
# Build end command if provided
26+
END_COMMAND=()
27+
while [[ $# -gt 0 ]]; do
28+
END_COMMAND+=("$1")
29+
shift
30+
done
1831

1932
# Configure core dump pattern
2033
echo "kernel.core_pattern = /tmp/core.%e.%p" > /etc/sysctl.d/99-core-pattern.conf
2134
sysctl --system
2235

2336
# Execute the main command
2437
echo "Executing: ${COMMAND[*]}"
25-
eval "${COMMAND[@]}"
38+
"${COMMAND[@]}"
2639
EXIT_CODE=$?
2740

2841
if [ $EXIT_CODE -ne 0 ]; then
2942
CORE_FILE=$(ls /tmp/core.* 2>/dev/null | head -n 1)
3043

3144
if [ -f "$CORE_FILE" ]; then
3245
echo "Fatal error: Core dump found: $CORE_FILE"
33-
echo "==== COREDUMP BEGIN ====" >> "$OUTPUT_FILE"
34-
gdb -batch -ex "bt" -ex "info registers" -ex "list" "${COMMAND[0]}" "$CORE_FILE" >> "$OUTPUT_FILE" 2>&1
35-
echo "==== COREDUMP END ====" >> "$OUTPUT_FILE"
46+
{
47+
echo "==== COREDUMP BEGIN ===="
48+
gdb -batch -ex "bt" -ex "info registers" -ex "list" "${COMMAND[0]}" "$CORE_FILE"
49+
echo "==== COREDUMP END ===="
50+
} >> "$OUTPUT_FILE" 2>&1
3651

3752
rm -f "$CORE_FILE"
3853
echo "Core dump $CORE_FILE has been removed."
@@ -44,9 +59,9 @@ else
4459
fi
4560

4661
# Execute the end command if provided
47-
if [ -n "$END_COMMAND" ]; then
48-
echo "Executing end command: $END_COMMAND"
49-
eval "$END_COMMAND"
62+
if [ ${#END_COMMAND[@]} -gt 0 ]; then
63+
echo "Executing end command: ${END_COMMAND[*]}"
64+
"${END_COMMAND[@]}"
5065
fi
5166

5267
exit $EXIT_CODE

main.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,18 @@ int main(int argc, char *argv[]) {
248248
PrintHeader();
249249
} else if (std::string(argv[1]) == "-test") {
250250
return 0;
251-
} else if (std::string(argv[1]) == "-crash" ||
251+
} else if (std::string(argv[1]) == "--crash" ||
252252
std::string(argv[1]) == "--get-last-crash") {
253253
PrintHeader("(Crash handler)");
254254

255255
if (argc > 2) {
256256
std::string arg2 = argv[2];
257-
if (arg2.rfind("--session_id=\"", 0) == 0 && arg2.back() == '\"') {
258-
session_id = arg2.substr(13, arg2.length() - 14);
257+
if (arg2.rfind("--session_id=", 0) == 0) {
258+
session_id = arg2.substr(13);
259+
if (!session_id.empty() && session_id.front() == '"' &&
260+
session_id.back() == '"') {
261+
session_id = session_id.substr(1, session_id.size() - 2);
262+
}
259263
}
260264
}
261265

@@ -313,9 +317,9 @@ int main(int argc, char *argv[]) {
313317

314318
std::thread receiveThread;
315319
try {
316-
std::thread Thread([&]() { VortexMaker::VortexEditor(argc, argv); });
317-
receiveThread.swap(Thread);
318-
320+
std::thread Thread([&]() { VortexMaker::VortexEditor(argc, argv); });
321+
receiveThread.swap(Thread);
322+
319323
} catch (std::exception e) {
320324
std::thread Thread([&]() { VortexMaker::VortexEditor(argc, argv); });
321325
receiveThread.swap(Thread);

main/include/modules/interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ModuleInterface {
7070
// Misc
7171
void AddLogo(const uint8_t *hexa, size_t size);
7272
void AddLogo(const std::string &relative_path);
73+
void ResetModule();
7374

7475
// Functions of the modules (gives the Vortex abstraction/features)
7576
void AddFunction(std::function<void()> foo, const std::string &name);

main/include/vortex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
//_____________________________________________________________________________
1010
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if
1111
// VORTEX_VERSION_NUM >= 12345')
12-
#define VORTEX_MAIN_VERSION "1.0"
13-
#define VORTEX_VERSION "1.0.1"
14-
#define VORTEX_VERSION_NUM 10001
12+
#define VORTEX_VERSION "1.0"
13+
#define VORTEX_VERSION_NUM 1000
1514

1615
//_____________________________________________________________________________
1716

main/src/modules/interface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ void ModuleInterface::Stop() {
656656
}
657657
}
658658

659+
void ModuleInterface::ResetModule() { m_item_handlers.clear(); }
660+
659661
void ModuleInterface::CallOutputEvent(const std::string &event_name,
660662
ArgumentValues &args, ReturnValues &ret) {
661663
VortexMaker::CallOutputEvent(event_name, args, ret, this->m_name);

ui/editor/app/instances/content_browser/content_browser.cpp

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ static char pool_add_path[512];
1313
static char pool_add_name[512];
1414

1515
static bool ShowViewModal = false;
16+
static std::vector<std::shared_ptr<ItemHandlerInterface>> item_handles;
17+
static bool item_context_menu_opened = false;
1618

1719
static std::string _parent;
1820
static std::string ProjectSearch;
@@ -1326,7 +1328,7 @@ bool ContentBrowserAppWindow::ItemCard(
13261328
}
13271329
m_Selected.clear();
13281330
}
1329-
1331+
item_context_menu_opened = false;
13301332
if (ImGui::BeginPopupContextItem("ThumbmailsItemContextPopup")) {
13311333
ImGui::GetFont()->Scale = 0.9;
13321334
ImGui::PushFont(ImGui::GetFont());
@@ -1336,9 +1338,7 @@ bool ContentBrowserAppWindow::ItemCard(
13361338
ImVec4 grayColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f);
13371339
ImVec4 graySeparatorColor = ImVec4(0.4f, 0.4f, 0.4f, 0.5f);
13381340

1339-
CherryKit::SeparatorText("Actions");
1340-
1341-
static std::vector<std::shared_ptr<ItemHandlerInterface>> item_handles;
1341+
item_context_menu_opened = true;
13421342

13431343
FileTypes fileType = detect_file(path);
13441344

@@ -1347,8 +1347,13 @@ bool ContentBrowserAppWindow::ItemCard(
13471347
VortexMaker::GetAllItemHandlersFor(GetFileTypeStr(fileType));
13481348
}
13491349

1350+
if (!item_handles.empty()) {
1351+
CherryKit::SeparatorText("Actions");
1352+
}
1353+
13501354
for (auto ih : item_handles) {
1351-
if (ImGui::MenuItem(ih->title.c_str(), ih->description.c_str())) {
1355+
if (ImGui::MenuItem(ih->title.c_str(), ih->description.c_str(),
1356+
Cherry::GetTexture(ih->logo), false)) {
13521357
ih->handler(path);
13531358
}
13541359
}
@@ -1360,7 +1365,10 @@ bool ContentBrowserAppWindow::ItemCard(
13601365

13611366
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2.0f);
13621367

1363-
if (ImGui::MenuItem("Copy folder", "Ctrl + C")) {
1368+
if (ImGui::MenuItem("Copy", "Ctrl + C",
1369+
Cherry::GetTexture(Cherry::GetPath(
1370+
"resources/imgs/icons/misc/icon_copy.png")),
1371+
NULL)) {
13641372
if (m_CopyPathsCallback) {
13651373
m_CopyPathsCallback(m_Selected, false);
13661374
}
@@ -1372,7 +1380,10 @@ bool ContentBrowserAppWindow::ItemCard(
13721380
if (m_Selected.size() > 0) {
13731381
std::string label =
13741382
"Copy in addition (" + std::to_string(m_Selected.size()) + " copies)";
1375-
if (ImGui::MenuItem(label.c_str(), "Ctrl + C")) {
1383+
if (ImGui::MenuItem(label.c_str(), "Ctrl + C",
1384+
Cherry::GetTexture(Cherry::GetPath(
1385+
"resources/imgs/icons/misc/icon_copy.png")),
1386+
NULL)) {
13761387
if (m_CopyPathsCallback) {
13771388
m_CopyPathsCallback(m_Selected, true);
13781389
}
@@ -1381,41 +1392,36 @@ bool ContentBrowserAppWindow::ItemCard(
13811392
ImGui::CloseCurrentPopup();
13821393
}
13831394
}
1384-
if (ImGui::MenuItem("Cut folder", "Ctrl + X")) {
1395+
if (ImGui::MenuItem("Cut", "Ctrl + X",
1396+
Cherry::GetTexture(Cherry::GetPath(
1397+
"resources/imgs/icons/misc/icon_cut.png")),
1398+
NULL)) {
13851399
ChangeDirectory(path);
13861400
ImGui::CloseCurrentPopup();
13871401
}
13881402

1389-
ImGui::GetFont()->Scale = 0.9;
1390-
ImGui::PushFont(ImGui::GetFont());
1391-
1392-
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f);
1393-
1394-
ImGui::PushStyleColor(ImGuiCol_Text, grayColor);
1395-
1396-
ImGui::Text("Main");
1397-
1398-
ImGui::PopStyleColor();
1399-
1400-
ImGui::PushStyleColor(ImGuiCol_Separator, graySeparatorColor);
1401-
ImGui::Separator();
1402-
ImGui::PopStyleColor();
1403-
1404-
ImGui::GetFont()->Scale = oldfontsize;
1405-
ImGui::PopFont();
1403+
CherryKit::SeparatorText("Customize");
14061404

14071405
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2.0f);
14081406

1409-
if (ImGui::MenuItem("Change color")) {
1407+
if (ImGui::MenuItem("Change color", "Ctrl + X",
1408+
Cherry::GetTexture(Cherry::GetPath(
1409+
"resources/imgs/icons/misc/icon_palette.png")),
1410+
NULL)) {
14101411
//
14111412
}
1412-
if (ImGui::MenuItem("Mark as favorite")) {
1413+
if (ImGui::MenuItem("Mark as favorite", "Ctrl + X",
1414+
Cherry::GetTexture(Cherry::GetPath(
1415+
"resources/imgs/icons/misc/icon_heart.png")),
1416+
NULL)) {
14131417
//
14141418
}
14151419

14161420
ImGui::EndPopup();
14171421
}
1418-
1422+
if (!item_context_menu_opened) {
1423+
item_handles.clear();
1424+
}
14191425
/*if (ImGui::BeginPopupContextItem("ContextPopup")) {
14201426
CherryKit::SeparatorText("Main");
14211427
570 Bytes
Loading
436 Bytes
Loading
489 Bytes
Loading

0 commit comments

Comments
 (0)