Skip to content

Commit

Permalink
Release 1.0.0 update
Browse files Browse the repository at this point in the history
misc fixes to ui actions

fixed some bugs regarding loading empty files

added icon properly for windows

added lowspecs release with lower open gl version
  • Loading branch information
gk646 committed May 10, 2024
1 parent 1b0f6d8 commit cd0b8c5
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 31 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ set(CMAKE_CXX_STANDARD 23)

set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
set(OPENGL_VERSION "4.3" CACHE STRING "OpenGL Version to build raylib with")
set(OPENGL_VERSION "2.1" CACHE STRING "OpenGL Version to build raylib with")
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) # Build as shared lib


set(ENABLE_SANITIZER OFF)
set(RUN_TESTS ON)
set(RUN_TESTS ON) # If it should build the test executable

# Compiler options for MSVC and unix
# Compiler options for MSVC and GCC
include(cmake/CompilerOptions.cmake)

# Choose how the STL is linked
include(cmake/LinkSTL.cmake)

# Choose either one - currently only local libs supported
# Choose how to supply dependencies - currently only local libs supported
# include(cmake/FetchLibs.cmake)
include(cmake/LoadLocalLibs.cmake)

Expand Down
11 changes: 6 additions & 5 deletions cmake/LoadLocalLibs.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
set(DEPENDENCIES_PATH "C:/Users/gk646/Documents/Libraries")

set(DEPENDENCIES_PATH "C:/Users/gk646/Documents/Libraries") # Set to where your libraries are stored

include_directories(
"${DEPENDENCIES_PATH}/raylib-master/src"
"${DEPENDENCIES_PATH}/raygui-master/src"
"${DEPENDENCIES_PATH}/tinyfiledialogs"
"${CMAKE_SOURCE_DIR}/../cxstructs/src" #Just supply a clone of cxstructs/include here
"${DEPENDENCIES_PATH}/raylib-master/src" # Supply a clone of raylib.git
"${DEPENDENCIES_PATH}/raygui-master/src" # Supply a clone of raygui.git
"${DEPENDENCIES_PATH}/tinyfiledialogs" # Download from here https://sourceforge.net/projects/tinyfiledialogs/
"${DEPENDENCIES_PATH}/cxstructs-master/include" # Supply a clone of cxstructs.git
)

add_subdirectory("${DEPENDENCIES_PATH}/raylib-master" raylib)
Expand Down
8 changes: 5 additions & 3 deletions src/raynodes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ add_executable(raynodes main.cpp)
target_include_directories(raynodes PRIVATE ${CMAKE_SOURCE_DIR}/src/raynodes)
# This places the executable in the root of the build directory
set_target_properties(raynodes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Link against user32 on windows
# Link raylib and the core editor
target_link_libraries(raynodes PUBLIC raylib editor)

if (MSVC)
target_link_libraries(raynodes PRIVATE user32)
target_sources(raynodes PRIVATE shared/app.rc) # Add the icon resource file
target_link_libraries(raynodes PRIVATE user32) # Need to link to avoid duplicate symbols
add_custom_command(TARGET raynodes POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename
"${CMAKE_BINARY_DIR}/raylib/raylib/raylib.dll"
"${CMAKE_BINARY_DIR}/raylib.dll"
COMMENT "Moving raylib.dll to project binary directory"
)

else ()
add_custom_command(TARGET raynodes POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename
"${CMAKE_BINARY_DIR}/raylib/raylib/libraylib.so"
"${CMAKE_BINARY_DIR}/libraylib.so"
COMMENT "Moving raylib.dll to project binary directory"
COMMENT "Moving raylib.so to project binary directory"
)
endif ()
2 changes: 1 addition & 1 deletion src/raynodes/application/context/ContextCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

struct Core {
static constexpr int TARGET_FPS = 100;
static constexpr int MAX_ACTIONS = 25;
static constexpr int MAX_ACTIONS = 5;

std::unordered_map<NodeID, Node*> selectedNodes;
std::unordered_map<NodeID, Node*> nodeMap;
Expand Down
6 changes: 3 additions & 3 deletions src/raynodes/application/context/ContextInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct Info {
static constexpr auto wikiLink = "https://github.com/gk646/raynodes";
static constexpr auto github = "https://github.com/gk646/raynodes";
static constexpr auto about = "Copyright #226# 2024 gk646. MIT License";
static constexpr int majorVersion = 0;
static constexpr int middleVersion = 9;
static constexpr int minorVersion = 9;
static constexpr int majorVersion = 1;
static constexpr int minorVersion = 0;
static constexpr int patch = 0;

static const char* getVersion(EditorContext& ec);
};
Expand Down
2 changes: 1 addition & 1 deletion src/raynodes/application/context/ContextUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct UI final {
{63, 63, 63, 255}, // N_BACK_GROUND
{207, 207, 207, 255}, // UI_LIGHT
{88, 88, 88, 255}, // UI_MEDIUM
{56, 56, 56, 255} // UI_DARK
{60, 60, 60, 255} // UI_DARK
};

static constexpr auto* fileMenuText = "#001#File;"
Expand Down
2 changes: 1 addition & 1 deletion src/raynodes/application/context/impl/ContextInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
#include "application/EditorContext.h"

const char* Info::getVersion(EditorContext& ec) {
return ec.string.formatText2("%d.%d.%d", majorVersion, middleVersion, minorVersion);
return ec.string.formatText2("%d.%d.%d", majorVersion, minorVersion, patch);
}
7 changes: 5 additions & 2 deletions src/raynodes/application/context/impl/ContextPersist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ void LoadTemplates(FILE* file, EditorContext& ec) {
int LoadNodes(FILE* file, EditorContext& ec) {
int count = 0;
while (io_load_inside_section(file, "Nodes")) {
printf("%d\n",(int)ftell(file));
int index = 0;
int index = -1;
io_load(file, index);
if(index == -1) {
io_load_newline(file, true);
continue;
}
int id;
io_load(file, id);
auto* nodeName = compIndices.getName(index);
Expand Down
9 changes: 5 additions & 4 deletions src/raynodes/application/editor/EditorUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline void DrawContextMenu(EditorContext& ec) {
Vector2 drawPos{pos.x, pos.y};

// Draw main menu background
DrawRectangleRounded(menuRect, 0.1F, 10, ColorAlpha(UI::COLORS[UI_DARK], 0.8));
DrawRectangleRounded(menuRect, 0.1F, 10, ColorAlpha(UI::COLORS[UI_DARK], 0.9));

const ContextMenuCategory* hoveredCategory = nullptr;
bool closeToMenu = false;
Expand Down Expand Up @@ -113,12 +113,13 @@ inline void DrawContextMenu(EditorContext& ec) {
// Highlight the category if it's open
if (category.isOpen) { DrawRectangleRounded(textRect, 0.1F, 10, hightLightColor); }

DrawTextEx(font, category.name, {drawPos.x + padding, drawPos.y + padding}, fs, 0.6F, UI::COLORS[UI_LIGHT]);
DrawTextEx(font, category.name, {drawPos.x + padding, drawPos.y + padding / 2.0F}, fs, 0.6F,
UI::COLORS[UI_LIGHT]);

// Draw the category's nodes if it's open
if (category.isOpen && !category.nodes.empty()) {
Vector2 drawPosC = {drawPos.x + menuWidth, drawPos.y};
DrawRectangleRounded(categoryRect, 0.1F, 10, ColorAlpha(UI::COLORS[UI_DARK], 0.8));
DrawRectangleRounded(categoryRect, 0.1F, 10, ColorAlpha(UI::COLORS[UI_DARK], 0.9));
for (const auto& name : category.nodes) {
const Rectangle nodeTextRect = {drawPosC.x, drawPosC.y, menuWidth, fs + padding};
if (CheckCollisionPointRec(mouse, nodeTextRect)) {
Expand All @@ -129,7 +130,7 @@ inline void DrawContextMenu(EditorContext& ec) {
break;
}
}
DrawTextEx(font, name, {drawPosC.x + padding, drawPosC.y + padding}, fs, 0.7F, UI::COLORS[UI_LIGHT]);
DrawTextEx(font, name, {drawPosC.x + padding, drawPosC.y + padding / 2.0F}, fs, 0.7F, UI::COLORS[UI_LIGHT]);
drawPosC.y += fs + padding;
}
}
Expand Down
23 changes: 16 additions & 7 deletions src/raynodes/application/elements/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,39 @@ void NodeDeleteAction::undo(EditorContext& ec) {
for (const auto conn : deletedConnections) {
ec.core.addConnection(conn);
}
deletedConnections.clear();
}

void NodeDeleteAction::redo(EditorContext& ec) {
removeNodes = true;
for (const auto n : deletedNodes) {
ec.core.removeNode(ec, n->uID);
}
for (const auto conn : deletedConnections) {
ec.core.removeConnection(conn);
ec.core.removeConnectionsFromNode(*n, deletedConnections);
}
}

//-----------NODE_CREATE-----------//
NodeCreateAction::NodeCreateAction(const int size) : Action(CREATE_NODE) {
createdNodes.reserve(size);
createdNodes.reserve(size+1);
deletedConnections.reserve(5);
}

NodeCreateAction::~NodeCreateAction() noexcept {
if (!removeNodes) return;
for (const auto n : createdNodes) {
delete n;
if (removeNodes) {
for (const auto n : createdNodes) {
delete n;
}
for (const auto conn : deletedConnections) {
delete conn;
}
}
}

void NodeCreateAction::undo(EditorContext& ec) {
removeNodes = true;
for (const auto n : createdNodes) {
ec.core.removeNode(ec, n->uID);
ec.core.removeConnectionsFromNode(*n, deletedConnections);
}
}

Expand All @@ -98,6 +103,10 @@ void NodeCreateAction::redo(EditorContext& ec) {
for (const auto n : createdNodes) {
ec.core.insertNode(ec, *n);
}
for (const auto conn : deletedConnections) {
ec.core.addConnection(conn);
}
deletedConnections.clear();
}

//-----------NODE_MOVE-----------//
Expand Down
1 change: 1 addition & 0 deletions src/raynodes/application/elements/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct NodeDeleteAction final : Action {

struct NodeCreateAction final : Action {
std::vector<Node*> createdNodes;
std::vector<Connection*> deletedConnections;
explicit NodeCreateAction(int size);
~NodeCreateAction() noexcept override;
void undo(EditorContext& ec) override;
Expand Down
2 changes: 2 additions & 0 deletions src/raynodes/shared/app.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "winuser.h"
IDI_ICON1 ICON DISCARDABLE "../../../res/icon.ico"
7 changes: 7 additions & 0 deletions src/raynodes/ui/TextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void TextInputField::draw() {
}
}

//TODO reoder operations to avoid creating rare crashes of same tick inputs
void TextInputField::update(Vector2 mouse) {
if (!isFocused) return;

Expand Down Expand Up @@ -146,6 +147,8 @@ void TextInputField::update(Vector2 mouse) {
while (key > 0) {
selectionStart = selectionEnd;
if (IsInputAllowed(key, constraint) && buffer.length() < 1024) {
// Safety measure - i could produce some crashes here
cursorPos = cxstructs::clamp(static_cast<int>(cursorPos), 0, static_cast<int>(buffer.size()));
buffer.insert(buffer.begin() + cursorPos, static_cast<char>(key));
cursorPos++;
updateDimensions();
Expand All @@ -161,6 +164,8 @@ void TextInputField::update(Vector2 mouse) {
}

if (IsKeyPressed(KEY_ENTER) && buffer.length() < 1024) {
// Safety measure - i could produce some crashes here
cursorPos = cxstructs::clamp(static_cast<int>(cursorPos), 0, static_cast<int>(buffer.size()));
buffer.insert(buffer.begin() + cursorPos, '\n');
cursorPos++;
updateDimensions();
Expand All @@ -172,6 +177,8 @@ void TextInputField::update(Vector2 mouse) {
buffer.erase(start, end - start);
cursorPos -= end - start - 1;
} else {
// Safety measure - i could produce some crashes here
cursorPos = cxstructs::clamp(static_cast<int>(cursorPos), 1, static_cast<int>(buffer.size()));
buffer.erase(buffer.begin() + cursorPos - 1);
}
selectionStart = selectionEnd;
Expand Down

0 comments on commit cd0b8c5

Please sign in to comment.