feat(background): add other in-game backgrouds (2/2)

This commit is contained in:
Haoyu Xu
2023-01-19 14:18:01 -05:00
parent 5669f78009
commit f18b5a6116
10 changed files with 199 additions and 39 deletions

View File

@@ -8,12 +8,14 @@ export default class ProjectJson {
#operatorName
#operatorSourceFolder
#operatorShareFolder
#assets
constructor(config, operatorName, __dirname, operatorShareFolder) {
constructor(config, operatorName, __dirname, operatorShareFolder, assets) {
this.#config = config
this.#operatorName = operatorName
this.#operatorSourceFolder = path.join(__dirname, this.#config.folder.operator)
this.#operatorShareFolder = operatorShareFolder
this.#assets = assets
}
async load() {
@@ -47,25 +49,144 @@ export default class ProjectJson {
...this.#json.general,
properties: {
...this.#json.general.properties,
paddingbottom: {
...this.#json.general.properties.paddingbottom,
value: this.#config.operators[this.#operatorName].viewport_bottom
},
paddingleft: {
...this.#json.general.properties.paddingleft,
value: this.#config.operators[this.#operatorName].viewport_left
},
paddingright: {
...this.#json.general.properties.paddingright,
value: this.#config.operators[this.#operatorName].viewport_right
},
paddingtop: {
...this.#json.general.properties.paddingtop,
value: this.#config.operators[this.#operatorName].viewport_top
},
...this.#properties
}
},
}
}
get #properties() {
const properties = [
{
key: "notice",
value: {
text: "ui_logo_notice",
type: "textinput",
"value": "Set FPS target in Settings"
}
}, {
key: "logo",
value: {
text: "ui_operator_logo",
type: "bool",
value: true
}
}, {
key: "logoimage",
value: {
text: "ui_logo_image",
type: "file",
value: "",
condition: "logo.value == true",
}
}, {
key: "logoratio",
value: {
text: "ui_logo_ratio",
type: "slider",
value: 61.8,
condition: "logo.value == true",
fraction: true,
max: 100,
min: 0,
precision: 2,
step: 0.1,
}
}, {
key: "logoopacity",
value: {
text: "ui_logo_opacity",
type: "slider",
value: 30,
condition: "logo.value == true",
fraction: false,
max: 100,
min: 0,
}
}, {
key: "defaultbackground",
value: {
text: "ui_default_background",
type: "combo",
value: this.#assets.backgrounds[0],
fraction: false,
max: 100,
min: 0,
options: this.#assets.backgrounds.map((b) => {
return {
"label": b,
"value": b
}
})
}
}, {
key: "background",
value: {
text: "ui_custom_background",
type: "file",
value: "",
}
}, {
key: "position",
value: {
text: "ui_position",
type: "bool",
value: false,
}
}, {
key: "paddingleft",
value: {
text: "ui_position_padding_left",
type: "slider",
value: this.#config.operators[this.#operatorName].viewport_left,
condition: "position.value == true",
fraction: false,
max: 100,
min: -100,
}
}, {
key: "paddingright",
value: {
text: "ui_position_padding_right",
type: "slider",
value: this.#config.operators[this.#operatorName].viewport_right,
condition: "position.value == true",
fraction: false,
max: 100,
min: -100,
}
}, {
key: "paddingtop",
value: {
text: "ui_position_padding_top",
type: "slider",
value: this.#config.operators[this.#operatorName].viewport_top,
condition: "position.value == true",
fraction: false,
max: 100,
min: -100,
}
}, {
key: "paddingbottom",
value: {
text: "ui_position_padding_bottom",
type: "slider",
value: this.#config.operators[this.#operatorName].viewport_bottom,
condition: "position.value == true",
fraction: false,
max: 100,
min: -100,
}
}
]
const output = {}
for (let i = 0; i < properties.length; i++) {
output[properties[i].key] = {
index: i,
order: 100 + i,
...properties[i].value
}
}
return output
}
}