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.169 by root, Mon Apr 24 02:41:48 2006 UTC vs.
Revision 1.175 by root, Mon Apr 24 06:57:39 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
1122 1142
1123 $chunk->play; 1143 $chunk->play;
1124# warn "sound $x,$y,$soundnum,$type\n";#d# 1144# warn "sound $x,$y,$soundnum,$type\n";#d#
1125} 1145}
1126 1146
1147my $LAST_QUERY; # server is stupid, stupid, stupid
1148
1127sub conn::query { 1149sub conn::query {
1128 my ($self, $flags, $prompt) = @_; 1150 my ($self, $flags, $prompt) = @_;
1129 1151
1130 #TODO, display dialog with relevant information 1152 $prompt = $LAST_QUERY unless length $prompt;
1131 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 1153 $LAST_QUERY = $prompt;
1154
1155 my $dialog = new CFClient::UI::FancyFrame
1156 title => "Query",
1157 child => my $vbox = new CFClient::UI::VBox;
1158
1159 $vbox->add (new CFClient::UI::Label
1160 max_w => $::WIDTH * 0.4,
1161 text => $prompt);
1162
1163 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) {
1164 $vbox->add (my $hbox = new CFClient::HBox);
1165 $hbox->add (new CFClient::Button
1166 text => "No",
1167 connect_activate => sub {
1168 $self->send ("reply n");
1169 $dialog->destroy;
1170 $MAPWIDGET->focus_in;
1171 }
1172 );
1173 $hbox->add (new CFClient::Button
1174 text => "Yes",
1175 connect_activate => sub {
1176 $self->send ("reply y");
1177 $dialog->destroy;
1178 $MAPWIDGET->focus_in;
1179 },
1180 );
1181
1182 $dialog->focus_in;
1183
1184 } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) {
1185 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
1186 $vbox->add (my $entry = new CFClient::UI::Entry
1187 connect_changed => sub {
1188 $self->send ("reply $_[1]");
1189 $dialog->destroy;
1190 $MAPWIDGET->focus_in;
1191 },
1192 );
1193
1194 $entry->focus_in;
1195
1196 } else {
1197 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
1198
1199 $vbox->add (my $entry = new CFClient::UI::Entry
1200 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
1201 connect_activate => sub {
1202 $self->send ("reply $_[1]");
1203 $dialog->destroy;
1204 $MAPWIDGET->focus_in;
1205 },
1206 );
1207
1208 $entry->focus_in;
1209 }
1210
1211 $dialog->show;
1132} 1212}
1133 1213
1134sub conn::drawinfo { 1214sub conn::drawinfo {
1135 my ($self, $color, $text) = @_; 1215 my ($self, $color, $text) = @_;
1136 1216
1154} 1234}
1155 1235
1156sub conn::spell_add { 1236sub conn::spell_add {
1157 my ($self, $spell) = @_; 1237 my ($self, $spell) = @_;
1158 1238
1239 # TODO
1240 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1159 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { 1241 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message});
1160 });
1161 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { 1242 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message});
1162 });
1163} 1243}
1164 1244
1165sub conn::spell_delete { 1245sub conn::spell_delete {
1166 my ($self, $spell) = @_; 1246 my ($self, $spell) = @_;
1167} 1247}
1168 1248
1169sub conn::addme_success { 1249sub conn::addme_success {
1170 my ($self) = @_; 1250 my ($self) = @_;
1171 1251
1172 for my $skill (values %{$self->{skill_info}}) { 1252 for my $skill (values %{$self->{skill_info}}) {
1173 $MAPWIDGET->add_command ("ready_skill $skill", "", sub { 1253 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1174 }); 1254 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1175 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
1176 });
1177 } 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 can_events => 0,
1297 face => $item->{face},
1298 anim => $item->{anim},
1299 animspeed => $item->{animspeed},
1300 );
1301
1302 $hbox->add (new CFClient::UI::Label
1303 can_events => 0,
1304 text => $desc,
1305 );
1306 }
1307 });
1308 refresh;
1178} 1309}
1179 1310
1180sub conn::container_add { 1311sub conn::container_add {
1181 my ($self, $id, $items) = @_; 1312 my ($self, $id, $items) = @_;
1182 1313
1183 # 0 floor 1314 update_floorbox if $id == 0;
1184 # $self-<{player}{tag} => player inv 1315 # $self-<{player}{tag} => player inv
1185 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1316 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1186} 1317}
1187 1318
1188sub conn::container_clear { 1319sub conn::container_clear {
1189 my ($self, $id) = @_; 1320 my ($self, $id) = @_;
1321
1322 update_floorbox if $id == 0;
1190# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1323# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1324}
1325
1326sub conn::item_delete {
1327 my ($self, @items) = @_;
1328
1329 for (@items) {
1330 update_floorbox if $_->{container} == 0;
1331 }
1332}
1333
1334sub conn::item_update {
1335 my ($self, $item) = @_;
1336
1337 update_floorbox if $item->{container} == 0;
1191} 1338}
1192 1339
1193%SDL_CB = ( 1340%SDL_CB = (
1194 CFClient::SDL_QUIT => sub { 1341 CFClient::SDL_QUIT => sub {
1195 Event::unloop -1; 1342 Event::unloop -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines