mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Translate PlaceholderParser::apply_config to C++.
This commit is contained in:
parent
e88545b966
commit
a837e26f51
4 changed files with 109 additions and 31 deletions
|
@ -30,32 +30,6 @@ sub update_timestamp {
|
|||
$self->_single_set('version', $Slic3r::VERSION);
|
||||
}
|
||||
|
||||
sub apply_config {
|
||||
my ($self, $config) = @_;
|
||||
|
||||
# options with single value
|
||||
my @opt_keys = grep $Slic3r::Config::Options->{$_}{cli} !~ /\@$/,
|
||||
grep !$Slic3r::Config::Options->{$_}{multiline},
|
||||
@{$config->get_keys};
|
||||
$self->_single_set($_, $config->serialize($_)) for @opt_keys;
|
||||
|
||||
# options with multiple values
|
||||
foreach my $opt_key (@opt_keys) {
|
||||
my $value = $config->$opt_key;
|
||||
next unless ref($value) eq 'ARRAY';
|
||||
# TODO: this is a workaroud for XS string param handling
|
||||
# https://rt.cpan.org/Public/Bug/Display.html?id=94110
|
||||
no warnings 'void';
|
||||
"$_" for @$value;
|
||||
$self->_multiple_set("${opt_key}_" . $_, $value->[$_]."") for 0..$#$value;
|
||||
$self->_multiple_set($opt_key, $value->[0]."");
|
||||
if ($Slic3r::Config::Options->{$opt_key}{type} eq 'point') {
|
||||
$self->_multiple_set("${opt_key}_X", $value->[0]."");
|
||||
$self->_multiple_set("${opt_key}_Y", $value->[1]."");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: or this could be an alias
|
||||
sub set {
|
||||
my ($self, $key, $val) = @_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue