2017-11-21 02:55:32 +00:00
|
|
|
//
|
|
|
|
// StandardOptions.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 20/11/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-11-21 02:55:32 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "StandardOptions.hpp"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Appends a Boolean selection of @c selection for option @c name to @c selection_set.
|
|
|
|
*/
|
|
|
|
void append_bool(Configurable::SelectionSet &selection_set, const std::string &name, bool selection) {
|
|
|
|
selection_set[name] = std::unique_ptr<Configurable::Selection>(new Configurable::BooleanSelection(selection));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Enquires for a Boolean selection for option @c name from @c selections_by_option, storing it to @c result if found.
|
|
|
|
*/
|
|
|
|
bool get_bool(const Configurable::SelectionSet &selections_by_option, const std::string &name, bool &result) {
|
|
|
|
auto quickload = Configurable::selection<Configurable::BooleanSelection>(selections_by_option, "quickload");
|
|
|
|
if(!quickload) return false;
|
|
|
|
result = quickload->value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Standard option list builder
|
|
|
|
std::vector<std::unique_ptr<Configurable::Option>> Configurable::standard_options(Configurable::StandardOptions mask) {
|
|
|
|
std::vector<std::unique_ptr<Configurable::Option>> options;
|
|
|
|
if(mask & QuickLoadTape) options.emplace_back(new Configurable::BooleanOption("Load Tapes Quickly", "quickload"));
|
2018-04-01 02:14:34 +00:00
|
|
|
if(mask & (DisplayRGB | DisplayComposite | DisplaySVideo)) {
|
|
|
|
std::vector<std::string> display_options;
|
|
|
|
if(mask & DisplayComposite) display_options.emplace_back("composite");
|
|
|
|
if(mask & DisplaySVideo) display_options.emplace_back("svideo");
|
|
|
|
if(mask & DisplayRGB) display_options.emplace_back("rgb");
|
|
|
|
options.emplace_back(new Configurable::ListOption("Display", "display", display_options));
|
|
|
|
}
|
2017-11-21 02:55:32 +00:00
|
|
|
if(mask & AutomaticTapeMotorControl) options.emplace_back(new Configurable::BooleanOption("Automatic Tape Motor Control", "autotapemotor"));
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Selection appenders
|
|
|
|
void Configurable::append_quick_load_tape_selection(Configurable::SelectionSet &selection_set, bool selection) {
|
|
|
|
append_bool(selection_set, "quickload", selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configurable::append_automatic_tape_motor_control_selection(SelectionSet &selection_set, bool selection) {
|
|
|
|
append_bool(selection_set, "autotapemotor", selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configurable::append_display_selection(Configurable::SelectionSet &selection_set, Display selection) {
|
2018-04-01 02:14:34 +00:00
|
|
|
std::string string_selection;
|
|
|
|
switch(selection) {
|
|
|
|
default:
|
|
|
|
case Display::RGB: string_selection = "rgb"; break;
|
|
|
|
case Display::SVideo: string_selection = "svideo"; break;
|
|
|
|
case Display::Composite: string_selection = "composite"; break;
|
|
|
|
}
|
|
|
|
selection_set["display"] = std::unique_ptr<Configurable::Selection>(new Configurable::ListSelection(string_selection));
|
2017-11-21 02:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Selection parsers
|
|
|
|
bool Configurable::get_quick_load_tape(const Configurable::SelectionSet &selections_by_option, bool &result) {
|
|
|
|
return get_bool(selections_by_option, "quickload", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configurable::get_automatic_tape_motor_control_selection(const SelectionSet &selections_by_option, bool &result) {
|
|
|
|
return get_bool(selections_by_option, "autotapemotor", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configurable::get_display(const Configurable::SelectionSet &selections_by_option, Configurable::Display &result) {
|
|
|
|
auto display = Configurable::selection<Configurable::ListSelection>(selections_by_option, "display");
|
|
|
|
if(display) {
|
|
|
|
if(display->value == "rgb") {
|
|
|
|
result = Configurable::Display::RGB;
|
|
|
|
return true;
|
|
|
|
}
|
2018-04-01 02:14:34 +00:00
|
|
|
if(display->value == "svideo") {
|
|
|
|
result = Configurable::Display::SVideo;
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-21 02:55:32 +00:00
|
|
|
if(display->value == "composite") {
|
|
|
|
result = Configurable::Display::Composite;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|