… | |
… | |
86 | our $CONSOLE; |
86 | our $CONSOLE; |
87 | our $METASERVER; |
87 | our $METASERVER; |
88 | our $LOGIN_BUTTON; |
88 | our $LOGIN_BUTTON; |
89 | our $QUIT_DIALOG; |
89 | our $QUIT_DIALOG; |
90 | our $HOST_ENTRY; |
90 | our $HOST_ENTRY; |
|
|
91 | our $FULLSCREEN_ENABLE; |
91 | our $PICKUP_ENABLE; |
92 | our $PICKUP_ENABLE; |
92 | our $SERVER_INFO; |
93 | our $SERVER_INFO; |
93 | |
94 | |
94 | our $SETUP_DIALOG; |
95 | our $SETUP_DIALOG; |
95 | our $SETUP_NOTEBOOK; |
96 | our $SETUP_NOTEBOOK; |
… | |
… | |
99 | our $PL_NOTEBOOK; |
100 | our $PL_NOTEBOOK; |
100 | our $PL_WINDOW; |
101 | our $PL_WINDOW; |
101 | |
102 | |
102 | our $INVENTORY_PAGE; |
103 | our $INVENTORY_PAGE; |
103 | our $STATS_PAGE; |
104 | our $STATS_PAGE; |
|
|
105 | our $SKILL_PAGE; |
104 | our $SPELL_PAGE; |
106 | our $SPELL_PAGE; |
105 | |
107 | |
106 | our $HELP_WINDOW; |
108 | our $HELP_WINDOW; |
107 | our $MESSAGE_WINDOW; |
109 | our $MESSAGE_WINDOW; |
108 | our $FLOORBOX; |
110 | our $FLOORBOX; |
… | |
… | |
416 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
418 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
417 | |
419 | |
418 | my $row = 1; |
420 | my $row = 1; |
419 | |
421 | |
420 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
422 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
421 | $table->add (1, $row++, new CFClient::UI::CheckBox |
423 | $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFClient::UI::CheckBox |
422 | state => $CFG->{fullscreen}, |
424 | state => $CFG->{fullscreen}, |
423 | tooltip => "Bring the client into fullscreen mode.", |
425 | tooltip => "Bring the client into fullscreen mode.", |
424 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
426 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
425 | ); |
427 | ); |
426 | |
428 | |
… | |
… | |
689 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
691 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
690 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
692 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
691 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
693 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
692 | } |
694 | } |
693 | |
695 | |
694 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
696 | $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
695 | |
697 | |
696 | my $row = 0; |
698 | my $row = 0; |
697 | my $col = 0; |
699 | my $col = 0; |
698 | |
700 | |
699 | my %resist_names = ( |
701 | my %resist_names = ( |
|
|
702 | slow => ["Slow", |
700 | slow => "<b>Slow</b> (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)", |
703 | "<b>Slow</b> (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)"], |
|
|
704 | holyw => ["Holy Word", |
701 | holyw => "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)", |
705 | "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)"], |
|
|
706 | conf => ["Confusion", |
702 | conf => "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
707 | "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)"], |
|
|
708 | fire => ["Fire", |
703 | fire => "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
709 | "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)"], |
|
|
710 | depl => ["Depletion", |
704 | depl => "<b>Depletion</b> (some monsters and other effects can cause stats depletion)", |
711 | "<b>Depletion</b> (some monsters and other effects can cause stats depletion)"], |
|
|
712 | magic => ["Magic", |
705 | magic => "<b>Magic</b> (resistance to magic spells like magic missile or similar)", |
713 | "<b>Magic</b> (resistance to magic spells like magic missile or similar)"], |
|
|
714 | drain => ["Draining", |
706 | drain => "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)", |
715 | "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)"], |
|
|
716 | acid => ["Acid", |
707 | acid => "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
717 | "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)"], |
|
|
718 | pois => ["Poison", |
708 | pois => "<b>Poison</b> (resistance to getting poisoned)", |
719 | "<b>Poison</b> (resistance to getting poisoned)"], |
|
|
720 | para => ["Paralysation", |
709 | para => "<b>Paralysation</b> (this resistance affects the chance you get paralysed)", |
721 | "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], |
|
|
722 | deat => ["Death", |
710 | deat => "<b>Death</b> (resistance against death spells)", |
723 | "<b>Death</b> (resistance against death spells)"], |
|
|
724 | phys => ["Physical", |
711 | phys => "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)", |
725 | "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"], |
|
|
726 | blind => ["Blind", |
712 | blind => "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)", |
727 | "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], |
|
|
728 | fear => ["Fear", |
713 | fear => "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)", |
729 | "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], |
|
|
730 | tund => ["Turn undead", |
714 | tund => "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead...", |
731 | "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead..."], |
|
|
732 | elec => ["Electricity", |
715 | elec => "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)", |
733 | "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)"], |
|
|
734 | cold => ["Cold", |
716 | cold => "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
735 | "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)"], |
|
|
736 | ghit => ["Ghost hit", |
717 | ghit => "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)", |
737 | "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)"], |
718 | ); |
738 | ); |
719 | for (qw/slow holyw conf fire depl magic |
739 | for (qw/slow holyw conf fire depl magic |
720 | drain acid pois para deat phys |
740 | drain acid pois para deat phys |
721 | blind fear tund elec cold ghit/) |
741 | blind fear tund elec cold ghit/) |
722 | { |
742 | { |
… | |
… | |
727 | template => "-100%", |
747 | template => "-100%", |
728 | align => +1, |
748 | align => +1, |
729 | valign => 0, |
749 | valign => 0, |
730 | can_events => 1, |
750 | can_events => 1, |
731 | can_hover => 1, |
751 | can_hover => 1, |
732 | tooltip => $resist_names{$_}, |
752 | tooltip => $resist_names{$_}->[1], |
733 | ); |
753 | ); |
734 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
754 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
735 | font => $FONT_FIXED, |
755 | font => $FONT_FIXED, |
736 | can_hover => 1, |
756 | can_hover => 1, |
737 | can_events => 1, |
757 | can_events => 1, |
738 | path => "ui/resist/resist_$_.png", |
758 | path => "ui/resist/resist_$_.png", |
739 | tooltip => $resist_names{$_}, |
759 | tooltip => $resist_names{$_}->[1], |
|
|
760 | ); |
|
|
761 | $tbl2->add ($col + 2, $row, new CFClient::UI::Label |
|
|
762 | text => $resist_names{$_}->[0], |
|
|
763 | font => $FONT_FIXED, |
|
|
764 | can_hover => 1, |
|
|
765 | can_events => 1, |
|
|
766 | tooltip => $resist_names{$_}->[1], |
740 | ); |
767 | ); |
741 | |
768 | |
742 | $row++; |
769 | $row++; |
743 | if ($row % 6 == 0) { |
770 | if ($row % 6 == 0) { |
744 | $col += 2; |
771 | $col += 3; |
745 | $row = 0; |
772 | $row = 0; |
746 | } |
773 | } |
747 | } |
774 | } |
748 | |
775 | |
749 | $vb->add (my $tbl3 = new CFClient::UI::Table expand => 1); |
|
|
750 | $STATWIDS->{"_skill_tbl"} = $tbl3; |
|
|
751 | |
|
|
752 | update_stats_window ({}); |
776 | #update_stats_window ({}); |
753 | |
777 | |
754 | $vb |
778 | $vb |
|
|
779 | } |
|
|
780 | |
|
|
781 | sub skill_window { |
|
|
782 | $STATWIDS->{skill_tbl} = new CFClient::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1] |
755 | } |
783 | } |
756 | |
784 | |
757 | sub formsep($) { |
785 | sub formsep($) { |
758 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
786 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
759 | } |
|
|
760 | |
|
|
761 | sub update_stats_window { |
|
|
762 | my ($stats) = @_; |
|
|
763 | |
|
|
764 | # I love text protocols... |
|
|
765 | |
|
|
766 | my $hp = $stats->{+CS_STAT_HP} * 1; |
|
|
767 | my $hp_m = $stats->{+CS_STAT_MAXHP} * 1; |
|
|
768 | my $sp = $stats->{+CS_STAT_SP} * 1; |
|
|
769 | my $sp_m = $stats->{+CS_STAT_MAXSP} * 1; |
|
|
770 | my $fo = $stats->{+CS_STAT_FOOD} * 1; |
|
|
771 | my $fo_m = 999; |
|
|
772 | my $gr = $stats->{+CS_STAT_GRACE} * 1; |
|
|
773 | my $gr_m = $stats->{+CS_STAT_MAXGRACE} * 1; |
|
|
774 | |
|
|
775 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
|
|
776 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
|
|
777 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
|
|
778 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
|
|
779 | $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{+CS_STAT_EXP64}) |
|
|
780 | . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); |
|
|
781 | my $rng = $stats->{+CS_STAT_RANGE}; |
|
|
782 | $rng =~ s/^Range: //; # thank you so much dear server |
|
|
783 | $GAUGES->{range} ->set_text ("Rng: " . $rng); |
|
|
784 | my $title = $stats->{+CS_STAT_TITLE}; |
|
|
785 | $title =~ s/^Player: //; |
|
|
786 | $STATWIDS->{title} ->set_text ("Title: " . $title); |
|
|
787 | |
|
|
788 | $STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR}); |
|
|
789 | $STATWIDS->{st_dex} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DEX}); |
|
|
790 | $STATWIDS->{st_con} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CON}); |
|
|
791 | $STATWIDS->{st_int} ->set_text (sprintf "%d" , $stats->{+CS_STAT_INT}); |
|
|
792 | $STATWIDS->{st_wis} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WIS}); |
|
|
793 | $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW}); |
|
|
794 | $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA}); |
|
|
795 | $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC}); |
|
|
796 | $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC}); |
|
|
797 | $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM}); |
|
|
798 | $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_RES_PHYS}); |
|
|
799 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); |
|
|
800 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); |
|
|
801 | |
|
|
802 | $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); |
|
|
803 | |
|
|
804 | my %tbl = ( |
|
|
805 | phys => CS_STAT_RES_PHYS, |
|
|
806 | magic => CS_STAT_RES_MAG, |
|
|
807 | fire => CS_STAT_RES_FIRE, |
|
|
808 | elec => CS_STAT_RES_ELEC, |
|
|
809 | cold => CS_STAT_RES_COLD, |
|
|
810 | conf => CS_STAT_RES_CONF, |
|
|
811 | acid => CS_STAT_RES_ACID, |
|
|
812 | drain => CS_STAT_RES_DRAIN, |
|
|
813 | ghit => CS_STAT_RES_GHOSTHIT, |
|
|
814 | pois => CS_STAT_RES_POISON, |
|
|
815 | slow => CS_STAT_RES_SLOW, |
|
|
816 | para => CS_STAT_RES_PARA, |
|
|
817 | tund => CS_STAT_TURN_UNDEAD, |
|
|
818 | fear => CS_STAT_RES_FEAR, |
|
|
819 | depl => CS_STAT_RES_DEPLETE, |
|
|
820 | deat => CS_STAT_RES_DEATH, |
|
|
821 | holyw => CS_STAT_RES_HOLYWORD, |
|
|
822 | blind => CS_STAT_RES_BLIND, |
|
|
823 | ); |
|
|
824 | |
|
|
825 | if ($::CONN && !$STATWIDS->{_skill_tbl_init}) { |
|
|
826 | my $sktbl = $STATWIDS->{_skill_tbl}; |
|
|
827 | $sktbl->clear; |
|
|
828 | |
|
|
829 | $sktbl->add (0, 0, new CFClient::UI::Label text => "Exp.", align => 1); |
|
|
830 | $sktbl->add (1, 0, new CFClient::UI::Label text => "Level", align => 1); |
|
|
831 | $sktbl->add (2, 0, new CFClient::UI::Label text => "Skillname"); |
|
|
832 | |
|
|
833 | my @skills; |
|
|
834 | |
|
|
835 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
836 | push @skills, [$i, $::CONN->{skill_info}{$i}]; |
|
|
837 | } |
|
|
838 | |
|
|
839 | my $y = 1; |
|
|
840 | for (sort { $a->[1] cmp $b->[1] } @skills) { |
|
|
841 | my ($idx, $name) = @$_; |
|
|
842 | |
|
|
843 | unless (defined $STATWIDS->{"sk_xp_$idx"} || !$::CONN->{skill_info}{$idx}) { |
|
|
844 | $sktbl->add (0, $y, $STATWIDS->{"sk_xp_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
845 | $sktbl->add (1, $y, $STATWIDS->{"sk_lvl_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
846 | $sktbl->add (2, $y++, new CFClient::UI::Label text => $name); |
|
|
847 | } |
|
|
848 | } |
|
|
849 | |
|
|
850 | $STATWIDS->{_skill_tbl_init} = 1; |
|
|
851 | } |
|
|
852 | |
|
|
853 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
854 | if (exists $stats->{$i}) { |
|
|
855 | $STATWIDS->{"sk_xp_$i"}->set_text (formsep $stats->{$i}->[1]) |
|
|
856 | if $STATWIDS->{"sk_xp_$i"}; |
|
|
857 | $STATWIDS->{"sk_lvl_$i"}->set_text (sprintf "%d", $stats->{$i}->[0]) |
|
|
858 | if $STATWIDS->{"sk_lvl_$i"}; |
|
|
859 | } |
|
|
860 | } |
|
|
861 | |
|
|
862 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
|
|
863 | for keys %tbl; |
|
|
864 | } |
787 | } |
865 | |
788 | |
866 | my $METASERVER_ATIME; |
789 | my $METASERVER_ATIME; |
867 | |
790 | |
868 | sub update_metaserver { |
791 | sub update_metaserver { |
… | |
… | |
1114 | sub message_window { |
1037 | sub message_window { |
1115 | my $window = new CFClient::UI::FancyFrame |
1038 | my $window = new CFClient::UI::FancyFrame |
1116 | name => "message_window", |
1039 | name => "message_window", |
1117 | title => "Messages", |
1040 | title => "Messages", |
1118 | border_bg => [1, 1, 1, 1], |
1041 | border_bg => [1, 1, 1, 1], |
1119 | bg => [0, 0, 0, 0.75], |
|
|
1120 | x => "max", |
1042 | x => "max", |
1121 | y => 0, |
1043 | y => 0, |
1122 | force_w => $::WIDTH * 0.4, |
1044 | force_w => $::WIDTH * 0.4, |
1123 | force_h => $::HEIGHT * 0.5, |
1045 | force_h => $::HEIGHT * 0.5, |
1124 | child => (my $vbox = new CFClient::UI::VBox), |
1046 | child => (my $vbox = new CFClient::UI::VBox), |
… | |
… | |
1352 | debug => 1, |
1274 | debug => 1, |
1353 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1275 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1354 | ; |
1276 | ; |
1355 | |
1277 | |
1356 | $ntb->add ( |
1278 | $ntb->add ( |
1357 | "Stats & Skills" => $STATS_PAGE = stats_window, |
1279 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1358 | "Shows statistics and skill window, where all your Stats, Resistances and Skills are shown." |
1280 | "Shows statistics, where all your Stats and Resistances are shown." |
1359 | ); |
1281 | ); |
1360 | $ntb->add ( |
1282 | $ntb->add ( |
|
|
1283 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
|
|
1284 | "Shows all your Skills." |
|
|
1285 | ); |
|
|
1286 | $ntb->add ( |
1361 | Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, |
1287 | "Spellbook (F4)" => $SPELL_PAGE = new CFClient::UI::SpellList, |
1362 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1288 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1363 | ); |
1289 | ); |
1364 | $ntb->add ( |
1290 | $ntb->add ( |
1365 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1291 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1366 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1292 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1367 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1293 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1368 | ); |
1294 | ); |
1369 | |
1295 | |
1370 | $ntb->set_current_page ($INVENTORY_PAGE); |
1296 | $ntb->set_current_page ($INVENTORY_PAGE); |
… | |
… | |
1483 | $refresh->(); |
1409 | $refresh->(); |
1484 | |
1410 | |
1485 | $vb |
1411 | $vb |
1486 | } |
1412 | } |
1487 | |
1413 | |
|
|
1414 | # just weirdness, pls. ignore |
|
|
1415 | sub load_html_page { |
|
|
1416 | my ($viewer, $base) = @_; |
|
|
1417 | |
|
|
1418 | $viewer->clear; |
|
|
1419 | |
|
|
1420 | require LWP::Simple; |
|
|
1421 | require HTML::Parser; |
|
|
1422 | require URI; |
|
|
1423 | |
|
|
1424 | my $page = LWP::Simple::get ($base) |
|
|
1425 | or return; |
|
|
1426 | |
|
|
1427 | my @s = { }; |
|
|
1428 | my %passthrough = map ($_ => undef), qw(b i u s tt big small sub sup); |
|
|
1429 | |
|
|
1430 | my $parser = HTML::Parser->new ( |
|
|
1431 | text_h => [sub { |
|
|
1432 | my ($text) = @_; |
|
|
1433 | $text =~ s/\s+/ /g; |
|
|
1434 | $s[-1]{text} .= CFClient::UI::Label::escape $text; |
|
|
1435 | }, "dtext"], |
|
|
1436 | start_h => [sub { |
|
|
1437 | my ($tag, $attr) = @_; |
|
|
1438 | if ($passthrough{$tag}) { |
|
|
1439 | $s[-1]{text} .= "<$tag>"; |
|
|
1440 | } elsif ($tag eq "h1") { |
|
|
1441 | push @s, { text => "<span foreground='#ffff00' size='x-large'>" }; |
|
|
1442 | } elsif ($tag eq "h2") { |
|
|
1443 | push @s, { text => "<span foreground='#ccccff' size='large'>" }; |
|
|
1444 | } elsif ($tag eq "h3") { |
|
|
1445 | push @s, { text => "<span size='large'>" }; |
|
|
1446 | } elsif ($tag eq "a") { |
|
|
1447 | push @s, { text => "", url => $attr->{href} }; |
|
|
1448 | } elsif ($tag eq "p") { |
|
|
1449 | push @s, { }; |
|
|
1450 | } elsif ($tag eq "img") { |
|
|
1451 | eval { |
|
|
1452 | push @{$s[-1]{obj}}, new CFClient::UI::Image |
|
|
1453 | tex => (new_from_image CFClient::Texture LWP::Simple::get (URI->new ($attr->{src}, $base)->abs ($base))); |
|
|
1454 | $s[-1]{text} .= "\x{fffc}"; |
|
|
1455 | }; |
|
|
1456 | } |
|
|
1457 | }, "tagname, attr"], |
|
|
1458 | end_h => [sub { |
|
|
1459 | my ($tag) = @_; |
|
|
1460 | if ($passthrough{$tag}) { |
|
|
1461 | $s[-1]{text} .= "</$tag>"; |
|
|
1462 | } elsif ($tag =~ /^h\d$/) { |
|
|
1463 | $s[-1]{text} .= "</span>"; |
|
|
1464 | push @s, { }; |
|
|
1465 | } elsif ($tag eq "a") { |
|
|
1466 | my $S = pop @s; |
|
|
1467 | $s[-1]{text} .= "\x{fffc}"; |
|
|
1468 | push @{$s[-1]{obj}}, new CFClient::UI::Label |
|
|
1469 | fg => [0.8, 0.8, 1], |
|
|
1470 | markup => "<u>$S->{text}</u>", |
|
|
1471 | fontsize => 0.8, |
|
|
1472 | can_events => 1, |
|
|
1473 | can_focus => 1, |
|
|
1474 | on_button_up => sub { |
|
|
1475 | load_html_page ($viewer, URI->new ($S->{url}, $base)->abs ($base)); |
|
|
1476 | }, |
|
|
1477 | ; |
|
|
1478 | } |
|
|
1479 | }, "tagname"], |
|
|
1480 | ); |
|
|
1481 | |
|
|
1482 | $parser->parse ($page); |
|
|
1483 | $parser->eof; |
|
|
1484 | |
|
|
1485 | $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent}) |
|
|
1486 | for @s; |
|
|
1487 | |
|
|
1488 | $viewer->set_offset (0); |
|
|
1489 | } |
|
|
1490 | |
1488 | sub help_window { |
1491 | sub help_window { |
1489 | my $win = new CFClient::UI::FancyFrame |
1492 | my $win = new CFClient::UI::FancyFrame |
1490 | x => 'center', |
1493 | x => 'center', |
1491 | y => 'center', |
1494 | y => 'center', |
1492 | z => 2, |
1495 | z => 2, |
… | |
… | |
1510 | [manual => "Main Manual"], |
1513 | [manual => "Main Manual"], |
1511 | [skill_help => "Skill Reference"], |
1514 | [skill_help => "Skill Reference"], |
1512 | [command_help => "Command Reference"], |
1515 | [command_help => "Command Reference"], |
1513 | [dmcommand_help => "DM Commands"], |
1516 | [dmcommand_help => "DM Commands"], |
1514 | [COPYING => "License Terms"], |
1517 | [COPYING => "License Terms"], |
|
|
1518 | [test => "test (do not select)"], #d#TODO |
1515 | ], |
1519 | ], |
1516 | on_changed => sub { |
1520 | on_changed => sub { |
1517 | my ($self, $pod) = @_; |
1521 | my ($self, $pod) = @_; |
|
|
1522 | |
|
|
1523 | if ($pod eq "test") {#d#TODO |
|
|
1524 | eval { |
|
|
1525 | load_html_page $viewer, "http://crossfire.real-time.com/guides/walkthrough/newbie-tower.html"; |
|
|
1526 | }; |
|
|
1527 | warn "$@" if $@; |
|
|
1528 | return; |
|
|
1529 | } |
1518 | |
1530 | |
1519 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1531 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1520 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1532 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1521 | |
1533 | |
1522 | $viewer->clear; |
1534 | $viewer->clear; |
… | |
… | |
1909 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1921 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1910 | }, |
1922 | }, |
1911 | CFClient::SDL_KEYDOWN => sub { |
1923 | CFClient::SDL_KEYDOWN => sub { |
1912 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
1924 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
1913 | # alt-enter |
1925 | # alt-enter |
|
|
1926 | $FULLSCREEN_ENABLE->toggle; |
1914 | video_shutdown; |
1927 | video_shutdown; |
1915 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
|
|
1916 | video_init; |
1928 | video_init; |
1917 | } else { |
1929 | } else { |
1918 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1930 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1919 | } |
1931 | } |
1920 | }, |
1932 | }, |
… | |
… | |
1936 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1948 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1937 | |
1949 | |
1938 | { |
1950 | { |
1939 | local $SIG{__DIE__} = sub { |
1951 | local $SIG{__DIE__} = sub { |
1940 | return unless defined $^S && !$^S; |
1952 | return unless defined $^S && !$^S; |
1941 | Carp::confess $_[1];#d#TODO: remove when stable |
1953 | Carp::confess $_[0];#d#TODO: remove when stable |
1942 | CFClient::fatal $_[0]; |
1954 | CFClient::fatal $_[0]; |
1943 | }; |
1955 | }; |
1944 | |
1956 | |
1945 | CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
1957 | CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
1946 | CFClient::UI::set_layout ($::CFG->{layout}); |
1958 | CFClient::UI::set_layout ($::CFG->{layout}); |