///|
pub struct RuntimePreset {
name : String
target : RuntimeTarget
extension : String
indent : Int
include_diagnostics : Bool
include_slices : Bool
} derive(Debug, Eq, ToJson, FromJson)
///|
pub fn RuntimePreset::options(self : RuntimePreset) -> RuntimeOptions {
{
target: self.target,
indent: self.indent,
include_diagnostics: self.include_diagnostics,
include_slices: self.include_slices,
}
}
///|
pub fn RuntimePreset::adapter(self : RuntimePreset) -> RuntimeAdapter {
RuntimeAdapter::for_target(self.target)
}
///|
pub fn RuntimePreset::to_json_string(
self : RuntimePreset,
indent? : Int = 2,
) -> String {
ToJson::to_json(self).stringify(indent~)
}
///|
pub fn runtime_presets() -> Array[RuntimePreset] {
[
{
name: "godot-debug",
target: Godot,
extension: "tres",
indent: 2,
include_diagnostics: true,
include_slices: true,
},
{
name: "godot-release",
target: Godot,
extension: "tres",
indent: 0,
include_diagnostics: false,
include_slices: false,
},
{
name: "phaser-debug",
target: Phaser,
extension: "json",
indent: 2,
include_diagnostics: true,
include_slices: true,
},
{
name: "phaser-release",
target: Phaser,
extension: "json",
indent: 0,
include_diagnostics: false,
include_slices: false,
},
{
name: "moonbit-module",
target: MoonBit,
extension: "mbt.json",
indent: 2,
include_diagnostics: true,
include_slices: true,
},
{
name: "portable-json",
target: Generic,
extension: "json",
indent: 2,
include_diagnostics: true,
include_slices: true,
},
]
}
///|
pub fn runtime_preset_named(name : String) -> RuntimePreset? {
match runtime_presets().search_by(fn(preset) { preset.name == name }) {
Some(index) => Some(runtime_presets()[index])
None => None
}
}
///|
pub fn runtime_preset_count() -> Int {
runtime_presets().length()
}
///|
pub fn runtime_presets_for(target : RuntimeTarget) -> Array[RuntimePreset] {
runtime_presets().filter(fn(preset) { preset.target == target })
}