diff --git a/extension/main.js b/extension/main.js
index 7e57ee2c..a14d0af7 100644
--- a/extension/main.js
+++ b/extension/main.js
@@ -44,6 +44,7 @@ function getSettings() {
CC_WORKER_ASSET_PIPELINE: getMacroBooleanValue(content, "CC_WORKER_ASSET_PIPELINE"),
CC_WORKER_AUDIO_SYSTEM: getMacroBooleanValue(content, "CC_WORKER_AUDIO_SYSTEM"),
CC_WORKER_SCHEDULER: getMacroBooleanValue(content, "CC_WORKER_SCHEDULER"),
+ CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: getMacroIntegerValue(content, "CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL"),
};
}
}
@@ -55,7 +56,7 @@ function syncSettingsToSubWorker() {
for (const key in result) {
if (key !== "code") {
- content = setMacroBooleanValue(content, key, result[key]);
+ content = setMacroValue(content, key, result[key]);
}
}
@@ -66,7 +67,7 @@ function syncSettingsToSubWorker() {
function setSettings(macro, value) {
{
const content = fs.readFileSync(engineWechatMinigameWorkerMainMacroPath, { encoding: "utf-8" });
- fs.writeFileSync(engineWechatMinigameWorkerMainMacroPath, setMacroBooleanValue(content, macro, value));
+ fs.writeFileSync(engineWechatMinigameWorkerMainMacroPath, setMacroValue(content, macro, value));
}
checkAndModifyWorkerFiles();
@@ -79,10 +80,24 @@ function getMacroBooleanValue(text, macro) {
return match ? match[1] === 'true' : null;
}
-function setMacroBooleanValue(text, macro, value) {
- const regex = new RegExp(`globalThis\\.${macro}\\s*=\\s*(true|false);`);
- const replacement = `globalThis.${macro} = ${value};`;
- return text.replace(regex, replacement);
+function getMacroIntegerValue(text, macro) {
+ const regex = new RegExp(`globalThis\\.${macro}\\s*=\\s*(\\d+);`);
+ const match = text.match(regex);
+ return match ? parseInt(match[1]) : null;
+}
+
+function setMacroValue(text, macro, value) {
+ if (typeof value === "number") {
+ const regex = new RegExp(`globalThis\\.${macro}\\s*=\\s*(\\d+);`);
+ const replacement = `globalThis.${macro} = ${value};`;
+ return text.replace(regex, replacement);
+ } else if (typeof value === "boolean") {
+ const regex = new RegExp(`globalThis\\.${macro}\\s*=\\s*(true|false);`);
+ const replacement = `globalThis.${macro} = ${value};`;
+ return text.replace(regex, replacement);
+ } else {
+ Editor.error(`setMacroValue: unknown value: ${value}`);
+ }
}
function checkAndModifyWorkerFiles() {
diff --git a/extension/panel/index.js b/extension/panel/index.js
index 791a324c..72463d9e 100644
--- a/extension/panel/index.js
+++ b/extension/panel/index.js
@@ -24,8 +24,13 @@ Editor.Panel.extend({
-
+
+
+
+
+
+
@@ -44,6 +49,8 @@ Editor.Panel.extend({
thread_asset_pipeline_checkbox: '#tapc',
thread_audio_system: '#fs',
thread_audio_system_checkbox: '#fsc',
+ thread_audio_system_interval: '#fsi',
+ thread_audio_system_interval_input: '#fsii',
thread_scheduler: '#ts',
thread_scheduler_checkbox: '#tsc',
},
@@ -63,6 +70,7 @@ Editor.Panel.extend({
this.$thread_debug_checkbox.checked = data.CC_WORKER_DEBUG;
this.$thread_asset_pipeline_checkbox.checked = data.CC_WORKER_ASSET_PIPELINE;
this.$thread_audio_system_checkbox.checked = data.CC_WORKER_AUDIO_SYSTEM;
+ this.$thread_audio_system_interval_input.value = data.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL;
this.$thread_scheduler_checkbox.checked = data.CC_WORKER_SCHEDULER;
this.$thread_debug_checkbox.addEventListener('change', () => {
@@ -73,8 +81,19 @@ Editor.Panel.extend({
this.setSettings("CC_WORKER_ASSET_PIPELINE", this.$thread_asset_pipeline_checkbox.checked);
});
+ const onAudioSystemEnableChange = (enabled) => {
+ this.$thread_audio_system_interval_input.disabled = !enabled;
+ };
+ onAudioSystemEnableChange(this.$thread_asset_pipeline_checkbox.checked);
+
this.$thread_audio_system_checkbox.addEventListener('change', () => {
- this.setSettings("CC_WORKER_AUDIO_SYSTEM", this.$thread_audio_system_checkbox.checked);
+ const enabled = this.$thread_audio_system_checkbox.checked;
+ onAudioSystemEnableChange(enabled);
+ this.setSettings("CC_WORKER_AUDIO_SYSTEM", enabled);
+ });
+
+ this.$thread_audio_system_interval_input.addEventListener('confirm', () => {
+ this.setSettings("CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL", this.$thread_audio_system_interval_input.value);
});
this.$thread_scheduler_checkbox.addEventListener('change', () => {