1 | package dc::UI::MessageWindow; |
1 | package DC::UI::MessageWindow; |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use Scalar::Util qw/weaken/; |
6 | use Scalar::Util qw/weaken/; |
7 | use dc::UI::ChatView; |
7 | use DC::UI::ChatView; |
8 | use Deliantra::Protocol::Constants; |
8 | use Deliantra::Protocol::Constants; |
9 | |
9 | |
10 | our @ISA = dc::UI::Toplevel::; |
10 | our @ISA = DC::UI::Toplevel::; |
11 | |
11 | |
12 | our %channel_info; |
12 | our %channel_info; |
13 | |
13 | |
14 | sub clr_def($) { "<span foreground=\"#ffffff\">$_[0]</span>" } |
14 | sub clr_def($) { "<span foreground=\"#ffffff\">$_[0]</span>" } |
15 | sub clr_act($) { "<span foreground=\"#ffffff\">$_[0]</span>" } |
15 | sub clr_act($) { "<span foreground=\"#ffffff\">$_[0]</span>" } |
… | |
… | |
25 | border_bg => [1, 1, 1, 1], |
25 | border_bg => [1, 1, 1, 1], |
26 | x => "max", |
26 | x => "max", |
27 | y => 0, |
27 | y => 0, |
28 | force_w => $::WIDTH * 0.4, |
28 | force_w => $::WIDTH * 0.4, |
29 | force_h => $::HEIGHT * 0.5, |
29 | force_h => $::HEIGHT * 0.5, |
30 | child => (my $nb = dc::UI::Notebook->new (expand => 1)), |
30 | child => (my $nb = DC::UI::Notebook->new (expand => 1)), |
31 | has_close_button => 1 |
31 | has_close_button => 1 |
32 | ); |
32 | ); |
33 | |
33 | |
34 | $self->{nb} = $nb; |
34 | $self->{nb} = $nb; |
35 | $self->{chatviews} = {}; |
35 | $self->{chatviews} = {}; |
… | |
… | |
41 | $nb->connect (c_add => sub { |
41 | $nb->connect (c_add => sub { |
42 | $self->update_tabs; |
42 | $self->update_tabs; |
43 | }); |
43 | }); |
44 | |
44 | |
45 | my $l = $self->{main_log} = |
45 | my $l = $self->{main_log} = |
46 | dc::UI::ChatView->new (expand => 1, say_command => ''); |
46 | DC::UI::ChatView->new (expand => 1, say_command => ''); |
47 | |
47 | |
48 | $l->{_tab_label} = |
48 | $l->{_tab_label} = |
49 | $l->{c_tab} = |
49 | $l->{c_tab} = |
50 | dc::UI::Button->new ( |
50 | DC::UI::Button->new ( |
51 | markup => "Log", tooltip => "This is the main log of the server." |
51 | markup => "Log", tooltip => "This is the main log of the server." |
52 | ); |
52 | ); |
53 | |
53 | |
54 | $nb->add ($l); |
54 | $nb->add ($l); |
55 | $nb->set_current_page ($l); |
55 | $nb->set_current_page ($l); |
… | |
… | |
63 | my $chatviews = $self->{chatviews}; |
63 | my $chatviews = $self->{chatviews}; |
64 | my $chaninfo = $self->{channel_info}->{$id}; |
64 | my $chaninfo = $self->{channel_info}->{$id}; |
65 | my $nb = $self->{nb}; |
65 | my $nb = $self->{nb}; |
66 | |
66 | |
67 | my $cv = $chatviews->{$id} = |
67 | my $cv = $chatviews->{$id} = |
68 | dc::UI::ChatView->new ( |
68 | DC::UI::ChatView->new ( |
69 | expand => 1, |
69 | expand => 1, |
70 | say_command => $chaninfo->{reply}, |
70 | say_command => $chaninfo->{reply}, |
71 | entry_tooltip => $chaninfo->{tooltip}, |
71 | entry_tooltip => $chaninfo->{tooltip}, |
72 | text_tooltip => "Conversation with $chaninfo->{title}" |
72 | text_tooltip => "Conversation with $chaninfo->{title}" |
73 | ); |
73 | ); |
74 | |
74 | |
75 | my $bb = dc::UI::ButtonBin->new (tooltip => $chaninfo->{tooltip}); |
75 | my $bb = DC::UI::ButtonBin->new (tooltip => $chaninfo->{tooltip}); |
76 | $cv->{c_tab} = $bb; |
76 | $cv->{c_tab} = $bb; |
77 | |
77 | |
78 | $bb->add (my $vb = dc::UI::Box->new); |
78 | $bb->add (my $vb = DC::UI::Box->new); |
79 | $vb->add ( |
79 | $vb->add ( |
80 | my $b = dc::UI::Label->new ( |
80 | my $b = DC::UI::Label->new ( |
81 | expand => 1, markup => clr_def ($chaninfo->{title}), valign => 0, align => 0 |
81 | expand => 1, markup => clr_def ($chaninfo->{title}), valign => 0, align => 0 |
82 | ) |
82 | ) |
83 | ); |
83 | ); |
84 | |
84 | |
85 | $cv->{_chat_id} = $id; |
85 | $cv->{_chat_id} = $id; |
86 | $cv->{_tab_label} = $b; |
86 | $cv->{_tab_label} = $b; |
87 | weaken $cv->{_tab_label}; |
87 | weaken $cv->{_tab_label}; |
88 | |
88 | |
89 | $vb->add ( |
89 | $vb->add ( |
90 | my $b = dc::UI::ImageButton->new ( |
90 | my $b = DC::UI::ImageButton->new ( |
91 | path => 'x1_close.png', |
91 | path => 'x1_close.png', |
92 | scale => 0.3, |
92 | scale => 0.3, |
93 | ) |
93 | ) |
94 | ); |
94 | ); |
95 | $b->connect (activate => sub { |
95 | $b->connect (activate => sub { |