Browse Source

first pass at option_string

ag-yep
Taylor Bockman 7 years ago
parent
commit
c176d390bd
  1. 7
      src/commands.rs
  2. 35
      src/options.rs

7
src/commands.rs

@ -88,3 +88,10 @@ pub const INFO: &'static str = "info";
/// OPTION tells the GUI which parameters can be changed in the engine
pub const OPTION: &'static str = "option";
/// OPTIONNAME tells the GUI which option name is being sent
pub const OPTIONNAME: &'static str = "name";
/// TYPE tells the GUI the type of the option
pub const TYPE: &'static str = "type";

35
src/options.rs

@ -4,6 +4,7 @@
//! of the nicer parts of typechecking.
use std::collections::HashMap;
use commands;
pub mod constants {
@ -48,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,
Spin,
Combo,
Button,
TypeString, // `String` is a reserved word so `TypeString` is substituted
Check("check"),
Spin("spin"),
Combo("combo"),
Button("button"),
TypeString("string"), // `String` is a reserved word so `TypeString` is substituted
}
#[derive(Clone, Debug, PartialEq, PartialOrd)]
@ -67,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` is reserved so `DefaultVal` is used
Min,
Max,
Var,
DefaultVal("default"), // `Default` is reserved so `DefaultVal` is used
Min("min"),
Max("max"),
Var("var"),
}
#[derive(Debug, PartialEq)]
@ -90,12 +91,14 @@ impl EngineOption {
}
pub fn option_string(&self) -> String {
// TODO: Implement this to save this when looping through and sending options
// TODO: This should be tested in isolation as well
// This should handle the case where optional min max var are specified as well.
// pattern match the engine option type and convert it to the correct string.
// EVERYTHING SHOULD BE TRIVIALLY CASTABLE INTO A STRING
// NO MATCHING NEEDED....PROBABLY
format!("PUT THE FULL COMMAND STRING HERE!")
let option_data_string: String;
for dt, eod in &self.option_data {
option_data_string = option_data_string + format!("{} {}", dt, eod);
}
format!("{} {} {} {} {} {}\n", commands::OPTION, commands::OPTIONNAME, self.name,
commands::TYPE, option_type, option_data_string);
}
}

Loading…
Cancel
Save