11 :
Setting(commandController_,
"videosource",
12 "selects the video source to display on the screen",
15 sources = { {
"none", 0 } };
23void VideoSourceSetting::checkSetValue(std::string_view newValue)
const
28 if (((newValue ==
"none") && (sources.size() > 1)) ||
29 ((newValue !=
"none") && !has(newValue))) {
37 if (std::string_view str =
getValue().getString();
40 if (
int id = has(str)) {
46 if (!
id) {
id = has(
"Video9000"); }
47 if (!
id) {
id = has(
"MSX"); }
48 if (!
id) {
id = has(
"GFX9000"); }
49 if (!
id) {
id = has(
"Laserdisc"); }
73 std::vector<std::string_view> result;
74 if (sources.size() == 1) {
75 assert(sources.front().name ==
"none");
76 result.emplace_back(
"none");
78 for (
const auto& [name, val] : sources) {
80 result.emplace_back(name);
102 static int counter = 0;
104 assert(!has(source));
105 sources.emplace_back(source, ++counter);
125bool VideoSourceSetting::has(
int val)
const
127 return contains(sources, val, &Source::id);
130int VideoSourceSetting::has(std::string_view val)
const
134 return cmp(p.name, val);
136 return (it !=
end(sources)) ? it->id : 0;
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
void setChecker(std::function< void(TclObject &)> checkFunc_)
Set value-check-callback.
const TclObject & getValue() const final
Gets the current value of this setting as a TclObject.
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
void notifyPropertyChange() const
void addListElement(const T &t)
void addListElements(ITER first, ITER last)
zstring_view getString() const
VideoSourceActivator(VideoSourceSetting &setting, const std::string &name)
void tabCompletion(std::vector< std::string > &tokens) const override
Complete a partly typed value.
void unregisterVideoSource(int source)
void additionalInfo(TclObject &result) const override
Helper method for info().
VideoSourceSetting(CommandController &commandController)
std::string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
int registerVideoSource(const std::string &source)
std::vector< std::string_view > getPossibleValues() const
This file implemented 3 utility functions:
auto find_if(InputRange &&range, UnaryPredicate pred)
ITER find_unguarded(ITER first, ITER last, const VAL &val, Proj proj={})
Faster alternative to 'find' when it's guaranteed that the value will be found (if not the behavior i...
auto max_value(InputIterator first, InputIterator last, Proj proj={})
void move_pop_back(VECTOR &v, typename VECTOR::iterator it)
Erase the pointed to element from the given vector.
auto rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
constexpr bool contains(ITER first, ITER last, const VAL &val)
Check if a range contains a given value, using linear search.
constexpr auto end(const zstring_view &x)