mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-20 01:34:04 +01:00
Add default Godot project with GDExtension
Add Godot Editor download Add Godot Editor start in launch.json
This commit is contained in:
parent
410920df9c
commit
7ecbd2e8d1
1
.gitignore
vendored
1
.gitignore
vendored
@ -261,3 +261,4 @@ cython_debug/
|
||||
/ThirdParty/qml-archive/**
|
||||
/ThirdParty/qml-plausible/
|
||||
/ThirdParty/ffmpeg/**
|
||||
/Tools/Apps/Godot/*
|
||||
|
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
[submodule "ScreenPlayWallpaper/Godot/GDExtention/extern/godot-cpp"]
|
||||
path = ScreenPlayWallpaper/Godot/GDExtention/extern/godot-cpp
|
||||
url = https://github.com/godotengine/godot-cpp.git
|
||||
branch = 4.1
|
14
.vscode/launch.json
vendored
14
.vscode/launch.json
vendored
@ -22,6 +22,20 @@
|
||||
],
|
||||
"visualizerFile": "${workspaceFolder}/.vscode/qt.natvis.xml"
|
||||
},
|
||||
{
|
||||
"name": "Godot Editor",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}\\Tools\\Apps\\Godot\\Godot_v4.1.1-stable_win64.exe",
|
||||
"args": [
|
||||
"--path",
|
||||
"${workspaceFolder}\\ScreenPlayWallpaper\\Godot\\ScreenPlayGodot",
|
||||
"--editor"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"preLaunchTask": "CMake: build",
|
||||
"externalConsole": false
|
||||
},
|
||||
{
|
||||
"name": "macOS Launch",
|
||||
"type": "lldb",
|
||||
|
@ -27,6 +27,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(THIRD_PARTY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/")
|
||||
|
||||
option(GODOT_WALLPAPER "Godot Wallpaper support" ON)
|
||||
option(OSX_BUNDLE "Enable distribution macOS bundle" OFF)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0")
|
||||
|
||||
@ -122,6 +123,10 @@ add_subdirectory(ScreenPlayWidget)
|
||||
add_subdirectory(ScreenPlayUtil)
|
||||
add_subdirectory(ScreenPlayWeather)
|
||||
|
||||
if(GODOT_WALLPAPER)
|
||||
add_subdirectory(ScreenPlayWallpaper/Godot/GDExtention)
|
||||
endif()
|
||||
|
||||
if(${SCREENPLAY_TESTS})
|
||||
enable_testing()
|
||||
endif()
|
||||
|
128
ScreenPlayWallpaper/Godot/GDExtention/CMakeLists.txt
Normal file
128
ScreenPlayWallpaper/Godot/GDExtention/CMakeLists.txt
Normal file
@ -0,0 +1,128 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
cmake_minimum_required( VERSION 3.22 )
|
||||
|
||||
message( STATUS "Using CMake ${CMAKE_VERSION}" )
|
||||
|
||||
# Require out-of-source builds
|
||||
file( TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH )
|
||||
|
||||
if ( EXISTS "${LOC_PATH}" )
|
||||
message( FATAL_ERROR "You cannot build in the source directory. Please use a build subdirectory." )
|
||||
endif()
|
||||
|
||||
# Add paths to modules
|
||||
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
|
||||
|
||||
# Turn on link time optimization for everything
|
||||
set( CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON )
|
||||
|
||||
# Output compile commands to compile_commands.json (for debugging CMake issues)
|
||||
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
|
||||
|
||||
# Build universal lib on macOS
|
||||
# Note that CMAKE_OSX_ARCHITECTURES must be set before project().
|
||||
if ( APPLE )
|
||||
set( CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" )
|
||||
endif()
|
||||
|
||||
# Main project information
|
||||
project( GDExtensionTemplate
|
||||
LANGUAGES
|
||||
CXX
|
||||
VERSION
|
||||
0.1.0
|
||||
)
|
||||
|
||||
# Create our library
|
||||
add_library( ${PROJECT_NAME} SHARED )
|
||||
|
||||
target_compile_features( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
cxx_std_17
|
||||
)
|
||||
|
||||
# LIB_ARCH is the architecture being built. It is set to the build system's architecture.
|
||||
# For macOS, we build a universal library (both arm64 and x86_64).
|
||||
set( LIB_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
|
||||
if ( APPLE )
|
||||
set( LIB_ARCH "universal" )
|
||||
endif()
|
||||
|
||||
# LIB_DIR is where the actual library ends up. This is used in both the build directory and the
|
||||
# install directory and needs to be consistent with the paths in the gdextension file.
|
||||
# e.g. linux.release.x86_64 = "lib/Linux-x86_64/libGDExtensionTemplate.so"
|
||||
set( LIB_DIR "lib/${CMAKE_SYSTEM_NAME}-${LIB_ARCH}" )
|
||||
|
||||
message( STATUS "Building ${PROJECT_NAME} for ${LIB_ARCH} on ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
# BUILD_OUTPUT_DIR is where we put the resulting library (in the build directory)
|
||||
set( BUILD_OUTPUT_DIR "${PROJECT_BINARY_DIR}/${PROJECT_NAME}/" )
|
||||
|
||||
set_target_properties( ${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
VISIBILITY_INLINES_HIDDEN true
|
||||
RUNTIME_OUTPUT_DIRECTORY "${BUILD_OUTPUT_DIR}/${LIB_DIR}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_DIR}/${LIB_DIR}"
|
||||
)
|
||||
|
||||
if( NOT DEFINED CMAKE_DEBUG_POSTFIX )
|
||||
set_target_properties( ${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
DEBUG_POSTFIX "-d"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Warnings
|
||||
include( CompilerWarnings )
|
||||
|
||||
# Create and include version info file from git
|
||||
include( GitVersionInfo )
|
||||
|
||||
add_subdirectory( src )
|
||||
|
||||
# Install library and extension file in ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}
|
||||
set( INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/" )
|
||||
|
||||
message( STATUS "Install directory: ${INSTALL_DIR}")
|
||||
|
||||
install( TARGETS ${PROJECT_NAME}
|
||||
LIBRARY
|
||||
DESTINATION ${INSTALL_DIR}/${LIB_DIR}
|
||||
RUNTIME
|
||||
DESTINATION ${INSTALL_DIR}/${LIB_DIR}
|
||||
)
|
||||
|
||||
add_subdirectory( templates )
|
||||
|
||||
# ccache
|
||||
# Turns on ccache if found
|
||||
include( ccache )
|
||||
|
||||
# Formatting
|
||||
# Adds a custom target to format all the code at once
|
||||
include( ClangFormat )
|
||||
|
||||
# godot-cpp
|
||||
# From here: https://github.com/godotengine/godot-cpp
|
||||
if ( NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/extern/godot-cpp/Makefile" )
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"[${PROJECT_NAME}] The godot-cpp submodule was not downloaded. Please update submodules: git submodule update --init --recursive."
|
||||
)
|
||||
endif()
|
||||
|
||||
set( GODOT_CPP_SYSTEM_HEADERS ON CACHE BOOL "" FORCE )
|
||||
|
||||
add_subdirectory( extern/godot-cpp )
|
||||
|
||||
set_target_properties( godot-cpp
|
||||
PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden # visibility needs to be the same as the main library
|
||||
)
|
||||
|
||||
target_link_libraries( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
godot-cpp
|
||||
)
|
87
ScreenPlayWallpaper/Godot/GDExtention/CMakePresets.json
Normal file
87
ScreenPlayWallpaper/Godot/GDExtention/CMakePresets.json
Normal file
@ -0,0 +1,87 @@
|
||||
{
|
||||
"version": 5,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "default",
|
||||
"description": "Default preset that are inherited by all",
|
||||
"generator": "Ninja",
|
||||
"hidden": true,
|
||||
"binaryDir": "${sourceDir}/../build_MyGodotProject"
|
||||
},
|
||||
{
|
||||
"name": "default-windows",
|
||||
"displayName": "64bit Windows",
|
||||
"description": "Windows only!",
|
||||
"inherits": "default",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"toolset": {
|
||||
"value": "host=x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl.exe",
|
||||
"CMAKE_CXX_COMPILER": "cl.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-debug",
|
||||
"displayName": "64bit Debug Linux",
|
||||
"description": "Linux only!",
|
||||
"generator": "Ninja",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_COMPILER": "g++",
|
||||
"CMAKE_C_COMPILER": "gcc",
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "osx-debug",
|
||||
"displayName": "64bit Debug osx",
|
||||
"description": "Osx only!",
|
||||
"generator": "Ninja",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "linux-debug",
|
||||
"configurePreset": "linux-debug"
|
||||
},
|
||||
{
|
||||
"name": "default-windows",
|
||||
"configurePreset": "default-windows"
|
||||
},
|
||||
{
|
||||
"name": "osx-debug",
|
||||
"configurePreset": "osx-debug"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
find_program( CLANG_FORMAT_PROGRAM NAMES clang-format )
|
||||
|
||||
if ( CLANG_FORMAT_PROGRAM )
|
||||
# get version information
|
||||
execute_process(
|
||||
COMMAND "${CLANG_FORMAT_PROGRAM}" --version
|
||||
OUTPUT_VARIABLE CLANG_FORMAT_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
message( STATUS "Using clang-format: ${CLANG_FORMAT_PROGRAM} (${CLANG_FORMAT_VERSION})" )
|
||||
|
||||
get_target_property( CLANG_FORMAT_SOURCES ${PROJECT_NAME} SOURCES )
|
||||
|
||||
# Remove some files from the list
|
||||
list( FILTER CLANG_FORMAT_SOURCES EXCLUDE REGEX ".*/extern/.*" )
|
||||
list( FILTER CLANG_FORMAT_SOURCES EXCLUDE REGEX ".*/gen/.*" )
|
||||
list( FILTER CLANG_FORMAT_SOURCES EXCLUDE REGEX ".*/*.gdextension.in" )
|
||||
list( FILTER CLANG_FORMAT_SOURCES EXCLUDE REGEX ".*/Version.h.in" )
|
||||
|
||||
add_custom_target( clang-format
|
||||
COMMAND "${CLANG_FORMAT_PROGRAM}" --style=file -i ${CLANG_FORMAT_SOURCES}
|
||||
COMMENT "Running clang-format..."
|
||||
COMMAND_EXPAND_LISTS
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
unset( CLANG_FORMAT_VERSION )
|
||||
unset( CLANG_FORMAT_SOURCES )
|
||||
endif()
|
@ -0,0 +1,115 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
# by Andy Maloney <asmaloney@gmail.com>
|
||||
|
||||
string( TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE )
|
||||
|
||||
if ( NOT MSVC )
|
||||
option( ${PROJECT_NAME_UPPERCASE}_WARN_EVERYTHING "Turn on all warnings (not recommended - used for lib development)" OFF )
|
||||
endif()
|
||||
|
||||
option( ${PROJECT_NAME_UPPERCASE}_WARNING_AS_ERROR "Treat warnings as errors" ON )
|
||||
|
||||
# Add warnings based on compiler
|
||||
# Set some helper variables for readability
|
||||
set( compiler_is_clang "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>" )
|
||||
set( compiler_is_gnu "$<CXX_COMPILER_ID:GNU>" )
|
||||
set( compiler_is_msvc "$<CXX_COMPILER_ID:MSVC>" )
|
||||
|
||||
target_compile_options( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
# MSVC only
|
||||
$<${compiler_is_msvc}:
|
||||
/W4
|
||||
|
||||
/w14263 # 'function': member function does not override any base class virtual member function
|
||||
/w14296 # 'operator': expression is always 'boolean_value'
|
||||
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
|
||||
/w14545 # expression before comma evaluates to a function which is missing an argument list
|
||||
/w14546 # function call before comma missing argument list
|
||||
/w14547 # 'operator': operator before comma has no effect; expected operator with side-effect
|
||||
/w14549 # 'operator': operator before comma has no effect; did you intend 'operator'?
|
||||
/w14619 # pragma warning: there is no warning number 'number'
|
||||
/w14640 # thread un-safe static member initialization
|
||||
/w14905 # wide string literal cast to 'LPSTR'
|
||||
/w14906 # string literal cast to 'LPWSTR'
|
||||
|
||||
# Disable warnings which bleed through from godot-cpp's macros.
|
||||
/wd4100 # unreferenced formal parameter
|
||||
>
|
||||
|
||||
# Clang and GNU
|
||||
$<$<OR:${compiler_is_clang},${compiler_is_gnu}>:
|
||||
-Wall
|
||||
-Wcast-align
|
||||
-Wctor-dtor-privacy
|
||||
-Wextra
|
||||
-Wformat=2
|
||||
-Wnon-virtual-dtor
|
||||
-Wnull-dereference
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wunused
|
||||
-Wwrite-strings
|
||||
|
||||
# Disable warnings which bleed through from godot-cpp's macros.
|
||||
-Wno-unused-parameter
|
||||
>
|
||||
|
||||
# Clang only
|
||||
$<${compiler_is_clang}:
|
||||
-Wdocumentation
|
||||
-Wimplicit-fallthrough
|
||||
>
|
||||
|
||||
# GNU only
|
||||
$<${compiler_is_gnu}:
|
||||
-Walloc-zero
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Wlogical-op
|
||||
>
|
||||
)
|
||||
|
||||
# Turn on (almost) all warnings on Clang, Apple Clang, and GNU.
|
||||
# Useful for internal development, but too noisy for general development.
|
||||
function( set_warn_everything )
|
||||
message( STATUS "[${PROJECT_NAME}] Turning on (almost) all warnings")
|
||||
|
||||
target_compile_options( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
# Clang and GNU
|
||||
$<$<OR:${compiler_is_clang},${compiler_is_gnu}>:
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-padded
|
||||
>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
if ( NOT MSVC AND ${PROJECT_NAME_UPPERCASE}_WARN_EVERYTHING )
|
||||
set_warn_everything()
|
||||
endif()
|
||||
|
||||
# Treat warnings as errors
|
||||
function( set_warning_as_error )
|
||||
message( STATUS "[${PROJECT_NAME}] Treating warnings as errors")
|
||||
|
||||
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.24" )
|
||||
set_target_properties( ${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
COMPILE_WARNING_AS_ERROR ON
|
||||
)
|
||||
else()
|
||||
target_compile_options( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<${compiler_is_msvc}:/WX>
|
||||
$<$<OR:${compiler_is_clang},${compiler_is_gnu}>:-Werror>
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if ( ${PROJECT_NAME_UPPERCASE}_WARNING_AS_ERROR )
|
||||
set_warning_as_error()
|
||||
endif()
|
@ -0,0 +1,284 @@
|
||||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_describe_working_tree(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the working tree (--dirty option),
|
||||
# and adjusting the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# git_local_changes(<var>)
|
||||
#
|
||||
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
|
||||
# Uses the return code of "git diff-index --quiet HEAD --".
|
||||
# Does not regard untracked files.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
#
|
||||
# Copyright 2009-2013, Iowa State University.
|
||||
# Copyright 2013-2020, Ryan Pavlik
|
||||
# Copyright 2013-2020, Contributors
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
# Function _git_find_closest_git_dir finds the next closest .git directory
|
||||
# that is part of any directory in the path defined by _start_dir.
|
||||
# The result is returned in the parent scope variable whose name is passed
|
||||
# as variable _git_dir_var. If no .git directory can be found, the
|
||||
# function returns an empty string via _git_dir_var.
|
||||
#
|
||||
# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
|
||||
# neither foo nor bar contain a file/directory .git. This wil return
|
||||
# C:/bla/.git
|
||||
#
|
||||
function(_git_find_closest_git_dir _start_dir _git_dir_var)
|
||||
set(cur_dir "${_start_dir}")
|
||||
set(git_dir "${_start_dir}/.git")
|
||||
while(NOT EXISTS "${git_dir}")
|
||||
# .git dir not found, search parent directories
|
||||
set(git_previous_parent "${cur_dir}")
|
||||
get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
|
||||
if(cur_dir STREQUAL git_previous_parent)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_git_dir_var}
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(git_dir "${cur_dir}/.git")
|
||||
endwhile()
|
||||
set(${_git_dir_var}
|
||||
"${git_dir}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
|
||||
|
||||
if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
|
||||
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
|
||||
else()
|
||||
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
|
||||
endif()
|
||||
if(NOT "${GIT_DIR}" STREQUAL "")
|
||||
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
|
||||
"${GIT_DIR}")
|
||||
if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
|
||||
# We've gone above the CMake root dir.
|
||||
set(GIT_DIR "")
|
||||
endif()
|
||||
endif()
|
||||
if("${GIT_DIR}" STREQUAL "")
|
||||
set(${_refspecvar}
|
||||
"GITDIR-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
set(${_hashvar}
|
||||
"GITDIR-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check if the current source dir is a git submodule or a worktree.
|
||||
# In both cases .git is a file instead of a directory.
|
||||
#
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
# The following git command will return a non empty string that
|
||||
# points to the super project working tree if the current
|
||||
# source dir is inside a git submodule.
|
||||
# Otherwise the command will return an empty string.
|
||||
#
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse
|
||||
--show-superproject-working-tree
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${out}" STREQUAL "")
|
||||
# If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
|
||||
${submodule})
|
||||
string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
|
||||
ABSOLUTE)
|
||||
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||
else()
|
||||
# GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree
|
||||
file(READ ${GIT_DIR} worktree_ref)
|
||||
# The .git directory contains a path to the worktree information directory
|
||||
# inside the parent git repo of the worktree.
|
||||
#
|
||||
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
|
||||
${worktree_ref})
|
||||
string(STRIP ${git_worktree_dir} git_worktree_dir)
|
||||
_git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
|
||||
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
|
||||
endif()
|
||||
else()
|
||||
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${HEAD_SOURCE_FILE}")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake" @ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar}
|
||||
"${HEAD_REF}"
|
||||
PARENT_SCOPE)
|
||||
set(${_hashvar}
|
||||
"${HEAD_HASH}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe_working_tree _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_local_changes _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(res EQUAL 0)
|
||||
set(${_var}
|
||||
"CLEAN"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
set(${_var}
|
||||
"DIRTY"
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
@ -0,0 +1,43 @@
|
||||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright 2009-2012, Iowa State University
|
||||
# Copyright 2011-2015, Contributors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
@ -0,0 +1,46 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
find_program( GIT_PROGRAM git )
|
||||
|
||||
if ( GIT_PROGRAM )
|
||||
# get version information
|
||||
execute_process(
|
||||
COMMAND "${GIT_PROGRAM}" --version
|
||||
OUTPUT_VARIABLE GIT_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
message( STATUS "Using git: ${GIT_PROGRAM} (${GIT_VERSION})" )
|
||||
|
||||
include( GetGitRevisionDescription )
|
||||
|
||||
get_git_head_revision( GIT_REFSPEC GIT_SHA1 )
|
||||
git_describe( GIT_SHORT )
|
||||
|
||||
string( TOUPPER ${PROJECT_NAME} UPPER_PROJECT_NAME )
|
||||
|
||||
set( VERSION_INPUT_FILE "src/Version.h.in" )
|
||||
set( VERSION_OUTPUT_FILE "${CMAKE_BINARY_DIR}/gen/Version.h" )
|
||||
|
||||
configure_file( "${VERSION_INPUT_FILE}" "${VERSION_OUTPUT_FILE}" )
|
||||
|
||||
target_sources( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"${VERSION_INPUT_FILE}"
|
||||
"${VERSION_OUTPUT_FILE}"
|
||||
)
|
||||
|
||||
get_filename_component( VERSION_OUTPUT_FILE_DIR ${VERSION_OUTPUT_FILE} DIRECTORY )
|
||||
|
||||
target_include_directories( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${VERSION_OUTPUT_FILE_DIR}
|
||||
)
|
||||
|
||||
message( STATUS "${PROJECT_NAME} version: ${GIT_SHORT}" )
|
||||
|
||||
unset( VERSION_INPUT_FILE )
|
||||
unset( VERSION_OUTPUT_FILE )
|
||||
unset( VERSION_OUTPUT_FILE_DIR )
|
||||
unset( GIT_VERSION )
|
||||
endif()
|
22
ScreenPlayWallpaper/Godot/GDExtention/cmake/ccache.cmake
Normal file
22
ScreenPlayWallpaper/Godot/GDExtention/cmake/ccache.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# See: https://crascit.com/2016/04/09/using-ccache-with-cmake/
|
||||
find_program( CCACHE_PROGRAM ccache )
|
||||
|
||||
if ( CCACHE_PROGRAM )
|
||||
# get version information
|
||||
execute_process(
|
||||
COMMAND "${CCACHE_PROGRAM}" --version
|
||||
OUTPUT_VARIABLE CCACHE_VERSION
|
||||
)
|
||||
|
||||
string( REGEX MATCH "[^\r\n]*" CCACHE_VERSION ${CCACHE_VERSION} )
|
||||
|
||||
message( STATUS "Using ccache: ${CCACHE_PROGRAM} (${CCACHE_VERSION})" )
|
||||
|
||||
# Turn on ccache for all targets
|
||||
set( CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" )
|
||||
set( CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" )
|
||||
|
||||
unset( CCACHE_VERSION )
|
||||
endif()
|
1
ScreenPlayWallpaper/Godot/GDExtention/extern/godot-cpp
vendored
Submodule
1
ScreenPlayWallpaper/Godot/GDExtention/extern/godot-cpp
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 28494f0bd59f9c35289524e503648ed8b4baaa59
|
15
ScreenPlayWallpaper/Godot/GDExtention/src/CMakeLists.txt
Normal file
15
ScreenPlayWallpaper/Godot/GDExtention/src/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
target_sources( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
ScreenPlayWallpaper.h
|
||||
ScreenPlayWallpaper.cpp
|
||||
GDExtensionTemplate.h
|
||||
GDExtensionTemplate.cpp
|
||||
RegisterExtension.cpp
|
||||
)
|
||||
|
||||
target_include_directories( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"src"
|
||||
)
|
@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
|
||||
#include "GDExtensionTemplate.h"
|
||||
#include "Version.h"
|
||||
|
||||
/// @file
|
||||
/// GDExtensionTemplate example implementation.
|
||||
|
||||
/*!
|
||||
@brief Get the version string for this extension.
|
||||
|
||||
@details
|
||||
The version string is generated by cmake using src/Version.h.in.
|
||||
|
||||
It uses the form "<project name> <last tag>-<# commits since last tag>-<short commit hash>".
|
||||
If there are no commits since the last tag, only the tag is shown.
|
||||
|
||||
@return The version string (e.g. "Foo v1.2.3-gdedbd01").
|
||||
*/
|
||||
godot::String GDExtensionTemplate::version()
|
||||
{
|
||||
return VersionInfo::VERSION_STR.data();
|
||||
}
|
||||
|
||||
/// Bind our methods so GDScript can access them.
|
||||
void GDExtensionTemplate::_bind_methods()
|
||||
{
|
||||
godot::ClassDB::bind_static_method( "GDExtensionTemplate", godot::D_METHOD( "version" ),
|
||||
&GDExtensionTemplate::version );
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
#include "godot_cpp/classes/object.hpp"
|
||||
|
||||
namespace godot
|
||||
{
|
||||
class ClassDB;
|
||||
};
|
||||
|
||||
class GDExtensionTemplate : public godot::Object
|
||||
{
|
||||
GDCLASS( GDExtensionTemplate, godot::Object )
|
||||
|
||||
public:
|
||||
static godot::String version();
|
||||
|
||||
private:
|
||||
static void _bind_methods();
|
||||
};
|
@ -0,0 +1,74 @@
|
||||
// Copied from godot-cpp/test/src and modified.
|
||||
|
||||
#include "gdextension_interface.h"
|
||||
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/core/defs.hpp"
|
||||
#include "godot_cpp/godot.hpp"
|
||||
|
||||
#include "GDExtensionTemplate.h"
|
||||
#include "ScreenPlayWallpaper.h"
|
||||
|
||||
/// @file
|
||||
/// Register our classes with Godot.
|
||||
|
||||
namespace {
|
||||
/// @brief Called by Godot to let us register our classes with Godot.
|
||||
///
|
||||
/// @param p_level the level being initialized by Godot
|
||||
///
|
||||
/// @see GDExtensionInit
|
||||
void initializeExtension(godot::ModuleInitializationLevel p_level)
|
||||
{
|
||||
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
return;
|
||||
}
|
||||
|
||||
godot::ClassDB::register_class<ScreenPlayWallpaper>();
|
||||
godot::ClassDB::register_class<ExampleMin>();
|
||||
godot::ClassDB::register_class<Example>();
|
||||
godot::ClassDB::register_class<ExampleVirtual>(true);
|
||||
godot::ClassDB::register_abstract_class<ExampleAbstract>();
|
||||
|
||||
godot::ClassDB::register_class<GDExtensionTemplate>();
|
||||
}
|
||||
|
||||
/// @brief Called by Godot to let us do any cleanup.
|
||||
///
|
||||
/// @see GDExtensionInit
|
||||
void uninitializeExtension(godot::ModuleInitializationLevel p_level)
|
||||
{
|
||||
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
/// @brief This is the entry point for the shared library.
|
||||
///
|
||||
/// @note The name of this function must match the "entry_symbol" in
|
||||
/// templates/template.*.gdextension.in
|
||||
///
|
||||
/// @param p_get_proc_address the interface (need more info)
|
||||
/// @param p_library the library (need more info)
|
||||
/// @param r_initialization the intialization (need more info)
|
||||
///
|
||||
/// @returns GDExtensionBool
|
||||
GDExtensionBool GDE_EXPORT GDExtensionInit(
|
||||
GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library,
|
||||
GDExtensionInitialization* r_initialization)
|
||||
{
|
||||
{
|
||||
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library,
|
||||
r_initialization);
|
||||
|
||||
init_obj.register_initializer(initializeExtension);
|
||||
init_obj.register_terminator(uninitializeExtension);
|
||||
init_obj.set_minimum_library_initialization_level(
|
||||
godot::MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||
|
||||
return init_obj.init();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,475 @@
|
||||
// Copied from godot-cpp/test/src and modified.
|
||||
|
||||
#include "godot_cpp/classes/global_constants.hpp"
|
||||
#include "godot_cpp/classes/label.hpp"
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
|
||||
#include "ScreenPlayWallpaper.h"
|
||||
|
||||
// Used to mark unused parameters to indicate intent and suppress warnings.
|
||||
#define UNUSED(expr) (void)(expr)
|
||||
|
||||
namespace {
|
||||
constexpr int MAGIC_NUMBER = 42;
|
||||
}
|
||||
|
||||
//// ScreenPlayWallpaper
|
||||
|
||||
int ScreenPlayWallpaper::sInstanceCount = 0;
|
||||
int ScreenPlayWallpaper::sLastID = 0;
|
||||
|
||||
ScreenPlayWallpaper::ScreenPlayWallpaper()
|
||||
{
|
||||
mID = ++sLastID;
|
||||
sInstanceCount++;
|
||||
|
||||
godot::UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", godot::itos(mID),
|
||||
" created, current instance count: ", godot::itos(sInstanceCount));
|
||||
}
|
||||
|
||||
ScreenPlayWallpaper::~ScreenPlayWallpaper()
|
||||
{
|
||||
sInstanceCount--;
|
||||
godot::UtilityFunctions::print(
|
||||
"ScreenPlayWallpaper ", godot::itos(mID),
|
||||
" destroyed, current instance count: ", godot::itos(sInstanceCount));
|
||||
}
|
||||
|
||||
int ScreenPlayWallpaper::getID() const
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
|
||||
void ScreenPlayWallpaper::_bind_methods()
|
||||
{
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("get_id"), &ScreenPlayWallpaper::getID);
|
||||
}
|
||||
|
||||
//// ExampleMin
|
||||
|
||||
void ExampleMin::_bind_methods()
|
||||
{
|
||||
}
|
||||
|
||||
//// Example
|
||||
|
||||
Example::Example()
|
||||
{
|
||||
godot::UtilityFunctions::print("Constructor.");
|
||||
}
|
||||
|
||||
Example::~Example()
|
||||
{
|
||||
godot::UtilityFunctions::print("Destructor.");
|
||||
}
|
||||
|
||||
// Methods.
|
||||
void Example::simpleFunc()
|
||||
{
|
||||
godot::UtilityFunctions::print(" Simple func called.");
|
||||
}
|
||||
|
||||
void Example::simpleConstFunc() const
|
||||
{
|
||||
godot::UtilityFunctions::print(" Simple const func called.");
|
||||
}
|
||||
|
||||
godot::String Example::returnSomething(const godot::String& inBase)
|
||||
{
|
||||
godot::UtilityFunctions::print(" Return something called.");
|
||||
|
||||
return inBase;
|
||||
}
|
||||
|
||||
godot::Viewport* Example::returnSomethingConst() const
|
||||
{
|
||||
godot::UtilityFunctions::print(" Return something const called.");
|
||||
|
||||
if (is_inside_tree()) {
|
||||
godot::Viewport* result = get_viewport();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
godot::Ref<ScreenPlayWallpaper> Example::returnEmptyRef() const
|
||||
{
|
||||
godot::Ref<ScreenPlayWallpaper> ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
ScreenPlayWallpaper* Example::returnExtendedRef() const
|
||||
{
|
||||
// You can instance and return a refcounted object like this, but keep in mind that refcounting
|
||||
// starts with the returned object and it will be destroyed when all references are destroyed.
|
||||
// If you store this pointer you run the risk of having a pointer to a destroyed object.
|
||||
return memnew(ScreenPlayWallpaper());
|
||||
}
|
||||
|
||||
godot::Ref<ScreenPlayWallpaper> Example::extendedRefChecks(godot::Ref<ScreenPlayWallpaper> inRef) const
|
||||
{
|
||||
// This is the preferred way of instancing and returning a refcounted object:
|
||||
godot::Ref<ScreenPlayWallpaper> ref;
|
||||
ref.instantiate();
|
||||
|
||||
godot::UtilityFunctions::print(
|
||||
" Example ref checks called with value: ", inRef->get_instance_id(),
|
||||
", returning value: ", ref->get_instance_id());
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
godot::Variant Example::varargsFunc(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError)
|
||||
{
|
||||
UNUSED(inArgs);
|
||||
UNUSED(outError);
|
||||
|
||||
godot::UtilityFunctions::print(" Varargs (Variant return) called with ",
|
||||
godot::String::num_int64(inArgCount), " arguments");
|
||||
|
||||
return inArgCount;
|
||||
}
|
||||
|
||||
int Example::varargsFuncNonVoidReturn(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError)
|
||||
{
|
||||
UNUSED(inArgs);
|
||||
UNUSED(outError);
|
||||
|
||||
godot::UtilityFunctions::print(" Varargs (int return) called with ",
|
||||
godot::String::num_int64(inArgCount), " arguments");
|
||||
|
||||
return MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
void Example::varargsFuncVoidReturn(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError)
|
||||
{
|
||||
UNUSED(inArgs);
|
||||
UNUSED(outError);
|
||||
|
||||
godot::UtilityFunctions::print(" Varargs (no return) called with ",
|
||||
godot::String::num_int64(inArgCount), " arguments");
|
||||
}
|
||||
|
||||
void Example::emitCustomSignal(const godot::String& inName, int inValue)
|
||||
{
|
||||
emit_signal("custom_signal", inName, inValue);
|
||||
}
|
||||
|
||||
int Example::defArgs(int inA, int inB) const
|
||||
{
|
||||
return inA + inB;
|
||||
}
|
||||
|
||||
godot::Array Example::testArray() const
|
||||
{
|
||||
godot::Array arr;
|
||||
|
||||
arr.resize(2);
|
||||
arr[0] = godot::Variant(1);
|
||||
arr[1] = godot::Variant(2);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
void Example::testTypedArrayArg(const godot::TypedArray<int64_t>& inArray)
|
||||
{
|
||||
for (int i = 0; i < inArray.size(); ++i) {
|
||||
godot::UtilityFunctions::print(inArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Vector2> Example::testTypedArray() const
|
||||
{
|
||||
godot::TypedArray<godot::Vector2> arr;
|
||||
|
||||
arr.resize(2);
|
||||
arr[0] = godot::Vector2(1, 2);
|
||||
arr[1] = godot::Vector2(2, 3);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
godot::Dictionary Example::testDictionary() const
|
||||
{
|
||||
godot::Dictionary dict;
|
||||
|
||||
dict["hello"] = "world";
|
||||
dict["foo"] = "bar";
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
Example* Example::testNodeArgument(Example* inNode) const
|
||||
{
|
||||
// This should use godot::String::num_uint64(), but it is currently broken:
|
||||
// https://github.com/godotengine/godot-cpp/issues/1014
|
||||
godot::UtilityFunctions::print(
|
||||
" Test node argument called with ",
|
||||
(inNode != nullptr)
|
||||
? godot::String::num_int64(static_cast<int64_t>(inNode->get_instance_id()))
|
||||
: "null");
|
||||
return inNode;
|
||||
}
|
||||
|
||||
godot::String Example::testStringOps() const
|
||||
{
|
||||
godot::String s = godot::String("A");
|
||||
s += "B";
|
||||
s += "C";
|
||||
s += char32_t(0x010E);
|
||||
s = s + "E";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int Example::testVectorOps() const
|
||||
{
|
||||
godot::PackedInt32Array arr;
|
||||
arr.push_back(10);
|
||||
arr.push_back(20);
|
||||
arr.push_back(30);
|
||||
arr.push_back(45);
|
||||
|
||||
int ret = 0;
|
||||
for (const int32_t& E : arr) {
|
||||
ret += E;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
godot::BitField<Example::Flags> Example::testBitfield(godot::BitField<Flags> inFlags)
|
||||
{
|
||||
godot::UtilityFunctions::print(" Got BitField: ", godot::String::num_int64(inFlags));
|
||||
return inFlags;
|
||||
}
|
||||
|
||||
// Properties.
|
||||
void Example::setCustomPosition(const godot::Vector2& inPos)
|
||||
{
|
||||
mCustomPosition = inPos;
|
||||
}
|
||||
|
||||
godot::Vector2 Example::getCustomPosition() const
|
||||
{
|
||||
return mCustomPosition;
|
||||
}
|
||||
|
||||
godot::Vector4 Example::getV4() const
|
||||
{
|
||||
return { 1.2f, 3.4f, 5.6f, 7.8f };
|
||||
}
|
||||
|
||||
// Static methods
|
||||
int Example::testStatic(int inA, int inB)
|
||||
{
|
||||
return inA + inB;
|
||||
}
|
||||
|
||||
void Example::testStatic2()
|
||||
{
|
||||
godot::UtilityFunctions::print(" void static");
|
||||
}
|
||||
|
||||
// Virtual function override.
|
||||
bool Example::_has_point(const godot::Vector2& inPoint) const
|
||||
{
|
||||
auto* label = godot::Control::get_node<godot::Label>("Label");
|
||||
|
||||
label->set_text("Got point: " + godot::Variant(inPoint).stringify());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Example::_bind_methods()
|
||||
{
|
||||
// Methods.
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("simple_func"), &Example::simpleFunc);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("simple_const_func"),
|
||||
&Example::simpleConstFunc);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("return_something"), &Example::returnSomething);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("return_something_const"),
|
||||
&Example::returnSomethingConst);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("return_empty_ref"), &Example::returnEmptyRef);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("return_extended_ref"),
|
||||
&Example::returnExtendedRef);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("extended_ref_checks", "ref"),
|
||||
&Example::extendedRefChecks);
|
||||
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_array"), &Example::testArray);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_tarray_arg", "array"),
|
||||
&Example::testTypedArrayArg);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_tarray"), &Example::testTypedArray);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_dictionary"), &Example::testDictionary);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_node_argument"),
|
||||
&Example::testNodeArgument);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_string_ops"), &Example::testStringOps);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_vector_ops"), &Example::testVectorOps);
|
||||
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("test_bitfield", "flags"),
|
||||
&Example::testBitfield);
|
||||
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("def_args", "a", "b"), &Example::defArgs,
|
||||
DEFVAL(100), DEFVAL(200));
|
||||
|
||||
godot::ClassDB::bind_static_method("Example", godot::D_METHOD("test_static", "a", "b"),
|
||||
&Example::testStatic);
|
||||
godot::ClassDB::bind_static_method("Example", godot::D_METHOD("test_static2"),
|
||||
&Example::testStatic2);
|
||||
|
||||
{
|
||||
godot::MethodInfo mi;
|
||||
mi.arguments.emplace_back(godot::Variant::STRING, "some_argument");
|
||||
mi.name = "varargs_func";
|
||||
|
||||
godot::ClassDB::bind_vararg_method(godot::METHOD_FLAGS_DEFAULT, "varargs_func",
|
||||
&Example::varargsFunc, mi);
|
||||
}
|
||||
|
||||
{
|
||||
godot::MethodInfo mi;
|
||||
mi.arguments.emplace_back(godot::Variant::STRING, "some_argument");
|
||||
mi.name = "varargs_func_nv";
|
||||
|
||||
godot::ClassDB::bind_vararg_method(godot::METHOD_FLAGS_DEFAULT, "varargs_func_nv",
|
||||
&Example::varargsFuncNonVoidReturn, mi);
|
||||
}
|
||||
|
||||
{
|
||||
godot::MethodInfo mi;
|
||||
mi.arguments.emplace_back(godot::Variant::STRING, "some_argument");
|
||||
mi.name = "varargs_func_void";
|
||||
|
||||
godot::ClassDB::bind_vararg_method(godot::METHOD_FLAGS_DEFAULT, "varargs_func_void",
|
||||
&Example::varargsFuncVoidReturn, mi);
|
||||
}
|
||||
|
||||
// Properties.
|
||||
ADD_GROUP("Test group", "group_");
|
||||
ADD_SUBGROUP("Test subgroup", "group_subgroup_");
|
||||
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("get_custom_position"),
|
||||
&Example::getCustomPosition);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("get_v4"), &Example::getV4);
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("set_custom_position", "position"),
|
||||
&Example::setCustomPosition);
|
||||
ADD_PROPERTY(godot::PropertyInfo(godot::Variant::VECTOR2, "group_subgroup_custom_position"),
|
||||
"set_custom_position", "get_custom_position");
|
||||
|
||||
// Signals.
|
||||
ADD_SIGNAL(godot::MethodInfo("custom_signal",
|
||||
godot::PropertyInfo(godot::Variant::STRING, "name"),
|
||||
godot::PropertyInfo(godot::Variant::INT, "value")));
|
||||
godot::ClassDB::bind_method(godot::D_METHOD("emit_custom_signal", "name", "value"),
|
||||
&Example::emitCustomSignal);
|
||||
|
||||
// Constants.
|
||||
BIND_ENUM_CONSTANT(FIRST)
|
||||
BIND_ENUM_CONSTANT(ANSWER_TO_EVERYTHING)
|
||||
|
||||
BIND_BITFIELD_FLAG(FLAG_ONE);
|
||||
BIND_BITFIELD_FLAG(FLAG_TWO);
|
||||
|
||||
BIND_CONSTANT(CONSTANT_WITHOUT_ENUM);
|
||||
BIND_ENUM_CONSTANT(OUTSIDE_OF_CLASS);
|
||||
}
|
||||
|
||||
void Example::_notification(int inWhat)
|
||||
{
|
||||
godot::UtilityFunctions::print("Notification: ", godot::String::num(inWhat));
|
||||
}
|
||||
|
||||
bool Example::_set(const godot::StringName& inName, const godot::Variant& inValue)
|
||||
{
|
||||
godot::String name = inName;
|
||||
|
||||
if (name.begins_with("dproperty")) {
|
||||
int64_t index = name.get_slicec('_', 1).to_int();
|
||||
mDProp[index] = inValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "property_from_list") {
|
||||
mPropertyFromList = inValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Example::_get(const godot::StringName& inName, godot::Variant& outReturn) const
|
||||
{
|
||||
godot::String name = inName;
|
||||
|
||||
if (name.begins_with("dproperty")) {
|
||||
int64_t index = name.get_slicec('_', 1).to_int();
|
||||
outReturn = mDProp[index];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "property_from_list") {
|
||||
outReturn = mPropertyFromList;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Example::_get_property_list(godot::List<godot::PropertyInfo>* outList) const
|
||||
{
|
||||
outList->push_back(godot::PropertyInfo(godot::Variant::VECTOR3, "property_from_list"));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
outList->push_back(
|
||||
godot::PropertyInfo(godot::Variant::VECTOR2, "dproperty_" + godot::itos(i)));
|
||||
}
|
||||
}
|
||||
|
||||
bool Example::_property_can_revert(const godot::StringName& inName) const
|
||||
{
|
||||
if (inName == godot::StringName("property_from_list") && mPropertyFromList != godot::Vector3(MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bool Example::_property_get_revert(const godot::StringName& inName,
|
||||
godot::Variant& outProperty) const
|
||||
{
|
||||
if (inName == godot::StringName("property_from_list")) {
|
||||
outProperty = godot::Vector3(MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
godot::String Example::_to_string() const
|
||||
{
|
||||
return "[ GDExtension::Example <--> Instance ID:" + godot::uitos(get_instance_id()) + " ]";
|
||||
}
|
||||
|
||||
//// ExampleVirtual
|
||||
|
||||
void ExampleVirtual::_bind_methods()
|
||||
{
|
||||
}
|
||||
|
||||
//// ExampleAbstract
|
||||
|
||||
void ExampleAbstract::_bind_methods()
|
||||
{
|
||||
}
|
135
ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayWallpaper.h
Normal file
135
ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayWallpaper.h
Normal file
@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
// Copied from godot-cpp/test/src and modified.
|
||||
|
||||
#include "godot_cpp/classes/control.hpp"
|
||||
#include "godot_cpp/classes/global_constants.hpp"
|
||||
#include "godot_cpp/classes/viewport.hpp"
|
||||
#include "godot_cpp/core/binder_common.hpp"
|
||||
|
||||
class ScreenPlayWallpaper : public godot::RefCounted {
|
||||
GDCLASS(ScreenPlayWallpaper, RefCounted)
|
||||
|
||||
public:
|
||||
ScreenPlayWallpaper();
|
||||
~ScreenPlayWallpaper() override;
|
||||
|
||||
int getID() const;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
static int sInstanceCount;
|
||||
static int sLastID;
|
||||
|
||||
int mID;
|
||||
};
|
||||
|
||||
class ExampleMin : public godot::Control {
|
||||
GDCLASS(ExampleMin, Control)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
class Example : public godot::Control {
|
||||
GDCLASS(Example, godot::Control)
|
||||
|
||||
public:
|
||||
// Constants.
|
||||
enum Constants {
|
||||
FIRST,
|
||||
ANSWER_TO_EVERYTHING = 42,
|
||||
};
|
||||
|
||||
enum {
|
||||
CONSTANT_WITHOUT_ENUM = 314,
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
FLAG_ONE = 1,
|
||||
FLAG_TWO = 2,
|
||||
};
|
||||
|
||||
Example();
|
||||
~Example() override;
|
||||
|
||||
// Functions.
|
||||
void simpleFunc();
|
||||
void simpleConstFunc() const;
|
||||
godot::String returnSomething(const godot::String& inBase);
|
||||
godot::Viewport* returnSomethingConst() const;
|
||||
godot::Ref<ScreenPlayWallpaper> returnEmptyRef() const;
|
||||
ScreenPlayWallpaper* returnExtendedRef() const;
|
||||
godot::Ref<ScreenPlayWallpaper> extendedRefChecks(godot::Ref<ScreenPlayWallpaper> inRef) const;
|
||||
godot::Variant varargsFunc(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError);
|
||||
int varargsFuncNonVoidReturn(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError);
|
||||
void varargsFuncVoidReturn(const godot::Variant** inArgs, GDExtensionInt inArgCount,
|
||||
GDExtensionCallError& outError);
|
||||
|
||||
void emitCustomSignal(const godot::String& inName, int inValue);
|
||||
int defArgs(int inA = 100, int inB = 200) const;
|
||||
|
||||
godot::Array testArray() const;
|
||||
void testTypedArrayArg(const godot::TypedArray<int64_t>& inArray);
|
||||
godot::TypedArray<godot::Vector2> testTypedArray() const;
|
||||
godot::Dictionary testDictionary() const;
|
||||
Example* testNodeArgument(Example* inNode) const;
|
||||
godot::String testStringOps() const;
|
||||
int testVectorOps() const;
|
||||
|
||||
godot::BitField<Flags> testBitfield(godot::BitField<Flags> inFlags);
|
||||
|
||||
// Property.
|
||||
void setCustomPosition(const godot::Vector2& inPos);
|
||||
godot::Vector2 getCustomPosition() const;
|
||||
godot::Vector4 getV4() const;
|
||||
|
||||
// Static method.
|
||||
static int testStatic(int inA, int inB);
|
||||
static void testStatic2();
|
||||
|
||||
// Virtual function override (no need to bind manually).
|
||||
virtual bool _has_point(const godot::Vector2& inPoint) const override;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
void _notification(int inWhat);
|
||||
bool _set(const godot::StringName& inName, const godot::Variant& inValue);
|
||||
bool _get(const godot::StringName& inName, godot::Variant& outReturn) const;
|
||||
void _get_property_list(godot::List<godot::PropertyInfo>* outList) const;
|
||||
bool _property_can_revert(const godot::StringName& inName) const;
|
||||
bool _property_get_revert(const godot::StringName& inName, godot::Variant& outProperty) const;
|
||||
|
||||
godot::String _to_string() const;
|
||||
|
||||
private:
|
||||
godot::Vector2 mCustomPosition;
|
||||
godot::Vector3 mPropertyFromList;
|
||||
godot::Vector2 mDProp[3];
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Example::Constants);
|
||||
VARIANT_BITFIELD_CAST(Example::Flags);
|
||||
|
||||
enum EnumWithoutClass {
|
||||
OUTSIDE_OF_CLASS = 512
|
||||
};
|
||||
VARIANT_ENUM_CAST(EnumWithoutClass);
|
||||
|
||||
class ExampleVirtual : public godot::Object {
|
||||
GDCLASS(ExampleVirtual, godot::Object)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
class ExampleAbstract : public godot::Object {
|
||||
GDCLASS(ExampleAbstract, godot::Object)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
45
ScreenPlayWallpaper/Godot/GDExtention/src/Version.h.in
Normal file
45
ScreenPlayWallpaper/Godot/GDExtention/src/Version.h.in
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
// This file is generated by cmake. Changes will be overwritten.
|
||||
// clang-format off
|
||||
|
||||
#include <string_view>
|
||||
|
||||
// Creates a version number for use in macro comparisons.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// // Check if the version is less than 2.1.0
|
||||
// #if ${UPPER_PROJECT_NAME}_VERSION < ${UPPER_PROJECT_NAME}_VERSION_CHECK(2, 1, 0)
|
||||
// // do stuff
|
||||
// #endif
|
||||
//
|
||||
// Returns an integer which may be used in comparisons
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_CHECK( major, minor, patch ) ( ((major)<<16) | ((minor)<<8) | (patch) )
|
||||
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR}
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH}
|
||||
|
||||
// The version number of this extension. Used for #if comparisons.
|
||||
// This is generated using the version set in the CMake project macro.
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION ${UPPER_PROJECT_NAME}_VERSION_CHECK( ${PROJECT_VERSION_MAJOR}, ${PROJECT_VERSION_MINOR}, ${PROJECT_VERSION_PATCH} )
|
||||
|
||||
namespace VersionInfo {
|
||||
// Project name and version as a string.
|
||||
// This is generated using the project name from the cmake project macro and the current git commit information.
|
||||
//
|
||||
// It uses the form "<project name> <last tag>-<# commits since last tag>-<short commit hash>".
|
||||
// If there are no commits since the last tag, only the tag is shown.
|
||||
constexpr std::string_view VERSION_STR = "${PROJECT_NAME} ${GIT_SHORT}";
|
||||
|
||||
// The version information as a string.
|
||||
// This is generated using the current git commit information.
|
||||
//
|
||||
// It uses the form "<last tag>-<# commits since last tag>-<short commit hash>".
|
||||
// If there are no commits since the last tag, only the tag is shown.
|
||||
constexpr std::string_view VERSION_SHORT_STR = "${GIT_SHORT}";
|
||||
|
||||
// The full git SHA1 hash as a string.
|
||||
// This is generated using the current git commit information.
|
||||
constexpr std::string_view GIT_SHA1_STR = "${GIT_SHA1}";
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
add_custom_target( templates
|
||||
SOURCES
|
||||
template.debug.gdextension.in
|
||||
template.release.gdextension.in
|
||||
)
|
||||
|
||||
add_dependencies( ${PROJECT_NAME} templates )
|
||||
|
||||
# We shouldn't be relying on CMAKE_BUILD_TYPE (see https://github.com/asmaloney/GDExtensionTemplate/issues/25)
|
||||
# But until we fix it here and in godot-cpp, ensure it's one we expect.
|
||||
set ( ALLOWED_BUILDS "Debug;Release" )
|
||||
if ( NOT "${CMAKE_BUILD_TYPE}" IN_LIST ALLOWED_BUILDS )
|
||||
message( FATAL_ERROR "CMAKE_BUILD_TYPE must be set to Debug or Release" )
|
||||
endif()
|
||||
|
||||
# Get our gdextension input file name based on build type
|
||||
string( TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE )
|
||||
set( GD_EXTENSION_FILE_INPUT template.${BUILD_TYPE}.gdextension.in )
|
||||
|
||||
# Workaround to add the "lib" prefix to the library in our template file if using MSYS2.
|
||||
if ( MINGW )
|
||||
set( LIB_PREFIX "lib")
|
||||
endif()
|
||||
|
||||
# Generate our project's .gdextension file from the template
|
||||
set( GD_EXTENSION_FILE ${PROJECT_NAME}.gdextension )
|
||||
configure_file( ${GD_EXTENSION_FILE_INPUT} ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/${GD_EXTENSION_FILE} )
|
||||
|
||||
# Install the gdextension file from the build directory
|
||||
install(
|
||||
FILES ${BUILD_OUTPUT_DIR}/${GD_EXTENSION_FILE}
|
||||
DESTINATION ${INSTALL_DIR}
|
||||
)
|
||||
|
||||
unset( ALLOWED_BUILDS )
|
||||
unset( BUILD_TYPE )
|
||||
unset( GD_EXTENSION_FILE )
|
||||
unset( GD_EXTENSION_FILE_INPUT )
|
||||
unset( LIB_PREFIX )
|
@ -0,0 +1,10 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "GDExtensionInit"
|
||||
compatibility_minimum = 4.1
|
||||
|
||||
[libraries]
|
||||
|
||||
linux.debug.x86_64 = "lib/Linux-x86_64/lib${PROJECT_NAME}-d.so"
|
||||
macos.debug = "lib/Darwin-Universal/lib${PROJECT_NAME}-d.dylib"
|
||||
windows.debug.x86_64 = "lib/Windows-AMD64/${LIB_PREFIX}${PROJECT_NAME}-d.dll"
|
@ -0,0 +1,10 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "GDExtensionInit"
|
||||
compatibility_minimum = 4.1
|
||||
|
||||
[libraries]
|
||||
|
||||
linux.release.x86_64 = "lib/Linux-x86_64/lib${PROJECT_NAME}.so"
|
||||
macos.release = "lib/Darwin-universal/lib${PROJECT_NAME}.dylib"
|
||||
windows.release.x86_64 = "lib/Windows-AMD64/${LIB_PREFIX}${PROJECT_NAME}.dll"
|
2
ScreenPlayWallpaper/Godot/ScreenPlayGodot/.gitattributes
vendored
Normal file
2
ScreenPlayWallpaper/Godot/ScreenPlayGodot/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
2
ScreenPlayWallpaper/Godot/ScreenPlayGodot/.gitignore
vendored
Normal file
2
ScreenPlayWallpaper/Godot/ScreenPlayGodot/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
61
ScreenPlayWallpaper/Godot/ScreenPlayGodot/export_presets.cfg
Normal file
61
ScreenPlayWallpaper/Godot/ScreenPlayGodot/export_presets.cfg
Normal file
@ -0,0 +1,61 @@
|
||||
[preset.0]
|
||||
|
||||
name="Windows Desktop"
|
||||
platform="Windows Desktop"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../SP_export/export.exe"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=true
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
binary_format/architecture="x86_64"
|
||||
codesign/enable=false
|
||||
codesign/timestamp=true
|
||||
codesign/timestamp_server_url=""
|
||||
codesign/digest_algorithm=1
|
||||
codesign/description=""
|
||||
codesign/custom_options=PackedStringArray()
|
||||
application/modify_resources=true
|
||||
application/icon=""
|
||||
application/console_wrapper_icon=""
|
||||
application/icon_interpolation=4
|
||||
application/file_version=""
|
||||
application/product_version=""
|
||||
application/company_name=""
|
||||
application/product_name=""
|
||||
application/file_description=""
|
||||
application/copyright=""
|
||||
application/trademarks=""
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||
$settings = New-ScheduledTaskSettingsSet
|
||||
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||
Start-ScheduledTask -TaskName godot_remote_debug
|
||||
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
1
ScreenPlayWallpaper/Godot/ScreenPlayGodot/icon.svg
Normal file
1
ScreenPlayWallpaper/Godot/ScreenPlayGodot/icon.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>
|
After Width: | Height: | Size: 950 B |
37
ScreenPlayWallpaper/Godot/ScreenPlayGodot/icon.svg.import
Normal file
37
ScreenPlayWallpaper/Godot/ScreenPlayGodot/icon.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://by316gekc8lr7"
|
||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
15
ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd
Normal file
15
ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd
Normal file
@ -0,0 +1,15 @@
|
||||
extends Node3D
|
||||
|
||||
func _ready():
|
||||
var path = ""
|
||||
var success = ProjectSettings.load_resource_pack (path)
|
||||
if success:
|
||||
var scene_resource = load("res://wallpaper.tscn")
|
||||
if scene_resource:
|
||||
var scene_instance = scene_resource.instantiate()
|
||||
add_child(scene_instance)
|
||||
else:
|
||||
print("Failed to load the wallpaper.tscn scene.")
|
||||
else:
|
||||
print("Failed to load the PCK file.")
|
||||
Engine.set_max_fps(24)
|
6
ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.tscn
Normal file
6
ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bc5caslt2tiuk"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_ceeuk"]
|
||||
|
||||
[node name="Wallpaper" type="Node3D"]
|
||||
script = ExtResource("1_ceeuk")
|
21
ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot
Normal file
21
ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot
Normal file
@ -0,0 +1,21 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="ScreenPlay"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/features=PackedStringArray("4.1", "Mobile")
|
||||
boot_splash/show_image=false
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="mobile"
|
@ -28,3 +28,4 @@ QT_IFW_VERSION = "4.6"
|
||||
VCPKG_VERSION = "f06975f46d8c7a1dad916e1e997584f77ae0c34a"
|
||||
PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3"
|
||||
FFMPEG_VERSION = "5.0.1"
|
||||
GODOT_VERSION = "4.1.1"
|
||||
|
@ -1,2 +1,3 @@
|
||||
cmake-format
|
||||
aqtinstall
|
||||
requests
|
@ -8,6 +8,7 @@ import defines
|
||||
import argparse
|
||||
import util
|
||||
import datetime
|
||||
import setup_godot
|
||||
from sys import stdout
|
||||
|
||||
stdout.reconfigure(encoding='utf-8')
|
||||
@ -119,6 +120,7 @@ def main():
|
||||
setup_qt()
|
||||
|
||||
download_ffmpeg.execute()
|
||||
setup_godot.execute()
|
||||
|
||||
if system() == "Windows":
|
||||
vcpkg_command = "vcpkg.exe"
|
||||
|
58
Tools/setup_godot.py
Normal file
58
Tools/setup_godot.py
Normal file
@ -0,0 +1,58 @@
|
||||
import requests
|
||||
import zipfile
|
||||
import platform
|
||||
from pathlib import Path
|
||||
# Assuming defines.py exists and has GODOT_VERSION
|
||||
from defines import GODOT_VERSION
|
||||
from util import repo_root_path # Assuming util.py exists and has repo_root_path()
|
||||
|
||||
|
||||
def execute():
|
||||
# Assuming repo_root_path() returns the git repo root path
|
||||
root_path = Path(repo_root_path())
|
||||
godot_path = root_path / "Tools" / "Apps" / "Godot"
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
godot_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Check if Godot executable already exists
|
||||
for file in godot_path.iterdir():
|
||||
if GODOT_VERSION in str(file):
|
||||
print(f"Godot v{GODOT_VERSION} already exists.")
|
||||
return
|
||||
|
||||
# Determine OS type
|
||||
os_type = platform.system().lower()
|
||||
if os_type == "windows":
|
||||
os_type = "win64.exe"
|
||||
elif os_type == "linux":
|
||||
os_type = "linux.x86_64"
|
||||
elif os_type == "darwin": # macOS
|
||||
os_type = "macos.universal"
|
||||
else:
|
||||
print("Unsupported OS")
|
||||
return
|
||||
|
||||
# Download Godot
|
||||
base_url = "https://github.com/godotengine/godot/releases/download"
|
||||
file_name = f"Godot_v{GODOT_VERSION}-stable_{os_type}.zip"
|
||||
url = f"{base_url}/{GODOT_VERSION}-stable/{file_name}"
|
||||
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
download_path = godot_path / file_name
|
||||
download_path.write_bytes(response.content)
|
||||
|
||||
# Extract ZIP file
|
||||
with zipfile.ZipFile(download_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(godot_path)
|
||||
|
||||
# Delete ZIP file
|
||||
download_path.unlink()
|
||||
print(f"Successfully installed Godot v{GODOT_VERSION}")
|
||||
else:
|
||||
print(f"Failed to download Godot v{GODOT_VERSION} for {os_type}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
execute()
|
Loading…
Reference in New Issue
Block a user