|
|
|
@ -49,11 +49,11 @@ pub mod constants {
|
|
|
|
|
/// The `EngineOptionType` type used to indicate what type of option the GUI should display
|
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq)] |
|
|
|
|
pub enum EngineOptionType { |
|
|
|
|
Check("check"), |
|
|
|
|
Spin("spin"), |
|
|
|
|
Combo("combo"), |
|
|
|
|
Button("button"), |
|
|
|
|
TypeString("string"), // `String` is a reserved word so `TypeString` is substituted
|
|
|
|
|
Check, |
|
|
|
|
Spin, |
|
|
|
|
Combo, |
|
|
|
|
Button, |
|
|
|
|
TypeString, // `String` is a reserved word so `TypeString` is substituted
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, PartialOrd)] |
|
|
|
@ -68,10 +68,10 @@ pub enum EngineOptionData {
|
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] |
|
|
|
|
/// The `EngineOptionDataType` type used to indicate the type of the `EngineOption` setting
|
|
|
|
|
pub enum EngineOptionDataType { |
|
|
|
|
DefaultVal("default"), // `Default` is reserved so `DefaultVal` is used
|
|
|
|
|
Min("min"), |
|
|
|
|
Max("max"), |
|
|
|
|
Var("var"), |
|
|
|
|
DefaultVal, // `Default` is reserved so `DefaultVal` is used
|
|
|
|
|
Min, |
|
|
|
|
Max, |
|
|
|
|
Var, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)] |
|
|
|
@ -91,14 +91,34 @@ impl EngineOption {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn option_string(&self) -> String { |
|
|
|
|
let option_data_string: String; |
|
|
|
|
|
|
|
|
|
for dt, eod in &self.option_data { |
|
|
|
|
option_data_string = option_data_string + format!("{} {}", dt, eod); |
|
|
|
|
let mut option_data_string: String = "".to_owned(); |
|
|
|
|
|
|
|
|
|
for (ref dt, ref eod) in &self.option_data { |
|
|
|
|
let dts = match dt { |
|
|
|
|
EngineOptionDataType::DefaultVal => "default", |
|
|
|
|
EngineOptionDataType::Min => "min", |
|
|
|
|
EngineOptionDataType::Max => "max", |
|
|
|
|
EngineOptionDataType::Var => "var", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let res = match eod { |
|
|
|
|
EngineOptionData::Int(v) => v.to_string(), |
|
|
|
|
EngineOptionData::Float(v) => v.to_string(), |
|
|
|
|
EngineOptionData::Text(v) => v.cloned(), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
option_data_string.push_str(&format!("{} {:?} ", dts, res)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let ots = match self.option_type { |
|
|
|
|
EngineOptionType::Check => "check", |
|
|
|
|
EngineOptionType::Spin => "spin", |
|
|
|
|
EngineOptionType::Combo => "combo", |
|
|
|
|
EngineOptionType::Button => "button", |
|
|
|
|
EngineOptionType::TypeString => "string", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
format!("{} {} {} {} {} {}\n", commands::OPTION, commands::OPTIONNAME, self.name, |
|
|
|
|
commands::TYPE, option_type, option_data_string); |
|
|
|
|
commands::TYPE, ots, option_data_string) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|