1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | CFClient - undocumented utility garbage for our crossfire client |
3 | CFPlus - undocumented utility garbage for our crossfire client |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use CFClient; |
7 | use CFPlus; |
8 | |
8 | |
9 | =head1 DESCRIPTION |
9 | =head1 DESCRIPTION |
10 | |
10 | |
11 | =over 4 |
11 | =over 4 |
12 | |
12 | |
13 | =cut |
13 | =cut |
14 | |
14 | |
15 | package CFClient; |
15 | package CFPlus; |
16 | |
16 | |
17 | BEGIN { |
17 | BEGIN { |
18 | $VERSION = '0.1'; |
18 | $VERSION = '0.2'; |
19 | |
19 | |
20 | use XSLoader; |
20 | use XSLoader; |
21 | XSLoader::load "CFClient", $VERSION; |
21 | XSLoader::load "CFPlus", $VERSION; |
22 | } |
22 | } |
23 | |
23 | |
24 | use utf8; |
24 | use utf8; |
25 | |
25 | |
26 | use Carp (); |
26 | use Carp (); |
… | |
… | |
28 | use BerkeleyDB; |
28 | use BerkeleyDB; |
29 | use Pod::POM (); |
29 | use Pod::POM (); |
30 | use Scalar::Util (); |
30 | use Scalar::Util (); |
31 | use Storable (); # finally |
31 | use Storable (); # finally |
32 | |
32 | |
33 | package CFClient::PodToPango; |
33 | =item guard { BLOCK } |
34 | |
34 | |
35 | use base Pod::POM::View::Text; |
35 | Returns an object that executes the given block as soon as it is destroyed. |
36 | |
36 | |
37 | our $VERSION = 1; # bump if resultant formatting changes |
37 | =cut |
38 | |
38 | |
39 | our $indent = 0; |
39 | sub guard(&) { |
40 | |
40 | bless \(my $cb = $_[0]), "CFPlus::Guard" |
41 | *view_seq_code = |
|
|
42 | *view_seq_bold = sub { "<b>$_[1]</b>" }; |
|
|
43 | *view_seq_italic = sub { "<i>$_[1]</i>" }; |
|
|
44 | *view_seq_space = |
|
|
45 | *view_seq_link = |
|
|
46 | *view_seq_index = sub { CFClient::UI::Label::escape ($_[1]) }; |
|
|
47 | |
|
|
48 | sub view_seq_text { |
|
|
49 | my $text = $_[1]; |
|
|
50 | $text =~ s/\s+/ /g; |
|
|
51 | CFClient::UI::Label::escape ($text) |
|
|
52 | } |
41 | } |
53 | |
42 | |
54 | sub view_item { |
43 | sub CFPlus::Guard::DESTROY { |
55 | ("\t" x ($indent / 4)) |
44 | ${$_[0]}->() |
56 | . $_[1]->title->present ($_[0]) |
|
|
57 | . "\n\n" |
|
|
58 | . $_[1]->content->present ($_[0]) |
|
|
59 | } |
45 | } |
60 | |
46 | |
61 | sub view_verbatim { |
47 | sub asxml($) { |
62 | (join "", |
48 | local $_ = $_[0]; |
63 | map +("\t" x ($indent / 2)) . "<tt>$_</tt>\n", |
|
|
64 | split /\n/, CFClient::UI::Label::escape ($_[1])) |
|
|
65 | . "\n" |
|
|
66 | } |
|
|
67 | |
49 | |
68 | sub view_textblock { |
50 | s/&/&/g; |
69 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
51 | s/>/>/g; |
70 | } |
52 | s/</</g; |
71 | |
53 | |
72 | sub view_head1 { |
54 | $_ |
73 | "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
|
|
74 | . $_[1]->content->present ($_[0]) |
|
|
75 | }; |
|
|
76 | |
|
|
77 | sub view_head2 { |
|
|
78 | "\n<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
|
|
79 | . $_[1]->content->present ($_[0]) |
|
|
80 | }; |
|
|
81 | |
|
|
82 | sub view_head3 { |
|
|
83 | "\n<span size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
|
|
84 | . $_[1]->content->present ($_[0]) |
|
|
85 | }; |
|
|
86 | |
|
|
87 | sub view_over { |
|
|
88 | local $indent = $indent + $_[1]->indent; |
|
|
89 | $_[1]->content->present ($_[0]) |
|
|
90 | } |
55 | } |
91 | |
56 | |
92 | package CFClient::Database; |
57 | package CFPlus::Database; |
93 | |
58 | |
94 | our @ISA = BerkeleyDB::Btree::; |
59 | our @ISA = BerkeleyDB::Btree::; |
95 | |
60 | |
96 | sub get($$) { |
61 | sub get($$) { |
97 | my $data; |
62 | my $data; |
… | |
… | |
109 | $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync }); |
74 | $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync }); |
110 | |
75 | |
111 | $db->db_put ($key => $data) |
76 | $db->db_put ($key => $data) |
112 | } |
77 | } |
113 | |
78 | |
114 | package CFClient; |
79 | package CFPlus; |
115 | |
80 | |
116 | sub find_rcfile($) { |
81 | sub find_rcfile($) { |
117 | my $path; |
82 | my $path; |
118 | |
83 | |
119 | for (grep !ref, @INC) { |
84 | for (grep !ref, @INC) { |
120 | $path = "$_/CFClient/resources/$_[0]"; |
85 | $path = "$_/CFPlus/resources/$_[0]"; |
121 | return $path if -r $path; |
86 | return $path if -r $path; |
122 | } |
87 | } |
123 | |
88 | |
124 | die "FATAL: can't find required file $_[0]\n"; |
89 | die "FATAL: can't find required file $_[0]\n"; |
125 | } |
90 | } |
126 | |
91 | |
|
|
92 | BEGIN { |
|
|
93 | use Crossfire::Protocol::Base (); |
|
|
94 | *to_json = \&Crossfire::Protocol::Base::to_json; |
|
|
95 | *from_json = \&Crossfire::Protocol::Base::from_json; |
|
|
96 | } |
|
|
97 | |
127 | sub read_cfg { |
98 | sub read_cfg { |
128 | my ($file) = @_; |
99 | my ($file) = @_; |
129 | |
100 | |
130 | open CFG, $file |
101 | open my $fh, $file |
131 | or return; |
102 | or return; |
132 | |
103 | |
133 | my $CFG; |
|
|
134 | |
|
|
135 | local $/; |
104 | local $/; |
136 | $CFG = eval <CFG>; |
105 | my $CFG = <$fh>; |
137 | |
106 | |
138 | $::CFG = $CFG; |
107 | if ($CFG =~ /^---/) { ## TODO compatibility cruft, remove |
139 | |
108 | require YAML; |
140 | close CFG; |
109 | utf8::decode $CFG; |
|
|
110 | $::CFG = YAML::Load ($CFG); |
|
|
111 | } elsif ($CFG =~ /^\{/) { |
|
|
112 | $::CFG = from_json $CFG; |
|
|
113 | } else { |
|
|
114 | $::CFG = eval $CFG; ## todo comaptibility cruft |
|
|
115 | } |
141 | } |
116 | } |
142 | |
117 | |
143 | sub write_cfg { |
118 | sub write_cfg { |
144 | my ($file) = @_; |
119 | my ($file) = @_; |
145 | |
120 | |
146 | open CFG, ">$file" |
121 | $::CFG->{VERSION} = $::VERSION; |
|
|
122 | |
|
|
123 | open my $fh, ">:utf8", $file |
147 | or return; |
124 | or return; |
148 | |
125 | print $fh to_json $::CFG; |
149 | { |
|
|
150 | require Data::Dumper; |
|
|
151 | local $Data::Dumper::Purity = 1; |
|
|
152 | $::CFG->{VERSION} = $::VERSION; |
|
|
153 | print CFG Data::Dumper->Dump ([$::CFG], [qw/CFG/]); |
|
|
154 | } |
|
|
155 | |
|
|
156 | close CFG; |
|
|
157 | } |
126 | } |
158 | |
127 | |
159 | our $DB_ENV; |
128 | our $DB_ENV; |
160 | |
129 | |
161 | { |
130 | { |
… | |
… | |
180 | sub db_table($) { |
149 | sub db_table($) { |
181 | my ($table) = @_; |
150 | my ($table) = @_; |
182 | |
151 | |
183 | $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; |
152 | $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; |
184 | |
153 | |
185 | new CFClient::Database |
154 | new CFPlus::Database |
186 | -Env => $DB_ENV, |
155 | -Env => $DB_ENV, |
187 | -Filename => $table, |
156 | -Filename => $table, |
188 | # -Filename => "database", |
157 | # -Filename => "database", |
189 | # -Subname => $table, |
158 | # -Subname => $table, |
190 | -Property => DB_CHKSUM, |
159 | -Property => DB_CHKSUM, |
191 | -Flags => DB_CREATE | DB_UPGRADE, |
160 | -Flags => DB_CREATE | DB_UPGRADE, |
192 | or die "unable to create/open database table $_[0]: $BerkeleyDB::Error" |
161 | or die "unable to create/open database table $_[0]: $BerkeleyDB::Error" |
193 | } |
162 | } |
194 | |
163 | |
195 | my $pod_cache = db_table "pod_cache"; |
|
|
196 | |
|
|
197 | sub load_pod($$$$) { |
|
|
198 | my ($path, $filtertype, $filterversion, $filtercb) = @_; |
|
|
199 | |
|
|
200 | stat $path |
|
|
201 | or die "$path: $!"; |
|
|
202 | |
|
|
203 | my $phash = join ",", $filterversion, $CFClient::PodToPango::VERSION, (stat _)[7,9]; |
|
|
204 | |
|
|
205 | my ($chash, $pom) = eval { @{ Storable::thaw $pod_cache->get ("$path/$filtertype") } }; |
|
|
206 | |
|
|
207 | return $pom if $chash eq $phash; |
|
|
208 | |
|
|
209 | my $pod = do { |
|
|
210 | local $/; |
|
|
211 | open my $pod, "<:utf8", $_[0] |
|
|
212 | or die "$_[0]: $!"; |
|
|
213 | <$pod> |
|
|
214 | }; |
|
|
215 | |
|
|
216 | #utf8::downgrade $pod; |
|
|
217 | |
|
|
218 | $pom = $filtercb-> (Pod::POM->new->parse_text ($pod)); |
|
|
219 | |
|
|
220 | $pod_cache->put ("$path/$filtertype" => Storable::nfreeze [$phash, $pom]); |
|
|
221 | |
|
|
222 | $pom |
|
|
223 | } |
|
|
224 | |
|
|
225 | sub pod_to_pango($) { |
|
|
226 | my ($pom) = @_; |
|
|
227 | |
|
|
228 | $pom->present ("CFClient::PodToPango") |
|
|
229 | } |
|
|
230 | |
|
|
231 | sub pod_to_pango_list($) { |
|
|
232 | my ($pom) = @_; |
|
|
233 | |
|
|
234 | [ |
|
|
235 | map s/^(\s*)// && [40 * length $1, length $_ ? $_ : " "], |
|
|
236 | split /\n/, $pom->present ("CFClient::PodToPango") |
|
|
237 | ] |
|
|
238 | } |
|
|
239 | |
|
|
240 | package CFClient::Layout; |
164 | package CFPlus::Layout; |
241 | |
165 | |
242 | $CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Layout"} = sub { |
166 | $CFPlus::OpenGL::SHUTDOWN_HOOK{"CFPlus::Layout"} = sub { |
243 | reset_glyph_cache; |
167 | reset_glyph_cache; |
244 | }; |
168 | }; |
245 | |
169 | |
246 | package CFClient::Item; |
170 | package CFPlus::Item; |
247 | |
171 | |
248 | use strict; |
172 | use strict; |
249 | use Crossfire::Protocol::Constants; |
173 | use Crossfire::Protocol::Constants; |
250 | |
174 | |
251 | my $last_enter_count = 1; |
175 | my $last_enter_count = 1; |
… | |
… | |
285 | } |
209 | } |
286 | |
210 | |
287 | sub do_n_dialog { |
211 | sub do_n_dialog { |
288 | my ($cb) = @_; |
212 | my ($cb) = @_; |
289 | |
213 | |
290 | my $w = new CFClient::UI::FancyFrame; |
214 | my $w = new CFPlus::UI::Toplevel |
|
|
215 | on_delete => sub { $_[0]->destroy; 1 }, |
|
|
216 | has_close_button => 1, |
|
|
217 | ; |
|
|
218 | |
291 | $w->add (my $vb = new CFClient::UI::VBox x => "center", y => "center"); |
219 | $w->add (my $vb = new CFPlus::UI::VBox x => "center", y => "center"); |
292 | $vb->add (new CFClient::UI::Label text => "Enter item count:"); |
220 | $vb->add (new CFPlus::UI::Label text => "Enter item count:"); |
293 | $vb->add (my $entry = new CFClient::UI::Entry |
221 | $vb->add (my $entry = new CFPlus::UI::Entry |
294 | text => $last_enter_count, |
222 | text => $last_enter_count, |
295 | on_activate => sub { |
223 | on_activate => sub { |
296 | my ($entry) = @_; |
224 | my ($entry) = @_; |
297 | $last_enter_count = $entry->get_text; |
225 | $last_enter_count = $entry->get_text; |
298 | $cb->($last_enter_count); |
226 | $cb->($last_enter_count); |
299 | $w->hide; |
227 | $w->hide; |
300 | $w = undef; |
228 | $w->destroy; |
|
|
229 | |
|
|
230 | 0 |
301 | } |
231 | }, |
|
|
232 | on_escape => sub { $w->destroy; 1 }, |
302 | ); |
233 | ); |
303 | $entry->grab_focus; |
234 | $entry->grab_focus; |
304 | $w->show; |
235 | $w->show; |
305 | |
|
|
306 | } |
236 | } |
307 | |
237 | |
308 | sub update_widgets { |
238 | sub update_widgets { |
309 | my ($self) = @_; |
239 | my ($self) = @_; |
310 | |
240 | |
… | |
… | |
318 | |
248 | |
319 | if ($self->{container} == $::CONN->{player}{tag}) { |
249 | if ($self->{container} == $::CONN->{player}{tag}) { |
320 | $targ = $::CONN->{open_container}; |
250 | $targ = $::CONN->{open_container}; |
321 | } |
251 | } |
322 | |
252 | |
323 | if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) { |
253 | if (($ev->{mod} & CFPlus::KMOD_SHIFT) && $ev->{button} == 1) { |
324 | $::CONN->send ("move $targ $self->{tag} 0") |
254 | $::CONN->send ("move $targ $self->{tag} 0") |
325 | if $targ || !($self->{flags} & F_LOCKED); |
255 | if $targ || !($self->{flags} & F_LOCKED); |
326 | } elsif (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 2) { |
256 | } elsif (($ev->{mod} & CFPlus::KMOD_SHIFT) && $ev->{button} == 2) { |
327 | $self->{flags} & F_LOCKED |
257 | $self->{flags} & F_LOCKED |
328 | ? $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) |
258 | ? $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) |
329 | : $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) |
259 | : $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) |
330 | } elsif ($ev->{button} == 1) { |
260 | } elsif ($ev->{button} == 1) { |
331 | $::CONN->send ("examine $self->{tag}"); |
261 | $::CONN->send ("examine $self->{tag}"); |
332 | } elsif ($ev->{button} == 2) { |
262 | } elsif ($ev->{button} == 2) { |
333 | $::CONN->send ("apply $self->{tag}"); |
263 | $::CONN->send ("apply $self->{tag}"); |
334 | } elsif ($ev->{button} == 3) { |
264 | } elsif ($ev->{button} == 3) { |
|
|
265 | my $move_prefix = $::CONN->{open_container} ? 'put' : 'drop'; |
|
|
266 | if ($self->{container} == $::CONN->{open_container}) { |
|
|
267 | $move_prefix = "take"; |
|
|
268 | } |
|
|
269 | |
335 | my @menu_items = ( |
270 | my @menu_items = ( |
336 | ["examine", sub { $::CONN->send ("examine $self->{tag}") }], |
271 | ["examine", sub { $::CONN->send ("examine $self->{tag}") }], |
337 | ["mark", sub { $::CONN->send ("mark ". pack "N", $self->{tag}) }], |
272 | ["mark", sub { $::CONN->send ("mark ". pack "N", $self->{tag}) }], |
338 | ["ignite/thaw", # first try of an easier use of flint&steel |
273 | ["ignite/thaw", # first try of an easier use of flint&steel |
339 | sub { |
274 | sub { |
340 | $::CONN->send ("mark ". pack "N", $self->{tag}); |
275 | $::CONN->send ("mark ". pack "N", $self->{tag}); |
341 | $::CONN->send ("command apply flint and steel"); |
276 | $::CONN->send ("command apply flint and steel"); |
|
|
277 | } |
|
|
278 | ], |
|
|
279 | ["inscribe", # first try of an easier use of flint&steel |
|
|
280 | sub { |
|
|
281 | &::open_string_query ("Text to inscribe", sub { |
|
|
282 | my ($entry, $txt) = @_; |
|
|
283 | $::CONN->send ("mark ". pack "N", $self->{tag}); |
|
|
284 | $::CONN->send ("command use_skill inscription $txt"); |
|
|
285 | }); |
|
|
286 | } |
|
|
287 | ], |
|
|
288 | ["rename", # first try of an easier use of flint&steel |
|
|
289 | sub { |
|
|
290 | &::open_string_query ("Rename item to:", sub { |
|
|
291 | my ($entry, $txt) = @_; |
|
|
292 | $::CONN->send ("mark ". pack "N", $self->{tag}); |
|
|
293 | $::CONN->send ("command rename to <$txt>"); |
|
|
294 | }, $self->{name}, |
|
|
295 | "If you input no name or erase the current custom name, the custom name will be unset"); |
342 | } |
296 | } |
343 | ], |
297 | ], |
344 | ["apply", sub { $::CONN->send ("apply $self->{tag}") }], |
298 | ["apply", sub { $::CONN->send ("apply $self->{tag}") }], |
345 | ( |
299 | ( |
346 | $self->{flags} & F_LOCKED |
300 | $self->{flags} & F_LOCKED |
347 | ? ( |
301 | ? ( |
348 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], |
302 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], |
349 | ) |
303 | ) |
350 | : ( |
304 | : ( |
351 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], |
305 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], |
352 | ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }], |
306 | ["$move_prefix all", sub { $::CONN->send ("move $targ $self->{tag} 0") }], |
353 | ["move n", |
307 | ["$move_prefix <n>", |
354 | sub { |
308 | sub { |
355 | do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") }) |
309 | do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") }) |
356 | } |
310 | } |
357 | ] |
311 | ] |
358 | ) |
312 | ) |
359 | ), |
313 | ), |
360 | ); |
314 | ); |
361 | |
315 | |
362 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
316 | CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev); |
363 | } |
317 | } |
364 | |
318 | |
365 | 1 |
319 | 1 |
366 | }; |
320 | }; |
367 | |
321 | |
… | |
… | |
371 | . "Middle click - apply\n" |
325 | . "Middle click - apply\n" |
372 | . "Shift-Middle click - lock/unlock\n" |
326 | . "Shift-Middle click - lock/unlock\n" |
373 | . "Right click - further options" |
327 | . "Right click - further options" |
374 | . "</small>\n"; |
328 | . "</small>\n"; |
375 | |
329 | |
|
|
330 | my $bg = $self->{flags} & F_CURSED ? [1 , 0 , 0, 0.5] |
|
|
331 | : $self->{flags} & F_MAGIC ? [0.2, 0.2, 1, 0.5] |
|
|
332 | : undef; |
|
|
333 | |
376 | $self->{face_widget} ||= new CFClient::UI::Face |
334 | $self->{face_widget} ||= new CFPlus::UI::Face |
377 | can_events => 1, |
335 | can_events => 1, |
378 | can_hover => 1, |
336 | can_hover => 1, |
379 | anim => $self->{anim}, |
337 | anim => $self->{anim}, |
380 | animspeed => $self->{animspeed}, # TODO# must be set at creation time |
338 | animspeed => $self->{animspeed}, # TODO# must be set at creation time |
381 | on_button_down => $button_cb, |
339 | on_button_down => $button_cb, |
382 | ; |
340 | ; |
|
|
341 | $self->{face_widget}{bg} = $bg; |
383 | $self->{face_widget}{face} = $self->{face}; |
342 | $self->{face_widget}{face} = $self->{face}; |
384 | $self->{face_widget}{anim} = $self->{anim}; |
343 | $self->{face_widget}{anim} = $self->{anim}; |
385 | $self->{face_widget}{animspeed} = $self->{animspeed}; |
344 | $self->{face_widget}{animspeed} = $self->{animspeed}; |
386 | $self->{face_widget}->set_tooltip ( |
345 | $self->{face_widget}->set_tooltip ( |
387 | "<b>Face/Animation.</b>\n" |
346 | "<b>Face/Animation.</b>\n" |
388 | . "Item uses face #$self->{face}. " |
347 | . "Item uses face #$self->{face}. " |
389 | . ($self->{animspeed} ? "Item uses animation #$self->{anim} at " . (1 / $self->{animspeed}) . "fps. " : "Item is not animated. ") |
348 | . ($self->{animspeed} ? "Item uses animation #$self->{anim} at " . (1 / $self->{animspeed}) . "fps. " : "Item is not animated. ") |
390 | . "\n\n$tooltip_std" |
349 | . "\n\n$tooltip_std" |
391 | ); |
350 | ); |
392 | |
351 | |
393 | $self->{desc_widget} ||= new CFClient::UI::Label |
352 | $self->{desc_widget} ||= new CFPlus::UI::Label |
394 | can_events => 1, |
353 | can_events => 1, |
395 | can_hover => 1, |
354 | can_hover => 1, |
396 | ellipsise => 2, |
355 | ellipsise => 2, |
397 | align => -1, |
356 | align => -1, |
398 | on_button_down => $button_cb, |
357 | on_button_down => $button_cb, |
399 | ; |
358 | ; |
400 | my $desc = CFClient::Item::desc_string $self; |
359 | my $desc = CFPlus::Item::desc_string $self; |
|
|
360 | $self->{desc_widget}{bg} = $bg; |
401 | $self->{desc_widget}->set_text ($desc); |
361 | $self->{desc_widget}->set_text ($desc); |
402 | $self->{desc_widget}->set_tooltip ("<b>$desc</b>.\n$tooltip_std"); |
362 | $self->{desc_widget}->set_tooltip ("<b>$desc</b>.\n$tooltip_std"); |
403 | |
363 | |
404 | $self->{weight_widget} ||= new CFClient::UI::Label |
364 | $self->{weight_widget} ||= new CFPlus::UI::Label |
405 | can_events => 1, |
365 | can_events => 1, |
406 | can_hover => 1, |
366 | can_hover => 1, |
407 | ellipsise => 0, |
367 | ellipsise => 0, |
408 | align => 0, |
368 | align => 0, |
409 | on_button_down => $button_cb, |
369 | on_button_down => $button_cb, |
410 | ; |
370 | ; |
|
|
371 | $self->{weight_widget}{bg} = $bg; |
411 | $self->{weight_widget}->set_text (CFClient::Item::weight_string $self); |
372 | $self->{weight_widget}->set_text (CFPlus::Item::weight_string $self); |
412 | |
|
|
413 | $self->{weight_widget}->set_tooltip ( |
373 | $self->{weight_widget}->set_tooltip ( |
414 | "<b>Weight</b>.\n" |
374 | "<b>Weight</b>.\n" |
415 | . ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ") |
375 | . ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ") |
416 | . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ") |
376 | . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ") |
417 | . "\n\n$tooltip_std" |
377 | . "\n\n$tooltip_std" |