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

Loading…
Cancel
Save