mirror of
https://github.com/tonytins/citylimits.git
synced 2025-03-15 12:21:22 +00:00
Game version
This commit is contained in:
parent
239fa63a0c
commit
0ed6b75520
7 changed files with 199 additions and 1 deletions
21
addons/godot-version-management/LICENSE
Normal file
21
addons/godot-version-management/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Tomek
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
70
addons/godot-version-management/README.md
Normal file
70
addons/godot-version-management/README.md
Normal file
|
@ -0,0 +1,70 @@
|
|||
# Godot Version Manager
|
||||
|
||||
<img src="https://raw.githubusercontent.com/fcazalet/godot-version-management/main/icon.png" width="64" height="64">
|
||||
|
||||
This addon is for developpers that want a centralized place for version naming / build number and then display it in game.
|
||||
|
||||
It allow you to configure version and build in project settings.
|
||||
|
||||
These configurations are synchronized to all existing export of your project.
|
||||
|
||||
Moreover configurations can be loaded for in game display.
|
||||
|
||||
## How to install it
|
||||
|
||||
You can find this addon in Godot AssetLibrary
|
||||
See the Godot Addon install section : https://docs.godotengine.org/en/stable/tutorials/plugins/editor/installing_plugins.html
|
||||
|
||||
## How to use it for exports
|
||||
|
||||
Once the addon activated it add two entry in your project configuration:
|
||||
|
||||
- Application / Config / Version as String (application/config/version default to 0.0.1)
|
||||
- Application / Config / Build as Integer (application/config/build default to 1)
|
||||
|
||||
You can change the version and the build numbers.
|
||||
It will update all your exports versions value to the project config value.
|
||||
Then you need to reload the project (Project / Reload current project).
|
||||
|
||||
See below section to know why you need to reload project.
|
||||
|
||||
For Android exports:
|
||||
* version is version/name
|
||||
* build is version/code
|
||||
|
||||
For iOS and MacOS exports:
|
||||
* version is application/short_version
|
||||
* build is application/version
|
||||
|
||||
For Windows Desktop exports:
|
||||
* version is application/file_version and application/product_version
|
||||
|
||||
For HTML5 and UWP exports no versions specified.
|
||||
|
||||
## How to use it for in game display
|
||||
|
||||
The version and build numbers can be accessed for in game use like that:
|
||||
|
||||
|
||||
```GDScript
|
||||
# To get version string
|
||||
var version = ProjectSettings.get_setting("application/config/version")
|
||||
# To get build number
|
||||
var build = ProjectSettings.get_setting("application/config/build")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Why I need to reload project ?
|
||||
|
||||
The GodotVersionManager addon update the export-presets.cfg file.
|
||||
|
||||
Because of Godot keep in memory ExportsSettings and do not reload it from export-presets.cfg file you will need to reload your project.
|
||||
|
||||
When project is loaded Godot load in memory the export-presets.cfg .
|
||||
|
||||
## Support Me
|
||||
|
||||
You to buy me a coffee ?
|
||||
<a href='https://ko-fi.com/J3J2COV54' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee' /></a>
|
78
addons/godot-version-management/godot_version_manager.gd
Normal file
78
addons/godot-version-management/godot_version_manager.gd
Normal file
|
@ -0,0 +1,78 @@
|
|||
# By Erasor
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
const PLUGIN_NAME = "Godot-Version-Manager"
|
||||
const DEBUG = true
|
||||
# Use same name as https://github.com/godotengine/godot/pull/35555
|
||||
const PROJECT_VERSION_SETTING = "application/config/version"
|
||||
const PROJECT_BUILD_SETTING = "application/config/build"
|
||||
const EXPORT_PRESETS_FILE = "res://export_presets.cfg"
|
||||
var current_version
|
||||
var current_build
|
||||
|
||||
func _enter_tree():
|
||||
if not ProjectSettings.has_setting(PROJECT_VERSION_SETTING):
|
||||
ProjectSettings.set_setting(PROJECT_VERSION_SETTING, "0.0.1")
|
||||
if not ProjectSettings.has_setting(PROJECT_BUILD_SETTING):
|
||||
ProjectSettings.set_setting(PROJECT_BUILD_SETTING, 1)
|
||||
current_version = ProjectSettings.get_setting(PROJECT_VERSION_SETTING)
|
||||
current_build = ProjectSettings.get_setting(PROJECT_BUILD_SETTING)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
# Do not remove the verson config, may conflict with https://github.com/godotengine/godot/pull/35555
|
||||
pass
|
||||
|
||||
|
||||
func apply_changes():
|
||||
_update_export_presets()
|
||||
|
||||
|
||||
func save_external_data():
|
||||
_update_export_presets()
|
||||
|
||||
|
||||
func _update_export_presets():
|
||||
# If config version changed, update all exports
|
||||
if ProjectSettings.get_setting(PROJECT_VERSION_SETTING) != current_version:
|
||||
var export_config: ConfigFile = ConfigFile.new()
|
||||
var err = export_config.load(EXPORT_PRESETS_FILE)
|
||||
if err == OK:
|
||||
# Loop limited to 100 exports
|
||||
for i in range(0, 100):
|
||||
var section = "preset." + str(i)
|
||||
if export_config.has_section(section):
|
||||
plugin_log("Update Export " + export_config.get_value(section, "platform"))
|
||||
# Update Android exports configs
|
||||
if export_config.get_value(section, "platform") == "Android":
|
||||
export_config.set_value(section + ".options", 'version/name', ProjectSettings.get_setting(PROJECT_VERSION_SETTING))
|
||||
export_config.set_value(section + ".options", 'version/code', ProjectSettings.get_setting(PROJECT_BUILD_SETTING))
|
||||
if export_config.get_value(section, "platform") == "iOS" or export_config.get_value(section, "platform") == "Mac OSX":
|
||||
export_config.set_value(section + ".options", 'application/short_version', ProjectSettings.get_setting(PROJECT_VERSION_SETTING))
|
||||
export_config.set_value(section + ".options", 'application/version', ProjectSettings.get_setting(PROJECT_BUILD_SETTING))
|
||||
if export_config.get_value(section, "platform") == "UWP":
|
||||
# TODO parsing of version to minor/major
|
||||
pass
|
||||
if export_config.get_value(section, "platform") == "Windows Desktop":
|
||||
export_config.set_value(section + ".options", 'application/file_version', ProjectSettings.get_setting(PROJECT_VERSION_SETTING))
|
||||
export_config.set_value(section + ".options", 'application/product_version', ProjectSettings.get_setting(PROJECT_VERSION_SETTING))
|
||||
else:
|
||||
break
|
||||
err = export_config.save(EXPORT_PRESETS_FILE)
|
||||
ProjectSettings.save()
|
||||
if err == OK:
|
||||
plugin_log("All exports updated")
|
||||
else:
|
||||
plugin_log("Error saving " + EXPORT_PRESETS_FILE + ", exports not updated")
|
||||
else:
|
||||
plugin_log('Error open ' + EXPORT_PRESETS_FILE)
|
||||
|
||||
|
||||
func plugin_log(message):
|
||||
if (DEBUG):
|
||||
var time : Dictionary = OS.get_datetime()
|
||||
var date_string : String = "%02d:%02d" % [time.hour, time.minute]
|
||||
print(date_string, " - ", PLUGIN_NAME, " - ", message)
|
||||
|
||||
|
8
addons/godot-version-management/plugin.cfg
Normal file
8
addons/godot-version-management/plugin.cfg
Normal file
|
@ -0,0 +1,8 @@
|
|||
[plugin]
|
||||
|
||||
name="Godot-Version-Manager"
|
||||
description="Godot plugin to manage versions for exports.
|
||||
It centralize the version number in project."
|
||||
author="Erasor"
|
||||
version="1.0.0"
|
||||
script="godot_version_manager.gd"
|
|
@ -115,6 +115,8 @@ run/main_scene="res://scenes/Game.tscn"
|
|||
config/icon="res://icon.png"
|
||||
config/macos_native_icon="res://icon.icns"
|
||||
config/windows_native_icon="res://icon.ico"
|
||||
config/version="0.0.1"
|
||||
config/build=1000
|
||||
|
||||
[autoload]
|
||||
|
||||
|
@ -132,7 +134,7 @@ window/stretch/aspect="keep"
|
|||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "res://addons/beehave/plugin.cfg" )
|
||||
enabled=PoolStringArray( "res://addons/beehave/plugin.cfg", "res://addons/godot-version-management/plugin.cfg" )
|
||||
|
||||
[gdnative]
|
||||
|
||||
|
|
|
@ -293,6 +293,16 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="VersionLbl" type="Label" parent="Controls/Control Panel/Windows"]
|
||||
anchor_left = 0.0146199
|
||||
anchor_top = 0.0271318
|
||||
anchor_right = 0.182261
|
||||
anchor_bottom = 0.0542636
|
||||
text = "Version"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Status" type="Panel" parent="Controls/Control Panel"]
|
||||
anchor_top = 12.95
|
||||
anchor_right = 25.65
|
||||
|
|
|
@ -5,7 +5,16 @@ onready var tax_window = $TaxWindow
|
|||
onready var advsior_meet_window = $AdvisorMeet
|
||||
onready var tools_window = $ToolsWindow
|
||||
|
||||
onready var verLabel = $VersionLbl
|
||||
|
||||
func _ready():
|
||||
# To get version string
|
||||
var version = ProjectSettings.get_setting("application/config/version")
|
||||
# To get build number
|
||||
var build = ProjectSettings.get_setting("application/config/build")
|
||||
|
||||
verLabel.text = version + " (Build " + str(build) + ")"
|
||||
|
||||
SimData.city_name = SimData.city_name.capitalize()
|
||||
SimData.mayor_name = SimData.mayor_name.capitalize()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue