… | |
… | |
47 | our $BUTTONBAR; |
47 | our $BUTTONBAR; |
48 | our $LOGVIEW; |
48 | our $LOGVIEW; |
49 | our $CONSOLE; |
49 | our $CONSOLE; |
50 | our $METASERVER; |
50 | our $METASERVER; |
51 | |
51 | |
|
|
52 | our $FLOORBOX; |
52 | our $GAUGES; |
53 | our $GAUGES; |
53 | our $STATWIDS; |
54 | our $STATWIDS; |
54 | |
55 | |
55 | our $SDL_ACTIVE; |
56 | our $SDL_ACTIVE; |
56 | our %SDL_CB; |
57 | our %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 <playername>' 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 | |
1085 | gotid: |
1104 | gotid: |
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 | |
1091 | sub conn::face_update { |
1111 | sub 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 |
… | |
… | |
1233 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1253 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1234 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1254 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1235 | } |
1255 | } |
1236 | } |
1256 | } |
1237 | |
1257 | |
|
|
1258 | sub 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; |
|
|
1309 | } |
|
|
1310 | |
1238 | sub conn::container_add { |
1311 | sub conn::container_add { |
1239 | my ($self, $id, $items) = @_; |
1312 | my ($self, $id, $items) = @_; |
1240 | |
1313 | |
1241 | # 0 floor |
1314 | update_floorbox if $id == 0; |
1242 | # $self-<{player}{tag} => player inv |
1315 | # $self-<{player}{tag} => player inv |
1243 | #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}}; |
1244 | } |
1317 | } |
1245 | |
1318 | |
1246 | sub conn::container_clear { |
1319 | sub conn::container_clear { |
1247 | my ($self, $id) = @_; |
1320 | my ($self, $id) = @_; |
|
|
1321 | |
|
|
1322 | update_floorbox if $id == 0; |
1248 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1323 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
|
|
1324 | } |
|
|
1325 | |
|
|
1326 | sub conn::item_delete { |
|
|
1327 | my ($self, @items) = @_; |
|
|
1328 | |
|
|
1329 | for (@items) { |
|
|
1330 | update_floorbox if $_->{container} == 0; |
|
|
1331 | } |
|
|
1332 | } |
|
|
1333 | |
|
|
1334 | sub conn::item_update { |
|
|
1335 | my ($self, $item) = @_; |
|
|
1336 | |
|
|
1337 | update_floorbox if $item->{container} == 0; |
1249 | } |
1338 | } |
1250 | |
1339 | |
1251 | %SDL_CB = ( |
1340 | %SDL_CB = ( |
1252 | CFClient::SDL_QUIT => sub { |
1341 | CFClient::SDL_QUIT => sub { |
1253 | Event::unloop -1; |
1342 | Event::unloop -1; |