diff --git a/.github/workflows/extension.yml b/.github/workflows/extension.yml index dfcc496..326269f 100644 --- a/.github/workflows/extension.yml +++ b/.github/workflows/extension.yml @@ -13,6 +13,7 @@ env: LC_ALL: en_US.UTF-8 PYTHONIOENCODING: utf8 GODOT_VERSION_4: ${{ inputs.godot_tag }} + KEYCHAIN_PATH: app-signing.keychain-db concurrency: group: ci-scons-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }} @@ -35,7 +36,7 @@ jobs: platform: windows - name: 🍎 macOS (universal) - os: macos-15 + os: macos-latest platform: macos - name: 🀖 Android (arm64) @@ -43,7 +44,7 @@ jobs: platform: android - name: 🍏 iOS (arm64) - os: macos-15 + os: macos-latest platform: ios - name: 🌐 Web (wasm32) @@ -73,6 +74,29 @@ jobs: platform: ${{ matrix.platform }} os: ${{ matrix.os }} + - name: Retrieve the secret and decode it to a file + if: matrix.platform == 'macos' || matrix.platform == 'ios' + env: + DEV_CERT_APPLICATION: ${{ secrets.DEV_CERT_APPLICATION }} + DEV_CERT_PASS: ${{ secrets.DEV_CERT_PASS }} + KC_PASS: ${{ secrets.KC_PASS }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + + # import certificate and provisioning profile from secrets + echo -n "$DEV_CERT_APPLICATION" | base64 --decode > $CERTIFICATE_PATH + + # create temporary keychain + security create-keychain -p "$KC_PASS" ${{ env.KEYCHAIN_PATH }} + security set-keychain-settings -lut 21600 ${{ env.KEYCHAIN_PATH }} + security unlock-keychain -p "$KC_PASS" ${{ env.KEYCHAIN_PATH }} + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$DEV_CERT_PASS" -f pkcs12 -k ${{ env.KEYCHAIN_PATH }} -T /usr/bin/codesign + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KC_PASS" ${{ env.KEYCHAIN_PATH }} + security list-keychain -d user -s ${{ env.KEYCHAIN_PATH }} + - name: build Linux if: matrix.platform == 'linux' run: | @@ -80,14 +104,28 @@ jobs: - name: build macOS if: matrix.platform == 'macos' + env: + DEV_ID_APPLICATION: ${{ secrets.DEV_ID_APPLICATION }} run: | ./scripts/release-gdextension-macos.sh + for f in ./bin/macos/*.framework + do + codesign --force --verify --verbose --keychain ${{ env.KEYCHAIN_PATH }} --sign "${DEV_ID_APPLICATION}" $f --deep --options runtime --timestamp + done + - name: build iOS if: matrix.platform == 'ios' + env: + DEV_ID_APPLICATION: ${{ secrets.DEV_ID_APPLICATION }} run: | ./scripts/release-gdextension-ios.sh + for f in ./bin/ios/*.framework + do + codesign --force --verify --verbose --keychain ${{ env.KEYCHAIN_PATH }} --sign "${DEV_ID_APPLICATION}" $f --deep --options runtime --timestamp + done + - name: build Android if: matrix.platform == 'android' run: | @@ -113,7 +151,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: extension-${{ matrix.platform }}-${{ steps.commit.outputs.short }} + name: extension-${{ env.GODOT_VERSION_4 }}-${{ matrix.platform }}-${{ steps.commit.outputs.short }} path: bin/ if-no-files-found: error @@ -140,17 +178,17 @@ jobs: mkdir -p bin cp ../misc/ssplayer_godot_extension.gdextension bin/ - mv extension-android-${{ steps.commit.outputs.short }}/android bin/ - mv extension-ios-${{ steps.commit.outputs.short }}/ios bin/ - mv extension-macos-${{ steps.commit.outputs.short }}/macos bin/ - mv extension-web-${{ steps.commit.outputs.short }}/web bin/ - mv extension-windows-${{ steps.commit.outputs.short }}/windows bin/ - # mv extension-linux-${{ steps.commit.outputs.short }}/linux bin/ + mv extension-${{ env.GODOT_VERSION_4 }}-android-${{ steps.commit.outputs.short }}/android bin/ + mv extension-${{ env.GODOT_VERSION_4 }}-ios-${{ steps.commit.outputs.short }}/ios bin/ + mv extension-${{ env.GODOT_VERSION_4 }}-macos-${{ steps.commit.outputs.short }}/macos bin/ + mv extension-${{ env.GODOT_VERSION_4 }}-web-${{ steps.commit.outputs.short }}/web bin/ + mv extension-${{ env.GODOT_VERSION_4 }}-windows-${{ steps.commit.outputs.short }}/windows bin/ + # mv extension-${{ env.GODOT_VERSION_4 }}-linux-${{ steps.commit.outputs.short }}/linux bin/ - zip -r ../ssplayer-godot-extension-${{ steps.commit.outputs.short }}.zip ssplayer_godot_extension.gdextension bin/ + zip -r ../ssplayer-godot-extension-${{ env.GODOT_VERSION_4 }}-${{ steps.commit.outputs.short }}.zip bin/ - name: Upload final release package uses: actions/upload-artifact@v4 with: - name: ssplayer-godot-extension-${{ steps.commit.outputs.short }} - path: ssplayer-godot-extension-${{ steps.commit.outputs.short }}.zip + name: ssplayer-godot-extension-${{ env.GODOT_VERSION_4 }}-${{ steps.commit.outputs.short }} + path: ssplayer-godot-extension-${{ env.GODOT_VERSION_4 }}-${{ steps.commit.outputs.short }}.zip diff --git a/BUILD.md b/BUILD.md index d0c553c..26610df 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,6 +1,6 @@ # ゜ヌス取埗 -本リポゞトリをクロヌンしおください。 +本リポゞトリをクロヌンしお、 `SSPlayerForGodot` ディレクトリ内に入っおください。 ```bash git clone --recursive https://github.com/SpriteStudio/SSPlayerForGodot.git @@ -20,10 +20,10 @@ git clone https://github.com/godotengine/godot-cpp.git ``` # ブランチ遞択 +## Godot SSPlayerForGodot ディレクトリの `godot` ディレクトリ内でビルドする Godot Engine のブランチを遞択しおください。 -## Godot -### 4.4 +### 4 ```bash pushd godot @@ -50,10 +50,11 @@ popd ``` # ビルド環境のセットアップ -## Windows 以降でビルド環境の構築手順に぀いお説明しおいきたす。 +## Windows + [Godot公匏のコンパむル手順](https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_for_windows.html) 必芁なツヌル @@ -101,12 +102,21 @@ brew install molten-vk brew install emscripten ``` +(Optional) target を Android のビルドをする際は Android NDK をむンストヌルしおください。 + + +## Linux +T.B.D + # ビルド ## Windows ### 4 [build.ps1](./scripts/build.ps1) でビルド可胜です。 + +成果物は `godot\bin` に栌玍されたす。 + **PowerShell** ```powershell @@ -124,6 +134,7 @@ PowerShell.exe -ExecutionPolicy Bypass -File .\scripts\build.ps1 ### 3.x [build-v3.ps1](./scripts/build-v3.ps1) でビルド可胜です。 +成果物は `godot\bin` に栌玍されたす。 **PowerShell** @@ -144,6 +155,7 @@ PowerShell.exe -ExecutionPolicy Bypass -File .\scripts\build-v3.ps1 ### 4 [build.sh](./scripts/build.sh) でビルド可胜です。 +成果物は `godot/bin` に栌玍されたす。 ```sh ./scripts/build.sh @@ -175,6 +187,7 @@ PowerShell.exe -ExecutionPolicy Bypass -File .\scripts\build-v3.ps1 ### 3.x [build-v3.sh](./scripts/build-v3.sh) でビルド可胜です。 +成果物は `godot/bin` に栌玍されたす。 ```sh ./scripts/build-v3.sh @@ -207,6 +220,8 @@ PowerShell.exe -ExecutionPolicy Bypass -File .\scripts\build-v3.ps1 # GDExtension ## Windows [build-extension.ps1](./scripts/build-extension.ps1) でビルド可胜です。 +成果物は `bin` ディレクトリに栌玍されたす。 + **PowerShell** @@ -227,6 +242,7 @@ PowerShell.exe -ExecutionPolicy Bypass -File .\scripts\build-extension.ps1 macOS か Linux で実行しおください。 [build-extension.sh](./scripts/build-extension.sh) でビルド可胜です。 +成果物は `bin` ディレクトリに栌玍されたす。 ```sh ./scripts/build-extension.sh @@ -236,10 +252,40 @@ macOS か Linux で実行しおください。 # リリヌスビルド ## 4 -... +各プラットフォヌムの godot の `editor`, `template_debug`, `template_release` をたずめおビルドスクリプトは䞋蚘の通りです。 + +windows +``` +.\scripts\release-windows.ps1 +``` + +macOS +```sh +./scripts/release-macos.sh +``` + +Linux +```sh +./scripts/release-linux.sh +``` + +iOS +```sh +./scripts/release-ios.sh +``` + +Android +```sh +./scripts/release-android.sh +``` + +Web +```sh +./scripts/release-web.sh +``` ## GDExtension -各プラットフォヌムの gdextension の editor, template_debug, template_release をたずめおビルドスクリプトは䞋蚘の通りです。 +各プラットフォヌムの gdextension の `editor`, `template_debug`, `template_release` をたずめおビルドスクリプトは䞋蚘の通りです。 windows ``` diff --git a/README.md b/README.md index d6c88d9..a7ebb27 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ 実行時パフォヌマンスを優先するため C++ モゞュヌルの圢態になっおいたす。 SpriteStudioPlayer for Godot を利甚する堎合、SpriteStudioPlayer の[カスタムモゞュヌル](https://docs.godotengine.org/en/stable/contributing/development/core_and_modules/custom_modules_in_cpp.html) を組み蟌んだ Godot Engine の Editor を手元でビルドするか、 SpriteStudioPlayer の [GDExtension](https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/what_is_gdextension.html) をプロゞェクトぞ入れる必芁がありたす。 - ## 察応する [OPTPiX SpriteStudio](https://www.webtech.co.jp/spritestudio/index.html) のバヌゞョン Ver.6 ず Ver.7 に察応しおいたす。 @@ -23,190 +22,8 @@ Ver.6 ず Ver.7 に察応しおいたす。 [BUILD.md](BUILD.md) を参照しおください。 # 䜿い方 -## SpriteStudioデヌタのむンポヌト - -SpriteStudioデヌタのむンポヌト手順に぀いお説明したす。 -珟圚の SpriteStudio for Godot プラグむンでは sspj ファむルを盎接指定する圢態になっおいたす。 -ご利甚のプロゞェクト䞋のフォルダに sspj、ssae、ssce ず画像ファむルなどの䞀匏を配眮したす。 - -## SpriteStudioノヌドの䜜成ず sspj ファむルの指定 - -1. 「Node を新芏䜜成」から「GdNodeSsPlayer」を遞択し、「䜜成」ボタンを抌したす。 -2. むンスペクタヌの「Res Player」から「新芏 GdResourceSsPlayer」を遞択したす。 -3. GdResourceSsPlayer の「Res Project」から「読み蟌み」を遞択したす。 -4. 「ファむルを開く」ダむアログから「*.sspj」ファむルを遞択しお開きたす。 - -## アニメヌションの指定 - -1. 「Animation Settings」を展開「Anime Pack」から再生させる「*.ssae」ファむルを遞択したす。 -2. 続いお「Animation」から再生させるアニメヌションを遞択したす。 -3. Frame をドラッグしたり、Play フラグをオンにするこずでプレビュヌできたす。 - -### むンスペクタヌの各プロパティの意味 - -![image](./doc_images/ssnode_inspector.png) - -``` -GdNodeSsPlayer - SsPlayer を扱うノヌド -├── Res Player - SsPlayer が䜿甚するリ゜ヌス -│ └── Res Project - sspj ファむル -│ └── CellMap Settings - セルマップの蚭定 -│ ├── ssce File 01 - セルマップ -│ └── ssce File 02 - セルマップ -│ -└── Animation Settings - アニメヌションの蚭定 - ├── Anime Pack - アニメパック - ├── Animation - アニメヌション - ├── Frame - 珟圚のフレヌム - ├── Loop - ルヌプ再生フラグ - ├── Playing - 再生フラグ - └── Texture Interpolate - テクスチャ補間フラグ -``` - -### テクスチャ補間フラグに぀いお - -SSPlayer for Godot の実装(v1.2.0時点)では、䞀床アニメヌションをテクスチャにレンダリングした埌、Godot のレンダラヌによっおスクリヌンバッファに描画されたす。 -このテクスチャにレンダリングする際にバむリニア補間をかける堎合はフラグをオンに蚭定したす。 -この状態では回転しお斜めになったパヌツの゚ッゞにアンチ゚むリアスがかかりたすが、この動䜜が奜たしくない堎合はオフにしおください。 -このフラグをオフに蚭定し、CanvasItem の Texture の FilterMode も Nearest にしおおくずスクリヌンバッファに描画する際にも補間がかからずピクセルの゚ッゞが明確になりたす。 -䟋えばピクセルアヌト系のゲヌムで利甚する堎合は、この蚭定を詊しおみお䞋さい。 - -#### レンダリングするテクスチャのサむズ -レンダリングするテクスチャのサむズはSpriteStudio䞊でアニメヌションに蚭定した「基準枠」のサむズが採甚されたす。(v1.2.0時点) - -## クラス - -GDScript からコントロヌルできるクラスの圹割ず䞻芁なメ゜ッドに぀いお説明したす。 -各クラスが持っおいる党おのメ゜ッド、プロパティ、シグナルに぀いおは Godot の Script 画面で確認しおみおください。 - -### リ゜ヌス管理クラス - -SpriteStudio の各皮 .ss** ファむルに盞圓するリ゜ヌスを管理するクラスがありたす。 - -#### [GdResourceSsProject](./gd_spritestudio/gd_resource_ssproject.h) クラス - -぀の sspj ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 -sspj に登録された ssae, ssce, ssee 各々のリ゜ヌスの取埗ず蚭定を行いたす。 - -#### [GdResourceSsCellMap](./gd_spritestudio/gd_resource_sscellmap.h) クラス - -぀の ssce ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 -珟圚テクスチャの取埗ず蚭定を行うメンバヌのみ察応しおいたす。 - -#### [GdResourceSsAnimePack](./gd_spritestudio/gd_resource_ssanimepack.h) クラス - -぀の ssae ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 -内包しおいるアニメヌションの数、ずアニメヌション名の取埗を行えたす。 - -#### [GdResourceSsPlayer](./gd_spritestudio/gd_resource_ssplayer.h) クラス - -珟圚 GdResourceSsProject リ゜ヌスを蚭定、取埗するアクセサのみです。 - -### 再生のためのクラス - -GdNodeSsPlayer に前述のリ゜ヌスを指定するこずで再生を行いたす。 -以䞋はファむルの読み蟌みから再生開始たでのシンプルなサンプルコヌドです。 - -```python -# GdNodeSsPlayerノヌドを指したす。 -## Godot 4 -@onread var ssnode = $target -## Godot 3.x -# onready var ssnode = $target -func _ready(): - # sspj ファむルを読み蟌みたす。 - ssnode.res_player.res_project = ResourceLoader.load("Sample.sspj") - - # ssaeファむルずアニメヌションを指定したす。 - ssnode.set_anime_pack("Sample.ssae") - ssnode.set_animation("anime_1") - - # アニメヌション終了時コヌルバックの蚭定 - ## Godot 4 - ssnode.connect("animation_finished", Callable(self, "_on_animation_finished")) - ## Godot 3.x - # ssnode.connect("animation_finished", self, "_on_animation_finished") - - # ルヌプを指定しお再生を開始したす。 - ssnode.set_loop(true) - ssnode.play() - -# アニメ終了時のコヌルバック関数です -func _on_animation_finished(name): - print("SIGNAL _on_animation_finished from " + name) -``` - -他にもカレントフレヌムの指定、䞀時停止、開始、終了フレヌム、FPSの取埗など䞀般的なメ゜ッドがありたす。 -䞀芧は Godot の Script 画面で確認しおみおください。 - -#### シグナル - -GdNodeSsPlayer が発行するシグナルに぀いお説明したす。 - -#### on_animation_changed(name: String) - -アニメヌション倉曎時に発行されたす。 -name倉曎したアニメヌション名 - -#### on_animation_finished(name: String) - -再生䞭のアニメヌションが終了フレヌムに到達した時に発行されたす。 -ルヌプ再生オンでも毎呚発行されたす。 -name倉曎したアニメヌション名 - -#### on_animepack_changed(name: String) - -アニメパック倉曎時に発行されたす。 -name倉曎したアニメパック名 - -#### on_frame_changed(frame: int) - -フレヌム䜍眮倉曎時に発行されたす。 -frame倉曎したフレヌム䜍眮 - -#### on_signal(command: String, value: Dictionary) - -SpriteStudioのシグナルアトリビュヌトのキヌフレヌム到達時に発行されたす。 -commandコマンド名 -valueパラメヌタ名ず倀のコレクション - -#### on_user_data(flag: int, intValue: int, rectValue: Rect2, pointValue: Vector2, stringValue: String) - -ナヌザヌデヌタのキヌフレヌム到達時に発行されたす。 - -- flag埌続の匕数が有効かどうかの論理倀 - - 1敎数が有効 - - 2範囲が有効 - - 4䜍眮が有効 - - 8文字列が有効 -- intValue敎数 -- rectValue範囲 -- pointValue䜍眮 -- stringValue文字列 - -## 制限事項 - -### 動䜜しないもの - -- マスク機胜 -- 描画モヌドミックス以倖もミックス盞圓になりたす。 -- SpriteStudio Ver.7.1 で远加された新機胜(テキスト・サりンド・9スラむス・シェむプ) - -### 衚瀺が異なるもの - -- パヌツカラヌ - - [x] v1.1.1 で修正枈ミックスの頂点単䜍の時にX状(䞉角圢の蟺郚分)の茝床が高くなっおいたす。 - - [x] v1.1 で修正枈乗算でテクスチャカラヌの割合が゚ディタより倧きくなりたす。 - -### その他の制限 - -- むンスタンスの独立動䜜がOnのパヌツの再生に぀いお - - シヌン䞊で Frame プロパティが 0 以倖の状態で Play プロパティを On にしお再生開始した堎合、独立動䜜がOnに蚭定されたむンスタンスパヌツを再生させた堎合、むンスタンスパヌツの再生フレヌムがずれるこずがありたす。 - - この堎合、䞀旊 Frame プロパティの倀を 0 以倖に倉曎埌、0 に戻しおから再生開始するこずで䞀臎させられたす。 -- シェヌダヌ - - SpriteStudio公匏の䞀郚のみ察応しおいたす。 - - カスタムシェヌダヌは独自に远加・察応する必芁がありたす。 +[USAGE.md](USAGE.md) を参照しおください。 # サンプル @@ -248,7 +65,6 @@ gdextension の動䜜確認甚プロゞェクトです。 確認できるサンプルは [feature_test](./examples/feature_test) ず同じものになりたす。 - # お問い合わせ ご質問、ご芁望、䞍具合のご報告は [Issues](../../issues) に投皿しおください。 diff --git a/SConstruct b/SConstruct index 15da5e9..a5e2b1e 100644 --- a/SConstruct +++ b/SConstruct @@ -1,6 +1,7 @@ #!/usr/bin/env python import os import sys +import subprocess def normalize_path(val, env): return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val) @@ -10,6 +11,7 @@ def validate_parent_dir(key, val, env): if not os.path.isdir(normalize_path(os.path.dirname(val), env)): raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val))) + libname = "SSGodot" projectdir = os.path.join("examples", "feature_test_gdextension") @@ -34,13 +36,11 @@ opts.Add( validator=validate_parent_dir, ) ) - opts.Update(localEnv) Help(opts.GenerateHelpText(localEnv)) env = localEnv.Clone() - env["compiledb"] = False env.Tool("compilation_db") @@ -76,6 +76,10 @@ env.Append( "gd_spritestudio/SpriteStudio6-SDK/Common/Helper", ] ) +# Set iOS minimum deployment target +if env["platform"] == "ios": + env.Append(CCFLAGS=["-miphoneos-version-min=12.0"]) + env.Append(LINKFLAGS=["-miphoneos-version-min=12.0"]) sources = Glob("gd_spritestudio/*.cpp") sources.extend(Glob("gd_spritestudio/SpriteStudio6-SDK/Common/Loader/tinyxml2/*.cpp")) @@ -93,12 +97,13 @@ if env["target"] in ["editor", "template_debug"]: except AttributeError: print("Not including class reference as we're targeting a pre-4.3 baseline.") -file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]) +file = "lib{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]) filepath = "" if env["platform"] == "macos" or env["platform"] == "ios": - filepath = "{}.framework/".format(env["platform"]) - file = "{}.{}.{}".format(libname, env["platform"], env["target"]) + filepath = "lib{}.{}.{}.framework/".format(libname, env["platform"], env["target"]) + file = "lib{}.{}.{}".format(libname, env["platform"], env["target"]) + env.Append(LINKFLAGS=["-Wl,-install_name,@rpath/{}{}".format(filepath, file)]) libraryfile = "bin/{}/{}{}".format(env["platform"], filepath, file) library = env.SharedLibrary( @@ -106,9 +111,40 @@ library = env.SharedLibrary( source=sources, ) -copy = env.InstallAs("{}/bin/{}/{}lib{}".format(projectdir, env["platform"], filepath, file), library) - +if env["platform"] == "macos" or env["platform"] == "ios": + plist_subst = { + "${BUNDLE_LIBRARY}": file, + "${BUNDLE_NAME}": "ssplayer-godot", + "${BUNDLE_IDENTIFIER}": "jp.co.cri-mw.spritestudio.ssplayer-godot.{}".format(env["target"]), + "${BUNDLE_VERSION}": subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').strip().split('-')[0] + '.0', + "${MIN_MACOS_VERSION}": "10.12", + "${MIN_IOS_VERSION}": "12.0" + } + + if env["platform"] == "macos": + plist_file = "bin/macos/{}Resources/Info.plist".format(filepath) + plist = env.Substfile( + target=plist_file, + source="misc/Info.macos.plist", + SUBST_DICT=plist_subst + ) + elif env["platform"] == "ios": + plist_file = "bin/ios/{}Info.plist".format(filepath) + plist = env.Substfile( + target=plist_file, + source="misc/Info.ios.plist", + SUBST_DICT=plist_subst + ) + + env.Depends(library, plist) + +copy = env.InstallAs("{}/{}".format(projectdir, libraryfile), library) default_args = [library, copy] + +if env["platform"] == "macos" or env["platform"] == "ios": + copy_plist = env.InstallAs("{}/{}".format(projectdir, plist_file), plist_file) + default_args.append(copy_plist) + if localEnv.get("compiledb", False): default_args += [compilation_db] -Default(*default_args) +Default(*default_args) \ No newline at end of file diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 0000000..86bb77c --- /dev/null +++ b/USAGE.md @@ -0,0 +1,193 @@ +# ゚ディタの遞択 +䞋蚘どちらかの方法で利甚しおください。 + +- SpriteStudioPlayer のカスタムモゞュヌルを組み蟌んだ Godot Engine を甚意する。 + - [BUILD.md](BUILD.md) を参照しおください +- SpriteStudioPlayer の GDExtension を Godot プロゞェクトの `bin` ディレクトリぞ栌玍する。 + - [リリヌス](https://github.com/SpriteStudio/SSPlayerForGodot/releases)を参照しおください。自前でビルドする堎合は [BUILD.md](BUILD.md) を参照しおください + + +# SpriteStudioデヌタのむンポヌト + +SpriteStudioデヌタのむンポヌト手順に぀いお説明したす。 +珟圚の SpriteStudio for Godot プラグむンでは sspj ファむルを盎接指定する圢態になっおいたす。 +ご利甚のプロゞェクト䞋のフォルダに sspj、ssae、ssce ず画像ファむルなどの䞀匏を配眮したす。 + +# SpriteStudioノヌドの䜜成ず sspj ファむルの指定 + +1. 「Node を新芏䜜成」から「GdNodeSsPlayer」を遞択し、「䜜成」ボタンを抌したす。 +2. むンスペクタヌの「Res Player」から「新芏 GdResourceSsPlayer」を遞択したす。 +3. GdResourceSsPlayer の「Res Project」から「読み蟌み」を遞択したす。 +4. 「ファむルを開く」ダむアログから「*.sspj」ファむルを遞択しお開きたす。 + +# アニメヌションの指定 + +1. 「Animation Settings」を展開「Anime Pack」から再生させる「*.ssae」ファむルを遞択したす。 +2. 続いお「Animation」から再生させるアニメヌションを遞択したす。 +3. Frame をドラッグしたり、Play フラグをオンにするこずでプレビュヌできたす。 + +## むンスペクタヌの各プロパティの意味 + +![image](./doc_images/ssnode_inspector.png) + +``` +GdNodeSsPlayer - SsPlayer を扱うノヌド +├── Res Player - SsPlayer が䜿甚するリ゜ヌス +│ └── Res Project - sspj ファむル +│ └── CellMap Settings - セルマップの蚭定 +│ ├── ssce File 01 - セルマップ +│ └── ssce File 02 - セルマップ +│ +└── Animation Settings - アニメヌションの蚭定 + ├── Anime Pack - アニメパック + ├── Animation - アニメヌション + ├── Frame - 珟圚のフレヌム + ├── Loop - ルヌプ再生フラグ + ├── Playing - 再生フラグ + └── Texture Interpolate - テクスチャ補間フラグ +``` + +## テクスチャ補間フラグに぀いお + +SSPlayer for Godot の実装(v1.2.0時点)では、䞀床アニメヌションをテクスチャにレンダリングした埌、Godot のレンダラヌによっおスクリヌンバッファに描画されたす。 +このテクスチャにレンダリングする際にバむリニア補間をかける堎合はフラグをオンに蚭定したす。 +この状態では回転しお斜めになったパヌツの゚ッゞにアンチ゚むリアスがかかりたすが、この動䜜が奜たしくない堎合はオフにしおください。 +このフラグをオフに蚭定し、CanvasItem の Texture の FilterMode も Nearest にしおおくずスクリヌンバッファに描画する際にも補間がかからずピクセルの゚ッゞが明確になりたす。 +䟋えばピクセルアヌト系のゲヌムで利甚する堎合は、この蚭定を詊しおみお䞋さい。 + +### レンダリングするテクスチャのサむズ +レンダリングするテクスチャのサむズはSpriteStudio䞊でアニメヌションに蚭定した「基準枠」のサむズが採甚されたす。(v1.2.0時点) + +# クラス + +GDScript からコントロヌルできるクラスの圹割ず䞻芁なメ゜ッドに぀いお説明したす。 +各クラスが持っおいる党おのメ゜ッド、プロパティ、シグナルに぀いおは Godot の Script 画面で確認しおみおください。 + +## リ゜ヌス管理クラス + +SpriteStudio の各皮 .ss** ファむルに盞圓するリ゜ヌスを管理するクラスがありたす。 + +### [GdResourceSsProject](./gd_spritestudio/gd_resource_ssproject.h) クラス + +぀の sspj ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 +sspj に登録された ssae, ssce, ssee 各々のリ゜ヌスの取埗ず蚭定を行いたす。 + +### [GdResourceSsCellMap](./gd_spritestudio/gd_resource_sscellmap.h) クラス + +぀の ssce ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 +珟圚テクスチャの取埗ず蚭定を行うメンバヌのみ察応しおいたす。 + +### [GdResourceSsAnimePack](./gd_spritestudio/gd_resource_ssanimepack.h) クラス + +぀の ssae ファむルに盞圓するリ゜ヌスを取り扱うクラスです。 +内包しおいるアニメヌションの数、ずアニメヌション名の取埗を行えたす。 + +### [GdResourceSsPlayer](./gd_spritestudio/gd_resource_ssplayer.h) クラス + +珟圚 GdResourceSsProject リ゜ヌスを蚭定、取埗するアクセサのみです。 + +## 再生のためのクラス + +GdNodeSsPlayer に前述のリ゜ヌスを指定するこずで再生を行いたす。 +以䞋はファむルの読み蟌みから再生開始たでのシンプルなサンプルコヌドです。 + +```python +# GdNodeSsPlayerノヌドを指したす。 +## Godot 4 +@onread var ssnode = $target +## Godot 3.x +# onready var ssnode = $target + +func _ready(): + # sspj ファむルを読み蟌みたす。 + ssnode.res_player.res_project = ResourceLoader.load("Sample.sspj") + + # ssaeファむルずアニメヌションを指定したす。 + ssnode.set_anime_pack("Sample.ssae") + ssnode.set_animation("anime_1") + + # アニメヌション終了時コヌルバックの蚭定 + ## Godot 4 + ssnode.connect("animation_finished", Callable(self, "_on_animation_finished")) + ## Godot 3.x + # ssnode.connect("animation_finished", self, "_on_animation_finished") + + # ルヌプを指定しお再生を開始したす。 + ssnode.set_loop(true) + ssnode.play() + +# アニメ終了時のコヌルバック関数です +func _on_animation_finished(name): + print("SIGNAL _on_animation_finished from " + name) +``` + +他にもカレントフレヌムの指定、䞀時停止、開始、終了フレヌム、FPSの取埗など䞀般的なメ゜ッドがありたす。 +䞀芧は Godot の Script 画面で確認しおみおください。 + +### シグナル + +GdNodeSsPlayer が発行するシグナルに぀いお説明したす。 + +### on_animation_changed(name: String) + +アニメヌション倉曎時に発行されたす。 +name倉曎したアニメヌション名 + +### on_animation_finished(name: String) + +再生䞭のアニメヌションが終了フレヌムに到達した時に発行されたす。 +ルヌプ再生オンでも毎呚発行されたす。 +name倉曎したアニメヌション名 + +### on_animepack_changed(name: String) + +アニメパック倉曎時に発行されたす。 +name倉曎したアニメパック名 + +### on_frame_changed(frame: int) + +フレヌム䜍眮倉曎時に発行されたす。 +frame倉曎したフレヌム䜍眮 + +### on_signal(command: String, value: Dictionary) + +SpriteStudioのシグナルアトリビュヌトのキヌフレヌム到達時に発行されたす。 +commandコマンド名 +valueパラメヌタ名ず倀のコレクション + +### on_user_data(flag: int, intValue: int, rectValue: Rect2, pointValue: Vector2, stringValue: String) + +ナヌザヌデヌタのキヌフレヌム到達時に発行されたす。 + +- flag埌続の匕数が有効かどうかの論理倀 + - 1敎数が有効 + - 2範囲が有効 + - 4䜍眮が有効 + - 8文字列が有効 +- intValue敎数 +- rectValue範囲 +- pointValue䜍眮 +- stringValue文字列 + +# 制限事項 + +## 動䜜しないもの + +- マスク機胜 +- 描画モヌドミックス以倖もミックス盞圓になりたす。 +- SpriteStudio Ver.7.1 で远加された新機胜(テキスト・サりンド・9スラむス・シェむプ) + +## 衚瀺が異なるもの + +- パヌツカラヌ + - [x] v1.1.1 で修正枈ミックスの頂点単䜍の時にX状(䞉角圢の蟺郚分)の茝床が高くなっおいたす。 + - [x] v1.1 で修正枈乗算でテクスチャカラヌの割合が゚ディタより倧きくなりたす。 + +## その他の制限 + +- むンスタンスの独立動䜜がOnのパヌツの再生に぀いお + - シヌン䞊で Frame プロパティが 0 以倖の状態で Play プロパティを On にしお再生開始した堎合、独立動䜜がOnに蚭定されたむンスタンスパヌツを再生させた堎合、むンスタンスパヌツの再生フレヌムがずれるこずがありたす。 + - この堎合、䞀旊 Frame プロパティの倀を 0 以倖に倉曎埌、0 に戻しおから再生開始するこずで䞀臎させられたす。 +- シェヌダヌ + - SpriteStudio公匏の䞀郚のみ察応しおいたす。 + - カスタムシェヌダヌは独自に远加・察応する必芁がありたす。 diff --git a/misc/Info.ios.plist b/misc/Info.ios.plist new file mode 100644 index 0000000..84d3d2b --- /dev/null +++ b/misc/Info.ios.plist @@ -0,0 +1,24 @@ + + + + + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleExecutable + ${BUNDLE_LIBRARY} + CFBundleName + ${BUNDLE_NAME} + CFBundleIdentifier + ${BUNDLE_IDENTIFIER} + CFBundleVersion + ${BUNDLE_VERSION} + CFBundleShortVersionString + ${BUNDLE_VERSION} + MinimumOSVersion + ${MIN_IOS_VERSION} + DTPlatformName + iphoneos + + diff --git a/misc/Info.macos.plist b/misc/Info.macos.plist new file mode 100644 index 0000000..6be9410 --- /dev/null +++ b/misc/Info.macos.plist @@ -0,0 +1,26 @@ + + + + + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleExecutable + ${BUNDLE_LIBRARY} + CFBundleName + ${BUNDLE_NAME} + CFBundleIdentifier + ${BUNDLE_IDENTIFIER} + CFBundleVersion + ${BUNDLE_VERSION} + CFBundleShortVersionString + ${BUNDLE_VERSION} + LSMinimumSystemVersion + ${MIN_MACOS_VERSION} + CFBundleSupportedPlatforms + + MacOSX + + + diff --git a/misc/ssplayer_godot_extension.gdextension b/misc/ssplayer_godot_extension.gdextension index 84a34f9..35a08ad 100644 --- a/misc/ssplayer_godot_extension.gdextension +++ b/misc/ssplayer_godot_extension.gdextension @@ -1,40 +1,32 @@ [configuration] entry_symbol = "spritestudio_godot_library_init" -compatibility_minimum = "4.3" +compatibility_minimum = "4.4" [libraries] -macos.editor = "res://bin/macos/macos.framework/libSSGodot.macos.editor" -macos.debug = "res://bin/macos/macos.framework/libSSGodot.macos.template_debug" -macos.release = "res://bin/macos/macos.framework/libSSGodot.macos.template_release" +macos.editor = "macos/libSSGodot.macos.editor.framework" +macos.debug = "macos/libSSGodot.macos.template_debug.framework" +macos.release = "macos/libSSGodot.macos.template_release.framework" -ios.debug = "res://bin/ios/ios.framework/libSSGodot.ios.template_debug.xcframework" -ios.release = "res://bin/ios/ios.framework/libSSGodot.ios.template_release.xcframework" +ios.debug = "ios/libSSGodot.ios.template_debug.framework" +ios.release = "ios/libSSGodot.ios.template_debug.framework" -windows.editor.x86_64 = "res://bin/windows/libSSGodot.windows.editor.x86_64.dll" -windows.debug.x86_64 = "res://bin/windows/libSSGodot.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://bin/windows/libSSGodot.windows.template_release.x86_64.dll" +windows.editor.x86_64 = "windows/libSSGodot.windows.editor.x86_64.dll" +windows.debug.x86_64 = "windows/libSSGodot.windows.template_debug.x86_64.dll" +windows.release.x86_64 = "windows/libSSGodot.windows.template_release.x86_64.dll" -linux.editor.x86_64 = "res://bin/linux/libSSGodot.linux.editor.x86_64.so" -linux.debug.x86_64 = "res://bin/linux/libSSGodot.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://bin/linux/libSSGodot.linux.template_release.x86_64.so" +android.debug.x86_64 = "android/libSSGodot.android.template_debug.x86_64.so" +android.release.x86_64 = "android/libSSGodot.android.template_release.x86_64.so" -linux.editor.arm64 = "res://bin/linux/libSSGodot.linux.editor.arm64.so" -linux.debug.arm64 = "res://bin/linux/libSSGodot.linux.template_debug.arm64.so" -linux.release.arm64 = "res://bin/linux/libSSGodot.linux.template_release.arm64.so" +android.debug.arm32 = "android/libSSGodot.android.template_debug.arm32.so" +android.release.arm32 = "android/libSSGodot.android.template_release.arm32.so" -linux.editor.rv64 = "res://bin/linux/libSSGodot.linux.editor.rv64.so" -linux.debug.rv64 = "res://bin/linux/libSSGodot.linux.template_debug.rv64.so" -linux.release.rv64 = "res://bin/linux/libSSGodot.linux.template_release.rv64.so" +android.debug.arm64 = "android/libSSGodot.android.template_debug.arm64.so" +android.release.arm64 = "android/libSSGodot.android.template_release.arm64.so" -android.debug.x86_64 = "res://bin/android/libSSGodot.android.template_debug.x86_64.so" -android.release.x86_64 = "res://bin/android/libSSGodot.android.template_release.x86_64.so" +web.debug.threads.wasm32 = "web/libSSGodot.web.template_debug.wasm32.wasm" +web.release.threads.wasm32 = "web/libSSGodot.web.template_release.wasm32.wasm" -android.debug.arm64 = "res://bin/android/libSSGodot.android.template_debug.arm64.so" -android.release.arm64 = "res://bin/android/libSSGodot.android.template_release.arm64.so" - -web.debug.threads.wasm32 = "res://bin/web/libSSGodot.web.template_debug.wasm32.wasm" -web.release.threads.wasm32 = "res://bin/web/libSSGodot.web.template_release.wasm32.wasm" -web.debug.wasm32 = "res://bin/web/libSSGodot.web.template_debug.wasm32.nothreads.wasm" -web.release.wasm32 = "res://bin/web/libSSGodot.web.template_release.wasm32.nothreads.wasm" \ No newline at end of file +web.debug.wasm32 = "web/libSSGodot.web.template_debug.wasm32.nothreads.wasm" +web.release.wasm32 = "web/libSSGodot.web.template_release.wasm32.nothreads.wasm" diff --git a/scripts/build-extension.sh b/scripts/build-extension.sh index 2b4c65e..ddea287 100755 --- a/scripts/build-extension.sh +++ b/scripts/build-extension.sh @@ -109,12 +109,7 @@ echo "scons command options: $scons_command_opts" pushd ${ROOTDIR} > /dev/null -if [[ "$opts[platform]" = "macos" ]] || [[ "$opts[platform]" = "ios" ]]; then - BINDIR=./bin/${opts[platform]}/${opts[platform]}.framework -else - BINDIR=./bin/${opts[platform]} -fi - +BINDIR=./bin/${opts[platform]} /bin/mkdir -p ${BINDIR} alias scons_macro="scons ${scons_command_opts}" if [[ ${opts[arch]} == "universal" ]]; then @@ -134,8 +129,9 @@ for arch in $ARCHES; do # strip ${BINDIR}/libSSGodot.macos.${opts[target]} # fi if [[ ${opts[platform]} == "ios" ]] && [[ ${opts[ios_simulator]} == "yes" ]]; then - echo mv - mv ${BINDIR}/libSSGodot.${opts[platform]}.${opts[target]} ${BINDIR}/libSSGodot.${opts[platform]}.${opts[target]}.simulator + pushd ${BINDIR} > /dev/null + mv libSSGodot.${opts[platform]}.${opts[target]}.framework libSSGodot.${opts[platform]}.${opts[target]}.simulator.framework + popd > /dev/null fi done diff --git a/scripts/release-gdextension-android.sh b/scripts/release-gdextension-android.sh index ec3d136..8f934fe 100755 --- a/scripts/release-gdextension-android.sh +++ b/scripts/release-gdextension-android.sh @@ -7,7 +7,8 @@ ROOTDIR=${BASEDIR}/.. ROOTDIR=$(cd $ROOTDIR && pwd -P) pushd ${ROOTDIR} > /dev/null - +BINDIR=$(pwd)/bin/android +/bin/rm -rf ${BINDIR} targets=("template_release" "template_debug") for target in ${targets[@]}; do scripts/build-extension.sh platform=android arch=arm32 strip=yes target=${target} diff --git a/scripts/release-gdextension-ios.sh b/scripts/release-gdextension-ios.sh index 6157139..82a110c 100755 --- a/scripts/release-gdextension-ios.sh +++ b/scripts/release-gdextension-ios.sh @@ -1,5 +1,6 @@ #!/usr/bin/env zsh set -e +set -x BASEDIR=$(dirname $0) BASEDIR=$(cd $BASEDIR && pwd -P) @@ -8,23 +9,26 @@ ROOTDIR=$(cd $ROOTDIR && pwd -P) pushd ${ROOTDIR} > /dev/null BINDIR=$(pwd)/bin/ios +/bin/rm -rf ${BINDIR} targets=("template_release" "template_debug") for target in ${targets[@]}; do - scripts/build-extension.sh platform=ios arch=universal strip=yes target=${target} ios_simulator=yes +# scripts/build-extension.sh platform=ios arch=universal strip=yes target=${target} ios_simulator=yes scripts/build-extension.sh platform=ios arch=universal strip=yes target=${target} ios_simulator=no done -# create xcframeworks pushd ${BINDIR} -for target in ${targets[@]}; do - rm -rf tmp - mkdir -p tmp/ios tmp/ios-simulator - mv $BINDIR/ios.framework/libSSGodot.ios.${target} tmp/ios/libSSGodot.ios.${target}.dylib - mv $BINDIR/ios.framework/libSSGodot.ios.${target}.simulator tmp/ios-simulator/libSSGodot.ios.${target}.dylib - xcodebuild -create-xcframework -library tmp/ios/libSSGodot.ios.${target}.dylib -library tmp/ios-simulator/libSSGodot.ios.${target}.dylib -output libSSGodot.ios.${target}.xcframework -done -rm -rf tmp -rm -rf ios.framework + +## create xcframeworks +#for target in ${targets[@]}; do +# rm -rf tmp +# mkdir -p tmp/ios tmp/ios-simulator +# mv $BINDIR/libSSGodot.ios.${target}.framework tmp/ios/libSSGodot.ios.${target}.framework +# mv $BINDIR/libSSGodot.ios.${target}.simulator.framework tmp/ios-simulator/libSSGodot.ios.${target}.framework +# xcodebuild -create-xcframework -framework tmp/ios/libSSGodot.ios.${target}.framework -framework tmp/ios-simulator/libSSGodot.ios.${target}.framework -output libSSGodot.ios.${target}.xcframework +#done +#/bin/rm -rf tmp + +/bin/rm -rf ios.framework popd > /dev/null # ${BINDIR} popd > /dev/null # ${ROOTDIR} diff --git a/scripts/release-gdextension-macos.sh b/scripts/release-gdextension-macos.sh index 4201df3..456dac1 100755 --- a/scripts/release-gdextension-macos.sh +++ b/scripts/release-gdextension-macos.sh @@ -7,10 +7,12 @@ ROOTDIR=${BASEDIR}/.. ROOTDIR=$(cd $ROOTDIR && pwd -P) pushd ${ROOTDIR} > /dev/null - +BINDIR=$(pwd)/bin/macos +/bin/rm -rf ${BINDIR} targets=("editor" "template_release" "template_debug") for target in ${targets[@]}; do scripts/build-extension.sh platform=macos arch=universal strip=yes target=${target} done +/bin/rm -rf bin/macos/macos.framework popd > /dev/null # ${ROOTDIR} diff --git a/scripts/release-gdextension-web.sh b/scripts/release-gdextension-web.sh index 692f805..ae5aacb 100755 --- a/scripts/release-gdextension-web.sh +++ b/scripts/release-gdextension-web.sh @@ -7,11 +7,12 @@ ROOTDIR=${BASEDIR}/.. ROOTDIR=$(cd $ROOTDIR && pwd -P) pushd ${ROOTDIR} > /dev/null - +BINDIR=$(pwd)/bin/web +/bin/rm -rf ${BINDIR} targets=("template_release" "template_debug") for target in ${targets[@]}; do scripts/build-extension.sh platform=web arch=wasm32 strip=yes target=${target} - # scripts/build-extension.sh platform=web arch=wasm32 strip=yes target=${target} threads=no + scripts/build-extension.sh platform=web arch=wasm32 strip=yes target=${target} threads=no done popd > /dev/null # ${ROOTDIR}