… | |
… | |
25 | $self->pack_start (my $sw = Gtk2::ScrolledWindow->new, 1, 1, 0); |
25 | $self->pack_start (my $sw = Gtk2::ScrolledWindow->new, 1, 1, 0); |
26 | $sw->add_with_viewport ($self->{stackbox} = Gtk2::VBox->new); |
26 | $sw->add_with_viewport ($self->{stackbox} = Gtk2::VBox->new); |
27 | } |
27 | } |
28 | |
28 | |
29 | sub set_stack { |
29 | sub set_stack { |
30 | my ($self, $mapedit, $stack, $x, $y) = @_; |
30 | my ($self, $mapedit, $x, $y) = @_; |
31 | |
31 | |
32 | for ($self->{stackbox}->get_children) { |
32 | for ($self->{stackbox}->get_children) { |
33 | |
33 | |
34 | $self->{stackbox}->remove ($_); |
34 | $self->{stackbox}->remove ($_); |
35 | } |
35 | } |
36 | |
36 | |
|
|
37 | my $stack = $mapedit->get ($x, $y); |
37 | my $idx = (@$stack - 1); |
38 | my $idx = (@$stack - 1); |
38 | |
39 | |
39 | for (reverse @$stack) { |
40 | for (reverse @$stack) { |
|
|
41 | # FIXME: How to change a stack with a virtual arch???? |
|
|
42 | next if $_->{_virtual}; |
|
|
43 | |
40 | my $a = $_->{_virtual} || $_; |
44 | #my $a = $_->{_virtual} || $_; |
|
|
45 | my $a = $_; |
41 | |
46 | |
42 | # this is awful, is this really the best way? |
47 | # this is awful, is this really the best way? |
43 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
48 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
44 | $pb->fill (0x00000000); |
49 | $pb->fill (0x00000000); |
45 | |
50 | |
… | |
… | |
55 | do { |
60 | do { |
56 | my $ownidx = $idx; |
61 | my $ownidx = $idx; |
57 | |
62 | |
58 | $delbtn->signal_connect (clicked => sub { |
63 | $delbtn->signal_connect (clicked => sub { |
59 | |
64 | |
60 | my $oldstack = [ @$stack ]; |
65 | #my $oldstack = [ @$stack ]; |
61 | splice @$stack, $ownidx, 1; |
66 | splice @$stack, $ownidx, 1; |
62 | $self->set_stack ($mapedit, $stack, $x, $y); |
|
|
63 | |
67 | |
64 | $GCE::MainWindow::MAINWIN->change_map_tile ($mapedit, $x, $y, $stack, $oldstack); |
68 | # XXX: Insert undo here! |
|
|
69 | $mapedit->set ($x, $y, $stack); |
|
|
70 | |
|
|
71 | # XXX: force an update ? maybe some more intelligent update later? |
|
|
72 | $self->set_stack ($mapedit, $x, $y); |
65 | }); |
73 | }); |
66 | }; |
74 | }; |
67 | |
75 | |
68 | |
76 | |
69 | $hb->pack_start (my $elemhdl = new Gtk2::Button, 0, 0, 0); |
77 | $hb->pack_start (my $elemhdl = new Gtk2::Button, 0, 0, 0); |
… | |
… | |
98 | |
106 | |
99 | if (($data->length >= 0) && ($data->format == 8)) { |
107 | if (($data->length >= 0) && ($data->format == 8)) { |
100 | |
108 | |
101 | $context->finish (1, 0, $time); |
109 | $context->finish (1, 0, $time); |
102 | |
110 | |
103 | my $oldstack = [ @$stack ]; |
111 | #my $oldstack = [ @$stack ]; |
104 | my $swapidx = int $data->data; |
112 | my $swapidx = int $data->data; |
105 | |
113 | |
106 | ($stack->[$swapidx], $stack->[$ownidx]) |
114 | ($stack->[$swapidx], $stack->[$ownidx]) |
107 | = ($stack->[$ownidx], $stack->[$swapidx]); |
115 | = ($stack->[$ownidx], $stack->[$swapidx]); |
108 | |
116 | |
|
|
117 | # XXX: Insert undo here! |
|
|
118 | $mapedit->set ($x, $y, $stack); |
|
|
119 | |
109 | $self->set_stack ($mapedit, $stack, $x, $y); |
120 | $self->set_stack ($mapedit, $x, $y); |
110 | $GCE::MainWindow::MAINWIN->change_map_tile ($mapedit, $x, $y, $stack, $oldstack); |
|
|
111 | |
121 | |
112 | return; |
122 | return; |
113 | } |
123 | } |
114 | $context->finish (0, 0, $time); |
124 | $context->finish (0, 0, $time); |
115 | }); |
125 | }); |