mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Improves request construction and improves descriptions.
This commit is contained in:
parent
95971f39f1
commit
dd64aef910
@ -27,14 +27,28 @@ Request::Request(Name name, bool optional) {
|
||||
}
|
||||
|
||||
Request Request::append(Node::Type type, const Request &rhs) {
|
||||
// Start with the easiest case: this is already an ::All request, and
|
||||
// so is the new thing.
|
||||
// Start with the easiest case: this is already an appropriate
|
||||
// request, and so is the new thing.
|
||||
if(node.type == type && rhs.node.type == type) {
|
||||
Request new_request = *this;
|
||||
new_request.node.children.insert(new_request.node.children.end(), rhs.node.children.begin(), rhs.node.children.end());
|
||||
return new_request;
|
||||
}
|
||||
|
||||
// Possibly: left is appropriate request and rhs is just one more thing?
|
||||
if(node.type == type && rhs.node.type == Node::Type::One) {
|
||||
Request new_request = *this;
|
||||
new_request.node.children.push_back(rhs.node);
|
||||
return new_request;
|
||||
}
|
||||
|
||||
// Or: right is appropriate request and this is just one more thing?
|
||||
if(rhs.node.type == type && node.type == Node::Type::One) {
|
||||
Request new_request = rhs;
|
||||
new_request.node.children.push_back(node);
|
||||
return new_request;
|
||||
}
|
||||
|
||||
// Otherwise create a new parent node.
|
||||
Request parent;
|
||||
parent.node.type = type;
|
||||
@ -144,7 +158,7 @@ bool Request::Node::validate(Map &map) const {
|
||||
}
|
||||
|
||||
void Request::visit(
|
||||
const std::function<void(ListType)> &enter_list,
|
||||
const std::function<void(ListType, size_t)> &enter_list,
|
||||
const std::function<void(void)> &exit_list,
|
||||
const std::function<void(ROM::Request::ListType, const ROM::Description &, bool, size_t)> &add_item
|
||||
) const {
|
||||
@ -156,8 +170,8 @@ void Request::visit(
|
||||
) const {
|
||||
int indentation_level = 0;
|
||||
node.visit(
|
||||
[&indentation_level, &add_item] (ROM::Request::ListType type) {
|
||||
add_item(LineItem::NewList, type, indentation_level, nullptr, false, -1);
|
||||
[&indentation_level, &add_item] (ROM::Request::ListType type, size_t size) {
|
||||
add_item(LineItem::NewList, type, indentation_level, nullptr, false, size);
|
||||
++indentation_level;
|
||||
},
|
||||
[&indentation_level] {
|
||||
@ -170,13 +184,13 @@ void Request::visit(
|
||||
}
|
||||
|
||||
void Request::Node::visit(
|
||||
const std::function<void(ListType)> &enter_list,
|
||||
const std::function<void(ListType, size_t)> &enter_list,
|
||||
const std::function<void(void)> &exit_list,
|
||||
const std::function<void(ROM::Request::ListType type, const ROM::Description &, bool is_optional, size_t remaining)> &add_item
|
||||
) const {
|
||||
switch(type) {
|
||||
case Type::One:
|
||||
enter_list(ListType::Single);
|
||||
enter_list(ListType::Single, 1);
|
||||
add_item(ROM::Request::ListType::Any, Description(name), is_optional, 0);
|
||||
exit_list();
|
||||
break;
|
||||
@ -184,7 +198,7 @@ void Request::Node::visit(
|
||||
case Type::Any:
|
||||
case Type::All: {
|
||||
const ListType list_type = type == Type::Any ? ListType::Any : ListType::All;
|
||||
enter_list(list_type);
|
||||
enter_list(list_type, children.size());
|
||||
for(size_t index = 0; index < children.size(); index++) {
|
||||
auto &child = children[index];
|
||||
|
||||
@ -304,10 +318,21 @@ std::wstring Request::description(int description_flags, wchar_t bullet_point) {
|
||||
|
||||
switch(item) {
|
||||
case ROM::Request::LineItem::NewList:
|
||||
switch(type) {
|
||||
default:
|
||||
case ROM::Request::ListType::All: output << "all of:"; break;
|
||||
case ROM::Request::ListType::Any: output << "any of:"; break;
|
||||
if(remaining > 1) {
|
||||
if(!indentation_level) output << " ";
|
||||
switch(type) {
|
||||
default:
|
||||
case ROM::Request::ListType::All: output << "all of:"; break;
|
||||
case ROM::Request::ListType::Any:
|
||||
if(remaining == 2) {
|
||||
output << "either of:";
|
||||
} else {
|
||||
output << "any of:";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
output << ":";
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -201,7 +201,7 @@ struct Request {
|
||||
Any, All, Single
|
||||
};
|
||||
void visit(
|
||||
const std::function<void(ListType)> &enter_list,
|
||||
const std::function<void(ListType, size_t size)> &enter_list,
|
||||
const std::function<void(void)> &exit_list,
|
||||
const std::function<void(ROM::Request::ListType type, const ROM::Description &, bool is_optional, size_t remaining)> &add_item
|
||||
) const;
|
||||
@ -214,7 +214,8 @@ struct Request {
|
||||
) const;
|
||||
|
||||
/// @returns a full bullet-pointed list of the requirements of this request, including
|
||||
/// appropriate conjuntives.
|
||||
/// appropriate conjuntives. This text is intended to be glued to the end of an opening
|
||||
/// portion of a sentence, e.g. "Please supply" + request.description(0, L'*').
|
||||
std::wstring description(int description_flags, wchar_t bullet_point);
|
||||
|
||||
private:
|
||||
@ -233,7 +234,7 @@ struct Request {
|
||||
void add_descriptions(std::vector<Description> &) const;
|
||||
bool validate(Map &) const;
|
||||
void visit(
|
||||
const std::function<void(ListType)> &enter_list,
|
||||
const std::function<void(ListType, size_t)> &enter_list,
|
||||
const std::function<void(void)> &exit_list,
|
||||
const std::function<void(ROM::Request::ListType type, const ROM::Description &, bool is_optional, size_t remaining)> &add_item
|
||||
) const;
|
||||
|
@ -14,6 +14,7 @@
|
||||
4B049CDD1DA3C82F00322067 /* BCDTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B049CDC1DA3C82F00322067 /* BCDTest.swift */; };
|
||||
4B051C912669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B051C5826670A9300CA44E8 /* ROMCatalogue.cpp */; };
|
||||
4B051C922669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B051C5826670A9300CA44E8 /* ROMCatalogue.cpp */; };
|
||||
4B051C93266D9D6900CA44E8 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; };
|
||||
4B05401E219D1618001BF69C /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B05401D219D1618001BF69C /* ScanTarget.cpp */; };
|
||||
4B05401F219D1618001BF69C /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B05401D219D1618001BF69C /* ScanTarget.cpp */; };
|
||||
4B055A7A1FAE78A00060FFFF /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B055A771FAE78210060FFFF /* SDL2.framework */; };
|
||||
@ -568,7 +569,6 @@
|
||||
4B9F11CA2272433900701480 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B69FB451C4D950F00B5F0AA /* libz.tbd */; };
|
||||
4B9F11CC22729B3600701480 /* OPCLOGR2.BIN in Resources */ = {isa = PBXBuildFile; fileRef = 4B9F11CB22729B3500701480 /* OPCLOGR2.BIN */; };
|
||||
4BA0F68E1EEA0E8400E9489E /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA0F68C1EEA0E8400E9489E /* ZX8081.cpp */; };
|
||||
4BA3189422E7A4CA00D18CFA /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; };
|
||||
4BA61EB01D91515900B3C876 /* NSData+StdVector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */; };
|
||||
4BA91E1D216D85BA00F79557 /* MasterSystemVDPTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BA91E1C216D85BA00F79557 /* MasterSystemVDPTests.mm */; };
|
||||
4BAD13441FF709C700FD114A /* MSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0E61051FF34737002A9DBD /* MSX.cpp */; };
|
||||
@ -4768,7 +4768,7 @@
|
||||
4BB73EAC1B587A5100552FC2 /* MainMenu.xib in Resources */,
|
||||
4B8FE21D1DA19D5F0090D3CE /* QuickLoadCompositeOptions.xib in Resources */,
|
||||
4B49F0A923346F7A0045E6A6 /* MacintoshOptions.xib in Resources */,
|
||||
4BA3189422E7A4CA00D18CFA /* ROMImages in Resources */,
|
||||
4B051C93266D9D6900CA44E8 /* ROMImages in Resources */,
|
||||
4B79E4461E3AF38600141F11 /* floppy525.png in Resources */,
|
||||
4BEEE6BD20DC72EB003723BF /* CompositeOptions.xib in Resources */,
|
||||
4B1497981EE4B97F00CE2596 /* ZX8081Options.xib in Resources */,
|
||||
|
@ -415,6 +415,10 @@ class MachineDocument:
|
||||
private var romRequestBaseText = ""
|
||||
|
||||
private func setRomRequesterIsVisible(_ visible : Bool) {
|
||||
if !visible && self.romRequesterPanel == nil {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.romRequesterPanel!.isVisible == visible {
|
||||
return
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@ -20,18 +20,16 @@
|
||||
<windowStyleMask key="styleMask" titled="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1440"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ" customClass="CSROMReceiverView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5qG-I3-Qav">
|
||||
<rect key="frame" x="18" y="154" width="444" height="96"/>
|
||||
<rect key="frame" x="18" y="186" width="444" height="64"/>
|
||||
<textFieldCell key="cell" enabled="NO" allowsUndo="NO" id="itJ-2T-0ia">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<string key="title">Clock Signal requires you to provide images of the system ROMs for this machine. They will be stored permanently; you need do this only once.
Please drag and drop the following over this text:
|
||||
|
||||
</string>
|
||||
<string key="title">Clock Signal requires you to provide images of the system ROMs for this machine. They will be stored permanently; you need do this only once.
Please drag and drop over this text</string>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
|
@ -774,7 +774,7 @@ int main(int argc, char *argv[]) {
|
||||
default: break;
|
||||
case ::Machine::Error::MissingROM: {
|
||||
std::cerr << "Could not find system ROMs; please install to /usr/local/share/CLK/ or /usr/share/CLK/, or provide a --rompath, e.g. --rompath=~/ROMs." << std::endl;
|
||||
std::cerr << "Needed — but didn't find — ";
|
||||
std::cerr << "Needed — but didn't find —";
|
||||
|
||||
using DescriptionFlag = ROM::Description::DescriptionFlag;
|
||||
std::wcerr << missing_roms.description(DescriptionFlag::Filename | DescriptionFlag::CRC, L'*');
|
||||
|
Loading…
x
Reference in New Issue
Block a user