mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-17 23:43:47 +00:00
Updated func godot to latest dev
This commit is contained in:
parent
aef2437e21
commit
d41eaf5164
26 changed files with 682 additions and 6069 deletions
|
|
@ -178,7 +178,7 @@ func build_def_text(target_editor: FuncGodotFGDFile.FuncGodotTargetMapEditors =
|
|||
prop_val = "\"\""
|
||||
TYPE_OBJECT:
|
||||
if value is Resource:
|
||||
prop_val = value.resource_path
|
||||
prop_val = "\"" + value.resource_path + "\""
|
||||
if value is Material:
|
||||
if target_editor != FuncGodotFGDFile.FuncGodotTargetMapEditors.JACK:
|
||||
prop_type = "material"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum TargetMapEditor {
|
|||
@export var scale_expression : String = ""
|
||||
## Model Point Class can override the 'size' meta property by auto-generating a value from the meshes' [AABB]. Proper generation requires 'scale_expression' set to a float or [Vector3]. **WARNING:** Generated size property unlikely to align cleanly to grid!
|
||||
@export var generate_size_property : bool = false
|
||||
## Degrees to rotate model prior to export. Different editors may handdle GLTF transformations differently. If your model isn't oriented correctly, try modifying this property.
|
||||
@export var rotation_offset: Vector3 = Vector3(0.0, 0.0, 0.0)
|
||||
## Creates a .gdignore file in the model export folder to prevent Godot importing the display models. Only needs to be generated once.
|
||||
@export var generate_gd_ignore_file : bool = false :
|
||||
get:
|
||||
|
|
@ -97,7 +99,9 @@ func _create_gltf_file(gltf_state: GLTFState, path: String, node: Node3D) -> boo
|
|||
var gltf_document := GLTFDocument.new()
|
||||
gltf_state.create_animations = false
|
||||
|
||||
node.rotate_y(deg_to_rad(-90))
|
||||
node.rotate_x(deg_to_rad(rotation_offset.x))
|
||||
node.rotate_y(deg_to_rad(rotation_offset.y))
|
||||
node.rotate_z(deg_to_rad(rotation_offset.z))
|
||||
|
||||
# With TrenchBroom we can specify a scale expression, but for other editors we need to scale our models manually.
|
||||
if target_map_editor != TargetMapEditor.TRENCHBROOM:
|
||||
|
|
|
|||
|
|
@ -47,15 +47,17 @@ func _enter_tree() -> void:
|
|||
|
||||
add_custom_type("FuncGodotMap", "Node3D", preload("res://addons/func_godot/src/map/func_godot_map.gd"), null)
|
||||
|
||||
ProjectSettings.set("func_godot/default_map_settings", "res://addons/func_godot/func_godot_default_map_settings.tres")
|
||||
var property_info = {
|
||||
"name": "func_godot/default_map_settings",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.tres"
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
ProjectSettings.set_initial_value("func_godot/default_map_settings", "res://addons/func_godot/func_godot_default_map_settings.tres")
|
||||
if not ProjectSettings.has_setting("func_godot/default_map_settings"):
|
||||
ProjectSettings.set_setting("func_godot/default_map_settings", "res://addons/func_godot/func_godot_default_map_settings.tres")
|
||||
var property_info = {
|
||||
"name": "func_godot/default_map_settings",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.tres"
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
ProjectSettings.set_as_basic("func_godot/default_map_settings", true)
|
||||
ProjectSettings.set_initial_value("func_godot/default_map_settings", "res://addons/func_godot/func_godot_default_map_settings.tres")
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_custom_type("FuncGodotMap")
|
||||
|
|
|
|||
|
|
@ -352,6 +352,18 @@ func build_texture_size_dict() -> Dictionary:
|
|||
texture_size_dict[tex_key] = Vector2.ONE
|
||||
|
||||
return texture_size_dict
|
||||
|
||||
static func get_script_by_class_name(name_of_class : String) -> Script:
|
||||
if ResourceLoader.exists(name_of_class, "Script"):
|
||||
return load(name_of_class) as Script
|
||||
|
||||
for global_class in ProjectSettings.get_global_class_list():
|
||||
var found_name_of_class : String = global_class["class"]
|
||||
var found_path : String = global_class["path"]
|
||||
if found_name_of_class == name_of_class:
|
||||
return load(found_path) as Script
|
||||
|
||||
return null
|
||||
|
||||
## Build nodes from the entities in [member entity_dicts]
|
||||
func build_entity_nodes() -> Array:
|
||||
|
|
@ -423,7 +435,12 @@ func build_entity_nodes() -> Array:
|
|||
entity_nodes[entity_idx] = null
|
||||
continue
|
||||
if entity_definition.node_class != "":
|
||||
node = ClassDB.instantiate(entity_definition.node_class)
|
||||
if ClassDB.class_exists(entity_definition.node_class):
|
||||
node = ClassDB.instantiate(entity_definition.node_class)
|
||||
else:
|
||||
var script : Script = get_script_by_class_name(entity_definition.node_class)
|
||||
if script is GDScript:
|
||||
node = (script as GDScript).new()
|
||||
elif entity_definition is FuncGodotFGDPointClass:
|
||||
if entity_definition.scene_file:
|
||||
var flag: PackedScene.GenEditState = PackedScene.GEN_EDIT_STATE_DISABLED
|
||||
|
|
@ -431,7 +448,12 @@ func build_entity_nodes() -> Array:
|
|||
flag = PackedScene.GEN_EDIT_STATE_INSTANCE
|
||||
node = entity_definition.scene_file.instantiate(flag)
|
||||
elif entity_definition.node_class != "":
|
||||
node = ClassDB.instantiate(entity_definition.node_class)
|
||||
if ClassDB.class_exists(entity_definition.node_class):
|
||||
node = ClassDB.instantiate(entity_definition.node_class)
|
||||
else:
|
||||
var script : Script = get_script_by_class_name(entity_definition.node_class)
|
||||
if script is GDScript:
|
||||
node = (script as GDScript).new()
|
||||
if 'rotation_degrees' in node and entity_definition.apply_rotation_on_map_build:
|
||||
var angles := Vector3.ZERO
|
||||
if 'angles' in properties or 'mangle' in properties:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
class_name NetRadiantCustomGamePackConfig
|
||||
extends Resource
|
||||
|
||||
enum NetRadiantCustomMapType {
|
||||
QUAKE_1,
|
||||
QUAKE_3
|
||||
}
|
||||
|
||||
## Button to export / update this gamepack's configuration in the NetRadiant Custom Gamepacks Folder.
|
||||
@export var export_file: bool:
|
||||
get:
|
||||
|
|
@ -50,6 +55,12 @@ extends Resource
|
|||
## Skip texture path that gets applied to caulk and nodrawnonsolid shaders.
|
||||
@export var skip_texture: String = "textures/special/skip"
|
||||
|
||||
## Quake map type NetRadiant will filter the map for.
|
||||
## By default, will specify Quake 1 limitations. This will remove patches.
|
||||
## mapq3 will allow saving patches.
|
||||
## @warning Toggling this option may be destructive!
|
||||
@export var map_type: NetRadiantCustomMapType = NetRadiantCustomMapType.QUAKE_1
|
||||
|
||||
## Variables to include in the exported gamepack's [code]default_build_menu.xml[/code].[br][br]
|
||||
## Each [String] key defines a variable name, and its corresponding [String] value as the literal command-line string to execute in place of this variable identifier[br][br]
|
||||
## Entries may be referred to by key in [member default_build_menu_commands] values.
|
||||
|
|
@ -92,6 +103,13 @@ func build_gamepack_text() -> String:
|
|||
soundtypes_str += sound_type
|
||||
if sound_type != sound_types[-1]:
|
||||
soundtypes_str += " "
|
||||
|
||||
var maptype_str: String
|
||||
|
||||
if map_type == NetRadiantCustomMapType.QUAKE_3:
|
||||
maptype_str = "mapq3"
|
||||
else:
|
||||
maptype_str = "mapq1"
|
||||
|
||||
var gamepack_text: String = """<?xml version="1.0"?>
|
||||
<game
|
||||
|
|
@ -110,7 +128,7 @@ func build_gamepack_text() -> String:
|
|||
texturetypes="%s"
|
||||
modeltypes="%s"
|
||||
soundtypes="%s"
|
||||
maptypes="mapq1"
|
||||
maptypes="%s"
|
||||
shaders="quake3"
|
||||
entityclass="halflife"
|
||||
entityclasstype="fgd"
|
||||
|
|
@ -140,6 +158,7 @@ func build_gamepack_text() -> String:
|
|||
texturetypes_str,
|
||||
modeltypes_str,
|
||||
soundtypes_str,
|
||||
maptype_str,
|
||||
default_scale,
|
||||
clip_texture,
|
||||
skip_texture,
|
||||
|
|
@ -149,7 +168,8 @@ func build_gamepack_text() -> String:
|
|||
|
||||
## Exports or updates a folder in the /games directory, with an icon, .cfg, and all accompanying FGDs.
|
||||
func do_export_file() -> void:
|
||||
if (FuncGodotLocalConfig.get_setting(FuncGodotLocalConfig.PROPERTY.MAP_EDITOR_GAME_PATH) as String).is_empty():
|
||||
var game_path: String = FuncGodotLocalConfig.get_setting(FuncGodotLocalConfig.PROPERTY.MAP_EDITOR_GAME_PATH) as String
|
||||
if game_path.is_empty():
|
||||
printerr("Skipping export: Map Editor Game Path not set in Project Configuration")
|
||||
return
|
||||
|
||||
|
|
@ -172,7 +192,8 @@ func do_export_file() -> void:
|
|||
var gamepack_dir_paths: Array = [
|
||||
gamepacks_folder + "/" + gamepack_name + ".game",
|
||||
gamepacks_folder + "/" + gamepack_name + ".game/" + base_game_path,
|
||||
gamepacks_folder + "/" + gamepack_name + ".game/scripts"
|
||||
gamepacks_folder + "/" + gamepack_name + ".game/scripts",
|
||||
game_path + "/scripts"
|
||||
]
|
||||
var err: Error
|
||||
|
||||
|
|
@ -198,18 +219,44 @@ func do_export_file() -> void:
|
|||
printerr("Error: Could not modify " + target_file_path)
|
||||
|
||||
# .shader
|
||||
# NOTE: To work properly, this should go in the game path. For now, I'm leaving the export to NRC as well, so it can easily
|
||||
# be repackaged for distribution. However, I believe in the end, it shouldn't exist there.
|
||||
# We'll need to make a decision for this. - Vera
|
||||
var shader_text: String = build_shader_text()
|
||||
|
||||
# build to <gamepack path>/scripts/
|
||||
target_file_path = gamepacks_folder + "/" + gamepack_name + ".game/scripts/" + gamepack_name + ".shader"
|
||||
print("Exporting NetRadiant Custom Shader to ", target_file_path)
|
||||
print("Exporting NetRadiant Custom shader definitions to ", target_file_path)
|
||||
file = FileAccess.open(target_file_path, FileAccess.WRITE)
|
||||
if file != null:
|
||||
file.store_string(build_shader_text())
|
||||
file.store_string(shader_text)
|
||||
file.close()
|
||||
else:
|
||||
printerr("Error: Could not modify " + target_file_path)
|
||||
|
||||
# build to <game path>/scripts/
|
||||
target_file_path = game_path.path_join("scripts/%s.shader" % gamepack_name)
|
||||
print("Exporting NetRadiant Custom shader definitions to ", target_file_path)
|
||||
file = FileAccess.open(target_file_path, FileAccess.WRITE)
|
||||
if file != null:
|
||||
file.store_string(shader_text)
|
||||
file.close()
|
||||
else:
|
||||
printerr("Error: could not modify " + target_file_path)
|
||||
|
||||
# shaderlist.txt - see above NOTE regarding duplication
|
||||
target_file_path = gamepacks_folder + "/" + gamepack_name + ".game/scripts/shaderlist.txt"
|
||||
print("Exporting NetRadiant Custom shader list to ", target_file_path)
|
||||
file = FileAccess.open(target_file_path, FileAccess.WRITE)
|
||||
if file != null:
|
||||
file.store_string(gamepack_name)
|
||||
file.close()
|
||||
else:
|
||||
printerr("Error: Could not modify " + target_file_path)
|
||||
|
||||
# shaderlist.txt
|
||||
target_file_path = gamepacks_folder + "/" + gamepack_name + ".game/scripts/shaderlist.txt"
|
||||
print("Exporting NetRadiant Custom Default Buld Menu to ", target_file_path)
|
||||
# game path/scripts/shaderlist.txt
|
||||
target_file_path = game_path.path_join("scripts/shaderlist.txt")
|
||||
print("Exporting NetRadiant Custom shader list to ", target_file_path)
|
||||
file = FileAccess.open(target_file_path, FileAccess.WRITE)
|
||||
if file != null:
|
||||
file.store_string(gamepack_name)
|
||||
|
|
@ -219,7 +266,7 @@ func do_export_file() -> void:
|
|||
|
||||
# default_build_menu.xml
|
||||
target_file_path = gamepacks_folder + "/" + gamepack_name + ".game/default_build_menu.xml"
|
||||
print("Exporting NetRadiant Custom Default Buld Menu to ", target_file_path)
|
||||
print("Exporting NetRadiant Custom default build menu to ", target_file_path)
|
||||
file = FileAccess.open(target_file_path, FileAccess.WRITE)
|
||||
|
||||
if file != null:
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@ enum PROPERTY {
|
|||
DEFAULT_INVERSE_SCALE
|
||||
}
|
||||
|
||||
@export var export_func_godot_settings: bool: set = _save_settings
|
||||
@export var reload_func_godot_settings: bool = false :
|
||||
set(value):
|
||||
_load_settings()
|
||||
@export_tool_button("Export func_godot settings", "Save") var export_func_godot_settings = _save_settings
|
||||
@export_tool_button("Reload func_godot settings", "Reload") var reload_func_godot_settings = _load_settings
|
||||
|
||||
const CONFIG_PROPERTIES: Array[Dictionary] = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ func create_material(texture_name: String) -> Material:
|
|||
if (map_settings.save_generated_materials and material
|
||||
and texture_name != map_settings.clip_texture
|
||||
and texture_name != map_settings.skip_texture
|
||||
and texture_name != map_settings.origin_texture
|
||||
and texture.resource_path != "res://addons/func_godot/textures/default_texture.png"):
|
||||
ResourceSaver.save(material, material_path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue