Skip to content

Commit

Permalink
Merge pull request #79 from MisterGC/release/2022.1
Browse files Browse the repository at this point in the history
Release/2022.1
  • Loading branch information
MisterGC authored Sep 30, 2022
2 parents f9933a0 + 8ac84c3 commit aad6510
Show file tree
Hide file tree
Showing 62 changed files with 1,224 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
build-windows:
runs-on: windows-latest
runs-on: windows-2019

steps:

Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "thirdparty/simple-svg-writer"]
path = thirdparty/simple-svg-writer
url = https://github.com/MisterGC/simple-svg-writer.git
[submodule "thirdparty/jsonata"]
path = thirdparty/jsonata
url = https://github.com/MisterGC/jsonata.git
[submodule "thirdparty/csv-parser"]
path = thirdparty/csv-parser/csv-parser
url = https://github.com/vincentlaucsb/csv-parser.git
54 changes: 43 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
# (c) Clayground Contributors - MIT License, see "LICENSE" file

cmake_minimum_required(VERSION 3.19)
project (Clayground VERSION 2021.2)
project (Clayground VERSION 2022.1)

# CMAKE INCLUDES
set(CLAY_CMAKE_SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CLAY_CMAKE_SCRIPT_DIR}")
include(clayplugin)


# COMMON CONFIGURATION
enable_testing()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CLAYGROUND_PROJECT_NAME "${CMAKE_PROJECT_NAME}")
set(CLAYGROUND_PROJECT_VERSION "${CMAKE_PROJECT_VERSION}")

if (NOT ANDROID) # Qt Android cmake causes problems otherwise
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
else()
# In some environements Qt (Creator) produces a gradle properties
# file with invalid androidBuildToolsVersion value - the following
# option allows to workaround this bug by allowing to provide the version
# explicitely. (See https://bugreports.qt.io/browse/QTBUG-94956)
set(CLAY_ANDROID_BUILD_TOOLS_VERSION
"DO_NOT_USE" CACHE STRING
"Set to the used version, if you need to workaround QTBUG-94956")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CLAY_PLUGIN_BASE_DIR ${CMAKE_BINARY_DIR}/bin/qml/Clayground)
set(QML_IMPORT_PATH ${CMAKE_BINARY_DIR}/bin/qml CACHE STRING "" FORCE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CLAY_PLUGIN_BASE_DIR ${QML_IMPORT_PATH}/Clayground)
set(CLAY_DEPS_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)

if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set(QML_PLUGIN_LINK_TYPE STATIC CACHE STRING "" FORCE)

# PLUGIN LINKING
set(CLAYPLUGIN_LINKING SHARED)
if (ANDROID) # Avoids plugin loading problems
set(CLAYPLUGIN_LINKING STATIC)
endif()
init_static_plugin_cfg()


# DEPENDENCIES
add_subdirectory (thirdparty/qml-box2d)
if (TARGET Box2Dplugin)
extend_static_plugin_cfg("Box2Dplugin" "Box2DPlugin")
endif()
add_subdirectory (thirdparty/simple-svg-writer)
add_subdirectory (plugins)
add_subdirectory (thirdparty/csv-parser)

# Qt has problems with multiple executables when building for Android
# TODO Re-check if support for Android got better in Qt6
# CLAYGROUND PLUGINS, TOOLS AND EXAMPLES
add_subdirectory (plugins)
if(NOT ANDROID)
add_subdirectory (tools)
add_subdirectory (examples)
endif()
add_subdirectory (examples)
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,42 @@ Main components:
### Plugins: Clayground's basic building blocks
Clayground comes with a set of plugins that extend Qt capabilities in order to
build interactive experiences:
- Physics/Box2D: Adds 2D Physics capabilities
- Text: Utilities and components to process (CSV, JSON) and present text
- Physics: Adds 2D Physics capabilities based on Box2D
- Canvas: A canvas component that provides a 2D virtual/world coordinate
system tries to hide dealing with pixels as much as possible.
- SVG Utils: Allows inspection of (Inkscape based) SVGs, can be used to create 2d scenes
- GameController: Supports game input using three different sources GamePad, Keyboard and Touch Screen with single component.
system, tries to hide dealing with pixels as much as possible.
- SVG: Allows inspection of (Inkscape based) SVGs, can be used to create 2d scenes
- GameController: Supports game input using two different sources Keyboard and Touch Screen with single component (unfortunately Qt6 doesn't support Qt Gamepad yet(?))
- Storage: Get persistent storage with a very simple API
- World: Uses Canvas, Physics and SVG to provide a foundation for small games and simulations
- Behavior: Collection of components that allow define entity behavior (Move, FollowPath ...)
- Network: Simple networking with automatic detection of other nodes and high-level peer to peer messaging

### Examples: See how problems can be solved with Clayground
A bunch of example application allow you to try it out easily:
- GUI: Visual training app for keyboard shortcuts, comes with a configuration for Inkscape.
- VisualFX: Implementation of different visual effects, includes usage of the [Qt Particle System](https://doc.qt.io/qt-5/qtquick-effects-particles.html).
- VisualFX: Implementation of different visual effects, includes usage of the [Qt Particle System](https://doc.qt.io/qt-6/qtquick-effects-particles.html).
- Platformer: Starting point for a platformer game.
- TopDown: Starting point for a topdown game (for example a classical RPG), comes with network support
- PluginLive: Demonstrates how to use the Clayground LiveLoader to develop a C++ plugin

### How to work with a sandbox?
1. Clone this repo and build it (Qt 6.2.2 or higher, Qt Creator). Make sure to pull the submodules `git submodule update --recursive --init`
2. Start the dojo app `claydojo --sbx=<clone-dir>/sandboxes/void/Sandbox.qml`
3. Move the window to a location that allows you to keep it visible even when your are editing code.
1. Clone this repo and build it using CMake (Qt 6.3.0+, Qt Creator 7.0.0+). Make sure to pull the submodules `git submodule update --recursive --init`
2. Start the dojo app `claydojo --sbx <clone-dir>/sandboxes/void/Sandbox.qml`
3. Move the created windows to a location that allows you to keep them visible even when your are editing code.
4. Make changes to `<clone-dir>/sandboxes/void/Sandbox.qml` -> see the changes applied automatically
5. Press `G` in the app window to show the Guide/Help overlay.
5. Press `Ctrl+G` in the app window to show the Guide/Help overlay.
6. Check out the other sandboxes in the same way :)

### How to work with multiple sandboxes?
If you pass multiple `--sbx` args (up to 5) to the dojo app, you can switch between them by using `Ctrl+(1|2|3|4|5)`.
Alternatively, you can just edit one sandbox file and the dojo app will change to the sandbox automatically if needed.
This allows you for example to work on a complete app using one `sbx` and quickly doing isolated experiments with a
minimal `sbx` like `examples/void/Sandbox.qml`.

#### Using the Logging Overlay
The sandbox comes with a logging overlay that shows all `console.log(...)` messages in a continous log view and watched properties/expressions in a sticky section. You can
easily show/hide the logging overlay by pressing `L` when the Sandbox Window has the focus.
easily show/hide the logging overlay by pressing `Ctrl+L` when the Sandbox Window has the focus.

<img src="res/log_overlay.png" width="50%" height="50%" alt="LogOverlay Screenshot">

Expand Down
72 changes: 58 additions & 14 deletions cmake/clayexample.cmake
Original file line number Diff line number Diff line change
@@ -1,29 +1,73 @@
# (c) Clayground Contributors - MIT License, see "LICENSE" file
include(CMakeParseArguments)

function(clay_example EXAMPLE_NAME)
macro(clay_example EXAMPLE_NAME)

cmake_minimum_required(VERSION 3.16)
set (oneValueArgs VERSION)
set (multiValueArgs SOURCES QML_FILES RES_FILES)
cmake_parse_arguments(CLAYEXAMPLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

project (${EXAMPLE_NAME})
cmake_minimum_required(VERSION 3.16)
project (${EXAMPLE_NAME} VERSION ${CLAYEXAMPLE_VERSION})

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Core Quick)

configure_file(${CMAKE_SOURCE_DIR}/cmake/main_example.cpp.in main.cpp)
add_executable (${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}/main.cpp res.qrc)
set(example_templ_dir ${CLAY_CMAKE_SCRIPT_DIR}/example_app)
set(CLAYGROUND_IMPORT_PLUGINS $CACHE{CLAYGROUND_IMPORT_PLUGINS})
if(${CLAYGROUND_IMPORT_PLUGINS})
string(REPLACE " " "\n" CLAYGROUND_IMPORT_PLUGINS ${CLAYGROUND_IMPORT_PLUGINS})
endif()

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt::Core
Qt::Quick
configure_file(${example_templ_dir}/main.cpp.in main.cpp)
qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION
${CMAKE_CURRENT_BINARY_DIR}/main.cpp
${CLAYEXAMPLE_SOURCES} )

qt_add_qml_module(${PROJECT_NAME}
URI ${PROJECT_NAME}
VERSION ${CLAYEXAMPLE_VERSION}
QML_FILES ${CLAYEXAMPLE_QML_FILES}
RESOURCES ${CLAYEXAMPLE_RES_FILES}
)

add_test(NAME test${PROJECT_NAME} COMMAND ${PROJECT_NAME})
set_tests_properties(test${PROJECT_NAME} PROPERTIES
ENVIRONMENT "QSG_INFO=1;QT_OPENGL=software;QT_QPA_PLATFORM=minimal"
target_compile_definitions(${PROJECT_NAME}
PRIVATE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
$<$<STREQUAL:"${CLAYPLUGIN_LINKING}","STATIC">:CLAYPLUGIN_LINKING_STATIC>
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt::Core
Qt::Quick
$CACHE{CLAYGROUND_STATIC_PLUGINS})

if (NOT ANDROID)
add_test(NAME test${PROJECT_NAME} COMMAND ${PROJECT_NAME})
set_tests_properties(test${PROJECT_NAME} PROPERTIES
ENVIRONMENT "QSG_INFO=1;QT_OPENGL=software;QT_QPA_PLATFORM=minimal"
)
else()
set(CLAY_APP_TARGET "${PROJECT_NAME}")
set(CLAY_APP_VERSION "${CLAYEXAMPLE_VERSION}")
set(android_templ_dir ${example_templ_dir}/android)
configure_file(${android_templ_dir}/android_manifest.xml.in android/AndroidManifest.xml)
if (NOT CLAY_ANDROID_BUILD_TOOLS_VERSION STREQUAL "DO_NOT_USE")
configure_file(${android_templ_dir}/gradle.properties.in android/gradle.properties)
endif()
file(COPY ${android_templ_dir}/res DESTINATION android)
set_target_properties(${PROJECT_NAME} PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/android)
endif()

endfunction()
qt_import_qml_plugins(${PROJECT_NAME})
qt_finalize_executable(${PROJECT_NAME})
endmacro()
25 changes: 23 additions & 2 deletions cmake/clayplugin.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Thanks to https://github.com/xarxer/cmake-qmlplugin for inspiration
# (c) Clayground Contributors - MIT License, see "LICENSE" file
include(CMakeParseArguments)

# Thanks to https://github.com/xarxer/cmake-qmlplugin for initial inspiration

# TODO Think about to get rid of this function completly as soon
# as Qt6.3 has been released and qt_add_qml_module is more mature
function(clay_p PLUGIN_NAME)
Expand All @@ -12,17 +14,19 @@ function(clay_p PLUGIN_NAME)
set(multiValueArgs SOURCES QML_FILES LINK_LIBS)
cmake_parse_arguments(CLAYPLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

extend_static_plugin_cfg("Clay${PLUGIN_NAME}plugin" "Clayground_${PLUGIN_NAME}Plugin")

if(NOT CLAYPLUGIN_DEST_DIR AND NOT CLAYPLUGIN_URI)
set(CLAYPLUGIN_DEST_DIR "${CLAY_PLUGIN_BASE_DIR}/${PLUGIN_NAME}")
set(CLAYPLUGIN_URI "Clayground.${PLUGIN_NAME}")
set(PLUGIN_NAME "Clay${PLUGIN_NAME}")
message("Fix names: ${PLUGIN_NAME} ${CLAYPLUGIN_DEST_DIR} ${CLAYPLUGIN_URI}")
endif()

qt_add_qml_module(${PLUGIN_NAME}
URI ${CLAYPLUGIN_URI}
OUTPUT_DIRECTORY ${CLAYPLUGIN_DEST_DIR}
VERSION ${CLAYPLUGIN_VERSION}
${CLAYPLUGIN_LINKING}
SOURCES ${CLAYPLUGIN_SOURCES}
QML_FILES ${CLAYPLUGIN_QML_FILES}
NO_CACHEGEN
Expand All @@ -32,3 +36,20 @@ function(clay_p PLUGIN_NAME)
target_link_libraries(${PLUGIN_NAME} PRIVATE ${CLAYPLUGIN_LINK_LIBS})

endfunction()


function(init_static_plugin_cfg)
set(CLAYGROUND_STATIC_PLUGINS "" CACHE INTERNAL "")
set(CLAYGROUND_IMPORT_PLUGINS "" CACHE INTERNAL "")
if ("${CLAYPLUGIN_LINKING}" STREQUAL "STATIC")
set(CLAYGROUND_IMPORT_PLUGINS "#include<QtQml/qqmlextensionplugin.h>" CACHE INTERNAL "")
endif()
endfunction()


function(extend_static_plugin_cfg plugin_target plugin_import)
if ("${CLAYPLUGIN_LINKING}" STREQUAL "STATIC")
set(CLAYGROUND_STATIC_PLUGINS "${CLAYGROUND_STATIC_PLUGINS};${plugin_target}" CACHE INTERNAL "")
set(CLAYGROUND_IMPORT_PLUGINS "${CLAYGROUND_IMPORT_PLUGINS} Q_IMPORT_QML_PLUGIN(${plugin_import})" CACHE INTERNAL "")
endif()
endfunction()
45 changes: 45 additions & 0 deletions cmake/example_app/android/android_manifest.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="clayground.examples.${CLAY_APP_TARGET}"
android:installLocation="auto"
android:versionCode="1"
android:versionName="${CLAY_APP_VERSION}">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"/>

<application android:name="org.qtproject.qt.android.bindings.QtApplication"
android:extractNativeLibs="true"
android:hardwareAccelerated="true"
android:label="${CLAY_APP_TARGET}"
android:requestLegacyExternalStorage="true"
android:allowNativeHeapPointerTagging="false"
android:icon="@drawable/icon">

<activity android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:label="${CLAY_APP_TARGET}"
android:launchMode="singleTop"
android:screenOrientation="unspecified">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<meta-data android:name="android.app.lib_name" android:value="${CLAY_APP_TARGET}"/>
<meta-data android:name="android.app.arguments" android:value=""/>
<meta-data android:name="android.app.extract_android_style" android:value="minimal"/>

</activity>

</application>

</manifest>

Loading

0 comments on commit aad6510

Please sign in to comment.