Compare commits

...

107 Commits

Author SHA1 Message Date
AlexandreS
95783fd58f Bump newIDE version 2023-01-17 15:49:19 +01:00
github-actions[bot]
a78aa4af6e Update translations [skip ci] (#4794) 2023-01-17 15:48:47 +01:00
D8H
4f4b2b7901 Replace touch conditions to also handle the mouse (#4785)
* Add expressions to get the mouse cursor position without touches moving it.
2023-01-17 15:27:58 +01:00
Tristan Rhodes
957f672b90 Add LinearVelocityAngle() expression for the Physics behavior (#4798) 2023-01-17 14:11:21 +01:00
AlexandreS
b9e932d0de Fix flaky animation frame setting action (#4835) 2023-01-17 14:04:11 +01:00
Florian Rival
fdd2362dae Show link to business plans in the subscription dialog (#4838)
As we're having more and more professionals (game designers, game studios), startups and large-scale companies using GDevelop, we're now providing dedicated plans for businesses: https://gdevelop.io/pricing. They come with dedicated support, ability to apply custom branding and more things for usage by enterprises or game studios.
2023-01-17 12:28:48 +01:00
AlexandreS
47583e3092 Fix: Display new resource created with Jfxr or Yarn in resource selector dropdown (#4834) 2023-01-16 15:24:58 +01:00
AlexandreS
8d7967d71a Commit variable name changes after build (#4833)
Do not show in changelog
2023-01-16 15:08:25 +01:00
AlexandreS
72142a62c4 Fix bug that prevented to close parameter popover on the event sheet (#4832) 2023-01-16 14:49:48 +01:00
D8H
619890a25f Fix extension life-cycle functions were not exported (#4830) 2023-01-16 14:39:55 +01:00
AlexandreS
debcd3045f Add autocompletions for some fields that can contain object groups (#4831)
* Effect name
* Effect parameter name
* Sprite point name
2023-01-16 14:37:46 +01:00
D8H
86635e4f66 Add a condition to check if the game has just resumed (#4824)
* It can be useful to display a pause menu when the player come back to the game.
2023-01-16 13:34:38 +01:00
D8H
eedc68b0f2 Fix pathfinding movement angle condition (#4825)
* Add a condition to check the movement angle of the top-down movement behavior.
2023-01-16 10:30:00 +01:00
Florian Rival
b1a6425ab8 Display, when available, video tutorials translated in other languages (#4829)
* For example, some French tutorials have been translated by https://www.youtube.com/@videogamecoder6395
* If you have some translated tutorials, please send them to us using this form: https://airtable.com/shrv295oHlsuS69el - the GDevelop team will review them and add them for your language.
2023-01-15 21:24:45 +01:00
Florian Rival
3d1ee5efcc Update yarn.lock
Don't show in changelog
2023-01-15 12:00:19 +01:00
Florian Rival
4d1fde608b Fix missing translation marker
Don't show in changelog
2023-01-14 14:19:06 +01:00
Florian Rival
e40666bd73 Improve wording of the action to set a Text Input read-only 2023-01-14 14:15:44 +01:00
Florian Rival
4a6c075e41 Fix plural in variable child count in the variables editor 2023-01-14 14:04:14 +01:00
Florian Rival
82426fa564 Fix tinting of deleted sprites sometimes wrongly used to render newly created objects (#4823)
Fix #4822
2023-01-13 14:35:37 +01:00
Florian Rival
a21eef6930 Rename the signing options to make clearer that the legacy options must not be used
Some users were trying to change the upload key when they wanted to update their app,
because they thought "new upload key" would generate a new upload key at every packaging,
instead of using the "default" key - while the other option uses a legacy key that must not
be used in 99.9% of cases

Don't show in changelog
2023-01-13 10:41:55 +01:00
D8H
c6112a1549 Allow custom objects to define an origin point (#4821)
*  Fix camera renderer position update when the center stays the same but dimensions change.
* Don't show in changelog.
2023-01-12 18:47:57 +01:00
D8H
d8350396df Add an action to toggle boolean property values (#4800) 2023-01-12 12:10:47 +01:00
Florian Rival
a8282aaf83 Add conditions to check if the game is exported as a native mobile or desktop app (#4820) 2023-01-12 11:27:47 +01:00
D8H
7de7fc7193 Allow anchored child-objects to scale with the child-object they target (#4818)
* Don't show in changelogs.
2023-01-11 23:49:08 +01:00
AlexandreS
81c5829267 Fix selection rectangle around an instance not displaying correctly for sprites with custom center (#4817) 2023-01-11 16:04:41 +01:00
D8H
07cf1a90a4 Fix a crash when an event-based object tries to access scene variables (#4816)
* Internal changes (for developers)
2023-01-11 14:11:19 +01:00
Florian Rival
3213985a81 Add two expressions to replace one or all occurrences of a text in another (#4809)
* `StrReplaceOne` can be used to replace one occurrence of a "pattern" in a text by another.
* `StrReplaceAll` can be used to replace all occurrences of a "pattern" in a text by another.
2023-01-10 12:39:59 +01:00
Clément Pasteau
d4441fda99 Disable player auth checkbox if offline and improve error message (#4810)
Do not show in changelog
2023-01-10 11:54:39 +01:00
Florian Rival
91c55fcf94 Ask for company name/size or goal when asking about GDevelop usage (#4807)
* Also ask for what's the goal for people using GDevelop for a personal/student usage. Useful to better understand the motivation of the user base.
2023-01-10 11:09:57 +01:00
D8H
6d7b5ac7d3 Add missing icons in the instruction tree (#4797) 2023-01-09 13:45:50 +01:00
Florian Rival
903b353b7b Fix LDtk maps not properly loaded when not having a IntGrid layer (#4806)
Fix #4803
2023-01-09 13:20:31 +01:00
Clément Pasteau
4dd189512b Show contact information from a feedback (#4804) 2023-01-09 12:42:09 +01:00
Clément Pasteau
535fa39a7b Fix renaming children objects of event-based Object (#4805)
Do not show in changelog
2023-01-09 12:41:41 +01:00
Daniel R
78c0cb944f Use F2 as a shortcut for renaming object in the Objects List Panel (#4682)
Thanks @danired!
Co-authored-by: Daniel Redondo <dani@easydevel.com>
2023-01-09 11:02:29 +01:00
Clément Pasteau
55e037484f Allow accessing user profile of a game feedback made by a connected player (#4796) 2023-01-09 10:58:49 +01:00
D8H
84392c08b2 Add an event that returns true when a new condition is added to an extension (#4802) 2023-01-09 09:25:47 +01:00
Florian Rival
0061b1cb8b Allow to close the Home page menu drawer by tapping outside
Don't show in changelog
2023-01-08 21:25:40 +01:00
github-actions[bot]
9e19aa8886 Update translations [skip ci] (#4750)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2023-01-06 14:40:33 +01:00
Clément Pasteau
f4b812ab29 Small fixes player auth (#4792)
* Prevent listening for liluo connection if not on web
* Catch any error when interacting with localstorage

Do not show in changelog
2023-01-06 14:39:21 +01:00
Florian Rival
106d9de47c Fix naming of filenames created from resources in an external editor (#4791)
Don't show in changelog
2023-01-05 22:52:29 +01:00
Florian Rival
ecbafe60d1 Fix crash sometimes happening when an action/condition was stored with more parameters than expected (#4786)
Don't show in changelog
2023-01-05 16:11:28 +01:00
D8H
c0ba26f1d5 Allow to add a vertex to a collision mask by pulling an edge (#4778)
* Vertices can also be removed by dropping them next to one of their neighbors.
2023-01-05 12:58:02 +01:00
AlexandreS
089be66e82 Fix top down behavior "Rotation speed" property keeping the value 180° for no reason (#4764) 2023-01-05 10:52:20 +01:00
Florian Rival
ffb8a399cd Add support for Piskel, Jfxr and Yarn on the web-app (#4779)
* When you're using the web version of GDevelop, be it on a mobile phone, tablet, Chromebook, traditional computer, on iOS, Android, Windows, Linux or macOS, you can now create and edit images with Piskel, sounds with Jfxr and dialogue trees with Yarn.
2023-01-04 22:42:50 +01:00
Clément Pasteau
63482a0cda Allow automatic player login when the game is hosted on Liluo (#4776)
Do not show in changelog
2023-01-03 16:49:25 +01:00
Clément Pasteau
4fe8dcaf0c Improve default build name (#4777)
Do not show in changelog
2023-01-03 15:35:22 +01:00
Florian Rival
9729461aa1 Add support for using Piskel (image editor), Jfxr (sound editor) and Yarn (dialogue editor) for Cloud projects on desktop (#4769) 2023-01-03 11:41:40 +01:00
D8H
26fcc9770b Add new collision mask vertices on the middle of edges (#4774) 2023-01-03 11:10:42 +01:00
D8H
c62f9c5c65 Fix missing export files for extensions (#4773) 2023-01-02 19:11:11 +01:00
Daniel R
9b199d5aa0 Fix missing space between "Add action" and "paste actions" labels (#4772) 2023-01-02 09:01:48 +01:00
AlexandreS
46e1a5c6e8 Fix Text object Scale X condition and action (#4768) 2022-12-30 11:39:03 +01:00
Aurélien Vivet
052a6240c5 Fix typo (#4766)
Don't show in changelog
2022-12-30 09:10:24 +01:00
AlexandreS
d081711838 Allow to use Escape key as way to cancel rename of object/group/scene/external layout (#4765)
* Also fix drag and drop of project manager items preventing to select text when renaming item
2022-12-30 09:05:03 +01:00
AlexandreS
f0151b2e1f Improve subscription panel and user experience (#4755) 2022-12-29 11:03:37 +01:00
AlexandreS
e2f42ca290 Fix unwelcome opening of keyboard on mobile on the app 2022-12-27 17:59:32 +01:00
Clément Pasteau
b7a3d85287 Allow opening the Game Dashboard from the Home Build page (#4730)
* This will work by default for new games
* For existing games, the option will appear the next time you save your project
2022-12-27 12:43:30 +01:00
Clément Pasteau
4b542e071a Allow navigating through asset packs of an Asset Creator from their profile (#4697) 2022-12-27 11:59:29 +01:00
Florian Rival
64cad25b81 Bump newIDE version (#4752) 2022-12-26 16:24:35 +01:00
Florian Rival
8472e30342 Show a warning about Piskel/Jfxr/Yarn not being available yet for cloud projects on desktop (#4751) 2022-12-26 16:23:29 +01:00
Clément Pasteau
1b7d258727 Remove mentions of "experimental" for features and tools widely used and supported (#4749) 2022-12-26 15:02:56 +01:00
github-actions[bot]
946b77093d Update translations [skip ci] (#4742)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-26 14:10:34 +01:00
Florian Rival
74c882f219 Fix wrong scrollbars in the Sprite editor 2022-12-26 12:50:40 +01:00
Florian Rival
abd417c494 Fix games crash because of some extensions not included in the generated games
Revert "Fix missing export files by including the free functions of every extension that is actually used (#4672)" (#4746) (commit 93121d1a1c)
2022-12-26 12:36:39 +01:00
Florian Rival
2005f9c37b Bump newIDE version 2022-12-24 11:30:25 +01:00
github-actions[bot]
b749ac1106 Update translations [skip ci] (#4736)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-24 11:21:40 +01:00
Baptiste Augrain
f34f901fa7 Add support for opacity of layers for Tiled tilemaps (#4739) 2022-12-24 11:21:03 +01:00
Florian Rival
c74110c058 Fix the storage provider default choice not being always the optimal one when running the tutorial 2022-12-23 23:29:44 +01:00
Baptiste Augrain
2a38be827c Add support for Tileset resources with .tsj extension (#4737) 2022-12-23 23:09:16 +01:00
D8H
7cd97e8cc4 Disable "missing shared data" error logs for custom objects. (#4735)
* Don't in changelog
2022-12-23 18:31:19 +01:00
github-actions[bot]
4c9445f6f5 Update translations [skip ci] (#4734)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-23 18:08:28 +01:00
Baptiste Augrain
b7772520b5 Add support for selecting directly .ldtk and .tmj files from the interface (#4733)
* Files saved from LDtk or from Tiled (using the .tmj format) can be now selected directly when choosing a Tilemap to be displayed by a Tilemap object.
2022-12-23 17:46:17 +01:00
D8H
93121d1a1c Fix missing export files by including the free functions of every extension that is actually used (#4672) 2022-12-23 17:33:52 +01:00
D8H
9f7c1a1748 Better display custom objects in the editor (#4643) 2022-12-23 17:21:47 +01:00
Florian Rival
f6fc2406a5 Fix missing menu items on web-app
Don't show in changelog
2022-12-23 15:32:37 +01:00
github-actions[bot]
daede19d0d Update translations [skip ci] (#4718)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-23 12:42:26 +01:00
Florian Rival
36e835c461 Don't enable player authentication if a tutorial is running when creating a new project
Don't show in changelog
2022-12-23 10:49:16 +01:00
Florian Rival
8d0b3ef53e Fix MarkdownText using a div instead of a span when not a standalone text
* Also add a missing translation
* Also enable player authentication by default when creating a new game
2022-12-23 10:13:58 +01:00
Florian Rival
7ccd2cd146 Update README with link to GDevelop-tutorials repository [skip ci]
* This is where the step-by-step onboarding is stored and future tutorials can be built by the community: https://github.com/GDevelopApp/GDevelop-tutorials

Only show in developer changelog
2022-12-22 22:59:40 +01:00
D8H
49974131d0 Improve installation of assets containing custom objects, like menu buttons, so that if an extension needs an update, a confirmation dialog is shown (#4724) 2022-12-22 19:27:54 +01:00
Baptiste Augrain
77320ce12e Add support for LDtk Tilemaps (#4575)
* Tilemaps made with [LDtk](https://ldtk.io/), a modern 2D level editor, can be now used directly. Make sure to save your map made in LDtk as a JSON file, create a new Tilemap object in GDevelop and in the Tilemap field, choose the LDtk file.
* Tilesets used by the LDtk Tilemap are automatically imported in your game - you don't need to import them separately.
* For more information, read about the [Tilemap object on the wiki](https://wiki.gdevelop.io/gdevelop5/objects/tilemap).

Co-authored-by: Davy Hélard <davy.helard@gmail.com>
Co-authored-by: Florian Rival <Florian.Rival@gmail.com>
2022-12-22 18:44:27 +01:00
Clément Pasteau
35833e6e23 Allow adding default player authentication when creating a project (#4714)
* New checkbox in the Project Creation dialog, which will apply best practices for player authentication on the empty project
2022-12-22 16:20:13 +01:00
AlexandreS
7436032787 Fix asset store preview (#4729)
Do not show in changelog
2022-12-22 15:48:15 +01:00
AlexandreS
aa4fd1bda9 Prefer scroll in homepage header rather than uncontrolled wrap (#4728)
Do not show in changelog
2022-12-22 11:46:04 +01:00
AlexandreS
e10dd57fed In the scene editor, paste cut instances at highest z order (#4726) 2022-12-22 10:53:26 +01:00
Florian Rival
893257491a Launch automatically the search in the asset store when typing (#4725) 2022-12-21 22:12:05 +01:00
AlexandreS
b8f04515f3 Do not close context menu when clicking on checkbox items (#4690) 2022-12-21 12:46:45 +01:00
AlexandreS
4a807b6053 Fix editor that was setting the z order of a new instance a bit randomly 2022-12-21 12:41:49 +01:00
AlexandreS
dbfef27d2e Fix leaderboard admin closing when trying to remove a leaderboard (#4691) 2022-12-21 11:08:24 +01:00
D8H
72b69e4cdf Add a sprite editor for custom objects with a locked animation list (#4719) 2022-12-21 09:32:24 +01:00
D8H
2f11cd667b Add an expression to get the number of frames in the current animation of a sprite object (#4722) 2022-12-21 09:30:03 +01:00
Florian Rival
d9de2a3177 Fix the asset store search
Don't show in changelog
2022-12-20 17:52:21 +01:00
AlexandreS
53828a6b61 Add possibility to drag n drop items in the project manager (scenes, external layouts, external events, extensions) (#4720) 2022-12-20 16:54:58 +01:00
github-actions[bot]
eb797281cf Update translations [skip ci] (#4696)
Co-authored-by: D8H <D8H@users.noreply.github.com>
2022-12-20 14:54:38 +01:00
Florian Rival
80f5a9a0d6 Add the asset store on the homepage (#4692)
* You can now browse free and premium asset packs from the home page, under the tab "Shop".
* When you have found great assets for your game, it's easy to add them in your game in a click. You can choose them to add them to a specific scene or to the whole project as global objects.
* If you're interested to sell your assets on the GDevelop asset store, check our wiki page to find how it works and the form to send us your assets: https://wiki.gdevelop.io/gdevelop5/community/sell-asset-pack-store
2022-12-20 14:49:54 +01:00
D8H
07ab4c938b Fix event-based objects properties that were changing for all instances at once (#4717)
* It was only affecting properties defined in the event-based objects not the one from child-object configurations.
2022-12-20 14:20:19 +01:00
AlexandreS
41fa153ddf Add description to a certain amount of parameters in actions and conditions (#4716) 2022-12-20 13:59:10 +01:00
Clément Pasteau
4cdac65944 Put beginner courses on top of Learn section (#4715) 2022-12-19 15:18:25 +01:00
AlexandreS
7b5036286f Fix scene background color setting via the textfield (#4713) 2022-12-19 12:42:27 +01:00
AlexandreS
fd4dd62f9b Allow text selection on game feedback cards (#4712) 2022-12-19 10:55:11 +01:00
Clément Pasteau
6701a52a88 Update shortcut to close project and quit app to match other app standards (#4711) 2022-12-19 10:51:42 +01:00
AlexandreS
0b61bb5053 Fix: Close all the dialogs at the same time when creating a project from an example (#4710) 2022-12-19 10:34:49 +01:00
AlexandreS
259e35d941 Use a constant zoom speed on the scene editor and on image preview, regardless of zoom factor (#4674) 2022-12-19 09:02:49 +01:00
Clément Pasteau
b9ac22208b Replace most float with double for better precision (#4689)
Do not show in changelog
2022-12-16 14:50:11 +01:00
Clément Pasteau
a991283bb5 Correctly display asset authors coming from premium asset packs (#4688) 2022-12-16 11:21:46 +01:00
Clément Pasteau
bf3ecceb06 Update service worker to put translations in cache (#4693)
* This should prevent unwanted {0} appearing on the web for each update
2022-12-16 09:24:32 +01:00
github-actions[bot]
b3bc1dd21b Update translations [skip ci] (#4685)
Co-authored-by: ClementPasteau <ClementPasteau@users.noreply.github.com>
2022-12-15 12:34:23 +01:00
Clément Pasteau
d63b83b606 Improve instance number properties by hiding unnecessary decimals (#4557)
* "resize", "drag" or "rotate" of an instance in the editor will now round the properties to the nearest integer for ease of use.
  * This does not prevent entering digits in the instance properties directly
* The fields do not update the instance with "0" when a user is still typing (ex: "19," does not update the field)
* The "width/height/x/y/angle" properties can now correctly accept precise float numbers, avoiding excessive and inaccurate digits
2022-12-15 12:16:12 +01:00
524 changed files with 19557 additions and 7932 deletions

View File

@@ -726,6 +726,8 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
metadata.GetType() == "fontResource" ||
metadata.GetType() == "imageResource" ||
metadata.GetType() == "jsonResource" ||
metadata.GetType() == "tilemapResource" ||
metadata.GetType() == "tilesetResource" ||
metadata.GetType() == "videoResource" ||
// Deprecated, old parameter names:
metadata.GetType() == "password" || metadata.GetType() == "musicfile" ||

View File

@@ -105,7 +105,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
"res/function32.png",
"res/function16.png")
.AddParameter("functionParameterName", "Parameter name")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
extension
.AddCondition(
@@ -117,7 +118,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
"res/function32.png",
"res/function16.png")
.AddParameter("functionParameterName", "Parameter name")
.UseStandardRelationalOperatorParameters("string");
.UseStandardRelationalOperatorParameters(
"string", gd::ParameterOptions::MakeNewOptions());
}
} // namespace gd

View File

@@ -23,6 +23,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
.SetCategory("Audio");
extension.AddInstructionOrExpressionGroupMetadata(_("Sounds and music"))
.SetIcon("res/actions/music24.png");
extension.AddInstructionOrExpressionGroupMetadata(_("Sounds on channels"))
.SetIcon("res/actions/son24.png");
extension
.AddAction("PlaySoundCanal",
@@ -146,69 +148,83 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
.AddAction("ModVolumeSoundCanal",
_("Volume of the sound on a channel"),
_("This action modifies the volume of the sound on the "
"specified channel. The volume is between 0 and 100."),
"specified channel."),
_("the volume of the sound on channel _PARAM1_"),
_("Sounds on channels"),
"res/actions/sonVolume24.png",
"res/actions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume (0-100)")))
.MarkAsAdvanced();
extension
.AddAction("ModVolumeMusicCanal",
_("Volume of the music on a channel"),
_("This action modifies the volume of the music on the "
"specified channel. The volume is between 0 and 100."),
"specified channel."),
_("the volume of the music on channel _PARAM1_"),
_("Music on channels"),
"res/actions/musicVolume24.png",
"res/actions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume (0-100)")))
.MarkAsAdvanced();
extension
.AddAction("ModGlobalVolume",
_("Game global volume"),
_("This action modifies the global volume of the game. The "
"volume is between 0 and 100."),
_("This action modifies the global volume of the game."),
_("the global sound level"),
"",
"res/actions/volume24.png",
"res/actions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume (0-100)")))
.MarkAsSimple();
extension
.AddAction("ModPitchSoundChannel",
_("Pitch of the sound of a channel"),
_("This action modifies the pitch (speed) of the sound on a "
"channel.\n1 is the default pitch."),
"channel."),
_("the pitch of the sound on channel _PARAM1_"),
_("Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Pitch (1 by default)")))
.MarkAsAdvanced();
extension
.AddAction("ModPitchMusicChannel",
_("Pitch of the music on a channel"),
_("This action modifies the pitch of the music on the "
"specified channel. 1 is the default pitch"),
"specified channel."),
_("the pitch of the music on channel _PARAM1_"),
_("Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Pitch (1 by default)")))
.MarkAsAdvanced();
extension
@@ -222,7 +238,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Position (in seconds)")))
.MarkAsAdvanced();
extension
@@ -236,7 +255,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Position (in seconds)")))
.MarkAsAdvanced();
extension
@@ -448,15 +470,17 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
.AddCondition(
"SoundCanalVolume",
_("Volume of the sound on a channel"),
_("Test the volume of the sound on the specified channel. The volume "
"is between 0 and 100."),
_("Test the volume of the sound on the specified channel."),
_("the volume of the sound on channel _PARAM1_"),
_("Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume to compare to (0-100)")))
.MarkAsAdvanced();
extension
@@ -471,7 +495,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume to compare to (0-100)")))
.MarkAsAdvanced();
extension
@@ -484,7 +511,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/conditions/volume24.png",
"res/conditions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Volume to compare to (0-100)")));
extension
.AddCondition(
@@ -498,22 +528,27 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Pitch to compare to (1 by default)")))
.MarkAsAdvanced();
extension
.AddCondition(
"MusicChannelPitch",
_("Pitch of the music on a channel"),
_("Test the pitch (speed) of the music on a specified channel. 1 is "
"the default pitch."),
_("Test the pitch (speed) of the music on a specified channel."),
_("the pitch of the music on channel _PARAM1_"),
_("Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Pitch to compare to (1 by default)")))
.MarkAsAdvanced();
extension
@@ -527,7 +562,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Position to compare to (in seconds)")))
.MarkAsAdvanced();
extension
@@ -541,7 +579,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Position to compare to (in seconds)")))
.MarkAsAdvanced();
extension

View File

@@ -40,7 +40,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/position_black.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsSimple();
obj.AddAction("MettreX",
@@ -52,7 +53,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/actions/position_black.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsSimple();
obj.AddCondition("PosY",
@@ -64,7 +66,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/position_black.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsSimple();
obj.AddAction("MettreY",
@@ -76,7 +79,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/actions/position_black.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsSimple();
obj.AddAction("MettreXY",
@@ -120,7 +124,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Center"),
"res/actions/position24_black.png")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndConditionAndAction(
"number",
@@ -131,7 +135,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Center"),
"res/actions/position24_black.png")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition("number",
"BoundingBoxLeft",
@@ -142,7 +146,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-left_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition(
"number",
@@ -153,7 +157,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-top_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition("number",
"BoundingBoxRight",
@@ -164,7 +168,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-right_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition("number",
"BoundingBoxBottom",
@@ -175,7 +179,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-bottom_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition("number",
"BoundingBoxCenterX",
@@ -186,7 +190,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-center_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddExpressionAndCondition("number",
"BoundingBoxCenterY",
@@ -197,7 +201,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position/Bounding Box"),
"res/conditions/bounding-box-center_black.svg")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
.UseStandardParameters("number", ParameterOptions::MakeNewOptions());
obj.AddAction("MettreAutourPos",
_("Put around a position"),
@@ -226,7 +230,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/actions/direction_black.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")));
obj.AddAction("Rotate",
_("Rotate"),
@@ -382,7 +389,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/actions/planicon.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions());
obj.AddAction("ChangeLayer",
_("Layer"),
@@ -407,7 +415,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions());
obj.AddAction("ModVarObjetTxt",
_("Text of an object variable"),
@@ -419,7 +428,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardOperatorParameters("string");
.UseStandardOperatorParameters("string",
ParameterOptions::MakeNewOptions());
obj.AddAction("SetObjectVariableAsBoolean",
_("Boolean value of an object variable"),
@@ -516,7 +526,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/direction_black.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")))
.MarkAsAdvanced();
obj.AddCondition("Plan",
@@ -528,7 +541,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/planicon.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("Layer",
@@ -585,7 +599,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/vitesse.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("AngleOfDisplacement",
@@ -613,7 +628,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions());
obj.AddCondition("VarObjetTxt",
_("Text of an object variable"),
@@ -625,7 +641,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardRelationalOperatorParameters("string");
.UseStandardRelationalOperatorParameters(
"string", ParameterOptions::MakeNewOptions());
obj.AddCondition("ObjectVariableAsBoolean",
_("Boolean value of an object variable"),
@@ -1423,34 +1440,39 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/conditions/nbObjet24.png",
"res/conditions/nbObjet.png")
.AddParameter("objectList", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsSimple()
.SetHidden();
extension.AddExpressionAndCondition(
"number",
"SceneInstancesCount",
_("Number of object instances on the scene"),
_("the number of instances of the specified objects living on the scene"),
_("the number of _PARAM1_ living on the scene"),
_("Objects"),
"res/conditions/nbObjet24.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
.UseStandardParameters("number")
.MarkAsSimple();
extension
.AddExpressionAndCondition(
"number",
"SceneInstancesCount",
_("Number of object instances on the scene"),
_("the number of instances of the specified objects living on the "
"scene"),
_("the number of _PARAM1_ living on the scene"),
_("Objects"),
"res/conditions/nbObjet24.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsSimple();
extension.AddExpressionAndCondition(
"number",
"PickedInstancesCount",
_("Number of object instances currently picked"),
_("the number of instances picked by the previous conditions (or actions)"),
_("the number of _PARAM0_ currently picked"),
_("Objects"),
"res/conditions/nbObjet24.png")
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
.UseStandardParameters("number")
.MarkAsSimple();
extension
.AddExpressionAndCondition(
"number",
"PickedInstancesCount",
_("Number of object instances currently picked"),
_("the number of instances picked by the previous conditions (or "
"actions)"),
_("the number of _PARAM0_ currently picked"),
_("Objects"),
"res/conditions/nbObjet24.png")
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsSimple();
extension
.AddCondition(
@@ -1559,7 +1581,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"",
"res/conditions/nbObjet.png")
.AddParameter("objectList", _("Object"))
.SetHidden(); // Deprecated
.SetHidden(); // Deprecated
obj.AddStrExpression("ObjectName",
_("Object name"),

View File

@@ -26,6 +26,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.SetExtensionHelpPath("/interface/scene-editor/layers-and-cameras");
extension.AddInstructionOrExpressionGroupMetadata(_("Layers and cameras"))
.SetIcon("res/conditions/camera24.png");
extension.AddInstructionOrExpressionGroupMetadata(_("Effects"))
.SetIcon("res/actions/effect24.png");
extension
.AddExpressionAndConditionAndAction(
@@ -37,7 +39,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"",
"res/conditions/camera24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
@@ -69,7 +71,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"",
"res/conditions/camera24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
@@ -104,7 +106,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -120,7 +122,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -137,7 +139,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -154,7 +156,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -171,7 +173,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -188,7 +190,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"), "", true)
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -201,7 +203,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"",
"res/conditions/camera24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
@@ -453,8 +455,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"names) in the effects window."),
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
_("Effects"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
"res/actions/effect24.png",
"res/actions/effect.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
@@ -472,8 +474,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"names) in the effects window."),
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
_("Effects"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
"res/actions/effect24.png",
"res/actions/effect.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
@@ -491,8 +493,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"names) in the effects window."),
_("Enable _PARAM3_ for effect _PARAM2_ of layer _PARAM1_: _PARAM4_"),
_("Effects"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
"res/actions/effect24.png",
"res/actions/effect.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
@@ -506,9 +508,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
_("Layer effect is enabled"),
_("The effect on a layer is enabled"),
_("Effect _PARAM2_ on layer _PARAM1_ is enabled"),
_("Effects"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
_(""),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
@@ -521,8 +523,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
_("Enable an effect on a layer"),
_("Enable effect _PARAM2_ on layer _PARAM1_: _PARAM3_"),
_("Effects"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
"res/actions/effect24.png",
"res/actions/effect.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
@@ -542,7 +544,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Time scale (1 by default)")))
.MarkAsAdvanced();
extension
@@ -572,7 +577,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -597,7 +603,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
_("Set the ambient light color of the lighting layer in format "
"\"R;G;B\" string."),
_("Set the ambient color of the lighting layer _PARAM1_ to _PARAM2_"),
_("Lighting"),
_(""),
"res/actions/color24.png",
"res/actions/color.png")
.AddCodeOnlyParameter("currentScene", "")

View File

@@ -27,6 +27,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
.SetCategory("Input");
extension.AddInstructionOrExpressionGroupMetadata(_("Mouse and touch"))
.SetIcon("res/actions/mouse24.png");
extension.AddInstructionOrExpressionGroupMetadata(_("Multitouch"))
.SetIcon("res/conditions/touch24.png");
extension
.AddCondition(
@@ -153,42 +155,82 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
extension
.AddExpressionAndCondition(
"number",
"MouseX",
"CursorX",
_("Cursor X position"),
_("the X position of the cursor or of a touch"),
_("the cursor (or touch) X position"),
"",
"res/conditions/mouse24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
// Support for deprecated names:
extension.AddDuplicatedCondition("SourisX", "MouseX").SetHidden();
extension.AddDuplicatedExpression("SourisX", "MouseX").SetHidden();
extension.AddDuplicatedCondition("MouseX", "CursorX").SetHidden();
extension.AddDuplicatedExpression("MouseX", "CursorX").SetHidden();
extension.AddDuplicatedCondition("SourisX", "CursorX").SetHidden();
extension.AddDuplicatedExpression("SourisX", "CursorX").SetHidden();
extension
.AddExpressionAndCondition(
"number",
"MouseY",
"CursorY",
_("Cursor Y position"),
_("the Y position of the cursor or of a touch"),
_("the cursor (or touch) Y position"),
"",
"res/conditions/mouse24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
// Support for deprecated names:
extension.AddDuplicatedCondition("SourisY", "MouseY").SetHidden();
extension.AddDuplicatedExpression("SourisY", "MouseY").SetHidden();
extension.AddDuplicatedCondition("MouseY", "CursorY").SetHidden();
extension.AddDuplicatedExpression("MouseY", "CursorY").SetHidden();
extension.AddDuplicatedCondition("SourisY", "CursorY").SetHidden();
extension.AddDuplicatedExpression("SourisY", "CursorY").SetHidden();
extension
.AddExpressionAndCondition(
"number",
"MouseOnlyCursorX",
_("Mouse cursor X position"),
_("the X position of the mouse cursor"),
_("the mouse cursor X position"),
"",
"res/conditions/mouse24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
// It's only useful for extensions as they can't use TouchSimulateMouse.
.SetHidden();
extension
.AddExpressionAndCondition(
"number",
"MouseOnlyCursorY",
_("Mouse cursor Y position"),
_("the Y position of the mouse cursor"),
_("the mouse cursor Y position"),
"",
"res/conditions/mouse24.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
// It's only useful for extensions as they can't use TouchSimulateMouse.
.SetHidden();
extension
.AddCondition("IsMouseInsideCanvas",
@@ -276,7 +318,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
"res/conditions/touch24.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
@@ -292,7 +334,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
"res/conditions/touch24.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.UseStandardParameters("number")
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
@@ -340,7 +382,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
_("Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
.AddCodeOnlyParameter("currentScene", "")
.SetHidden();
extension
.AddExpression(
@@ -350,7 +393,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
"accessed using StartedTouchId()."),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
.AddCodeOnlyParameter("currentScene", "")
.SetHidden();
extension
.AddExpression(
@@ -361,13 +405,50 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch index"))
.SetHidden();
extension
.AddCondition(
"HasAnyTouchOrMouseStarted",
_("A new touch has started"),
_("Check if a touch has just started or the mouse left button has "
"been pressed on this frame. The touch identifiers can be "
"accessed using StartedTouchOrMouseId() and StartedTouchOrMouseCount()."),
_("A new touch has started"),
_("Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddExpression(
"StartedTouchOrMouseCount",
_("Started touch count"),
_("The number of touches (including the mouse) that have just "
"started on this frame. The touch identifiers can be "
"accessed using StartedTouchOrMouseCount()."),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddExpression(
"StartedTouchOrMouseId",
_("Started touch identifier"),
_("The identifier of the touch or mouse that has just started on "
"this frame. The touch number of touches can be "
"accessed using StartedTouchOrMouseCount()."),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch index"));
extension
.AddCondition(
"HasTouchEnded",
_("A touch has ended"),
_("Check if a touch has ended."),
_("Check if a touch has ended or a mouse left button has been released."),
_("The touch with identifier _PARAM1_ has ended"),
_("Multitouch"),
"res/conditions/touch24.png",

View File

@@ -136,6 +136,20 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Deactivate input when focus is lost"))
.MarkAsAdvanced();
extension
.AddCondition(
"HasGameJustResumed",
_("Game has just resumed"),
_("Check if the game has just resumed from being hidden. It "
"happens when the game tab is selected, a minimized window is "
"restored or the application is put back on front."),
_("Game has just resumed"),
"",
"res/actions/window24.png",
"res/actions/window.png")
.SetHelpPath("/interface/scene-editor/events")
.AddCodeOnlyParameter("currentScene", "");
}
} // namespace gd

View File

@@ -31,7 +31,7 @@ class GD_CORE_API Point {
/**
* Change point position.
*/
void SetXY(float x_, float y_) {
void SetXY(double x_, double y_) {
x = x_;
y = y_;
}
@@ -39,27 +39,27 @@ class GD_CORE_API Point {
/**
* Change point X position.
*/
void SetX(float x_) { x = x_; }
void SetX(double x_) { x = x_; }
/**
* Change point Y position.
*/
void SetY(float y_) { y = y_; }
void SetY(double y_) { y = y_; }
/**
* Get point X position.
*/
float GetX() const { return x; }
double GetX() const { return x; }
/**
* Get point Y position.
*/
float GetY() const { return y; }
double GetY() const { return y; }
private:
gd::String name;
float x;
float y;
double x;
double y;
};
#endif // GDCORE_POINT_H

View File

@@ -4,13 +4,15 @@
* reserved. This project is released under the MIT License.
*/
#include "Polygon2d.h"
#include "GDCore/Vector2.h"
#include <cmath>
#include <iostream>
void Polygon2d::Rotate(float angle) {
float t, cosa = cos(-angle),
sina = sin(-angle); // We want a clockwise rotation
#include "GDCore/Vector2.h"
void Polygon2d::Rotate(double angle) {
double t, cosa = cos(-angle),
sina = sin(-angle); // We want a clockwise rotation
for (std::size_t i = 0; i < vertices.size(); ++i) {
t = vertices[i].x;
@@ -19,7 +21,7 @@ void Polygon2d::Rotate(float angle) {
}
}
void Polygon2d::Move(float x, float y) {
void Polygon2d::Move(double x, double y) {
for (std::size_t i = 0; i < vertices.size(); i++) {
vertices[i].x += x;
vertices[i].y += y;
@@ -50,13 +52,13 @@ bool Polygon2d::IsConvex() const {
(edges[0].x * edges[0 + 1].y - edges[0].y * edges[0 + 1].x) > 0;
for (std::size_t i = 1; i < edges.size() - 1; ++i) {
float zCrossProduct =
double zCrossProduct =
edges[i].x * edges[i + 1].y - edges[i].y * edges[i + 1].x;
if ((zCrossProduct > 0) != zProductIsPositive) return false;
}
float lastZCrossProduct = edges[edges.size() - 1].x * edges[0].y -
edges[edges.size() - 1].y * edges[0].x;
double lastZCrossProduct = edges[edges.size() - 1].x * edges[0].y -
edges[edges.size() - 1].y * edges[0].x;
if ((lastZCrossProduct > 0) != zProductIsPositive) return false;
return true;
@@ -75,7 +77,7 @@ gd::Vector2f Polygon2d::ComputeCenter() const {
return center;
}
Polygon2d Polygon2d::CreateRectangle(float width, float height) {
Polygon2d Polygon2d::CreateRectangle(double width, double height) {
Polygon2d rect;
rect.vertices.push_back(gd::Vector2f(-width / 2.0f, -height / 2.0f));
rect.vertices.push_back(gd::Vector2f(+width / 2.0f, -height / 2.0f));

View File

@@ -5,9 +5,10 @@
*/
#ifndef GDCORE_POLYGON_H
#define GDCORE_POLYGON_H
#include "GDCore/Vector2.h"
#include <vector>
#include "GDCore/Vector2.h"
/**
* \brief Represents a polygon. Usually used for collisions masks.
*
@@ -42,7 +43,7 @@ class GD_CORE_API Polygon2d {
* \note Edges are updated, there is no need to call ComputeEdges after
* calling Move.
*/
void Move(float x, float y);
void Move(double x, double y);
/**
* \brief Rotate the polygon.
@@ -52,7 +53,7 @@ class GD_CORE_API Polygon2d {
* \warning edges vector is not updated, you have to call ComputeEdges if
* needed.
*/
void Rotate(float angle);
void Rotate(double angle);
/**
* \brief Automatically fill edges vector using vertices.
@@ -77,7 +78,7 @@ class GD_CORE_API Polygon2d {
/**
* \brief Create a rectangle
*/
static Polygon2d CreateRectangle(float width, float height);
static Polygon2d CreateRectangle(double width, double height);
///@}
};

View File

@@ -44,7 +44,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity (0-255)")))
.MarkAsSimple();
obj.AddAction("ChangeAnimation",
@@ -57,7 +60,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsSimple();
obj.AddAction("SetAnimationName",
@@ -86,7 +90,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
.SetHidden() // Hide as 8 direction is not supported officially in the
// interface.
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("ChangeSprite",
@@ -98,7 +103,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("PauseAnimation",
@@ -134,7 +140,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(_("Speed scale")))
.MarkAsSimple();
obj.AddAction("TourneVersPos",
@@ -162,7 +170,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/scale_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddAction("ChangeScaleWidth",
@@ -174,7 +185,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddAction("ChangeScaleHeight",
@@ -186,7 +200,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddAction("ChangeWidth",
@@ -198,7 +215,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("Width",
@@ -210,7 +228,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("ChangeHeight",
@@ -222,7 +241,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/actions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("Height",
@@ -234,7 +254,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("SetSize",
@@ -260,7 +281,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("AnimationName",
@@ -288,7 +310,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
.SetHidden() // Hide as 8 direction is not supported officially in the
// interface.
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions());
obj.AddCondition("Sprite",
_("Current frame"),
@@ -301,7 +324,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/sprite.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddCondition("AnimStopped",
@@ -349,7 +373,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddCondition("ScaleHeight",
@@ -361,7 +388,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddCondition("Opacity",
@@ -374,7 +404,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity to compare to (0-255)")))
.MarkAsSimple();
obj.AddCondition(
@@ -387,7 +420,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("ChangeColor",
@@ -549,7 +583,14 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
obj.AddExpression("Sprite",
_("Image"),
_("Animation frame of the object"),
_("Current frame of the animation of the object"),
_("Animations and images"),
"res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("AnimationFrameCount",
_("Number of frames"),
_("Number of frames in the current animation of the object"),
_("Animations and images"),
"res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite");

View File

@@ -183,6 +183,26 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
_("Position of the last character in the string to be "
"considered in the search"));
extension
.AddStrExpression("StrReplaceOne",
_("Replace the first occurrence of a text by another."),
_("Replace the first occurrence of a text by another."),
"",
"res/conditions/toujours24_black.png")
.AddParameter("string", _("Text in which the replacement must be done"))
.AddParameter("string", _("Text to find inside the first text"))
.AddParameter("string", _("Replacement to put instead of the text to find"));
extension
.AddStrExpression("StrReplaceAll",
_("Replace all occurrences of a text by another."),
_("Replace all occurrences of a text by another."),
"",
"res/conditions/toujours24_black.png")
.AddParameter("string", _("Text in which the replacement(s) must be done"))
.AddParameter("string", _("Text to find inside the first text"))
.AddParameter("string", _("Replacement to put instead of the text to find"));
}
} // namespace gd

View File

@@ -65,7 +65,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
"res/conditions/time24.png",
"res/conditions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Time scale (1 by default)")))
.MarkAsAdvanced();
extension
@@ -148,7 +151,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
extension
.AddAction("Wait",
_("Wait X seconds (experimental)"),
_("Wait X seconds"),
_("Waits a number of seconds before running "
"the next actions (and sub-events)."),
_("Wait _PARAM0_ seconds"),

View File

@@ -34,7 +34,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("scenevar", _("Variable"))
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions());
extension
.AddCondition("VarSceneTxt",
@@ -45,7 +46,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("scenevar", _("Variable"))
.UseStandardRelationalOperatorParameters("string");
.UseStandardRelationalOperatorParameters(
"string", ParameterOptions::MakeNewOptions());
extension
.AddCondition(
@@ -107,7 +109,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("globalvar", _("Variable"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -119,7 +122,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("globalvar", _("Variable"))
.UseStandardRelationalOperatorParameters("string")
.UseStandardRelationalOperatorParameters(
"string", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -157,7 +161,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"))
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions());
extension
.AddAction("ModVarSceneTxt",
@@ -168,7 +173,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"))
.UseStandardOperatorParameters("string");
.UseStandardOperatorParameters("string",
ParameterOptions::MakeNewOptions());
extension
.AddAction(
@@ -203,7 +209,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"))
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
@@ -215,7 +222,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"))
.UseStandardOperatorParameters("string")
.UseStandardOperatorParameters("string",
ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension

View File

@@ -94,13 +94,15 @@ InstructionMetadata& InstructionMetadata::AddCodeOnlyParameter(
}
InstructionMetadata& InstructionMetadata::UseStandardOperatorParameters(
const gd::String& type, const gd::String& typeExtraInfo) {
const gd::String& type, const ParameterOptions &options) {
const gd::String& expressionValueType =
gd::ValueTypeMetadata::GetPrimitiveValueType(type);
SetManipulatedType(expressionValueType);
if (type == "boolean") {
AddParameter("yesorno", _("New value"));
AddParameter(
"yesorno",
options.description.empty() ? _("New value") : options.description);
size_t valueParamIndex = parameters.size() - 1;
if (isObjectInstruction || isBehaviorInstruction) {
@@ -122,7 +124,9 @@ InstructionMetadata& InstructionMetadata::UseStandardOperatorParameters(
}
} else {
AddParameter("operator", _("Modification's sign"), expressionValueType);
AddParameter(type, _("Value"), typeExtraInfo);
AddParameter(type,
options.description.empty() ? _("Value") : options.description,
options.typeExtraInfo);
size_t operatorParamIndex = parameters.size() - 2;
size_t valueParamIndex = parameters.size() - 1;
@@ -155,7 +159,7 @@ InstructionMetadata& InstructionMetadata::UseStandardOperatorParameters(
InstructionMetadata&
InstructionMetadata::UseStandardRelationalOperatorParameters(
const gd::String& type, const gd::String& typeExtraInfo) {
const gd::String& type, const ParameterOptions &options) {
const gd::String& expressionValueType =
gd::ValueTypeMetadata::GetPrimitiveValueType(type);
SetManipulatedType(expressionValueType);
@@ -175,7 +179,9 @@ InstructionMetadata::UseStandardRelationalOperatorParameters(
}
} else {
AddParameter("relationalOperator", _("Sign of the test"), expressionValueType);
AddParameter(type, _("Value to compare"), typeExtraInfo);
AddParameter(type,
options.description.empty() ? _("Value to compare") : options.description,
options.typeExtraInfo);
size_t operatorParamIndex = parameters.size() - 2;
size_t valueParamIndex = parameters.size() - 1;

View File

@@ -14,6 +14,8 @@
#include "GDCore/Events/Instruction.h"
#include "GDCore/String.h"
#include "ParameterMetadata.h"
#include "ParameterOptions.h"
namespace gd {
class Project;
class Layout;
@@ -109,8 +111,8 @@ class GD_CORE_API InstructionMetadata {
}
/**
* Check if the instruction asynchronicity is optional. If it is, it can either
* be used synchronously or asynchronously, with one function for each.
* Check if the instruction asynchronicity is optional. If it is, it can
* either be used synchronously or asynchronously, with one function for each.
*/
bool IsOptionallyAsync() const {
return IsAsync() && !codeExtraInformation.functionCallName.empty();
@@ -223,21 +225,22 @@ class GD_CORE_API InstructionMetadata {
/**
* \brief Add the default parameters for an instruction manipulating the
* specified type ("string", "number") with the default operators.
*
*
* \note The type "string" can be declined in several subtypes.
* \see ParameterMetadata
*/
InstructionMetadata &UseStandardOperatorParameters(const gd::String &type, const gd::String& typeExtraInfo = "");
InstructionMetadata &UseStandardOperatorParameters(
const gd::String &type, const ParameterOptions &options);
/**
* \brief Add the default parameters for an instruction comparing the
* specified type ("string", "number") with the default relational operators.
*
*
* \note The type "string" can be declined in several subtypes.
* \see ParameterMetadata
*/
InstructionMetadata &UseStandardRelationalOperatorParameters(
const gd::String &type, const gd::String& typeExtraInfo = "");
const gd::String &type, const ParameterOptions &options);
/**
* \brief Mark the instruction as an object instruction. Automatically called
@@ -334,11 +337,12 @@ class GD_CORE_API InstructionMetadata {
}
/**
* Set the name of the function, doing asynchronous work, which will be called in
* the generated code. This function should return an asynchronous task
* (i.e: `gdjs.AsyncTask` in the JavaScript runtime).
* Set the name of the function, doing asynchronous work, which will be
* called in the generated code. This function should return an asynchronous
* task (i.e: `gdjs.AsyncTask` in the JavaScript runtime).
*
* \param functionName the name of the function doing asynchronous work to call.
* \param functionName the name of the function doing asynchronous work to
* call.
*/
ExtraInformation &SetAsyncFunctionName(const gd::String &functionName_) {
asyncFunctionCallName = functionName_;
@@ -482,12 +486,12 @@ class GD_CORE_API InstructionMetadata {
}
/**
* Set the name of the function, doing asynchronous work, which will be called in
* the generated code. This function should return an asynchronous task
* Set the name of the function, doing asynchronous work, which will be called
* in the generated code. This function should return an asynchronous task
* (i.e: `gdjs.AsyncTask` in the JavaScript runtime).
*
* \param functionName the name of the function doing asynchronous work to call.
* \note Shortcut for `codeExtraInformation.SetAsyncFunctionName`.
* \param functionName the name of the function doing asynchronous work to
* call. \note Shortcut for `codeExtraInformation.SetAsyncFunctionName`.
*/
ExtraInformation &SetAsyncFunctionName(const gd::String &functionName) {
return codeExtraInformation.SetAsyncFunctionName(functionName);
@@ -512,7 +516,7 @@ class GD_CORE_API InstructionMetadata {
/**
* \brief Get the files that must be included to use the instruction.
*/
const std::vector<gd::String>& GetIncludeFiles() const {
const std::vector<gd::String> &GetIncludeFiles() const {
return codeExtraInformation.GetIncludeFiles();
};

View File

@@ -8,6 +8,8 @@
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
#include "GDCore/String.h"
#include "ParameterOptions.h"
namespace gd {} // namespace gd
namespace gd {
@@ -32,8 +34,7 @@ class GD_CORE_API MultipleInstructionMetadata {
return MultipleInstructionMetadata(expression, condition, action);
}
static MultipleInstructionMetadata WithConditionAndAction(
gd::InstructionMetadata &condition,
gd::InstructionMetadata &action) {
gd::InstructionMetadata &condition, gd::InstructionMetadata &action) {
return MultipleInstructionMetadata(condition, action);
}
@@ -83,7 +84,8 @@ class GD_CORE_API MultipleInstructionMetadata {
/**
* \see gd::InstructionMetadata::SetParameterExtraInfo
*/
MultipleInstructionMetadata &SetParameterExtraInfo(const gd::String &defaultValue) {
MultipleInstructionMetadata &SetParameterExtraInfo(
const gd::String &defaultValue) {
if (expression) expression->SetParameterExtraInfo(defaultValue);
if (condition) condition->SetParameterExtraInfo(defaultValue);
if (action) action->SetParameterExtraInfo(defaultValue);
@@ -126,9 +128,11 @@ class GD_CORE_API MultipleInstructionMetadata {
* \see gd::InstructionMetadata::UseStandardOperatorParameters
* \see gd::InstructionMetadata::UseStandardRelationalOperatorParameters
*/
MultipleInstructionMetadata &UseStandardParameters(const gd::String &type, const gd::String& typeExtraInfo = "") {
if (condition) condition->UseStandardRelationalOperatorParameters(type, typeExtraInfo);
if (action) action->UseStandardOperatorParameters(type, typeExtraInfo);
MultipleInstructionMetadata &UseStandardParameters(
const gd::String &type, const ParameterOptions &options) {
if (condition)
condition->UseStandardRelationalOperatorParameters(type, options);
if (action) action->UseStandardOperatorParameters(type, options);
return *this;
}
@@ -167,13 +171,12 @@ class GD_CORE_API MultipleInstructionMetadata {
/**
* \brief Get the files that must be included to use the instruction.
*/
const std::vector<gd::String>& GetIncludeFiles() const {
const std::vector<gd::String> &GetIncludeFiles() const {
if (expression)
return expression->GetCodeExtraInformation().GetIncludeFiles();
if (condition)
return condition->GetCodeExtraInformation().GetIncludeFiles();
if (action)
return action->GetCodeExtraInformation().GetIncludeFiles();
if (action) return action->GetCodeExtraInformation().GetIncludeFiles();
// It can't actually happen.
throw std::logic_error("no instruction metadata");
}
@@ -182,12 +185,9 @@ class GD_CORE_API MultipleInstructionMetadata {
* \see gd::InstructionMetadata::SetPrivate
*/
MultipleInstructionMetadata &SetPrivate() {
if (expression)
expression->SetPrivate();
if (condition)
condition->SetPrivate();
if (action)
action->SetPrivate();
if (expression) expression->SetPrivate();
if (condition) condition->SetPrivate();
if (action) action->SetPrivate();
return *this;
}

View File

@@ -0,0 +1,35 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef PARAMETEROPTIONS_H
#define PARAMETEROPTIONS_H
#include "GDCore/String.h"
#include "ParameterMetadata.h"
namespace gd {} // namespace gd
namespace gd {
struct GD_CORE_API ParameterOptions {
gd::String description;
gd::String typeExtraInfo;
ParameterOptions &SetDescription(const gd::String &description_) {
description = description_;
return *this;
}
ParameterOptions &SetTypeExtraInfo(const gd::String &typeExtraInfo_) {
typeExtraInfo = typeExtraInfo_;
return *this;
}
static ParameterOptions MakeNewOptions() {
ParameterOptions emptyOptions;
return emptyOptions;
}
};
}
#endif // PARAMETEROPTIONS_H

View File

@@ -2,6 +2,7 @@
#include "GDCore/Events/Instruction.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/IDE/WholeProjectRefactorer.h"
#include "GDCore/IDE/Events/ExpressionTypeFinder.h"
@@ -11,30 +12,36 @@
namespace gd {
std::set<gd::String> UsedExtensionsFinder::ScanProject(gd::Project& project) {
const UsedExtensionsResult UsedExtensionsFinder::ScanProject(gd::Project& project) {
UsedExtensionsFinder worker(project);
gd::WholeProjectRefactorer::ExposeProjectObjects(project, worker);
gd::WholeProjectRefactorer::ExposeProjectEvents(project, worker);
return worker.usedExtensions;
return worker.result;
};
// Objects scanner
void UsedExtensionsFinder::DoVisitObject(gd::Object& object) {
usedExtensions.insert(gd::MetadataProvider::GetExtensionAndObjectMetadata(
project.GetCurrentPlatform(), object.GetType())
.GetExtension()
.GetName());
void UsedExtensionsFinder::DoVisitObject(gd::Object &object) {
auto metadata = gd::MetadataProvider::GetExtensionAndObjectMetadata(
project.GetCurrentPlatform(), object.GetType());
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
result.GetUsedIncludeFiles().insert(includeFile);
}
};
// Behaviors scanner
void UsedExtensionsFinder::DoVisitBehavior(gd::Behavior& behavior) {
usedExtensions.insert(
gd::MetadataProvider::GetExtensionAndBehaviorMetadata(
project.GetCurrentPlatform(), behavior.GetTypeName())
.GetExtension()
.GetName());
void UsedExtensionsFinder::DoVisitBehavior(gd::Behavior &behavior) {
auto metadata = gd::MetadataProvider::GetExtensionAndBehaviorMetadata(
project.GetCurrentPlatform(), behavior.GetTypeName());
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
result.GetUsedIncludeFiles().insert(includeFile);
}
for (auto &&includeFile : metadata.GetMetadata().requiredFiles) {
result.GetUsedRequiredFiles().insert(includeFile);
}
};
// Instructions scanner
@@ -46,23 +53,29 @@ bool UsedExtensionsFinder::DoVisitInstruction(gd::Instruction& instruction,
project.GetCurrentPlatform(), instruction.GetType())
: gd::MetadataProvider::GetExtensionAndActionMetadata(
project.GetCurrentPlatform(), instruction.GetType());
usedExtensions.insert(metadata.GetExtension().GetName());
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) {
result.GetUsedIncludeFiles().insert(includeFile);
}
size_t i = 0;
for (auto expression : instruction.GetParameters()) {
const gd::String& parameterType =
metadata.GetMetadata().GetParameter(i).GetType();
i++;
gd::ParameterMetadataTools::IterateOverParameters(
instruction.GetParameters(),
metadata.GetMetadata().GetParameters(),
[this](const gd::ParameterMetadata& parameterMetadata,
const gd::Expression& parameterValue,
const gd::String& lastObjectName) {
const gd::String& parameterType = parameterMetadata.GetType();
if (gd::ParameterMetadata::IsExpression("string", parameterType)) {
rootType = "string";
expression.GetRootNode()->Visit(*this);
parameterValue.GetRootNode()->Visit(*this);
} else if (gd::ParameterMetadata::IsExpression("number", parameterType)) {
rootType = "number";
expression.GetRootNode()->Visit(*this);
parameterValue.GetRootNode()->Visit(*this);
} else if (gd::ParameterMetadata::IsExpression("variable", parameterType))
usedExtensions.insert("BuiltinVariables");
}
result.GetUsedExtensions().insert("BuiltinVariables");
});
return false;
}
@@ -93,31 +106,35 @@ void UsedExtensionsFinder::OnVisitUnaryOperatorNode(UnaryOperatorNode& node) {
// Add variable extension and visit sub-expressions on variable nodes
void UsedExtensionsFinder::OnVisitVariableNode(VariableNode& node) {
usedExtensions.insert("BuiltinVariables");
result.GetUsedExtensions().insert("BuiltinVariables");
if (node.child) node.child->Visit(*this);
};
void UsedExtensionsFinder::OnVisitVariableAccessorNode(
VariableAccessorNode& node) {
usedExtensions.insert("BuiltinVariables");
result.GetUsedExtensions().insert("BuiltinVariables");
if (node.child) node.child->Visit(*this);
};
void UsedExtensionsFinder::OnVisitVariableBracketAccessorNode(
VariableBracketAccessorNode& node) {
usedExtensions.insert("BuiltinVariables");
result.GetUsedExtensions().insert("BuiltinVariables");
node.expression->Visit(*this);
if (node.child) node.child->Visit(*this);
};
// Add extensions bound to Objects/Behaviors/Functions
void UsedExtensionsFinder::OnVisitIdentifierNode(IdentifierNode& node) {
auto type = gd::ExpressionTypeFinder::GetType(project.GetCurrentPlatform(), GetGlobalObjectsContainer(), GetObjectsContainer(), rootType, node);
void UsedExtensionsFinder::OnVisitIdentifierNode(IdentifierNode &node) {
auto type = gd::ExpressionTypeFinder::GetType(
project.GetCurrentPlatform(), GetGlobalObjectsContainer(),
GetObjectsContainer(), rootType, node);
if (gd::ParameterMetadata::IsObject(type)) {
usedExtensions.insert(gd::MetadataProvider::GetExtensionAndObjectMetadata(
project.GetCurrentPlatform(), node.identifierName)
.GetExtension()
.GetName());
auto metadata = gd::MetadataProvider::GetExtensionAndObjectMetadata(
project.GetCurrentPlatform(), node.identifierName);
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
result.GetUsedIncludeFiles().insert(includeFile);
}
}
};
@@ -138,7 +155,10 @@ void UsedExtensionsFinder::OnVisitFunctionCallNode(FunctionCallNode& node) {
return;
}
usedExtensions.insert(metadata.GetExtension().GetName());
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) {
result.GetUsedIncludeFiles().insert(includeFile);
}
};
} // namespace gd

View File

@@ -21,18 +21,62 @@ class Behavior;
namespace gd {
class GD_CORE_API UsedExtensionsResult {
public:
/**
* The extensions used by the project (or part of it).
*/
const std::set<gd::String> &GetUsedExtensions() const {
return usedExtensions;
}
/**
* The include files used at runtime by the project (or part of it).
*/
const std::set<gd::String> &GetUsedIncludeFiles() const {
return usedIncludeFiles;
}
/**
* The additional files required at runtime by the project (or part of it).
*/
const std::set<gd::String> &GetUsedRequiredFiles() const {
return usedRequiredFiles;
}
/**
* The extensions used by the project (or part of it).
*/
std::set<gd::String> &GetUsedExtensions() { return usedExtensions; }
/**
* The include files used at runtime by the project (or part of it).
*/
std::set<gd::String> &GetUsedIncludeFiles() { return usedIncludeFiles; }
/**
* The additional files required at runtime by the project (or part of it).
*/
std::set<gd::String> &GetUsedRequiredFiles() { return usedRequiredFiles; }
private:
std::set<gd::String> usedExtensions;
std::set<gd::String> usedIncludeFiles;
std::set<gd::String> usedRequiredFiles;
};
class GD_CORE_API UsedExtensionsFinder
: public ArbitraryObjectsWorker,
public ArbitraryEventsWorkerWithContext,
public ExpressionParser2NodeWorker {
public:
static std::set<gd::String> ScanProject(gd::Project& project);
static const UsedExtensionsResult ScanProject(gd::Project& project);
private:
UsedExtensionsFinder(gd::Project& project_) : project(project_){};
gd::Project& project;
gd::String rootType;
std::set<gd::String> usedExtensions;
UsedExtensionsResult result;
// Object Visitor
void DoVisitObject(gd::Object& object) override;

View File

@@ -35,6 +35,16 @@ void ArbitraryResourceWorker::ExposeJson(gd::String& jsonName){
// do.
};
void ArbitraryResourceWorker::ExposeTilemap(gd::String& tilemapName){
// Nothing to do by default - each child class can define here the action to
// do.
};
void ArbitraryResourceWorker::ExposeTileset(gd::String& tilesetName){
// Nothing to do by default - each child class can define here the action to
// do.
};
void ArbitraryResourceWorker::ExposeVideo(gd::String& videoName){
// Nothing to do by default - each child class can define here the action to
// do.
@@ -92,6 +102,67 @@ void ArbitraryResourceWorker::ExposeResources(
}
}
void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {
if (resourcesManagers.empty()) return;
gd::ResourcesManager* resourcesManager = resourcesManagers[0];
gd::Resource& resource = resourcesManager->GetResource(resourceName);
if (!resource.GetMetadata().empty()) {
gd::SerializerElement serializerElement =
gd::Serializer::FromJSON(resource.GetMetadata());
if (serializerElement.HasChild("embeddedResourcesMapping")) {
bool anyEmbeddedResourceNameWasRenamed = false;
gd::SerializerElement& embeddedResourcesMappingElement =
serializerElement.GetChild("embeddedResourcesMapping");
for (const auto& child :
embeddedResourcesMappingElement.GetAllChildren()) {
const gd::String& targetResourceName =
child.second->GetValue().GetString();
if (resourcesManager->HasResource(targetResourceName)) {
std::cout << targetResourceName << std::endl;
gd::Resource& targetResource =
resourcesManager->GetResource(targetResourceName);
const gd::String& targetResourceKind = targetResource.GetKind();
gd::String potentiallyUpdatedTargetResourceName = targetResourceName;
if (targetResourceKind == "audio") {
ExposeAudio(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "bitmapFont") {
ExposeBitmapFont(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "font") {
ExposeFont(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "image") {
ExposeImage(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "json") {
ExposeJson(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "tilemap") {
ExposeTilemap(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "tileset") {
ExposeTileset(potentiallyUpdatedTargetResourceName);
} else if (targetResourceKind == "video") {
ExposeVideo(potentiallyUpdatedTargetResourceName);
}
if (potentiallyUpdatedTargetResourceName != targetResourceName) {
// The resource name was renamed. Also update the mapping.
child.second->SetStringValue(potentiallyUpdatedTargetResourceName);
anyEmbeddedResourceNameWasRenamed = true;
}
}
}
if (anyEmbeddedResourceNameWasRenamed) {
resource.SetMetadata(gd::Serializer::ToJSON(serializerElement));
}
}
}
}
void ArbitraryResourceWorker::ExposeResource(gd::Resource& resource) {
if (!resource.UseFile()) return;
@@ -154,6 +225,14 @@ class ResourceWorkerInEventsWorker : public ArbitraryEventsWorker {
gd::String updatedParameterValue = parameterValue;
worker.ExposeJson(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
} else if (parameterMetadata.GetType() == "tilemapResource") {
gd::String updatedParameterValue = parameterValue;
worker.ExposeTilemap(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
} else if (parameterMetadata.GetType() == "tilesetResource") {
gd::String updatedParameterValue = parameterValue;
worker.ExposeTileset(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
}
});

View File

@@ -75,6 +75,16 @@ class GD_CORE_API ArbitraryResourceWorker {
*/
virtual void ExposeJson(gd::String &jsonName);
/**
* \brief Expose a Tilemap, which is always a reference to a "tilemap" resource.
*/
virtual void ExposeTilemap(gd::String &tilemapName);
/**
* \brief Expose a Tileset, which is always a reference to a "tileset" resource.
*/
virtual void ExposeTileset(gd::String &tilesetName);
/**
* \brief Expose a video, which is always a reference to a "video" resource.
*/
@@ -96,6 +106,11 @@ class GD_CORE_API ArbitraryResourceWorker {
*/
virtual void ExposeFile(gd::String &resourceFileName) = 0;
/**
* \brief Expose the embedded resources of the specified resource.
*/
virtual void ExposeEmbeddeds(gd::String &resourceName);
protected:
const std::vector<gd::ResourcesManager *> &GetResources() {
return resourcesManagers;

View File

@@ -40,6 +40,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
std::set<gd::String>& GetAllAudios() { return GetAll("audio"); };
std::set<gd::String>& GetAllFonts() { return GetAll("font"); };
std::set<gd::String>& GetAllJsons() { return GetAll("json"); };
std::set<gd::String>& GetAllTilemaps() { return GetAll("tilemap"); };
std::set<gd::String>& GetAllTilesets() { return GetAll("tileset"); };
std::set<gd::String>& GetAllVideos() { return GetAll("video"); };
std::set<gd::String>& GetAllBitmapFonts() { return GetAll("bitmapFont"); };
std::set<gd::String>& GetAll(const gd::String& resourceType) {
@@ -47,6 +49,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
if (resourceType == "audio") return allAudios;
if (resourceType == "font") return allFonts;
if (resourceType == "json") return allJsons;
if (resourceType == "tilemap") return allTilemaps;
if (resourceType == "tileset") return allTilesets;
if (resourceType == "video") return allVideos;
if (resourceType == "bitmapFont") return allBitmapFonts;
@@ -68,6 +72,12 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
virtual void ExposeJson(gd::String& jsonResourceName) override {
allJsons.insert(jsonResourceName);
};
virtual void ExposeTilemap(gd::String& tilemapResourceName) override {
allTilemaps.insert(tilemapResourceName);
};
virtual void ExposeTileset(gd::String& tilesetResourceName) override {
allTilesets.insert(tilesetResourceName);
};
virtual void ExposeVideo(gd::String& videoResourceName) override {
allVideos.insert(videoResourceName);
};
@@ -80,6 +90,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
std::set<gd::String> allAudios;
std::set<gd::String> allFonts;
std::set<gd::String> allJsons;
std::set<gd::String> allTilemaps;
std::set<gd::String> allTilesets;
std::set<gd::String> allVideos;
std::set<gd::String> allBitmapFonts;
std::set<gd::String> emptyResources;

View File

@@ -49,6 +49,12 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
virtual void ExposeJson(gd::String& jsonResourceName) override {
RenameIfNeeded(jsonResourceName);
};
virtual void ExposeTilemap(gd::String& tilemapResourceName) override {
RenameIfNeeded(tilemapResourceName);
};
virtual void ExposeTileset(gd::String& tilesetResourceName) override {
RenameIfNeeded(tilesetResourceName);
};
virtual void ExposeVideo(gd::String& videoResourceName) override {
RenameIfNeeded(videoResourceName);
};

View File

@@ -12,6 +12,7 @@
#include "GDCore/Project/EventsBasedBehavior.h"
#include "GDCore/Project/EventsBasedObject.h"
#include "GDCore/Project/EventsFunctionsExtension.h"
#include "GDCore/Project/EventsFunction.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Project/PropertyDescriptor.h"
#include "GDCore/String.h"
@@ -298,4 +299,16 @@ PropertyFunctionGenerator::UnCapitalizeFirstLetter(const gd::String &string) {
return string.substr(0, 1).LowerCase() + string.substr(1);
}
void PropertyFunctionGenerator::GenerateConditionSkeleton(
gd::Project &project, gd::EventsFunction &eventFunction) {
auto &event = dynamic_cast<gd::StandardEvent &>(
eventFunction.GetEvents().InsertNewEvent(
project, "BuiltinCommonInstructions::Standard", 0));
gd::Instruction action;
action.SetType("SetReturnBoolean");
action.AddParameter("True");
event.GetActions().Insert(action, 0);
}
} // namespace gd

View File

@@ -10,6 +10,7 @@ namespace gd {
class String;
class Project;
class EventsFunctionsExtension;
class EventsFunction;
class EventsBasedBehavior;
class EventsBasedObject;
class AbstractEventsBasedEntity;
@@ -43,6 +44,12 @@ public:
const gd::AbstractEventsBasedEntity &eventsBasedEntity,
const gd::NamedPropertyDescriptor &property);
/**
* \brief Generate an event with a "return" action.
*/
static void GenerateConditionSkeleton(gd::Project &project,
gd::EventsFunction &eventFunction);
~PropertyFunctionGenerator();
private:

View File

@@ -125,6 +125,11 @@ class GD_CORE_API AbstractEventsBasedEntity {
*/
static gd::String GetPropertyExpressionName(const gd::String& propertyName) { return "Property" + propertyName; };
/**
* \brief Get the name of the action to toggle a boolean property.
*/
static gd::String GetPropertyToggleActionName(const gd::String& propertyName) { return "ToggleProperty" + propertyName; };
/** \name Serialization
*/
///@{

View File

@@ -38,7 +38,7 @@ gd::ObjectConfiguration &CustomObjectConfiguration::GetChildObjectConfiguration(
return badObjectConfiguration;
}
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());
if (!eventsBasedObject.HasObjectNamed(objectName)) {
gd::LogError("Tried to get the configuration of a child-object:" + objectName
+ " that doesn't exist in the event-based object: " + GetType());
@@ -78,7 +78,7 @@ bool CustomObjectConfiguration::UpdateProperty(const gd::String& propertyName,
}
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());
const auto &properties = eventsBasedObject.GetPropertyDescriptors();
return gd::CustomConfigurationHelper::UpdateProperty(
properties,
objectContent,
@@ -125,8 +125,7 @@ void CustomObjectConfiguration::DoUnserializeFrom(Project& project,
}
}
void CustomObjectConfiguration::ExposeResources(
gd::ArbitraryResourceWorker& worker) {
void CustomObjectConfiguration::ExposeResources(gd::ArbitraryResourceWorker& worker) {
std::map<gd::String, gd::PropertyDescriptor> properties = GetProperties();
for (auto& property : properties) {
@@ -148,6 +147,10 @@ void CustomObjectConfiguration::ExposeResources(
worker.ExposeVideo(newPropertyValue);
} else if (resourceType == "json") {
worker.ExposeJson(newPropertyValue);
} else if (resourceType == "tilemap") {
worker.ExposeTilemap(newPropertyValue);
} else if (resourceType == "tileset") {
worker.ExposeTileset(newPropertyValue);
} else if (resourceType == "bitmapFont") {
worker.ExposeBitmapFont(newPropertyValue);
}

View File

@@ -87,9 +87,9 @@ class CustomObjectConfiguration : public gd::ObjectConfiguration {
/**
* Initialize configuration using another configuration. Used by copy-ctor
* and assign-op.
*
*
* Don't forget to update me if members were changed!
*
*
* It's needed because there is no default copy for childObjectConfigurations
* and it must be a deep copy.
*/

View File

@@ -125,6 +125,13 @@ class GD_CORE_API EventsBasedBehavior: public AbstractEventsBasedEntity {
return "SharedProperty" + propertyName;
};
/**
* \brief Get the name of the action to toggle a boolean shared property.
*/
static gd::String GetSharedPropertyToggleActionName(const gd::String &propertyName) {
return "ToggleSharedProperty" + propertyName;
};
void SerializeTo(SerializerElement& element) const override;
void UnserializeFrom(gd::Project& project,

View File

@@ -7,13 +7,14 @@
#ifndef GDCORE_INITIALINSTANCE_H
#define GDCORE_INITIALINSTANCE_H
#include <map>
#include "GDCore/Project/VariablesContainer.h"
#include "GDCore/String.h"
namespace gd {
class PropertyDescriptor;
class Project;
class Layout;
}
} // namespace gd
namespace gd {
@@ -127,7 +128,8 @@ class GD_CORE_API InitialInstance {
void SetCustomHeight(double height_) { height = height_; }
/**
* \brief Return true if the instance is locked and cannot be moved in the IDE.
* \brief Return true if the instance is locked and cannot be moved in the
* IDE.
*/
bool IsLocked() const { return locked; };
@@ -240,7 +242,7 @@ class GD_CORE_API InitialInstance {
* \brief Set the value of a string property stored in the instance.
*/
void SetRawStringProperty(const gd::String& name, const gd::String& value);
///@}
///@}
/** \name Saving and loading
* Members functions related to serialization.
@@ -272,18 +274,19 @@ class GD_CORE_API InitialInstance {
stringProperties; ///< More data which can be used by the object
gd::String objectName; ///< Object name
double x; ///< Object initial X position
double y; ///< Object initial Y position
double angle; ///< Object initial angle
double x; ///< Object initial X position
double y; ///< Object initial Y position
double angle; ///< Object initial angle
int zOrder; ///< Object initial Z order
gd::String layer; ///< Object initial layer
bool personalizedSize; ///< True if object has a custom size
double width; ///< Object custom width
double height; ///< Object custom height
double width; ///< Object custom width
double height; ///< Object custom height
gd::VariablesContainer initialVariables; ///< Instance specific variables
bool locked; ///< True if the instance is locked
bool sealed; ///< True if the instance is sealed
mutable gd::String persistentUuid; ///< A persistent random version 4 UUID, useful for hot reloading.
mutable gd::String persistentUuid; ///< A persistent random version 4 UUID,
///< useful for hot reloading.
static gd::String*
badStringProperyValue; ///< Empty string returned by GetRawStringProperty

View File

@@ -12,6 +12,7 @@
#include "GDCore/Project/Behavior.h"
#include "GDCore/Project/EffectsContainer.h"
#include "GDCore/Project/ResourcesManager.h"
#include "GDCore/Project/VariablesContainer.h"
#include "GDCore/String.h"
#include "GDCore/Tools/MakeUnique.h"

View File

@@ -22,8 +22,8 @@
#include "GDCore/IDE/Events/UsedExtensionsFinder.h"
#include "GDCore/IDE/PlatformManager.h"
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/Project/EventsFunctionsExtension.h"
#include "GDCore/Project/CustomObjectConfiguration.h"
#include "GDCore/Project/EventsFunctionsExtension.h"
#include "GDCore/Project/ExternalEvents.h"
#include "GDCore/Project/ExternalLayout.h"
#include "GDCore/Project/Layout.h"
@@ -347,6 +347,49 @@ void Project::RemoveExternalEvents(const gd::String& name) {
externalEvents.erase(events);
}
void Project::MoveLayout(std::size_t oldIndex, std::size_t newIndex) {
if (oldIndex >= scenes.size() || newIndex >= scenes.size()) return;
std::unique_ptr<gd::Layout> scene = std::move(scenes[oldIndex]);
scenes.erase(scenes.begin() + oldIndex);
scenes.insert(scenes.begin() + newIndex, std::move(scene));
};
void Project::MoveExternalEvents(std::size_t oldIndex, std::size_t newIndex) {
if (oldIndex >= externalEvents.size() || newIndex >= externalEvents.size())
return;
std::unique_ptr<gd::ExternalEvents> externalEventsItem =
std::move(externalEvents[oldIndex]);
externalEvents.erase(externalEvents.begin() + oldIndex);
externalEvents.insert(externalEvents.begin() + newIndex,
std::move(externalEventsItem));
};
void Project::MoveExternalLayout(std::size_t oldIndex, std::size_t newIndex) {
if (oldIndex >= externalLayouts.size() || newIndex >= externalLayouts.size())
return;
std::unique_ptr<gd::ExternalLayout> externalLayout =
std::move(externalLayouts[oldIndex]);
externalLayouts.erase(externalLayouts.begin() + oldIndex);
externalLayouts.insert(externalLayouts.begin() + newIndex,
std::move(externalLayout));
};
void Project::MoveEventsFunctionsExtension(std::size_t oldIndex,
std::size_t newIndex) {
if (oldIndex >= eventsFunctionsExtensions.size() ||
newIndex >= eventsFunctionsExtensions.size())
return;
std::unique_ptr<gd::EventsFunctionsExtension> eventsFunctionsExtension =
std::move(eventsFunctionsExtensions[oldIndex]);
eventsFunctionsExtensions.erase(eventsFunctionsExtensions.begin() + oldIndex);
eventsFunctionsExtensions.insert(eventsFunctionsExtensions.begin() + newIndex,
std::move(eventsFunctionsExtension));
};
void Project::SwapExternalEvents(std::size_t first, std::size_t second) {
if (first >= externalEvents.size() || second >= externalEvents.size()) return;
@@ -939,8 +982,10 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {
// (this time for effects). Ideally, this method could be moved outside of
// gd::Project.
gd::ResourcesManager* resourcesManager = &GetResourcesManager();
// Add project resources
worker.ExposeResources(&GetResourcesManager());
worker.ExposeResources(resourcesManager);
platformSpecificAssets.ExposeResources(worker);
// Add layouts resources

View File

@@ -165,7 +165,7 @@ class GD_CORE_API Project : public ObjectsContainer {
*/
const gd::String& GetPackageName() const { return packageName; }
/**
/**
* \brief Change the slug of the template from which the project is created.
*/
void SetTemplateSlug(const gd::String& templateSlug_) {
@@ -458,7 +458,7 @@ class GD_CORE_API Project : public ObjectsContainer {
/**
* Create an object of the given type with the specified name.
*
*
* \param type The type of the object
* \param name The name of the object
*/
@@ -467,7 +467,7 @@ class GD_CORE_API Project : public ObjectsContainer {
/**
* Create an object configuration of the given type.
*
*
* \param type The type of the object
*/
std::unique_ptr<gd::ObjectConfiguration> CreateObjectConfiguration(
@@ -525,6 +525,11 @@ class GD_CORE_API Project : public ObjectsContainer {
*/
std::size_t GetLayoutPosition(const gd::String& name) const;
/**
* Change the position of the specified layout.
*/
void MoveLayout(std::size_t oldIndex, std::size_t newIndex);
/**
* \brief Swap the specified layouts.
*
@@ -628,6 +633,11 @@ class GD_CORE_API Project : public ObjectsContainer {
*/
std::size_t GetExternalEventsPosition(const gd::String& name) const;
/**
* Change the position of the specified external events.
*/
void MoveExternalEvents(std::size_t oldIndex, std::size_t newIndex);
/**
* \brief Swap the specified external events.
*
@@ -702,6 +712,11 @@ class GD_CORE_API Project : public ObjectsContainer {
*/
std::size_t GetExternalLayoutPosition(const gd::String& name) const;
/**
* Change the position of the specified external layout.
*/
void MoveExternalLayout(std::size_t oldIndex, std::size_t newIndex);
/**
* \brief Swap the specified external layouts.
*
@@ -791,6 +806,11 @@ class GD_CORE_API Project : public ObjectsContainer {
*/
std::size_t GetEventsFunctionsExtensionPosition(const gd::String& name) const;
/**
* Change the position of the specified events function extension.
*/
void MoveEventsFunctionsExtension(std::size_t oldIndex, std::size_t newIndex);
/**
* \brief Swap the specified events functions extensions.
*

View File

@@ -85,6 +85,10 @@ std::shared_ptr<Resource> ResourcesManager::CreateResource(
return std::make_shared<VideoResource>();
else if (kind == "json")
return std::make_shared<JsonResource>();
else if (kind == "tilemap")
return std::make_shared<TilemapResource>();
else if (kind == "tileset")
return std::make_shared<TilesetResource>();
else if (kind == "bitmapFont")
return std::make_shared<BitmapFontResource>();
@@ -650,6 +654,74 @@ bool JsonResource::UpdateProperty(const gd::String& name,
return true;
}
void TilemapResource::SetFile(const gd::String& newFile) {
file = NormalizePathSeparator(newFile);
}
void TilemapResource::UnserializeFrom(const SerializerElement& element) {
SetUserAdded(element.GetBoolAttribute("userAdded"));
SetFile(element.GetStringAttribute("file"));
DisablePreload(element.GetBoolAttribute("disablePreload", false));
}
void TilemapResource::SerializeTo(SerializerElement& element) const {
element.SetAttribute("userAdded", IsUserAdded());
element.SetAttribute("file", GetFile());
element.SetAttribute("disablePreload", IsPreloadDisabled());
}
std::map<gd::String, gd::PropertyDescriptor> TilemapResource::GetProperties()
const {
std::map<gd::String, gd::PropertyDescriptor> properties;
properties["disablePreload"]
.SetValue(disablePreload ? "true" : "false")
.SetType("Boolean")
.SetLabel(_("Disable preloading at game startup"));
return properties;
}
bool TilemapResource::UpdateProperty(const gd::String& name,
const gd::String& value) {
if (name == "disablePreload") disablePreload = value == "1";
return true;
}
void TilesetResource::SetFile(const gd::String& newFile) {
file = NormalizePathSeparator(newFile);
}
void TilesetResource::UnserializeFrom(const SerializerElement& element) {
SetUserAdded(element.GetBoolAttribute("userAdded"));
SetFile(element.GetStringAttribute("file"));
DisablePreload(element.GetBoolAttribute("disablePreload", false));
}
void TilesetResource::SerializeTo(SerializerElement& element) const {
element.SetAttribute("userAdded", IsUserAdded());
element.SetAttribute("file", GetFile());
element.SetAttribute("disablePreload", IsPreloadDisabled());
}
std::map<gd::String, gd::PropertyDescriptor> TilesetResource::GetProperties()
const {
std::map<gd::String, gd::PropertyDescriptor> properties;
properties["disablePreload"]
.SetValue(disablePreload ? "true" : "false")
.SetType("Boolean")
.SetLabel(_("Disable preloading at game startup"));
return properties;
}
bool TilesetResource::UpdateProperty(const gd::String& name,
const gd::String& value) {
if (name == "disablePreload") disablePreload = value == "1";
return true;
}
void BitmapFontResource::SetFile(const gd::String& newFile) {
file = NormalizePathSeparator(newFile);
}

View File

@@ -373,6 +373,88 @@ class GD_CORE_API JsonResource : public Resource {
gd::String file;
};
/**
* \brief Describe a tilemap file used by a project.
*
* \see Resource
* \ingroup ResourcesManagement
*/
class GD_CORE_API TilemapResource : public Resource {
public:
TilemapResource() : Resource(), disablePreload(false) { SetKind("tilemap"); };
virtual ~TilemapResource(){};
virtual TilemapResource* Clone() const override {
return new TilemapResource(*this);
}
virtual const gd::String& GetFile() const override { return file; };
virtual void SetFile(const gd::String& newFile) override;
virtual bool UseFile() const override { return true; }
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
bool UpdateProperty(const gd::String& name, const gd::String& value) override;
void SerializeTo(SerializerElement& element) const override;
void UnserializeFrom(const SerializerElement& element) override;
/**
* \brief Return true if the loading at game startup must be disabled
*/
bool IsPreloadDisabled() const { return disablePreload; }
/**
* \brief Set if the tilemap preload at game startup must be disabled
*/
void DisablePreload(bool disable = true) { disablePreload = disable; }
private:
bool disablePreload; ///< If "true", don't load the tilemap at game startup
gd::String file;
};
/**
* \brief Describe a tileset file used by a project.
*
* \see Resource
* \ingroup ResourcesManagement
*/
class GD_CORE_API TilesetResource : public Resource {
public:
TilesetResource() : Resource(), disablePreload(false) { SetKind("tileset"); };
virtual ~TilesetResource(){};
virtual TilesetResource* Clone() const override {
return new TilesetResource(*this);
}
virtual const gd::String& GetFile() const override { return file; };
virtual void SetFile(const gd::String& newFile) override;
virtual bool UseFile() const override { return true; }
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
bool UpdateProperty(const gd::String& name, const gd::String& value) override;
void SerializeTo(SerializerElement& element) const override;
void UnserializeFrom(const SerializerElement& element) override;
/**
* \brief Return true if the loading at game startup must be disabled
*/
bool IsPreloadDisabled() const { return disablePreload; }
/**
* \brief Set if the tilemap preload at game startup must be disabled
*/
void DisablePreload(bool disable = true) { disablePreload = disable; }
private:
bool disablePreload; ///< If "true", don't load the tilemap at game startup
gd::String file;
};
/**
* \brief Describe a bitmap font file used by a project.
*

View File

@@ -3,8 +3,7 @@
#ifndef GDCORE_VECTOR2_H
#define GDCORE_VECTOR2_H
namespace gd
{
namespace gd {
////////////////////////////////////////////////////////////
//
@@ -12,11 +11,12 @@ namespace gd
// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
// In no event will the authors be held liable for any damages arising from the
// use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.

View File

@@ -187,7 +187,7 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0")
.SetFunctionName("getMouseX");
.SetFunctionName("getCursorX");
extension
->AddExpression("GetGlobalVariableAsNumber",
"Get me a global variable value",

View File

@@ -217,7 +217,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
REQUIRE(node);
node->Visit(expressionCodeGenerator);
REQUIRE(expressionCodeGenerator.GetOutput() ==
"getMouseX(\"\", \"layer1\", 2 + 2)");
"getCursorX(\"\", \"layer1\", 2 + 2)");
// (first argument is the currentScene)
}
SECTION("with last optional parameter omit") {
@@ -231,7 +231,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
REQUIRE(node);
node->Visit(expressionCodeGenerator);
REQUIRE(expressionCodeGenerator.GetOutput() ==
"getMouseX(\"\", \"layer1\", 0)");
"getCursorX(\"\", \"layer1\", 0)");
// (first argument is the currentScene)
}
SECTION("with last optional parameter omit (deprecated way)") {
@@ -245,7 +245,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
REQUIRE(node);
node->Visit(expressionCodeGenerator);
REQUIRE(expressionCodeGenerator.GetOutput() ==
"getMouseX(\"\", \"layer1\", 0)");
"getCursorX(\"\", \"layer1\", 0)");
// (first argument is the currentScene)
}
SECTION("with explicit comma (deprecated way)") {
@@ -258,7 +258,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
REQUIRE(node);
node->Visit(expressionCodeGenerator);
REQUIRE(expressionCodeGenerator.GetOutput() ==
"getMouseX(\"\", \"\", 0)");
"getCursorX(\"\", \"\", 0)");
// (first argument is the currentScene)
}
}
@@ -624,7 +624,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
REQUIRE(node);
node->Visit(expressionCodeGenerator);
REQUIRE(expressionCodeGenerator.GetOutput() ==
"-(+(-(getMouseX(\"\", \"\", 0))))");
"-(+(-(getCursorX(\"\", \"\", 0))))");
// (first argument is the currentScene)
}
}

View File

@@ -19,15 +19,77 @@ TEST_CASE("ResourcesRenamer", "[common]") {
gd::ResourcesRenamer resourcesRenamer(renamings);
gd::Project project;
// Add "classic", plain resources.
gd::ImageResource resource1;
resource1.SetName("Resource1");
project.GetResourcesManager().AddResource(resource1);
gd::ImageResource resource2;
resource2.SetName("Resource2");
project.GetResourcesManager().AddResource(resource2);
// Add usage of some resources.
project.GetPlatformSpecificAssets().Set(
"android", "some-icon", "Resource1");
project.GetPlatformSpecificAssets().Set(
"android", "some-other-icon", "Resource2");
project.ExposeResources(resourcesRenamer);
// Check that resources were renamed were used.
REQUIRE(project.GetPlatformSpecificAssets().Get("android", "some-icon") ==
"RenamedResource1");
REQUIRE(project.GetPlatformSpecificAssets().Get(
"android", "some-other-icon") == "Resource2");
}
SECTION("It renames embedded resources") {
std::map<gd::String, gd::String> renamings = {
{"Resource1", "RenamedResource1"}};
gd::ResourcesRenamer resourcesRenamer(renamings);
gd::Project project;
// Add "classic", plain resources.
gd::ImageResource resource1;
resource1.SetName("Resource1");
project.GetResourcesManager().AddResource(resource1);
gd::ImageResource resource2;
resource2.SetName("Resource2");
project.GetResourcesManager().AddResource(resource2);
// Add a resource containing a mapping to other resources.
gd::JsonResource jsonResourceWithEmbeddeds;
jsonResourceWithEmbeddeds.SetName("Resource3");
jsonResourceWithEmbeddeds.SetMetadata(
"{ \"embeddedResourcesMapping\": {\"some-resource-name\": "
"\"Resource1\", \"some-other-resource-name\": \"Resource2\"} }");
project.GetResourcesManager().AddResource(jsonResourceWithEmbeddeds);
// Add usage of some resources.
project.GetPlatformSpecificAssets().Set(
"android", "some-icon", "Resource1");
project.GetPlatformSpecificAssets().Set(
"android", "some-other-icon", "Resource2");
project.ExposeResources(resourcesRenamer);
// TODO: This should not be necessary, but for now not all resources support embeddeds,
// so we must call it manually:
gd::String resource3Name = "Resource3";
resourcesRenamer.ExposeEmbeddeds(resource3Name);
// Check that resources were renamed were used.
REQUIRE(project.GetPlatformSpecificAssets().Get("android", "some-icon") ==
"RenamedResource1");
REQUIRE(project.GetPlatformSpecificAssets().Get(
"android", "some-other-icon") == "Resource2");
// Check that the names were also updated in the embedded resources mapping.
REQUIRE(project.GetResourcesManager().HasResource("Resource3") == true);
REQUIRE(
project.GetResourcesManager().GetResource("Resource3").GetMetadata() ==
"{\"embeddedResourcesMapping\":{\"some-resource-name\":"
"\"RenamedResource1\",\"some-other-resource-name\":\"Resource2\"}}");
}
}

View File

@@ -19,6 +19,8 @@
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
*/
const stringifyOptions = (options) => '["' + options.join('","') + '"]';
module.exports = {
createExtension: function (
_ /*: (string) => string */,
@@ -35,8 +37,9 @@ module.exports = {
)
.setExtensionHelpPath('/objects/bbtext')
.setCategory('User interface');
extension.addInstructionOrExpressionGroupMetadata(_("BBCode Text Object"))
.setIcon("JsPlatform/Extensions/bbcode32.png");
extension
.addInstructionOrExpressionGroupMetadata(_('BBCode Text Object'))
.setIcon('JsPlatform/Extensions/bbcode32.png');
var objectBBText = new gd.ObjectJsImplementation();
// $FlowExpectedError
@@ -195,7 +198,10 @@ module.exports = {
.addParameter('object', objectName, objectName, false)
.getCodeExtraInformation()
.setFunctionName(`get${property.functionName}`);
} else if (parameterType === 'string') {
} else if (
parameterType === 'string' ||
parameterType === 'stringWithSelector'
) {
gdObject
.addStrExpression(
`Get${property.functionName}`,
@@ -210,13 +216,24 @@ module.exports = {
}
// Add the action
if (parameterType === 'number' || parameterType === 'string') {
const expressionType =
parameterType === 'number' ? 'expression' : 'string';
if (
parameterType === 'number' ||
parameterType === 'string' ||
parameterType === 'stringWithSelector'
) {
const parameterOptions =
gd.ParameterOptions.makeNewOptions().setDescription(
property.paramLabel
);
if (property.options) {
parameterOptions.setTypeExtraInfo(
stringifyOptions(property.options)
);
}
gdObject
.addAction(
`Set${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.actionDescription,
property.actionSentence,
'',
@@ -224,7 +241,7 @@ module.exports = {
property.iconPath
)
.addParameter('object', objectName, objectName, false)
.useStandardOperatorParameters(parameterType)
.useStandardOperatorParameters(parameterType, parameterOptions)
.getCodeExtraInformation()
.setFunctionName(`set${property.functionName}`)
.setGetter(`get${property.functionName}`);
@@ -232,7 +249,7 @@ module.exports = {
gdObject
.addAction(
`Set${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.actionDescription,
property.actionSentence,
'',
@@ -243,9 +260,7 @@ module.exports = {
.addParameter(
parameterType,
property.paramLabel,
property.options
? '["' + property.options.join('", "') + '"]'
: '',
'', // There should not be options for the property if it's not a stringWithSelector
false
)
.getCodeExtraInformation()
@@ -254,13 +269,24 @@ module.exports = {
}
// Add condition
if (parameterType === 'string' || parameterType === 'number') {
const propExpressionType =
parameterType === 'string' ? 'string' : 'expression';
if (
parameterType === 'string' ||
parameterType === 'number' ||
parameterType === 'stringWithSelector'
) {
const parameterOptions =
gd.ParameterOptions.makeNewOptions().setDescription(
property.paramLabel
);
if (property.options) {
parameterOptions.setTypeExtraInfo(
stringifyOptions(property.options)
);
}
gdObject
.addCondition(
`Is${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.conditionDescription,
property.conditionSentence,
'',
@@ -268,14 +294,17 @@ module.exports = {
property.iconPath
)
.addParameter('object', objectName, objectName, false)
.useStandardRelationalOperatorParameters(parameterType)
.useStandardRelationalOperatorParameters(
parameterType,
parameterOptions
)
.getCodeExtraInformation()
.setFunctionName(`get${property.functionName}`);
} else if (parameterType === 'yesorno') {
gdObject
.addCondition(
`Is${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.conditionDescription,
property.conditionSentence,
'',
@@ -294,7 +323,8 @@ module.exports = {
functionName: 'BBText',
iconPath: 'res/actions/text24_black.png',
type: 'string',
paramLabel: _('BBCode text'),
instructionLabel: _('BBCode text'),
paramLabel: _('Text'),
conditionDescription: _('Compare the value of the BBCode text.'),
conditionSentence: _('the BBCode text'),
actionDescription: _('Set BBCode text'),
@@ -306,7 +336,8 @@ module.exports = {
functionName: 'Color',
iconPath: 'res/actions/color24.png',
type: 'color',
paramLabel: _('Color'),
instructionLabel: _('Color'),
paramLabel: _('Color (R;G;B)'),
conditionDescription: '', // No conditions for a "color" property
conditionSentence: '', // No conditions for a "color" property
actionDescription: _('Set base color'),
@@ -318,7 +349,8 @@ module.exports = {
functionName: 'Opacity',
iconPath: 'res/actions/opacity24.png',
type: 'number',
paramLabel: _('Opacity'),
instructionLabel: _('Opacity'),
paramLabel: _('Opacity (0-255)'),
conditionDescription: _(
'Compare the value of the base opacity of the text.'
),
@@ -332,6 +364,7 @@ module.exports = {
functionName: 'FontSize',
iconPath: 'res/actions/characterSize24.png',
type: 'number',
instructionLabel: _('Font size'),
paramLabel: _('Font size'),
conditionDescription: _('Compare the base font size of the text.'),
conditionSentence: _('the base font size'),
@@ -344,6 +377,7 @@ module.exports = {
functionName: 'FontFamily',
iconPath: 'res/actions/font24.png',
type: 'string',
instructionLabel: _('Font family'),
paramLabel: _('Font family'),
conditionDescription: _('Compare the value of font family'),
conditionSentence: _('the base font family'),
@@ -356,6 +390,7 @@ module.exports = {
functionName: 'Alignment',
iconPath: 'res/actions/textAlign24.png',
type: 'stringWithSelector',
instructionLabel: _('Alignment'),
paramLabel: _('Alignment'),
options: ['left', 'right', 'center'],
conditionDescription: _('Check the current text alignment.'),
@@ -369,6 +404,7 @@ module.exports = {
functionName: 'WordWrap',
iconPath: 'res/actions/scaleWidth24_black.png',
type: 'boolean',
instructionLabel: _('Word wrap'),
paramLabel: _('Word wrap'),
conditionDescription: _('Check if word wrap is enabled.'),
conditionSentence: _('Word wrap is enabled'),
@@ -381,6 +417,7 @@ module.exports = {
functionName: 'WrappingWidth',
iconPath: 'res/actions/scaleWidth24_black.png',
type: 'number',
instructionLabel: _('Wrapping width'),
paramLabel: _('Wrapping width'),
conditionDescription: _(
'Compare the width, in pixels, after which the text is wrapped on next line.'
@@ -510,8 +547,7 @@ module.exports = {
* This is called to update the PIXI object on the scene editor
*/
RenderedBBTextInstance.prototype.update = function () {
const properties = this._associatedObjectConfiguration
.getProperties();
const properties = this._associatedObjectConfiguration.getProperties();
const rawText = properties.get('text').getValue();
if (rawText !== this._pixiObject.text) {

View File

@@ -187,7 +187,7 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters('string', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setText')
.setGetter('getText');
@@ -202,7 +202,12 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Opacity (0-255)')
)
)
.setFunctionName('setOpacity')
.setGetter('getOpacity');
@@ -217,7 +222,7 @@ module.exports = {
'res/conditions/characterSize24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('getFontSize');
object
@@ -231,7 +236,12 @@ module.exports = {
'res/actions/scale24_black.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Scale (1 by default)')
)
)
.setFunctionName('setScale')
.setGetter('getScale');
@@ -246,7 +256,7 @@ module.exports = {
'res/conditions/font24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters('string', gd.ParameterOptions.makeNewOptions())
.setFunctionName('getFontName');
object
@@ -304,7 +314,12 @@ module.exports = {
'res/actions/textAlign24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters(
'string',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Alignment ("left", "right" or "center")')
)
)
.setFunctionName('getAlignment');
object
@@ -367,7 +382,7 @@ module.exports = {
'res/actions/scaleWidth24_black.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setWrappingWidth')
.setGetter('getWrappingWidth');

View File

@@ -45,7 +45,8 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/destroyoutsideicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "DestroyOutside")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced()
.SetFunctionName("GetExtraBorder");
@@ -59,7 +60,8 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/destroyoutsideicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "DestroyOutside")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced()
.SetFunctionName("SetExtraBorder")
.SetGetter("GetExtraBorder");

View File

@@ -28,7 +28,7 @@ module.exports = {
extension
.setExtensionInformation(
'DialogueTree',
_('Dialogue Tree (experimental)'),
_('Dialogue Tree'),
'Handle dialogue trees, made using Yarn Spinner. Useful to make complex dialogues with multiple choices. The Yarn Spinner editor is embedded in GDevelop so you can edit your dialogues without leaving GDevelop.',
'Todor Imreorov',
'Open source (MIT License)'
@@ -36,7 +36,7 @@ module.exports = {
.setExtensionHelpPath('/all-features/dialogue-tree')
.setCategory('Game mechanic');
extension
.addInstructionOrExpressionGroupMetadata(_('Dialogue Tree (experimental)'))
.addInstructionOrExpressionGroupMetadata(_('Dialogue Tree'))
.setIcon('JsPlatform/Extensions/yarn32.png');
extension

View File

@@ -57,35 +57,18 @@ namespace gdjs {
}
const inputManager = instanceContainer.getGame().getInputManager();
//Try mouse
const mouseDraggableManager = DraggableManager.getMouseManager(
instanceContainer
);
if (
inputManager.isMouseButtonPressed(0) &&
!mouseDraggableManager.isDragging(this)
) {
if (mouseDraggableManager.tryAndTakeDragging(instanceContainer, this)) {
this._draggedByDraggableManager = mouseDraggableManager;
return true;
const touchIds = inputManager.getStartedTouchIdentifiers();
for (let i = 0; i < touchIds.length; ++i) {
const touchDraggableManager = DraggableManager.getTouchManager(
instanceContainer,
touchIds[i]
);
if (touchDraggableManager.isDragging(this)) {
continue;
}
} else {
//Try touches
const touchIds = inputManager.getStartedTouchIdentifiers();
for (let i = 0; i < touchIds.length; ++i) {
const touchDraggableManager = DraggableManager.getTouchManager(
instanceContainer,
touchIds[i]
);
if (touchDraggableManager.isDragging(this)) {
continue;
}
if (
touchDraggableManager.tryAndTakeDragging(instanceContainer, this)
) {
this._draggedByDraggableManager = touchDraggableManager;
return true;
}
if (touchDraggableManager.tryAndTakeDragging(instanceContainer, this)) {
this._draggedByDraggableManager = touchDraggableManager;
return true;
}
}
return false;
@@ -121,14 +104,6 @@ namespace gdjs {
}
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
const mouseDraggableManager = DraggableManager.getMouseManager(
instanceContainer
);
mouseDraggableManager.leftPressedLastFrame = instanceContainer
.getGame()
.getInputManager()
.isMouseButtonPressed(0);
this._justDropped = false;
}
@@ -144,7 +119,8 @@ namespace gdjs {
/**
* Handle the dragging
*/
abstract class DraggableManager {
class DraggableManager {
private _touchId: integer;
/**
* The object has left its original position.
* When true, the search for the best object to drag has ended.
@@ -157,24 +133,11 @@ namespace gdjs {
protected _xOffset: number = 0;
protected _yOffset: number = 0;
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {}
/**
* Get the platforms manager of an instance container.
*/
static getMouseManager(
instanceContainer: gdjs.RuntimeInstanceContainer
): MouseDraggableManager {
// @ts-ignore
if (!instanceContainer.mouseDraggableManager) {
//Create the shared manager if necessary.
// @ts-ignore
instanceContainer.mouseDraggableManager = new MouseDraggableManager(
instanceContainer
);
}
// @ts-ignore
return instanceContainer.mouseDraggableManager;
constructor(
instanceContainer: gdjs.RuntimeInstanceContainer,
touchId: integer
) {
this._touchId = touchId;
}
/**
@@ -196,7 +159,7 @@ namespace gdjs {
// @ts-ignore
instanceContainer.touchDraggableManagers[
touchId
] = new TouchDraggableManager(instanceContainer, touchId);
] = new DraggableManager(instanceContainer, touchId);
}
// @ts-ignore
return instanceContainer.touchDraggableManagers[touchId];
@@ -263,75 +226,6 @@ namespace gdjs {
this._draggableBehavior = null;
}
abstract isDragging(
draggableRuntimeBehavior: DraggableRuntimeBehavior
): boolean;
abstract shouldEndDrag(
instanceContainer: gdjs.RuntimeInstanceContainer,
draggableRuntimeBehavior: DraggableRuntimeBehavior
): boolean;
abstract getPosition(
instanceContainer: gdjs.RuntimeInstanceContainer,
draggableRuntimeBehavior: DraggableRuntimeBehavior
): FloatPoint;
}
/**
* Handle the dragging by mouse
*/
class MouseDraggableManager extends DraggableManager {
/** Used to only start dragging when clicking. */
leftPressedLastFrame = false;
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {
super(instanceContainer);
}
isDragging(draggableRuntimeBehavior: DraggableRuntimeBehavior): boolean {
return this.leftPressedLastFrame || this._draggingSomething;
}
getPosition(
instanceContainer: gdjs.RuntimeInstanceContainer,
draggableRuntimeBehavior: DraggableRuntimeBehavior
): FloatPoint {
const workingPoint: FloatPoint = gdjs.staticArray(
MouseDraggableManager.prototype.getPosition
) as FloatPoint;
const inputManager = instanceContainer.getGame().getInputManager();
return instanceContainer
.getLayer(draggableRuntimeBehavior.owner.getLayer())
.convertCoords(
inputManager.getMouseX(),
inputManager.getMouseY(),
0,
workingPoint
);
}
shouldEndDrag(
instanceContainer: gdjs.RuntimeInstanceContainer,
draggableRuntimeBehavior: DraggableRuntimeBehavior
): boolean {
const inputManager = instanceContainer.getGame().getInputManager();
return !inputManager.isMouseButtonPressed(0);
}
}
/**
* Handle the dragging by touch
*/
class TouchDraggableManager extends DraggableManager {
private _touchId: integer;
constructor(
instanceContainer: gdjs.RuntimeInstanceContainer,
touchId: integer
) {
super(instanceContainer);
this._touchId = touchId;
}
isDragging(draggableRuntimeBehavior: DraggableRuntimeBehavior): boolean {
return this._draggingSomething;
}
@@ -341,7 +235,7 @@ namespace gdjs {
draggableRuntimeBehavior: DraggableRuntimeBehavior
): FloatPoint {
const workingPoint: FloatPoint = gdjs.staticArray(
TouchDraggableManager.prototype.getPosition
DraggableManager.prototype.getPosition
) as FloatPoint;
const inputManager = instanceContainer.getGame().getInputManager();
return instanceContainer
@@ -359,9 +253,7 @@ namespace gdjs {
draggableRuntimeBehavior: DraggableRuntimeBehavior
): boolean {
const inputManager = instanceContainer.getGame().getInputManager();
return (
inputManager.getAllTouchIdentifiers().indexOf(this._touchId) === -1
);
return inputManager.hasTouchEnded(this._touchId);
}
}

View File

@@ -66,17 +66,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Drag'n'drop
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(450, 500);
runtimeGame
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
@@ -84,6 +88,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Mouse move without dragging
runtimeGame.getInputManager().onMouseMove(600, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
@@ -94,12 +99,15 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(850, 700);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(850);
expect(object.getY()).to.be(700);
@@ -111,17 +119,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Dragged point is in the bounding box but not in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(450, 500);
runtimeGame
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
@@ -135,34 +147,42 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Dragged point is in the bounding box but not in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(450, 500);
runtimeGame
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object2.getX()).to.be(450);
expect(object2.getY()).to.be(500);
// Dragged point is in the bounding box and in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(455, 505);
runtimeGame
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(855, 705);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object2.getX()).to.be(850);
expect(object2.getY()).to.be(700);
@@ -185,17 +205,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Drag'n'drop
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(450, 500);
runtimeGame
.getInputManager()
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame
.getInputManager()
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
if (firstInFront) {
// The 1st object moved
@@ -220,6 +244,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Drag'n'drop
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(1, 10, 20);
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
runtimeScene.renderAndStep(1000 / 60);
@@ -237,22 +262,25 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Move another unrelated touch
runtimeGame.getInputManager().onTouchMove(1, 750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
// Start drag'n'drop with another touch
runtimeGame.getInputManager().onTouchEnd(1);
runtimeGame.getInputManager().onFrameEnded();
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(1, 750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onTouchEnd(1);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchEnd(1);
expect(object.getX()).to.be(850);
expect(object.getY()).to.be(700);
@@ -264,12 +292,12 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Dragged point is in the bounding box but not in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchMove(0, 750, 600);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchEnd(0);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
@@ -286,6 +314,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Dragged point is in the bounding box but not in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
@@ -301,6 +330,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Dragged point is in the bounding box but not in hitbox
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(0, 455, 505);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
@@ -323,6 +353,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Drag'n'drop
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(2, 450, 500);
runtimeGame.getInputManager().onTouchStart(1, 650, 600);
runtimeScene.renderAndStep(1000 / 60);
@@ -361,6 +392,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
// Drag'n'drop
runtimeGame.getInputManager().touchSimulateMouse(false);
runtimeScene.renderAndStep(1000 / 60);
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchStart(1, 10, 20);
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
runtimeScene.renderAndStep(1000 / 60);

View File

@@ -2037,7 +2037,7 @@ module.exports = {
_('Update a document in Database'),
_('Updates a variable on the database.'),
_(
'Update varable _PARAM0_ with _PARAM1_ (store result state in _PARAM2_)'
'Update variable _PARAM0_ with _PARAM1_ (store result state in _PARAM2_)'
),
_('Realtime Database'),
'JsPlatform/Extensions/firebase.png',

View File

@@ -64,7 +64,8 @@ void DeclareInventoryExtension(gd::PlatformExtension& extension) {
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Inventory name"))
.AddParameter("string", _("Item name"))
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("InventoryTools::Count");
extension

View File

@@ -28,14 +28,14 @@ module.exports = {
extension
.setExtensionInformation(
'Leaderboards',
_('Leaderboards (experimental)'),
_('Leaderboards'),
_('Allow your game to send scores to your leaderboards.'),
'Florian Rival',
'Open source (MIT License)'
)
.setExtensionHelpPath('/all-features/leaderboards')
.setCategory('Players')
.addInstructionOrExpressionGroupMetadata(_('Leaderboards (experimental)'))
.addInstructionOrExpressionGroupMetadata(_('Leaderboards'))
.setIcon('JsPlatform/Extensions/leaderboard.svg');
extension

View File

@@ -28,7 +28,7 @@ module.exports = {
extension
.setExtensionInformation(
'P2P',
_('P2P (experimental)'),
_('P2P'),
'Allow game instances to communicate remotely using messages sent via WebRTC (P2P).',
'Arthur Pacaud (arthuro555)',
'MIT'
@@ -36,7 +36,7 @@ module.exports = {
.setExtensionHelpPath('/all-features/p2p')
.setCategory('Network');
extension
.addInstructionOrExpressionGroupMetadata(_('P2P (experimental)'))
.addInstructionOrExpressionGroupMetadata(_('P2P'))
.setIcon('JsPlatform/Extensions/p2picon.svg');
extension

View File

@@ -24,7 +24,9 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"Victor Levasseur and Florian Rival",
"Open source (MIT License)")
.SetExtensionHelpPath("/objects/panel_sprite");
extension.AddInstructionOrExpressionGroupMetadata(_("Panel Sprite (9-patch) Object"))
extension
.AddInstructionOrExpressionGroupMetadata(
_("Panel Sprite (9-patch) Object"))
.SetIcon("CppPlatform/Extensions/PanelSpriteIcon.png");
gd::ObjectMetadata& obj =
@@ -48,7 +50,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity to compare to (0-255)")));
obj.AddAction(
"SetOpacity",
@@ -61,7 +66,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity (0-255)")));
obj.AddExpression("Opacity",
_("Opacity"),
@@ -91,7 +99,8 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/actions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetWidth")
.SetGetter("GetWidth");
@@ -104,7 +113,8 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetWidth");
obj.AddAction("Height",
@@ -116,7 +126,8 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/actions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetHeight")
.SetGetter("GetHeight");
@@ -129,7 +140,8 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetHeight")
.SetGetter("GetHeight");
@@ -143,7 +155,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
.SetHidden() // Deprecated
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")))
.SetFunctionName("SetAngle")
.SetGetter("GetAngle");
@@ -157,7 +172,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
.SetHidden() // Deprecated
.AddParameter("object", _("Object"), "PanelSprite")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")))
.SetFunctionName("SetAngle")
.SetGetter("GetAngle");

View File

@@ -54,7 +54,8 @@ void PanelSpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
element.SetAttribute("tiled", tiled);
}
void PanelSpriteObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
void PanelSpriteObject::ExposeResources(
gd::ArbitraryResourceWorker& worker) {
worker.ExposeImage(textureName);
}
#endif

View File

@@ -8,12 +8,13 @@ This project is released under the MIT License.
#ifndef PANELSPRITEOBJECT_H
#define PANELSPRITEOBJECT_H
#include <memory>
#include "GDCore/Project/Object.h"
namespace gd {
class ObjectConfiguration;
class InitialInstance;
class Project;
}
} // namespace gd
/**
* PanelSprite Object
@@ -23,37 +24,36 @@ class GD_EXTENSION_API PanelSpriteObject : public gd::ObjectConfiguration {
PanelSpriteObject();
virtual ~PanelSpriteObject();
virtual std::unique_ptr<gd::ObjectConfiguration> Clone() const {
return std::unique_ptr<gd::ObjectConfiguration>(new PanelSpriteObject(*this));
return std::unique_ptr<gd::ObjectConfiguration>(
new PanelSpriteObject(*this));
}
#if defined(GD_IDE_ONLY)
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker);
#endif
float GetWidth() const { return width; };
float GetHeight() const { return height; };
double GetWidth() const { return width; };
double GetHeight() const { return height; };
void SetWidth(float newWidth) {
void SetWidth(double newWidth) {
width = newWidth >= (leftMargin + rightMargin) ? newWidth
: (leftMargin + rightMargin);
};
void SetHeight(float newHeight) {
void SetHeight(double newHeight) {
height = newHeight >= (topMargin + bottomMargin)
? newHeight
: (topMargin + bottomMargin);
};
float GetLeftMargin() const { return leftMargin; };
void SetLeftMargin(float newMargin) { leftMargin = newMargin; };
double GetLeftMargin() const { return leftMargin; };
void SetLeftMargin(double newMargin) { leftMargin = newMargin; };
float GetTopMargin() const { return topMargin; };
void SetTopMargin(float newMargin) { topMargin = newMargin; };
double GetTopMargin() const { return topMargin; };
void SetTopMargin(double newMargin) { topMargin = newMargin; };
float GetRightMargin() const { return rightMargin; };
void SetRightMargin(float newMargin) { rightMargin = newMargin; };
double GetRightMargin() const { return rightMargin; };
void SetRightMargin(double newMargin) { rightMargin = newMargin; };
float GetBottomMargin() const { return bottomMargin; };
void SetBottomMargin(float newMargin) { bottomMargin = newMargin; };
double GetBottomMargin() const { return bottomMargin; };
void SetBottomMargin(double newMargin) { bottomMargin = newMargin; };
bool IsTiled() const { return tiled; };
void SetTiled(bool enable = true) { tiled = enable; };
@@ -72,13 +72,13 @@ class GD_EXTENSION_API PanelSpriteObject : public gd::ObjectConfiguration {
virtual void DoSerializeTo(gd::SerializerElement &element) const;
#endif
float width;
float height;
double width;
double height;
float leftMargin;
float topMargin;
float rightMargin;
float bottomMargin;
double leftMargin;
double topMargin;
double rightMargin;
double bottomMargin;
bool tiled;
};

View File

@@ -5,10 +5,9 @@ Copyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
#include "Extension.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Tools/Localization.h"
#include "Extension.h"
#include "ParticleEmitterObject.h"
/**
@@ -23,7 +22,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddAction("EmitterForceMax",
_("Emission maximal force"),
@@ -33,7 +33,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddAction("EmitterAngle",
_("Emission angle"),
@@ -43,7 +44,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")));
obj.AddCondition("EmitterAngle",
_("Emission angle"),
@@ -53,7 +57,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")));
obj.AddAction("EmitterAngleA",
_("Emission angle 1"),
@@ -63,8 +70,9 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number")
.SetHidden(); // Angle A is not used.
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetHidden(); // Angle A is not used.
obj.AddCondition("EmitterAngleA",
_("Emission angle 1"),
@@ -74,8 +82,9 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number")
.SetHidden(); // Angle A is not used.
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetHidden(); // Angle A is not used.
obj.AddAction("EmitterAngleB",
_("Emission angle 2"),
@@ -85,8 +94,9 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number")
.SetHidden(); // Angle B is the same as cone spray angle
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetHidden(); // Angle B is the same as cone spray angle
obj.AddCondition("EmitterAngleB",
_("Emission angle 2"),
@@ -96,8 +106,9 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number")
.SetHidden(); // Angle B is the same as cone spray angle
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetHidden(); // Angle B is the same as cone spray angle
obj.AddAction(
"ConeSprayAngle",
@@ -108,7 +119,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")));
obj.AddCondition("ConeSprayAngle",
_("Angle of the spray cone"),
@@ -118,7 +132,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")));
obj.AddAction("ZoneRadius",
_("Creation radius"),
@@ -129,7 +146,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition("ZoneRadius",
_("Creation radius"),
@@ -139,19 +157,23 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction(
"ParticleLifeTimeMin",
_("Minimum lifetime"),
_("Modify particles minimum lifetime.Particles have to be recreated "
_("Modify particles minimum lifetime. Particles have to be recreated "
"in order to take changes in account."),
_("the minimum lifetime of particles"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration (in seconds)")));
obj.AddCondition(
"ParticleLifeTimeMin",
@@ -162,7 +184,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration to compare to (in seconds)")));
obj.AddAction(
"ParticleLifeTimeMax",
@@ -174,7 +199,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration (in seconds)")));
obj.AddCondition(
"ParticleLifeTimeMax",
@@ -185,7 +213,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration to compare to (in seconds)")));
obj.AddAction("ParticleGravityX",
_("Gravity value on X axis"),
@@ -195,7 +226,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition(
"ParticleGravityX",
@@ -206,7 +238,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("ParticleGravityY",
_("Gravity value on Y axis"),
@@ -216,7 +249,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition(
"ParticleGravityY",
@@ -227,7 +261,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("ParticleGravityAngle",
_("Gravity angle"),
@@ -237,7 +272,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")));
obj.AddCondition("ParticleGravityAngle",
_("Gravity angle"),
@@ -247,7 +285,10 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")));
obj.AddAction("ParticleGravityLength",
_("Gravity"),
@@ -257,7 +298,8 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition("ParticleGravityLength",
_("Gravity"),
@@ -267,11 +309,13 @@ void ExtensionSubDeclaration1(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("StartEmission",
_("Start emission"),
_("Refill tank (if not infinite) and start emission of the particles."),
_("Refill tank (if not infinite) and start emission of the "
"particles."),
_("Start emission of _PARAM0_"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",

View File

@@ -5,11 +5,10 @@ Copyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
#include "Extension.h"
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
#include "Extension.h"
#include "ParticleEmitterObject.h"
/**
@@ -36,137 +35,161 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
.AddParameter("object", _("Object"), "ParticleEmitter")
.AddParameter("color", _("End color"));
obj.AddAction(
"ParticleRed1",
_("Start color red component"),
_("Modify the start color red component."),
_("the start color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleRed1",
_("Start color red component"),
_("Modify the start color red component."),
_("the start color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleRed1",
_("Start color red component"),
_("Compare the start color red component."),
_("the start color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleRed1",
_("Start color red component"),
_("Compare the start color red component."),
_("the start color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction(
"ParticleRed2",
_("End color red component"),
_("Modify the end color red component."),
_("the end color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleRed2",
_("End color red component"),
_("Modify the end color red component."),
_("the end color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleRed2",
_("End color red component"),
_("Compare the end color red component."),
_("the end color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleRed2",
_("End color red component"),
_("Compare the end color red component."),
_("the end color red component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction(
"ParticleBlue1",
_("Start color blue component"),
_("Modify the start color blue component."),
_("the start color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleBlue1",
_("Start color blue component"),
_("Modify the start color blue component."),
_("the start color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleBlue1",
_("Start color blue component"),
_("Compare the start color blue component."),
_("the start color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleBlue1",
_("Start color blue component"),
_("Compare the start color blue component."),
_("the start color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction(
"ParticleBlue2",
_("End color blue component"),
_("Modify the end color blue component."),
_("the end color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleBlue2",
_("End color blue component"),
_("Modify the end color blue component."),
_("the end color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleBlue2",
_("End color blue component"),
_("Compare the end color blue component."),
_("the end color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleBlue2",
_("End color blue component"),
_("Compare the end color blue component."),
_("the end color blue component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction(
"ParticleGreen1",
_("Start color green component"),
_("Modify the start color green component."),
_("the start color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleGreen1",
_("Start color green component"),
_("Modify the start color green component."),
_("the start color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleGreen1",
_("Start color green component"),
_("Compare the start color green component."),
_("the start color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleGreen1",
_("Start color green component"),
_("Compare the start color green component."),
_("the start color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction(
"ParticleGreen2",
_("End color green component"),
_("Modify the end color green component."),
_("the end color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddAction("ParticleGreen2",
_("End color green component"),
_("Modify the end color green component."),
_("the end color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleGreen2",
_("End color green component"),
_("Compare the end color green component."),
_("the end color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleGreen2",
_("End color green component"),
_("Compare the end color green component."),
_("the end color green component"),
_("Advanced"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction("ParticleSize1",
_("Start size"),
@@ -176,7 +199,8 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition("ParticleSize1",
_("Start size"),
@@ -186,7 +210,8 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("ParticleSize2",
_("End size"),
@@ -196,7 +221,8 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition("ParticleSize2",
_("End size"),
@@ -206,7 +232,8 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("ParticleAlpha1",
_("Start opacity"),
@@ -216,18 +243,23 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleAlpha1",
_("Start opacity"),
_("Compare the start opacity of particles."),
_("the start opacity"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleAlpha1",
_("Start opacity"),
_("Compare the start opacity of particles."),
_("the start opacity"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddAction("ParticleAlpha2",
_("End opacity"),
@@ -237,18 +269,23 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value (0-255)")));
obj.AddCondition(
"ParticleAlpha2",
_("End opacity"),
_("Compare the end opacity of particles."),
_("the end opacity"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("ParticleAlpha2",
_("End opacity"),
_("Compare the end opacity of particles."),
_("the end opacity"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Value to compare to (0-255)")));
obj.AddCondition("NoMoreParticles",
_("No more particles"),
@@ -261,58 +298,63 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
.AddParameter("object", _("Object"), "ParticleEmitter");
obj.AddExpressionAndConditionAndAction(
"number",
"ParticleRotationMinSpeed",
_("Particle rotation min speed"),
_("the minimum rotation speed of the particles"),
_("the particles minimum rotation speed"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
"number",
"ParticleRotationMinSpeed",
_("Particle rotation min speed"),
_("the minimum rotation speed of the particles"),
_("the particles minimum rotation speed"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardParameters("number")
.UseStandardParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angular speed (in degrees per second)")))
.MarkAsAdvanced()
.SetFunctionName("setParticleRotationMinSpeed")
.SetGetter("getParticleRotationMinSpeed");
obj.AddExpressionAndConditionAndAction(
"number",
"ParticleRotationMaxSpeed",
_("Particle rotation max speed"),
_("the maximum rotation speed of the particles"),
_("the particles maximum rotation speed"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
"number",
"ParticleRotationMaxSpeed",
_("Particle rotation max speed"),
_("the maximum rotation speed of the particles"),
_("the particles maximum rotation speed"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardParameters("number")
.UseStandardParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angular speed (in degrees per second)")))
.MarkAsAdvanced()
.SetFunctionName("setParticleRotationMaxSpeed")
.SetGetter("getParticleRotationMaxSpeed");
obj.AddExpressionAndConditionAndAction(
"number",
"MaxParticlesCount",
_("Number of displayed particles"),
_("the maximum number of displayed particles"),
_("the maximum number of displayed particles"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
"number",
"MaxParticlesCount",
_("Number of displayed particles"),
_("the maximum number of displayed particles"),
_("the maximum number of displayed particles"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardParameters("number")
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("setMaxParticlesCount")
.SetGetter("getMaxParticlesCount");
obj.AddExpressionAndConditionAndAction(
"boolean",
"AdditiveRendering",
_("Activate particles additive rendering"),
_("the particles additive rendering is activated"),
_("displaying particles with additive rendering activated"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
"boolean",
"AdditiveRendering",
_("Activate particles additive rendering"),
_("the particles additive rendering is activated"),
_("displaying particles with additive rendering activated"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardParameters("boolean")
.UseStandardParameters("boolean", gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced()
.SetFunctionName("setAdditiveRendering")
.SetGetter("getAdditiveRendering");
}

View File

@@ -34,19 +34,20 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition(
"RendererParam1",
_("Rendering first parameter"),
_("Test the first parameter of rendering (Size/Length)."),
_("the 1st rendering parameter"),
_("Setup"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("RendererParam1",
_("Rendering first parameter"),
_("Test the first parameter of rendering (Size/Length)."),
_("the 1st rendering parameter"),
_("Setup"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("RendererParam2",
_("Rendering second parameter"),
@@ -58,18 +59,19 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition(
"RendererParam2",
_("Rendering second parameter"),
_("Test the second parameter of rendering (Size/Length)."),
_("the 2nd rendering parameter"),
_("Setup"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("RendererParam2",
_("Rendering second parameter"),
_("Test the second parameter of rendering (Size/Length)."),
_("the 2nd rendering parameter"),
_("Setup"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("Tank",
_("Capacity"),
@@ -79,8 +81,9 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.SetHidden() // DEPRECATED - Use SetTank instead
.UseStandardOperatorParameters("number");
.SetHidden() // DEPRECATED - Use SetTank instead
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddAction("SetTank",
_("Capacity"),
@@ -90,7 +93,9 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Capacity")));
obj.AddCondition("Tank",
_("Capacity"),
@@ -100,7 +105,10 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Capacity to compare to")));
obj.AddAction("Flow",
_("Flow"),
@@ -110,8 +118,9 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.SetHidden() // DEPRECATED - Use SetFlow instead
.UseStandardOperatorParameters("number");
.SetHidden() // DEPRECATED - Use SetFlow instead
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddAction("SetFlow",
_("Flow"),
@@ -121,7 +130,10 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Flow (in particles per second)")));
obj.AddCondition("Flow",
_("Flow"),
@@ -131,7 +143,10 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Flow to compare to (in particles per second)")));
obj.AddAction("Texture",
_("Particle image (using an expression)"),
@@ -154,16 +169,16 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
.AddParameter("object", _("Object"), "ParticleEmitter")
.AddParameter("imageResource", _("Image file (or image resource name)"));
obj.AddCondition(
"Texture",
_("Image"),
_("Test the name of the image displayed by particles."),
_("the image displayed by particles"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
obj.AddCondition("Texture",
_("Image"),
_("Test the name of the image displayed by particles."),
_("the image displayed by particles"),
_("Common"),
"CppPlatform/Extensions/particleSystemicon24.png",
"CppPlatform/Extensions/particleSystemicon16.png")
.AddParameter("object", _("Object"), "ParticleEmitter")
.UseStandardRelationalOperatorParameters("string");
.UseStandardRelationalOperatorParameters(
"string", gd::ParameterOptions::MakeNewOptions());
obj.AddStrExpression("Texture",
_("Particles image"),
@@ -177,7 +192,7 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
_("Particles number"),
_("Particles"),
"CppPlatform/Extensions/particleSystemicon16.png")
.SetHidden() // DEPRECATED - Use CurrentParticleCount instead
.SetHidden() // DEPRECATED - Use CurrentParticleCount instead
.AddParameter("object", _("Object"), "ParticleEmitter", false);
obj.AddExpression("CurrentParticleCount",

View File

@@ -5,16 +5,15 @@ Copyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
#include "GDCore/Tools/Localization.h"
#include "ParticleEmitterObject.h"
#include "GDCore/CommonTools.h"
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/Project/InitialInstance.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "ParticleEmitterObject.h"
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
@@ -178,53 +177,49 @@ void ParticleEmitterObject::ExposeResources(
SetParticleTexture(texture);
}
void ParticleEmitterBase::SetTank(float newValue) {
tank = newValue;
}
void ParticleEmitterBase::SetFlow(float newValue) {
flow = newValue;
}
void ParticleEmitterBase::SetEmitterForceMin(float newValue) {
void ParticleEmitterBase::SetTank(double newValue) { tank = newValue; }
void ParticleEmitterBase::SetFlow(double newValue) { flow = newValue; }
void ParticleEmitterBase::SetEmitterForceMin(double newValue) {
emitterForceMin = newValue;
}
void ParticleEmitterBase::SetEmitterForceMax(float newValue) {
void ParticleEmitterBase::SetEmitterForceMax(double newValue) {
emitterForceMax = newValue;
}
void ParticleEmitterBase::SetParticleGravityX(float newValue) {
void ParticleEmitterBase::SetParticleGravityX(double newValue) {
particleGravityX = newValue;
}
void ParticleEmitterBase::SetParticleGravityY(float newValue) {
void ParticleEmitterBase::SetParticleGravityY(double newValue) {
particleGravityY = newValue;
}
void ParticleEmitterBase::SetEmitterAngleA(float newValue) {
void ParticleEmitterBase::SetEmitterAngleA(double newValue) {
emitterAngleA = newValue;
}
void ParticleEmitterBase::SetEmitterAngleB(float newValue) {
void ParticleEmitterBase::SetEmitterAngleB(double newValue) {
emitterAngleB = newValue;
}
void ParticleEmitterBase::SetZoneRadius(float newValue) {
void ParticleEmitterBase::SetZoneRadius(double newValue) {
zoneRadius = newValue;
}
void ParticleEmitterBase::SetParticleGravityAngle(float newAngleInDegree) {
float length = sqrt(GetParticleGravityY() * GetParticleGravityY() +
GetParticleGravityX() * GetParticleGravityX());
void ParticleEmitterBase::SetParticleGravityAngle(double newAngleInDegree) {
double length = sqrt(GetParticleGravityY() * GetParticleGravityY() +
GetParticleGravityX() * GetParticleGravityX());
SetParticleGravityX(cos(newAngleInDegree / 180.0f * 3.14159f) * length);
SetParticleGravityY(sin(newAngleInDegree / 180.0f * 3.14159f) * length);
}
void ParticleEmitterBase::SetParticleGravityLength(float length) {
float angle = atan2(GetParticleGravityY(), GetParticleGravityX());
void ParticleEmitterBase::SetParticleGravityLength(double length) {
double angle = atan2(GetParticleGravityY(), GetParticleGravityX());
SetParticleGravityX(cos(angle) * length);
SetParticleGravityY(sin(angle) * length);
}
float ParticleEmitterBase::GetParticleGravityAngle() const {
double ParticleEmitterBase::GetParticleGravityAngle() const {
return atan2(GetParticleGravityY(), GetParticleGravityX()) * 180.0f /
3.14159f;
}
float ParticleEmitterBase::GetParticleGravityLength() const {
double ParticleEmitterBase::GetParticleGravityLength() const {
return sqrt(GetParticleGravityY() * GetParticleGravityY() +
GetParticleGravityX() * GetParticleGravityX());
}

View File

@@ -12,7 +12,7 @@ This project is released under the MIT License.
namespace gd {
class InitialInstance;
class Project;
}
} // namespace gd
/**
* \brief Base class containing the parameters of an emitter as well as the
@@ -22,95 +22,69 @@ class GD_EXTENSION_API ParticleEmitterBase {
public:
ParticleEmitterBase();
virtual ~ParticleEmitterBase();
ParticleEmitterBase(const ParticleEmitterBase& other) {
Init(other);
};
ParticleEmitterBase(const ParticleEmitterBase& other) { Init(other); };
ParticleEmitterBase& operator=(const ParticleEmitterBase& other) {
if (&other != this) Init(other);
return *this;
}
void SetParticleTexture(const gd::String & imageName) {
void SetParticleTexture(const gd::String& imageName) {
textureParticleName = imageName;
};
const gd::String & GetParticleTexture() const { return textureParticleName; };
const gd::String& GetParticleTexture() const { return textureParticleName; };
void SetRendererParam1(float newValue) { rendererParam1 = newValue; };
void SetRendererParam2(float newValue) { rendererParam2 = newValue; };
void SetTank(float newValue);
void SetFlow(float newValue);
void SetEmitterForceMin(float newValue);
void SetEmitterForceMax(float newValue);
void SetEmitterAngleA(float newValue);
void SetEmitterAngleB(float newValue);
void SetConeSprayAngle(float newValue) { SetEmitterAngleB(newValue); };
void SetZoneRadius(float newValue);
void SetParticleGravityX(float newValue);
void SetParticleGravityY(float newValue);
void SetParticleGravityAngle(float newAngleInDegree);
void SetParticleGravityLength(float newLength);
void SetRendererParam1(double newValue) { rendererParam1 = newValue; };
void SetRendererParam2(double newValue) { rendererParam2 = newValue; };
void SetTank(double newValue);
void SetFlow(double newValue);
void SetEmitterForceMin(double newValue);
void SetEmitterForceMax(double newValue);
void SetEmitterAngleA(double newValue);
void SetEmitterAngleB(double newValue);
void SetConeSprayAngle(double newValue) { SetEmitterAngleB(newValue); };
void SetZoneRadius(double newValue);
void SetParticleGravityX(double newValue);
void SetParticleGravityY(double newValue);
void SetParticleGravityAngle(double newAngleInDegree);
void SetParticleGravityLength(double newLength);
void SetParticleColor1(const gd::String& color);
void SetParticleColor2(const gd::String& color);
void SetParticleRed1(float newValue) {
particleRed1 = newValue;
};
void SetParticleRed2(float newValue) {
particleRed2 = newValue;
};
void SetParticleGreen1(float newValue) {
particleGreen1 = newValue;
};
void SetParticleGreen2(float newValue) {
particleGreen2 = newValue;
};
void SetParticleBlue1(float newValue) {
particleBlue1 = newValue;
};
void SetParticleBlue2(float newValue) {
particleBlue2 = newValue;
};
void SetParticleAlpha1(float newValue) {
particleAlpha1 = newValue;
};
void SetParticleAlpha2(float newValue) {
particleAlpha2 = newValue;
};
void SetParticleSize1(float newValue) {
particleSize1 = newValue;
};
void SetParticleSize2(float newValue) {
particleSize2 = newValue;
};
void SetParticleAngle1(float newValue) {
particleAngle1 = newValue;
};
void SetParticleAngle2(float newValue) {
particleAngle2 = newValue;
};
void SetParticleAlphaRandomness1(float newValue) {
void SetParticleRed1(double newValue) { particleRed1 = newValue; };
void SetParticleRed2(double newValue) { particleRed2 = newValue; };
void SetParticleGreen1(double newValue) { particleGreen1 = newValue; };
void SetParticleGreen2(double newValue) { particleGreen2 = newValue; };
void SetParticleBlue1(double newValue) { particleBlue1 = newValue; };
void SetParticleBlue2(double newValue) { particleBlue2 = newValue; };
void SetParticleAlpha1(double newValue) { particleAlpha1 = newValue; };
void SetParticleAlpha2(double newValue) { particleAlpha2 = newValue; };
void SetParticleSize1(double newValue) { particleSize1 = newValue; };
void SetParticleSize2(double newValue) { particleSize2 = newValue; };
void SetParticleAngle1(double newValue) { particleAngle1 = newValue; };
void SetParticleAngle2(double newValue) { particleAngle2 = newValue; };
void SetParticleAlphaRandomness1(double newValue) {
particleAlphaRandomness1 = newValue;
};
void SetParticleAlphaRandomness2(float newValue) {
void SetParticleAlphaRandomness2(double newValue) {
particleAlphaRandomness2 = newValue;
};
void SetParticleSizeRandomness1(float newValue) {
void SetParticleSizeRandomness1(double newValue) {
particleSizeRandomness1 = newValue;
};
void SetParticleSizeRandomness2(float newValue) {
void SetParticleSizeRandomness2(double newValue) {
particleSizeRandomness2 = newValue;
};
void SetParticleAngleRandomness1(float newValue) {
void SetParticleAngleRandomness1(double newValue) {
particleAngleRandomness1 = newValue;
};
void SetParticleAngleRandomness2(float newValue) {
void SetParticleAngleRandomness2(double newValue) {
particleAngleRandomness2 = newValue;
};
void SetParticleLifeTimeMin(float newValue) {
void SetParticleLifeTimeMin(double newValue) {
particleLifeTimeMin = newValue;
};
void SetParticleLifeTimeMax(float newValue) {
void SetParticleLifeTimeMax(double newValue) {
particleLifeTimeMax = newValue;
};
void SetMaxParticleNb(std::size_t newValue) { maxParticleNb = newValue; };
@@ -118,50 +92,49 @@ class GD_EXTENSION_API ParticleEmitterBase {
destroyWhenNoParticles = enable;
};
float GetRendererParam1() const { return rendererParam1; };
float GetRendererParam2() const { return rendererParam2; };
float GetTank() const { return tank; };
float GetFlow() const { return flow; };
float GetEmitterForceMin() const { return emitterForceMin; };
float GetEmitterForceMax() const { return emitterForceMax; };
float GetEmitterAngleA() const { return emitterAngleA; };
float GetEmitterAngleB() const { return emitterAngleB; };
float GetConeSprayAngle() const { return GetEmitterAngleB(); };
float GetZoneRadius() const { return zoneRadius; };
float GetParticleGravityX() const { return particleGravityX; };
float GetParticleGravityY() const { return particleGravityY; };
float GetParticleGravityAngle() const;
float GetParticleGravityLength() const;
float GetParticleLifeTimeMin() const { return particleLifeTimeMin; };
float GetParticleLifeTimeMax() const { return particleLifeTimeMax; };
double GetRendererParam1() const { return rendererParam1; };
double GetRendererParam2() const { return rendererParam2; };
double GetTank() const { return tank; };
double GetFlow() const { return flow; };
double GetEmitterForceMin() const { return emitterForceMin; };
double GetEmitterForceMax() const { return emitterForceMax; };
double GetEmitterAngleA() const { return emitterAngleA; };
double GetEmitterAngleB() const { return emitterAngleB; };
double GetConeSprayAngle() const { return GetEmitterAngleB(); };
double GetZoneRadius() const { return zoneRadius; };
double GetParticleGravityX() const { return particleGravityX; };
double GetParticleGravityY() const { return particleGravityY; };
double GetParticleGravityAngle() const;
double GetParticleGravityLength() const;
double GetParticleLifeTimeMin() const { return particleLifeTimeMin; };
double GetParticleLifeTimeMax() const { return particleLifeTimeMax; };
std::size_t GetMaxParticleNb() const { return maxParticleNb; };
bool GetDestroyWhenNoParticles() const { return destroyWhenNoParticles; };
float GetParticleRed1() const { return particleRed1; };
float GetParticleRed2() const { return particleRed2; };
float GetParticleGreen1() const { return particleGreen1; };
float GetParticleGreen2() const { return particleGreen2; };
float GetParticleBlue1() const { return particleBlue1; };
float GetParticleBlue2() const { return particleBlue2; };
float GetParticleAlpha1() const { return particleAlpha1; };
float GetParticleAlpha2() const { return particleAlpha2; };
float GetParticleSize1() const { return particleSize1; };
float GetParticleSize2() const { return particleSize2; };
float GetParticleAngle1() const { return particleAngle1; };
float GetParticleAngle2() const { return particleAngle2; };
float GetParticleAlphaRandomness1() const {
double GetParticleRed1() const { return particleRed1; };
double GetParticleRed2() const { return particleRed2; };
double GetParticleGreen1() const { return particleGreen1; };
double GetParticleGreen2() const { return particleGreen2; };
double GetParticleBlue1() const { return particleBlue1; };
double GetParticleBlue2() const { return particleBlue2; };
double GetParticleAlpha1() const { return particleAlpha1; };
double GetParticleAlpha2() const { return particleAlpha2; };
double GetParticleSize1() const { return particleSize1; };
double GetParticleSize2() const { return particleSize2; };
double GetParticleAngle1() const { return particleAngle1; };
double GetParticleAngle2() const { return particleAngle2; };
double GetParticleAlphaRandomness1() const {
return particleAlphaRandomness1;
};
float GetParticleAlphaRandomness2() const {
double GetParticleAlphaRandomness2() const {
return particleAlphaRandomness2;
};
float GetParticleSizeRandomness1() const { return particleSizeRandomness1; };
float GetParticleSizeRandomness2() const { return particleSizeRandomness2; };
float GetParticleAngleRandomness1() const {
double GetParticleSizeRandomness1() const { return particleSizeRandomness1; };
double GetParticleSizeRandomness2() const { return particleSizeRandomness2; };
double GetParticleAngleRandomness1() const {
return particleAngleRandomness1;
};
float GetParticleAngleRandomness2() const {
double GetParticleAngleRandomness2() const {
return particleAngleRandomness2;
};
@@ -184,23 +157,23 @@ class GD_EXTENSION_API ParticleEmitterBase {
gd::String textureParticleName;
RendererType rendererType;
float rendererParam1;
float rendererParam2;
double rendererParam1;
double rendererParam2;
bool additive;
float tank;
float flow;
float emitterForceMin;
float emitterForceMax;
float emitterAngleA;
float emitterAngleB;
float zoneRadius;
float particleGravityX, particleGravityY;
float particleLifeTimeMin, particleLifeTimeMax;
float particleRed1, particleRed2, particleGreen1, particleGreen2,
double tank;
double flow;
double emitterForceMin;
double emitterForceMax;
double emitterAngleA;
double emitterAngleB;
double zoneRadius;
double particleGravityX, particleGravityY;
double particleLifeTimeMin, particleLifeTimeMax;
double particleRed1, particleRed2, particleGreen1, particleGreen2,
particleBlue1, particleBlue2, particleAlpha1, particleAlpha2;
float particleSize1, particleSize2, particleAngle1, particleAngle2;
float particleAlphaRandomness1, particleAlphaRandomness2;
float particleSizeRandomness1, particleSizeRandomness2,
double particleSize1, particleSize2, particleAngle1, particleAngle2;
double particleAlphaRandomness1, particleAlphaRandomness2;
double particleSizeRandomness1, particleSizeRandomness2,
particleAngleRandomness1, particleAngleRandomness2;
std::size_t maxParticleNb;
bool destroyWhenNoParticles; ///< If set to true, the object will removed

View File

@@ -5,10 +5,10 @@ Copyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Project/BehaviorsSharedData.h"
#include "GDCore/Tools/Localization.h"
#include "PathfindingBehavior.h"
#include "PathfindingObstacleBehavior.h"
@@ -89,7 +89,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetCellWidth")
.SetGetter("GetCellWidth");
@@ -103,7 +104,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetCellWidth");
aut.AddAction("CellHeight",
@@ -116,7 +118,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetCellHeight")
.SetGetter("GetCellHeight");
@@ -130,7 +133,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetCellHeight");
aut.AddAction("Acceleration",
@@ -143,7 +147,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetAcceleration")
.SetGetter("GetAcceleration");
@@ -157,7 +162,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetAcceleration");
aut.AddAction("MaxSpeed",
@@ -170,7 +176,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed (in pixels per second)")))
.SetFunctionName("SetMaxSpeed")
.SetGetter("GetMaxSpeed");
@@ -184,7 +193,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed to compare to (in pixels per second)")))
.SetFunctionName("GetMaxSpeed");
aut.AddAction("Speed",
@@ -197,7 +209,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed (in pixels per second)")))
.SetFunctionName("SetSpeed")
.SetGetter("GetSpeed");
@@ -211,17 +226,21 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.SetFunctionName("GetSpeed");
aut.AddScopedCondition("MovementAngleIsAround",
_("Angle of movement on its path"),
_("Compare the angle of movement of an object on its path."),
_("Angle of movement of _PARAM0_ is _PARAM2_ (tolerance"
": _PARAM3_ degrees)"),
_("Movement on the path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
aut.AddScopedCondition(
"MovementAngleIsAround",
_("Angle of movement on its path"),
_("Compare the angle of movement of an object on its path."),
_("Angle of movement of _PARAM0_ is _PARAM2_ (tolerance"
": _PARAM3_ degrees)"),
_("Movement on the path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -238,7 +257,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max angular speed (in degrees per second)")))
.SetFunctionName("SetAngularMaxSpeed")
.SetGetter("GetAngularMaxSpeed");
@@ -253,7 +275,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max angular speed to compare to (in degrees per second)")))
.SetFunctionName("GetAngularMaxSpeed");
aut.AddAction(
@@ -267,7 +292,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")))
.SetFunctionName("SetAngleOffset")
.SetGetter("GetAngleOffset");
@@ -281,7 +309,10 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")))
.SetFunctionName("GetAngleOffset");
aut.AddAction(
@@ -296,7 +327,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetExtraBorder")
.SetGetter("GetExtraBorder");
@@ -311,7 +343,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetExtraBorder");
aut.AddAction(
@@ -548,7 +581,7 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/AStaricon24.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardParameters("number");
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions());
aut.AddExpressionAndConditionAndAction("number",
"GridOffsetY",
@@ -559,7 +592,7 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/AStaricon24.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.UseStandardParameters("number");
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions());
}
{
@@ -584,7 +617,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetCost")
.SetGetter("GetCost");
@@ -598,7 +632,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetCost");
aut.AddAction("SetImpassable",

View File

@@ -8,6 +8,7 @@ This project is released under the MIT License.
#ifndef PATHFINDINGOBSTACLEBEHAVIOR_H
#define PATHFINDINGOBSTACLEBEHAVIOR_H
#include <map>
#include "GDCore/Project/Behavior.h"
namespace gd {
class SerializerElement;
@@ -28,13 +29,11 @@ class GD_EXTENSION_API PathfindingObstacleBehavior : public gd::Behavior {
return new PathfindingObstacleBehavior(*this);
}
#if defined(GD_IDE_ONLY)
virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties(
const gd::SerializerElement& behaviorContent) const override;
virtual bool UpdateProperty(gd::SerializerElement& behaviorContent,
const gd::String& name,
const gd::String& value) override;
#endif
virtual void InitializeContent(
gd::SerializerElement& behaviorContent) override;

View File

@@ -179,9 +179,8 @@ namespace gdjs {
movementAngleIsAround(degreeAngle: float, tolerance: float) {
return (
gdjs.evtTools.common.angleDifference(
this._movementAngle,
degreeAngle
Math.abs(
gdjs.evtTools.common.angleDifference(this._movementAngle, degreeAngle)
) <= tolerance
);
}

View File

@@ -426,7 +426,9 @@ module.exports = {
)
.setIncludeFile('Extensions/Physics2Behavior/physics2runtimebehavior.js')
.addIncludeFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.js')
.addRequiredFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm')
.addRequiredFile(
'Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm'
);
// Global
aut
@@ -441,7 +443,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Gravity to compare to (in pixels per second per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getGravityX');
@@ -470,7 +477,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Gravity to compare to (in pixels per second per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getGravityY');
@@ -520,7 +532,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Time scale to compare to (1 by default)')
)
)
.getCodeExtraInformation()
.setFunctionName('getTimeScale');
@@ -541,7 +558,7 @@ module.exports = {
)
.addParameter('objectList', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Value'))
.addParameter('expression', _('Time scale (1 by default)'))
.getCodeExtraInformation()
.setIncludeFile('Extensions/Physics2Behavior/physics2tools.js')
.setFunctionName('gdjs.physics2.setTimeScale');
@@ -788,7 +805,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Scale (1 by default)')
)
)
.getCodeExtraInformation()
.setFunctionName('setShapeScale')
.setGetter('getShapeScale');
@@ -805,7 +827,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getDensity');
@@ -823,7 +848,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setDensity')
.setGetter('getDensity');
@@ -853,7 +881,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getFriction');
@@ -871,7 +902,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setFriction')
.setGetter('getFriction');
@@ -901,7 +935,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getRestitution');
@@ -919,7 +956,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setRestitution')
.setGetter('getRestitution');
@@ -949,7 +989,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getLinearDamping');
@@ -967,7 +1010,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setLinearDamping')
.setGetter('getLinearDamping');
@@ -997,7 +1043,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getAngularDamping');
@@ -1015,7 +1064,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setAngularDamping')
.setGetter('getAngularDamping');
@@ -1045,7 +1097,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Scale to compare to (1 by default)')
)
)
.getCodeExtraInformation()
.setFunctionName('getGravityScale');
@@ -1063,7 +1120,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Scale (1 by default)')
)
)
.getCodeExtraInformation()
.setFunctionName('setGravityScale')
.setGetter('getGravityScale');
@@ -1167,7 +1229,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Speed to compare to (in pixels per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityX');
@@ -1183,7 +1250,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Speed (in pixels per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('setLinearVelocityX')
.setGetter('getLinearVelocityX');
@@ -1213,7 +1285,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Speed to compare to (in pixels per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityY');
@@ -1229,7 +1306,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Speed (in pixels per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('setLinearVelocityY')
.setGetter('getLinearVelocityY');
@@ -1259,7 +1341,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Speed to compare to (in pixels per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityLength');
@@ -1276,6 +1363,40 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityLength');
aut
.addCondition(
'LinearVelocityAngle',
_('Linear velocity angle'),
_('Test an object linear velocity angle.'),
_('the linear velocity angle'),
_('Velocity'),
'res/physics32.png',
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Angle to compare to (in degrees)')
)
)
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityAngle');
aut
.addExpression(
'LinearVelocityAngle',
_('Linear velocity angle'),
_('Get the linear velocity angle of an object.'),
_('Velocity'),
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.getCodeExtraInformation()
.setFunctionName('getLinearVelocityAngle');
aut
.addCondition(
'AngularVelocity',
@@ -1288,7 +1409,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Angular speed to compare to (in degrees per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('getAngularVelocity');
@@ -1304,7 +1430,12 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Angular speed (in degrees per second)')
)
)
.getCodeExtraInformation()
.setFunctionName('setAngularVelocity')
.setGetter('getAngularVelocity');
@@ -1403,8 +1534,14 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('X component (in Newton * seconds or kilogram * meter per second)'))
.addParameter('expression', _('Y component (in Newton * seconds or kilogram * meter per second)'))
.addParameter(
'expression',
_('X component (in Newton * seconds or kilogram * meter per second)')
)
.addParameter(
'expression',
_('Y component (in Newton * seconds or kilogram * meter per second)')
)
.addParameter('expression', _('Applying X position'))
.addParameter('expression', _('Applying Y position'))
.getCodeExtraInformation()
@@ -1427,7 +1564,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Angle'))
.addParameter('expression', _('Length (in Newton * seconds or kilogram * meter per second)'))
.addParameter(
'expression',
_('Length (in Newton * seconds or kilogram * meter per second)')
)
.addParameter('expression', _('Applying X position'))
.addParameter('expression', _('Applying Y position'))
.getCodeExtraInformation()
@@ -1449,7 +1589,10 @@ module.exports = {
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Length (in Newton * seconds or kilogram * meter per second)'))
.addParameter(
'expression',
_('Length (in Newton * seconds or kilogram * meter per second)')
)
.addParameter('expression', _('X position'))
.addParameter('expression', _('Y position'))
.addParameter('expression', _('Applying X position'))
@@ -1493,7 +1636,7 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('applyAngularImpulse');
aut
aut
.addExpression(
'Mass',
_('Mass'),
@@ -1506,31 +1649,33 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('getMass');
aut
.addExpression(
'Inertia',
_('Inertia'),
_('Return the rotational inertia of the object (in kilograms * meters * meters)'),
'',
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.getCodeExtraInformation()
.setFunctionName('getInertia');
aut
.addExpression(
'Inertia',
_('Inertia'),
_(
'Return the rotational inertia of the object (in kilograms * meters * meters)'
),
'',
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.getCodeExtraInformation()
.setFunctionName('getInertia');
aut
.addExpression(
'MassCenterX',
_('Mass center X'),
_('Mass center X'),
'',
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.getCodeExtraInformation()
.setFunctionName('getMassCenterX');
aut
.addExpression(
'MassCenterX',
_('Mass center X'),
_('Mass center X'),
'',
'res/physics32.png'
)
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.getCodeExtraInformation()
.setFunctionName('getMassCenterX');
aut
.addExpression(
@@ -1647,7 +1792,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getJointReactionForce');
@@ -1678,7 +1826,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardRelationalOperatorParameters('number')
.useStandardRelationalOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('getJointReactionTorque');
@@ -1782,7 +1933,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setDistanceJointLength')
.setGetter('getDistanceJointLength');
@@ -1814,7 +1968,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setDistanceJointFrequency')
.setGetter('getDistanceJointFrequency');
@@ -1846,7 +2003,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setDistanceJointDampingRatio')
.setGetter('getDistanceJointDampingRatio');
@@ -2141,7 +2301,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setRevoluteJointMotorSpeed')
.setGetter('getRevoluteJointMotorSpeed');
@@ -2173,7 +2336,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setRevoluteJointMaxMotorTorque')
.setGetter('getRevoluteJointMaxMotorTorque');
@@ -2453,7 +2619,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setPrismaticJointMotorSpeed')
.setGetter('getPrismaticJointMotorSpeed');
@@ -2485,7 +2654,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setPrismaticJointMaxMotorForce')
.setGetter('getPrismaticJointMaxMotorForce');
@@ -2755,7 +2927,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setGearJointRatio')
.setGetter('getGearJointRatio');
@@ -2882,7 +3057,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMouseJointMaxForce')
.setGetter('getMouseJointMaxForce');
@@ -2914,7 +3092,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMouseJointFrequency')
.setGetter('getMouseJointFrequency');
@@ -2946,7 +3127,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMouseJointDampingRatio')
.setGetter('getMouseJointDampingRatio');
@@ -3115,7 +3299,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWheelJointMotorSpeed')
.setGetter('getWheelJointMotorSpeed');
@@ -3147,7 +3334,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWheelJointMaxMotorTorque')
.setGetter('getWheelJointMaxMotorTorque');
@@ -3193,7 +3383,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWheelJointFrequency')
.setGetter('getWheelJointFrequency');
@@ -3225,7 +3418,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWheelJointDampingRatio')
.setGetter('getWheelJointDampingRatio');
@@ -3321,7 +3517,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWeldJointFrequency')
.setGetter('getWeldJointFrequency');
@@ -3353,7 +3552,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setWeldJointDampingRatio')
.setGetter('getWeldJointDampingRatio');
@@ -3428,7 +3630,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setRopeJointMaxLength')
.setGetter('getRopeJointMaxLength');
@@ -3496,7 +3701,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setFrictionJointMaxForce')
.setGetter('getFrictionJointMaxForce');
@@ -3528,7 +3736,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setFrictionJointMaxTorque')
.setGetter('getFrictionJointMaxTorque');
@@ -3645,7 +3856,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMotorJointAngularOffset')
.setGetter('getMotorJointAngularOffset');
@@ -3677,7 +3891,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMotorJointMaxForce')
.setGetter('getMotorJointMaxForce');
@@ -3709,7 +3926,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMotorJointMaxTorque')
.setGetter('getMotorJointMaxTorque');
@@ -3741,7 +3961,10 @@ module.exports = {
.addParameter('object', _('Object'), '', false)
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
.addParameter('expression', _('Joint ID'))
.useStandardOperatorParameters('number')
.useStandardOperatorParameters(
'number',
gd.ParameterOptions.makeNewOptions()
)
.getCodeExtraInformation()
.setFunctionName('setMotorJointCorrectionFactor')
.setGetter('getMotorJointCorrectionFactor');
@@ -3767,7 +3990,7 @@ module.exports = {
_('Collision'),
_('Check if two objects collide.'),
_('_PARAM0_ is colliding with _PARAM2_'),
'',
'',
'res/physics32.png',
'res/physics32.png'
)

View File

@@ -1408,6 +1408,22 @@ namespace gdjs {
).Length();
}
getLinearVelocityAngle(): float {
// If there is no body, set a new one
if (this._body === null) {
if (!this.createBody()) return 0;
}
const body = this._body!;
// Get the linear velocity angle
return gdjs.toDegrees(
Math.atan2(
body.GetLinearVelocity().get_y() * this._sharedData.scaleY,
body.GetLinearVelocity().get_x() * this._sharedData.scaleX
)
);
}
getAngularVelocity(): float {
// If there is no body, set a new one
if (this._body === null) {

View File

@@ -337,7 +337,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocityX");
@@ -351,7 +352,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocityY");
@@ -364,7 +366,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocity");
@@ -390,7 +393,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularVelocity");
@@ -403,7 +407,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearDamping");
@@ -445,7 +450,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularDamping");
@@ -516,7 +522,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetPolygonScaleX");
@@ -530,7 +537,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetPolygonScaleY");

View File

@@ -5,11 +5,10 @@ Copyright (c) 2014-2016 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
#include "PlatformBehavior.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Project/BehaviorsSharedData.h"
#include "GDCore/Tools/Localization.h"
#include "PlatformBehavior.h"
#include "PlatformerObjectBehavior.h"
void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
@@ -134,61 +133,71 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddCondition("Gravity",
_("Gravity"),
_("Compare the gravity applied on the object (in pixels "
"per second per second)."),
_("Compare the gravity applied on the object."),
_("the gravity"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Gravity to compare to (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetGravity");
aut.AddAction("Gravity",
_("Gravity"),
_("Change the gravity applied on an object (in pixels per "
"second per second)."),
_("Change the gravity applied on an object."),
_("the gravity"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Gravity (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("SetGravity")
.SetGetter("GetGravity");
aut.AddCondition(
"MaxFallingSpeed",
_("Maximum falling speed"),
_("Compare the maximum falling speed of the object (in pixels per "
"second)."),
_("the maximum falling speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddCondition("MaxFallingSpeed",
_("Maximum falling speed"),
_("Compare the maximum falling speed of the object."),
_("the maximum falling speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetMaxFallingSpeed");
aut.AddAction(
"MaxFallingSpeed",
_("Maximum falling speed"),
_("Change the maximum falling speed of an object (in pixels per "
"second)."),
_("the maximum falling speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddAction("MaxFallingSpeed",
_("Maximum falling speed"),
_("Change the maximum falling speed of an object."),
_("the maximum falling speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.AddParameter("yesorno", _("If jumping, try to preserve the current speed in the air"))
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed (in pixels per second)")))
.AddParameter(
"yesorno",
_("If jumping, try to preserve the current speed in the air"))
.MarkAsAdvanced()
.SetFunctionName("SetMaxFallingSpeed")
.SetGetter("GetMaxFallingSpeed");
@@ -203,145 +212,170 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetLadderClimbingSpeed");
aut.AddAction("LadderClimbingSpeed",
_("Ladder climbing speed"),
_("Change the ladder climbing speed (in pixels per "
"second)."),
_("Change the ladder climbing speed."),
_("the ladder climbing speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("SetLadderClimbingSpeed")
.SetGetter("GetLadderClimbingSpeed");
aut.AddCondition("Acceleration",
_("Acceleration"),
_("Compare the horizontal acceleration of the object (in pixels per "
"second per second)."),
_("Compare the horizontal acceleration of the object."),
_("the horizontal acceleration"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Acceleration to compare to (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetAcceleration");
aut.AddAction("Acceleration",
_("Acceleration"),
_("Change the horizontal acceleration of an object (in pixels per "
"second per second)."),
_("Change the horizontal acceleration of an object."),
_("the horizontal acceleration"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Acceleration (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("SetAcceleration")
.SetGetter("GetAcceleration");
aut.AddCondition("Deceleration",
_("Deceleration"),
_("Compare the horizontal deceleration of the object (in pixels per "
"second per second)."),
_("Compare the horizontal deceleration of the object."),
_("the horizontal deceleration"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Deceleration to compare to (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetDeceleration");
aut.AddAction("Deceleration",
_("Deceleration"),
_("Change the horizontal deceleration of an object (in pixels per "
"second per second)."),
_("Change the horizontal deceleration of an object."),
_("the horizontal deceleration"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Deceleration (in pixels per "
"second per second)")))
.MarkAsAdvanced()
.SetFunctionName("SetDeceleration")
.SetGetter("GetDeceleration");
aut.AddCondition(
"MaxSpeed",
_("Maximum horizontal speed"),
_("Compare the maximum horizontal speed of the object (in pixels per second)."),
_("the maximum horizontal speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddCondition("MaxSpeed",
_("Maximum horizontal speed"),
_("Compare the maximum horizontal speed of the object."),
_("the maximum horizontal speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed to compare to (in pixels per second)")))
.SetFunctionName("GetMaxSpeed");
aut.AddAction(
"MaxSpeed",
_("Maximum horizontal speed"),
_("Change the maximum horizontal speed of an object (in pixels per second)."),
_("the maximum horizontal speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddAction("MaxSpeed",
_("Maximum horizontal speed"),
_("Change the maximum horizontal speed of an object."),
_("the maximum horizontal speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Max speed (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("SetMaxSpeed")
.SetGetter("GetMaxSpeed");
aut.AddCondition(
"JumpSpeed",
_("Jump speed"),
_("Compare the jump speed of the object (in pixels per second)."
"Its value is always positive."),
_("the jump speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddCondition("JumpSpeed",
_("Jump speed"),
_("Compare the jump speed of the object."
"Its value is always positive."),
_("the jump speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetJumpSpeed");
aut.AddAction(
"JumpSpeed",
_("Jump speed"),
_("Change the jump speed of an object (in pixels per second). "
"Its value is always positive."),
_("the jump speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddAction("JumpSpeed",
_("Jump speed"),
_("Change the jump speed of an object. "
"Its value is always positive."),
_("the jump speed"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed (in pixels per second)")))
.SetFunctionName("SetJumpSpeed")
.SetGetter("GetJumpSpeed");
aut.AddCondition(
"JumpSustainTime",
_("Jump sustain time"),
_("Compare the jump sustain time of the object (in seconds)."
_("Compare the jump sustain time of the object."
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("the jump sustain time"),
@@ -350,21 +384,28 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration to compare to (in seconds)")))
.MarkAsAdvanced();
aut.AddAction("JumpSustainTime",
_("Jump sustain time"),
_("Change the jump sustain time of an object (in seconds). "
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("the jump sustain time"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddAction(
"JumpSustainTime",
_("Jump sustain time"),
_("Change the jump sustain time of an object."
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("the jump sustain time"),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Duration (in seconds)")));
aut.AddAction(
"SetCanJump",
@@ -400,7 +441,8 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"AbortJump",
_("Abort jump"),
_("Abort the current jump and stop the object vertically. "
"This action doesn't have any effect when the character is not jumping."),
"This action doesn't have any effect when the character is not "
"jumping."),
_("Abort the current jump of _PARAM0_"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
@@ -589,11 +631,28 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
.MarkAsSimple()
.SetFunctionName("canGrabPlatforms");
aut.AddCondition("CurrentFallSpeed",
_("Current falling speed"),
_("Compare the current falling speed of the object. Its "
"value is always positive."),
_("the current falling speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetCurrentFallSpeed");
aut.AddScopedAction(
"SetCurrentFallSpeed",
_("Current falling speed"),
_("Change the current falling speed of the object (in pixels per "
"second). This action doesn't have any effect when the character "
_("Change the current falling speed of the object. This action "
"doesn't have any effect when the character "
"is not falling or is in the first phase of a jump."),
_("the current falling speed"),
_(""),
@@ -601,72 +660,70 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed (in pixels per second)")))
.MarkAsAdvanced();
aut.AddCondition(
"CurrentFallSpeed",
_("Current falling speed"),
_("Compare the current falling speed of the object (in pixels per "
"second). Its value is always positive."),
_("the current falling speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddCondition("CurrentJumpSpeed",
_("Current jump speed"),
_("Compare the current jump speed of the object. Its "
"value is always positive."),
_("the current jump speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.MarkAsAdvanced()
.SetFunctionName("GetCurrentFallSpeed");
aut.AddCondition(
"CurrentJumpSpeed",
_("Current jump speed"),
_("Compare the current jump speed of the object (in pixels per "
"second). Its value is always positive."),
_("the current jump speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetCurrentJumpSpeed");
aut.AddScopedAction("SetCurrentSpeed",
_("Current horizontal speed"),
_("Change the current horizontal speed of the object "
"(in pixels per second). The object moves to the left "
"with negative values and to the right with positive ones"),
_("the current horizontal speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddScopedAction(
"SetCurrentSpeed",
_("Current horizontal speed"),
_("Change the current horizontal speed of the object. The object "
"moves to the left with negative values and to the right with "
"positive ones"),
_("the current horizontal speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed (in pixels per second)")))
.MarkAsAdvanced();
aut.AddCondition("CurrentSpeed",
_("Current horizontal speed"),
_("Compare the current horizontal speed of the object "
"(in pixels per second). The object moves to the left "
"with negative values and to the right with positive ones"),
_("the current horizontal speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddCondition(
"CurrentSpeed",
_("Current horizontal speed"),
_("Compare the current horizontal speed of the object. The object "
"moves to the left "
"with negative values and to the right with positive ones"),
_("the current horizontal speed"),
_(""),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Speed to compare to (in pixels per second)")))
.MarkAsAdvanced()
.SetFunctionName("GetCurrentSpeed");
aut.AddExpression("Gravity",
_("Gravity"),
_("Return the gravity applied on the object "
"(in pixels per second per second)."),
"(in pixels per second per second)."),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -696,7 +753,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Acceleration",
_("Acceleration"),
_("Return the horizontal acceleration of the object "
"(in pixels per second per second)."),
"(in pixels per second per second)."),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -706,7 +763,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Deceleration",
_("Deceleration"),
_("Return the horizontal deceleration of the object "
"(in pixels per second per second)."),
"(in pixels per second per second)."),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -723,12 +780,13 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.SetFunctionName("GetMaxSpeed");
aut.AddExpression("JumpSpeed",
_("Jump speed"),
_("Return the jump speed of the object "
"(in pixels per second). Its value is always positive."),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png")
aut.AddExpression(
"JumpSpeed",
_("Jump speed"),
_("Return the jump speed of the object "
"(in pixels per second). Its value is always positive."),
_("Options"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.SetFunctionName("GetJumpSpeed");

View File

@@ -28,7 +28,7 @@ module.exports = {
extension
.setExtensionInformation(
'PlayerAuthentication',
_('Player Authentication (experimental)'),
_('Player Authentication'),
_('Allow your game to authenticate players.'),
'Florian Rival',
'Open source (MIT License)'
@@ -36,9 +36,7 @@ module.exports = {
.setExtensionHelpPath('/all-features/player-authentication')
.setCategory('Players');
extension
.addInstructionOrExpressionGroupMetadata(
_('Player Authentication (experimental)')
)
.addInstructionOrExpressionGroupMetadata(_('Player Authentication'))
.setIcon('JsPlatform/Extensions/authentication.svg');
extension

View File

@@ -19,10 +19,11 @@ namespace gdjs {
'If the window did not open, please check your pop-up blocker and click the button below to try again.',
}
: {
title: 'Your game is not registered!',
title: 'Publish your game!',
text1:
'In order to use player authentication, this game must be registered with GDevelop Services first.',
text2: 'Head to your Game Dashboard, then try again.',
"GDevelop's player accounts are only available for published games.",
text2:
'Click the button below to learn how to publish your game then try again.',
};
/**
@@ -119,7 +120,8 @@ namespace gdjs {
export const addAuthenticationTextsToLoadingContainer = (
loaderContainer: HTMLDivElement,
platform,
isGameRegistered
isGameRegistered,
wikiOpenAction
) => {
const textContainer: HTMLDivElement = document.createElement('div');
textContainer.id = 'authentication-container-texts';
@@ -151,8 +153,20 @@ namespace gdjs {
textContainer.appendChild(text2);
if (!isGameRegistered) {
// Remove the loader.
// Remove the loader and add the wiki link.
loaderContainer.innerHTML = '';
if (wikiOpenAction) {
const link = document.createElement('a');
addTouchAndClickEventListeners(link, wikiOpenAction);
link.innerText = 'How to publish my game';
link.style.color = '#0078d4';
link.style.textDecoration = 'none';
link.style.textDecoration = 'underline';
link.style.cursor = 'pointer';
textContainer.appendChild(link);
}
}
loaderContainer.prepend(textContainer);
@@ -170,7 +184,7 @@ namespace gdjs {
) => {
const link = document.createElement('a');
addTouchAndClickEventListeners(link, onClick);
link.innerText = 'Click here to authenticate';
link.innerText = 'Try again';
link.style.color = '#0078d4';
link.style.textDecoration = 'none';
link.style.textDecoration = 'underline';

View File

@@ -20,6 +20,7 @@ namespace gdjs {
let _authenticationLoaderContainer: HTMLDivElement | null = null;
let _authenticationTextContainer: HTMLDivElement | null = null;
let _authenticationBanner: HTMLDivElement | null = null;
let _initialAuthenticationTimeoutId: NodeJS.Timeout | null = null;
let _authenticationTimeoutId: NodeJS.Timeout | null = null;
// Communication methods.
@@ -36,6 +37,43 @@ namespace gdjs {
_justLoggedIn = false;
});
// If the extension is used, register an eventlistener to know if the user is
// logged in while playing the game on Liluo.io.
// Then send a message to the parent iframe to say that the player auth is ready.
gdjs.registerFirstRuntimeSceneLoadedCallback(
(runtimeScene: RuntimeScene) => {
if (getPlatform(runtimeScene) !== 'web') {
// Automatic authentication is only valid when the game is hosted in Liluo.io.
return;
}
removeAuthenticationCallbacks(); // Remove any callback that could have been registered before.
_authenticationMessageCallback = (event: MessageEvent) => {
receiveAuthenticationMessage(runtimeScene, event, {
checkOrigin: true,
});
};
window.addEventListener(
'message',
_authenticationMessageCallback,
true
);
logger.info(
'Notifying parent window that player authentication is ready.'
);
window.parent.postMessage(
{
id: 'playerAuthReady',
},
'*' // We could restrict to liluo.io but it's not necessary as the message is not sensitive, and it allows easy debugging.
);
// If no answer after 3 seconds, assume that the game is not embedded in Liluo.io, and remove the listener.
_initialAuthenticationTimeoutId = setTimeout(() => {
logger.info('Removing initial authentication listener.');
removeAuthenticationCallbacks();
}, 3000);
}
);
const getLocalStorageKey = (gameId: string) =>
`${gameId}_authenticatedUser`;
@@ -190,19 +228,26 @@ namespace gdjs {
logger.error('Missing game id in project properties.');
return;
}
const authenticatedUserStorageItem = window.localStorage.getItem(
getLocalStorageKey(gameId)
);
if (!authenticatedUserStorageItem) {
_checkedLocalStorage = true;
return;
}
const authenticatedUser = JSON.parse(authenticatedUserStorageItem);
try {
const authenticatedUserStorageItem = window.localStorage.getItem(
getLocalStorageKey(gameId)
);
if (!authenticatedUserStorageItem) {
_checkedLocalStorage = true;
return;
}
const authenticatedUser = JSON.parse(authenticatedUserStorageItem);
_username = authenticatedUser.username;
_userId = authenticatedUser.userId;
_userToken = authenticatedUser.userToken;
_checkedLocalStorage = true;
_username = authenticatedUser.username;
_userId = authenticatedUser.userId;
_userToken = authenticatedUser.userToken;
_checkedLocalStorage = true;
} catch (err) {
logger.warn(
'Unable to read authentication details from localStorage. Player authentication will not be available.',
err
);
}
};
/**
@@ -228,16 +273,15 @@ namespace gdjs {
}
};
/**
* When the websocket receives the authentication result, close all the
* authentication windows, display the notification and focus on the game.
*/
const handleLoggedInEvent = function (
runtimeScene: gdjs.RuntimeScene,
userId: string,
username: string | null,
userToken: string
) {
const saveAuthKeyToStorage = ({
username,
userId,
userToken,
}: {
username: string | null;
userId: string;
userToken: string;
}) => {
if (!username) {
logger.warn('The authenticated player does not have a username');
}
@@ -251,14 +295,34 @@ namespace gdjs {
logger.error('Missing game id in project properties.');
return;
}
window.localStorage.setItem(
getLocalStorageKey(gameId),
JSON.stringify({
username: _username,
userId: _userId,
userToken: _userToken,
})
);
try {
window.localStorage.setItem(
getLocalStorageKey(gameId),
JSON.stringify({
username: _username,
userId: _userId,
userToken: _userToken,
})
);
} catch (err) {
logger.warn(
'Unable to save the authentication details to localStorage. Player authentication will not be available.',
err
);
}
};
/**
* When the game receives the authentication result, close all the
* authentication windows, display the notification and focus on the game.
*/
const handleLoggedInEvent = function (
runtimeScene: gdjs.RuntimeScene,
userId: string,
username: string | null,
userToken: string
) {
saveAuthKeyToStorage({ userId, username, userToken });
cleanUpAuthWindowAndCallbacks(runtimeScene);
removeAuthenticationBanner(runtimeScene);
@@ -284,15 +348,15 @@ namespace gdjs {
* Reads the event sent by the authentication window and
* display the appropriate banner.
*/
const receiveMessageFromAuthenticationWindow = function (
const receiveAuthenticationMessage = function (
runtimeScene: gdjs.RuntimeScene,
event: MessageEvent,
{ checkOrigin }: { checkOrigin: boolean }
) {
const allowedOrigin = 'https://liluo.io';
const allowedOrigins = ['https://liluo.io', 'https://gd.games'];
// Check origin of message.
if (checkOrigin && event.origin !== allowedOrigin) {
if (checkOrigin && !allowedOrigins.includes(event.origin)) {
throw new Error(`Unexpected origin: ${event.origin}`);
}
// Check that message is not malformed.
@@ -315,6 +379,20 @@ namespace gdjs {
);
break;
}
case 'alreadyAuthenticated': {
if (!(event.data.body && event.data.body.token)) {
throw new Error('Malformed message.');
}
saveAuthKeyToStorage({
userId: event.data.body.userId,
username: event.data.body.username,
userToken: event.data.body.token,
});
removeAuthenticationCallbacks();
refreshAuthenticationBannerIfAny(runtimeScene);
break;
}
}
};
@@ -362,15 +440,42 @@ namespace gdjs {
};
/**
* Clear the authentication window timeout.
* Clear all existing authentication timeouts.
* Useful when:
* - a new authentication starts
* - the authentication succeeded
* - the authentication window is closed
*/
const clearAuthenticationWindowTimeout = () => {
if (_initialAuthenticationTimeoutId)
clearTimeout(_initialAuthenticationTimeoutId);
if (_authenticationTimeoutId) clearTimeout(_authenticationTimeoutId);
};
/**
* Helper to create the authentication banner based on the authentication status.
*/
const createAuthenticationBanner = function (
runtimeScene: gdjs.RuntimeScene
): HTMLDivElement {
const onDismissBanner = () => {
removeAuthenticationBanner(runtimeScene);
};
const onOpenAuthenticationWindow = () => {
openAuthenticationWindow(runtimeScene);
};
return _userToken
? authComponents.computeAuthenticatedBanner(
onOpenAuthenticationWindow,
onDismissBanner,
_username
)
: authComponents.computeNotAuthenticatedBanner(
onOpenAuthenticationWindow,
onDismissBanner
);
};
/**
* Action to display the banner to the user, depending on their authentication status.
*/
@@ -397,26 +502,39 @@ namespace gdjs {
);
return;
}
const onDismissBanner = () => {
removeAuthenticationBanner(runtimeScene);
};
const onOpenAuthenticationWindow = () => {
openAuthenticationWindow(runtimeScene);
};
// We display the corresponding banner depending on the authentication status.
_authenticationBanner = _userToken
? authComponents.computeAuthenticatedBanner(
onOpenAuthenticationWindow,
onDismissBanner,
_username
)
: authComponents.computeNotAuthenticatedBanner(
onOpenAuthenticationWindow,
onDismissBanner
);
_authenticationBanner = createAuthenticationBanner(runtimeScene);
domElementContainer.appendChild(_authenticationBanner);
};
/**
* Helper to recompute the authentication banner.
* This is useful if the user is already logged in on Liluo.io
* and we want to display the banner with the username.
*/
const refreshAuthenticationBannerIfAny = function (
runtimeScene: gdjs.RuntimeScene
) {
if (!_authenticationBanner) return;
const domElementContainer = runtimeScene
.getGame()
.getRenderer()
.getDomElementContainer();
if (!domElementContainer) {
handleAuthenticationError(
runtimeScene,
"The div element covering the game couldn't be found, the authentication banner cannot be displayed."
);
return;
}
const oldAuthenticationBanner = _authenticationBanner;
_authenticationBanner = createAuthenticationBanner(runtimeScene);
domElementContainer.replaceChild(
_authenticationBanner,
oldAuthenticationBanner
);
};
/**
* Helper to handle authentication window on Electron.
* We open a new window, and create a websocket to know when the user is logged in.
@@ -516,7 +634,7 @@ namespace gdjs {
// know when the user is authenticated.
if (_authenticationInAppWindow) {
_cordovaAuthenticationMessageCallback = (event: MessageEvent) => {
receiveMessageFromAuthenticationWindow(runtimeScene, event, {
receiveAuthenticationMessage(runtimeScene, event, {
checkOrigin: false, // For Cordova we don't check the origin, as the message is read from the InAppBrowser directly.
});
};
@@ -545,7 +663,7 @@ namespace gdjs {
// Listen to messages posted by the authentication window, so that we can
// know when the user is authenticated.
_authenticationMessageCallback = (event: MessageEvent) => {
receiveMessageFromAuthenticationWindow(runtimeScene, event, {
receiveAuthenticationMessage(runtimeScene, event, {
checkOrigin: true,
});
};
@@ -622,10 +740,19 @@ namespace gdjs {
checkIfGameIsRegistered(runtimeScene.getGame(), _gameId)
.then((isGameRegistered) => {
if (_authenticationLoaderContainer) {
const electron = runtimeScene.getGame().getRenderer().getElectron();
const wikiOpenAction = electron
? () =>
electron.shell.openExternal(
'https://wiki.gdevelop.io/gdevelop5/publishing/web'
)
: null; // Only show a link if we're on electron.
_authenticationTextContainer = authComponents.addAuthenticationTextsToLoadingContainer(
_authenticationLoaderContainer,
platform,
isGameRegistered
isGameRegistered,
wikiOpenAction
);
}
if (isGameRegistered) {
@@ -652,7 +779,7 @@ namespace gdjs {
runtimeScene,
'Error while checking if the game is registered.'
);
console.error(error);
logger.error(error);
});
};
@@ -669,6 +796,7 @@ namespace gdjs {
export const removeAuthenticationContainer = function (
runtimeScene: gdjs.RuntimeScene
) {
removeAuthenticationCallbacks();
const domElementContainer = runtimeScene
.getGame()
.getRenderer()
@@ -685,6 +813,15 @@ namespace gdjs {
domElementContainer.removeChild(_authenticationRootContainer);
}
_authenticationRootContainer = null;
_authenticationLoaderContainer = null;
_authenticationTextContainer = null;
};
/*
* Remove the authentication callbacks from web or cordova.
*/
const removeAuthenticationCallbacks = function () {
// Remove the authentication callbacks.
if (_authenticationMessageCallback) {
window.removeEventListener(
@@ -696,10 +833,6 @@ namespace gdjs {
// No need to detach the callback from the InAppBrowser, as it's destroyed when the window is closed.
_cordovaAuthenticationMessageCallback = null;
}
_authenticationRootContainer = null;
_authenticationLoaderContainer = null;
_authenticationTextContainer = null;
};
/**

View File

@@ -480,7 +480,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/outlineSize_black.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("SetOutlineSize")
.SetGetter("GetOutlineSize");
@@ -493,7 +494,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/conditions/outlineSize_black.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.SetFunctionName("GetOutlineSize");
obj.AddExpression("OutlineSize",
@@ -514,7 +516,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/opacity.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity (0-255)")))
.SetFunctionName("SetFillOpacity")
.SetGetter("GetFillOpacity");
@@ -527,7 +532,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/conditions/opacity.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity to compare to (0-255)")))
.SetFunctionName("GetFillOpacity");
obj.AddExpression("FillOpacity",
@@ -547,7 +555,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/opacity.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity (0-255)")))
.SetFunctionName("SetOutlineOpacity")
.SetGetter("GetOutlineOpacity");
@@ -560,7 +571,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/conditions/opacity.png")
.AddParameter("object", _("Shape Painter object"), "Drawer")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity to compare to (0-255)")))
.SetFunctionName("GetOutlineOpacity");
obj.AddExpression("OutlineOpacity",
@@ -605,7 +619,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/scale24_black.png",
"res/actions/scale_black.png")
.AddParameter("object", _("Object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddExpressionAndConditionAndAction("number",
@@ -616,7 +633,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
_("Size"),
"res/actions/scaleWidth24_black.png")
.AddParameter("object", _("Object"), "Drawer")
.UseStandardParameters("number")
.UseStandardParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddExpressionAndConditionAndAction("number",
@@ -627,7 +647,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
_("Size"),
"res/actions/scaleHeight24_black.png")
.AddParameter("object", _("Object"), "Drawer")
.UseStandardParameters("number")
.UseStandardParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.MarkAsAdvanced();
obj.AddAction("FlipX",
@@ -678,7 +701,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/scaleWidth24_black.png",
"res/actions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction("Height",
@@ -689,7 +713,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
"res/actions/scaleHeight24_black.png",
"res/actions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Drawer")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddAction(

View File

@@ -108,7 +108,7 @@ void ShapePainterObjectBase::SetFillColor(unsigned int r,
fillColorB = b;
}
void ShapePainterObjectBase::SetFillOpacity(float val) {
void ShapePainterObjectBase::SetFillOpacity(double val) {
if (val > 255)
val = 255;
else if (val < 0)
@@ -128,7 +128,7 @@ void ShapePainterObjectBase::SetOutlineColor(unsigned int r,
outlineColorB = b;
}
void ShapePainterObjectBase::SetOutlineOpacity(float val) {
void ShapePainterObjectBase::SetOutlineOpacity(double val) {
if (val > 255)
val = 255;
else if (val < 0)

View File

@@ -26,11 +26,11 @@ class GD_EXTENSION_API ShapePainterObjectBase {
ShapePainterObjectBase();
virtual ~ShapePainterObjectBase(){};
inline void SetOutlineSize(float size) { outlineSize = size; };
inline float GetOutlineSize() const { return outlineSize; };
inline void SetOutlineSize(double size) { outlineSize = size; };
inline double GetOutlineSize() const { return outlineSize; };
void SetOutlineOpacity(float val);
inline float GetOutlineOpacity() const { return outlineOpacity; };
void SetOutlineOpacity(double val);
inline double GetOutlineOpacity() const { return outlineOpacity; };
void SetOutlineColor(unsigned int r, unsigned int v, unsigned int b);
inline unsigned int GetOutlineColorR() const { return outlineColorR; };
@@ -41,8 +41,8 @@ class GD_EXTENSION_API ShapePainterObjectBase {
*/
void SetOutlineColor(const gd::String& color);
void SetFillOpacity(float val);
inline float GetFillOpacity() const { return fillOpacity; };
void SetFillOpacity(double val);
inline double GetFillOpacity() const { return fillOpacity; };
void SetFillColor(unsigned int r, unsigned int v, unsigned int b);
inline unsigned int GetFillColorR() const { return fillColorR; };

View File

@@ -9,27 +9,47 @@ This project is released under the MIT License.
#include "GDCore/Tools/Localization.h"
void DeclareSystemInfoExtension(gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"SystemInfo",
_("System information"),
_("Get information about the system and device running the game."),
"Florian Rival",
"Open source (MIT License)")
extension
.SetExtensionInformation(
"SystemInfo",
_("System information"),
_("Get information about the system and device running the game."),
"Florian Rival",
"Open source (MIT License)")
.SetCategory("Advanced");
extension.AddInstructionOrExpressionGroupMetadata(_("System information"))
.SetIcon("CppPlatform/Extensions/systeminfoicon.png");
extension
.AddCondition(
"IsMobile",
_("Is a mobile device"),
_("Check if the device running the game is a mobile device"),
_("The device is a mobile device"),
"",
"CppPlatform/Extensions/systeminfoicon.png",
"CppPlatform/Extensions/systeminfoicon.png")
extension.AddCondition(
"IsMobile",
_("Is a mobile device"),
_("Check if the device running the game is a mobile device (phone or "
"tablet on iOS, Android or other mobile devices). The game itself "
"might be a web game or distributed as a native mobile app (to check "
"this precisely, use other conditions)."),
_("The device is a mobile device"),
"",
"CppPlatform/Extensions/systeminfoicon.png",
"CppPlatform/Extensions/systeminfoicon.png");
.SetFunctionName("SystemInfo::IsMobile");
extension.AddCondition("IsNativeMobileApp",
_("Is a native mobile app"),
_("Check if the game is running as a native mobile "
"app (iOS or Android app)."),
_("The game is running as a native mobile app"),
"",
"CppPlatform/Extensions/systeminfoicon.png",
"CppPlatform/Extensions/systeminfoicon.png");
extension
.AddCondition("IsNativeDesktopApp",
_("Is a native desktop app"),
_("Check if the game is running as a native desktop app."),
_("The game is running as a native desktop app"),
"",
"CppPlatform/Extensions/systeminfoicon.png",
"CppPlatform/Extensions/systeminfoicon.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddCondition("IsWebGLSupported",

View File

@@ -28,6 +28,14 @@ class SystemInfoJsExtension : public gd::PlatformExtension {
.codeExtraInformation
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
.SetFunctionName("gdjs.evtTools.systemInfo.isMobile");
GetAllConditions()["SystemInfo::IsNativeMobileApp"]
.codeExtraInformation
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
.SetFunctionName("gdjs.evtTools.systemInfo.isNativeMobileApp");
GetAllConditions()["SystemInfo::IsNativeDesktopApp"]
.codeExtraInformation
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
.SetFunctionName("gdjs.evtTools.systemInfo.isNativeDesktopApp");
GetAllConditions()["SystemInfo::IsWebGLSupported"]
.codeExtraInformation
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")

View File

@@ -59,6 +59,32 @@ namespace gdjs {
}
return (cachedIsMobile = checkIsMobile());
};
/**
* Check if the game is running as a native mobile app - which in the case
* of an exported GDevelop game means: running packaged inside Cordova/Capacitor.js.
*
* Note: this could be improved to also detect running inside an embedded webview.
*
* @returns true if running inside Cordova (or Capacitor.js).
*/
export const isNativeMobileApp = (): boolean => {
return typeof window !== 'undefined' && (window as any).cordova;
};
/**
* Check if the game is running as a native desktop app - which in the case
* of an exported GDevelop game means: running packaged inside Electron.
*
* @param instanceContainer The current scene.
* @returns true if running inside Electron.
*/
export const isNativeDesktopApp = (
instanceContainer: gdjs.RuntimeInstanceContainer
): boolean => {
return !!instanceContainer.getGame().getRenderer().getElectron();
};
const checkHasTouchScreen = (): boolean => {
// First check if the device is mobile, as all mobile devices have a touchscreen
// and some older browsers don't have support for `navigator.maxTouchPoints`

View File

@@ -39,7 +39,9 @@ void DeclareTextEntryObjectExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/textentryicon.png")
.AddParameter("object", _("Object"), "TextEntry")
.UseStandardOperatorParameters("string")
.UseStandardOperatorParameters(
"string",
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Text")))
.SetFunctionName("SetString")
.SetGetter("GetString");
@@ -52,7 +54,9 @@ void DeclareTextEntryObjectExtension(gd::PlatformExtension& extension) {
"CppPlatform/Extensions/textentryicon.png")
.AddParameter("object", _("Object"), "TextEntry")
.UseStandardRelationalOperatorParameters("string")
.UseStandardRelationalOperatorParameters(
"string",
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Text to compare to")))
.SetFunctionName("GetString");
obj.AddAction(

View File

@@ -25,16 +25,18 @@ module.exports = {
gd /*: libGDevelop */
) {
const extension = new gd.PlatformExtension();
extension.setExtensionInformation(
'TextInput',
_('Text Input'),
_('A text field the player can type text into.'),
'Florian Rival',
'MIT'
)
.setCategory('User interface');
extension.addInstructionOrExpressionGroupMetadata(_("Text Input"))
.setIcon("JsPlatform/Extensions/text_input.svg");
extension
.setExtensionInformation(
'TextInput',
_('Text Input'),
_('A text field the player can type text into.'),
'Florian Rival',
'MIT'
)
.setCategory('User interface');
extension
.addInstructionOrExpressionGroupMetadata(_('Text Input'))
.setIcon('JsPlatform/Extensions/text_input.svg');
const textInputObject = new gd.ObjectJsImplementation();
// $FlowExpectedError - ignore Flow warning as we're creating an object
@@ -275,7 +277,7 @@ module.exports = {
const object = extension
.addObject(
'TextInputObject',
_('Text input (experimental)'),
_('Text input'),
_('A text field the player can type text into.'),
'JsPlatform/Extensions/text_input.svg',
textInputObject
@@ -299,7 +301,10 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('string')
.useStandardParameters(
'string',
gd.ParameterOptions.makeNewOptions().setDescription(_('Text'))
)
.setFunctionName('setString')
.setGetter('getString');
@@ -314,7 +319,10 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('string')
.useStandardParameters(
'string',
gd.ParameterOptions.makeNewOptions().setDescription(_('Text'))
)
.setFunctionName('setPlaceholder')
.setGetter('getPlaceholder');
@@ -329,7 +337,7 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setFontSize')
.setGetter('getFontSize');
@@ -344,7 +352,7 @@ module.exports = {
'res/conditions/font24.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('string')
.useStandardParameters('string', gd.ParameterOptions.makeNewOptions())
.setFunctionName('getFontResourceName');
// TODO: could this be merged with the previous expression and condition?
@@ -374,7 +382,10 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('string') // TODO: stringWithSelector?
.useStandardParameters(
'string',
gd.ParameterOptions.makeNewOptions().setDescription(_('Input type'))
) // TODO: stringWithSelector?
.setFunctionName('setInputType')
.setGetter('getInputType');
@@ -419,7 +430,12 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Opacity (0-255)')
)
)
.setFunctionName('setFillOpacity')
.setGetter('getFillOpacity');
@@ -449,7 +465,12 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Opacity (0-255)')
)
)
.setFunctionName('setBorderOpacity')
.setGetter('getBorderOpacity');
@@ -464,7 +485,7 @@ module.exports = {
'res/conditions/outlineSize24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setBorderWidth')
.setGetter('getBorderWidth');
@@ -481,7 +502,10 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('boolean')
.useStandardParameters(
'boolean',
gd.ParameterOptions.makeNewOptions().setDescription(_('Read-only?'))
)
.setFunctionName('setReadOnly')
.setGetter('isReadOnly');
@@ -496,7 +520,7 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('boolean')
.useStandardParameters('boolean', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setDisabled')
.setGetter('isDisabled');
@@ -512,7 +536,12 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Opacity (0-255)')
)
)
.setFunctionName('setOpacity')
.setGetter('getOpacity');
@@ -621,8 +650,7 @@ module.exports = {
update() {
const instance = this._instance;
const properties = this._associatedObjectConfiguration
.getProperties();
const properties = this._associatedObjectConfiguration.getProperties();
const placeholder =
instance.getRawStringProperty('placeholder') ||

View File

@@ -45,7 +45,9 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/text_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("string")
.UseStandardOperatorParameters(
"string",
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Text")))
.SetFunctionName("SetString")
.SetGetter("GetString");
@@ -58,7 +60,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/text_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("string")
.UseStandardRelationalOperatorParameters(
"string",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Text to compare to")))
.SetFunctionName("GetString");
obj.AddAction("Font",
@@ -82,7 +87,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale to compare to (1 by default)")))
.SetFunctionName("GetScaleX");
obj.AddAction(
@@ -95,7 +103,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/scaleWidth_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.SetFunctionName("SetScaleX");
obj.AddCondition("ScaleY",
@@ -107,7 +118,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale to compare to (1 by default)")))
.SetFunctionName("GetScaleY");
obj.AddAction(
@@ -120,7 +134,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/scaleHeight_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.SetFunctionName("SetScaleY");
obj.AddAction(
@@ -133,7 +150,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/scale_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Scale (1 by default)")))
.SetFunctionName("SetScale");
obj.AddAction(
@@ -218,7 +238,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity (0-255)")))
.SetFunctionName("SetOpacity")
.SetGetter("GetOpacity");
@@ -232,7 +255,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Opacity to compare to (0-255)")))
.SetFunctionName("GetOpacity");
obj.AddAction("SetSmooth",
@@ -336,7 +362,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/rotate_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number")
.UseStandardOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")))
.SetFunctionName("SetAngle")
.SetGetter("GetAngle");
@@ -349,7 +378,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/rotate_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number")
.UseStandardRelationalOperatorParameters(
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle to compare to (in degrees)")))
.SetFunctionName("GetAngle");
obj.AddCondition("Padding",
@@ -363,7 +395,8 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/textPadding_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddAction("SetPadding",
_("Padding"),
@@ -376,7 +409,8 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/textPadding_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddAction("SetTextAlignment",
_("Alignment"),
@@ -403,7 +437,11 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/textAlign.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("string");
.UseStandardRelationalOperatorParameters(
"stringWithSelector",
gd::ParameterOptions::MakeNewOptions()
.SetDescription(_("Alignment"))
.SetTypeExtraInfo("[\"left\", \"center\", \"right\"]"));
obj.AddAction(
"SetWrapping",
@@ -437,7 +475,8 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/actions/wordWrap_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardOperatorParameters("number");
.UseStandardOperatorParameters("number",
gd::ParameterOptions::MakeNewOptions());
obj.AddCondition("WrappingWidth",
_("Wrapping width"),
@@ -448,7 +487,8 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"res/conditions/wordWrap_black.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardRelationalOperatorParameters("number");
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions());
obj.AddExpression("Padding",
_("Padding"),
@@ -497,7 +537,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
"",
"res/conditions/characterSize24.png")
.AddParameter("object", _("Object"), "Text")
.UseStandardParameters("number");
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions());
// Support for deprecated "Size" actions/conditions:
obj.AddDuplicatedAction("Size", "Text::SetFontSize").SetHidden();

View File

@@ -71,7 +71,8 @@ void TextObject::DoSerializeTo(gd::SerializerElement& element) const {
element.SetAttribute("underlined", underlined);
}
void TextObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
void TextObject::ExposeResources(
gd::ArbitraryResourceWorker& worker) {
worker.ExposeFont(fontName);
}
#endif

View File

@@ -12,7 +12,7 @@ namespace gd {
class Project;
class Object;
class InitialInstance;
}
} // namespace gd
/**
* Text Object
@@ -25,9 +25,7 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
return gd::make_unique<TextObject>(*this);
}
#if defined(GD_IDE_ONLY)
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker);
#endif
/** \brief Change the text.
*/
@@ -39,11 +37,11 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
/** \brief Change the character size.
*/
inline void SetCharacterSize(float size) { characterSize = size; };
inline void SetCharacterSize(double size) { characterSize = size; };
/** \brief Get the character size.
*/
inline float GetCharacterSize() const { return characterSize; };
inline double GetCharacterSize() const { return characterSize; };
/** \brief Return the name of the font resource used for the text.
*/
@@ -54,7 +52,9 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
void SetFontName(const gd::String& resourceName) { fontName = resourceName; };
inline const gd::String& GetTextAlignment() const { return textAlignment; };
void SetTextAlignment(const gd::String& textAlignment_) { textAlignment = textAlignment_; };
void SetTextAlignment(const gd::String& textAlignment_) {
textAlignment = textAlignment_;
};
bool IsBold() const { return bold; };
void SetBold(bool enable) { bold = enable; };
@@ -83,7 +83,7 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
#endif
gd::String text;
float characterSize;
double characterSize;
gd::String fontName;
bool smoothed;
bool bold, italic, underlined;

File diff suppressed because it is too large Load Diff

View File

@@ -60,17 +60,20 @@ namespace gdjs {
/**
* @param tileMapJsonResourceName The resource name of the tile map.
* @param tileSetJsonResourceName The resource name of the tile set.
* @param levelIndex The level of the tile map.
* @param callback A function called when the tile map is parsed.
*/
getOrLoadTileMap(
tileMapJsonResourceName: string,
tileSetJsonResourceName: string,
levelIndex: number,
callback: (tileMap: TileMapHelper.EditableTileMap | null) => void
): void {
this._manager.getOrLoadTileMap(
this._loadTiledMap.bind(this),
this._loadTileMap.bind(this),
tileMapJsonResourceName,
tileSetJsonResourceName,
levelIndex,
pako,
callback
);
@@ -81,6 +84,7 @@ namespace gdjs {
* @param atlasImageResourceName The resource name of the atlas image.
* @param tileMapJsonResourceName The resource name of the tile map.
* @param tileSetJsonResourceName The resource name of the tile set.
* @param levelIndex The level of the tile map.
* @param callback A function called when the tiles textures are split.
*/
getOrLoadTextureCache(
@@ -88,14 +92,16 @@ namespace gdjs {
atlasImageResourceName: string,
tileMapJsonResourceName: string,
tileSetJsonResourceName: string,
levelIndex: number,
callback: (textureCache: TileMapHelper.TileTextureCache | null) => void
): void {
this._manager.getOrLoadTextureCache(
this._loadTiledMap.bind(this),
this._loadTileMap.bind(this),
getTexture,
atlasImageResourceName,
tileMapJsonResourceName,
tileSetJsonResourceName,
levelIndex,
callback
);
}
@@ -104,10 +110,10 @@ namespace gdjs {
* Parse both JSON and set the content of the tile set in the right
* attribute in the tile map to merge both parsed data.
*/
private _loadTiledMap(
private _loadTileMap(
tileMapJsonResourceName: string,
tileSetJsonResourceName: string,
callback: (tiledMap: TileMapHelper.TiledMap | null) => void
callback: (tileMap: TileMapHelper.TileMap | null) => void
): void {
this._instanceContainer
.getGame()
@@ -121,8 +127,14 @@ namespace gdjs {
callback(null);
return;
}
const tiledMap = tileMapJsonData as TileMapHelper.TiledMap;
if (tileSetJsonResourceName) {
const tileMap = TileMapHelper.TileMapManager.identify(
tileMapJsonData
);
if (!tileMap) {
callback(null);
return;
}
if (tileMap.kind === 'tiled' && tileSetJsonResourceName) {
this._instanceContainer
.getGame()
.getJsonManager()
@@ -135,13 +147,14 @@ namespace gdjs {
callback(null);
return;
}
const tiledMap = tileMap.data;
const tileSet = tileSetJsonData as TileMapHelper.TiledTileset;
tileSet.firstgid = tiledMap.tilesets[0].firstgid;
tiledMap.tilesets = [tileSet];
callback(tiledMap);
callback(tileMap);
});
} else {
callback(tiledMap);
callback(tileMap);
}
});
}

View File

@@ -580,7 +580,7 @@ namespace gdjs {
if (!definition) {
continue;
}
if (definition.hasTag(this.tag)) {
if (definition.hasTaggedHitBox(this.tag)) {
polygonItr = tile.getHitboxes()[Symbol.iterator]();
listNext = polygonItr.next();
}
@@ -661,7 +661,7 @@ namespace gdjs {
*/
getDefinition(): TileMapHelper.TileDefinition {
return this.layer.tileMap.getTileDefinition(
this.layer._source.get(this.x, this.y)!
this.layer._source.getTileId(this.x, this.y)!
)!;
}

View File

@@ -1,23 +1,25 @@
import {
EditableTileMap,
EditableTileMapLayer,
PixiTileMapHelper,
TileDefinition,
TiledMap,
TiledTileset,
TileMap,
TileMapManager,
TileTextureCache,
PixiTileMapHelper,
TiledTileset,
} from './dts/index';
declare global {
namespace TileMapHelper {
export { EditableTileMap };
export { EditableTileMapLayer };
export { TileDefinition };
export { TiledMap };
export { TiledTileset };
export { TileMapManager };
export { TileTextureCache };
export { PixiTileMapHelper };
export {
EditableTileMap,
EditableTileMapLayer,
PixiTileMapHelper,
TileDefinition,
TileMap,
TileMapManager,
TileTextureCache,
TiledTileset,
};
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,22 +2,15 @@
* @packageDocumentation
* @module TileMapHelper
*/
import { TiledMap, TiledTileset } from './tiled/TiledFormat';
import {
export {
EditableTileMap,
EditableTileMapLayer,
TileDefinition,
} from './model/TileMapModel';
import { TileMapManager } from './render/TileMapManager';
import { TileTextureCache } from './render/TileTextureCache';
import { PixiTileMapHelper } from './render/TileMapPixiHelper';
export { TileMapManager } from './render/TileMapManager';
export { TileTextureCache } from './render/TileTextureCache';
export { PixiTileMapHelper } from './render/TileMapPixiHelper';
export * from './types/index';
export * from './model/CommonTypes';
export { EditableTileMap };
export { EditableTileMapLayer };
export { TileDefinition };
export { TiledMap };
export { TiledTileset };
export { TileMapManager };
export { TileTextureCache };
export { PixiTileMapHelper };
export { TiledTileset } from './load/tiled/TiledFormat';
//# sourceMappingURL=index.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}

View File

@@ -0,0 +1,18 @@
import type { EditableTileMap } from '../model/TileMapModel';
import { TileMap } from '../types';
export declare namespace TileMapLoader {
/**
* Create a {@link EditableTileMap} from the raw data.
*
* @param tiledMap The data exported from Tiled/LDtk.
* @param levelIndex The level of the tile map to load from.
* @param pako The zlib library.
* @returns A {@link EditableTileMap}
*/
function load(
tileMap: TileMap,
levelIndex: number,
pako: any
): EditableTileMap | null;
}
//# sourceMappingURL=TileMapLoader.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TileMapLoader.d.ts","sourceRoot":"","sources":["../../src/load/TileMapLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,yBAAiB,aAAa,CAAC;IAC7B;;;;;;;OAOG;IACH,SAAgB,IAAI,CAClB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAaxB;CACF"}

View File

@@ -0,0 +1,589 @@
import { integer } from '../../model/CommonTypes';
/**
* version 1.1.3 - https://github.com/deepnight/ldtk/blob/66fff7199932357f3ab9b044c2fc2a856f527831/docs/JSON_SCHEMA.json
*/
export type LDtkTileMap = {
/** LDtk application build identifier.<br/> This is only used to identify the LDtk version that generated this particular project file, which can be useful for specific bug fixing. Note that the build identifier is just the date of the release, so it's not unique to each user (one single global ID per LDtk public release), and as a result, completely anonymous. */
appBuildId: number;
/** Number of backup files to keep, if the `backupOnSave` is TRUE */
backupLimit: integer;
/** If TRUE, an extra copy of the project will be created in a sub folder, when saving. */
backupOnSave: boolean;
/** Project background color */
bgColor: string;
/** Default grid size for new layers */
defaultGridSize: integer;
/** Default background color of levels */
defaultLevelBgColor: string;
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Default new level height */
defaultLevelHeight: integer | null;
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Default new level width */
defaultLevelWidth: integer | null;
/** Default X pivot (0 to 1) for new entities */
defaultPivotX: number;
/** Default Y pivot (0 to 1) for new entities */
defaultPivotY: number;
/** A structure containing all the definitions of this project */
defs: LDtkDefinition;
/** **WARNING**: this deprecated value is no longer exported since version 0.9.3 Replaced by: `imageExportMode` */
exportPng: boolean | null;
/** If TRUE, a Tiled compatible file will also be generated along with the LDtk JSON file (default is FALSE) */
exportTiled: boolean;
/** If TRUE, one file will be saved for the project (incl. all its definitions) and one file in a sub-folder for each level. */
externalLevels: boolean;
/** An array containing various advanced flags (ie. options or other states). Possible values: `DiscardPreCsvIntGrid`, `ExportPreCsvIntGridFormat`, `IgnoreBackupSuggest`, `PrependIndexToLevelFileNames`, `MultiWorlds`, `UseMultilinesType` */
flags: LDtkFlag[];
/** Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible values: `Capitalize`, `Uppercase`, `Lowercase`, `Free` */
identifierStyle: 'Capitalize' | 'Uppercase' | 'Lowercase' | 'Free';
/** \"Image export\" option when saving project. Possible values: `None`, `OneImagePerLayer`, `OneImagePerLevel`, `LayersAndLevels` */
imageExportMode:
| 'None'
| 'OneImagePerLayer'
| 'OneImagePerLevel'
| 'LayersAndLevels';
/** File format version */
jsonVersion: string;
/** The default naming convention for level identifiers. */
levelNamePattern: string;
/** All levels. The order of this array is only relevant in `LinearHorizontal` and `linearVertical` world layouts (see `worldLayout` value).<br/> Otherwise, you should refer to the `worldX`,`worldY` coordinates of each Level. */
levels: LDtkLevel[];
/** If TRUE, the Json is partially minified (no indentation, nor line breaks, default is FALSE) */
minifyJson: boolean;
/** Next Unique integer ID available */
nextUid: integer;
/** File naming pattern for exported PNGs */
pngFilePattern: string | null;
/** If TRUE, a very simplified will be generated on saving, for quicker & easier engine integration. */
simplifiedExport: boolean;
/** This optional description is used by LDtk Samples to show up some informations and instructions. */
tutorialDesc: string | null;
/** This array is not used yet in current LDtk version (so, for now, it's always empty).<br/><br/>In a later update, it will be possible to have multiple Worlds in a single project, each containing multiple Levels.<br/><br/>What will change when \"Multiple worlds\" support will be added to LDtk:<br/><br/> - in current version, a LDtk project file can only contain a single world with multiple levels in it. In this case, levels and world layout related settings are stored in the root of the JSON.<br/> - after the \"Multiple worlds\" update, there will be a `worlds` array in root, each world containing levels and layout settings. Basically, it's pretty much only about moving the `levels` array to the `worlds` array, along with world layout related values (eg. `worldGridWidth` etc).<br/><br/>If you want to start supporting this future update easily, please refer to this documentation: https://github.com/deepnight/ldtk/issues/231 */
worlds: LDtkWorld[];
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Height of the world grid in pixels. */
worldGridHeight: integer | null;
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Width of the world grid in pixels. */
worldGridWidth: integer | null;
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: &lt;`null`&gt;, `Free`, `GridVania`, `LinearHorizontal`, `LinearVertical` */
worldLayout:
| 'Free'
| 'GridVania'
| 'LinearHorizontal'
| 'LinearVertical'
| null;
};
/** Auto-layer rule group */
type LDtkAutoLayerRuleGroup = {
/** */
active: boolean;
/** *This field was removed in 1.0.0 and should no longer be used.* */
collapsed: boolean | null;
/** */
isOptional: boolean;
/** */
name: string;
/** */
rules: LDtkAutoRuleDef[];
/** */
uid: integer;
};
/** This complex section isn't meant to be used by game devs at all, as these rules are completely resolved internally by the editor before any saving. You should just ignore this part. */
type LDtkAutoRuleDef = {};
/** If you're writing your own LDtk importer, you should probably just ignore *most* stuff in the `defs` section, as it contains data that are mostly important to the editor. To keep you away from the `defs` section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. `__identifier` or `__type`). The 2 only definition types you might need here are **Tilesets** and **Enums**. */
type LDtkDefinition = {
/** All entities definitions, including their custom fields */
entities: LDtkEntityDef[];
/** All internal enums */
enums: LDtkEnumDef[];
/** Note: external enums are exactly the same as `enums`, except they have a `relPath` to point to an external source file. */
externalEnums: LDtkEnumDef[];
/** All layer definitions */
layers: LDtkLayerDef[];
/** All custom fields available to all levels. */
levelFields: LDtkFieldDef[];
/** All tilesets */
tilesets: LDtkTilesetDef[];
};
/** Entity definition */
type LDtkEntityDef = {
/** Base entity color */
color: string;
/** Array of field definitions */
fieldDefs: LDtkFieldDef[];
/** */
fillOpacity: number;
/** Pixel height */
height: integer;
/** */
hollow: boolean;
/** User defined unique identifier */
identifier: string;
/** Only applies to entities resizable on both X/Y. If TRUE, the entity instance width/height will keep the same aspect ratio as the definition. */
keepAspectRatio: boolean;
/** Possible values: `DiscardOldOnes`, `PreventAdding`, `MoveLastOne` */
limitBehavior: 'DiscardOldOnes' | 'MoveLastOne' | 'PreventAdding';
/** If TRUE, the maxCount is a \"per world\" limit, if FALSE, it's a \"per level\". Possible values: `PerLayer`, `PerLevel`, `PerWorld` */
limitScope: 'PerLayer' | 'PerLevel' | 'PerWorld';
/** */
lineOpacity: number;
/** Max instances count */
maxCount: integer;
/** An array of 4 dimensions for the up/right/down/left borders (in this order) when using 9-slice mode for `tileRenderMode`.<br/> If the tileRenderMode is not NineSlice, then this array is empty.<br/> See: https://en.wikipedia.org/wiki/9-slice_scaling */
nineSliceBorders: integer[];
/** Pivot X coordinate (from 0 to 1.0) */
pivotX: number;
/** Pivot Y coordinate (from 0 to 1.0) */
pivotY: number;
/** Possible values: `Rectangle`, `Ellipse`, `Tile`, `Cross` */
renderMode: 'Cross' | 'Ellipse' | 'Rectangle' | 'Ellipse';
/** If TRUE, the entity instances will be resizable horizontally */
resizableX: boolean;
/** If TRUE, the entity instances will be resizable vertically */
resizableY: boolean;
/** Display entity name in editor */
showName: boolean;
/** An array of strings that classifies this entity */
tags: string[];
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `tileRect` */
tileId: integer | null;
/** */
tileOpacity: number;
/** An object representing a rectangle from an existing Tileset */
tileRect: LDtkTilesetRect | null;
/** An enum describing how the the Entity tile is rendered inside the Entity bounds. Possible values: `Cover`, `FitInside`, `Repeat`, `Stretch`, `FullSizeCropped`, `FullSizeUncropped`, `NineSlice` */
tileRenderMode:
| 'Cover'
| 'FitInside'
| 'FullSizeCropped'
| 'FullSizeUncropped'
| 'NineSlice'
| 'Repeat'
| 'Stretch';
/** Tileset ID used for optional tile display */
tilesetId: integer | null;
/** Unique Int identifier */
uid: integer;
/** Pixel width */
width: integer;
};
/** Entity instance */
type LDtkEntityInstance = {
/** Grid-based coordinates (`[x,y]` format) */
__grid: integer[];
/** Entity definition identifier */
__identifier: string;
/** Pivot coordinates (`[x,y]` format, values are from 0 to 1) of the Entity */
__pivot: number[];
/** The entity \"smart\" color, guessed from either Entity definition, or one its field instances. */
__smartColor: string;
/** Array of tags defined in this Entity definition */
__tags: string[];
/** Optional TilesetRect used to display this entity (it could either be the default Entity tile, or some tile provided by a field value, like an Enum). */
__tile: LDtkTilesetRect | null;
/** Reference of the **Entity definition** UID */
defUid: integer;
/** An array of all custom fields and their values. */
fieldInstances: LDtkFieldInstance[];
/** Entity height in pixels. For non-resizable entities, it will be the same as Entity definition. */
height: integer;
/** Unique instance identifier */
iid: string;
/** Pixel coordinates (`[x,y]` format) in current level coordinate space. Don't forget optional layer offsets, if they exist! */
px: integer[];
/** Entity width in pixels. For non-resizable entities, it will be the same as Entity definition. */
width: integer;
};
/** Enum definition */
type LDtkEnumDef = {
/** */
externalFileChecksum: string | null;
/** Relative path to the external file providing this Enum */
externalRelPath: string | null;
/** Tileset UID if provided */
iconTilesetUid: integer | null;
/** User defined unique identifier */
identifier: string;
/** An array of user-defined tags to organize the Enums */
tags: string[];
/** Unique Int identifier */
uid: integer;
/** All possible enum values, with their optional Tile infos. */
values: LDtkEnumDefValues[];
};
/** Enum value definition */
type LDtkEnumDefValues = {
/** An array of 4 Int values that refers to the tile in the tileset image: `[ x, y, width, height ]` */
__tileSrcRect: integer[] | null;
/** Optional color */
color: integer;
/** Enum value */
id: string;
/** The optional ID of the tile */
tileId: integer | null;
};
/** In a tileset definition, enum based tag infos */
type LDtkEnumTagValue = {
/** */
enumValueId: string;
/** */
tileIds: integer[];
};
/** This section is mostly only intended for the LDtk editor app itself. You can safely ignore it. */
type LDtkFieldDef = {
/** Human readable value type. Possible values: `Int, Float, String, Bool, Color, ExternEnum.XXX, LocalEnum.XXX, Point, FilePath`.<br/> If the field is an array, this field will look like `Array<...>` (eg. `Array<Int>`, `Array<Point>` etc.)<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */
__type: string;
/** Optional list of accepted file extensions for FilePath value type. Includes the dot: `.ext` */
acceptFileTypes: string[] | null;
/** Possible values: `Any`, `OnlySame`, `OnlyTags` */
allowedRefs: 'Any' | 'OnlySame' | 'OnlyTags';
/** */
allowedRefTags: string[];
/** */
allowOutOfLevelRef: boolean;
/** Array max length */
arrayMaxLength: integer | null;
/** Array min length */
arrayMinLength: integer | null;
/** */
autoChainRef: boolean;
/** TRUE if the value can be null. For arrays, TRUE means it can contain null values (exception: array of Points can't have null values). */
canBeNull: boolean;
/** Default value if selected value is null or invalid. */
defaultOverride: any | null;
/** */
editorAlwaysShow: boolean;
/** */
editorCutLongValues: boolean;
/** Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`, `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`, `RefLinkBetweenCenters` */
editorDisplayMode:
| 'ArrayCountNoLabel'
| 'ArrayCountWithLabel'
| 'EntityTile'
| 'Hidden'
| 'NameAndValue'
| 'PointPath'
| 'PointPathLoop'
| 'PointStar'
| 'Points'
| 'RadiusGrid'
| 'RadiusPx'
| 'RefLinkBetweenCenters'
| 'RefLinkBetweenPivots'
| 'ValueOnly';
/** Possible values: `Above`, `Center`, `Beneath` */
editorDisplayPos: 'Above' | 'Beneath' | 'Center';
/** */
editorTextPrefix: string | null;
/** */
editorTextSuffix: string | null;
/** User defined unique identifier */
identifier: string;
/** TRUE if the value is an array of multiple values */
isArray: boolean;
/** Max limit for value, if applicable */
max: number | null;
/** Min limit for value, if applicable */
min: number | null;
/** Optional regular expression that needs to be matched to accept values. Expected format: `/some_reg_ex/g`, with optional \"i\" flag. */
regex: string | null;
/** */
symmetricalRef: boolean;
/** Possible values: &lt;`null`&gt;, `LangPython`, `LangRuby`, `LangJS`, `LangLua`, `LangC`, `LangHaxe`, `LangMarkdown`, `LangJson`, `LangXml`, `LangLog` */
textLanguageMode:
| 'LangC'
| 'LangHaxe'
| 'LangJS'
| 'LangJson'
| 'LangLog'
| 'LangLua'
| 'LangMarkdown'
| 'LangPython'
| 'LangRuby'
| 'LangXml'
| null;
/** UID of the tileset used for a Tile */
tilesetUid: integer | null;
/** Internal enum representing the possible field types. Possible values: F_Int, F_Float, F_String, F_Text, F_Bool, F_Color, F_Enum(...), F_Point, F_Path, F_EntityRef, F_Tile */
type: string;
/** Unique Int identifier */
uid: integer;
/** If TRUE, the color associated with this field will override the Entity or Level default color in the editor UI. For Enum fields, this would be the color associated to their values. */
useForSmartColor: boolean;
};
/** Field instance */
type LDtkFieldInstance = {
/** Field definition identifier */
__identifier: string;
/** Optional TilesetRect used to display this field (this can be the field own Tile, or some other Tile guessed from the value, like an Enum). */
__tile: LDtkTilesetRect | null;
/** Type of the field, such as `Int`, `Float`, `String`, `Enum(my_enum_name)`, `Bool`, etc.<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */
__type: string;
/** Actual value of the field instance. The value type varies, depending on `__type`:<br/> - For **classic types** (ie. Integer, Float, Boolean, String, Text and FilePath), you just get the actual value with the expected type.<br/> - For **Color**, the value is an hexadecimal string using \"#rrggbb\" format.<br/> - For **Enum**, the value is a String representing the selected enum value.<br/> - For **Point**, the value is a [GridPoint](#ldtk-GridPoint) object.<br/> - For **Tile**, the value is a [TilesetRect](#ldtk-TilesetRect) object.<br/> - For **EntityRef**, the value is an [EntityReferenceInfos](#ldtk-EntityReferenceInfos) object.<br/><br/> If the field is an array, then this `__value` will also be a JSON array. */
__value: any;
/** Reference of the **Field definition** UID */
defUid: integer;
/** Editor internal raw values */
realEditorValues: any[];
};
type LDtkFlag =
| 'DiscardPreCsvIntGrid'
| 'ExportPreCsvIntGridFormat'
| 'IgnoreBackupSuggest'
| 'PrependIndexToLevelFileNames'
| 'MultiWorlds'
| 'UseMultilinesType';
/** IntGrid value definition */
type LDtkIntGridValueDef = {
/** */
color: string;
/** User defined unique identifier */
identifier: string | null;
/** The IntGrid value itself */
value: integer;
};
/** IntGrid value instance */
type LDtkIntGridValueInstance = {
/** Coordinate ID in the layer grid */
coordId: integer;
/** IntGrid value */
v: integer;
};
/** Layer definition */
type LDtkLayerDef = {
/** Type of the layer (*IntGrid, Entities, Tiles or AutoLayer*) */
__type: string;
/** Contains all the auto-layer rule definitions. */
autoRuleGroups: LDtkAutoLayerRuleGroup[];
/** */
autoSourceLayerDefUid: integer | null;
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `tilesetDefUid` */
autoTilesetDefUid: integer | null;
/** Opacity of the layer (0 to 1.0) */
displayOpacity: number;
/** An array of tags to forbid some Entities in this layer */
excludedTags: string[];
/** Width and height of the grid in pixels*/
gridSize: integer;
/** Height of the optional \"guide\" grid in pixels */
guideGridHei: integer;
/** Width of the optional \"guide\" grid in pixels */
guideGridWid: integer;
/** */
hideFieldsWhenInactive: boolean;
/** Hide the layer from the list on the side of the editor view. */
hideInList: boolean;
/** User defined unique identifier */
identifier: string;
/** Alpha of this layer when it is not the active one. */
inactiveOpacity: number;
/** An array that defines extra optional info for each IntGrid value.<br/> WARNING: the array order is not related to actual IntGrid values! As user can re-order IntGrid values freely, you may value \"2\" before value \"1\" in this array. */
intGridValues: LDtkIntGridValueDef[];
/** Parallax horizontal factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect. */
parallaxFactorX: number;
/** Parallax vertical factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect. */
parallaxFactorY: number;
/** If true (default), a layer with a parallax factor will also be scaled up/down accordingly. */
parallaxScaling: boolean;
/** X offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance` optional offset) */
pxOffsetX: integer;
/** Y offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance` optional offset) */
pxOffsetY: integer;
/** An array of tags to filter Entities that can be added to this layer */
requiredTags: string[];
/** If the tiles are smaller or larger than the layer grid, the pivot value will be used to position the tile relatively its grid cell. */
tilePivotX: number;
/** If the tiles are smaller or larger than the layer grid, the pivot value will be used to position the tile relatively its grid cell.*/
tilePivotY: number;
/** Reference to the default Tileset UID being used by this layer definition.<br/> **WARNING**: some layer *instances* might use a different tileset. So most of the time, you should probably use the `__tilesetDefUid` value found in layer instances.<br/> Note: since version 1.0.0, the old `autoTilesetDefUid` was removed and merged into this value. */
tilesetDefUid: integer | null;
/** Type of the layer as Haxe Enum Possible values: `IntGrid`, `Entities`, `Tiles`, `AutoLayer` */
type: 'AutoLayer' | 'Entities' | 'IntGrid' | 'Tiles';
/** Unique Int identifier */
uid: integer;
};
/** Layer instance */
type LDtkLayerInstance = {
/** Grid-based height */
__cHei: integer;
/** Grid-based width */
__cWid: integer;
/** Grid size */
__gridSize: integer;
/** Layer definition identifier */
__identifier: string;
/** Layer opacity as Float [0-1] */
__opacity: number;
/** Total layer X pixel offset, including both instance and definition offsets. */
__pxTotalOffsetX: integer;
/** Total layer Y pixel offset, including both instance and definition offsets. */
__pxTotalOffsetY: integer;
/** The definition UID of corresponding Tileset, if any. */
__tilesetDefUid: integer | null;
/** The relative path to corresponding Tileset, if any. */
__tilesetRelPath: string | null;
/** Layer type (possible values: IntGrid, Entities, Tiles or AutoLayer) */
__type: string;
/** An array containing all tiles generated by Auto-layer rules. The array is already sorted in display order (ie. 1st tile is beneath 2nd, which is beneath 3rd etc.).<br/><br/> Note: if multiple tiles are stacked in the same cell as the result of different rules, all tiles behind opaque ones will be discarded. */
autoLayerTiles: LDtkTile[];
/** */
entityInstances: LDtkEntityInstance[];
/** */
gridTiles: LDtkTile[];
/** Unique layer instance identifier */
iid: string;
/** **WARNING**: this deprecated value is no longer exported since version 1.0.0 Replaced by: `intGridCsv` */
intGrid: LDtkIntGridValueInstance[] | null;
/** A list of all values in the IntGrid layer, stored in CSV format (Comma Separated Values).<br/> Order is from left to right, and top to bottom (ie. first row from left to right, followed by second row, etc).<br/> `0` means \"empty cell\" and IntGrid values start at 1.<br/> The array size is `__cWid` x `__cHei` cells. */
intGridCsv: integer[];
/** Reference the Layer definition UID */
layerDefUid: integer;
/** Reference to the UID of the level containing this layer instance */
levelId: integer;
/** An Array containing the UIDs of optional rules that were enabled in this specific layer instance. */
optionalRules: integer[];
/** This layer can use another tileset by overriding the tileset UID here. */
overrideTilesetUid: integer | null;
/** X offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, see `__pxTotalOffsetX`) */
pxOffsetX: integer;
/** Y offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, see `__pxTotalOffsetY`) */
pxOffsetY: integer;
/** Random seed used for Auto-Layers rendering */
seed: integer;
/** Layer instance visibility */
visible: boolean;
};
/** This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If \"*Separate level files*\" is **disabled** (default): full level data is *embedded* inside the main Project JSON file, - If \"*Separate level files*\" is **enabled**: level data is stored in *separate* standalone `.ldtkl` files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the `layerInstances` array (which will be null). The `externalRelPath` string points to the `ldtkl` file. A `ldtkl` file is just a JSON file containing exactly what is described below. */
type LDtkLevel = {
/** Background color of the level (same as `bgColor`, except the default value is automatically used here if its value is `null`) */
__bgColor: string;
/** Position informations of the background image, if there is one. */
__bgPos: LDtkLevelBgPosInfos | null;
/** An array listing all other levels touching this one on the world map.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty. */
__neighbours: LDtkNeighbourLevel[];
/** The \"guessed\" color for this level in the editor, decided using either the background color or an existing custom field. */
__smartColor: string;
/** Background color of the level. If `null`, the project `defaultLevelBgColor` should be used. */
bgColor: string | null;
/** Background image Y pivot (0-1) */
bgPivotY: number;
/** Background image X pivot (0-1) */
bgPivotX: number;
/** An enum defining the way the background image (if any) is positioned on the level. See `__bgPos` for resulting position info. Possible values: &lt;`null`&gt;, `Unscaled`, `Contain`, `Cover`, `CoverDirty` */
bgPos: 'Unscaled' | 'Contain' | 'Cover' | 'CoverDirty' | null;
/** The *optional* relative path to the level background image. */
bgRelPath: string | null;
/** This value is not null if the project option \"*Save levels separately*\" is enabled. In this case, this **relative** path points to the level Json file. */
externalRelPath: string | null;
/** An array containing this level custom field values. */
fieldInstances: LDtkFieldInstance[];
/** User defined unique identifier */
identifier: string;
/** Unique instance identifier */
iid: string;
/** An array containing all Layer instances. **IMPORTANT**: if the project option \"*Save levels separately*\" is enabled, this field will be `null`.<br/> This array is **sorted in display order**: the 1st layer is the top-most and the last is behind. */
layerInstances: LDtkLayerInstance[] | null;
/** Height of the level in pixels */
pxHei: integer;
/** Width of the level in pixels */
pxWid: integer;
/** Unique Int identifier */
uid: integer;
/** If TRUE, the level identifier will always automatically use the naming pattern as defined in `Project.levelNamePattern`. Becomes FALSE if the identifier is manually modified by user. */
useAutoIdentifier: boolean;
/** Index that represents the \"depth\" of the level in the world. Default is 0, greater means \"above\", lower means \"below\".<br/> This value is mostly used for display only and is intended to make stacking of levels easier to manage. */
worldDepth: integer;
/** World X coordinate in pixels.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here. */
worldX: integer;
/** World Y coordinate in pixels.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here. */
worldY: integer;
};
/** Level background image position info */
type LDtkLevelBgPosInfos = {
/** An array of 4 float values describing the cropped sub-rectangle of the displayed background image. This cropping happens when original is larger than the level bounds. Array format: `[ cropX, cropY, cropWidth, cropHeight ]` */
cropRect: number[];
/** An array containing the `[scaleX,scaleY]` values of the **cropped** background image, depending on `bgPos` option. */
scale: number[];
/** An array containing the `[x,y]` pixel coordinates of the top-left corner of the **cropped** background image, depending on `bgPos` option. */
topLeftPx: integer[];
};
/** Nearby level info */
type LDtkNeighbourLevel = {
/** A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est, `e`ast). */
dir: string;
/** Neighbour Instance Identifier */
levelIid: string;
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `levelIid` */
levelUid: integer;
};
/** This structure represents a single tile from a given Tileset. */
type LDtkTile = {
/** Internal data used by the editor.<br/> For auto-layer tiles: `[ruleId, coordId]`.<br/> For tile-layer tiles: `[coordId]`. */
d: integer[];
/** \"Flip bits\", a 2-bits integer to represent the mirror transformations of the tile.<br/> - Bit 0 = X flip<br/> - Bit 1 = Y flip<br/> Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips) */
f: integer;
/** Pixel coordinates of the tile in the **layer** (`[x,y]` format). Don't forget optional layer offsets, if they exist! */
px: integer[];
/** Pixel coordinates of the tile in the **tileset** (`[x,y]` format) */
src: integer[];
/** The *Tile ID* in the corresponding tileset. */
t: integer;
};
/** The `Tileset` definition is the most important part among project definitions. It contains some extra informations about each integrated tileset. If you only had to parse one definition section, that would be the one. */
export type LDtkTilesetDef = {
/** Grid-based height */
__cHei: integer;
/** Grid-based width */
__cWid: integer;
/** The following data is used internally for various optimizations. It's always synced with source image changes. */
cachedPixelData: object | null;
/** An array of custom tile metadata */
customData: LDtkTileCustomMetadata[];
/** If this value is set, then it means that this atlas uses an internal LDtk atlas image instead of a loaded one. Possible values: &lt;`null`&gt;, `LdtkIcons` */
embedAtlas: 'LdtkIcons' | null;
/** Tileset tags using Enum values specified by `tagsSourceEnumId`. This array contains 1 element per Enum value, which contains an array of all Tile IDs that are tagged with it. */
enumTags: LDtkEnumTagValue[];
/** User defined unique identifier */
identifier: string;
/** Distance in pixels from image borders */
padding: integer;
/** Image height in pixels */
pxHei: integer;
/** Image width in pixels */
pxWid: integer;
/** Path to the source file, relative to the current project JSON file<br/> It can be null if no image was provided, or when using an embed atlas. */
relPath: string | null;
/** Array of group of tiles selections, only meant to be used in the editor */
savedSelections: object[];
/** Space in pixels between all tiles */
spacing: integer;
/** An array of user-defined tags to organize the Tilesets */
tags: string[];
/** Optional Enum definition UID used for this tileset meta-data */
tagsSourceEnumUid: integer | null;
/** */
tileGridSize: integer;
/** Unique Intidentifier */
uid: integer;
};
/** In a tileset definition, user defined meta-data of a tile. */
type LDtkTileCustomMetadata = {
/** */
data: string;
/** */
tileId: integer;
};
/** This object represents a custom sub rectangle in a Tileset image. */
type LDtkTilesetRect = {
/** Height in pixels */
h: integer;
/** UID of the tileset */
tilesetUid: integer;
/** Width in pixels */
w: integer;
/** X pixels coordinate of the top-left corner in the Tileset image */
x: integer;
/** Y pixels coordinate of the top-left corner in the Tileset image */
y: integer;
};
type LDtkWorld = {};
export {};
//# sourceMappingURL=LDtkFormat.d.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
import { EditableTileMap } from '../../model/TileMapModel';
import { LDtkTileMap } from './LDtkFormat';
export declare namespace LDtkTileMapLoader {
/**
* Create a {@link EditableTileMap} from the LDtk JSON.
*
* @param ldtkTileMap A tile map exported from LDtk.
* @param levelIndex The level of the tile map to load from.
* @returns A {@link EditableTileMap}
*/
function load(
ldtkTileMap: LDtkTileMap,
levelIndex: number
): EditableTileMap | null;
}
//# sourceMappingURL=LDtkTileMapLoader.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LDtkTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkB,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG,IAAI,CAwJxB;CACF"}

View File

@@ -0,0 +1,5 @@
export declare function getLDtkTileId(
tileSetId: number,
tileId: number
): number;
//# sourceMappingURL=LDtkTileMapLoaderHelper.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LDtkTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoaderHelper.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQvE"}

View File

@@ -1,8 +1,8 @@
import { float, integer } from '../model/CommonTypes';
import { float, integer } from '../../model/CommonTypes';
/**
* Tiled JSON format (https://www.mapeditor.org/).
* Tiled JSON format (https://github.com/mapeditor/tiled/blob/master/docs/reference/json-map-format.rst).
*/
export declare type TiledMap = {
export type TiledTileMap = {
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
backgroundcolor?: string;
/** The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default) */
@@ -44,7 +44,7 @@ export declare type TiledMap = {
/** Number of tile columns */
width: integer;
};
export declare type TiledLayer = {
export type TiledLayer = {
/** Array of {@link TiledChunk} (optional). `tilelayer` only. */
chunks?: Array<TiledChunk>;
/** `zlib`, `gzip`, `zstd` (since Tiled 1.3) or empty (default). `tilelayer` only. */
@@ -98,7 +98,7 @@ export declare type TiledLayer = {
/** Vertical layer offset in tiles. Always 0. */
y: integer;
};
export declare type TiledChunk = {
export type TiledChunk = {
/** Array of `unsigned` `integer` (GIDs) or base64-encoded data */
data: Array<integer> | string;
/** Height in tiles */
@@ -110,7 +110,7 @@ export declare type TiledChunk = {
/** Y coordinate in tiles */
y: integer;
};
export declare type TiledObject = {
export type TiledObject = {
/** The class of the object (renamed from type since 1.9, optional) */
class?: string;
/** Used to mark an object as an ellipse */
@@ -146,7 +146,7 @@ export declare type TiledObject = {
/** Y coordinate in pixels */
y: float;
};
export declare type TiledText = {
export type TiledText = {
/** Whether to use a bold font (default: `false`) */
bold: boolean;
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (default: `#000000`) */
@@ -172,7 +172,7 @@ export declare type TiledText = {
/** Whether the text is wrapped within the object bounds (default: `false`) */
wrap: boolean;
};
export declare type TiledTileset = {
export type TiledTileset = {
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
backgroundcolor?: string;
/** The number of tile columns in the tileset */
@@ -224,7 +224,7 @@ export declare type TiledTileset = {
/** Array of {@link TiledWangSet} (since 1.1.5) */
wangsets?: Array<TiledWangSet>;
};
export declare type TiledGrid = {
export type TiledGrid = {
/** Cell height of tile grid */
height: integer;
/** `orthogonal` (default) or `isometric` */
@@ -232,13 +232,13 @@ export declare type TiledGrid = {
/** Cell width of tile grid */
width: integer;
};
export declare type TileOffset = {
export type TileOffset = {
/** Horizontal offset in pixels */
x: integer;
/** Vertical offset in pixels (positive is down) */
y: integer;
};
export declare type TiledTransformations = {
export type TiledTransformations = {
/** Tiles can be flipped horizontally */
hflip: boolean;
/** Tiles can be flipped vertically */
@@ -248,7 +248,7 @@ export declare type TiledTransformations = {
/** Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations */
preferuntransformed: boolean;
};
export declare type TiledTileDefinition = {
export type TiledTileDefinition = {
/** Array of {@link TiledTiles} */
animation?: Array<TiledTileDefinition>;
/** The class of the tile (renamed from type since 1.9, optional) */
@@ -270,13 +270,13 @@ export declare type TiledTileDefinition = {
/** Index of terrain for each corner of tile (optional) */
terrain?: Array<integer>;
};
export declare type TiledFrame = {
export type TiledFrame = {
/** Frame duration in milliseconds */
duration: integer;
/** Local tile ID representing this frame */
tileid: integer;
};
export declare type TiledTerrain = {
export type TiledTerrain = {
/** Name of terrain */
name: string;
/** Array of {@link TiledProperty} */
@@ -284,7 +284,7 @@ export declare type TiledTerrain = {
/** Local ID of tile representing terrain */
tile: integer;
};
export declare type TiledWangSet = {
export type TiledWangSet = {
/** Array of {@link TiledWangColor} */
colors: Array<TiledWangColor>;
/** Name of the Wang set */
@@ -296,7 +296,7 @@ export declare type TiledWangSet = {
/** Array of {@link TiledWangTile} */
wangtiles: Array<TiledWangTile>;
};
export declare type TiledWangColor = {
export type TiledWangColor = {
/** Hex-formatted color (#RRGGBB or #AARRGGBB) */
color: string;
/** Name of the Wang color */
@@ -308,13 +308,13 @@ export declare type TiledWangColor = {
/** Local ID of tile representing the Wang color */
tile: integer;
};
export declare type TiledWangTile = {
export type TiledWangTile = {
/** Local ID of tile */
tileid: integer;
/** Array of Wang color indexes (`uchar[8]`) */
wangid: Array<integer>;
};
export declare type TiledObjectTemplate = {
export type TiledObjectTemplate = {
/** `template` */
type: string;
/** External tileset used by the template (optional) */
@@ -322,7 +322,7 @@ export declare type TiledObjectTemplate = {
/** The object instantiated by this template */
object: Object;
};
export declare type TiledProperty = {
export type TiledProperty = {
/** Name of the property */
name: string;
/** type of the property (`string` (default), `integer`, `float`, `boolean`, `color` or `file` (since 0.16, with `color` and `file` added in 0.17)) */
@@ -330,7 +330,7 @@ export declare type TiledProperty = {
/** Value of the property */
value: string | number;
};
export declare type TiledPoint = {
export type TiledPoint = {
/** X coordinate in pixels */
x: float;
/** Y coordinate in pixels */

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
import { EditableTileMap } from '../../model/TileMapModel';
import { TiledTileMap } from './TiledFormat';
/**
* It creates a {@link EditableTileMap} from a Tiled JSON.
*/
export declare namespace TiledTileMapLoader {
/**
* Create a {@link EditableTileMap} from the Tiled JSON.
*
* @param tiledTileMap A tile map exported from Tiled.
* @param pako The zlib library.
* @returns A {@link EditableTileMap}
*/
function load(tiledTileMap: TiledTileMap, pako: any): EditableTileMap | null;
}
//# sourceMappingURL=TiledTileMapLoader.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;GAEG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CA0KxB;CACF"}

Some files were not shown because too many files have changed in this diff Show More