ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.170 by root, Mon Apr 24 03:19:42 2006 UTC vs.
Revision 1.174 by root, Mon Apr 24 06:40:30 2006 UTC

47our $BUTTONBAR; 47our $BUTTONBAR;
48our $LOGVIEW; 48our $LOGVIEW;
49our $CONSOLE; 49our $CONSOLE;
50our $METASERVER; 50our $METASERVER;
51 51
52our $FLOORBOX;
52our $GAUGES; 53our $GAUGES;
53our $STATWIDS; 54our $STATWIDS;
54 55
55our $SDL_ACTIVE; 56our $SDL_ACTIVE;
56our %SDL_CB; 57our %SDL_CB;
308# my $gw = int ($WIDTH * $CFG->{gauge_w_size}); 309# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
309 310
310 my $win = new CFClient::UI::Frame ( 311 my $win = new CFClient::UI::Frame (
311 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh 312 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
312 ); 313 );
313 $win->add (my $vb = new CFClient::UI::VBox); 314 $win->add (my $hbox = new CFClient::UI::HBox
314 315 children => [
315 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1); 316 (new CFClient::UI::HBox expand => 1),
317 ($FLOORBOX = new CFClient::UI::VBox),
318 (my $vbox = new CFClient::UI::VBox),
319 ],
320 );
316 321
322 $vbox->add (new CFClient::UI::HBox
323 expand => 1,
324 children => [
317 $hbg->add (new CFClient::UI::Empty expand => 1); 325 (new CFClient::UI::Empty expand => 1),
318 $hbg->add (my $hb = new CFClient::UI::HBox); 326 (my $hb = new CFClient::UI::HBox),
327 ],
328 );
329
319 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', tooltip => "Health points"); 330 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp',
331 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle");
320 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', tooltip => "Spellpoints"); 332 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana',
333 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle");
321 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', tooltip => "Grace"); 334 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace',
335 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray");
322 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', tooltip => "Food"); 336 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food',
337 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food");
323 338
324 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP: 0 LVL: 0"); 339 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
340 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills");
325 $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, text => "Rng:"); 341 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
342 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
326 343
327 $GAUGES = { 344 $GAUGES = {
328 exp => $exp, win => $win, range => $rng, 345 exp => $exp, win => $win, range => $rng,
329 food => $fg, mana => $mg, hp => $hg, grace => $gg 346 food => $fg, mana => $mg, hp => $hg, grace => $gg
330 }; 347 };
342 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 359 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
343 360
344 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 361 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
345 362
346 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 363 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
364
365 my $black = [0, 0, 0];
347 366
348 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 367 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
349 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 368 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
350 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 369 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
351 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 370 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
352 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 371 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
353 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 372 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
354 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 373 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
355 374
356 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str"); 375 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str");
357 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dex"); 376 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex");
358 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Con"); 377 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con");
359 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Int"); 378 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int");
360 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wis"); 379 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis");
361 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Pow"); 380 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow");
362 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Cha"); 381 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha");
363 382
364 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 383 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
365 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 384 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
366 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 385 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
367 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 386 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
368 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54"); 387 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
369 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9"); 388 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
370 389
371 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); 390 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc");
372 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac"); 391 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac");
373 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam"); 392 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam");
374 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm"); 393 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm");
375 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp"); 394 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp");
376 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp"); 395 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp");
377 396
378 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 397 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
379 398
380 my $row = 0; 399 my $row = 0;
381 my $col = 0; 400 my $col = 0;
638 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 657 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
639 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry 658 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
640 text => $CFG->{say_command}, 659 text => $CFG->{say_command},
641 tooltip => "This is the command that will be used if you write a line in the message window entry. " 660 tooltip => "This is the command that will be used if you write a line in the message window entry. "
642 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 661 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
643 ."But you could also set it to 'tell <playername>' to only chat with that user.", 662 ."But you could also set it to 'tell &lt;playername&gt;' to only chat with that user.",
644 connect_changed => sub { 663 connect_changed => sub {
645 my ($self, $value) = @_; 664 my ($self, $value) = @_;
646 $CFG->{say_command} = $value; 665 $CFG->{say_command} = $value;
647 } 666 }
648 ); 667 );
1083 } 1102 }
1084 1103
1085gotid: 1104gotid:
1086 $face->{id} = $id; 1105 $face->{id} = $id;
1087 $MAP->set_face ($facenum => $id); 1106 $MAP->set_face ($facenum => $id);
1107 $self->{faceid}[$facenum] = $id;#d#
1088 $TILECACHE->get ($id) 1108 $TILECACHE->get ($id)
1089} 1109}
1090 1110
1091sub conn::face_update { 1111sub conn::face_update {
1092 my ($self, $facenum, $face) = @_; 1112 my ($self, $facenum, $face) = @_;
1100 my ($self, $id, $data) = @_; 1120 my ($self, $id, $data) = @_;
1101 1121
1102 $self->{texture}[$id] ||= do { 1122 $self->{texture}[$id] ||= do {
1103 my $tex = 1123 my $tex =
1104 new_from_image CFClient::Texture 1124 new_from_image CFClient::Texture
1105 $data, minify => 1; 1125 $data, minify => 1, mipmap => 1;
1106 1126
1107 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 1127 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
1108 $MAPWIDGET->update; 1128 $MAPWIDGET->update;
1109 1129
1110 $tex 1130 $tex
1214} 1234}
1215 1235
1216sub conn::spell_add { 1236sub conn::spell_add {
1217 my ($self, $spell) = @_; 1237 my ($self, $spell) = @_;
1218 1238
1239 # TODO
1240 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1219 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { 1241 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message});
1220 });
1221 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { 1242 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message});
1222 });
1223} 1243}
1224 1244
1225sub conn::spell_delete { 1245sub conn::spell_delete {
1226 my ($self, $spell) = @_; 1246 my ($self, $spell) = @_;
1227} 1247}
1228 1248
1229sub conn::addme_success { 1249sub conn::addme_success {
1230 my ($self) = @_; 1250 my ($self) = @_;
1231 1251
1232 for my $skill (values %{$self->{skill_info}}) { 1252 for my $skill (values %{$self->{skill_info}}) {
1233 $MAPWIDGET->add_command ("ready_skill $skill", "", sub { 1253 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1234 }); 1254 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1235 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
1236 });
1237 } 1255 }
1256}
1257
1258sub update_floorbox {
1259 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1260 $FLOORBOX->clear;
1261 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1262
1263 my @items = values %{ $CONN->{container}{0} };
1264
1265 # we basically have to use the same sorting as everybody else
1266 @items = sort { $a->{type} <=> $b->{type} } @items;
1267
1268 for my $item (reverse @items) {
1269 my $desc = $item->{nrof} < 2
1270 ? $item->{name}
1271 : "$item->{nrof} $item->{name_pl}";
1272 # todo: animation widget, face widget, weight(?) etc.
1273 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1274 tooltip => (CFClient::UI::Label->escape ($desc)
1275 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1276 can_hover => 1,
1277 can_events => 1,
1278 connect_button_down => sub {
1279 my ($self, $ev, $x, $y) = @_;
1280
1281 # todo: maybe put examine on 1? but should just be a tooltip :(
1282 if ($ev->{button} == 1) {
1283 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1284 } elsif ($ev->{button} == 2) {
1285 $CONN->send ("apply $item->{tag}");
1286 } elsif ($ev->{button} == 3) {
1287 # examine, lock, mark, maybe other things
1288 warn "MENU not implemented yet\n";
1289 }
1290
1291 1
1292 },
1293 );
1294
1295 $hbox->add (new CFClient::UI::Face
1296 face => $item->{face},
1297 anim => $item->{anim},
1298 animspeed => $item->{animspeed},
1299 );
1300
1301 $hbox->add (new CFClient::UI::Label
1302 text => $desc,
1303 );
1304 }
1305 });
1306 refresh;
1238} 1307}
1239 1308
1240sub conn::container_add { 1309sub conn::container_add {
1241 my ($self, $id, $items) = @_; 1310 my ($self, $id, $items) = @_;
1242 1311
1243 # 0 floor 1312 update_floorbox if $id == 0;
1244 # $self-<{player}{tag} => player inv 1313 # $self-<{player}{tag} => player inv
1245 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1314 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1246} 1315}
1247 1316
1248sub conn::container_clear { 1317sub conn::container_clear {
1249 my ($self, $id) = @_; 1318 my ($self, $id) = @_;
1319
1320 update_floorbox if $id == 0;
1250# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1321# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1322}
1323
1324sub conn::item_delete {
1325 my ($self, @items) = @_;
1326
1327 for (@items) {
1328 update_floorbox if $_->{container} == 0;
1329 }
1330}
1331
1332sub conn::item_update {
1333 my ($self, $item) = @_;
1334
1335 update_floorbox if $item->{container} == 0;
1251} 1336}
1252 1337
1253%SDL_CB = ( 1338%SDL_CB = (
1254 CFClient::SDL_QUIT => sub { 1339 CFClient::SDL_QUIT => sub {
1255 Event::unloop -1; 1340 Event::unloop -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines