ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI/MessageWindow.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI/MessageWindow.pm (file contents):
Revision 1.11 by elmex, Tue Jul 31 14:47:07 2007 UTC vs.
Revision 1.12 by elmex, Tue Aug 14 13:25:26 2007 UTC

3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6use Scalar::Util qw/weaken/; 6use Scalar::Util qw/weaken/;
7use CFPlus::UI::ChatView; 7use CFPlus::UI::ChatView;
8use Crossfire::Protocol::Constants;
8 9
9our @ISA = CFPlus::UI::Toplevel::; 10our @ISA = CFPlus::UI::Toplevel::;
10 11
11our %channel_info; 12our %channel_info;
12
13sub add_channel_info {
14 my ($info) = @_;
15}
16
17 13
18sub clr_def($) { "<span foreground=\"#777777\">$_[0]</span>" } 14sub clr_def($) { "<span foreground=\"#777777\">$_[0]</span>" }
19sub clr_act($) { "<span foreground=\"#ffffff\">$_[0]</span>" } 15sub clr_act($) { "<span foreground=\"#ffffff\">$_[0]</span>" }
20sub clr_hlt($) { "<span foreground=\"#aaaaff\">$_[0]</span>" } 16sub clr_hlt($) { "<span foreground=\"#aaaaff\">$_[0]</span>" }
21sub clr_hlt2($) { "<span foreground=\"#9999ff\">$_[0]</span>" } 17sub clr_hlt2($) { "<span foreground=\"#9999ff\">$_[0]</span>" }
107 103
108 delete $chatviews->{$id}; 104 delete $chatviews->{$id};
109 0 105 0
110 }); 106 });
111 107
108 my $preadd = $nb->get_current_page;
112 $nb->add ($cv); 109 $nb->add ($cv);
113 #$nb->set_current_page ($cv); 110 $nb->set_current_page ($preadd);
114} 111}
115 112
116sub touch_channel { 113sub touch_channel {
117 my ($self, $id) = @_; 114 my ($self, $id) = @_;
115
118 if (not exists $self->{chatviews}->{$id}) { 116 if (not exists $self->{chatviews}->{$id}) {
119 $self->add_chat ($id); 117 $self->add_chat ($id);
120 } 118 }
121} 119}
122 120
123sub highlight_channel { 121sub highlight_channel {
124 my ($self, $id) = @_; 122 my ($self, $id) = @_;
123
125 my $cv = $self->{chatviews}->{$id}; 124 my $cv = $self->{chatviews}->{$id};
126 $cv->{_channel_highlighted} = 1; 125 $cv->{_channel_highlighted} = 1;
127 my $tab = $cv->{_tab_button}; 126 my $tab = $cv->{_tab_button};
127
128 $tab->set_markup ( 128 $tab->set_markup (
129 clr_hlt (defined $id ? $self->{channel_info}->{$id}->{title} : "Log") 129 clr_hlt (defined $id ? $self->{channel_info}->{$id}->{title} : "Log")
130 ); 130 );
131} 131}
132 132
140 $tab->set_markup (clr_act (defined $id ? $self->{channel_info}->{$id}->{title} : "Log")); 140 $tab->set_markup (clr_act (defined $id ? $self->{channel_info}->{$id}->{title} : "Log"));
141} 141}
142 142
143sub update_current_tab { 143sub update_current_tab {
144 my ($self, $page) = @_; 144 my ($self, $page) = @_;
145
145 my $tab = $page->{_tab_button}; 146 my $tab = $page->{_tab_button};
146 my $label; 147 my $label;
148
147 if (defined $page->{_chat_id}) { 149 if (defined $page->{_chat_id}) {
148 $label = $self->{channel_info}->{$page->{_chat_id}}->{title}; 150 $label = $self->{channel_info}->{$page->{_chat_id}}->{title};
149 } 151 }
152
150 $label = "Log" unless defined $label; 153 $label = "Log" unless defined $label;
151 154
152 $tab->set_markup (clr_act ($label)); 155 $tab->set_markup (clr_act ($label));
153 156
154 for ($self->{nb}->pages) { 157 for ($self->{nb}->pages) {
155 next if $_ eq $page; 158 next if $_ eq $page;
159 next if $_->{_channel_highlighted};
160
156 my $tab = $_->{_tab_button}; 161 my $tab = $_->{_tab_button};
157 next if $_->{_channel_highlighted};
158 next unless $tab; 162 next unless $tab;
159 163
160 my $label; 164 my $label;
165
161 if (defined $_->{_chat_id}) { 166 if (defined $_->{_chat_id}) {
162 $label = $self->{channel_info}->{$_->{_chat_id}}->{title}; 167 $label = $self->{channel_info}->{$_->{_chat_id}}->{title};
163 } 168 }
169
164 $label = "Log" unless defined $label; 170 $label = "Log" unless defined $label;
165 171
166 $tab->set_markup (clr_def ($label)); 172 $tab->set_markup (clr_def ($label));
167 } 173 }
168} 174}
169 175
170sub add_channel { 176sub add_channel {
171 my ($self, $info) = @_; 177 my ($self, $info) = @_;
178
172 $self->{channel_info}->{$info->{id}} = $info; 179 $self->{channel_info}->{$info->{id}} = $info;
173 $self->touch_channel ($info->{id}); 180 $self->touch_channel ($info->{id});
174} 181}
175 182
176sub message { 183sub message {
177 my ($self, $para) = @_; 184 my ($self, $para) = @_;
185
186 #d# require Data::Dumper;
187 #d# print "FOO[".Data::Dumper->Dump ([$para])."]\n";
188
178 my $id = $para->{type}; 189 my $id = $para->{type};
179 190
180 if (exists $self->{channel_info}->{$id}) { 191 if (exists $self->{channel_info}->{$id}) {
181 $self->touch_channel ($id); 192 $self->touch_channel ($id);
193
182 if (my $cv = $self->{chatviews}->{$id}) { 194 if (my $cv = $self->{chatviews}->{$id}) {
195
183 if ($cv != $self->{nb}->get_current_page) { 196 if ($cv != $self->{nb}->get_current_page) {
184 $self->highlight_channel ($id); 197 $self->highlight_channel ($id);
185 } 198 }
199
200 if ($para->{color_flags} & NDI_REPLY) {
201 $self->{nb}->set_current_page ($cv);
202 $cv->activate_console;
203 }
186 } 204 }
205
187 $self->{chatviews}->{$id}->message ($para); 206 $self->{chatviews}->{$id}->message ($para);
207
188 } else { 208 } else {
189 $self->{main_log}->message ($para); 209 $self->{main_log}->message ($para);
190 } 210 }
191} 211}
192 212
193sub activate_console { 213sub activate_console {
194 my ($self, $preset) = @_; 214 my ($self, $preset) = @_;
215
195 $self->{main_log}->activate_console ($preset); 216 $self->{main_log}->activate_console ($preset);
217}
218
219sub activate_current {
220 my ($self) = @_;
221
222 $self->{nb}->get_current_page->activate_console;
196} 223}
197 224
198sub set_fontsize { 225sub set_fontsize {
199 my ($self, $size) = @_; 226 my ($self, $size) = @_;
227
200 for (values %{$self->{chatviews}}, $self->{main_log}) { 228 for (values %{$self->{chatviews}}, $self->{main_log}) {
201 $_->set_fontsize ($size); 229 $_->set_fontsize ($size);
202 } 230 }
203} 231}
204 232
205sub set_max_para { 233sub set_max_para {
206 my ($self, $max_par) = @_; 234 my ($self, $max_par) = @_;
235
207 for (values %{$self->{chatviews}}, $self->{main_log}) { 236 for (values %{$self->{chatviews}}, $self->{main_log}) {
208 $_->set_max_para ($max_par); 237 $_->set_max_para ($max_par);
209 } 238 }
210} 239}
211 240
241sub user_switch_to_page {
242 my ($self, $page) = @_;
243
244 $page = $page eq '0' ? 10 : $page;
245
246 my @tabs = $self->{nb}->pages;
247
248 for (my $i = 0; $i < ($page - 1); $i++) {
249 shift @tabs;
250 }
251
252 my $page = shift @tabs;
253 return unless $page;
254
255 $self->{nb}->set_current_page ($page);
256 $page->activate_console;
257}
258
2121; 2591;
213 260

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines