mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 10:59:00 +00:00
Update DroppedFiles
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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}/)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user