mirror of
https://github.com/TomHarte/CLK.git
synced 2025-03-21 09:29:41 +00:00
Reintroduces full messaging to macOS.
This commit is contained in:
parent
83beb3c0e6
commit
95971f39f1
@ -10,7 +10,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <codecvt>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
|
||||
using namespace ROM;
|
||||
@ -288,6 +290,49 @@ std::string Description::description(int flags) const {
|
||||
return output.str();
|
||||
}
|
||||
|
||||
std::wstring Request::description(int description_flags, wchar_t bullet_point) {
|
||||
std::wstringstream output;
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wstring_converter;
|
||||
|
||||
visit(
|
||||
[&output, description_flags, bullet_point, &wstring_converter] (ROM::Request::LineItem item, ROM::Request::ListType type, int indentation_level, const ROM::Description *description, bool is_optional, size_t remaining) {
|
||||
if(indentation_level) {
|
||||
output << std::endl;
|
||||
for(int c = 0; c < indentation_level; c++) output << '\t';
|
||||
output << 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;
|
||||
}
|
||||
break;
|
||||
|
||||
case ROM::Request::LineItem::Description:
|
||||
if(is_optional) output << "optionally, ";
|
||||
|
||||
output << wstring_converter.from_bytes(description->description(description_flags));
|
||||
|
||||
if(remaining) {
|
||||
output << ";";
|
||||
if(remaining == 1) {
|
||||
output << ((type == ROM::Request::ListType::All) ? " and" : " or");
|
||||
}
|
||||
} else {
|
||||
output << ".";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
|
||||
Description::Description(Name name) {
|
||||
switch(name) {
|
||||
default: assert(false); break;
|
||||
|
@ -213,6 +213,10 @@ struct Request {
|
||||
const std::function<void(LineItem, ListType, int level, const ROM::Description *, bool is_optional, size_t remaining)> &add_item
|
||||
) const;
|
||||
|
||||
/// @returns a full bullet-pointed list of the requirements of this request, including
|
||||
/// appropriate conjuntives.
|
||||
std::wstring description(int description_flags, wchar_t bullet_point);
|
||||
|
||||
private:
|
||||
struct Node {
|
||||
enum class Type {
|
||||
|
@ -125,7 +125,7 @@
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--new=msx"
|
||||
argument = "--new=vic20"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
</CommandLineArguments>
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
||||
@interface CSMachine() <CSScanTargetViewDisplayLinkDelegate>
|
||||
- (void)speaker:(Outputs::Speaker::Speaker *)speaker didCompleteSamples:(const int16_t *)samples length:(int)length;
|
||||
@ -113,28 +115,9 @@ struct ActivityObserver: public Activity::Observer {
|
||||
ROM::Request missing_roms;
|
||||
_machine.reset(Machine::MachineForTargets(_analyser.targets, CSROMFetcher(&missing_roms), error));
|
||||
if(!_machine) {
|
||||
// TODO.
|
||||
[missingROMs appendFormat:@"Who told you?"];
|
||||
/* for(const auto &missing_rom : missing_roms) {
|
||||
CSMissingROM *rom = [[CSMissingROM alloc] init];
|
||||
|
||||
// Copy/convert the primitive fields.
|
||||
rom.machineName = @(missing_rom.machine_name.c_str());
|
||||
rom.fileName = @(missing_rom.file_name.c_str());
|
||||
rom.descriptiveName = missing_rom.descriptive_name.empty() ? nil : @(missing_rom.descriptive_name.c_str());
|
||||
rom.size = missing_rom.size;
|
||||
|
||||
// Convert the CRC list.
|
||||
NSMutableArray<NSNumber *> *crc32s = [[NSMutableArray alloc] initWithCapacity:missing_rom.crc32s.size()];
|
||||
for(const auto &crc : missing_rom.crc32s) {
|
||||
[crc32s addObject:@(crc)];
|
||||
}
|
||||
rom.crc32s = crc32s;
|
||||
|
||||
// Add to the missing list.
|
||||
[missingROMs addObject:rom];
|
||||
}*/
|
||||
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wstring_converter;
|
||||
const std::wstring description = missing_roms.description(0, L'•');
|
||||
[missingROMs appendString:[NSString stringWithUTF8String:wstring_converter.to_bytes(description).c_str()]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -776,41 +776,8 @@ int main(int argc, char *argv[]) {
|
||||
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 — ";
|
||||
|
||||
missing_roms.visit(
|
||||
[] (ROM::Request::LineItem item, ROM::Request::ListType type, int indentation_level, const ROM::Description *description, bool is_optional, size_t remaining) {
|
||||
if(indentation_level) {
|
||||
std::cerr << std::endl;
|
||||
for(int c = 0; c < indentation_level; c++) std::cerr << '\t';
|
||||
std::cerr << "* ";
|
||||
}
|
||||
|
||||
switch(item) {
|
||||
case ROM::Request::LineItem::NewList:
|
||||
switch(type) {
|
||||
default:
|
||||
case ROM::Request::ListType::All: std::cerr << "all of:"; break;
|
||||
case ROM::Request::ListType::Any: std::cerr << "any of:"; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ROM::Request::LineItem::Description:
|
||||
if(is_optional) std::cerr << "optionally, ";
|
||||
|
||||
using DescriptionFlag = ROM::Description::DescriptionFlag;
|
||||
std::cerr << description->description(DescriptionFlag::Filename | DescriptionFlag::CRC);
|
||||
|
||||
if(remaining) {
|
||||
std::cerr << ";";
|
||||
if(remaining == 1) {
|
||||
std::cerr << ((type == ROM::Request::ListType::All) ? " and" : " or");
|
||||
}
|
||||
} else {
|
||||
std::cerr << ".";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
using DescriptionFlag = ROM::Description::DescriptionFlag;
|
||||
std::wcerr << missing_roms.description(DescriptionFlag::Filename | DescriptionFlag::CRC, L'*');
|
||||
|
||||
std::cerr << std::endl << std::endl << "Searched unsuccessfully: ";
|
||||
bool is_first = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user