mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Make exclusivity groups work in the GUI.
This commit is contained in:
@@ -13,37 +13,44 @@ import "lib/common.proto";
|
|||||||
import "lib/layout.proto";
|
import "lib/layout.proto";
|
||||||
|
|
||||||
// NEXT_TAG: 21
|
// NEXT_TAG: 21
|
||||||
message ConfigProto {
|
message ConfigProto
|
||||||
optional string comment = 8;
|
{
|
||||||
optional bool is_extension = 13;
|
optional string comment = 8;
|
||||||
repeated string include = 19;
|
optional bool is_extension = 13;
|
||||||
|
repeated string include = 19;
|
||||||
|
|
||||||
optional LayoutProto layout = 18;
|
optional LayoutProto layout = 18;
|
||||||
|
|
||||||
optional ImageReaderProto image_reader = 12;
|
optional ImageReaderProto image_reader = 12;
|
||||||
optional ImageWriterProto image_writer = 9;
|
optional ImageWriterProto image_writer = 9;
|
||||||
|
|
||||||
optional FluxSourceProto flux_source = 10;
|
optional FluxSourceProto flux_source = 10;
|
||||||
optional FluxSinkProto flux_sink = 11;
|
optional FluxSinkProto flux_sink = 11;
|
||||||
optional DriveProto drive = 15;
|
optional DriveProto drive = 15;
|
||||||
|
|
||||||
optional EncoderProto encoder = 3;
|
optional EncoderProto encoder = 3;
|
||||||
optional DecoderProto decoder = 4;
|
optional DecoderProto decoder = 4;
|
||||||
optional UsbProto usb = 5;
|
optional UsbProto usb = 5;
|
||||||
|
|
||||||
optional RangeProto tracks = 6;
|
optional RangeProto tracks = 6;
|
||||||
optional RangeProto heads = 7;
|
optional RangeProto heads = 7;
|
||||||
optional int32 tpi = 16 [ (help) = "TPI of image; if 0, use TPI of drive" ];
|
optional int32 tpi = 16 [ (help) = "TPI of image; if 0, use TPI of drive" ];
|
||||||
|
|
||||||
optional FilesystemProto filesystem = 17;
|
optional FilesystemProto filesystem = 17;
|
||||||
|
|
||||||
repeated OptionProto option = 20;
|
repeated OptionProto option = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OptionProto {
|
message OptionProto
|
||||||
optional string name = 1 [(help) = "Option name" ];
|
{
|
||||||
optional string comment = 2 [(help) = "Help text for option" ];
|
optional string name = 1 [ (help) = "option name" ];
|
||||||
optional string message = 3 [(help) = "Message to display when option is in use" ];
|
optional string comment = 2 [ (help) = "help text for option" ];
|
||||||
optional ConfigProto config = 4 [(help) = "Option data", (recurse) = false ];
|
optional string message = 3
|
||||||
|
[ (help) = "message to display when option is in use" ];
|
||||||
|
optional string exclusivity_group = 5 [
|
||||||
|
(help) =
|
||||||
|
"options with the same group cannot be selected at the same time"
|
||||||
|
];
|
||||||
|
optional ConfigProto config = 4
|
||||||
|
[ (help) = "option data", (recurse) = false ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ option {
|
|||||||
name: "appledos"
|
name: "appledos"
|
||||||
comment: "use AppleDOS soft sector skew for filesystem access and images"
|
comment: "use AppleDOS soft sector skew for filesystem access and images"
|
||||||
message: "compensating for AppleDOS soft sector skew"
|
message: "compensating for AppleDOS soft sector skew"
|
||||||
|
exclusivity_group: "format"
|
||||||
|
|
||||||
config {
|
config {
|
||||||
image_reader {
|
image_reader {
|
||||||
@@ -60,6 +61,7 @@ option {
|
|||||||
name: "prodos"
|
name: "prodos"
|
||||||
comment: "use ProDOS soft sector skew for filesystem access and images"
|
comment: "use ProDOS soft sector skew for filesystem access and images"
|
||||||
message: "compensating for ProDOS soft sector skew"
|
message: "compensating for ProDOS soft sector skew"
|
||||||
|
exclusivity_group: "format"
|
||||||
|
|
||||||
config {
|
config {
|
||||||
image_reader {
|
image_reader {
|
||||||
@@ -103,6 +105,7 @@ option {
|
|||||||
name: "cpm"
|
name: "cpm"
|
||||||
comment: "use CP/M soft sector skew for filesystem access and images"
|
comment: "use CP/M soft sector skew for filesystem access and images"
|
||||||
message: "compensating for CP/M soft sector skew"
|
message: "compensating for CP/M soft sector skew"
|
||||||
|
exclusivity_group: "format"
|
||||||
|
|
||||||
config {
|
config {
|
||||||
image_reader {
|
image_reader {
|
||||||
|
|||||||
@@ -1686,13 +1686,69 @@ public:
|
|||||||
_formatNames[formatChoice->GetSelection()];
|
_formatNames[formatChoice->GetSelection()];
|
||||||
FlagGroup::parseConfigFile(formatName, formats);
|
FlagGroup::parseConfigFile(formatName, formats);
|
||||||
|
|
||||||
|
std::set<std::string> exclusivityGroups;
|
||||||
|
for (auto& option : config.option())
|
||||||
|
{
|
||||||
|
if (option.has_exclusivity_group())
|
||||||
|
exclusivityGroups.insert(option.exclusivity_group());
|
||||||
|
}
|
||||||
|
|
||||||
if (config.option().empty())
|
if (config.option().empty())
|
||||||
sizer->Add(new wxStaticText(formatOptionsContainer,
|
sizer->Add(new wxStaticText(formatOptionsContainer,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
"(no options for this format)"));
|
"(no options for this format)"));
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* Add grouped radiobuttons for anything in an exclusivity
|
||||||
|
* group. */
|
||||||
|
|
||||||
|
for (auto& group : exclusivityGroups)
|
||||||
|
{
|
||||||
|
bool first = true;
|
||||||
|
for (auto& option : config.option())
|
||||||
|
{
|
||||||
|
if (option.exclusivity_group() != group)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto* rb = new wxRadioButton(formatOptionsContainer,
|
||||||
|
wxID_ANY,
|
||||||
|
option.comment());
|
||||||
|
auto key =
|
||||||
|
std::make_pair(formatName, option.name());
|
||||||
|
sizer->Add(rb);
|
||||||
|
|
||||||
|
rb->Bind(wxEVT_RADIOBUTTON,
|
||||||
|
[=](wxCommandEvent& e)
|
||||||
|
{
|
||||||
|
for (auto& option : config.option())
|
||||||
|
{
|
||||||
|
if (option.exclusivity_group() == group)
|
||||||
|
_formatOptions.erase(std::make_pair(
|
||||||
|
formatName, option.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
_formatOptions.insert(key);
|
||||||
|
|
||||||
|
OnControlsChanged(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (_formatOptions.find(key) !=
|
||||||
|
_formatOptions.end())
|
||||||
|
rb->SetValue(true);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
rb->SetExtraStyle(wxRB_GROUP);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Anything that's _not_ in a group gets a checkbox. */
|
||||||
|
|
||||||
for (auto& option : config.option())
|
for (auto& option : config.option())
|
||||||
{
|
{
|
||||||
|
if (option.has_exclusivity_group())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto* choice = new wxCheckBox(
|
auto* choice = new wxCheckBox(
|
||||||
formatOptionsContainer, wxID_ANY, option.comment());
|
formatOptionsContainer, wxID_ANY, option.comment());
|
||||||
auto key = std::make_pair(formatName, option.name());
|
auto key = std::make_pair(formatName, option.name());
|
||||||
@@ -1702,7 +1758,7 @@ public:
|
|||||||
choice->SetValue(true);
|
choice->SetValue(true);
|
||||||
|
|
||||||
choice->Bind(wxEVT_CHECKBOX,
|
choice->Bind(wxEVT_CHECKBOX,
|
||||||
[this, choice, key](wxCommandEvent& e)
|
[=](wxCommandEvent& e)
|
||||||
{
|
{
|
||||||
if (choice->GetValue())
|
if (choice->GetValue())
|
||||||
_formatOptions.insert(key);
|
_formatOptions.insert(key);
|
||||||
@@ -1712,6 +1768,7 @@ public:
|
|||||||
OnControlsChanged(e);
|
OnControlsChanged(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formatOptionsContainer->SetSizerAndFit(sizer);
|
formatOptionsContainer->SetSizerAndFit(sizer);
|
||||||
|
|||||||
Reference in New Issue
Block a user