Demo Mode
Goals
To be able to add custom project settings and in game logic to separate "demo" specific behavior from the standard builds.
How it works
First we need to create extra export presets, click on the "Features" tab, and add the "demo" tag to it, or any other number of tags for this particular export preset.
Then, anywhere on code you can check for the existence of any feature tag to trigger any special logic related to it by using OS.has_feature(Constants.TAG_DEMO)
For adding custom Project Settings options, you'll need to:
- Click the "name" of the setting you want to override
- Click the button "Override for..." on the top right of the Project Settings screen, to the left of the "Delete" button (be careful not to misclick the "Delete" button)
- Choose the desired "feature tag" from the drop down list
- A new entry will be created in the format "setting_name.feature_tag" and you can change it's value to whatever you want! When a build is exported with this feature tag, the value of that setting will be overriden to this value.
Testing
Unfortunately, it is not possible to test custom feature tags in the editor directly. Running the game in the editor will not apply any custom feature tags, even from export presets marked as "Runnable".
Marking an export preset as "Runnable" only affects what preset will be chosen for one click deploys, and in those, you can test for feature tags normally, but on Godot 3.x they only work for HTML and android builds.
So we need to export the game with the export preset that has the tag we need to test and test it manually.
Alternatively, you can create a custom gut test or scene to forcedly test the functions or logic that will be called in the demo build, but you can't test for the presence of the demo tag triggering this logic on gut or the editor.
With what script it communicates
To find out what is different on "demo" mode, run a project wide search for OS.has_feature(Constants.TAG_DEMO)
For now it is affecting:
- version label - it adds a "demo" to it
- SMKSIntroSplashScreen - makes a "demo" warning label visible
- QuestAnnouncement - Stops game after completing a quest and locks the player in a "Thanks for playing the demo please give feedback" screen. The player can go back to main menu to play the demo from scratch if they want, but can't progress further than this.
For finding all Project Settings that have a custom demo "override", open it in something like visual studio code, and search for .demo
The current overrides are for:
- name - Changes project name to "Tribe of the Accord Demo", which is the name that will appear in the window or task bar icon.