@ -0,0 +1 @@
|
||||
uid://b2d6l2etm3am0
|
||||
@ -0,0 +1 @@
|
||||
uid://bdjvoombhhukk
|
||||
@ -0,0 +1 @@
|
||||
uid://ceafg2rusa5p2
|
||||
@ -0,0 +1 @@
|
||||
uid://cu86ioldldpej
|
||||
@ -0,0 +1 @@
|
||||
uid://bqf4edhi1tdb0
|
||||
@ -0,0 +1 @@
|
||||
uid://dyc1hvpc75tyo
|
||||
@ -0,0 +1 @@
|
||||
uid://b7kek1flywafb
|
||||
@ -0,0 +1 @@
|
||||
uid://ckb1gpnr4l2dg
|
||||
@ -0,0 +1 @@
|
||||
uid://dcmlurxuhkoin
|
||||
@ -0,0 +1 @@
|
||||
uid://dyud43tsdrt5t
|
||||
@ -0,0 +1 @@
|
||||
uid://dy7dau5waslst
|
||||
@ -0,0 +1 @@
|
||||
uid://q4avarxpupic
|
||||
@ -0,0 +1 @@
|
||||
uid://b0mj3f3lyenk7
|
||||
@ -0,0 +1 @@
|
||||
uid://bnt8mrkolp0jt
|
||||
@ -0,0 +1 @@
|
||||
uid://dvutrxphi6utu
|
||||
@ -0,0 +1 @@
|
||||
uid://dngjcu8nwje7i
|
||||
@ -0,0 +1 @@
|
||||
uid://c4q0axlh3wuvq
|
||||
@ -0,0 +1 @@
|
||||
uid://cy2vus6bcoc3j
|
||||
@ -0,0 +1 @@
|
||||
uid://bm3xqrcmg0qm8
|
||||
@ -0,0 +1 @@
|
||||
uid://d0hg6xcrq5m1a
|
||||
@ -0,0 +1 @@
|
||||
uid://dwh3e6y2bwjwf
|
||||
@ -0,0 +1 @@
|
||||
uid://wbrllqhqgp1v
|
||||
@ -0,0 +1 @@
|
||||
uid://7r1kb6dawlo6
|
||||
@ -0,0 +1 @@
|
||||
uid://dyvjo0g47l1ku
|
||||
@ -0,0 +1 @@
|
||||
uid://c4c40cjr0ynh6
|
||||
@ -0,0 +1 @@
|
||||
uid://cppabxoq0wq7q
|
||||
@ -0,0 +1 @@
|
||||
uid://depfqvna057wy
|
||||
@ -0,0 +1 @@
|
||||
uid://cn4c7d3xr6pub
|
||||
@ -0,0 +1 @@
|
||||
uid://dv1unxt5d0hor
|
||||
@ -0,0 +1 @@
|
||||
uid://6qlnwkql2p2d
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cu0g4lm7gaxpf"
|
||||
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":false,"executable":"Starter Kit City Builder","experimentalVK":false,"fileSizes":{"Starter Kit City Builder.pck":14570480,"Starter Kit City Builder.wasm":1620216},"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>
|
||||
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c4u6k4wxw15co"
|
||||
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
|
||||
|
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c1wm7isue5iys"
|
||||
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,63 @@
|
||||
[gd_resource type="Resource" script_class="MissionData" load_steps=4 format=3 uid="uid://bsafjxsrgxcqf"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_dhx01"]
|
||||
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_mum3p"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_c06be"]
|
||||
script = ExtResource("1_dhx01")
|
||||
type = 7
|
||||
target_count = 1
|
||||
current_count = 0
|
||||
description = "Compare two construction companies and determine which one is more efficient for building 40 houses in a week."
|
||||
structure_index = -1
|
||||
completed = false
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_mum3p")
|
||||
id = "3a"
|
||||
title = "Compare Construction Companies"
|
||||
description = "As your city grows, you need to choose the most efficient construction company."
|
||||
objectives = Array[ExtResource("1_dhx01")]([SubResource("Resource_c06be")])
|
||||
rewards = {
|
||||
"cash": 500
|
||||
}
|
||||
next_mission_id = "3"
|
||||
graph_path = "res://images/mission_2.png"
|
||||
full_screen_path = ""
|
||||
intro_text = "Your city is rapidly growing, and you need to build houses to accommodate new residents! Two different construction companies offer to help. Study the company data below, find the unit rates (houses per worker), and determine which company would require fewer workers to build 40 houses in a week. Which company requires fewer workers to build 40 houses in a week? (A or B)"
|
||||
question_text = "Which company requires fewer workers to build 40 houses in a week? (A or B)"
|
||||
correct_answer = "A"
|
||||
feedback_text = "Correct! Company A (City Builders Inc.) would require fewer workers to build 40 houses. Company A builds at a rate of 4 houses per worker per week, while Company B builds at a rate of 3 houses per worker per week. For 40 houses, Company A needs 10 workers while Company B needs about 13.33 workers."
|
||||
incorrect_feedback = "Not quite right. Look carefully at the data for both companies. Compare their rates: Company A builds 4 houses per worker per week, while Company B builds 3 houses per worker per week. Calculate how many workers each would need for 40 houses."
|
||||
company_data = ""
|
||||
power_math_content = ""
|
||||
num_of_user_inputs = 1
|
||||
input_labels = Array[String]([])
|
||||
companion_dialog = {
|
||||
"correct_answer": {
|
||||
"animation": "happy",
|
||||
"duration": 5000,
|
||||
"text": ["Perfect! Company A is more efficient because each worker builds more houses per week.", "Exactly right! You found the company that can build the houses with fewer workers."]
|
||||
},
|
||||
"incorrect_answer": {
|
||||
"animation": "sad",
|
||||
"duration": 5000,
|
||||
"text": ["Let's think about this differently. Look at how many houses each worker can build per week and calculate from there.", "Not quite right. Check the rates carefully: how many houses can one worker build in a week for each company?"]
|
||||
},
|
||||
"mission_completed": {
|
||||
"animation": "happy",
|
||||
"duration": 6000,
|
||||
"text": "Great job selecting the most efficient construction company! Your city will grow faster now."
|
||||
},
|
||||
"mission_started": {
|
||||
"animation": "excited",
|
||||
"duration": 6000,
|
||||
"text": ["It's time to expand our city! We need to choose the most efficient construction company.", "We have two construction companies offering their services. Let's analyze which one is better!"]
|
||||
},
|
||||
"objective_completed_7": {
|
||||
"animation": "happy",
|
||||
"duration": 5000,
|
||||
"text": ["You've solved the construction company problem! That's good mathematical thinking.", "You've made a wise decision based on the data. That's how city planners work!"]
|
||||
}
|
||||
}
|
||||
unlocked_items = Array[String](["res://models/road-corner.glb", "res://models/building-small-b.glb"])
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bnn1b2yg61elu"
|
||||
path.s3tc="res://.godot/imported/colormap.png-c1bc3c3aabeec406ff4b53328583776a.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/colormap.png-c1bc3c3aabeec406ff4b53328583776a.etc2.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://models/Textures/colormap.png"
|
||||
dest_files=["res://.godot/imported/colormap.png-c1bc3c3aabeec406ff4b53328583776a.s3tc.ctex", "res://.godot/imported/colormap.png-c1bc3c3aabeec406ff4b53328583776a.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
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=0
|
||||
@ -0,0 +1 @@
|
||||
uid://dsdxor1cwpqp
|
||||
@ -0,0 +1,92 @@
|
||||
[gd_scene format=3 uid="uid://b81e2k3cevxnb"]
|
||||
|
||||
[node name="DirectUnlockedPanel" type="CanvasLayer"]
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 0.501961)
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -300.0
|
||||
offset_top = -200.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 200.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Control/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "New Items Unlocked!"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="Control/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ItemRow" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer/ItemRow"]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer/ItemRow"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer/ItemRow/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.9, 0.9, 0.2, 1)
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "Item Name"
|
||||
|
||||
[node name="Label2" type="Label" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer/ItemRow/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Item Description"
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="SimpleCloseButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "CLOSE"
|
||||
@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bb04k2hkfmls6"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/mission/improved_unlocked_panel.gd" id="1_r3fws"]
|
||||
|
||||
[node name="ImprovedUnlockedPanel" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_r3fws")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 0.501961)
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -300.0
|
||||
offset_top = -200.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 200.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "New Items Unlocked!"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ItemsContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="CloseButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Close"
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
@ -0,0 +1,95 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cc3c30ioo11if"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/mission/unlocked_items_panel.gd" id="1_j0tih"]
|
||||
[ext_resource type="FontFile" uid="uid://d0cxd77jybrcn" path="res://fonts/lilita_one_regular.ttf" id="2_exmr5"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2q5cr"]
|
||||
bg_color = Color(0.12549, 0.117647, 0.235294, 0.929412)
|
||||
border_width_left = 4
|
||||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color(0.796078, 0.721569, 0.133333, 1)
|
||||
border_blend = true
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
shadow_color = Color(0, 0, 0, 0.45098)
|
||||
shadow_size = 8
|
||||
|
||||
[node name="UnlockedItemsPanel" type="Control"]
|
||||
process_mode = 3
|
||||
z_index = 100
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_j0tih")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 0.501961)
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -300.0
|
||||
offset_top = -200.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 200.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_2q5cr")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 0.921569, 0.231373, 1)
|
||||
theme_override_fonts/font = ExtResource("2_exmr5")
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "New Items Unlocked!"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ItemsContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_top = 8
|
||||
|
||||
[node name="CloseButton" type="Button" parent="PanelContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_hover_color = Color(1, 0.921569, 0.231373, 1)
|
||||
theme_override_colors/font_pressed_color = Color(0.87451, 0.87451, 0.87451, 1)
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_fonts/font = ExtResource("2_exmr5")
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "CONTINUE"
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/MarginContainer/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
@ -0,0 +1,552 @@
|
||||
extends Node
|
||||
class_name AudioBridge
|
||||
|
||||
# This script provides a bridge between the Godot SoundManager
|
||||
# and the React Audio Manager in platform-one
|
||||
|
||||
signal bridge_connected(is_connected)
|
||||
|
||||
var is_connected: bool = false
|
||||
|
||||
func _ready():
|
||||
# Connect to the React sound manager if in web environment
|
||||
if OS.has_feature("web"):
|
||||
connect_to_sound_manager()
|
||||
|
||||
# Try to connect to the React sound manager
|
||||
func connect_to_sound_manager() -> bool:
|
||||
if not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
print("AudioBridge: Attempting to connect to React Sound Manager")
|
||||
|
||||
# Check if the JavaScriptBridge is available
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
print("AudioBridge: JavaScriptBridge singleton not available")
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try to connect using direct function call first
|
||||
var direct_connect_script = """
|
||||
(function() {
|
||||
if (window.connectSoundManager && typeof window.connectSoundManager === 'function') {
|
||||
console.log('AudioBridge: Calling connectSoundManager directly');
|
||||
return window.connectSoundManager();
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
var result = js.eval(direct_connect_script)
|
||||
if result == true:
|
||||
print("AudioBridge: Connected via direct call to connectSoundManager")
|
||||
is_connected = true
|
||||
bridge_connected.emit(true)
|
||||
return true
|
||||
|
||||
# If direct call fails, try via ReactSoundBridge
|
||||
var react_bridge_script = """
|
||||
(function() {
|
||||
if (window.ReactSoundBridge && typeof window.ReactSoundBridge.isAvailable === 'function') {
|
||||
console.log('AudioBridge: Found ReactSoundBridge, checking availability');
|
||||
if (window.ReactSoundBridge.isAvailable()) {
|
||||
console.log('AudioBridge: ReactSoundBridge is available');
|
||||
|
||||
// Get initial state
|
||||
window.ReactSoundBridge.getSoundState();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
result = js.eval(react_bridge_script)
|
||||
if result == true:
|
||||
print("AudioBridge: Connected via ReactSoundBridge")
|
||||
is_connected = true
|
||||
bridge_connected.emit(true)
|
||||
return true
|
||||
|
||||
# If both methods fail, try via postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
console.log('AudioBridge: Attempting to connect via postMessage');
|
||||
|
||||
// Send a message to the parent window
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'get_state',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
|
||||
// Set up a listener if not already
|
||||
if (!window._audioBridgeListener) {
|
||||
window._audioBridgeListener = true;
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data && event.data.type === 'sound_manager_state') {
|
||||
console.log('AudioBridge: Received sound manager state');
|
||||
if (typeof godot_audio_state_callback === 'function') {
|
||||
godot_audio_state_callback(JSON.stringify(event.data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error connecting via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
"""
|
||||
|
||||
// Set up the callback
|
||||
js.set_callback("godot_audio_state_callback", Callable(self, "_on_audio_state_received"))
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
if result == true:
|
||||
print("AudioBridge: Connection attempted via postMessage")
|
||||
# Note: We don't set is_connected here, we wait for the callback
|
||||
return true
|
||||
|
||||
print("AudioBridge: All connection methods failed")
|
||||
return false
|
||||
|
||||
# Play music through the React sound bridge
|
||||
func play_music(sound_name: String) -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.playMusic && typeof window.playMusic === 'function') {
|
||||
return window.playMusic('%s');
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.playMusic === 'function') {
|
||||
return window.ReactSoundBridge.playMusic('%s');
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
""" % [sound_name, sound_name]
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'play_music',
|
||||
soundName: '%s',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending play_music via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
""" % sound_name
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Play sound effect through the React sound bridge
|
||||
func play_sfx(sound_name: String) -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.playSfx && typeof window.playSfx === 'function') {
|
||||
return window.playSfx('%s');
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.playSfx === 'function') {
|
||||
return window.ReactSoundBridge.playSfx('%s');
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
""" % [sound_name, sound_name]
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'play_sfx',
|
||||
soundName: '%s',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending play_sfx via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
""" % sound_name
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Stop music through the React sound bridge
|
||||
func stop_music() -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.stopMusic && typeof window.stopMusic === 'function') {
|
||||
return window.stopMusic();
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.stopMusic === 'function') {
|
||||
return window.ReactSoundBridge.stopMusic();
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'stop_music',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending stop_music via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
"""
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Set music volume through the React sound bridge
|
||||
func set_music_volume(volume: float) -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.setMusicVolume && typeof window.setMusicVolume === 'function') {
|
||||
return window.setMusicVolume(%f);
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.setMusicVolume === 'function') {
|
||||
return window.ReactSoundBridge.setMusicVolume(%f);
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
""" % [volume, volume]
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'set_music_volume',
|
||||
value: %f,
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending set_music_volume via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
""" % volume
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Set SFX volume through the React sound bridge
|
||||
func set_sfx_volume(volume: float) -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.setSfxVolume && typeof window.setSfxVolume === 'function') {
|
||||
return window.setSfxVolume(%f);
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.setSfxVolume === 'function') {
|
||||
return window.ReactSoundBridge.setSfxVolume(%f);
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
""" % [volume, volume]
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'set_sfx_volume',
|
||||
value: %f,
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending set_sfx_volume via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
""" % volume
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Toggle music mute through the React sound bridge
|
||||
func toggle_music_mute() -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.toggleMusicMute && typeof window.toggleMusicMute === 'function') {
|
||||
return window.toggleMusicMute();
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.toggleMusicMute === 'function') {
|
||||
return window.ReactSoundBridge.toggleMusicMute();
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'toggle_music_mute',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending toggle_music_mute via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
"""
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Toggle SFX mute through the React sound bridge
|
||||
func toggle_sfx_mute() -> bool:
|
||||
if not is_connected or not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.toggleSfxMute && typeof window.toggleSfxMute === 'function') {
|
||||
return window.toggleSfxMute();
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.toggleSfxMute === 'function') {
|
||||
return window.ReactSoundBridge.toggleSfxMute();
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'toggle_sfx_mute',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending toggle_sfx_mute via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
"""
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Request sound state from the React sound bridge
|
||||
func get_sound_state() -> bool:
|
||||
if not OS.has_feature("web"):
|
||||
return false
|
||||
|
||||
if not Engine.has_singleton("JavaScriptBridge"):
|
||||
return false
|
||||
|
||||
var js = Engine.get_singleton("JavaScriptBridge")
|
||||
|
||||
# Set up the callback if not already
|
||||
js.set_callback("godot_audio_state_callback", Callable(self, "_on_audio_state_received"))
|
||||
|
||||
# Try direct function call first
|
||||
var direct_call_script = """
|
||||
(function() {
|
||||
if (window.getSoundState && typeof window.getSoundState === 'function') {
|
||||
var state = window.getSoundState();
|
||||
if (typeof godot_audio_state_callback === 'function') {
|
||||
godot_audio_state_callback(JSON.stringify(state));
|
||||
}
|
||||
return true;
|
||||
} else if (window.ReactSoundBridge && typeof window.ReactSoundBridge.getSoundState === 'function') {
|
||||
return window.ReactSoundBridge.getSoundState();
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
"""
|
||||
|
||||
var result = js.eval(direct_call_script)
|
||||
if result == true:
|
||||
return true
|
||||
|
||||
# If direct call fails, try postMessage
|
||||
var post_message_script = """
|
||||
(function() {
|
||||
try {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage({
|
||||
type: 'sound_manager',
|
||||
action: 'get_state',
|
||||
source: 'godot-game',
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('AudioBridge: Error sending get_state via postMessage', e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
"""
|
||||
|
||||
result = js.eval(post_message_script)
|
||||
return result == true
|
||||
|
||||
# Called when sound state is received from React
|
||||
func _on_audio_state_received(state_json: String):
|
||||
print("AudioBridge: Received audio state: ", state_json)
|
||||
|
||||
# Parse JSON
|
||||
var json = JSON.new()
|
||||
var error = json.parse(state_json)
|
||||
|
||||
if error == OK:
|
||||
var state = json.get_data()
|
||||
|
||||
# Mark the bridge as connected
|
||||
if not is_connected:
|
||||
is_connected = true
|
||||
bridge_connected.emit(true)
|
||||
|
||||
# Emit the data for other components to use
|
||||
emit_signal("sound_state_received", state)
|
||||
else:
|
||||
print("AudioBridge: Error parsing audio state JSON: ", error)
|
||||
@ -0,0 +1,91 @@
|
||||
extends Node
|
||||
|
||||
# This is a helper script to be attached to mission_manager to handle the direct unlocked panel
|
||||
|
||||
# Simplified function to show the unlocked panel without using signals
|
||||
func show_direct_unlocked_panel(structures, callback_node, callback_method):
|
||||
print("Showing direct unlocked panel")
|
||||
|
||||
# Load the scene
|
||||
var scene = load("res://scenes/direct_unlocked_panel.tscn")
|
||||
if not scene:
|
||||
push_error("Failed to load direct_unlocked_panel.tscn")
|
||||
return
|
||||
|
||||
# Instantiate
|
||||
var instance = scene.instantiate()
|
||||
get_tree().root.add_child(instance)
|
||||
|
||||
# Get the main nodes
|
||||
var panel = instance.get_node("Control")
|
||||
var close_button = instance.get_node("Control/PanelContainer/MarginContainer/VBoxContainer/SimpleCloseButton")
|
||||
var items_container = instance.get_node("Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer")
|
||||
|
||||
# Connect close button directly
|
||||
close_button.pressed.connect(func():
|
||||
print("Direct panel close button pressed")
|
||||
instance.queue_free()
|
||||
get_tree().paused = false
|
||||
callback_node.call(callback_method)
|
||||
)
|
||||
|
||||
# Clear sample content
|
||||
for child in items_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# Add each structure
|
||||
for structure in structures:
|
||||
# Create item row
|
||||
var row = HBoxContainer.new()
|
||||
row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
items_container.add_child(row)
|
||||
|
||||
# Add texture
|
||||
var tex_rect = TextureRect.new()
|
||||
tex_rect.custom_minimum_size = Vector2(100, 100)
|
||||
tex_rect.expand_mode = TextureRect.EXPAND_KEEP_ASPECT
|
||||
tex_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
row.add_child(tex_rect)
|
||||
|
||||
# Add info container
|
||||
var info = VBoxContainer.new()
|
||||
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row.add_child(info)
|
||||
|
||||
# Add name
|
||||
var name_label = Label.new()
|
||||
name_label.add_theme_color_override("font_color", Color(0.9, 0.9, 0.2))
|
||||
name_label.add_theme_font_size_override("font_size", 18)
|
||||
name_label.text = get_structure_name(structure)
|
||||
info.add_child(name_label)
|
||||
|
||||
# Add description
|
||||
var desc_label = Label.new()
|
||||
desc_label.text = structure.description if structure.has_method("description") else "No description"
|
||||
desc_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
info.add_child(desc_label)
|
||||
|
||||
# Add separator
|
||||
var separator = HSeparator.new()
|
||||
items_container.add_child(separator)
|
||||
|
||||
# Pause game
|
||||
get_tree().paused = true
|
||||
|
||||
# Get structure name
|
||||
func get_structure_name(structure):
|
||||
if structure.has_method("model") and structure.model:
|
||||
var path = structure.model.resource_path
|
||||
var filename = path.get_file().get_basename()
|
||||
|
||||
# Convert kebab-case to Title Case
|
||||
var words = filename.split("-")
|
||||
var title_case = ""
|
||||
|
||||
for word in words:
|
||||
if word.length() > 0:
|
||||
title_case += word[0].to_upper() + word.substr(1) + " "
|
||||
|
||||
return title_case.strip_edges()
|
||||
|
||||
return "Unknown Structure"
|
||||
@ -0,0 +1,62 @@
|
||||
extends Node
|
||||
|
||||
# Simple function to handle structure unlocking for missions
|
||||
static func process_structures(structures, mission_id):
|
||||
for structure in structures:
|
||||
# Default is locked
|
||||
structure.unlocked = false
|
||||
|
||||
# Handle basic structures (always available)
|
||||
if basic_structure(structure):
|
||||
structure.unlocked = true
|
||||
|
||||
# Handle mission-specific structures
|
||||
if mission_id == "1":
|
||||
# Mission 1: Unlock residential buildings
|
||||
if residential_building(structure):
|
||||
structure.unlocked = true
|
||||
|
||||
elif mission_id == "2" or mission_id == "3":
|
||||
# Missions 2-3: Unlock curved roads and decoration
|
||||
if curved_road(structure) or decoration(structure):
|
||||
structure.unlocked = true
|
||||
|
||||
elif mission_id == "4" or mission_id == "5":
|
||||
# Missions 4-5: Unlock power plants
|
||||
if power_plant(structure):
|
||||
structure.unlocked = true
|
||||
|
||||
# Simple helper functions to categorize structures
|
||||
static func basic_structure(structure):
|
||||
var path = structure.model.resource_path
|
||||
return path.contains("road-straight") or path.contains("pavement")
|
||||
|
||||
static func residential_building(structure):
|
||||
return structure.model.resource_path.contains("building-small-a")
|
||||
|
||||
static func curved_road(structure):
|
||||
return structure.model.resource_path.contains("road-corner")
|
||||
|
||||
static func decoration(structure):
|
||||
return structure.model.resource_path.contains("grass-trees")
|
||||
|
||||
static func power_plant(structure):
|
||||
return structure.model.resource_path.contains("power_plant")
|
||||
|
||||
# Ensure builder has an unlocked structure selected
|
||||
static func select_unlocked(builder):
|
||||
var found = false
|
||||
|
||||
# Look for an unlocked structure
|
||||
for i in range(builder.structures.size()):
|
||||
if builder.structures[i].unlocked:
|
||||
builder.index = i
|
||||
builder.update_structure()
|
||||
found = true
|
||||
break
|
||||
|
||||
# If nothing is unlocked, unlock the first structure
|
||||
if not found and builder.structures.size() > 0:
|
||||
builder.structures[0].unlocked = true
|
||||
builder.index = 0
|
||||
builder.update_structure()
|
||||
@ -0,0 +1,66 @@
|
||||
extends Node
|
||||
|
||||
# This is a helper function to handle structure unlocking
|
||||
# We're putting it in a separate file to avoid syntax issues in mission_manager.gd
|
||||
|
||||
# Unlocks basic structures and locks special ones
|
||||
func process_structures(structures_array):
|
||||
# Start with all unlocked
|
||||
for structure in structures_array:
|
||||
# Basic structures are always unlocked
|
||||
if basic_structure(structure):
|
||||
structure.unlocked = true
|
||||
# Special structures start locked unless mission-specific
|
||||
elif special_structure(structure):
|
||||
structure.unlocked = false
|
||||
else:
|
||||
# Default to unlocked for other structures
|
||||
structure.unlocked = true
|
||||
|
||||
# Check if this is a mission-dependent structure type that should be unlocked
|
||||
func unlock_by_mission(structures_array, mission_id):
|
||||
if mission_id == "1":
|
||||
# Only basic structures in mission 1
|
||||
return
|
||||
|
||||
if mission_id == "2" or mission_id == "3":
|
||||
# Unlock decorations and curved roads
|
||||
for structure in structures_array:
|
||||
if structure.model.resource_path.contains("road-corner") or structure.model.resource_path.contains("grass-trees-tall"):
|
||||
structure.unlocked = true
|
||||
|
||||
if mission_id == "4" or mission_id == "5":
|
||||
# Unlock power plants
|
||||
for structure in structures_array:
|
||||
if structure.model.resource_path.contains("power_plant"):
|
||||
structure.unlocked = true
|
||||
|
||||
# Check if a structure is one of the basic types (always available)
|
||||
func basic_structure(structure):
|
||||
return (structure.model.resource_path.contains("road-straight") or
|
||||
structure.model.resource_path.contains("building-small-a") or
|
||||
structure.model.resource_path.contains("pavement") or
|
||||
structure.model.resource_path.contains("grass.glb"))
|
||||
|
||||
# Check if a structure is a special type (requires unlocking)
|
||||
func special_structure(structure):
|
||||
return (structure.model.resource_path.contains("road-corner") or
|
||||
structure.model.resource_path.contains("grass-trees-tall") or
|
||||
structure.model.resource_path.contains("power_plant"))
|
||||
|
||||
# Ensure an unlocked structure is selected
|
||||
func select_unlocked_structure(builder):
|
||||
# Find the first unlocked structure
|
||||
var found_unlocked = false
|
||||
for i in range(builder.structures.size()):
|
||||
if builder.structures[i].unlocked:
|
||||
builder.index = i
|
||||
builder.update_structure()
|
||||
found_unlocked = true
|
||||
break
|
||||
|
||||
# If no structures are unlocked, unlock a basic one
|
||||
if not found_unlocked and builder.structures.size() > 0:
|
||||
builder.structures[0].unlocked = true
|
||||
builder.index = 0
|
||||
builder.update_structure()
|
||||
@ -0,0 +1,197 @@
|
||||
extends Control
|
||||
|
||||
# Signal emitted when the panel is closed
|
||||
signal closed
|
||||
|
||||
# Reference to the builder node to access all structures
|
||||
var builder
|
||||
|
||||
func _ready():
|
||||
# Make sure this control stays on top and blocks input
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
|
||||
# Initially hide the panel - will be shown when called
|
||||
visible = false
|
||||
|
||||
# Find the builder reference to access structure data
|
||||
builder = get_node_or_null("/root/Main/Builder")
|
||||
|
||||
print("UnlockedItemsPanel ready")
|
||||
|
||||
func setup(unlocked_structures):
|
||||
print("Setting up panel with " + str(unlocked_structures.size()) + " structures")
|
||||
|
||||
var items_container = $PanelContainer/VBoxContainer/ScrollContainer/ItemsContainer
|
||||
if not items_container:
|
||||
push_error("Items container not found!")
|
||||
return
|
||||
|
||||
# Clear any previous items
|
||||
for child in items_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# Debug info about structures
|
||||
for i in range(unlocked_structures.size()):
|
||||
if unlocked_structures[i].model:
|
||||
print("Structure " + str(i) + ": " + unlocked_structures[i].model.resource_path)
|
||||
if "title" in unlocked_structures[i]:
|
||||
print(" Title: " + unlocked_structures[i].title)
|
||||
if "description" in unlocked_structures[i]:
|
||||
print(" Description: " + unlocked_structures[i].description)
|
||||
if "thumbnail" in unlocked_structures[i]:
|
||||
print(" Thumbnail: " + unlocked_structures[i].thumbnail)
|
||||
else:
|
||||
print("Structure " + str(i) + ": No model")
|
||||
|
||||
# Add each unlocked structure
|
||||
for structure in unlocked_structures:
|
||||
# Skip structures without models
|
||||
if not structure.model:
|
||||
print("Skipping structure without model")
|
||||
continue
|
||||
|
||||
# Create the row container
|
||||
var row = HBoxContainer.new()
|
||||
row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
items_container.add_child(row)
|
||||
|
||||
# Add structure thumbnail
|
||||
var icon = TextureRect.new()
|
||||
icon.custom_minimum_size = Vector2(64, 64)
|
||||
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
icon.expand_mode = TextureRect.EXPAND_FIT_WIDTH
|
||||
|
||||
# Try to get thumbnail from structure thumbnail field
|
||||
if "thumbnail" in structure and structure.thumbnail and structure.thumbnail != "Thumbnail":
|
||||
# Check if the thumbnail path is valid
|
||||
if ResourceLoader.exists(structure.thumbnail):
|
||||
print("Loading thumbnail from path: " + structure.thumbnail)
|
||||
icon.texture = load(structure.thumbnail)
|
||||
else:
|
||||
print("Thumbnail path invalid: " + structure.thumbnail)
|
||||
# Fall back to getting thumbnail from model
|
||||
var model_thumbnail = get_structure_thumbnail(structure)
|
||||
if model_thumbnail:
|
||||
icon.texture = model_thumbnail
|
||||
else:
|
||||
# Fall back to getting thumbnail from model
|
||||
var model_thumbnail = get_structure_thumbnail(structure)
|
||||
if model_thumbnail:
|
||||
icon.texture = model_thumbnail
|
||||
|
||||
# Apply type-based colors for empty thumbnails
|
||||
if not icon.texture:
|
||||
if structure.type == Structure.StructureType.ROAD:
|
||||
# Use a road icon (fallback)
|
||||
icon.modulate = Color(0.7, 0.7, 0.7)
|
||||
elif structure.type == Structure.StructureType.RESIDENTIAL_BUILDING:
|
||||
# Use building color (fallback)
|
||||
icon.modulate = Color(0.2, 0.6, 0.9)
|
||||
elif structure.type == Structure.StructureType.POWER_PLANT:
|
||||
# Use power plant color (fallback)
|
||||
icon.modulate = Color(0.8, 0.3, 0.3)
|
||||
|
||||
row.add_child(icon)
|
||||
|
||||
# Info container for name and description
|
||||
var info = VBoxContainer.new()
|
||||
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row.add_child(info)
|
||||
|
||||
# Structure name - use title field if available
|
||||
var name_label = Label.new()
|
||||
if "title" in structure and structure.title:
|
||||
name_label.text = structure.title
|
||||
else:
|
||||
name_label.text = get_structure_name(structure)
|
||||
name_label.add_theme_font_size_override("font_size", 18)
|
||||
name_label.add_theme_color_override("font_color", Color(0.9, 0.9, 0.2))
|
||||
info.add_child(name_label)
|
||||
|
||||
# Structure description
|
||||
var desc = Label.new()
|
||||
if "description" in structure and structure.description and structure.description != "Description":
|
||||
desc.text = structure.description
|
||||
else:
|
||||
desc.text = "A new structure for your city!"
|
||||
desc.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
info.add_child(desc)
|
||||
|
||||
# Add separator if not the last item
|
||||
if structure != unlocked_structures[-1]:
|
||||
var sep = HSeparator.new()
|
||||
items_container.add_child(sep)
|
||||
|
||||
func show_panel():
|
||||
print("show_panel() called")
|
||||
visible = true
|
||||
# Ensure the game is paused when showing this panel
|
||||
# This prevents learning panels from appearing on top of this one
|
||||
get_tree().paused = true
|
||||
|
||||
# Set higher z-index to ensure it's on top
|
||||
z_index = 100
|
||||
|
||||
# Notify mission manager if available
|
||||
var mission_manager = get_node_or_null("/root/MissionManager")
|
||||
if mission_manager and mission_manager.has_method("_on_unlocked_panel_shown"):
|
||||
mission_manager._on_unlocked_panel_shown()
|
||||
|
||||
func hide_panel():
|
||||
print("hide_panel() called")
|
||||
visible = false
|
||||
|
||||
# We'll let the mission manager handle unpausing in its closed signal handler
|
||||
# This ensures proper handling of the mission queue
|
||||
# get_tree().paused = false
|
||||
|
||||
func _on_close_button_pressed():
|
||||
print("Close button pressed!")
|
||||
hide_panel()
|
||||
closed.emit()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
# New function to show all unlocked structures
|
||||
func show_all_unlocked_structures():
|
||||
if not builder:
|
||||
builder = get_node_or_null("/root/Main/Builder")
|
||||
if not builder:
|
||||
push_error("Cannot find Builder node to get structures")
|
||||
return
|
||||
|
||||
# Create an array to hold all unlocked structures
|
||||
var all_unlocked = []
|
||||
|
||||
# Get all unlocked structures from the builder
|
||||
for structure in builder.structures:
|
||||
if "unlocked" in structure and structure.unlocked:
|
||||
all_unlocked.append(structure)
|
||||
|
||||
print("Found " + str(all_unlocked.size()) + " unlocked structures")
|
||||
|
||||
# Call the regular setup function with all unlocked structures
|
||||
setup(all_unlocked)
|
||||
show_panel()
|
||||
|
||||
# Try to get a thumbnail for the structure
|
||||
func get_structure_thumbnail(structure):
|
||||
var structure_path = structure.model.resource_path
|
||||
|
||||
# Check if we can find a colormap texture for this model
|
||||
var colormap_path = structure_path.get_basename() + "_colormap.png"
|
||||
if ResourceLoader.exists(colormap_path):
|
||||
return load(colormap_path)
|
||||
|
||||
# Default case - no icon found
|
||||
return null
|
||||
|
||||
func get_structure_name(structure):
|
||||
var file_name = structure.model.resource_path.get_file().get_basename()
|
||||
var names = file_name.split("-")
|
||||
var title = ""
|
||||
|
||||
for part in names:
|
||||
if part.length() > 0:
|
||||
title += part[0].to_upper() + part.substr(1) + " "
|
||||
|
||||
return title.strip_edges()
|
||||
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://da2i0hcjhukce"
|
||||
path="res://.godot/imported/checkbox.png-56c7f74df246924c046c9d85864db5f4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/checkbox.png"
|
||||
dest_files=["res://.godot/imported/checkbox.png-56c7f74df246924c046c9d85864db5f4.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,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://om3jgm014lds"
|
||||
path="res://.godot/imported/checkbox_outline.png-405c555cfeeccf96424a8a975eb5d83e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/checkbox_outline.png"
|
||||
dest_files=["res://.godot/imported/checkbox_outline.png-405c555cfeeccf96424a8a975eb5d83e.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
|
||||
|
After Width: | Height: | Size: 88 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://3b76xyttegyj"
|
||||
path="res://.godot/imported/grass.png-24ac03dd3c22df56f9dd063178e4c133.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/residential/grass.png"
|
||||
dest_files=["res://.godot/imported/grass.png-24ac03dd3c22df56f9dd063178e4c133.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
|
||||
|
After Width: | Height: | Size: 177 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://0ghyp8mkxgkq"
|
||||
path="res://.godot/imported/residential-building-red.png-5577575bda87e15a7be34320a8e58f3e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/residential/residential-building-red.png"
|
||||
dest_files=["res://.godot/imported/residential-building-red.png-5577575bda87e15a7be34320a8e58f3e.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
|
||||
|
After Width: | Height: | Size: 143 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cdcq7nj3ib6hc"
|
||||
path="res://.godot/imported/trees.png-121171095056bf555d97c70e7420e8e1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/residential/trees.png"
|
||||
dest_files=["res://.godot/imported/trees.png-121171095056bf555d97c70e7420e8e1.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
|
||||
|
After Width: | Height: | Size: 77 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cfhhatnsmydxg"
|
||||
path="res://.godot/imported/road-corner.png-d81fc439b542f9c192ba02b016c22ff3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/roads/road-corner.png"
|
||||
dest_files=["res://.godot/imported/road-corner.png-d81fc439b542f9c192ba02b016c22ff3.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
|
||||