ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.44 by elmex, Sun Apr 9 02:44:51 2006 UTC vs.
Revision 1.45 by root, Sun Apr 9 17:34:15 2006 UTC

44our $ALT_ENTER_MESSAGE; 44our $ALT_ENTER_MESSAGE;
45 45
46our $TOPLEVEL; 46our $TOPLEVEL;
47 47
48our $tw; # Test widget #d# 48our $tw; # Test widget #d#
49
50my $last_refresh;
49 51
50sub init_screen { 52sub init_screen {
51 $SDL_APP = new SDL::App 53 $SDL_APP = new SDL::App
52 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 54 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
53 -title => "Crossfire+ Client", 55 -title => "Crossfire+ Client",
59 -blue_size => 8, 61 -blue_size => 8,
60 -double_buffer => 1, 62 -double_buffer => 1,
61 -fullscreen => $FULLSCREEN, 63 -fullscreen => $FULLSCREEN,
62 -resizeable => 0; 64 -resizeable => 0;
63 65
66 $last_refresh = SDL::GetTicks;
67
64 %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; 68 %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions;
65 69
66 $GL_EXT{GL_ARB_texture_non_power_of_two} 70 $GL_EXT{GL_ARB_texture_non_power_of_two}
67 or warn "WARNING: non-power-of-two opengl extension required"; 71 or warn "WARNING: non-power-of-two opengl extension required";
68 72
74 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); 78 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]);
75 $TOPLEVEL->add ($ALT_ENTER_MESSAGE); 79 $TOPLEVEL->add ($ALT_ENTER_MESSAGE);
76 80
77 # Test code #d# 81 # Test code #d#
78 unless ($tw) { # haha... 82 unless ($tw) { # haha...
83 $tw = new Crossfire::Client::Widget::Animator;
79 $tw = new Crossfire::Client::Widget::FancyFrame; 84 $tw->add (my $f = new Crossfire::Client::Widget::FancyFrame);
80 $tw->add ( 85 $f->add (
81 my $te = new Crossfire::Client::Widget::Label 86 my $te = new Crossfire::Client::Widget::Label
82 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!" 87 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"
83 ); 88 );
84 89
85 $tw->move ($WIDTH - 200, 0); 90 $tw->move ($WIDTH - 200, 0);
91 $tw->moveto (0, 0);
86 $TOPLEVEL->add ($tw); 92 $TOPLEVEL->add ($tw);
87 } 93 }
88 94
89 glClearColor 0, 0, 0, 0; 95 glClearColor 0, 0, 0, 0;
90 96
117 user => $CFG->{user}, 123 user => $CFG->{user},
118 pass => $CFG->{password}, 124 pass => $CFG->{password},
119 mapw => 50, 125 mapw => 50,
120 maph => 37, 126 maph => 37,
121 ; 127 ;
128
129 Crossfire::Client::lowdelay fileno $CONN->{fh};
122} 130}
123 131
124sub stop_game { 132sub stop_game {
125 remove Glib::Source $SDL_TIMER; 133 remove Glib::Source $SDL_TIMER;
126 134
132sub force_refresh { 140sub force_refresh {
133 glViewport 0, 0, $WIDTH, $HEIGHT; 141 glViewport 0, 0, $WIDTH, $HEIGHT;
134 142
135 glMatrixMode GL_PROJECTION; 143 glMatrixMode GL_PROJECTION;
136 glLoadIdentity; 144 glLoadIdentity;
137 glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100; 145 glOrtho 0, $WIDTH, $HEIGHT, 0, -6000 , 6000;
138 glMatrixMode GL_MODELVIEW; 146 glMatrixMode GL_MODELVIEW;
139 147
140 glClear GL_COLOR_BUFFER_BIT; 148 glClear GL_COLOR_BUFFER_BIT;
141 149
142 $TOPLEVEL->draw; 150 $TOPLEVEL->draw;
143 151
144 SDL::GLSwapBuffers; 152 SDL::GLSwapBuffers;
145} 153}
154
155my %ANIMATE;
146 156
147my $refresh_handler; 157my $refresh_handler;
148 158
149sub refresh { 159sub refresh {
150 $refresh_handler ||= add Glib::Idle sub { 160 $refresh_handler ||= add Glib::Idle sub {
161 my $next_refresh = SDL::GetTicks;
162 my $interval = ($next_refresh - $last_refresh) * 0.001;
163 $last_refresh = $next_refresh;
164
151 force_refresh; 165 force_refresh;
166 $_->animate ($interval) for grep $_, values %ANIMATE;
167
168 if (%ANIMATE) {
169 1
170 } else {
152 undef $refresh_handler; 171 undef $refresh_handler;
172 0
153 0 173 }
154 }; 174 };
175}
176
177sub animation_start {
178 my ($widget) = @_;
179 $ANIMATE{$widget} = $widget;
180 Scalar::Util::weaken $ANIMATE{$widget};
181
182 refresh;
183}
184
185sub animation_stop {
186 my ($widget) = @_;
187 delete $ANIMATE{$widget};
155} 188}
156 189
157%SDL_CB = ( 190%SDL_CB = (
158 SDL_QUIT() => sub { 191 SDL_QUIT() => sub {
159 main_quit Gtk2; 192 main_quit Gtk2;
198} 231}
199 232
200sub conn::map_scroll { 233sub conn::map_scroll {
201 my ($self, $dx, $dy) = @_; 234 my ($self, $dx, $dy) = @_;
202 235
203 refresh; 236# refresh;
204} 237}
205 238
206sub conn::map_clear { 239sub conn::map_clear {
207 my ($self) = @_; 240 my ($self) = @_;
208 241
209 refresh; 242# refresh;
210} 243}
211 244
212sub conn::face_find { 245sub conn::face_find {
213 my ($self, $face) = @_; 246 my ($self, $face) = @_;
214 247

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines