diff --git a/.gitignore b/.gitignore index 4777302..e3e3c09 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ scn/ override.cfg # Godot-specific ignores -.import/ +.godot/ export.cfg export_presets.cfg diff --git a/BootScreen.gd b/BootScreen.gd index 5a1cafb..1042955 100644 --- a/BootScreen.gd +++ b/BootScreen.gd @@ -26,7 +26,7 @@ func _ready(): Core.game_dir = config.sections["paths"]["sc4_files"] else: $dialog.popup_centered(get_viewport_rect().size / 2) - yield($dialog, "popup_hide") + await $dialog.popup_hide config.sections["paths"] = {} config.sections["paths"]["sc4_files"] = Core.game_dir config.save_file() @@ -36,7 +36,7 @@ func _ready(): var dir_complete = true while not dir_complete: if dir.open(Core.game_dir) == OK: - dir.list_dir_begin() + dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 var files = [] var file_name = dir.get_next() while file_name != "": @@ -52,7 +52,7 @@ func _ready(): var subdir = Directory.new() print(Core.game_dir+folder_dir) if subdir.open(Core.game_dir+folder_dir) == OK: - subdir.list_dir_begin() + subdir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 var subfile_name = subdir.get_next() var found = false while subfile_name != "": @@ -75,18 +75,18 @@ func _ready(): if not dir_complete: $dialog.window_title = "dir was incomplete, select the SC4 installation folder" $dialog.popup_centered(get_viewport_rect().size / 2) - yield($dialog, "popup_hide") + await $dialog.popup_hide print("todo: store path in cfg.ini") config.sections["paths"] = {} config.sections["paths"]["sc4_files"] = Core.game_dir config.save_file() - $dialog.deselect_items() + $dialog.deselect_all() $LoadProgress.value = 0 loading_thread = Thread.new() Logger.info("Loading OpenSC4...") Logger.info("Using %s as game data folder" % Core.game_dir) # Would be nice to start multiple threads here not only one - var err = loading_thread.start(self, 'load_DATs') + var err = loading_thread.start(Callable(self,'load_DATs')) if err != OK: Logger.error("Error starting thread: " % err) return @@ -117,12 +117,12 @@ func _on_dialog_confirmed(): func _on_DATExplorerButton_pressed(): print("here") - var err = get_tree().change_scene("res://DATExplorer/DATExplorer.tscn") + var err = get_tree().change_scene_to_file("res://DATExplorer/DATExplorer.tscn") if err != OK: Logger.error("Error: %s" % err) func _on_GameButton_pressed(): - var err = get_tree().change_scene("res://Region.tscn") + var err = get_tree().change_scene_to_file("res://Region.tscn") if err != OK: Logger.error("Error: %s" % err) diff --git a/BootScreen.tscn b/BootScreen.tscn index 05a30a7..7e5b213 100644 --- a/BootScreen.tscn +++ b/BootScreen.tscn @@ -1,96 +1,89 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=3 format=3 uid="uid://d0ediey6qa77f"] -[ext_resource path="res://BootScreen.gd" type="Script" id=1] -[ext_resource path="res://splash.png" type="Texture" id=2] +[ext_resource type="Script" path="res://BootScreen.gd" id="1"] +[ext_resource type="Texture2D" uid="uid://swmrfycjhv5j" path="res://splash.png" id="2"] [node name="BootScreen" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 1 ) +script = ExtResource("1") [node name="dialog" type="FileDialog" parent="."] -margin_left = 228.0 -margin_top = 87.0 -margin_right = 1045.0 -margin_bottom = 649.0 -rect_min_size = Vector2( 150, 52.5 ) -popup_exclusive = true -window_title = "set the SimCity 4 directory" -mode_overrides_title = false mode = 2 +mode_overrides_title = false access = 2 show_hidden_files = true [node name="LoadProgress" type="ProgressBar" parent="."] +layout_mode = 0 anchor_left = 0.25 anchor_top = 0.514 anchor_right = 0.75 anchor_bottom = 0.55 -margin_left = -10.0 -margin_top = 219.92 -margin_right = -10.0 -margin_bottom = 219.92 +offset_left = -10.0 +offset_top = 219.92 +offset_right = -10.0 +offset_bottom = 219.92 [node name="Label" type="Label" parent="."] -margin_left = 310.0 -margin_top = 568.0 -margin_right = 433.0 -margin_bottom = 582.0 +layout_mode = 0 +offset_left = 310.0 +offset_top = 568.0 +offset_right = 433.0 +offset_bottom = 582.0 text = "Loading OpenSC4..." [node name="CurrentFileLabel" type="Label" parent="."] -margin_left = 310.0 -margin_top = 631.0 -margin_right = 350.0 -margin_bottom = 645.0 +layout_mode = 0 +offset_left = 310.0 +offset_top = 631.0 +offset_right = 350.0 +offset_bottom = 645.0 -[node name="background" type="Sprite" parent="."] -position = Vector2( 636, 366 ) -scale = Vector2( 0.6625, 0.675 ) +[node name="background" type="Sprite2D" parent="."] z_index = -1 -texture = ExtResource( 2 ) +position = Vector2(636, 366) +scale = Vector2(0.6625, 0.675) +texture = ExtResource("2") [node name="NextScene" type="Panel" parent="."] visible = false +layout_mode = 0 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -381.0 -margin_top = -139.0 -margin_right = 381.0 -margin_bottom = 139.0 +offset_left = -381.0 +offset_top = -139.0 +offset_right = 381.0 +offset_bottom = 139.0 [node name="VBoxContainer" type="VBoxContainer" parent="NextScene"] +layout_mode = 0 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -122.0 -margin_top = -19.0 -margin_right = -122.0 -margin_bottom = -19.0 +offset_left = -122.0 +offset_top = -19.0 +offset_right = -122.0 +offset_bottom = -19.0 [node name="Label" type="Label" parent="NextScene/VBoxContainer"] -margin_right = 244.0 -margin_bottom = 14.0 +layout_mode = 2 text = "Game files loaded" -align = 1 [node name="HBoxContainer" type="HBoxContainer" parent="NextScene/VBoxContainer"] -margin_top = 18.0 -margin_right = 244.0 -margin_bottom = 38.0 +layout_mode = 2 [node name="GameButton" type="Button" parent="NextScene/VBoxContainer/HBoxContainer"] -margin_right = 96.0 -margin_bottom = 20.0 +layout_mode = 2 text = "Launch game" [node name="DATExplorerButton" type="Button" parent="NextScene/VBoxContainer/HBoxContainer"] -margin_left = 100.0 -margin_right = 244.0 -margin_bottom = 20.0 +layout_mode = 2 text = "Launch DAT explorer" [connection signal="confirmed" from="dialog" to="." method="_on_dialog_confirmed"] diff --git a/CameraAnchor.gd b/CameraAnchor.gd index 120167e..44feae7 100644 --- a/CameraAnchor.gd +++ b/CameraAnchor.gd @@ -1,4 +1,4 @@ -extends KinematicBody2D +extends CharacterBody2D var velocity = Vector2(0, 0) var viewport = 0 @@ -63,4 +63,6 @@ func right_click_movement(): func _process(delta): right_click_movement() - self.move_and_slide(self.velocity * delta) + self.set_velocity(self.velocity * delta) + self.move_and_slide() + self.velocity diff --git a/CityView/CityScene/CameraAnchor3D.gd b/CityView/CityScene/CameraAnchor3D.gd index 001e5cc..3bebc43 100644 --- a/CityView/CityScene/CameraAnchor3D.gd +++ b/CityView/CityScene/CameraAnchor3D.gd @@ -1,9 +1,9 @@ -extends KinematicBody +extends CharacterBody3D var zoom = 1 var zoom_list = [292, 146, 73, 32, 16, 8] var elevations = [60, 55, 50, 45, 45, 45] -var AZIMUTH = deg2rad(67.5) +var AZIMUTH = deg_to_rad(67.5) var rotated = 2 var boot = true var velocity = Vector3(0, 0, 0) @@ -12,7 +12,7 @@ var hold_r = [] func _ready(): self.transform.origin = Vector3(self.transform.origin.x, get_parent().WATER_HEIGHT, self.transform.origin.z) _set_view() - $Camera.set_znear(-200.0) + $Camera3D.set_near(-200.0) pass func _input(event): @@ -24,7 +24,7 @@ func _input(event): var camera_left = Vector3(self.transform.basis.x.x, 0, self.transform.basis.x.z) # Should move one screen width every 5 seconds - var move_vel = $Camera.size + var move_vel = $Camera3D.size if event is InputEventMouseMotion: if event.position.x < margin_w: move -= camera_left @@ -37,48 +37,50 @@ func _input(event): move += camera_forward self.velocity = move.normalized() * move_vel - #print($Camera.project_position(Vector2(0.5, 0.5), 0.5)) + #print($Camera3D.project_position(Vector2(0.5, 0.5), 0.5)) elif event is InputEventMouseButton: if event.is_pressed(): - if event.button_index == BUTTON_WHEEL_UP: + if event.button_index == MOUSE_BUTTON_WHEEL_UP: self.zoom += 1 if self.zoom > 6: self.zoom = 6 - $Camera.size = zoom_list[self.zoom-1] + $Camera3D.size = zoom_list[self.zoom-1] _set_view() - elif event.button_index == BUTTON_RIGHT: + elif event.button_index == MOUSE_BUTTON_RIGHT: if len(hold_r) == 0: hold_r = [event.position.x, event.position.y] - elif event.button_index == BUTTON_WHEEL_DOWN: + elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN: self.zoom -= 1 if self.zoom < 1: self.zoom = 1 - $Camera.size = zoom_list[self.zoom-1] + $Camera3D.size = zoom_list[self.zoom-1] _set_view() if not event.is_pressed(): - if event.button_index == BUTTON_RIGHT: + if event.button_index == MOUSE_BUTTON_RIGHT: hold_r = [] elif event is InputEventKey: - if event.pressed and event.scancode == KEY_PAGEUP: + if event.pressed and event.keycode == KEY_PAGEUP: rotated = (rotated + 1)%4 - var rot = round(((rotated*(PI/2)) + get_node("../Spatial").rotation.y) / (PI/2))*(PI/2) - var rot_trans = get_node("../Spatial").transform.rotated(Vector3(0,1,0), rot) - get_node("../Spatial").set_transform(rot_trans) + var rot = round(((rotated*(PI/2)) + get_node("../Node3D").rotation.y) / (PI/2))*(PI/2) + var rot_trans = get_node("../Node3D").transform.rotated(Vector3(0,1,0), rot) + get_node("../Node3D").set_transform(rot_trans) var old = self.transform.origin self.transform.origin = Vector3(-old.z, old.y, old.x) - elif event.pressed and event.scancode == KEY_PAGEDOWN: + elif event.pressed and event.keycode == KEY_PAGEDOWN: rotated = ((rotated-1)+4)%4 - var rot = round(((rotated*(PI/2)) + get_node("../Spatial").rotation.y) / (PI/2))*(PI/2) - var rot_trans = get_node("../Spatial").transform.rotated(Vector3(0,1,0), rot) - get_node("../Spatial").set_transform(rot_trans) + var rot = round(((rotated*(PI/2)) + get_node("../Node3D").rotation.y) / (PI/2))*(PI/2) + var rot_trans = get_node("../Node3D").transform.rotated(Vector3(0,1,0), rot) + get_node("../Node3D").set_transform(rot_trans) var old = self.transform.origin self.transform.origin = Vector3(old.z, old.y, -old.x) func _physics_process(_delta): - self.move_and_slide(self.velocity) + self.set_velocity(self.velocity) + self.move_and_slide() + self.velocity func _set_view(): # Elevation angle, Azimuth is a class var since it doesn't change - var El = deg2rad(elevations[zoom-1]) + var El = deg_to_rad(elevations[zoom-1]) # exposure angles D and E var D = atan( (cos(El)) / (tan(AZIMUTH)) ) @@ -97,23 +99,23 @@ func _set_view(): v_trans = v_trans.inverse() v_trans.origin = self.transform.origin self.transform = v_trans - #print("in", v_trans, "\ncm", self.get_node("Camera").transform) + #print("in", v_trans, "\ncm", self.get_node("Camera3D").transform) # set sun location self.get_node("../Sun").transform.origin = Vector3(-50, 30, 20) self.get_node("../Sun").look_at(Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0)) # set zoom related uniforms for shaders - var mat = self.get_parent().get_node("Spatial/Terrain").get_material_override() - mat.set_shader_param("zoom", zoom) - mat.set_shader_param("tiling_factor", zoom) - self.get_parent().get_node("Spatial/Terrain").set_material_override(mat) - var mat_e = self.get_parent().get_node("Spatial/Border").get_material_override() - mat_e.set_shader_param("zoom", zoom) - mat_e.set_shader_param("tiling_factor", zoom) - self.get_parent().get_node("Spatial/Border").set_material_override(mat_e) - var mat_w = self.get_parent().get_node("Spatial/WaterPlane").get_material_override() - mat_w.set_shader_param("zoom", zoom) - mat_w.set_shader_param("tiling_factor", zoom) - self.get_parent().get_node("Spatial/WaterPlane").set_material_override(mat_w) + var mat = self.get_parent().get_node("Node3D/Terrain").get_material_override() + mat.set_shader_parameter("zoom", zoom) + mat.set_shader_parameter("tiling_factor", zoom) + self.get_parent().get_node("Node3D/Terrain").set_material_override(mat) + var mat_e = self.get_parent().get_node("Node3D/Border").get_material_override() + mat_e.set_shader_parameter("zoom", zoom) + mat_e.set_shader_parameter("tiling_factor", zoom) + self.get_parent().get_node("Node3D/Border").set_material_override(mat_e) + var mat_w = self.get_parent().get_node("Node3D/WaterPlane").get_material_override() + mat_w.set_shader_parameter("zoom", zoom) + mat_w.set_shader_parameter("tiling_factor", zoom) + self.get_parent().get_node("Node3D/WaterPlane").set_material_override(mat_w) diff --git a/CityView/CityScene/City.gd b/CityView/CityScene/City.gd index 93dd615..04749ba 100644 --- a/CityView/CityScene/City.gd +++ b/CityView/CityScene/City.gd @@ -1,4 +1,4 @@ -extends Spatial +extends Node3D var size_w : int = 4 var size_h : int = 4 @@ -51,7 +51,7 @@ func load_city_terrain(svfile : DBPF): heightmap.append([]) for j in range(self.height): heightmap[i].append(terrain_info.get_altitude(i, j)) - self.get_node("Spatial/Terrain").heightmap = heightmap + self.get_node("Node3D/Terrain").heightmap = heightmap return heightmap #(0, 0) (1, 0) @@ -93,9 +93,9 @@ func create_face(v0 : Vector3, v1 : Vector3, v2 : Vector3, v3 : Vector3, heightm else: normalz.append(Vector3(0.0, 1.0, 0.0)) - var vertices = PoolVector3Array() - var normals = PoolVector3Array() - var UVs = PoolVector2Array() + var vertices = PackedVector3Array() + var normals = PackedVector3Array() + var UVs = PackedVector2Array() # this if-else is my attempt to make the terrain diagonals smart, sometimes they still don't cooperate if min(normal1.y, normal2.y) >= min(normal3.y, normal4.y): @@ -248,25 +248,25 @@ func create_edge(vert, n1, n2, normal): return [vertices, normals, UVs] func create_terrain(): - self.ind_layer = $Spatial/Terrain.load_textures_to_uv_dict() - var vertices : PoolVector3Array = PoolVector3Array() - var normals : PoolVector3Array = PoolVector3Array() - var UVs : PoolVector2Array = PoolVector2Array() - var col_layer_weights : PoolColorArray = PoolColorArray() - var uv2_layer_ind : PoolVector2Array = PoolVector2Array() - var e_vertices : PoolVector3Array = PoolVector3Array() - var e_normals : PoolVector3Array = PoolVector3Array() - var e_UVs : PoolVector2Array = PoolVector2Array() - var w_vertices : PoolVector3Array = PoolVector3Array() - var w_normals : PoolVector3Array = PoolVector3Array() - var w_UVs : PoolVector2Array = PoolVector2Array() + self.ind_layer = $Node3D/Terrain.load_textures_to_uv_dict() + var vertices : PackedVector3Array = PackedVector3Array() + var normals : PackedVector3Array = PackedVector3Array() + var UVs : PackedVector2Array = PackedVector2Array() + var col_layer_weights : PackedColorArray = PackedColorArray() + var uv2_layer_ind : PackedVector2Array = PackedVector2Array() + var e_vertices : PackedVector3Array = PackedVector3Array() + var e_normals : PackedVector3Array = PackedVector3Array() + var e_UVs : PackedVector2Array = PackedVector2Array() + var w_vertices : PackedVector3Array = PackedVector3Array() + var w_normals : PackedVector3Array = PackedVector3Array() + var w_UVs : PackedVector2Array = PackedVector2Array() # Random heightmap (for now) var heightmap : Array if savefile != null: heightmap = load_city_terrain(savefile) else: heightmap = gen_random_terrain(size_w * 64 + 1, size_h * 64 + 1) - $Spatial/WaterPlane.generate_wateredges(heightmap) + $Node3D/WaterPlane.generate_wateredges(heightmap) var tiles_w = size_w * 64 var tiles_h = size_h * 64 @@ -361,19 +361,19 @@ func create_terrain(): arrays[ArrayMesh.ARRAY_TEX_UV2] = uv2_layer_ind arrays[ArrayMesh.ARRAY_COLOR] = col_layer_weights array_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays) - $Spatial/Terrain.mesh = array_mesh - $Spatial/Terrain.create_trimesh_collision() + $Node3D/Terrain.mesh = array_mesh + $Node3D/Terrain.create_trimesh_collision() #var layer_img = Image.new() - #var layer_flat = PoolByteArray([]) + #var layer_flat = PackedByteArray([]) #for row in self.layer_arr: # layer_flat.append_array(row) #layer_img.create_from_data(self.width, self.height, false, Image.FORMAT_R8, layer_flat) #var layer_tex = ImageTexture.new() - #layer_tex.create_from_image(layer_img, 2) - #var mat = $Spatial/Terrain.get_material_override() - #mat.set_shader_param("layer", layer_tex) - #$Spatial/Terrain.set_material_override(mat) + #layer_tex.create_from_image(layer_img) #,2 + #var mat = $Node3D/Terrain.get_material_override() + #mat.set_shader_parameter("layer", layer_tex) + #$Node3D/Terrain.set_material_override(mat) var e_rray_mesh : ArrayMesh = ArrayMesh.new() var e_rrays : Array = [] @@ -382,7 +382,7 @@ func create_terrain(): e_rrays[ArrayMesh.ARRAY_NORMAL] = e_normals e_rrays[ArrayMesh.ARRAY_TEX_UV] = e_UVs e_rray_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, e_rrays) - $Spatial/Border.mesh = e_rray_mesh + $Node3D/Border.mesh = e_rray_mesh var warray_mesh : ArrayMesh = ArrayMesh.new() var warrays : Array = [] @@ -391,7 +391,7 @@ func create_terrain(): warrays[ArrayMesh.ARRAY_NORMAL] = w_normals warrays[ArrayMesh.ARRAY_TEX_UV] = w_UVs warray_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, warrays) - $Spatial/WaterPlane.mesh = warray_mesh + $Node3D/WaterPlane.mesh = warray_mesh "test s3d" var TGI_s3d = {"T": 0x5ad0e817, "G": 0xbadb57f1, "I":0x16620430} @@ -402,11 +402,11 @@ func create_terrain(): var x_rand = (x-2.5) + randf() var z_rand = (z-2.5) + randf() var loc_rand = location + Vector3(x_rand, 0, z_rand) - s3dobj.add_to_mesh($Spatial/TestS3D, loc_rand) + s3dobj.add_to_mesh($Node3D/TestS3D, loc_rand) test_exemplar() - var s3dmat = $Spatial/TestS3D.get_material_override() - s3dmat.set_shader_param("nois_texture", $Spatial/WaterPlane/NoiseTexture.texture) - $Spatial/TestS3D.set_material_override(s3dmat) + var s3dmat = $Node3D/TestS3D.get_material_override() + s3dmat.set_shader_parameter("nois_texture", $Node3D/WaterPlane/NoiseTexture.texture) + $Node3D/TestS3D.set_material_override(s3dmat) print("DEBUG") func set_cursor(): @@ -422,7 +422,7 @@ func coord_to_uv(x, y, z): var temp = max(min(32-int((y-15.0) * 1.312), 31),0) # 0x6534284a,0x7a4a8458,0x1a2fdb6b describes AltitudeTemperatureFactor of 0.082, i multiplied this by 16 var moist = 6 - var inst_key = $Spatial/Terrain.tm_table[temp][moist] + var inst_key = $Node3D/Terrain.tm_table[temp][moist] return [Vector2(x_factored, y_factored), self.ind_layer[inst_key]] func get_normal(vert : Vector3, heightmap): diff --git a/CityView/CityScene/City.tscn b/CityView/CityScene/City.tscn index d0b3f6e..afc3336 100644 --- a/CityView/CityScene/City.tscn +++ b/CityView/CityScene/City.tscn @@ -7,7 +7,7 @@ [ext_resource path="res://CityView/Meshes/TestS3D.gd" type="Script" id=5] [ext_resource path="res://CityView/Meshes/TransitTiles.gd" type="Script" id=6] -[sub_resource type="ProceduralSky" id=15] +[sub_resource type="Sky" id=15] radiance_size = 0 sky_top_color = Color( 0.909804, 0.92549, 0.933333, 1 ) sky_horizon_color = Color( 1, 1, 1, 1 ) @@ -49,7 +49,7 @@ uniform float open_wave_str = 20.0; uniform float open_wave_threshold = 0.95; varying float noise_height; -uniform sampler2DArray watertexture : hint_albedo; +uniform sampler2DArray watertexture : source_color; uniform int zoom; uniform float tiling_factor; uniform float max_depth; @@ -109,7 +109,7 @@ void fragment(){ noisenormal += (normalize(vec3(normal_horizontal*(2.0*(noise_tex.g)-1.0), normal_vertical*(2.0*(noise_tex.b)-1.0), normal_horizontal*(2.0*(noise_tex.r)-1.0))) * n_val2.b); noise_tex = texture(noise_normals, mod(n_val3.rg/1024.0, 1.0));// * vec4(2.0, 2.0, 1.0, 1.0) - vec4(1.0, 1.0, 0.0, 0.0); noisenormal -= (normalize(vec3(normal_horizontal*(2.0*sqrt(noise_tex.r)-1.0), normal_vertical*(2.0*sqrt(noise_tex.b)-1.0), normal_horizontal*(2.0*sqrt(noise_tex.g)-1.0))) * n_val3.b); - NORMAL = normalize((PROJECTION_MATRIX * INV_CAMERA_MATRIX * WORLD_MATRIX * vec4(normalize(noisenormal), 0.0)).rgb); + NORMAL = normalize((PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * vec4(normalize(noisenormal), 0.0)).rgb); vec3 break_col = vec3(0.0); if (noisenormal.y/3.0 < open_wave_threshold){ break_col = vec3((open_wave_threshold - noisenormal.y/3.0)*open_wave_str); @@ -179,7 +179,7 @@ flags = 22 width = 1024 height = 1024 seamless = true -as_normalmap = true +as_normal_map = true bump_strength = 10.0 noise = SubResource( 13 ) @@ -187,7 +187,7 @@ noise = SubResource( 13 ) code = "shader_type spatial; render_mode depth_draw_always; -uniform sampler2DArray terrain : hint_albedo; +uniform sampler2DArray terrain : source_color; uniform int zoom; uniform sampler2D layer; uniform sampler2D watermap; @@ -222,7 +222,7 @@ void vertex() layer_i_1 = UV2.x * 255.0; layer_i_2 = UV2.y * 255.0; beach_str = pow(min((texelFetch(watermap, ivec2(coord_pass.xz).yx, 0).r) * 100.0, 1.0), 4.0); - //normal = normalize((inverse(WORLD_MATRIX) * vec4(NORMAL, 0.0)).rgb); + //normal = normalize((inverse(MODEL_MATRIX) * vec4(NORMAL, 0.0)).rgb); //if (map_str < (beach_ht_range/2.0)){ // map_str = min(map_str, 1.0); //} @@ -266,7 +266,7 @@ void fragment() vec3 overlay = vec3(0.0, 0.0, 0.0); vec3 underlay = vec3(0.0, 0.0, 0.0); float over_str = 0.0; - //vec3 normal = normalize((vec4(NORMAL, 0.0) * inverse(WORLD_MATRIX)).xyz); + //vec3 normal = normalize((vec4(NORMAL, 0.0) * inverse(MODEL_MATRIX)).xyz); vec3 normal = normalize(vec3(norm_x, norm_y, norm_z)); if (normal.y < 0.75){ over_str = (max(min(((0.75-(normal.y))*8.0), 1.0), 0.01)); @@ -296,8 +296,8 @@ shader = SubResource( 4 ) code = "shader_type spatial; render_mode depth_draw_always; -uniform sampler2DArray s3dtexture : hint_albedo; -uniform sampler2D nois_texture: hint_albedo; +uniform sampler2DArray s3dtexture : source_color; +uniform sampler2D nois_texture: source_color; uniform vec2 direction = vec2(1.0, 0.0); void fragment(){ @@ -305,7 +305,7 @@ void fragment(){ vec3 noise_col = pow(texelFetch(nois_texture, iUV, 0).rgb * vec3(2.0), vec3(2.0));//*vec3(0.4, 0.8, 0.4); ALBEDO = min(texture(s3dtexture, vec3(UV, 0.0)).rgb * noise_col, vec3(1.0)); ALPHA = texture(s3dtexture, vec3(UV, 0.0)).a; - ALPHA_SCISSOR = 0.9; + ALPHA_SCISSOR_THRESHOLD = 0.9; } " @@ -317,7 +317,7 @@ shader_param/direction = Vector2( 40, 20 ) code = "shader_type spatial; render_mode depth_draw_always; -uniform sampler2DArray terrain : hint_albedo; +uniform sampler2DArray terrain : source_color; uniform int zoom; varying smooth float height_var; varying flat float height_flat; @@ -371,9 +371,9 @@ shader_param/bot_ind = null code = "shader_type spatial; render_mode depth_draw_always; -uniform sampler2DArray textarr : hint_albedo; +uniform sampler2DArray textarr : source_color; varying float built; -//uniform sampler2D layer : hint_albedo; +//uniform sampler2D layer : source_color; varying flat float index; void vertex(){ @@ -401,11 +401,11 @@ void fragment(){ render_priority = 1 shader = SubResource( 18 ) -[node name="City" type="Spatial"] +[node name="City" type="Node3D"] script = ExtResource( 1 ) -[node name="Sun" type="DirectionalLight" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 7.81531e-08, 0, -7.81531e-08, 1, 0, 0, 0 ) +[node name="Sun" type="DirectionalLight3D" parent="."] +transform = Transform3D( 1, 0, 0, 0, 1, 7.81531e-08, 0, -7.81531e-08, 1, 0, 0, 0 ) light_specular = 0.0 light_bake_mode = 0 shadow_enabled = true @@ -418,63 +418,63 @@ __meta__ = { "_editor_description_": "Default environment" } -[node name="Spatial" type="Spatial" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -64, 0, -64 ) +[node name="Node3D" type="Node3D" parent="."] +transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, -64, 0, -64 ) -[node name="WaterPlane" type="MeshInstance" parent="Spatial"] +[node name="WaterPlane" type="MeshInstance3D" parent="Node3D"] material_override = SubResource( 10 ) skeleton = NodePath("../..") software_skinning_transform_normals = false script = ExtResource( 4 ) -[node name="NoiseTexture" type="TextureRect" parent="Spatial/WaterPlane"] +[node name="NoiseTexture" type="TextureRect" parent="Node3D/WaterPlane"] visible = false -margin_left = 107.0 -margin_top = 169.0 -margin_right = 1131.0 -margin_bottom = 1193.0 +offset_left = 107.0 +offset_top = 169.0 +offset_right = 1131.0 +offset_bottom = 1193.0 texture = SubResource( 12 ) -[node name="NoiseNormals" type="TextureRect" parent="Spatial/WaterPlane"] +[node name="NoiseNormals" type="TextureRect" parent="Node3D/WaterPlane"] visible = false -margin_left = -407.0 -margin_top = 170.0 -margin_right = 617.0 -margin_bottom = 1194.0 +offset_left = -407.0 +offset_top = 170.0 +offset_right = 617.0 +offset_bottom = 1194.0 texture = SubResource( 14 ) -[node name="Terrain" type="MeshInstance" parent="Spatial"] +[node name="Terrain" type="MeshInstance3D" parent="Node3D"] material_override = SubResource( 5 ) skeleton = NodePath("../..") software_skinning_transform_normals = false script = ExtResource( 3 ) -[node name="TestS3D" type="MeshInstance" parent="Spatial"] +[node name="TestS3D" type="MeshInstance3D" parent="Node3D"] material_override = SubResource( 17 ) software_skinning_transform_normals = false script = ExtResource( 5 ) -[node name="Border" type="MeshInstance" parent="Spatial"] +[node name="Border" type="MeshInstance3D" parent="Node3D"] material_override = SubResource( 8 ) cast_shadow = 2 software_skinning_transform_normals = false -[node name="TransitTiles" type="MeshInstance" parent="Spatial"] +[node name="TransitTiles" type="MeshInstance3D" parent="Node3D"] material_override = SubResource( 19 ) script = ExtResource( 6 ) -[node name="CameraHandler" type="KinematicBody" parent="."] -transform = Transform( -0.924, 0, 0.191, 0, -1, 0.866, 0.383, 1, 0.462, 0, 15.625, 0 ) +[node name="CameraHandler" type="CharacterBody3D" parent="."] +transform = Transform3D( -0.924, 0, 0.191, 0, -1, 0.866, 0.383, 1, 0.462, 0, 15.625, 0 ) script = ExtResource( 2 ) -[node name="Camera" type="Camera" parent="CameraHandler"] +[node name="Camera3D" type="Camera3D" parent="CameraHandler"] projection = 1 current = true size = 292.0 near = 1.0 far = 200.0 -[node name="WorldEnvironment" type="WorldEnvironment" parent="KinematicBody"] +[node name="WorldEnvironment" type="WorldEnvironment" parent="CharacterBody3D"] environment = SubResource( 1 ) __meta__ = { "_editor_description_": "Default environment" diff --git a/CityView/ClassDefinitions/NetGraphEdge.gd b/CityView/ClassDefinitions/NetGraphEdge.gd index 2e4385c..30f42a0 100644 --- a/CityView/ClassDefinitions/NetGraphEdge.gd +++ b/CityView/ClassDefinitions/NetGraphEdge.gd @@ -3,7 +3,7 @@ class_name NetGraphEdge var start : Vector2 var end : Vector2 var length : float = 0.0 -var tilelocations : PoolVector2Array = PoolVector2Array([]) +var tilelocations : PackedVector2Array = PackedVector2Array([]) var start_node : NetGraphNode var end_node : NetGraphNode diff --git a/CityView/ClassDefinitions/NetGraphNode.gd b/CityView/ClassDefinitions/NetGraphNode.gd index e450bb6..fdacbad 100644 --- a/CityView/ClassDefinitions/NetGraphNode.gd +++ b/CityView/ClassDefinitions/NetGraphNode.gd @@ -1,7 +1,7 @@ class_name NetGraphNode var location : Vector2 -var tilelocations : PoolVector2Array = PoolVector2Array([]) +var tilelocations : PackedVector2Array = PackedVector2Array([]) var edges = [] func _init(): diff --git a/CityView/ClassDefinitions/NetTile.gd b/CityView/ClassDefinitions/NetTile.gd index a79817b..f0cb6ef 100644 --- a/CityView/ClassDefinitions/NetTile.gd +++ b/CityView/ClassDefinitions/NetTile.gd @@ -5,7 +5,7 @@ var edges : Array var tile : TransitTile var draw_dir : Vector2 -func _init(location_, edges_, tile_, draw_dir_): +func _init(location_,edges_,tile_,draw_dir_): self.locations = location_ self.edges = edges_ self.tile = tile_ diff --git a/CityView/ClassDefinitions/TransitTile.gd b/CityView/ClassDefinitions/TransitTile.gd index 000ee7f..b12617c 100644 --- a/CityView/ClassDefinitions/TransitTile.gd +++ b/CityView/ClassDefinitions/TransitTile.gd @@ -6,7 +6,7 @@ var tilepaths : Dictionary var text_arr_layers : Dictionary var UVs : Dictionary -func _init(edges_ : Dictionary, ids_ : Dictionary, layers_ : Dictionary): +func _init(edges_ : Dictionary,ids_ : Dictionary,layers_ : Dictionary): self.edges = edges_ self.ids = ids_ self.tilepaths = self.set_tile_paths() @@ -41,7 +41,7 @@ func set_UVs(tile_ind : int, dir : Vector2): else: flip_uvs = rot_uvs # will need to use the same order when assigning vectors - var ret_uvs = PoolVector2Array([ + var ret_uvs = PackedVector2Array([ flip_uvs[0], flip_uvs[2], flip_uvs[1], @@ -50,7 +50,7 @@ func set_UVs(tile_ind : int, dir : Vector2): flip_uvs[2] ]) if (dir.x>0 and dir.y>0) or (dir.x<0 and dir.y<0): - ret_uvs = PoolVector2Array([ + ret_uvs = PackedVector2Array([ flip_uvs[0], flip_uvs[3], flip_uvs[1], diff --git a/CityView/Meshes/Terrain.gd b/CityView/Meshes/Terrain.gd index c4b4946..ccb7518 100644 --- a/CityView/Meshes/Terrain.gd +++ b/CityView/Meshes/Terrain.gd @@ -1,8 +1,8 @@ -extends MeshInstance +extends MeshInstance3D var tmpMesh = ArrayMesh.new(); -var vertices = PoolVector3Array() -var UVs = PoolVector2Array() +var vertices = PackedVector3Array() +var UVs = PackedVector2Array() var color = Color(0.9, 0.1, 0.1) var mat = self.get_material_override() var st = SurfaceTool.new() @@ -104,7 +104,7 @@ func build_image_dict_and_texture_array(textures): max_width = fsh_subfile.width height = fsh_subfile.height - var texture_array = TextureArray.new() + var texture_array = Texture2DArray.new() texture_array.create (max_width, height, len(textures) * 5, list_texture_format[0], 2) return { "texture_array":texture_array, @@ -140,16 +140,16 @@ func create_ind_to_layer(config, images_dict, texture_array): Logger.error("failed to load layer %s with image %s" % [layer, key]) layer += 1 - self.mat.set_shader_param("cliff_ind", float(cliff_index)) - self.mat.set_shader_param("beach_ind", float(beach_index)) - self.mat.set_shader_param("terrain", texture_array) + self.mat.set_shader_parameter("cliff_ind", float(cliff_index)) + self.mat.set_shader_parameter("beach_ind", float(beach_index)) + self.mat.set_shader_parameter("terrain", texture_array) self.set_material_override(self.mat) var mat_e = self.get_parent().get_node("Border").get_material_override() - mat_e.set_shader_param("terrain", texture_array) + mat_e.set_shader_parameter("terrain", texture_array) - mat_e.set_shader_param("top_ind", float(top_edge)) - mat_e.set_shader_param("mid_ind", float(mid_edge)) - mat_e.set_shader_param("bot_ind", float(bot_edge)) + mat_e.set_shader_parameter("top_ind", float(top_edge)) + mat_e.set_shader_parameter("mid_ind", float(mid_edge)) + mat_e.set_shader_parameter("bot_ind", float(bot_edge)) return dict @@ -180,12 +180,12 @@ func load_textures_to_uv_dict(): #var f = File.new() #f.open("user://uv_dict.txt", File.WRITE) - #f.store_line(to_json(ind_to_layer)) + #f.store_line(JSON.new().stringify(ind_to_layer)) #f.close() return ind_to_layer -func update_terrain(locations : PoolVector3Array, rot_flipped_UVs : PoolVector2Array): +func update_terrain(locations : PackedVector3Array, rot_flipped_UVs : PackedVector2Array): var neighbours = [ Vector3(-1, 0, -1),Vector3(0, 0, -1),Vector3(1, 0, -1), Vector3(-1, 0, 0),Vector3(0, 0, 0),Vector3(1, 0, 0), diff --git a/CityView/Meshes/TestS3D.gd b/CityView/Meshes/TestS3D.gd index 130e54a..4cf98a2 100644 --- a/CityView/Meshes/TestS3D.gd +++ b/CityView/Meshes/TestS3D.gd @@ -1,8 +1,8 @@ -extends MeshInstance +extends MeshInstance3D var tmpMesh = ArrayMesh.new(); -var vertices = PoolVector3Array() -var UVs = PoolVector2Array() +var vertices = PackedVector3Array() +var UVs = PackedVector2Array() var color = Color(0.9, 0.1, 0.1) var mat = self.get_material_override() var st = SurfaceTool.new() diff --git a/CityView/Meshes/TransitTiles.gd b/CityView/Meshes/TransitTiles.gd index 3a5c49c..e24c571 100644 --- a/CityView/Meshes/TransitTiles.gd +++ b/CityView/Meshes/TransitTiles.gd @@ -1,4 +1,4 @@ -extends MeshInstance +extends MeshInstance3D var mat = self.get_material_override() @@ -12,7 +12,7 @@ var drag_arrays : Array = [] var built_arrays : Array = [] var drag_tracker : Array = [] var built_tracker : Array = [] -var drag_meshinst = MeshInstance.new() +var drag_meshinst = MeshInstance3D.new() var layer_map = [] var map_width : int var map_height : int @@ -118,7 +118,7 @@ func _ready(): if not format: format = t_FSH.img.get_format() if not self.textarr: - self.textarr = TextureArray.new() + self.textarr = Texture2DArray.new() self.textarr.create ( t_FSH.width, t_FSH.height, @@ -131,11 +131,11 @@ func _ready(): else: textarr.set_layer_data(t_FSH.img, i) self.mat = self.get_material_override() - self.mat.set_shader_param("textarr", textarr) + self.mat.set_shader_parameter("textarr", textarr) self.add_child(drag_meshinst) - #self.mat.set_shader_param("built", false) + #self.mat.set_shader_parameter("built", false) drag_meshinst.set_material_override(mat) - #self.mat.set_shader_param("built", true) + #self.mat.set_shader_parameter("built", true) self.set_material_override(mat) func _input(event): @@ -154,7 +154,7 @@ func _input(event): self.hold_l = self.mouse_ray() self._drag_network(self.start_l, self.hold_l, "Road") elif event is InputEventKey: - if event.pressed and event.scancode == KEY_CONTROL: + if event.pressed and event.keycode == KEY_CTRL: self.drag_first = not self.drag_first if self.start_l: self._drag_network(self.start_l, self.hold_l, "Road") @@ -162,9 +162,9 @@ func _input(event): func mouse_ray(): var ray_length = 2000 - var space = get_parent().get_world().direct_space_state + var space = get_parent().get_world_3d().direct_space_state var mouse_pos = get_viewport().get_mouse_position() - var camera = get_tree().root.get_camera() + var camera = get_tree().root.get_camera_3d() var from = camera.project_ray_origin(mouse_pos) var to = from + camera.project_ray_normal(mouse_pos) * ray_length var ray_dict = space.intersect_ray(from, to) @@ -524,8 +524,8 @@ func _drag_network(start, end, type): var numSmoothingProgressionSteps = 2 #var distAddedPerSmoothingProgressionStep = 4 # idk, i guess its supposed to take the average of more tiles? """ - var max_height_change = tan(deg2rad(MaxSlopeAlongNetwork))*step_length - var max_slope_change = tan(deg2rad(MaxNetworkSlopeChange))*step_length + var max_height_change = tan(deg_to_rad(MaxSlopeAlongNetwork))*step_length + var max_slope_change = tan(deg_to_rad(MaxNetworkSlopeChange))*step_length for _step in range(numSmoothingProgressionSteps): for h_i in range(len(strip_heights)): var from = strip_heights[max(h_i-1, 0)] @@ -639,7 +639,7 @@ func _drag_network(start, end, type): """ func _build_network():#start, end, type): - "TODO Register tiles to network_tiles and figure out how to copy PoolVector3Array" + "TODO Register tiles to network_tiles and figure out how to copy PackedVector3Array" if len(self.drag_arrays[ArrayMesh.ARRAY_VERTEX]) > 0: var debug = false if self.mesh == null: @@ -648,8 +648,8 @@ func _build_network():#start, end, type): self.built_arrays = [] self.built_arrays.resize(ArrayMesh.ARRAY_MAX) var built = Vector2(0, 128) # used to swap from yellow color to basic with tile colors - var verts_to_terrain = PoolVector3Array(self.drag_arrays[ArrayMesh.ARRAY_VERTEX]) - var UVs_to_terrain = PoolVector2Array(self.drag_arrays[ArrayMesh.ARRAY_TEX_UV]) + var verts_to_terrain = PackedVector3Array(self.drag_arrays[ArrayMesh.ARRAY_VERTEX]) + var UVs_to_terrain = PackedVector2Array(self.drag_arrays[ArrayMesh.ARRAY_TEX_UV]) self.get_parent().get_node("Terrain").update_terrain(verts_to_terrain, UVs_to_terrain) for i in len(self.drag_arrays): if self.built_arrays[i] == null and not self.drag_arrays[i] == null: @@ -690,11 +690,11 @@ func _build_network():#start, end, type): func get_mesh_arrays(arrays): var ret_array = [] ret_array.resize(ArrayMesh.ARRAY_MAX) - ret_array[ArrayMesh.ARRAY_VERTEX] = PoolVector3Array(arrays[ArrayMesh.ARRAY_VERTEX]) - ret_array[ArrayMesh.ARRAY_NORMAL] = PoolVector3Array(arrays[ArrayMesh.ARRAY_NORMAL]) - ret_array[ArrayMesh.ARRAY_COLOR] = PoolColorArray(arrays[ArrayMesh.ARRAY_COLOR]) - ret_array[ArrayMesh.ARRAY_TEX_UV] = PoolVector2Array(arrays[ArrayMesh.ARRAY_TEX_UV]) - ret_array[ArrayMesh.ARRAY_TEX_UV2] = PoolVector2Array(arrays[ArrayMesh.ARRAY_TEX_UV2]) + ret_array[ArrayMesh.ARRAY_VERTEX] = PackedVector3Array(arrays[ArrayMesh.ARRAY_VERTEX]) + ret_array[ArrayMesh.ARRAY_NORMAL] = PackedVector3Array(arrays[ArrayMesh.ARRAY_NORMAL]) + ret_array[ArrayMesh.ARRAY_COLOR] = PackedColorArray(arrays[ArrayMesh.ARRAY_COLOR]) + ret_array[ArrayMesh.ARRAY_TEX_UV] = PackedVector2Array(arrays[ArrayMesh.ARRAY_TEX_UV]) + ret_array[ArrayMesh.ARRAY_TEX_UV2] = PackedVector2Array(arrays[ArrayMesh.ARRAY_TEX_UV2]) return ret_array func get_uvs(rot : int, flip : int): @@ -724,7 +724,7 @@ func get_uvs(rot : int, flip : int): else: flip_uvs = rot_uvs # will need to use the same order when assigning vectors - var ret_uvs = PoolVector2Array([ + var ret_uvs = PackedVector2Array([ flip_uvs[0], flip_uvs[2], flip_uvs[1], diff --git a/CityView/Meshes/WaterPlane.gd b/CityView/Meshes/WaterPlane.gd index 13937f2..681304f 100644 --- a/CityView/Meshes/WaterPlane.gd +++ b/CityView/Meshes/WaterPlane.gd @@ -1,8 +1,8 @@ -extends MeshInstance +extends MeshInstance3D var tmpMesh = ArrayMesh.new(); -var vertices = PoolVector3Array() -var UVs = PoolVector2Array() +var vertices = PackedVector3Array() +var UVs = PackedVector2Array() var color = Color(0.9, 0.1, 0.1) var mat = self.get_material_override() var st = SurfaceTool.new() @@ -36,7 +36,7 @@ func generate_wateredges(HeightMap): var max_depth_water_alpha = 30.0 var depth_range = max_depth_water_alpha + max_beach_height - var watermap = PoolByteArray([]) + var watermap = PackedByteArray([]) var watercoords = [] for w in range(len(HeightMap)): watercoords.append([]) @@ -97,7 +97,7 @@ func generate_wateredges(HeightMap): water_imgs.append(Core.subfile(TGI_waterT["T"], TGI_waterT["G"], TGI_waterT["I"]+zoom, FSHSubfile)) - var water_text = TextureArray.new() + var water_text = Texture2DArray.new() var w_w = water_imgs[4].width var w_h = water_imgs[4].height var format = water_imgs[4].img.get_format() @@ -120,19 +120,19 @@ func generate_wateredges(HeightMap): #shoreimg.flip_x() #shoreimg.flip_y() var shoretex = ImageTexture.new() - shoretex.create_from_image(shoreimg, 0) + shoretex.create_from_image(shoreimg) #,0 mat = self.get_material_override() - mat.set_shader_param("watermap", shoretex) - mat.set_shader_param("watertexture", water_text) - mat.set_shader_param("depth_range", depth_range) - mat.set_shader_param("max_depth", max_depth_water_alpha) - mat.set_shader_param("noise_texture", $NoiseTexture.texture) - mat.set_shader_param("noise_normals", $NoiseNormals.texture) + mat.set_shader_parameter("watermap", shoretex) + mat.set_shader_parameter("watertexture", water_text) + mat.set_shader_parameter("depth_range", depth_range) + mat.set_shader_parameter("max_depth", max_depth_water_alpha) + mat.set_shader_parameter("noise_texture", $NoiseTexture.texture) + mat.set_shader_parameter("noise_normals", $NoiseNormals.texture) self.set_material_override(mat) var matT = self.get_parent().get_node("Terrain").get_material_override() - matT.set_shader_param("watermap", shoretex) - matT.set_shader_param("max_beach_ht", max_beach_height) - matT.set_shader_param("beach_ht_range", depth_range) + matT.set_shader_parameter("watermap", shoretex) + matT.set_shader_parameter("max_beach_ht", max_beach_height) + matT.set_shader_parameter("beach_ht_range", depth_range) self.get_parent().get_node("Terrain").set_material_override(matT) diff --git a/Core.gd b/Core.gd index 2c93461..6d34ffa 100644 --- a/Core.gd +++ b/Core.gd @@ -109,7 +109,6 @@ var group_dict_to_text = { 0xeafcb180: "LTEXT/Plugin Install Text", } - # TODO Generate these dictionaries from the above var type_dict = { "LTEXT": 0x2026960b, @@ -191,7 +190,6 @@ func _type_int_2_str(dict, number:int) -> String: result = dict[number] return result - func _type_str_2_int(dict, text: String) -> int: """ Tries to translate string into number based on dicionary @@ -204,7 +202,6 @@ func _type_str_2_int(dict, text: String) -> int: Logger.error("Could not translate %s into number. Not found." % text) return number - func get_list_instances(type_id_str:String, group_id_str: String): """ Provides list of all instances based on given type_id and group_id. diff --git a/DATExplorer/DATExplorer.tscn b/DATExplorer/DATExplorer.tscn index 0d12739..9b4a632 100644 --- a/DATExplorer/DATExplorer.tscn +++ b/DATExplorer/DATExplorer.tscn @@ -9,47 +9,47 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -640.0 -margin_top = -359.0 -margin_right = 640.0 -margin_bottom = 361.0 +offset_left = -640.0 +offset_top = -359.0 +offset_right = 640.0 +offset_bottom = 361.0 script = ExtResource( 1 ) [node name="DATTree" type="Tree" parent="."] visible = false -margin_top = 56.0 -margin_right = 1280.0 -margin_bottom = 306.0 -rect_min_size = Vector2( 1, 250 ) +offset_top = 56.0 +offset_right = 1280.0 +offset_bottom = 306.0 +custom_minimum_size = Vector2( 1, 250 ) columns = 4 [node name="Filters" type="HBoxContainer" parent="."] visible = false -margin_right = 1280.0 -margin_bottom = 98.0 +offset_right = 1280.0 +offset_bottom = 98.0 [node name="Type" parent="Filters" instance=ExtResource( 3 )] [node name="Group" parent="Filters" instance=ExtResource( 3 )] -margin_left = 68.0 -margin_right = 132.0 +offset_left = 68.0 +offset_right = 132.0 [node name="Instance" parent="Filters" instance=ExtResource( 3 )] -margin_left = 136.0 -margin_right = 200.0 +offset_left = 136.0 +offset_right = 200.0 [node name="ApplyFilter" type="Button" parent="Filters"] -margin_left = 204.0 -margin_right = 293.0 -margin_bottom = 98.0 +offset_left = 204.0 +offset_right = 293.0 +offset_bottom = 98.0 text = "Apply filters" [node name="SubfilePreview" parent="." instance=ExtResource( 4 )] visible = false anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 1280.0 -margin_bottom = 14.0 +offset_right = 1280.0 +offset_bottom = 14.0 [connection signal="item_selected" from="DATTree" to="." method="_on_DATTree_item_selected"] [connection signal="pressed" from="Filters/ApplyFilter" to="." method="_on_ApplyFilter_pressed"] diff --git a/DATExplorer/Filter.tscn b/DATExplorer/Filter.tscn index 426935f..297e116 100644 --- a/DATExplorer/Filter.tscn +++ b/DATExplorer/Filter.tscn @@ -1,25 +1,25 @@ [gd_scene format=2] [node name="TypeFilter" type="VBoxContainer"] -margin_right = 64.0 -margin_bottom = 98.0 +offset_right = 64.0 +offset_bottom = 98.0 [node name="Label" type="Label" parent="."] -margin_right = 64.0 -margin_bottom = 14.0 +offset_right = 64.0 +offset_bottom = 14.0 text = "Filter" [node name="ID" type="LineEdit" parent="."] -margin_top = 18.0 -margin_right = 64.0 -margin_bottom = 42.0 +offset_top = 18.0 +offset_right = 64.0 +offset_bottom = 42.0 max_length = 8 placeholder_text = "id" [node name="Mask" type="LineEdit" parent="."] -margin_top = 46.0 -margin_right = 64.0 -margin_bottom = 70.0 +offset_top = 46.0 +offset_right = 64.0 +offset_bottom = 70.0 text = "00000000" max_length = 8 placeholder_text = "mask" diff --git a/DATExplorer/SubfilePreview.tscn b/DATExplorer/SubfilePreview.tscn index 576cd36..813efaa 100644 --- a/DATExplorer/SubfilePreview.tscn +++ b/DATExplorer/SubfilePreview.tscn @@ -9,11 +9,11 @@ script = ExtResource( 2 ) [node name="Text" type="TextEdit" parent="."] visible = false -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 -rect_min_size = Vector2( 500, 200 ) +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 +custom_minimum_size = Vector2( 500, 200 ) text = "Text preview" readonly = true highlight_current_line = true @@ -29,23 +29,23 @@ caret_block_mode = true [node name="UI" type="Control" parent="."] visible = false -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 [node name="NoPreview" type="Label" parent="."] visible = false -margin_left = 7.0 -margin_top = 353.0 -margin_right = 1273.0 -margin_bottom = 367.0 +offset_left = 7.0 +offset_top = 353.0 +offset_right = 1273.0 +offset_bottom = 367.0 text = "No preview available" align = 1 valign = 1 [node name="Image" type="TextureRect" parent="."] -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 diff --git a/Radio/Stations/RadioPlayer.gd b/Radio/Stations/RadioPlayer.gd index ef3cc26..934d820 100644 --- a/Radio/Stations/RadioPlayer.gd +++ b/Radio/Stations/RadioPlayer.gd @@ -6,11 +6,11 @@ var current_music var music_list = [] var rng = RandomNumberGenerator.new() -func _init(): +func _init(): self.load_music_files() func _ready(): - self.connect("finished", self, "play_music") + self.connect("finished",Callable(self,"play_music")) func play_music(): if len(self.music_list) != 0: @@ -19,7 +19,7 @@ func play_music(): file.open(Core.game_dir + path_to_radio % self.current_music, File.READ) var audiostream = AudioStreamMP3.new() - audiostream.set_data(file.get_buffer(file.get_len())) + audiostream.set_data(file.get_buffer(file.get_length())) self.set_stream(audiostream) self.play() @@ -30,7 +30,7 @@ func load_music_files(): if err != OK: print('Error opening radio directory: %s' % err) return - dir.list_dir_begin() + dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 while true: var file = dir.get_next() if file == "": diff --git a/Region.gd b/Region.gd index f767911..b3ae47e 100644 --- a/Region.gd +++ b/Region.gd @@ -69,7 +69,7 @@ func _ready(): if err != OK: Logger.error('Error opening region directory \'%s\': %s' % [region_dir_full_path, err]) return - dir.list_dir_begin() + dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 while true: var file = dir.get_next() if file == "": @@ -80,7 +80,7 @@ func _ready(): self.read_config_bmp() var anchor = [] for f in files: - var city = load("res://RegionUI/RegionCityView.tscn").instance() + var city = load("res://RegionUI/RegionCityView.tscn").instantiate() city.init(Core.get_gamedata_path('Regions/%s/%s' % [REGION_NAME, f])) var x : int = city.city_info.location[0] var y : int = city.city_info.location[1] @@ -89,7 +89,7 @@ func _ready(): self.total_population += city.city_info.population_residential var vert_comp = (x+width) + (y+height) - width anchor.append([vert_comp, city, width]) - anchor.sort_custom(self, "anchror_sort") + anchor.sort_custom(Callable(self,"anchror_sort")) for anch in anchor: var city = anch[1] @@ -107,7 +107,7 @@ func _ready(): func read_config_bmp(): var region_config_file = File.new() region_config_file.open(Core.get_gamedata_path("Regions/%s/config.bmp" % REGION_NAME), File.READ) - var data = region_config_file.get_buffer(region_config_file.get_len()) + var data = region_config_file.get_buffer(region_config_file.get_length()) var region_config = Image.new() region_config.load_bmp_from_buffer(data) @@ -115,7 +115,7 @@ func read_config_bmp(): $BaseGrid.init_cities_array(region_config.get_width(), region_config.get_height()) region_w = region_config.get_width() region_h = region_config.get_height() - region_config.lock() + false # region_config.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed for i in range(region_config.get_width()): for j in range(region_config.get_height()): # Get the pixel at i,j diff --git a/Region.tscn b/Region.tscn index d6bf920..7d7f60f 100644 --- a/Region.tscn +++ b/Region.tscn @@ -21,16 +21,16 @@ cell_tile_origin = 2 format = 1 script = ExtResource( 3 ) -[node name="CameraAnchor" type="KinematicBody2D" parent="."] +[node name="CameraAnchor" type="CharacterBody2D" parent="."] script = ExtResource( 4 ) [node name="MainCamera" type="Camera2D" parent="CameraAnchor"] anchor_mode = 0 current = true -drag_margin_left = 0.8 -drag_margin_top = 0.8 -drag_margin_right = 0.8 -drag_margin_bottom = 0.8 +drag_left_margin = 0.8 +drag_top_margin = 0.8 +drag_right_margin = 0.8 +drag_bottom_margin = 0.8 [node name="RadioPlayer" type="AudioStreamPlayer" parent="."] script = ExtResource( 5 ) @@ -41,8 +41,8 @@ script = ExtResource( 5 ) motion_mirroring = Vector2( 128, 128 ) [node name="Grid" type="TextureRect" parent="ParallaxBackground/ParallaxLayer"] -margin_right = 5433.0 -margin_bottom = 3155.0 +offset_right = 5433.0 +offset_bottom = 3155.0 mouse_filter = 2 stretch_mode = 2 diff --git a/RegionGrid.gd b/RegionGrid.gd index 93a5653..8cb0f29 100644 --- a/RegionGrid.gd +++ b/RegionGrid.gd @@ -16,7 +16,7 @@ func init_cities_array(width_, height_): func _unhandled_input(event): if event is InputEventMouseButton and event.doubleclick: # Get the grid position - var grid_position : Vector2 = world_to_map(get_global_mouse_position()) + var grid_position : Vector2 = local_to_map(get_global_mouse_position()) if grid_position.x >= 0 and grid_position.x < width and grid_position.y >= 1 and grid_position.y < height: cities[grid_position.x][grid_position.y].open_city() diff --git a/RegionUI/AudioSettingsButton.gd b/RegionUI/AudioSettingsButton.gd index 7afb5bc..c96d165 100644 --- a/RegionUI/AudioSettingsButton.gd +++ b/RegionUI/AudioSettingsButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "AudioSettingsButton" diff --git a/RegionUI/BrowseRegionsButton.gd b/RegionUI/BrowseRegionsButton.gd index a2ece64..8fb4ad3 100644 --- a/RegionUI/BrowseRegionsButton.gd +++ b/RegionUI/BrowseRegionsButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "BrowseRegionsButton" \ No newline at end of file diff --git a/RegionUI/BrowseScreenshotsButton.gd b/RegionUI/BrowseScreenshotsButton.gd index f3451fb..627bb7c 100644 --- a/RegionUI/BrowseScreenshotsButton.gd +++ b/RegionUI/BrowseScreenshotsButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "BrowseScreenshotsButton" diff --git a/RegionUI/Compass.gd b/RegionUI/Compass.gd index 8232761..e8dd8a6 100644 --- a/RegionUI/Compass.gd +++ b/RegionUI/Compass.gd @@ -1,5 +1,5 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_TOP_LEFT, true) self.name="Compass" \ No newline at end of file diff --git a/RegionUI/DeleteRegionButton.gd b/RegionUI/DeleteRegionButton.gd index a14e87e..39833dd 100644 --- a/RegionUI/DeleteRegionButton.gd +++ b/RegionUI/DeleteRegionButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "DeleteRegionButton" \ No newline at end of file diff --git a/RegionUI/DisplaySettingsButton.gd b/RegionUI/DisplaySettingsButton.gd index 13ea945..ff8d244 100644 --- a/RegionUI/DisplaySettingsButton.gd +++ b/RegionUI/DisplaySettingsButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "DisplaySettingsButton" diff --git a/RegionUI/ExitGameButton.gd b/RegionUI/ExitGameButton.gd index 8c12999..8898ba9 100644 --- a/RegionUI/ExitGameButton.gd +++ b/RegionUI/ExitGameButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "ExitGameButton" diff --git a/RegionUI/GameSettingsButton.gd b/RegionUI/GameSettingsButton.gd index 46006f5..023506a 100644 --- a/RegionUI/GameSettingsButton.gd +++ b/RegionUI/GameSettingsButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "GameSettingsButton" diff --git a/RegionUI/InternetButton.gd b/RegionUI/InternetButton.gd index 46c7cdf..1fd2a34 100644 --- a/RegionUI/InternetButton.gd +++ b/RegionUI/InternetButton.gd @@ -1,8 +1,8 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "InternetButton" - self.connect("clicked", self, "_on_clicked") + self.connect("clicked",Callable(self,"_on_clicked")) func _on_clicked(): OS.shell_open("https://github.com/OpenSC4-org/OpenSC4") diff --git a/RegionUI/NameAndPopulation.gd b/RegionUI/NameAndPopulation.gd index 34af7a0..d7a93c4 100644 --- a/RegionUI/NameAndPopulation.gd +++ b/RegionUI/NameAndPopulation.gd @@ -1,5 +1,5 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_BOTTOM_LEFT, true) self.name="NameAndPopulation" \ No newline at end of file diff --git a/RegionUI/NewRegionButton.gd b/RegionUI/NewRegionButton.gd index 748c285..490ce61 100644 --- a/RegionUI/NewRegionButton.gd +++ b/RegionUI/NewRegionButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "NewRegionButton" diff --git a/RegionUI/PopulationIndicator.gd b/RegionUI/PopulationIndicator.gd index f1e9f21..1825d37 100644 --- a/RegionUI/PopulationIndicator.gd +++ b/RegionUI/PopulationIndicator.gd @@ -8,7 +8,7 @@ func format_thousands(val): val /= 1000 return res -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "RegionNameDisplay" func _ready(): diff --git a/RegionUI/RegionCityView.gd b/RegionUI/RegionCityView.gd index e28ca5a..0833d55 100644 --- a/RegionUI/RegionCityView.gd +++ b/RegionUI/RegionCityView.gd @@ -32,14 +32,14 @@ func display(): # TODO city edges override other cities causing glitches, can be else: $InfoContainer/CityName.text = self.city_name # Print city size - var pos_on_grid = get_parent().map_to_world(Vector2(city_info.location[0], city_info.location[1])) - #var thumbnail_texture : Texture = region_view_thumbnails[0] + var pos_on_grid = get_parent().map_to_local(Vector2(city_info.location[0], city_info.location[1])) + #var thumbnail_texture : Texture2D = region_view_thumbnails[0] # The height of a tile if it were completely flat #print(region_view_thumbnails[0].get_data().data["height"], region_view_thumbnails[0].get_data().data["width"], "\t", region_view_thumbnails[1].get_data().data["height"], region_view_thumbnails[1].get_data().data["width"]) var mystery_img = region_view_thumbnails[1].get_data() var region_img = region_view_thumbnails[0].get_data() - mystery_img.lock() - region_img.lock() + false # mystery_img.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed + false # region_img.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed var min_h = mystery_img.data["height"] var min_w = mystery_img.data["width"] for w in range(mystery_img.data["width"]): @@ -58,7 +58,7 @@ func display(): # TODO city edges override other cities causing glitches, can be #var trim = Rect2(Vector2(float(min_w), float(min_h)), Vector2(mystery_img.data["width"], mystery_img.data["height"])) #var trimmed = region_img.get_rect(trim) var thumbnail_texture = ImageTexture.new() - thumbnail_texture.create_from_image(region_img, 0) + thumbnail_texture.create_from_image(region_img) #,0 var expected_height = 63.604 * city_info.size[1] # Adjust the tile placement var extra_height = thumbnail_texture.get_height() - expected_height @@ -66,7 +66,7 @@ func display(): # TODO city edges override other cities causing glitches, can be pos_on_grid.x -= 37.305 * city_info.size[1] self.translate(pos_on_grid) $Thumbnail.texture = thumbnail_texture - $CollisionShape.shape.extents = Vector2(thumbnail_texture.get_width() / 2, thumbnail_texture.get_height() / 2) + $CollisionShape3D.shape.size = Vector2(thumbnail_texture.get_width() / 2, thumbnail_texture.get_height() / 2) $InfoContainer/CityName.set_position(Vector2(thumbnail_texture.get_width() / 2, expected_height / 2)) func get_total_pop(): @@ -77,6 +77,6 @@ func save_thumbnail(): func open_city(): Boot.current_city = savefile - var err = get_tree().change_scene("res://CityView/CityScene/City.tscn") + var err = get_tree().change_scene_to_file("res://CityView/CityScene/City.tscn") if err != OK: print("Error trying to change the scene to the city") diff --git a/RegionUI/RegionCityView.tscn b/RegionUI/RegionCityView.tscn index 98d8cf1..7a908b2 100644 --- a/RegionUI/RegionCityView.tscn +++ b/RegionUI/RegionCityView.tscn @@ -20,25 +20,25 @@ shader = SubResource( 2 ) [node name="RegionCityView" type="Area2D"] script = ExtResource( 1 ) -[node name="CollisionShape" type="CollisionShape2D" parent="."] +[node name="CollisionShape3D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) -[node name="Thumbnail" type="Sprite" parent="."] +[node name="Thumbnail" type="Sprite2D" parent="."] material = SubResource( 3 ) centered = false [node name="InfoContainer" type="CenterContainer" parent="."] anchor_right = 1.0 -margin_right = 40.0 -margin_bottom = 40.0 +offset_right = 40.0 +offset_bottom = 40.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="CityName" type="Label" parent="InfoContainer"] -margin_left = 6.0 -margin_top = 4.0 -margin_right = 33.0 -margin_bottom = 35.0 +offset_left = 6.0 +offset_top = 4.0 +offset_right = 33.0 +offset_bottom = 35.0 size_flags_horizontal = 6 size_flags_vertical = 6 text = "CITY diff --git a/RegionUI/RegionManagementButton.gd b/RegionUI/RegionManagementButton.gd index 2c9d237..ca95732 100644 --- a/RegionUI/RegionManagementButton.gd +++ b/RegionUI/RegionManagementButton.gd @@ -1,9 +1,9 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "RegionManagementButton" - self.connect("toggled_on", self, "_on_toggled_on") - self.connect("toggled_off", self, "_on_toggled_off") + self.connect("toggled_on",Callable(self,"_on_toggled_on")) + self.connect("toggled_off",Callable(self,"_on_toggled_off")) #TODO: Use notifications instead of signals for greater flexibility? diff --git a/RegionUI/RegionNameDisplay.gd b/RegionUI/RegionNameDisplay.gd index 8a8f3fd..a5006e3 100644 --- a/RegionUI/RegionNameDisplay.gd +++ b/RegionUI/RegionNameDisplay.gd @@ -1,6 +1,6 @@ extends GZWinText -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "RegionNameDisplay" func _ready(): diff --git a/RegionUI/RegionSubmenu.gd b/RegionUI/RegionSubmenu.gd index 6f94871..1c5d75d 100644 --- a/RegionUI/RegionSubmenu.gd +++ b/RegionUI/RegionSubmenu.gd @@ -1,6 +1,6 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_CENTER_TOP, true) self.name="RegionSubmenu" self.visible = false \ No newline at end of file diff --git a/RegionUI/SatelliteViewRadioButton.gd b/RegionUI/SatelliteViewRadioButton.gd index 586a8f3..1f08780 100644 --- a/RegionUI/SatelliteViewRadioButton.gd +++ b/RegionUI/SatelliteViewRadioButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "SatelliteViewRadioButton" \ No newline at end of file diff --git a/RegionUI/SaveScreenshotButton.gd b/RegionUI/SaveScreenshotButton.gd index 8418ae6..1067bea 100644 --- a/RegionUI/SaveScreenshotButton.gd +++ b/RegionUI/SaveScreenshotButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "SaveScreenshotButton" \ No newline at end of file diff --git a/RegionUI/ShowBordersCheckbox.gd b/RegionUI/ShowBordersCheckbox.gd index 7c4ef42..78fa1fd 100644 --- a/RegionUI/ShowBordersCheckbox.gd +++ b/RegionUI/ShowBordersCheckbox.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "ShowBordersCheckbox" \ No newline at end of file diff --git a/RegionUI/ShowNamesCheckbox.gd b/RegionUI/ShowNamesCheckbox.gd index f3e1073..89ebdd0 100644 --- a/RegionUI/ShowNamesCheckbox.gd +++ b/RegionUI/ShowNamesCheckbox.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes).(attributes): +func _init(attributes,attributes): self.name = "ShowNamesCheckbox" diff --git a/RegionUI/TopBarButtons.gd b/RegionUI/TopBarButtons.gd index 94e3c7c..f12d63d 100644 --- a/RegionUI/TopBarButtons.gd +++ b/RegionUI/TopBarButtons.gd @@ -1,5 +1,5 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_CENTER_TOP, true) self.name="TopBarButtons" \ No newline at end of file diff --git a/RegionUI/TopBarDecoration.gd b/RegionUI/TopBarDecoration.gd index 425057a..94cf9df 100644 --- a/RegionUI/TopBarDecoration.gd +++ b/RegionUI/TopBarDecoration.gd @@ -1,5 +1,5 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_CENTER_TOP, true) self.name = "TopBarDecoration" diff --git a/RegionUI/TopBarSettingsButton.gd b/RegionUI/TopBarSettingsButton.gd index 09ba65c..9385c4e 100644 --- a/RegionUI/TopBarSettingsButton.gd +++ b/RegionUI/TopBarSettingsButton.gd @@ -1,9 +1,9 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name="TopBarSettingsButton" - self.connect("toggled_on", self, "_on_toggled_on") - self.connect("toggled_off", self, "_on_toggled_off") + self.connect("toggled_on",Callable(self,"_on_toggled_on")) + self.connect("toggled_off",Callable(self,"_on_toggled_off")) func _on_toggled_on(): $"../../TopBarSettingsMenu".set_visible(true) diff --git a/RegionUI/TopBarSettingsButtonContainer.gd b/RegionUI/TopBarSettingsButtonContainer.gd index 9846ae7..3376cd6 100644 --- a/RegionUI/TopBarSettingsButtonContainer.gd +++ b/RegionUI/TopBarSettingsButtonContainer.gd @@ -1,5 +1,5 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_TOP_RIGHT, true) self.name = "TopBarSettingsButtonContainer" \ No newline at end of file diff --git a/RegionUI/TopBarSettingsMenu.gd b/RegionUI/TopBarSettingsMenu.gd index 3211b4a..3e24c92 100644 --- a/RegionUI/TopBarSettingsMenu.gd +++ b/RegionUI/TopBarSettingsMenu.gd @@ -1,6 +1,6 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.set_anchors_preset(PRESET_TOP_RIGHT, true) self.name="TopBarSettingsMenu" self.visible = false \ No newline at end of file diff --git a/RegionUI/TransportationViewRadioButton.gd b/RegionUI/TransportationViewRadioButton.gd index 802602f..28eb65f 100644 --- a/RegionUI/TransportationViewRadioButton.gd +++ b/RegionUI/TransportationViewRadioButton.gd @@ -1,4 +1,4 @@ extends GZWinBtn -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): self.name = "TransportationViewRadioButton" \ No newline at end of file diff --git a/RegionUI/ViewOptionsContainer.gd b/RegionUI/ViewOptionsContainer.gd index 25af77a..444d1d6 100644 --- a/RegionUI/ViewOptionsContainer.gd +++ b/RegionUI/ViewOptionsContainer.gd @@ -1,4 +1,4 @@ extends GZWinGen -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes): pass diff --git a/RegionViewCityThumbnail.gd b/RegionViewCityThumbnail.gd index af48233..2b918f2 100644 --- a/RegionViewCityThumbnail.gd +++ b/RegionViewCityThumbnail.gd @@ -1,11 +1,11 @@ -extends Sprite +extends Sprite2D class_name RegionViewCityThumbnail func _unhandled_input(event): - if event is InputEventMouseButton and not event.is_echo() and event.button_index == BUTTON_LEFT: + if event is InputEventMouseButton and not event.is_echo() and event.button_index == MOUSE_BUTTON_LEFT: var local_pos = to_local(event.global_position) if get_rect().has_point(local_pos): print('Click at %d %d' % [local_pos.x, local_pos.y]) print('Rect: %d %d %d %d' % [get_rect().position.x, get_rect().position.y, get_rect().size.x, get_rect().size.y]) - get_tree().set_input_as_handled() + get_viewport().set_input_as_handled() diff --git a/SC4City__WriteRegionViewThumbnail.gd b/SC4City__WriteRegionViewThumbnail.gd index 0014b28..c8c5b6e 100644 --- a/SC4City__WriteRegionViewThumbnail.gd +++ b/SC4City__WriteRegionViewThumbnail.gd @@ -1,4 +1,4 @@ extends "res://addons/dbpf/SpriteSubfile.gd" -func _init(index).(index): +func _init(index): pass diff --git a/SC4ReadRegionalCity.gd b/SC4ReadRegionalCity.gd index 94e1d0a..ba170c9 100644 --- a/SC4ReadRegionalCity.gd +++ b/SC4ReadRegionalCity.gd @@ -14,11 +14,11 @@ var tutorial_flag : bool = false var guid : int = 0 var mode : String = "god" -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) var stream = StreamPeerBuffer.new() stream.data_array = raw_data self.version = [stream.get_16(), stream.get_16()]; diff --git a/SC4UISubfile.gd b/SC4UISubfile.gd index d00b635..b319b5b 100644 --- a/SC4UISubfile.gd +++ b/SC4UISubfile.gd @@ -26,7 +26,7 @@ var vec2Regex : RegEx = RegEx.new() var elementsByID : Dictionary = {} var lines : Array = [] -func _init(index).(index): +func _init(index): rectRegex.compile("\\((?-?\\d+),(?-?\\d+),(?-?\\d+),(?-?\\d+)\\)") colorRegex.compile("\\((?\\d+),(?\\d+),(?\\d+)\\)") imgGIRegex.compile("\\{(?[0-9a-fA-F]{8}),(?[0-9a-fA-F]{8})\\}") @@ -61,7 +61,7 @@ func create_last_element(parts : Array, custom_classes : Dictionary) -> Control: func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) lines = stream.get_string(stream.get_available_bytes()).split("\n") func add_to_tree(parent : Node, custom_classes : Dictionary): diff --git a/SubfilePreview.tscn b/SubfilePreview.tscn index f8eed77..e52ee8a 100644 --- a/SubfilePreview.tscn +++ b/SubfilePreview.tscn @@ -9,11 +9,11 @@ script = ExtResource( 2 ) [node name="Text" type="TextEdit" parent="."] visible = false -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 -rect_min_size = Vector2( 500, 200 ) +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 +custom_minimum_size = Vector2( 500, 200 ) text = "Text preview" readonly = true highlight_current_line = true @@ -29,23 +29,23 @@ caret_block_mode = true [node name="UI" type="Control" parent="."] visible = false -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 [node name="NoPreview" type="Label" parent="."] visible = false -margin_left = 7.0 -margin_top = 353.0 -margin_right = 1273.0 -margin_bottom = 367.0 +offset_left = 7.0 +offset_top = 353.0 +offset_right = 1273.0 +offset_bottom = 367.0 text = "No preview available" align = 1 valign = 1 [node name="Image" type="TextureRect" parent="."] -margin_left = 7.0 -margin_top = 7.0 -margin_right = 1273.0 -margin_bottom = 713.0 +offset_left = 7.0 +offset_top = 7.0 +offset_right = 1273.0 +offset_bottom = 713.0 diff --git a/Terrain.gd b/Terrain.gd index 3a24e69..1398b6b 100644 --- a/Terrain.gd +++ b/Terrain.gd @@ -1,8 +1,8 @@ -extends MeshInstance +extends MeshInstance3D var tmpMesh = ArrayMesh.new(); -var vertices = PoolVector3Array() -var UVs = PoolVector2Array() +var vertices = PackedVector3Array() +var UVs = PackedVector2Array() var color = Color(0.9, 0.1, 0.1) var mat = self.get_material_override() var st = SurfaceTool.new() @@ -124,12 +124,12 @@ func load_textures_to_uv_dict(): tot_w = len(textures) * width tot_h = 5 * height var uv_mipmap_offset = height / tot_h - var arr_data = [PoolByteArray([])] + var arr_data = [PackedByteArray([])] while len(arr_data) < tot_h: arr_data.append_array(arr_data) arr_data = arr_data.slice(0, tot_h) var format_decomp - var textarr = TextureArray.new() + var textarr = Texture2DArray.new() textarr.create (width, height, len(textures) * 5, formats[0], 2) var layer = 0 var ind_to_layer = {} @@ -153,15 +153,15 @@ func load_textures_to_uv_dict(): print("failed to load layer", layer, "with image", im_ind) layer += 1 - self.mat.set_shader_param("cliff_ind", float(cliff_index)) - self.mat.set_shader_param("beach_ind", float(beach_index)) - self.mat.set_shader_param("terrain", textarr) + self.mat.set_shader_parameter("cliff_ind", float(cliff_index)) + self.mat.set_shader_parameter("beach_ind", float(beach_index)) + self.mat.set_shader_parameter("terrain", textarr) self.set_material_override(self.mat) var mat_e = self.get_parent().get_node("Border").get_material_override() - mat_e.set_shader_param("terrain", textarr) - mat_e.set_shader_param("top_ind", float(top_edge)) - mat_e.set_shader_param("mid_ind", float(mid_edge)) - mat_e.set_shader_param("bot_ind", float(bot_edge)) + mat_e.set_shader_parameter("terrain", textarr) + mat_e.set_shader_parameter("top_ind", float(top_edge)) + mat_e.set_shader_parameter("mid_ind", float(mid_edge)) + mat_e.set_shader_parameter("bot_ind", float(bot_edge)) return ind_to_layer diff --git a/addons/dbpf/CURSubfile.gd b/addons/dbpf/CURSubfile.gd index 34b9f0b..5b24115 100644 --- a/addons/dbpf/CURSubfile.gd +++ b/addons/dbpf/CURSubfile.gd @@ -5,20 +5,20 @@ class_name CURSubfile var n_images var entries = [] -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) var ind = 0 - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") # 4 bytes (char) - signature - var signature = self.get_int_from_bytes(raw_data.subarray(ind+2, ind+3)) - assert(signature == 2, "DBPFSubfile.load: not a CUR file") + var signature = self.get_int_from_bytes(raw_data.slice(ind+2, ind+3)) + assert(signature == 2) #,"DBPFSubfile.load: not a CUR file") ind += 4 # 4 bytes (unint32) - total file size - self.n_images = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + self.n_images = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 for n in range(n_images): var entry = CUR_Entry.new() @@ -26,14 +26,14 @@ func load(file, dbdf=null): ind += 1 entry.height = raw_data[ind] ind +=3 - entry.x_hotspot = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.x_hotspot = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 - entry.y_hotspot = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.y_hotspot = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) entry.vec_hotspot = Vector2(entry.x_hotspot, entry.y_hotspot) ind += 2 - entry.size = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + entry.size = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - entry.offset = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + entry.offset = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 entries.append(entry) for entry in entries: @@ -43,36 +43,36 @@ func load(file, dbdf=null): raw_data[ind+2] == 0x4E and raw_data[ind+3] == 0x47): entry.img = Image.new() - var img_data = raw_data.subarray(ind, ind+entry.size) + var img_data = raw_data.slice(ind, ind+entry.size) entry.img.load_png_from_buffer(img_data) - elif self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) == 40: + elif self.get_int_from_bytes(raw_data.slice(ind, ind+3)) == 40: ind += 4 - var bmp_width = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var bmp_width = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var bmp_height = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var bmp_height = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 6 - var bpp = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var bpp = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 - #var comp_meth = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + #var comp_meth = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var img_size = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var img_size = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 12 - #var n_colors = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + #var n_colors = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 8 var bmp_size = (bpp/8) * bmp_width * bmp_height var bmp_header = [0x42, 0x4d, (int(bmp_size)+54), (int(bmp_size)+54)>>8, (int(bmp_size)+54)>>16, (int(bmp_size)+54)>>24, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00] - var bmp_data = PoolByteArray(bmp_header) - bmp_data.append_array(raw_data.subarray(ind-40, ind-1)) - bmp_data.append_array(raw_data.subarray(ind, ind+bmp_size-1)) + var bmp_data = PackedByteArray(bmp_header) + bmp_data.append_array(raw_data.slice(ind-40, ind-1)) + bmp_data.append_array(raw_data.slice(ind, ind+bmp_size-1)) #bmp_data[22] = bmp_data[18] var temp_img = Image.new() temp_img.load_bmp_from_buffer(bmp_data) temp_img.decompress() temp_img = temp_img.get_rect(Rect2(Vector2(0.0, 0.0), Vector2(bmp_width, bmp_width))) - var mask_data = raw_data.subarray(ind+bmp_size, raw_data.size()-1) + var mask_data = raw_data.slice(ind+bmp_size, raw_data.size()-1) for i in range(bmp_width): for j in range(0, bmp_width, 8): var k = (j / 8) + (i * 4) @@ -100,5 +100,5 @@ func get_int_from_bytes(bytearr): func get_as_texture(entry_no = 0): assert(entries[entry_no].img != null) var ret = ImageTexture.new() - ret.create_from_image(entries[entry_no].img, 0) + ret.create_from_image(entries[entry_no].img) #,0 return ret diff --git a/addons/dbpf/DBDF.gd b/addons/dbpf/DBDF.gd index 1000a79..b118933 100644 --- a/addons/dbpf/DBDF.gd +++ b/addons/dbpf/DBDF.gd @@ -1,4 +1,4 @@ -extends Reference +extends RefCounted # See details: https://wiki.sc4devotion.com/index.php?title=DBDF diff --git a/addons/dbpf/DBPF.gd b/addons/dbpf/DBPF.gd index ff8789b..1abae2a 100644 --- a/addons/dbpf/DBPF.gd +++ b/addons/dbpf/DBPF.gd @@ -26,33 +26,35 @@ var indices : Dictionary var indices_by_type : Dictionary var indices_by_type_and_group : Dictionary var all_types : Dictionary -var file : File +var file : FileAccess var path : String var print_load_times : bool = false -export (Dictionary) var ui_region_textures: Dictionary = {} +@export var ui_region_textures: Dictionary = {} func _init(filepath : String): self.path = filepath - var total_time_start = OS.get_system_time_msecs() + var total_time_start = Time.get_unix_time_from_system() # Open the file - self.file = File.new() - var err = file.open(filepath, File.READ) + self.file = FileAccess.open(filepath, FileAccess.READ) + var err = file.get_error() if err != OK: - return err + push_error(err) + return # Read the file # Check that the first four bytes are DBPF var dbpf = self.file.get_buffer(4).get_string_from_ascii(); if (dbpf != "DBPF"): - return ERR_INVALID_DATA + push_error(ERR_INVALID_DATA) + return # Get the version var _version_major = self.file.get_32() var _version_minor = self.file.get_32() # useless bytes for _i in range(3): file.get_32() - var _date_created = OS.get_datetime_from_unix_time(self.file.get_32()) - var _date_modified = OS.get_datetime_from_unix_time(self.file.get_32()) + var _date_created = Time.get_datetime_dict_from_unix_time(self.file.get_32()) + var _date_modified = Time.get_datetime_dict_from_unix_time(self.file.get_32()) var _index_major_version = self.file.get_32() var index_entry_count = self.file.get_32() var index_first_offset = self.file.get_32() @@ -66,7 +68,7 @@ func _init(filepath : String): self.file.seek(index_first_offset) var index_buffer = StreamPeerBuffer.new() index_buffer.data_array = self.file.get_buffer(index_entry_count * 20) - var time_start = OS.get_system_time_msecs() + var time_start = Time.get_unix_time_from_system() for _i in range(index_entry_count): var index = SubfileIndex.new(self, index_buffer) self.indices[SubfileTGI.TGI2str(index.type_id, index.group_id, index.instance_id)] = index @@ -81,7 +83,7 @@ func _init(filepath : String): # indices_by_type_and_group[SubfileTGI.TG2int(index.type_id, index.group_id)] = [index] #else: # indices_by_type_and_group[SubfileTGI.TG2int(index.type_id, index.group_id)].append(index) - var time_now = OS.get_system_time_msecs() + var time_now = Time.get_unix_time_from_system() if self.print_load_times: print("Took ", time_now - time_start, "ms to read ", index_entry_count, " indices from ", filepath) @@ -91,7 +93,7 @@ func _init(filepath : String): dbdf.load(file, index.location, index.size) for compressed_file in dbdf.entries: compressed_files[SubfileTGI.TGI2str(compressed_file.type_id, compressed_file.group_id, compressed_file.instance_id)] = compressed_file - var total_time_now = OS.get_system_time_msecs() + var total_time_now = Time.get_unix_time_from_system() if self.print_load_times: print("Took ", total_time_now - total_time_start, "ms to load ", filepath) @@ -118,10 +120,10 @@ func dbg_show_all_subfiles(): func DEBUG_show_all_subfiles_to_file(filename): print("=== %s" % self.path) print("=== ALL SUBFILES ===") - var file = File.new() var name = "user://%s.txt" % [filename.split('/')[1]] print(name) - var err = file.open(name, file.WRITE) + var file = FileAccess.open(name, FileAccess.WRITE) + var err = file.get_error() print("error", err) file.seek(0) for index in indices.values(): @@ -139,8 +141,10 @@ func all_subfiles_by_group(group_id : int): print("====================") func get_subfile(type_id : int, group_id : int, instance_id : int, subfile_class) -> DBPFSubfile: - assert(SubfileTGI.TGI2str(type_id, group_id, instance_id) in self.indices, - "Subfile not found (%08x %08x %08x)" % [type_id, group_id, instance_id]) + assert( + SubfileTGI.TGI2str(type_id, group_id, instance_id) in self.indices, + "Subfile not found (%08x %08x %08x)" % [type_id, group_id, instance_id] + ) if subfiles.has([type_id, group_id, instance_id]) and subfiles[[type_id, group_id, instance_id]] != null: return subfiles[[type_id, group_id, instance_id]] diff --git a/addons/dbpf/DBPFPlugin.gd b/addons/dbpf/DBPFPlugin.gd index 4d9e176..8302716 100644 --- a/addons/dbpf/DBPFPlugin.gd +++ b/addons/dbpf/DBPFPlugin.gd @@ -1,4 +1,4 @@ -tool +@tool extends EditorPlugin class_name DBPFPlugin diff --git a/addons/dbpf/DBPFSubfile.gd b/addons/dbpf/DBPFSubfile.gd index 612b7f7..935ef53 100644 --- a/addons/dbpf/DBPFSubfile.gd +++ b/addons/dbpf/DBPFSubfile.gd @@ -1,14 +1,14 @@ -extends Reference +extends RefCounted class_name DBPFSubfile var index:SubfileIndex -var raw_data:PoolByteArray +var raw_data:PackedByteArray var stream:StreamPeerBuffer func _init(idx:SubfileIndex): self.index = idx -func load(file:File, dbdf:DBDFEntry=null): +func load(file:FileAccess, dbdf:DBDFEntry=null): file.seek(index.location) if dbdf != null: raw_data = decompress(file, index.size - 9, dbdf) @@ -17,9 +17,9 @@ func load(file:File, dbdf:DBDFEntry=null): stream = StreamPeerBuffer.new() stream.data_array = raw_data -func decompress(file : File, length : int, dbdf : DBDFEntry) -> PoolByteArray: - var buf:PoolByteArray - var answer:PoolByteArray = PoolByteArray() +func decompress(file : FileAccess, length : int, dbdf : DBDFEntry) -> PackedByteArray: + var buf:PackedByteArray + var answer:PackedByteArray = PackedByteArray() var numplain:int var numcopy:int var offset:int diff --git a/addons/dbpf/ExemplarSubfile.gd b/addons/dbpf/ExemplarSubfile.gd index 9755ca7..b14134b 100644 --- a/addons/dbpf/ExemplarSubfile.gd +++ b/addons/dbpf/ExemplarSubfile.gd @@ -8,44 +8,44 @@ var properties = {} var ind var keys_dict = {} -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) ind = 0 - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") # 4 bytes (char) - signature - var signature = raw_data.subarray(ind, ind+3).get_string_from_ascii() - assert(signature == "EQZB", "DBPFSubfile.load: not an Exemplar file") + var signature = raw_data.slice(ind, ind+3).get_string_from_ascii() + assert(signature == "EQZB") #,"DBPFSubfile.load: not an Exemplar file") ind += 4 # 4 bytes - parent cohort indicator always 0x23232331 ind += 4 - self.parent_cohort["T"] = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.parent_cohort["T"] = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - self.parent_cohort["G"] = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.parent_cohort["G"] = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - self.parent_cohort["I"] = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.parent_cohort["I"] = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - self.num_properties = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.num_properties = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 for _property in range(self.num_properties): - var key = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var key = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 # 1 Byte spacing always 0x00 ind += 1 - var type = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var type = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 var multi :bool = (type & 0xF000) > 0 var format :int = type & 0xF var value var length = 1 if multi: - length = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + length = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 if format == 0xC: #string - value = raw_data.subarray(ind, ind+(length-1)).get_string_from_ascii() + value = raw_data.slice(ind, ind+(length-1)).get_string_from_ascii() ind += length else: value = [] @@ -77,15 +77,15 @@ func val_from_format(format): ind += 1 return val elif format == 0x2: #Uint16 not used? - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 return val elif format == 0x3: #Uint32 - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 return val elif format == 0x4: #Uint64? not used? - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+7)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+7)) ind += 8 return val elif format == 0x5: #int8? not used? @@ -93,23 +93,23 @@ func val_from_format(format): ind += 1 return val elif format == 0x6: #int16? not used? - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 return val elif format == 0x7: #int32? not used? - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 return val elif format == 0x8: #int64? not used? - var val = self.get_int_from_bytes(raw_data.subarray(ind, ind+7)) + var val = self.get_int_from_bytes(raw_data.slice(ind, ind+7)) ind += 8 return val elif format == 0x9: #float32 - var val = self.get_float_from_bytes(raw_data.subarray(ind, ind+3)) + var val = self.get_float_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 return val elif format == 0xA: #float64? - var val = self.get_float_from_bytes(raw_data.subarray(ind, ind+7)) + var val = self.get_float_from_bytes(raw_data.slice(ind, ind+7)) ind += 8 return val elif format == 0xB: #bool @@ -121,9 +121,8 @@ func val_from_format(format): func key_description(key): if len(self.keys_dict) == 0: - var file = File.new() - file.open("res://exemplar_types.dict", File.READ) - self.keys_dict = str2var(file.get_as_text()) + var file = FileAccess.open("res://exemplar_types.dict", FileAccess.READ) + self.keys_dict = str_to_var(file.get_as_text()) file.close() var ret = null if self.keys_dict.keys().has(key): diff --git a/addons/dbpf/FSHSubfile.gd b/addons/dbpf/FSHSubfile.gd index cf41cc6..b876c8f 100644 --- a/addons/dbpf/FSHSubfile.gd +++ b/addons/dbpf/FSHSubfile.gd @@ -9,41 +9,41 @@ var size var mipmaps var file_size -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) var ind = 0 - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") # 4 bytes (char) - signature - var signature = raw_data.subarray(ind, ind+3).get_string_from_ascii() - assert(signature == "SHPI", "DBPFSubfile.load: not an FSH file") + var signature = raw_data.slice(ind, ind+3).get_string_from_ascii() + assert(signature == "SHPI") #,"DBPFSubfile.load: not an FSH file") ind += 4 # 4 bytes (unint32) - total file size - self.file_size = self._get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.file_size = self._get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 # 4 bytes (uint32) - number of entries - var num_entr : int = self._get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var num_entr : int = self._get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 # 4 bytes (char) - directory ID - var dir_id = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var dir_id = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 # Directory - var dir_bytes = raw_data.subarray(ind, ind+7) + var dir_bytes = raw_data.slice(ind, ind+7) var directory = [] while len(directory) < num_entr: # 4 bytes (char) - entry tag // e.g. "br02" - var tag = dir_bytes.subarray(0, 3).get_string_from_ascii() + var tag = dir_bytes.slice(0, 3).get_string_from_ascii() ind += 4 # 4 bytes (uint32) - entry offset - var offset : int = self._get_int_from_bytes(dir_bytes.subarray(4, 7)) + var offset : int = self._get_int_from_bytes(dir_bytes.slice(4, 7)) ind += 4 directory.append(FSH_Entry.new(tag, offset)) - dir_bytes = raw_data.subarray(ind, ind+7) + dir_bytes = raw_data.slice(ind, ind+7) assert (ind < file_size, "error") # optional binary attachment (padding) @@ -71,26 +71,26 @@ func load(file, dbdf=null): entry.entry_id = raw_data[ind] ind += 1 # 3 bytes (uint24) - size of the block not used - entry.block_size = self._get_int_from_bytes(raw_data.subarray(ind, ind+2)) + entry.block_size = self._get_int_from_bytes(raw_data.slice(ind, ind+2)) ind += 3 # 2 bytes (uint16) - image width - entry.width = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.width = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 # 2 bytes (uint16) - image height - entry.height = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.height = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 # 2 bytes (uint16) - X axis coordinate (Center X) - entry.x_coord = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.x_coord = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 # 2 bytes (uint16) - Y axis coordinate (Center Y) - entry.y_coord = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.y_coord = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 # 2 bytes - X axis position (Left X pos.)[uint12] + internal flag [uint1] + unknown [uint3] - entry.x_pos = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) >> 2 + entry.x_pos = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) >> 2 ind += 2 # 2 bytes - Y axis position (Top Y pos.)[uint12] + levels count (mipmaps) [uint4] - entry.y_pos = self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) >> 2 - entry.mipmaps = 3&self._get_int_from_bytes(raw_data.subarray(ind, ind+1)) + entry.y_pos = self._get_int_from_bytes(raw_data.slice(ind, ind+1)) >> 2 + entry.mipmaps = 3&self._get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 # x bytes - image data # x bytes - optional padding // up to 16 bytes, filled with nulls @@ -106,15 +106,15 @@ func load(file, dbdf=null): entry.img = Image.new() if att_id == 96: # compressed image, DXT1 4x4 packed, 1-bit alpha entry.size = ((entry.width * entry.height) / 16)*8 - var img_data = raw_data.subarray(start, start + entry.size-1) + var img_data = raw_data.slice(start, start + entry.size-1) entry.img.create_from_data(entry.width, entry.height, false, Image.FORMAT_DXT1, img_data) elif att_id == 97: # compressed image, DXT3 4x4 packed, 4-bit alpha entry.size = ((entry.width * entry.height) / 16)*16 - var img_data = raw_data.subarray(start, start + entry.size-1) + var img_data = raw_data.slice(start, start + entry.size-1) entry.img.create_from_data(entry.width, entry.height, false, Image.FORMAT_DXT3, img_data) """elif att_id == 123 or att_id == 125 or att_id == 127: # image with palette (256 colors), 24 and 32 bmp entry.img.load_bmp_from_buffer(img_data)""" - assert(entry.img != null, "img load failed") + assert(entry.img != null) #,"img load failed") self.img = entry.img self.width = entry.width self.height = entry.height @@ -132,5 +132,5 @@ func _get_int_from_bytes(bytearr): func get_as_texture(): assert(self.img != null) var ret = ImageTexture.new() - ret.create_from_image(self.img, 2) + ret.create_from_image(self.img) #,2 return ret diff --git a/addons/dbpf/FSH_Entry.gd b/addons/dbpf/FSH_Entry.gd index caec49e..a2f1405 100644 --- a/addons/dbpf/FSH_Entry.gd +++ b/addons/dbpf/FSH_Entry.gd @@ -16,6 +16,6 @@ var y_pos var mipmaps var img -func _init(tag, offset): +func _init(tag,offset): self.dir_tag = tag self.offset = offset diff --git a/addons/dbpf/GZWin.gd b/addons/dbpf/GZWin.gd index 1f7b2f2..82ff89f 100644 --- a/addons/dbpf/GZWin.gd +++ b/addons/dbpf/GZWin.gd @@ -9,4 +9,4 @@ func _init(attributes : Dictionary): self.set_position(area.position) self.set_size(area.size) if 'tipstext' in attributes: - self.hint_tooltip = attributes.get('hint_tooltip') + self.tooltip_text = attributes.get('tooltip_text') diff --git a/addons/dbpf/GZWinBMP.gd b/addons/dbpf/GZWinBMP.gd index 413307a..eef7d52 100644 --- a/addons/dbpf/GZWinBMP.gd +++ b/addons/dbpf/GZWinBMP.gd @@ -17,9 +17,9 @@ extends GZWin class_name GZWinBMP -var texture : Texture = null +var texture : Texture2D = null -func _init(attributes).(attributes): +func _init(attributes,attributes_): if not 'image' in attributes: print(attributes) else: @@ -28,9 +28,9 @@ func _init(attributes).(attributes): else: set_texture(attributes['image'].get_as_texture()) -func set_texture(texture : Texture): +func set_texture(texture : Texture2D): self.texture = texture - update() + queue_redraw() func _draw(): if self.texture != null: diff --git a/addons/dbpf/GZWinBtn.gd b/addons/dbpf/GZWinBtn.gd index f598771..4e2838a 100644 --- a/addons/dbpf/GZWinBtn.gd +++ b/addons/dbpf/GZWinBtn.gd @@ -1,7 +1,7 @@ extends GZWin class_name GZWinBtn -# Texture order: +# Texture2D order: # 0. disabled # 1. normal # 2. pressed @@ -40,7 +40,7 @@ var is_pressed : bool = false var is_checked : bool = false var is_disabled : bool = false -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary,attributes_): var style = attributes.get('style', 'standard') match style: "standard": @@ -58,15 +58,15 @@ func _init(attributes : Dictionary).(attributes): print("Imagerect", attributes['imagerect']) update_state() -func set_texture(texture : Texture): +func set_texture(texture : Texture2D): set_size(Vector2(texture.get_width() / N_SUBTEXTURES, texture.get_height())) for i in N_SUBTEXTURES: textures[i] = get_cropped_texture(texture, Rect2(i * texture.get_width() / N_SUBTEXTURES, 0, texture.get_width() / N_SUBTEXTURES, texture.get_height())) -func get_cropped_texture(texture : Texture, region : Rect2): +func get_cropped_texture(texture : Texture2D, region : Rect2): var atlas_texture = AtlasTexture.new() atlas_texture.set_atlas(texture) - atlas_texture.set_region(region) + atlas_texture.set_region_enabled(region) return atlas_texture func get_minimum_size(): @@ -95,12 +95,12 @@ func update_state(): self.state += ButtonState.CHECKBOX_PRESSED elif is_hovered: self.state += ButtonState.CHECKBOX_HOVER - update() + queue_redraw() func _gui_input(event): if is_disabled: return - if event is InputEventMouseButton and event.button_index == BUTTON_LEFT: + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: if event.pressed: is_pressed = true if self.style == ButtonStyle.RADIOCHECK: @@ -135,4 +135,4 @@ func _notification(what): func set_state(state): self.state = state - update() + queue_redraw() diff --git a/addons/dbpf/GZWinFlatRect.gd b/addons/dbpf/GZWinFlatRect.gd index ad4ecf0..bc2773c 100644 --- a/addons/dbpf/GZWinFlatRect.gd +++ b/addons/dbpf/GZWinFlatRect.gd @@ -5,11 +5,11 @@ var color : Color = Color(1, 1, 1) var nofill = false -func _init(attributes : Dictionary).(attributes): +func _init(attributes : Dictionary): print(attributes) if attributes.get("style", "") == "nofill": nofill = true - update() + queue_redraw() func _draw(): pass diff --git a/addons/dbpf/GZWinGen.gd b/addons/dbpf/GZWinGen.gd index e0a47d8..f866692 100644 --- a/addons/dbpf/GZWinGen.gd +++ b/addons/dbpf/GZWinGen.gd @@ -1,8 +1,8 @@ extends GZWin class_name GZWinGen -func _init(attributes : Dictionary).(attributes): - update() +func _init(attributes : Dictionary): + queue_redraw() func _draw(): pass diff --git a/addons/dbpf/GZWinText.gd b/addons/dbpf/GZWinText.gd index 16e8296..7c0e827 100644 --- a/addons/dbpf/GZWinText.gd +++ b/addons/dbpf/GZWinText.gd @@ -3,8 +3,9 @@ class_name GZWinText var text : String var font = null +var default_font_size = ThemeDB.fallback_font_size -func _init(attributes).(attributes): +func _init(attributes): # hack to get the default font while we can't decode the Simcity 4 ones var label = Label.new() self.font = label.get_font("") @@ -26,8 +27,7 @@ func _init(attributes).(attributes): func set_text(text : String): self.text = text - self.update() + self.queue_redraw() func _draw(): - draw_string(font, Vector2(0, font.get_height()), self.text, Color.white) - + draw_string(font, Vector2(0, font.get_height()), self.text, HORIZONTAL_ALIGNMENT_LEFT, -1, default_font_size, Color.WHITE) diff --git a/addons/dbpf/INISubfile.gd b/addons/dbpf/INISubfile.gd index bf0c470..673f897 100644 --- a/addons/dbpf/INISubfile.gd +++ b/addons/dbpf/INISubfile.gd @@ -5,11 +5,11 @@ var sections = {} var file_path var cfgFile : ConfigFile -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) # var current_section = "" diff --git a/addons/dbpf/ImageSubfile.gd b/addons/dbpf/ImageSubfile.gd index 551bdfe..f28db95 100644 --- a/addons/dbpf/ImageSubfile.gd +++ b/addons/dbpf/ImageSubfile.gd @@ -20,14 +20,14 @@ class_name ImageSubfile var img -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") - assert(raw_data[0] == 0x89 and raw_data[1] == 0x50 and raw_data[2] == 0x4E and raw_data[3] == 0x47, "DBPFSubfile.load: invalid magic") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") + assert(raw_data[0] == 0x89 and raw_data[1] == 0x50 and raw_data[2] == 0x4E and raw_data[3] == 0x47) #,"DBPFSubfile.load: invalid magic") self.img = Image.new() var err = img.load_png_from_buffer(raw_data) if err != OK: @@ -37,5 +37,5 @@ func load(file, dbdf=null): func get_as_texture(): assert(self.img != null) var ret = ImageTexture.new() - ret.create_from_image(self.img, 0) + ret.create_from_image(self.img) #,0 return ret diff --git a/addons/dbpf/LTEXTSubfile.gd b/addons/dbpf/LTEXTSubfile.gd index 73e19a3..2ef8051 100644 --- a/addons/dbpf/LTEXTSubfile.gd +++ b/addons/dbpf/LTEXTSubfile.gd @@ -20,11 +20,11 @@ class_name LTEXTSubfile var text : String -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) text = "" var n_characters = stream.get_u16() # (2-byte unicode characters) # Check that we have the correct amount of characters diff --git a/addons/dbpf/RULSubfile.gd b/addons/dbpf/RULSubfile.gd index c38df28..a53a78a 100644 --- a/addons/dbpf/RULSubfile.gd +++ b/addons/dbpf/RULSubfile.gd @@ -85,7 +85,7 @@ from the wiki: var RUL_wnes = {} var num_ids = 0 -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): @@ -104,10 +104,10 @@ func load(file, dbdf=null): 24 8 7 6 18 23 22 21 20 19 """ - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) var ind = 0 - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") var ini_str = raw_data.get_string_from_ascii() var i = 0 var raw_split = ini_str.split('\n') diff --git a/addons/dbpf/S3DSubfile.gd b/addons/dbpf/S3DSubfile.gd index 65aea4c..a7a2b77 100644 --- a/addons/dbpf/S3DSubfile.gd +++ b/addons/dbpf/S3DSubfile.gd @@ -7,24 +7,24 @@ var max_text_width = 0 var max_text_height = 0 var formats = [] -func _init(index).(index): +func _init(index): pass func load(file, dbdf=null): - .load(file, dbdf) + super.load(file, dbdf) file.seek(index.location) var ind = 0 - assert(len(raw_data) > 0, "DBPFSubfile.load: no data") + assert(len(raw_data) > 0) #,"DBPFSubfile.load: no data") # 4 bytes (char) - signature - var signature = raw_data.subarray(ind, ind+3).get_string_from_ascii() - assert(signature == "3DMD", "DBPFSubfile.load: not an FSH file") + var signature = raw_data.slice(ind, ind+3).get_string_from_ascii() + assert(signature == "3DMD") #,"DBPFSubfile.load: not an FSH file") ind += 4 # 4 bytes ? seems size and complexity related ind += 4 "-HEAD block-" - var h_head = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var h_head = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 - var h_length = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var h_length = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 # seems to be always 1, might be anim related? ind += 2 @@ -35,53 +35,53 @@ func load(file, dbdf=null): ind = h_length + 8 "-VERT block-" - var v_vert = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var v_vert = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 # seems field length for single group fields but gets freaky for multiple groups and animations ind += 4 - var v_grpcnt = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var v_grpcnt = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var vertices = PoolVector3Array([]) - var UVs = PoolVector2Array([]) + var vertices = PackedVector3Array([]) + var UVs = PackedVector2Array([]) for _grpind in range(v_grpcnt): var group = S3D_Group.new() self.groups.append(group) # 2 Bytes always 0? ind += 2 - var vert_count : int = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var vert_count : int = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 - var format : int = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var format : int = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 for _i in range(vert_count): - var x = self.get_float_from_bytes(raw_data.subarray(ind, ind+3))/16.0 + var x = self.get_float_from_bytes(raw_data.slice(ind, ind+3))/16.0 ind += 4 - var y = self.get_float_from_bytes(raw_data.subarray(ind, ind+3))/16.0 + var y = self.get_float_from_bytes(raw_data.slice(ind, ind+3))/16.0 ind += 4 - var z = self.get_float_from_bytes(raw_data.subarray(ind, ind+3))/16.0 + var z = self.get_float_from_bytes(raw_data.slice(ind, ind+3))/16.0 ind += 4 vertices.append(Vector3(x, y, z)) - var u = self.get_float_from_bytes(raw_data.subarray(ind, ind+3)) + var u = self.get_float_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var v = self.get_float_from_bytes(raw_data.subarray(ind, ind+3)) + var v = self.get_float_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 UVs.append(Vector2(u, v)) "-INDX block-" - var i_indx = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var i_indx = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 - var i_length = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var i_length = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var i_grpcnt = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var i_grpcnt = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 for grpind in range(i_grpcnt): # always 0? ind += 2 # always 2? ind += 2 - var indxcnt = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var indxcnt = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 for _indxind in range(indxcnt): - var vert_indx = self.get_int_from_bytes(raw_data.subarray(ind, ind+1)) + var vert_indx = self.get_int_from_bytes(raw_data.slice(ind, ind+1)) ind += 2 var verts_tmp = self.groups[grpind].vertices verts_tmp.append(vertices[vert_indx]) @@ -91,14 +91,14 @@ func load(file, dbdf=null): self.groups[grpind].UVs = UVs_tmp "-PRIM block-: this does nothing as everything seems to always just be triangles" - var p_prim = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var p_prim = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 - var p_length = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var p_length = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var p_grpcnt = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var p_grpcnt = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 for grpind in range(p_grpcnt): - var p_type = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var p_type = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 if p_type != 1: print("unexpected primary type in %d", self.index.instance_id) @@ -108,11 +108,11 @@ func load(file, dbdf=null): ind += 4 "-MATS block-" - var m_mats = raw_data.subarray(ind, ind+3).get_string_from_ascii() + var m_mats = raw_data.slice(ind, ind+3).get_string_from_ascii() ind += 4 - var m_length = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var m_length = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 - var m_grpcnt = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + var m_grpcnt = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 for grpind in range(m_grpcnt): var settings = raw_data[ind] @@ -137,11 +137,11 @@ func load(file, dbdf=null): ind += 1 self.groups[grpind].destblend = raw_data[ind] ind += 1 - self.groups[grpind].alphathreshold = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.groups[grpind].alphathreshold = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 # 4 Bytes 0x01000000 some mask? ind += 4 - self.groups[grpind].mat_id = self.get_int_from_bytes(raw_data.subarray(ind, ind+3)) + self.groups[grpind].mat_id = self.get_int_from_bytes(raw_data.slice(ind, ind+3)) ind += 4 self.groups[grpind].wrapmodeU = raw_data[ind] ind += 1 @@ -155,7 +155,7 @@ func load(file, dbdf=null): ind += 4 var str_length = raw_data[ind] ind += 1 - self.groups[grpind].group_name = raw_data.subarray(ind, ind+str_length).get_string_from_ascii() + self.groups[grpind].group_name = raw_data.slice(ind, ind+str_length).get_string_from_ascii() ind += str_length # 1 Byte end string 0x00 ind += 1 @@ -164,14 +164,14 @@ func load(file, dbdf=null): "-PROP block- TODO" "-REGP block- TODO" -func add_to_mesh(mesh: MeshInstance, location: Vector3): +func add_to_mesh(mesh: MeshInstance3D, location: Vector3): """this is temporary to test if it loads and how its size is compared to regulater terrain""" - var vertices = PoolVector3Array([]) - var UVs = PoolVector2Array([]) + var vertices = PackedVector3Array([]) + var UVs = PackedVector2Array([]) var images = [] for group in self.groups: - var loc_vert = PoolVector3Array([]) - var loc_UV = PoolVector2Array([]) + var loc_vert = PackedVector3Array([]) + var loc_UV = PackedVector2Array([]) for vertind in range(group.vertices.size()-1, -1, -1): loc_vert.append(location + group.vertices[vertind]) loc_UV.append(group.UVs[vertind]) @@ -179,7 +179,7 @@ func add_to_mesh(mesh: MeshInstance, location: Vector3): UVs.append_array(loc_UV) var image = get_texture_from_mat_id(group.mat_id) images.append(image) - var textarr = TextureArray.new() + var textarr = Texture2DArray.new() textarr.create (self.max_text_width, self.max_text_height, len(self.groups), self.formats[0], 2) for imgind in range(len(images)): textarr.set_layer_data(images[imgind], imgind) @@ -192,7 +192,7 @@ func add_to_mesh(mesh: MeshInstance, location: Vector3): array_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays) mesh.mesh = array_mesh var mat = mesh.get_material_override() - mat.set_shader_param("s3dtexture", textarr) + mat.set_shader_parameter("s3dtexture", textarr) mesh.set_material_override(mat) func get_texture_from_mat_id(iid): diff --git a/addons/dbpf/S3D_Group.gd b/addons/dbpf/S3D_Group.gd index ef4a12d..8d72c79 100644 --- a/addons/dbpf/S3D_Group.gd +++ b/addons/dbpf/S3D_Group.gd @@ -2,8 +2,8 @@ extends Node class_name S3D_Group -var vertices = PoolVector3Array([]) -var UVs = PoolVector2Array([]) +var vertices = PackedVector3Array([]) +var UVs = PackedVector2Array([]) var mat_id: int # shader mat index, should handle picking the texturearray and layer that hold the mat diff --git a/addons/dbpf/SubfileIndex.gd b/addons/dbpf/SubfileIndex.gd index df66cf6..0f948d1 100644 --- a/addons/dbpf/SubfileIndex.gd +++ b/addons/dbpf/SubfileIndex.gd @@ -9,7 +9,7 @@ var location:int var size:int var dbpf -func _init(dbpf, buffer): +func _init(dbpf,buffer): type_id = buffer.get_u32() group_id = buffer.get_u32() instance_id = buffer.get_u32() diff --git a/addons/dbpf/dbpf.png.import b/addons/dbpf/dbpf.png.import index b8fd077..9c9467b 100644 --- a/addons/dbpf/dbpf.png.import +++ b/addons/dbpf/dbpf.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/dbpf.png-7fcfe5f00851a7e63f4b76c9e4252da6.stex" +type="CompressedTexture2D" +uid="uid://l1vce1kd7fy7" +path="res://.godot/imported/dbpf.png-7fcfe5f00851a7e63f4b76c9e4252da6.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://addons/dbpf/dbpf.png" -dest_files=[ "res://.import/dbpf.png-7fcfe5f00851a7e63f4b76c9e4252da6.stex" ] +dest_files=["res://.godot/imported/dbpf.png-7fcfe5f00851a7e63f4b76c9e4252da6.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/cSTETerrain__SaveAltitudes.gd b/cSTETerrain__SaveAltitudes.gd index 2373024..dae802a 100644 --- a/cSTETerrain__SaveAltitudes.gd +++ b/cSTETerrain__SaveAltitudes.gd @@ -5,11 +5,11 @@ var width : int var height : int var altitudes : Array -func _init(index).(index): +func _init(index): pass func load(file, dbpf=null): - .load(file, dbpf) + super.load(file, dbpf) stream.data_array = raw_data var major = stream.get_16() print("major: %08x" % major) diff --git a/project.godot b/project.godot index 39b678b..29944f2 100644 --- a/project.godot +++ b/project.godot @@ -6,226 +6,13 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ { -"base": "DBPFSubfile", -"class": "CURSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/CURSubfile.gd" -}, { -"base": "Node", -"class": "CUR_Entry", -"language": "GDScript", -"path": "res://addons/dbpf/CUR_Entry.gd" -}, { -"base": "Reference", -"class": "DBDF", -"language": "GDScript", -"path": "res://addons/dbpf/DBDF.gd" -}, { -"base": "Node", -"class": "DBDFEntry", -"language": "GDScript", -"path": "res://addons/dbpf/DBDFEntry.gd" -}, { -"base": "Resource", -"class": "DBPF", -"language": "GDScript", -"path": "res://addons/dbpf/DBPF.gd" -}, { -"base": "EditorPlugin", -"class": "DBPFPlugin", -"language": "GDScript", -"path": "res://addons/dbpf/DBPFPlugin.gd" -}, { -"base": "Reference", -"class": "DBPFSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/DBPFSubfile.gd" -}, { -"base": "DBPFSubfile", -"class": "ExemplarSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/ExemplarSubfile.gd" -}, { -"base": "DBPFSubfile", -"class": "FSHSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/FSHSubfile.gd" -}, { -"base": "Node", -"class": "FSH_Entry", -"language": "GDScript", -"path": "res://addons/dbpf/FSH_Entry.gd" -}, { -"base": "Control", -"class": "GZWin", -"language": "GDScript", -"path": "res://addons/dbpf/GZWin.gd" -}, { -"base": "GZWin", -"class": "GZWinBMP", -"language": "GDScript", -"path": "res://addons/dbpf/GZWinBMP.gd" -}, { -"base": "GZWin", -"class": "GZWinBtn", -"language": "GDScript", -"path": "res://addons/dbpf/GZWinBtn.gd" -}, { -"base": "GZWin", -"class": "GZWinFlatRect", -"language": "GDScript", -"path": "res://addons/dbpf/GZWinFlatRect.gd" -}, { -"base": "GZWin", -"class": "GZWinGen", -"language": "GDScript", -"path": "res://addons/dbpf/GZWinGen.gd" -}, { -"base": "GZWin", -"class": "GZWinText", -"language": "GDScript", -"path": "res://addons/dbpf/GZWinText.gd" -}, { -"base": "Node", -"class": "INI", -"language": "GDScript", -"path": "res://ini.gd" -}, { -"base": "DBPFSubfile", -"class": "INISubfile", -"language": "GDScript", -"path": "res://addons/dbpf/INISubfile.gd" -}, { -"base": "DBPFSubfile", -"class": "ImageSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/ImageSubfile.gd" -}, { -"base": "DBPFSubfile", -"class": "LTEXTSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/LTEXTSubfile.gd" -}, { -"base": "Reference", -"class": "NetGraphEdge", -"language": "GDScript", -"path": "res://CityView/ClassDefinitions/NetGraphEdge.gd" -}, { -"base": "Reference", -"class": "NetGraphNode", -"language": "GDScript", -"path": "res://CityView/ClassDefinitions/NetGraphNode.gd" -}, { -"base": "Reference", -"class": "NetTile", -"language": "GDScript", -"path": "res://CityView/ClassDefinitions/NetTile.gd" -}, { -"base": "Reference", -"class": "NetworkGraph", -"language": "GDScript", -"path": "res://CityView/ClassDefinitions/NeworkGraph.gd" -}, { -"base": "DBPFSubfile", -"class": "RULSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/RULSubfile.gd" -}, { -"base": "Area2D", -"class": "RegionCityView", -"language": "GDScript", -"path": "res://RegionUI/RegionCityView.gd" -}, { -"base": "Sprite", -"class": "RegionViewCityThumbnail", -"language": "GDScript", -"path": "res://RegionViewCityThumbnail.gd" -}, { -"base": "DBPFSubfile", -"class": "S3DSubfile", -"language": "GDScript", -"path": "res://addons/dbpf/S3DSubfile.gd" -}, { -"base": "Node", -"class": "S3D_Group", -"language": "GDScript", -"path": "res://addons/dbpf/S3D_Group.gd" -}, { -"base": "DBPFSubfile", -"class": "SC4ReadRegionalCity", -"language": "GDScript", -"path": "res://SC4ReadRegionalCity.gd" -}, { -"base": "DBPFSubfile", -"class": "SC4UISubfile", -"language": "GDScript", -"path": "res://SC4UISubfile.gd" -}, { -"base": "Node", -"class": "SubfileIndex", -"language": "GDScript", -"path": "res://addons/dbpf/SubfileIndex.gd" -}, { -"base": "Node", -"class": "SubfileTGI", -"language": "GDScript", -"path": "res://addons/dbpf/SubfileTGI.gd" -}, { -"base": "Reference", -"class": "TransitTile", -"language": "GDScript", -"path": "res://CityView/ClassDefinitions/TransitTile.gd" -}, { -"base": "DBPFSubfile", -"class": "cSTETerrain__SaveAltitudes", -"language": "GDScript", -"path": "res://cSTETerrain__SaveAltitudes.gd" -} ] -_global_script_class_icons={ -"CURSubfile": "", -"CUR_Entry": "", -"DBDF": "", -"DBDFEntry": "", -"DBPF": "", -"DBPFPlugin": "", -"DBPFSubfile": "", -"ExemplarSubfile": "", -"FSHSubfile": "", -"FSH_Entry": "", -"GZWin": "", -"GZWinBMP": "", -"GZWinBtn": "", -"GZWinFlatRect": "", -"GZWinGen": "", -"GZWinText": "", -"INI": "", -"INISubfile": "", -"ImageSubfile": "", -"LTEXTSubfile": "", -"NetGraphEdge": "", -"NetGraphNode": "", -"NetTile": "", -"NetworkGraph": "", -"RULSubfile": "", -"RegionCityView": "", -"RegionViewCityThumbnail": "", -"S3DSubfile": "", -"S3D_Group": "", -"SC4ReadRegionalCity": "", -"SC4UISubfile": "", -"SubfileIndex": "", -"SubfileTGI": "", -"TransitTile": "", -"cSTETerrain__SaveAltitudes": "" -} +config_version=5 [application] config/name="OpenSC4" run/main_scene="res://BootScreen.tscn" +config/features=PackedStringArray("4.0") boot_splash/image="res://splash.png" config/icon="res://splash.png" @@ -240,16 +27,16 @@ Player="*res://CityView/Player.gd" [display] -window/size/width=1280 -window/size/height=720 +window/size/viewport_width=1280 +window/size/viewport_height=720 [editor_plugins] -enabled=PoolStringArray( "res://addons/dbpf/plugin.cfg" ) +enabled=PackedStringArray("res://addons/dbpf/plugin.cfg") [gdnative] -singletons=[ ] +singletons=[] [global] @@ -263,34 +50,34 @@ edit=false camera_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +] } camera_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +] } camera_left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +] } camera_right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +] } camera_right_click={ "deadzone": 0.5, -"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null) - ] +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"pressed":false,"double_click":false,"script":null) +] } [network] -limits/debugger_stdout/max_chars_per_second=20000 -limits/debugger_stdout/max_messages_per_frame=100 +limits/debugger/max_chars_per_second=20000 +limits/debugger/max_queued_messages=100 [physics] @@ -301,7 +88,6 @@ common/enable_pause_aware_picking=true 2d/snapping/use_gpu_pixel_snap=true threads/thread_model=2 vram_compression/import_etc=true -vram_compression/import_etc2=false quality/shadow_atlas/cubemap_size=1024 quality/shadows/filter_mode=2 quality/filters/use_fxaa=true diff --git a/splash.png.import b/splash.png.import index fab3fd8..4e06441 100644 --- a/splash.png.import +++ b/splash.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/splash.png-929ed8a00b89ba36c51789452f874c77.stex" +type="CompressedTexture2D" +uid="uid://swmrfycjhv5j" +path="res://.godot/imported/splash.png-929ed8a00b89ba36c51789452f874c77.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,24 @@ metadata={ [deps] source_file="res://splash.png" -dest_files=[ "res://.import/splash.png-929ed8a00b89ba36c51789452f874c77.stex" ] +dest_files=["res://.godot/imported/splash.png-929ed8a00b89ba36c51789452f874c77.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/utils/debug_ui/loading_icon_spinning.tres b/utils/debug_ui/loading_icon_spinning.tres index ddf4858..d42ddc2 100644 --- a/utils/debug_ui/loading_icon_spinning.tres +++ b/utils/debug_ui/loading_icon_spinning.tres @@ -1,13 +1,13 @@ [gd_resource type="AnimatedTexture" load_steps=9 format=2] -[ext_resource path="res://utils/debug_ui/load5.png" type="Texture" id=1] -[ext_resource path="res://utils/debug_ui/load0.png" type="Texture" id=2] -[ext_resource path="res://utils/debug_ui/load3.png" type="Texture" id=3] -[ext_resource path="res://utils/debug_ui/load6.png" type="Texture" id=4] -[ext_resource path="res://utils/debug_ui/load7.png" type="Texture" id=5] -[ext_resource path="res://utils/debug_ui/load1.png" type="Texture" id=6] -[ext_resource path="res://utils/debug_ui/load2.png" type="Texture" id=7] -[ext_resource path="res://utils/debug_ui/load4.png" type="Texture" id=8] +[ext_resource path="res://utils/debug_ui/load5.png" type="Texture2D" id=1] +[ext_resource path="res://utils/debug_ui/load0.png" type="Texture2D" id=2] +[ext_resource path="res://utils/debug_ui/load3.png" type="Texture2D" id=3] +[ext_resource path="res://utils/debug_ui/load6.png" type="Texture2D" id=4] +[ext_resource path="res://utils/debug_ui/load7.png" type="Texture2D" id=5] +[ext_resource path="res://utils/debug_ui/load1.png" type="Texture2D" id=6] +[ext_resource path="res://utils/debug_ui/load2.png" type="Texture2D" id=7] +[ext_resource path="res://utils/debug_ui/load4.png" type="Texture2D" id=8] [resource] flags = 4 diff --git a/utils/logger.gd b/utils/logger.gd index 0229645..46cd770 100644 --- a/utils/logger.gd +++ b/utils/logger.gd @@ -21,10 +21,10 @@ class ExternalSink: var name var queue_mode - var buffer = PoolStringArray() + var buffer = PackedStringArray() var buffer_idx = 0 - func _init(_name, _queue_mode = QUEUE_MODES.NONE) -> void: + func _init(_name,_queue_mode = QUEUE_MODES.NONE): name = _name queue_mode = _queue_mode @@ -60,7 +60,7 @@ class Logfile: var file = null var path = "" - func _init(_path, _queue_mode = QUEUE_MODES.NONE).(_path, _queue_mode): + func _init(_path,_queue_mode = QUEUE_MODES.NONE,_path,_queue_mode): file = File.new() if validate_path(_path): path = _path @@ -78,7 +78,7 @@ class Logfile: func validate_path(path): """Validate the path given as argument, making it possible to write to the designated file or folder. Returns whether the path is valid.""" - if not (path.is_abs_path() or path.is_rel_path()): + if not (path.is_absolute_path() or path.is_rel_path()): print("[ERROR] [logger] The given path '%s' is not valid." % path) return false var dir = Directory.new() @@ -147,7 +147,7 @@ class Module: var output_strategies = [] var external_sink = null - func _init(_name, _output_level, _output_strategies, _external_sink): + func _init(_name,_output_level,_output_strategies,_external_sink): name = _name set_output_level(_output_level) @@ -557,7 +557,7 @@ func get_default_output_level(): # * mm = Minutes # * ss = Seconds func get_formatted_datetime(): - var datetime = OS.get_datetime() + var datetime = Time.get_datetime_dict_from_system() var result = time_format result = result.replace("YYYY", "%04d" % [datetime.year]) result = result.replace("MM", "%02d" % [datetime.month])