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.50 by root, Sun Apr 9 21:05:50 2006 UTC vs.
Revision 1.53 by root, Sun Apr 9 22:17:40 2006 UTC

40our %SDL_CB; 40our %SDL_CB;
41 41
42our @GL_INIT; # hooks called on every gl init 42our @GL_INIT; # hooks called on every gl init
43 43
44our $ALT_ENTER_MESSAGE; 44our $ALT_ENTER_MESSAGE;
45our $STATUS_LINE;
45 46
46our $TOPLEVEL; 47our $TOPLEVEL;
47 48
48our $tw; # Test widget #d# 49our $tw; # Test widget #d#
49 50
56 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 57 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
57 -title => "Crossfire+ Client", 58 -title => "Crossfire+ Client",
58 -width => $WIDTH, 59 -width => $WIDTH,
59 -height => $HEIGHT, 60 -height => $HEIGHT,
60 -opengl => 1, 61 -opengl => 1,
61 -red_size => 8, 62 -red_size => 5,
62 -green_size => 8, 63 -green_size => 5,
63 -blue_size => 8, 64 -blue_size => 5,
65 -alpha_size => 0,
64 -double_buffer => 1, 66 -double_buffer => 1,
65 -fullscreen => $FULLSCREEN, 67 -fullscreen => $FULLSCREEN,
66 -resizeable => 0; 68 -resizeable => 0;
67 69
68 $last_refresh = SDL::GetTicks; 70 $last_refresh = SDL::GetTicks;
72 $GL_EXT{GL_ARB_texture_non_power_of_two} 74 $GL_EXT{GL_ARB_texture_non_power_of_two}
73 or warn "WARNING: non-power-of-two opengl extension required"; 75 or warn "WARNING: non-power-of-two opengl extension required";
74 76
75 $FONTSIZE = int $HEIGHT / 50; 77 $FONTSIZE = int $HEIGHT / 50;
76 78
79 #############################################################################
80
81 glClearColor 0, 0, 0, 0;
82
83 glEnable GL_TEXTURE_2D;
84 glEnable GL_COLOR_MATERIAL;
85 glShadeModel GL_FLAT;
86 glDisable GL_DEPTH_TEST;
87 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
88
89 $_->() for @GL_INIT;
90
91 #############################################################################
92
93 $STATUS_LINE = new Crossfire::Client::Widget::Label
94 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE,
95 "";
96 $TOPLEVEL->add ($STATUS_LINE);
97
77 $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label 98 $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label
78 0, $FONTSIZE, $HEIGHT - $FONTSIZE, $FONTSIZE, 99 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60,
79 "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 100 "Use <b>Alt-Enter</b> to toggle fullscreen mode";
80 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]);
81 $TOPLEVEL->add ($ALT_ENTER_MESSAGE); 101 $TOPLEVEL->add ($ALT_ENTER_MESSAGE);
82 102
83 # Test code #d# 103 # Test code #d#
84 unless ($tw) { # haha... 104 unless ($tw) { # haha...
85 $tw = new Crossfire::Client::Widget::Animator; 105 $tw = new Crossfire::Client::Widget::Animator;
104 $TOPLEVEL->add ($tw); 124 $TOPLEVEL->add ($tw);
105 125
106# $f->move ($WIDTH - 200, 0); 126# $f->move ($WIDTH - 200, 0);
107# $TOPLEVEL->add ($f); 127# $TOPLEVEL->add ($f);
108 } 128 }
109
110 glClearColor 0, 0, 0, 0;
111
112 glEnable GL_TEXTURE_2D;
113 glEnable GL_COLOR_MATERIAL;
114 glShadeModel GL_FLAT;
115 glDisable GL_DEPTH_TEST;
116 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
117
118 $_->() for @GL_INIT;
119} 129}
120 130
121sub start_game { 131sub start_game {
122 $SDL_TIMER = add Glib::Timeout 1000/50, sub { 132 $SDL_TIMER = add Glib::Timeout 1000/50, sub {
123 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() 133 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->()
146 Crossfire::Client::lowdelay fileno $CONN->{fh}; 156 Crossfire::Client::lowdelay fileno $CONN->{fh};
147} 157}
148 158
149sub stop_game { 159sub stop_game {
150 remove Glib::Source $SDL_TIMER; 160 remove Glib::Source $SDL_TIMER;
151 remove Glib::Source $refresh_handler; 161 remove Glib::Source $refresh_handler if $refresh_handler;
152 undef $refresh_handler; 162 undef $refresh_handler;
153 163
154 undef $SDL_APP; 164 undef $SDL_APP;
155 undef $CONN; 165 undef $CONN;
156 SDL::Quit; 166 SDL::Quit;
225 }, 235 },
226 SDL_KEYUP() => sub { 236 SDL_KEYUP() => sub {
227 Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); 237 Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV);
228 }, 238 },
229 SDL_MOUSEMOTION() => sub { 239 SDL_MOUSEMOTION() => sub {
230 warn "sdl motion\n";#d# 240 my ($x, $y) = ($SDL_EV->motion_x, $SDL_EV->motion_y);
241 my $widget = $TOPLEVEL->find_widget ($x, $y);
242
243 warn "mouse $x, $y = $widget\n";
231 }, 244 },
232 SDL_MOUSEBUTTONDOWN() => sub { 245 SDL_MOUSEBUTTONDOWN() => sub {
233 Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); 246 Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV);
234 }, 247 },
235 SDL_MOUSEBUTTONUP() => sub { 248 SDL_MOUSEBUTTONUP() => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines