From 47ccfbc01c774c1024cadceb2b020cce44265bc2 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Tue, 21 Apr 2020 12:57:52 -0400 Subject: [PATCH] Update DroppedFiles --- examples/core/core_drop_files.cpp | 8 +++++-- include/CMakeLists.txt | 39 +++++++++++++++++++++++++++---- include/raylib/DroppedFiles.hpp | 9 +++++++ lib/CMakeLists.txt | 3 +++ projects/CMake/CMakeLists.txt | 4 ++-- 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/examples/core/core_drop_files.cpp b/examples/core/core_drop_files.cpp index 849d825..dea950f 100644 --- a/examples/core/core_drop_files.cpp +++ b/examples/core/core_drop_files.cpp @@ -4,10 +4,10 @@ * * This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) * -* This example has been created using raylib 1.3 (www.raylib.com) +* This example has been created using raylib-cpp (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* Copyright (c) 2020 Rob Loach (@RobLoach) * ********************************************************************************************/ @@ -22,6 +22,7 @@ int main() raylib::Window w(screenWidth, screenHeight, "raylib [core] example - drop files"); + // Create the Dropped Files collection object. raylib::DroppedFiles droppedFiles; SetTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -43,18 +44,21 @@ int main() ClearBackground(RAYWHITE); + // Check if there are files to process. if (droppedFiles.empty()) { DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); } else { DrawText("Dropped files:", 100, 40, 20, DARKGRAY); + // Iterate through all the dropped files. for (int i = 0; i < droppedFiles.size(); i++) { if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); + // Display the path to the dropped file. DrawText(droppedFiles[i].c_str(), 120, 100 + 40*i, 10, GRAY); } diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1efec9f..ffb432a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,10 +1,39 @@ add_library(raylib-cpp INTERFACE) -file(GLOB sources raylib/*.hpp) -set(RAYLIBCPP_HEADERS, ${sources}) +target_include_directories(raylib-cpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/) install(FILES - ${RAYLIBCPP_HEADERS} DESTINATION include/ + raylib/AudioDevice.hpp + raylib/AudioStream.hpp + raylib/BoundingBox.hpp + raylib/Camera2D.hpp + raylib/Camera3D.hpp + raylib/Color.hpp + raylib/DroppedFiles.hpp + raylib/Font.hpp + raylib/Gamepad.hpp + raylib/Image.hpp + raylib/Material.hpp + raylib/Matrix.hpp + raylib/Mesh.hpp + raylib/ModelAnimation.hpp + raylib/Model.hpp + raylib/Mouse.hpp + raylib/Music.hpp + raylib/RayHitInfo.hpp + raylib/Ray.hpp + raylib/raylib.hpp + raylib/Rectangle.hpp + raylib/RenderTexture2D.hpp + raylib/Shader.hpp + raylib/Sound.hpp + raylib/Texture2D.hpp + raylib/utils.hpp + raylib/Vector2.hpp + raylib/Vector3.hpp + raylib/Vector4.hpp + raylib/VrSimulator.hpp + raylib/Wave.hpp + raylib/Window.hpp + DESTINATION include/raylib ) - -target_include_directories(raylib-cpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/) diff --git a/include/raylib/DroppedFiles.hpp b/include/raylib/DroppedFiles.hpp index 72c7004..258758a 100644 --- a/include/raylib/DroppedFiles.hpp +++ b/include/raylib/DroppedFiles.hpp @@ -21,15 +21,24 @@ namespace raylib { Get(); } + /** + * Get the dropped files names. + */ DroppedFiles& Get() { m_files = ::GetDroppedFiles(&m_count); return *this; } + /** + * Check if a file has been dropped into window. + */ inline bool IsFileDropped() { return ::IsFileDropped(); } + /** + * Clear dropped files paths buffer. + */ inline DroppedFiles& Clear() { ::ClearDroppedFiles(); return *this; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a0d32c9..f203b59 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -6,3 +6,6 @@ target_link_libraries(libraylib-cpp PUBLIC raylib raylib-cpp) # Remove the "lib" at the beginning since it's already there. set_target_properties(libraylib-cpp PROPERTIES PREFIX "") + +# Set up the install directory. +install(TARGETS libraylib-cpp DESTINATION lib) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 6ba1d28..e1c04be 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -28,7 +28,7 @@ if (NOT raylib-cpp_FOUND) FetchContent_Declare( raylib-cpp GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git - GIT_TAG 64c39d6d6b1ab2f68cb3669b0a3ff57857d5cdf7 + GIT_TAG 27f7a59fd2e7fb2356d90e4f477e994475e8dbb8 ) FetchContent_GetProperties(raylib-cpp) if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet? @@ -45,7 +45,7 @@ endif() set(PROJECT_NAME raylib-cpp-example) set(PROJECT_SOURCES main.cpp) add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) -#set(raylib_VERBOSE 1) +set(raylib_VERBOSE 1) target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib-cpp) # That's it! You should have an example executable that you can run. Have fun!