--- deliantra/Deliantra-Client/DC/Macro.pm 2006/12/09 22:28:11 1.4 +++ deliantra/Deliantra-Client/DC/Macro.pm 2007/07/20 16:32:04 1.7 @@ -194,8 +194,8 @@ ); $list->add (new CFPlus::UI::FancyFrame - label => "Bindings", - child => (my $macros = new CFPlus::UI::Table), + label => "Macros", + child => (my $macros = new CFPlus::UI::VBox), ); my $refresh; @@ -271,9 +271,8 @@ $recording = $::CONN && !$recording; if ($recording) { $widget->set_text ("Stop Recording"); - my $action = $macro->{action} ||= []; $::CONN->record (sub { - push @$action, $_[0]; + push @{ $macro->{action} }, $_[0]; $textedit->set_text (macro_to_text $macro); }) if $::CONN; } else { @@ -284,22 +283,34 @@ ); }; + $macros->add (new CFPlus::UI::Button + text => "New Macro", + tooltip => "Creates a new, empty, macro you can edit.", + on_activate => sub { + my $macro = { }; + push @{ $::PROFILE->{macro} }, $macro; + $edit_macro->($macro); + }, + ); + + $macros->add (my $macrolist = new CFPlus::UI::Table col_expand => [0, 1]); + $REFRESH_MACRO_LIST = $refresh = sub { - $macros->clear; + $macrolist->clear; - $macros->add (0, 0, new CFPlus::UI::Label + $macrolist->add_at (0, 1, new CFPlus::UI::Label text => "Trigger", align => 0, tooltip => $tooltip_trigger . $tooltip_common, ); - $macros->add (1, 0, new CFPlus::UI::Label + $macrolist->add_at (1, 1, new CFPlus::UI::Label text => "Commands", tooltip => $tooltip_commands . $tooltip_common, ); for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { my $macro = $::PROFILE->{macro}[$idx]; - my $y = $idx + 1; + my $y = $idx + 2; my $macro_cb = sub { my ($widget, $ev) = @_; @@ -327,7 +338,7 @@ 1 }; - $macros->add (0, $y, new CFPlus::UI::Label + $macrolist->add_at (0, $y, new CFPlus::UI::Label text => trigger_to_string $macro, tooltip => $tooltip_trigger . $tooltip_common, align => 0, @@ -336,7 +347,7 @@ on_button_down => $macro_cb, ); - $macros->add (1, $y, new CFPlus::UI::Label + $macrolist->add_at (1, $y, new CFPlus::UI::Label text => (join "; ", @{ $macro->{action} || [] }), tooltip => $tooltip_commands . $tooltip_common, expand => 1,