… | |
… | |
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 | }; |
… | |
… | |
638 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
655 | $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 |
656 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
640 | text => $CFG->{say_command}, |
657 | text => $CFG->{say_command}, |
641 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
658 | 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. " |
659 | ."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.", |
660 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
644 | connect_changed => sub { |
661 | connect_changed => sub { |
645 | my ($self, $value) = @_; |
662 | my ($self, $value) = @_; |
646 | $CFG->{say_command} = $value; |
663 | $CFG->{say_command} = $value; |
647 | } |
664 | } |
648 | ); |
665 | ); |
… | |
… | |
1083 | } |
1100 | } |
1084 | |
1101 | |
1085 | gotid: |
1102 | gotid: |
1086 | $face->{id} = $id; |
1103 | $face->{id} = $id; |
1087 | $MAP->set_face ($facenum => $id); |
1104 | $MAP->set_face ($facenum => $id); |
|
|
1105 | $self->{faceid}[$facenum] = $id;#d# |
1088 | $TILECACHE->get ($id) |
1106 | $TILECACHE->get ($id) |
1089 | } |
1107 | } |
1090 | |
1108 | |
1091 | sub conn::face_update { |
1109 | sub conn::face_update { |
1092 | my ($self, $facenum, $face) = @_; |
1110 | my ($self, $facenum, $face) = @_; |
… | |
… | |
1100 | my ($self, $id, $data) = @_; |
1118 | my ($self, $id, $data) = @_; |
1101 | |
1119 | |
1102 | $self->{texture}[$id] ||= do { |
1120 | $self->{texture}[$id] ||= do { |
1103 | my $tex = |
1121 | my $tex = |
1104 | new_from_image CFClient::Texture |
1122 | new_from_image CFClient::Texture |
1105 | $data, minify => 1; |
1123 | $data, minify => 1, mipmap => 1; |
1106 | |
1124 | |
1107 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1125 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1108 | $MAPWIDGET->update; |
1126 | $MAPWIDGET->update; |
1109 | |
1127 | |
1110 | $tex |
1128 | $tex |
… | |
… | |
1122 | |
1140 | |
1123 | $chunk->play; |
1141 | $chunk->play; |
1124 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1142 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1125 | } |
1143 | } |
1126 | |
1144 | |
|
|
1145 | my $LAST_QUERY; # server is stupid, stupid, stupid |
|
|
1146 | |
1127 | sub conn::query { |
1147 | sub conn::query { |
1128 | my ($self, $flags, $prompt) = @_; |
1148 | my ($self, $flags, $prompt) = @_; |
1129 | |
1149 | |
1130 | #TODO, display dialog with relevant information |
1150 | $prompt = $LAST_QUERY unless length $prompt; |
1131 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
1151 | $LAST_QUERY = $prompt; |
|
|
1152 | |
|
|
1153 | my $dialog = new CFClient::UI::FancyFrame |
|
|
1154 | title => "Query", |
|
|
1155 | child => my $vbox = new CFClient::UI::VBox; |
|
|
1156 | |
|
|
1157 | $vbox->add (new CFClient::UI::Label |
|
|
1158 | max_w => $::WIDTH * 0.4, |
|
|
1159 | text => $prompt); |
|
|
1160 | |
|
|
1161 | if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) { |
|
|
1162 | $vbox->add (my $hbox = new CFClient::HBox); |
|
|
1163 | $hbox->add (new CFClient::Button |
|
|
1164 | text => "No", |
|
|
1165 | connect_activate => sub { |
|
|
1166 | $self->send ("reply n"); |
|
|
1167 | $dialog->destroy; |
|
|
1168 | $MAPWIDGET->focus_in; |
|
|
1169 | } |
|
|
1170 | ); |
|
|
1171 | $hbox->add (new CFClient::Button |
|
|
1172 | text => "Yes", |
|
|
1173 | connect_activate => sub { |
|
|
1174 | $self->send ("reply y"); |
|
|
1175 | $dialog->destroy; |
|
|
1176 | $MAPWIDGET->focus_in; |
|
|
1177 | }, |
|
|
1178 | ); |
|
|
1179 | |
|
|
1180 | $dialog->focus_in; |
|
|
1181 | |
|
|
1182 | } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) { |
|
|
1183 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
|
|
1184 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1185 | connect_changed => sub { |
|
|
1186 | $self->send ("reply $_[1]"); |
|
|
1187 | $dialog->destroy; |
|
|
1188 | $MAPWIDGET->focus_in; |
|
|
1189 | }, |
|
|
1190 | ); |
|
|
1191 | |
|
|
1192 | $entry->focus_in; |
|
|
1193 | |
|
|
1194 | } else { |
|
|
1195 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
|
|
1196 | |
|
|
1197 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1198 | $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
|
|
1199 | connect_activate => sub { |
|
|
1200 | $self->send ("reply $_[1]"); |
|
|
1201 | $dialog->destroy; |
|
|
1202 | $MAPWIDGET->focus_in; |
|
|
1203 | }, |
|
|
1204 | ); |
|
|
1205 | |
|
|
1206 | $entry->focus_in; |
|
|
1207 | } |
|
|
1208 | |
|
|
1209 | $dialog->show; |
1132 | } |
1210 | } |
1133 | |
1211 | |
1134 | sub conn::drawinfo { |
1212 | sub conn::drawinfo { |
1135 | my ($self, $color, $text) = @_; |
1213 | my ($self, $color, $text) = @_; |
1136 | |
1214 | |
… | |
… | |
1154 | } |
1232 | } |
1155 | |
1233 | |
1156 | sub conn::spell_add { |
1234 | sub conn::spell_add { |
1157 | my ($self, $spell) = @_; |
1235 | my ($self, $spell) = @_; |
1158 | |
1236 | |
|
|
1237 | # TODO |
|
|
1238 | # create a widget dynamically, using spell face (CF::Protocol downloads them) |
1159 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
1239 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}); |
1160 | }); |
|
|
1161 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
1240 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}); |
1162 | }); |
|
|
1163 | } |
1241 | } |
1164 | |
1242 | |
1165 | sub conn::spell_delete { |
1243 | sub conn::spell_delete { |
1166 | my ($self, $spell) = @_; |
1244 | my ($self, $spell) = @_; |
1167 | } |
1245 | } |
1168 | |
1246 | |
1169 | sub conn::addme_success { |
1247 | sub conn::addme_success { |
1170 | my ($self) = @_; |
1248 | my ($self) = @_; |
1171 | |
1249 | |
1172 | for my $skill (values %{$self->{skill_info}}) { |
1250 | for my $skill (values %{$self->{skill_info}}) { |
1173 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
1251 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1174 | }); |
1252 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1175 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
1176 | }); |
|
|
1177 | } |
1253 | } |
|
|
1254 | } |
|
|
1255 | |
|
|
1256 | sub update_floorbox { |
|
|
1257 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
|
|
1258 | $FLOORBOX->clear; |
|
|
1259 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
|
|
1260 | |
|
|
1261 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1262 | |
|
|
1263 | # we basically have to use the same sorting as everybody else |
|
|
1264 | @items = sort { $a->{type} <=> $b->{type} } @items; |
|
|
1265 | |
|
|
1266 | for my $item (reverse @items) { |
|
|
1267 | my $desc = $item->{nrof} < 2 |
|
|
1268 | ? $item->{name} |
|
|
1269 | : "$item->{nrof} $item->{name_pl}"; |
|
|
1270 | # todo: animation widget, face widget, weight(?) etc. |
|
|
1271 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
|
|
1272 | tooltip => (CFClient::UI::Label->escape ($desc) |
|
|
1273 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
|
|
1274 | can_hover => 1, |
|
|
1275 | can_events => 1, |
|
|
1276 | ); |
|
|
1277 | |
|
|
1278 | $hbox->add (new CFClient::UI::Face |
|
|
1279 | face => $item->{face}, |
|
|
1280 | anim => $item->{anim}, |
|
|
1281 | animspeed => $item->{animspeed}, |
|
|
1282 | ); |
|
|
1283 | |
|
|
1284 | $hbox->add (new CFClient::UI::Label |
|
|
1285 | text => $desc, |
|
|
1286 | ); |
|
|
1287 | } |
|
|
1288 | }); |
|
|
1289 | refresh; |
1178 | } |
1290 | } |
1179 | |
1291 | |
1180 | sub conn::container_add { |
1292 | sub conn::container_add { |
1181 | my ($self, $id, $items) = @_; |
1293 | my ($self, $id, $items) = @_; |
1182 | |
1294 | |
1183 | # 0 floor |
1295 | update_floorbox if $id == 0; |
1184 | # $self-<{player}{tag} => player inv |
1296 | # $self-<{player}{tag} => player inv |
1185 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1297 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1186 | } |
1298 | } |
1187 | |
1299 | |
1188 | sub conn::container_clear { |
1300 | sub conn::container_clear { |
1189 | my ($self, $id) = @_; |
1301 | my ($self, $id) = @_; |
|
|
1302 | |
|
|
1303 | update_floorbox if $id == 0; |
1190 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1304 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
|
|
1305 | } |
|
|
1306 | |
|
|
1307 | sub conn::item_delete { |
|
|
1308 | my ($self, @items) = @_; |
|
|
1309 | |
|
|
1310 | for (@items) { |
|
|
1311 | update_floorbox if $_->{container} == 0; |
|
|
1312 | } |
|
|
1313 | } |
|
|
1314 | |
|
|
1315 | sub conn::item_update { |
|
|
1316 | my ($self, $item) = @_; |
|
|
1317 | |
|
|
1318 | update_floorbox if $item->{container} == 0; |
1191 | } |
1319 | } |
1192 | |
1320 | |
1193 | %SDL_CB = ( |
1321 | %SDL_CB = ( |
1194 | CFClient::SDL_QUIT => sub { |
1322 | CFClient::SDL_QUIT => sub { |
1195 | Event::unloop -1; |
1323 | Event::unloop -1; |