attribution screen changes

pull/15/head
Wade 2025-04-07 10:38:27 +07:00
parent 5380dbad12
commit a8faa4d51b
14 changed files with 1669 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://w2j0pxe0pcs"
path="res://.godot/imported/Starter Kit City Builder.apple-touch-icon.png-54e47c754919415f807e136dd0205656.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://builds/html/Starter Kit City Builder.apple-touch-icon.png"
dest_files=["res://.godot/imported/Starter Kit City Builder.apple-touch-icon.png-54e47c754919415f807e136dd0205656.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

@ -0,0 +1,213 @@
/**************************************************************************/
/* audio.worklet.js */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
class RingBuffer {
constructor(p_buffer, p_state, p_threads) {
this.buffer = p_buffer;
this.avail = p_state;
this.threads = p_threads;
this.rpos = 0;
this.wpos = 0;
}
data_left() {
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
}
space_left() {
return this.buffer.length - this.data_left();
}
read(output) {
const size = this.buffer.length;
let from = 0;
let to_write = output.length;
if (this.rpos + to_write > size) {
const high = size - this.rpos;
output.set(this.buffer.subarray(this.rpos, size));
from = high;
to_write -= high;
this.rpos = 0;
}
if (to_write) {
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
}
this.rpos += to_write;
if (this.threads) {
Atomics.add(this.avail, 0, -output.length);
Atomics.notify(this.avail, 0);
} else {
this.avail -= output.length;
}
}
write(p_buffer) {
const to_write = p_buffer.length;
const mw = this.buffer.length - this.wpos;
if (mw >= to_write) {
this.buffer.set(p_buffer, this.wpos);
this.wpos += to_write;
if (mw === to_write) {
this.wpos = 0;
}
} else {
const high = p_buffer.subarray(0, mw);
const low = p_buffer.subarray(mw);
this.buffer.set(high, this.wpos);
this.buffer.set(low);
this.wpos = low.length;
}
if (this.threads) {
Atomics.add(this.avail, 0, to_write);
Atomics.notify(this.avail, 0);
} else {
this.avail += to_write;
}
}
}
class GodotProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.threads = false;
this.running = true;
this.lock = null;
this.notifier = null;
this.output = null;
this.output_buffer = new Float32Array();
this.input = null;
this.input_buffer = new Float32Array();
this.port.onmessage = (event) => {
const cmd = event.data['cmd'];
const data = event.data['data'];
this.parse_message(cmd, data);
};
}
process_notify() {
if (this.notifier) {
Atomics.add(this.notifier, 0, 1);
Atomics.notify(this.notifier, 0);
}
}
parse_message(p_cmd, p_data) {
if (p_cmd === 'start' && p_data) {
const state = p_data[0];
let idx = 0;
this.threads = true;
this.lock = state.subarray(idx, ++idx);
this.notifier = state.subarray(idx, ++idx);
const avail_in = state.subarray(idx, ++idx);
const avail_out = state.subarray(idx, ++idx);
this.input = new RingBuffer(p_data[1], avail_in, true);
this.output = new RingBuffer(p_data[2], avail_out, true);
} else if (p_cmd === 'stop') {
this.running = false;
this.output = null;
this.input = null;
this.lock = null;
this.notifier = null;
} else if (p_cmd === 'start_nothreads') {
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
} else if (p_cmd === 'chunk') {
this.output.write(p_data);
}
}
static array_has_data(arr) {
return arr.length && arr[0].length && arr[0][0].length;
}
process(inputs, outputs, parameters) {
if (!this.running) {
return false; // Stop processing.
}
if (this.output === null) {
return true; // Not ready yet, keep processing.
}
const process_input = GodotProcessor.array_has_data(inputs);
if (process_input) {
const input = inputs[0];
const chunk = input[0].length * input.length;
if (this.input_buffer.length !== chunk) {
this.input_buffer = new Float32Array(chunk);
}
if (!this.threads) {
GodotProcessor.write_input(this.input_buffer, input);
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
} else if (this.input.space_left() >= chunk) {
GodotProcessor.write_input(this.input_buffer, input);
this.input.write(this.input_buffer);
} else {
// this.port.postMessage('Input buffer is full! Skipping input frame.'); // Uncomment this line to debug input buffer.
}
}
const process_output = GodotProcessor.array_has_data(outputs);
if (process_output) {
const output = outputs[0];
const chunk = output[0].length * output.length;
if (this.output_buffer.length !== chunk) {
this.output_buffer = new Float32Array(chunk);
}
if (this.output.data_left() >= chunk) {
this.output.read(this.output_buffer);
GodotProcessor.write_output(output, this.output_buffer);
if (!this.threads) {
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
}
} else {
// this.port.postMessage('Output buffer has not enough frames! Skipping output frame.'); // Uncomment this line to debug output buffer.
}
}
this.process_notify();
return true;
}
static write_output(dest, source) {
const channels = dest.length;
for (let ch = 0; ch < channels; ch++) {
for (let sample = 0; sample < dest[ch].length; sample++) {
dest[ch][sample] = source[sample * channels + ch];
}
}
}
static write_input(dest, source) {
const channels = source.length;
for (let ch = 0; ch < channels; ch++) {
for (let sample = 0; sample < source[ch].length; sample++) {
dest[sample * channels + ch] = source[ch][sample];
}
}
}
}
registerProcessor('godot-processor', GodotProcessor);

@ -0,0 +1,199 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
<title>Starter Kit City Builder</title>
<style>
html, body, #canvas {
margin: 0;
padding: 0;
border: 0;
}
body {
color: white;
background-color: black;
overflow: hidden;
touch-action: none;
}
#canvas {
display: block;
}
#canvas:focus {
outline: none;
}
#status, #status-splash, #status-progress {
position: absolute;
left: 0;
right: 0;
}
#status, #status-splash {
top: 0;
bottom: 0;
}
#status {
background-color: #242424;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
visibility: hidden;
}
#status-splash {
max-height: 100%;
max-width: 100%;
margin: auto;
}
#status-progress, #status-notice {
display: none;
}
#status-progress {
bottom: 10%;
width: 50%;
margin: 0 auto;
}
#status-notice {
background-color: #5b3943;
border-radius: 0.5rem;
border: 1px solid #9b3943;
color: #e0e0e0;
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
line-height: 1.3;
margin: 0 2rem;
overflow: hidden;
padding: 1rem;
text-align: center;
z-index: 1;
}
</style>
<link id="-gd-engine-icon" rel="icon" type="image/png" href="Starter Kit City Builder.icon.png" />
<link rel="apple-touch-icon" href="Starter Kit City Builder.apple-touch-icon.png"/>
</head>
<body>
<canvas id="canvas">
Your browser does not support the canvas tag.
</canvas>
<noscript>
Your browser does not support JavaScript.
</noscript>
<div id="status">
<img id="status-splash" src="Starter Kit City Builder.png" alt="">
<progress id="status-progress"></progress>
<div id="status-notice"></div>
</div>
<script src="Starter Kit City Builder.js"></script>
<script>
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":true,"executable":"Starter Kit City Builder","experimentalVK":false,"fileSizes":{"Starter Kit City Builder.pck":11398880,"Starter Kit City Builder.wasm":43016933},"focusCanvas":true,"gdextensionLibs":[]};
const GODOT_THREADS_ENABLED = false;
const engine = new Engine(GODOT_CONFIG);
(function () {
const statusOverlay = document.getElementById('status');
const statusProgress = document.getElementById('status-progress');
const statusNotice = document.getElementById('status-notice');
let initializing = true;
let statusMode = '';
function setStatusMode(mode) {
if (statusMode === mode || !initializing) {
return;
}
if (mode === 'hidden') {
statusOverlay.remove();
initializing = false;
return;
}
statusOverlay.style.visibility = 'visible';
statusProgress.style.display = mode === 'progress' ? 'block' : 'none';
statusNotice.style.display = mode === 'notice' ? 'block' : 'none';
statusMode = mode;
}
function setStatusNotice(text) {
while (statusNotice.lastChild) {
statusNotice.removeChild(statusNotice.lastChild);
}
const lines = text.split('\n');
lines.forEach((line) => {
statusNotice.appendChild(document.createTextNode(line));
statusNotice.appendChild(document.createElement('br'));
});
}
function displayFailureNotice(err) {
console.error(err);
if (err instanceof Error) {
setStatusNotice(err.message);
} else if (typeof err === 'string') {
setStatusNotice(err);
} else {
setStatusNotice('An unknown error occured');
}
setStatusMode('notice');
initializing = false;
}
const missing = Engine.getMissingFeatures({
threads: GODOT_THREADS_ENABLED,
});
if (missing.length !== 0) {
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
// There's a chance that installing the service worker would fix the issue
Promise.race([
navigator.serviceWorker.getRegistration().then((registration) => {
if (registration != null) {
return Promise.reject(new Error('Service worker already exists.'));
}
return registration;
}).then(() => engine.installServiceWorker()),
// For some reason, `getRegistration()` can stall
new Promise((resolve) => {
setTimeout(() => resolve(), 2000);
}),
]).catch((err) => {
console.error('Error while registering service worker:', err);
}).then(() => {
window.location.reload();
});
} else {
// Display the message as usual
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
displayFailureNotice(missingMsg + missing.join('\n'));
}
} else {
setStatusMode('progress');
engine.startGame({
'onProgress': function (current, total) {
if (current > 0 && total > 0) {
statusProgress.value = current;
statusProgress.max = total;
} else {
statusProgress.removeAttribute('value');
statusProgress.removeAttribute('max');
}
},
}).then(() => {
setStatusMode('hidden');
}, displayFailureNotice);
}
}());
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5tkllefokyj5"
path="res://.godot/imported/Starter Kit City Builder.icon.png-db6dbcb23970726fc8baf3f9f92171f6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://builds/html/Starter Kit City Builder.icon.png"
dest_files=["res://.godot/imported/Starter Kit City Builder.icon.png-db6dbcb23970726fc8baf3f9f92171f6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b3k4h7i1cvh2n"
path="res://.godot/imported/Starter Kit City Builder.png-a4c352fa688cf84948ae1c3c4c544c9e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://builds/html/Starter Kit City Builder.png"
dest_files=["res://.godot/imported/Starter Kit City Builder.png-a4c352fa688cf84948ae1c3c4c544c9e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

@ -0,0 +1,81 @@
[gd_scene load_steps=3 format=3 uid="uid://ib2t48fgsw62"]
[ext_resource type="FontFile" uid="uid://d0cxd77jybrcn" path="res://fonts/lilita_one_regular.ttf" id="1_ncwjb"]
[ext_resource type="Script" path="res://scripts/attribution_screen.gd" id="1_qwu4y"]
[node name="AttributionScreen" type="CanvasLayer"]
script = ExtResource("1_qwu4y")
[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.145098, 0.172549, 0.231373, 1)
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 100
theme_override_constants/margin_bottom = 100
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 30
[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("1_ncwjb")
theme_override_font_sizes/font_size = 48
text = "Attributions"
horizontal_alignment = 1
[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="AttributionsContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 20
[node name="PowerPlantLabel" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "3D Models - \"Power Plant\" (https://skfb.ly/6vZoR) by Romain PERRONE is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/)"
autowrap_mode = 3
[node name="Kenny" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "3D Models - Provided by Kenny.nl (Thanks Kenny)"
autowrap_mode = 3
[node name="SoundLabel1" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "SoundFX - building placing.wav by strange_dragoon -- https://freesound.org/s/271141/ -- License: Attribution 3.0"
autowrap_mode = 3
[node name="SoundLabel2" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "SoundFX - building construct p2.wav by strange_dragoon -- https://freesound.org/s/271135/ -- License: Attribution 3.0"
autowrap_mode = 3
[node name="SongLabel" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "Music - Provided by PaoloArgento - The Best Jazz Club In New Orleans"
autowrap_mode = 3
[node name="SoundLabel3" type="Label" parent="MarginContainer/VBoxContainer/AttributionsContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
text = "building construct p2.wav by strange_dragoon -- https://freesound.org/s/271135/ -- License: Attribution 3.0"
autowrap_mode = 3

@ -0,0 +1,23 @@
extends CanvasLayer
# Time in seconds to display the attribution screen
const DISPLAY_TIME: float = 3.0
const MAIN_SCENE_PATH: String = "res://scenes/main.tscn"
func _ready():
# Set up the timer to automatically transition to the main scene
var timer = Timer.new()
add_child(timer)
timer.wait_time = DISPLAY_TIME
timer.one_shot = true
timer.timeout.connect(_on_timer_timeout)
timer.start()
func _on_timer_timeout():
# Fade out the attribution screen
var tween = create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.5)
tween.tween_callback(change_scene)
func change_scene():
get_tree().change_scene_to_file(MAIN_SCENE_PATH)

@ -0,0 +1,143 @@
extends Node
# This script provides an accurate counter for mission 3's residential buildings
# Instead of polling, it listens for signals when buildings are constructed or demolished
func _ready():
# Wait a moment for the game to initialize
await get_tree().create_timer(1.0).timeout
# Get builder reference
var builder = get_node_or_null("/root/Main/Builder")
if builder:
# Connect to structure placed and removed signals
builder.structure_placed.connect(_on_structure_placed)
builder.structure_removed.connect(_on_structure_removed)
builder.construction_manager.construction_completed.connect(_on_construction_completed)
# Do initial count on mission start
update_mission_3_count()
else:
print("ERROR: Could not find Builder node for signal connections")
# Called when a structure is placed
func _on_structure_placed(structure_index, position):
# We don't need immediate action - residential counts are updated after construction
pass
# Called when a structure is removed
func _on_structure_removed(structure_index, position):
var builder = get_node_or_null("/root/Main/Builder")
if builder and structure_index >= 0 and structure_index < builder.structures.size():
if builder.structures[structure_index].type == 1: # Residential building
print("Residential building demolished at " + str(position) + ", updating mission count")
# Wait one frame to make sure the GridMap is updated
await get_tree().process_frame
# Update the count
update_mission_3_count()
# Called when construction is completed
func _on_construction_completed(position):
update_mission_3_count()
# Updates the mission 3 objective count based on actual residential buildings
func update_mission_3_count():
# Find the mission manager
var mission_manager = get_node_or_null("/root/Main/MissionManager")
if not mission_manager:
print("ERROR: Could not find MissionManager")
return
# Check if we're in mission 3
if mission_manager.current_mission and mission_manager.current_mission.id == "3":
# Count the actual number of residential buildings
var count = count_residential_buildings()
# Get the current objective count
var current_count = 0
for objective in mission_manager.current_mission.objectives:
if objective.type == 3: # BUILD_RESIDENTIAL type
current_count = objective.current_count
break
# Only update if the counts don't match
if current_count != count:
# Reset the objective count to match the actual number
mission_manager.reset_objective_count(3, count) # 3 is the BUILD_RESIDENTIAL type
print("Updated mission 3 objective count to match actual building count: " + str(count))
func count_residential_buildings():
# Find the builder
var builder = get_node_or_null("/root/Main/Builder")
if not builder:
print("ERROR: Could not find Builder")
return 0
# Find the gridmap
var gridmap = builder.gridmap
if not gridmap:
print("ERROR: Could not find GridMap")
return 0
# Count residential buildings in the gridmap
var residential_count = 0
var found_positions = []
print("COUNTING: Starting residential building count")
# First count buildings in the gridmap
for cell in gridmap.get_used_cells():
var structure_index = gridmap.get_cell_item(cell)
if structure_index >= 0 and structure_index < builder.structures.size():
if builder.structures[structure_index].type == 1: # 1 is RESIDENTIAL_BUILDING type
residential_count += 1
found_positions.append(Vector2(cell.x, cell.z))
print("COUNTING: Found residential building in GridMap at " + str(cell))
print("COUNTING: Found " + str(residential_count) + " buildings in GridMap")
# Also count completed buildings that might not be in the gridmap
if builder.has_node("NavRegion3D"):
var nav_region = builder.get_node("NavRegion3D")
var nav_buildings = 0
for child in nav_region.get_children():
if child.name.begins_with("Building_"):
var parts = child.name.split("_")
if parts.size() >= 3:
var x = int(parts[1])
var z = int(parts[2])
var pos = Vector2(x, z)
# Only count if we haven't already counted this position
if not pos in found_positions:
residential_count += 1
nav_buildings += 1
found_positions.append(pos)
print("COUNTING: Found building model in NavRegion3D at " + str(pos))
print("COUNTING: Found " + str(nav_buildings) + " additional buildings in NavRegion3D")
# Also count any buildings under construction
if builder.construction_manager:
var construction_count = 0
for position in builder.construction_manager.construction_sites:
var site = builder.construction_manager.construction_sites[position]
if site.structure_index >= 0 and site.structure_index < builder.structures.size():
if builder.structures[site.structure_index].type == 1 and site.completed: # Only count completed residential buildings
# Check if there's actually a building at this position in the GridMap
var cell_item = builder.gridmap.get_cell_item(position)
if cell_item >= 0: # Only count if there's still a building in the GridMap
var pos = Vector2(position.x, position.z)
if not pos in found_positions:
residential_count += 1
construction_count += 1
found_positions.append(pos)
print("COUNTING: Found completed construction site at " + str(position))
else:
print("COUNTING: Ignoring completed construction site at " + str(position) + " because no building found in GridMap")
print("COUNTING: Found " + str(construction_count) + " buildings from construction sites")
print("COUNTING: Final total - " + str(residential_count) + " residential buildings")
return residential_count