… | |
… | |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use Time::HiRes 'time'; |
6 | use Time::HiRes 'time'; |
7 | use Event; |
7 | use Event; |
8 | |
8 | |
9 | use SDL; |
|
|
10 | use SDL::App; |
|
|
11 | use SDL::Event; |
|
|
12 | use SDL::Surface; |
|
|
13 | use SDL::OpenGL; |
|
|
14 | |
|
|
15 | use Crossfire; |
9 | use Crossfire; |
16 | use Crossfire::Protocol; |
10 | use Crossfire::Protocol; |
17 | |
11 | |
|
|
12 | use Compress::LZF; |
|
|
13 | |
18 | use CFClient; |
14 | use CFClient; |
19 | use CFClient::UI; |
15 | use CFClient::UI; |
|
|
16 | use CFClient::MapWidget; |
20 | |
17 | |
21 | our $VERSION = '0.1'; |
18 | our $VERSION = '0.1'; |
22 | |
19 | |
23 | my $MAX_FPS = 60; |
20 | my $MAX_FPS = 60; |
24 | my $MIN_FPS = 5; # unused as of yet |
21 | my $MIN_FPS = 5; # unused as of yet |
25 | |
22 | |
26 | our $META_SERVER = "crossfire.real-time.com:13326"; |
23 | our $META_SERVER = "crossfire.real-time.com:13326"; |
27 | |
24 | |
|
|
25 | our $FACEMAP; |
|
|
26 | our $TILECACHE; |
28 | our $FACECACHE; |
27 | our $MAPCACHE; |
29 | |
28 | |
30 | our $LAST_REFRESH; |
29 | our $LAST_REFRESH; |
31 | our $NOW; |
30 | our $NOW; |
32 | |
31 | |
33 | our $CFG; |
32 | our $CFG; |
… | |
… | |
45 | our $BUTTONBAR; |
44 | our $BUTTONBAR; |
46 | our $LOGVIEW; |
45 | our $LOGVIEW; |
47 | our $CONSOLE; |
46 | our $CONSOLE; |
48 | our $METASERVER; |
47 | our $METASERVER; |
49 | |
48 | |
|
|
49 | our $GAUGES; |
|
|
50 | our $STATWIDS; |
|
|
51 | |
50 | our $SDL_ACTIVE; |
52 | our $SDL_ACTIVE; |
51 | our $SDL_EV; |
|
|
52 | our %SDL_CB; |
53 | our %SDL_CB; |
|
|
54 | |
|
|
55 | our $SDL_MIXER; |
|
|
56 | our @SOUNDS; # event => file mapping |
|
|
57 | our %AUDIO_CHUNKS; # audio files |
53 | |
58 | |
54 | our $ALT_ENTER_MESSAGE; |
59 | our $ALT_ENTER_MESSAGE; |
55 | our $STATUS_LINE; |
60 | our $STATUS_LINE; |
56 | our $DEBUG_STATUS; |
61 | our $DEBUG_STATUS; |
57 | |
62 | |
58 | sub status { |
63 | sub status { |
59 | $STATUS_LINE->set_text ($_[0]); |
64 | $STATUS_LINE->set_text ($_[0]); |
60 | my ($w, $h) = $STATUS_LINE->size_request; |
|
|
61 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
65 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
62 | } |
66 | } |
63 | |
67 | |
64 | sub debug { |
68 | sub debug { |
65 | $DEBUG_STATUS->set_text ($_[0]); |
69 | $DEBUG_STATUS->set_text ($_[0]); |
66 | my ($w, $h) = $DEBUG_STATUS->size_request; |
70 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); |
67 | $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); |
|
|
68 | } |
71 | } |
69 | |
72 | |
70 | sub start_game { |
73 | sub start_game { |
71 | status "logging in..."; |
74 | status "logging in..."; |
72 | |
75 | |
73 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
76 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
|
|
77 | |
|
|
78 | $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; |
74 | |
79 | |
75 | $MAP = new CFClient::Map $mapsize, $mapsize; |
80 | $MAP = new CFClient::Map $mapsize, $mapsize; |
76 | |
81 | |
77 | my ($host, $port) = split /:/, $CFG->{host}; |
82 | my ($host, $port) = split /:/, $CFG->{host}; |
78 | |
83 | |
… | |
… | |
94 | undef $CONN; |
99 | undef $CONN; |
95 | } |
100 | } |
96 | |
101 | |
97 | sub client_setup { |
102 | sub client_setup { |
98 | my $dialog = new CFClient::UI::FancyFrame |
103 | my $dialog = new CFClient::UI::FancyFrame |
|
|
104 | title => "Client Setup", |
99 | child => (my $vbox = new CFClient::UI::VBox); |
105 | child => (my $vbox = new CFClient::UI::VBox); |
100 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
|
|
101 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
106 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
102 | |
107 | |
103 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
108 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
104 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
109 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
105 | |
110 | |
106 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
111 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
107 | $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); |
112 | $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
108 | |
113 | |
109 | $mode_slider->connect (changed => sub { |
114 | $mode_slider->connect (changed => sub { |
110 | my ($self, $value) = @_; |
115 | my ($self, $value) = @_; |
111 | |
116 | |
112 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
117 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
113 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
118 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
114 | }); |
119 | }); |
115 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
120 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
116 | |
121 | |
117 | $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); |
122 | $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
118 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
123 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
119 | my ($self, $value) = @_; |
124 | my ($self, $value) = @_; |
120 | $CFG->{fullscreen} = $value; |
125 | $CFG->{fullscreen} = $value; |
121 | }); |
126 | }); |
122 | |
127 | |
123 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); |
128 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
124 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
129 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
125 | my ($self, $value) = @_; |
130 | my ($self, $value) = @_; |
126 | $CFG->{fast} = $value; |
131 | $CFG->{fast} = $value; |
127 | }); |
132 | }); |
128 | |
133 | |
129 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
134 | $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
130 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
135 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
131 | my ($self, $value) = @_; |
136 | my ($self, $value) = @_; |
132 | $CFG->{fow_enable} = $value; |
137 | $CFG->{fow_enable} = $value; |
133 | }); |
138 | }); |
134 | |
139 | |
135 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); |
140 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
136 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
141 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
137 | my ($self, $value) = @_; |
142 | my ($self, $value) = @_; |
138 | $CFG->{fow_intensity} = $value; |
143 | $CFG->{fow_intensity} = $value; |
139 | }); |
144 | }); |
140 | |
145 | |
141 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
146 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); |
142 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
147 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
143 | my ($self, $value) = @_; |
148 | my ($self, $value) = @_; |
144 | $CFG->{fow_smooth} = $value; |
149 | $CFG->{fow_smooth} = $value; |
|
|
150 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
145 | }); |
151 | }); |
146 | |
152 | |
147 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
153 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
|
|
154 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
|
|
155 | $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; |
|
|
156 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
|
|
157 | }); |
|
|
158 | |
|
|
159 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
148 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
160 | $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
149 | my ($self, $value) = @_; |
|
|
150 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
161 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
151 | }); |
162 | }); |
152 | |
163 | |
|
|
164 | $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
|
|
165 | $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{stat_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
|
|
166 | $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10; |
|
|
167 | &set_stats_window_fontsize; |
|
|
168 | }); |
|
|
169 | |
|
|
170 | |
153 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
171 | $table->add (1, 9, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
154 | destroy_screen (); |
172 | video_shutdown (); |
155 | init_screen (); |
173 | video_init (); |
|
|
174 | }); |
|
|
175 | |
|
|
176 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
|
|
177 | $table->add (1, 10, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
|
|
178 | $CFG->{audio_enable} = $_[1]; |
|
|
179 | }); |
|
|
180 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
|
|
181 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
|
|
182 | # $CFG->{effects_volume} = $_[1]; |
|
|
183 | # }); |
|
|
184 | $table->add (0, 11, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
|
|
185 | $table->add (1, 11, my $hbox = new CFClient::UI::HBox); |
|
|
186 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
|
|
187 | $CFG->{bgm_enable} = $_[1]; |
|
|
188 | }); |
|
|
189 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
|
|
190 | $CFG->{bgm_volume} = $_[1]; |
|
|
191 | CFClient::MixMusic::volume $_[1] * 128; |
|
|
192 | }); |
|
|
193 | |
|
|
194 | $table->add (1, 12, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
|
|
195 | audio_shutdown (); |
|
|
196 | audio_init (); |
156 | }); |
197 | }); |
157 | |
198 | |
158 | $dialog |
199 | $dialog |
|
|
200 | } |
|
|
201 | |
|
|
202 | sub set_stats_window_fontsize { |
|
|
203 | for (values %{$STATWIDS}, values %{$GAUGES}) { |
|
|
204 | $_->set_fontsize ($::CFG->{stat_fontsize}); |
|
|
205 | } |
|
|
206 | } |
|
|
207 | |
|
|
208 | sub make_stats_window { |
|
|
209 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
|
|
210 | |
|
|
211 | $tgw->add (my $vb = new CFClient::UI::VBox); |
|
|
212 | $vb->add (my $uhb = new CFClient::UI::HBox); |
|
|
213 | $uhb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); |
|
|
214 | $uhb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
|
|
215 | $vb->add (my $dhb = new CFClient::UI::HBox); |
|
|
216 | $dhb->add ($STATWIDS->{exp} = new CFClient::UI::Label valign => 0, align => -1, text => "Exp:", expand => 1); |
|
|
217 | $dhb->add ($STATWIDS->{lvl} = new CFClient::UI::Label valign => 0, align => -1, text => "Level:", expand => 1); |
|
|
218 | |
|
|
219 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
|
|
220 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', expand => 1); |
|
|
221 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', expand => 1); |
|
|
222 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', expand => 1); |
|
|
223 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', expand => 1); |
|
|
224 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
225 | |
|
|
226 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
|
|
227 | |
|
|
228 | if (0) { # this code can vanish, just wanted to preserver it for a checkin |
|
|
229 | $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => "S"); |
|
|
230 | $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => "D"); |
|
|
231 | $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => "Co"); |
|
|
232 | $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => "I"); |
|
|
233 | $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => "W"); |
|
|
234 | $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => "P"); |
|
|
235 | $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => "Ch"); |
|
|
236 | |
|
|
237 | $tbl->add (1, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); |
|
|
238 | $tbl->add (1, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac"); |
|
|
239 | $tbl->add (1, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam"); |
|
|
240 | $tbl->add (1, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm"); |
|
|
241 | $tbl->add (1, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp"); |
|
|
242 | $tbl->add (1, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp"); |
|
|
243 | } else { |
|
|
244 | $tbl->add (0, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "S"); |
|
|
245 | $tbl->add (0, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "D"); |
|
|
246 | $tbl->add (0, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Co"); |
|
|
247 | $tbl->add (0, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "I"); |
|
|
248 | $tbl->add (0, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "W"); |
|
|
249 | $tbl->add (0, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "P"); |
|
|
250 | $tbl->add (0, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Ch"); |
|
|
251 | |
|
|
252 | $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
253 | $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
254 | $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
255 | $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
256 | $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
257 | $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
258 | $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
259 | |
|
|
260 | $tbl->add (2, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wc"); |
|
|
261 | $tbl->add (2, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Ac"); |
|
|
262 | $tbl->add (2, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dam"); |
|
|
263 | $tbl->add (2, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Arm"); |
|
|
264 | $tbl->add (2, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Sp"); |
|
|
265 | $tbl->add (2, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "WSp"); |
|
|
266 | |
|
|
267 | $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
268 | $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
269 | $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
270 | $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
271 | $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
272 | $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
273 | } |
|
|
274 | |
|
|
275 | $hb->add (my $tbl2 = new CFClient::UI::Table); |
|
|
276 | |
|
|
277 | my $row = 0; |
|
|
278 | my $col = 0; |
|
|
279 | |
|
|
280 | for (qw/slow holyw conf fire depl magic |
|
|
281 | drain acid pois para deat phys |
|
|
282 | blind fear tund elec cold ghit/) |
|
|
283 | { |
|
|
284 | $tbl2->add ($col, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png"); |
|
|
285 | $tbl2->add ($col + 1, $row, |
|
|
286 | $STATWIDS->{"res_$_"} = |
|
|
287 | new CFClient::UI::Label text => "0", align => -1, valign => 0 |
|
|
288 | ); |
|
|
289 | |
|
|
290 | $row++; |
|
|
291 | if ($row % 6 == 0) { |
|
|
292 | $col += 2; |
|
|
293 | $row = 0; |
|
|
294 | } |
|
|
295 | } |
|
|
296 | |
|
|
297 | &set_stats_window_fontsize; |
|
|
298 | update_stats_window ({}); |
|
|
299 | |
|
|
300 | $tgw |
|
|
301 | } |
|
|
302 | |
|
|
303 | sub update_stats_window { |
|
|
304 | my ($stats) = @_; |
|
|
305 | |
|
|
306 | # i love text protocols!!! |
|
|
307 | my $hp = $stats->{1} * 1; |
|
|
308 | my $hp_m = $stats->{2} * 1; |
|
|
309 | my $sp = $stats->{3} * 1; |
|
|
310 | my $sp_m = $stats->{4} * 1; |
|
|
311 | my $fo = $stats->{18} * 1; |
|
|
312 | my $fo_m = 999; |
|
|
313 | my $gr = $stats->{23} * 1; |
|
|
314 | my $gr_m = $stats->{24} * 1; |
|
|
315 | |
|
|
316 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
|
|
317 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
|
|
318 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
|
|
319 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
|
|
320 | $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); |
|
|
321 | $STATWIDS->{exp} ->set_text ("Exp.: " . ($stats->{11} || $stats->{28})); |
|
|
322 | $STATWIDS->{lvl} ->set_text ("Level: " . $stats->{12}); |
|
|
323 | |
|
|
324 | if (0) { # this code can vanish, just wanted to preserver it for a checkin |
|
|
325 | $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5}); |
|
|
326 | $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8}); |
|
|
327 | $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9}); |
|
|
328 | $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6}); |
|
|
329 | $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7}); |
|
|
330 | $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22}); |
|
|
331 | $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10}); |
|
|
332 | $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13}); |
|
|
333 | $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14}); |
|
|
334 | $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15}); |
|
|
335 | $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16}); |
|
|
336 | $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17}); |
|
|
337 | $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19}); |
|
|
338 | } else { |
|
|
339 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
|
|
340 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
|
|
341 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
|
|
342 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
|
|
343 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
|
|
344 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
|
|
345 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
|
|
346 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
|
|
347 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
|
|
348 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
|
|
349 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
|
|
350 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); |
|
|
351 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); |
|
|
352 | } |
|
|
353 | |
|
|
354 | my %tbl = ( |
|
|
355 | phys => 100, |
|
|
356 | magic => 101, |
|
|
357 | fire => 102, |
|
|
358 | elec => 103, |
|
|
359 | cold => 104, |
|
|
360 | conf => 105, |
|
|
361 | acid => 106, |
|
|
362 | drain => 107, |
|
|
363 | ghit => 108, |
|
|
364 | pois => 109, |
|
|
365 | slow => 110, |
|
|
366 | para => 111, |
|
|
367 | tund => 112, |
|
|
368 | fear => 113, |
|
|
369 | deat => 115, |
|
|
370 | holyw => 116, |
|
|
371 | blind => 117 |
|
|
372 | ); |
|
|
373 | |
|
|
374 | for (keys %tbl) { |
|
|
375 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}); |
|
|
376 | } |
|
|
377 | |
159 | } |
378 | } |
160 | |
379 | |
161 | sub metaserver_dialog { |
380 | sub metaserver_dialog { |
162 | my $dialog = new CFClient::UI::FancyFrame |
381 | my $dialog = new CFClient::UI::FancyFrame |
|
|
382 | title => "Metaserver", |
163 | child => (my $vbox = new CFClient::UI::VBox); |
383 | child => (my $vbox = new CFClient::UI::VBox); |
164 | |
384 | |
165 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
385 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
166 | |
386 | |
167 | $dialog |
387 | $dialog |
… | |
… | |
224 | $HOST->set_text ($CFG->{host} = $host); |
444 | $HOST->set_text ($CFG->{host} = $host); |
225 | }), |
445 | }), |
226 | (new CFClient::UI::Empty expand => 1), |
446 | (new CFClient::UI::Empty expand => 1), |
227 | ]); |
447 | ]); |
228 | |
448 | |
229 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
449 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) |
230 | for 0 .. $#$m; |
450 | for 0 .. $#$m; |
231 | } |
451 | } |
232 | } |
452 | } |
233 | }); |
453 | }); |
234 | } |
454 | } |
235 | |
455 | |
236 | sub server_setup { |
456 | sub server_setup { |
237 | my $dialog = new CFClient::UI::FancyFrame |
457 | my $dialog = new CFClient::UI::FancyFrame |
|
|
458 | title => "Server Setup", |
238 | child => (my $vbox = new CFClient::UI::VBox); |
459 | child => (my $vbox = new CFClient::UI::VBox); |
239 | |
460 | |
240 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
|
|
241 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
461 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
242 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
462 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
243 | |
463 | |
244 | { |
464 | { |
245 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
465 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
246 | |
466 | |
247 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
467 | $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { |
248 | my ($self, $value) = @_; |
468 | my ($self, $value) = @_; |
249 | $CFG->{host} = $value; |
469 | $CFG->{host} = $value; |
250 | }); |
470 | }); |
251 | |
471 | |
252 | $METASERVER = metaserver_dialog; |
472 | $METASERVER = metaserver_dialog; |
253 | |
473 | |
254 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
474 | $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { |
255 | update_metaserver $HOST; |
475 | update_metaserver $HOST; |
256 | }); |
476 | }); |
257 | } |
477 | } |
258 | |
478 | |
259 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
479 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
260 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
480 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
261 | my ($self, $value) = @_; |
481 | my ($self, $value) = @_; |
262 | $CFG->{user} = $value; |
482 | $CFG->{user} = $value; |
263 | }); |
483 | }); |
264 | |
484 | |
265 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
485 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); |
266 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
486 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
267 | my ($self, $value) = @_; |
487 | my ($self, $value) = @_; |
268 | $CFG->{password} = $value; |
488 | $CFG->{password} = $value; |
269 | }); |
489 | }); |
270 | |
490 | |
271 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
491 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
272 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
492 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
273 | my ($self, $value) = @_; |
493 | my ($self, $value) = @_; |
274 | $CFG->{say_command} = $value; |
494 | $CFG->{say_command} = $value; |
275 | }); |
495 | }); |
276 | |
496 | |
277 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
497 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
278 | $table->add (1, 7, new CFClient::UI::Slider |
498 | $table->add (1, 7, new CFClient::UI::Slider |
279 | req_w => 100, |
499 | req_w => 100, |
280 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
500 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
281 | connect_changed => sub { |
501 | connect_changed => sub { |
282 | my ($self, $value) = @_; |
502 | my ($self, $value) = @_; |
… | |
… | |
292 | $dialog |
512 | $dialog |
293 | } |
513 | } |
294 | |
514 | |
295 | sub message_window { |
515 | sub message_window { |
296 | my $window = new CFClient::UI::FancyFrame |
516 | my $window = new CFClient::UI::FancyFrame |
|
|
517 | title => "Messages", |
297 | border_bg => [1, 1, 1, 0.5], |
518 | border_bg => [1, 1, 1, 0.5], |
298 | bg => [0.3, 0.3, 0.3, 0.8], |
519 | bg => [0.3, 0.3, 0.3, 0.8], |
299 | user_w => $::WIDTH/4, |
520 | user_w => int $::WIDTH / 3, |
300 | user_h => $::HEIGHT, |
521 | user_h => int $::HEIGHT / 5, |
301 | child => (my $vbox = new CFClient::UI::VBox); |
522 | child => (my $vbox = new CFClient::UI::VBox); |
302 | |
523 | |
303 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
524 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
304 | expand => 1, |
525 | expand => 1, |
305 | fontsize => $::CFG->{log_fontsize}, |
526 | fontsize => $::CFG->{log_fontsize}, |
306 | ); |
527 | ); |
307 | |
528 | |
308 | $vbox->add (my $input = new CFClient::UI::LineEntry); |
529 | $vbox->add (my $input = new CFClient::UI::Entry |
|
|
530 | connect_focus_in => sub { |
|
|
531 | my ($input, $prev_focus) = @_; |
|
|
532 | |
|
|
533 | delete $input->{refocus_map}; |
|
|
534 | |
|
|
535 | if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { |
|
|
536 | $input->{refocus_map} = 1; |
|
|
537 | } |
|
|
538 | delete $input->{auto_activated}; |
|
|
539 | }, |
309 | $input->connect (activate => sub { |
540 | connect_activate => sub { |
310 | my ($input, $text) = @_; |
541 | my ($input, $text) = @_; |
311 | $input->set_text (''); |
542 | $input->set_text (''); |
312 | |
543 | |
313 | if ($text =~ /^\/(.*)/) { |
544 | if ($text =~ /^\/(.*)/) { |
314 | $::CONN->user_send ("command $1"); |
545 | $::CONN->user_send ($1); |
315 | } else { |
546 | } else { |
316 | my $say_cmd = $::CFG->{say_command} || 'say'; |
547 | my $say_cmd = $::CFG->{say_command} || 'say'; |
317 | $::CONN->user_send ("command $say_cmd $text"); |
548 | $::CONN->user_send ("$say_cmd $text"); |
318 | } |
549 | } |
|
|
550 | if ($input->{refocus_map}) { |
|
|
551 | delete $input->{refocus_map}; |
|
|
552 | $MAPWIDGET->focus_in |
319 | 1 |
553 | } |
320 | }); |
554 | }, |
321 | $input->connect (escape => sub { |
555 | connect_escape => sub { |
322 | $MAPWIDGET->focus_in |
556 | $MAPWIDGET->focus_in |
323 | }); |
557 | }, |
324 | $input->focus_in; |
558 | ); |
325 | |
559 | |
326 | $CONSOLE = { |
560 | $CONSOLE = { |
327 | window => $window, |
561 | window => $window, |
328 | input => $input |
562 | input => $input |
329 | }; |
563 | }; |
330 | |
564 | |
331 | $window |
565 | $window |
332 | } |
566 | } |
333 | |
567 | |
334 | sub sdl_init { |
568 | sub sdl_init { |
335 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
569 | CFClient::SDL_Init |
336 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
|
337 | and die "SDL::Init failed!\n"; |
570 | and die "SDL::Init failed!\n"; |
338 | } |
571 | } |
339 | |
572 | |
340 | sub init_screen { |
573 | sub video_init { |
341 | sdl_init; |
574 | sdl_init; |
342 | |
575 | |
343 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
576 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
344 | $FULLSCREEN = $CFG->{fullscreen}; |
577 | $FULLSCREEN = $CFG->{fullscreen}; |
345 | $FAST = $CFG->{fast}; |
578 | $FAST = $CFG->{fast}; |
346 | |
579 | |
347 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
580 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
348 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
|
|
349 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
|
|
350 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
|
|
351 | |
|
|
352 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
|
|
353 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
|
|
354 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
|
|
355 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
|
|
356 | |
|
|
357 | SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1; |
|
|
358 | SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15; |
|
|
359 | SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0; |
|
|
360 | |
|
|
361 | SDL::SetVideoMode $WIDTH, $HEIGHT, 0, |
|
|
362 | SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF |
|
|
363 | | ($FULLSCREEN ? SDL_FULLSCREEN : 0) |
|
|
364 | or die "SDL::SetVideoMode failed!\n"; |
581 | or die "SDL_SetVideoMode failed!\n"; |
365 | |
|
|
366 | SDL::WMSetCaption "Crossfire+ Client", "Crossfire+"; |
|
|
367 | |
|
|
368 | $SDL_EV = new SDL::Event; |
|
|
369 | $SDL_EV->set_unicode (1); |
|
|
370 | |
582 | |
371 | $SDL_ACTIVE = 1; |
583 | $SDL_ACTIVE = 1; |
372 | |
584 | |
373 | $LAST_REFRESH = time - 0.01; |
585 | $LAST_REFRESH = time - 0.01; |
374 | |
586 | |
375 | CFClient::gl_init; |
587 | CFClient::gl_init; |
376 | |
588 | |
377 | $FONTSIZE = int $HEIGHT / 40; |
589 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
378 | |
590 | |
379 | ############################################################################# |
591 | ############################################################################# |
380 | |
592 | |
381 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
593 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
382 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
594 | $DEBUG_STATUS->show; |
383 | |
595 | |
384 | $STATUS_LINE = new CFClient::UI::Label |
596 | $STATUS_LINE = new CFClient::UI::Label |
385 | padding => 0, |
597 | padding => 0, |
386 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
598 | y => $HEIGHT - $FONTSIZE * 1.8; |
387 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
599 | $STATUS_LINE->show; |
388 | |
600 | |
389 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
601 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
390 | padding => 0, |
602 | padding => 0, |
391 | y => $HEIGHT * 44 / 45, |
603 | fontsize => 0.8, |
392 | height => $HEIGHT / 45, |
|
|
393 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
604 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
394 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
605 | $ALT_ENTER_MESSAGE->show; |
|
|
606 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
395 | |
607 | |
396 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
608 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); |
397 | $MAPWIDGET->focus_in; |
609 | $MAPWIDGET->focus_in; |
398 | $MAPWIDGET->connect (activate_console => sub { |
610 | $MAPWIDGET->connect (activate_console => sub { |
399 | my ($mapwidget, $preset) = @_; |
611 | my ($mapwidget, $preset) = @_; |
400 | |
612 | |
401 | if ($CONSOLE) { |
613 | if ($CONSOLE) { |
|
|
614 | $CONSOLE->{input}->{auto_activated} = 1; |
402 | $CONSOLE->{input}->focus_in; |
615 | $CONSOLE->{input}->focus_in; |
403 | |
616 | |
404 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
617 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
405 | $CONSOLE->{input}->set_text ($preset); |
618 | $CONSOLE->{input}->set_text ($preset); |
406 | } |
619 | } |
… | |
… | |
416 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
629 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
417 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
630 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
418 | status "Configuration Saved"; |
631 | status "Configuration Saved"; |
419 | }); |
632 | }); |
420 | |
633 | |
421 | $BUTTONBAR->{children}[0]->emit ("activate"); |
634 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
422 | } |
|
|
423 | |
635 | |
424 | sub destroy_screen { |
636 | |
|
|
637 | $CFClient::UI::ROOT->add (make_stats_window); |
|
|
638 | } |
|
|
639 | |
|
|
640 | sub video_shutdown { |
425 | $CFClient::UI::ROOT->{children} = []; |
641 | $CFClient::UI::ROOT->{children} = []; |
426 | undef $SDL_ACTIVE; |
642 | undef $SDL_ACTIVE; |
|
|
643 | } |
|
|
644 | |
|
|
645 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
|
|
646 | my $bgmusic;#TODO#hack#d# |
|
|
647 | |
|
|
648 | sub audio_music_finished { |
|
|
649 | return unless $CFG->{bgm_enable}; |
|
|
650 | |
|
|
651 | # TODO: hack, do play loop and mood music |
|
|
652 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/$bgmusic[0]"; |
|
|
653 | $bgmusic->play (0); |
|
|
654 | |
|
|
655 | push @bgmusic, shift @bgmusic; |
|
|
656 | } |
|
|
657 | |
|
|
658 | sub audio_init { |
|
|
659 | if ($CFG->{audio_enable}) { |
|
|
660 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
|
|
661 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
|
|
662 | CFClient::Mix_AllocateChannels 8; |
|
|
663 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
|
|
664 | |
|
|
665 | audio_music_finished; |
|
|
666 | |
|
|
667 | while (<$fh>) { |
|
|
668 | next if /^\s*#/; |
|
|
669 | next if /^\s*$/; |
|
|
670 | |
|
|
671 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
|
|
672 | |
|
|
673 | push @SOUNDS, "$volume,$file"; |
|
|
674 | |
|
|
675 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
|
|
676 | my $chunk = new_from_file CFClient::MixChunk CFClient::find_rcfile "sounds/$file"; |
|
|
677 | $chunk->volume ($volume * 128 / 100); |
|
|
678 | $chunk |
|
|
679 | }; |
|
|
680 | } |
|
|
681 | } else { |
|
|
682 | status "unable to open sound config: $!"; |
|
|
683 | } |
|
|
684 | } |
|
|
685 | } |
|
|
686 | |
|
|
687 | sub audio_shutdown { |
|
|
688 | CFClient::Mix_CloseAudio if $SDL_MIXER; |
427 | undef $SDL_EV; |
689 | undef $SDL_MIXER; |
428 | SDL::Quit; |
690 | @SOUNDS = (); |
|
|
691 | %AUDIO_CHUNKS = (); |
429 | } |
692 | } |
430 | |
693 | |
431 | my %animate_object; |
694 | my %animate_object; |
432 | my $animate_timer; |
695 | my $animate_timer; |
433 | |
696 | |
… | |
… | |
443 | $want_refresh = 0; |
706 | $want_refresh = 0; |
444 | $can_refresh = 0; |
707 | $can_refresh = 0; |
445 | |
708 | |
446 | $CFClient::UI::ROOT->draw; |
709 | $CFClient::UI::ROOT->draw; |
447 | |
710 | |
448 | SDL::GLSwapBuffers; |
711 | CFClient::SDL_GL_SwapBuffers; |
449 | |
712 | |
450 | $LAST_REFRESH = $NOW; |
713 | $LAST_REFRESH = $NOW; |
451 | } |
714 | } |
452 | |
715 | |
453 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
716 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
454 | $NOW = time; |
717 | $NOW = time; |
455 | |
718 | |
456 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
719 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
457 | while $SDL_EV->poll; |
720 | for CFClient::SDL_PollEvent; |
458 | |
721 | |
459 | if (%animate_object) { |
722 | if (%animate_object) { |
460 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
723 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
461 | $want_refresh++; |
724 | $want_refresh++; |
462 | } |
725 | } |
… | |
… | |
482 | delete $animate_object{$widget}; |
745 | delete $animate_object{$widget}; |
483 | } |
746 | } |
484 | |
747 | |
485 | @conn::ISA = Crossfire::Protocol::; |
748 | @conn::ISA = Crossfire::Protocol::; |
486 | |
749 | |
|
|
750 | sub conn::stats_update { |
|
|
751 | my ($self, $stats) = @_; |
|
|
752 | |
|
|
753 | update_stats_window ($stats); |
|
|
754 | } |
|
|
755 | |
487 | sub conn::user_send { |
756 | sub conn::user_send { |
488 | my ($self, $command) = @_; |
757 | my ($self, $command) = @_; |
489 | |
758 | |
490 | $self->send ($command); |
759 | $self->send_command ($command); |
491 | status $command; |
760 | status $command; |
|
|
761 | } |
|
|
762 | |
|
|
763 | sub conn::map_scroll { |
|
|
764 | my ($self, $dx, $dy) = @_; |
|
|
765 | |
|
|
766 | $MAP->scroll ($dx, $dy); |
492 | } |
767 | } |
493 | |
768 | |
494 | sub conn::feed_map1a { |
769 | sub conn::feed_map1a { |
495 | my ($self, $data) = @_; |
770 | my ($self, $data) = @_; |
496 | |
771 | |
497 | # $self->Crossfire::Protocol::feed_map1a ($data); |
772 | # $self->Crossfire::Protocol::feed_map1a ($data); |
498 | |
773 | |
499 | $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y}); |
|
|
500 | $MAP->map1a_update ($data); |
774 | $MAP->map1a_update ($data); |
501 | $MAPWIDGET->update; |
775 | $MAPWIDGET->update; |
502 | } |
776 | } |
503 | |
777 | |
504 | #sub conn::map_update { |
778 | sub conn::flush_map { |
505 | # my ($self, $dirty) = @_; |
779 | my ($self) = @_; |
506 | # |
780 | |
507 | # $MAPWIDGET->update; |
781 | my $map_info = delete $self->{map_info} |
508 | #} |
782 | or return; |
|
|
783 | |
|
|
784 | my ($hash, $x, $y, $w, $h) = @$map_info; |
|
|
785 | |
|
|
786 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
|
|
787 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
|
|
788 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
|
|
789 | } |
509 | |
790 | |
510 | sub conn::map_clear { |
791 | sub conn::map_clear { |
511 | my ($self) = @_; |
792 | my ($self) = @_; |
512 | |
793 | |
|
|
794 | $self->flush_map; |
|
|
795 | delete $self->{neigh_map}; |
|
|
796 | |
513 | $MAP->clear; |
797 | $MAP->clear; |
|
|
798 | } |
514 | |
799 | |
515 | # refresh; |
800 | |
|
|
801 | sub conn::load_map($$$) { |
|
|
802 | my ($self, $hash, $x, $y) = @_; |
|
|
803 | |
|
|
804 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
|
|
805 | $data = Compress::LZF::decompress $data; |
|
|
806 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
|
|
807 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
|
|
808 | my $data = $TILECACHE->get ($id) |
|
|
809 | or next; |
|
|
810 | |
|
|
811 | $self->set_texture ($id => $data); |
|
|
812 | } |
|
|
813 | } |
|
|
814 | } |
|
|
815 | |
|
|
816 | # this method does a "flood fill" into every tile direction |
|
|
817 | # it assumes that tiles are arranged in a rectangular grid, |
|
|
818 | # i.e. a map is the same as the left of the right map etc. |
|
|
819 | # failure to comply are harmless and result in display errors |
|
|
820 | # at worst. |
|
|
821 | sub conn::flood_fill { |
|
|
822 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
|
|
823 | |
|
|
824 | # the server does not allow map paths > 6 |
|
|
825 | return if 6 <= length $path; |
|
|
826 | |
|
|
827 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
|
|
828 | |
|
|
829 | for ( |
|
|
830 | [1, 0, -1], |
|
|
831 | [2, 1, 0], |
|
|
832 | [3, 0, 1], |
|
|
833 | [4, -1, 0], |
|
|
834 | ) { |
|
|
835 | my ($tile, $dx, $dy) = @$_; |
|
|
836 | |
|
|
837 | my $gx = $gx + $dx; |
|
|
838 | my $gy = $gy + $dy; |
|
|
839 | |
|
|
840 | next unless $flags & (1 << ($tile - 1)); |
|
|
841 | next if $self->{neigh_grid}{$gx, $gy}++; |
|
|
842 | |
|
|
843 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
|
|
844 | if (my $info = $neigh->[$tile]) { |
|
|
845 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
|
|
846 | |
|
|
847 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
|
|
848 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
849 | |
|
|
850 | } else { |
|
|
851 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
852 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
853 | |
|
|
854 | return if $mode ne "spatial"; |
|
|
855 | |
|
|
856 | $x += $MAP->ox; |
|
|
857 | $y += $MAP->oy; |
|
|
858 | |
|
|
859 | $self->load_map ($hash, $x, $y) |
|
|
860 | unless $self->{neigh_map}{$hash}[5]++;#d# |
|
|
861 | |
|
|
862 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
|
|
863 | |
|
|
864 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
|
|
865 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
866 | }); |
|
|
867 | } |
|
|
868 | } |
|
|
869 | } |
|
|
870 | |
|
|
871 | sub conn::map_change { |
|
|
872 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
873 | |
|
|
874 | $self->flush_map; |
|
|
875 | |
|
|
876 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
|
|
877 | |
|
|
878 | my $mapmapw = 250; |
|
|
879 | my $mapmaph = 250; |
|
|
880 | |
|
|
881 | $self->{neigh_rect} = [ |
|
|
882 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
883 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
|
|
884 | ]; |
|
|
885 | |
|
|
886 | delete $self->{neigh_grid}; |
|
|
887 | $self->flood_fill (0, 0, "", $hash, $flags); |
|
|
888 | |
|
|
889 | $x += $ox; |
|
|
890 | $y += $oy; |
|
|
891 | |
|
|
892 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
|
|
893 | |
|
|
894 | $STATWIDS->{map}->set_text ("Map: " . $self->{map_info}[0]); |
|
|
895 | |
|
|
896 | $self->load_map ($hash, $x, $y); |
516 | } |
897 | } |
517 | |
898 | |
518 | sub conn::face_find { |
899 | sub conn::face_find { |
519 | my ($self, $face) = @_; |
900 | my ($self, $facenum, $face) = @_; |
520 | |
901 | |
521 | my $data; |
902 | my $hash = "$face->{chksum},$face->{name}"; |
522 | |
903 | |
523 | $FACECACHE->get ("$face->{chksum},$face->{name}") |
904 | my $id = $FACEMAP->get ($hash); |
|
|
905 | |
|
|
906 | unless ($id) { |
|
|
907 | # create new id for face |
|
|
908 | # i love transactions |
|
|
909 | for (1..100) { |
|
|
910 | my $txn = $CFClient::DB_ENV->txn_begin; |
|
|
911 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
|
|
912 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
|
|
913 | $id++; |
|
|
914 | if ($FACEMAP->put (id => $id) == 0 |
|
|
915 | && $FACEMAP->put ($hash => $id) == 0) { |
|
|
916 | $txn->txn_commit; |
|
|
917 | |
|
|
918 | goto gotid; |
|
|
919 | } |
|
|
920 | } |
|
|
921 | $txn->abort; |
|
|
922 | } |
|
|
923 | |
|
|
924 | CFClient::fatal "maximum number of transaction retries reached - database problems?"; |
|
|
925 | } |
|
|
926 | |
|
|
927 | gotid: |
|
|
928 | $face->{id} = $id; |
|
|
929 | $MAP->set_face ($facenum => $id); |
|
|
930 | $TILECACHE->get ($id) |
524 | } |
931 | } |
525 | |
932 | |
526 | sub conn::face_update { |
933 | sub conn::face_update { |
527 | my ($self, $facenum, $face) = @_; |
934 | my ($self, $facenum, $face) = @_; |
528 | |
935 | |
529 | $FACECACHE->put ("$face->{chksum},$face->{name}" => $face->{image}); |
936 | $TILECACHE->put ($face->{id} => $face->{image}); #TODO: try to avoid duplicate writes |
530 | |
937 | |
531 | my $tex = $face->{texture} = |
938 | $self->set_texture ($face->{id} => delete $face->{image}); |
|
|
939 | } |
|
|
940 | |
|
|
941 | sub conn::set_texture { |
|
|
942 | my ($self, $id, $data) = @_; |
|
|
943 | |
|
|
944 | $self->{texture}[$id] ||= do { |
|
|
945 | my $tex = |
532 | new_from_image CFClient::Texture |
946 | new_from_image CFClient::Texture |
533 | delete $face->{image}, minify => 1; |
947 | $data, minify => 1; |
534 | |
948 | |
535 | $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
949 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
536 | $MAPWIDGET->update; |
950 | $MAPWIDGET->update; |
|
|
951 | |
|
|
952 | $tex |
|
|
953 | }; |
|
|
954 | } |
|
|
955 | |
|
|
956 | sub conn::sound_play { |
|
|
957 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
958 | |
|
|
959 | $SDL_MIXER |
|
|
960 | or return; |
|
|
961 | |
|
|
962 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
|
|
963 | or return; |
|
|
964 | |
|
|
965 | $chunk->play; |
|
|
966 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
537 | } |
967 | } |
538 | |
968 | |
539 | sub conn::query { |
969 | sub conn::query { |
540 | my ($self, $flags, $prompt) = @_; |
970 | my ($self, $flags, $prompt) = @_; |
541 | |
971 | |
542 | #TODO |
972 | #TODO, display dialog with relevant information |
543 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
973 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
544 | } |
974 | } |
545 | |
975 | |
546 | sub conn::drawinfo { |
976 | sub conn::drawinfo { |
547 | my ($self, $color, $text) = @_; |
977 | my ($self, $color, $text) = @_; |
548 | |
978 | |
549 | my @color = ( |
979 | my @color = ( |
550 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
980 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
551 | [1.00, 1.00, 1.00], |
981 | [1.00, 1.00, 1.00], |
552 | [0.00, 0.00, 0.55], |
982 | [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] |
553 | [1.00, 0.00, 0.00], |
983 | [1.00, 0.00, 0.00], |
554 | [1.00, 0.54, 0.00], |
984 | [1.00, 0.54, 0.00], |
555 | [0.11, 0.56, 1.00], |
985 | [0.11, 0.56, 1.00], |
556 | [0.93, 0.46, 0.00], |
986 | [0.93, 0.46, 0.00], |
557 | [0.18, 0.54, 0.34], |
987 | [0.18, 0.54, 0.34], |
… | |
… | |
563 | ); |
993 | ); |
564 | |
994 | |
565 | $LOGVIEW->add_paragraph ($color[$color], $text); |
995 | $LOGVIEW->add_paragraph ($color[$color], $text); |
566 | } |
996 | } |
567 | |
997 | |
|
|
998 | sub conn::spell_add { |
|
|
999 | my ($self, $spell) = @_; |
|
|
1000 | |
|
|
1001 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
|
|
1002 | }); |
|
|
1003 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
|
|
1004 | }); |
|
|
1005 | } |
|
|
1006 | |
|
|
1007 | sub conn::spell_delete { |
|
|
1008 | my ($self, $spell) = @_; |
|
|
1009 | } |
|
|
1010 | |
|
|
1011 | sub conn::addme_success { |
|
|
1012 | my ($self) = @_; |
|
|
1013 | |
|
|
1014 | for my $skill (values %{$self->{skill_info}}) { |
|
|
1015 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
|
|
1016 | }); |
|
|
1017 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
1018 | }); |
|
|
1019 | } |
|
|
1020 | } |
|
|
1021 | |
568 | %SDL_CB = ( |
1022 | %SDL_CB = ( |
569 | SDL_QUIT() => sub { |
1023 | CFClient::SDL_QUIT => sub { |
570 | Event::unloop -1; |
1024 | Event::unloop -1; |
571 | }, |
1025 | }, |
572 | SDL_VIDEORESIZE() => sub { |
1026 | CFClient::SDL_VIDEORESIZE => sub { |
573 | }, |
1027 | }, |
574 | SDL_VIDEOEXPOSE() => sub { |
1028 | CFClient::SDL_VIDEOEXPOSE => \&refresh, |
575 | refresh; |
1029 | CFClient::SDL_ACTIVEEVENT => sub { |
|
|
1030 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
576 | }, |
1031 | }, |
577 | SDL_KEYDOWN() => sub { |
1032 | CFClient::SDL_KEYDOWN => sub { |
578 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
1033 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
579 | # alt-enter |
1034 | # alt-enter |
580 | destroy_screen; |
1035 | video_shutdown; |
581 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
1036 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
582 | init_screen; |
1037 | video_init; |
583 | } else { |
1038 | } else { |
584 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
1039 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
585 | } |
1040 | } |
586 | }, |
1041 | }, |
587 | SDL_KEYUP() => sub { |
1042 | CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, |
588 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
1043 | CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, |
589 | }, |
1044 | CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, |
590 | SDL_MOUSEMOTION() => sub { |
1045 | CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, |
591 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
1046 | CFClient::SDL_USEREVENT => \&audio_music_finished, |
592 | }, |
|
|
593 | SDL_MOUSEBUTTONDOWN() => sub { |
|
|
594 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
|
|
595 | }, |
|
|
596 | SDL_MOUSEBUTTONUP() => sub { |
|
|
597 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
|
|
598 | }, |
|
|
599 | SDL_ACTIVEEVENT() => sub { |
|
|
600 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
|
|
601 | }, |
|
|
602 | ); |
1047 | ); |
603 | |
1048 | |
604 | ############################################################################# |
1049 | ############################################################################# |
605 | |
1050 | |
|
|
1051 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
1052 | |
606 | $FACECACHE = CFClient::db_table "facecache"; |
1053 | $TILECACHE = CFClient::db_table "tilecache"; |
|
|
1054 | $FACEMAP = CFClient::db_table "facemap"; |
607 | |
1055 | |
608 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
1056 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
609 | |
1057 | |
610 | my %DEF_CFG = ( |
1058 | my %DEF_CFG = ( |
611 | sdl_mode => 0, |
1059 | sdl_mode => 0, |
… | |
… | |
614 | fullscreen => 0, |
1062 | fullscreen => 0, |
615 | fast => 0, |
1063 | fast => 0, |
616 | fow_enable => 1, |
1064 | fow_enable => 1, |
617 | fow_intensity => 0.45, |
1065 | fow_intensity => 0.45, |
618 | fow_smooth => 0, |
1066 | fow_smooth => 0, |
|
|
1067 | gui_fontsize => 1, |
619 | log_fontsize => 14, |
1068 | log_fontsize => 1, |
|
|
1069 | stat_fontsize => 1, |
620 | mapsize => 100, |
1070 | mapsize => 100, |
621 | host => "crossfire.schmorp.de", |
1071 | host => "crossfire.schmorp.de", |
622 | say_command => 'say', |
1072 | say_command => 'say', |
|
|
1073 | audio_enable => 1, |
|
|
1074 | bgm_enable => 1, |
|
|
1075 | bgm_volume => 0.25, |
623 | ); |
1076 | ); |
624 | |
1077 | |
625 | while (my ($k, $v) = each %DEF_CFG) { |
1078 | while (my ($k, $v) = each %DEF_CFG) { |
626 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
1079 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
627 | } |
1080 | } |
628 | |
1081 | |
629 | sdl_init; |
1082 | sdl_init; |
630 | |
1083 | |
631 | @SDL_MODES = reverse |
1084 | @SDL_MODES = reverse |
632 | grep $_->[0] >= 640 && $_->[1] >= 480, |
1085 | grep $_->[0] >= 640 && $_->[1] >= 480, |
633 | map [SDL::RectW ($_), SDL::RectH ($_)], |
1086 | CFClient::SDL_ListModes; |
634 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
|
|
635 | |
1087 | |
636 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
1088 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
637 | |
1089 | |
638 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
1090 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
639 | |
|
|
640 | init_screen; |
|
|
641 | |
1091 | |
642 | { |
1092 | { |
643 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
1093 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
644 | |
1094 | |
645 | CFClient::add_font $_ for @fonts; |
1095 | CFClient::add_font $_ for @fonts; |
646 | CFClient::set_font $fonts[0]; |
1096 | CFClient::set_font $fonts[0]; |
647 | } |
1097 | } |
648 | |
1098 | |
|
|
1099 | video_init; |
|
|
1100 | audio_init; |
|
|
1101 | |
649 | Event::loop; |
1102 | Event::loop; |
650 | |
1103 | |
|
|
1104 | END { CFClient::SDL_Quit } |
651 | |
1105 | |
|
|
1106 | |