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.13 by root, Fri Apr 7 16:30:23 2006 UTC vs.
Revision 1.16 by elmex, Fri Apr 7 17:37:11 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use strict; 2use strict;
4 3
5use Glib; 4use Glib;
6use Gtk2 -init; 5use Gtk2 -init;
7 6
15use Crossfire; 14use Crossfire;
16use Crossfire::Client; 15use Crossfire::Client;
17use Crossfire::Protocol; 16use Crossfire::Protocol;
18 17
19use Client::Util; 18use Client::Util;
19use Client::Widget;
20 20
21our $VERSION = '0.1'; 21our $VERSION = '0.1';
22 22
23our $CFG; 23our $CFG;
24our $CONN; 24our $CONN;
83 83
84sub refresh { 84sub refresh {
85 glClearColor 0, 0, 0, 0; 85 glClearColor 0, 0, 0, 0;
86 glClear GL_COLOR_BUFFER_BIT; 86 glClear GL_COLOR_BUFFER_BIT;
87 87
88 my $map = $CONN->{map}; 88 for (values %Client::Widget::ACTIVE_WIDGETS) {
89 89 $_->draw
90 for my $x (0 .. $CONN->{mapw} - 1) {
91 for my $y (0 .. $CONN->{maph} - 1) {
92
93 my $cell = $map->[$x][$y]
94 or next;
95
96 my $darkness = $cell->[3] * (1 / 255);
97 glColor $darkness, $darkness, $darkness;
98
99 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
100 my $tex = $CONN->{face}[$num]{texture} || 0;
101
102 glBindTexture GL_TEXTURE_2D, $tex;
103
104 glBegin GL_QUADS;
105 glTexCoord 0, 0; glVertex $x, $y;
106 glTexCoord 0, 1; glVertex $x, $y + 1;
107 glTexCoord 1, 1; glVertex $x + 1, $y + 1;
108 glTexCoord 1, 0; glVertex $x + 1, $y;
109 glEnd;
110 }
111 }
112 } 90 }
113 91
114 SDL::GLSwapBuffers; 92 SDL::GLSwapBuffers;
115} 93}
116 94
123 }, 101 },
124 SDL_VIDEOEXPOSE() => sub { 102 SDL_VIDEOEXPOSE() => sub {
125 refresh; 103 refresh;
126 }, 104 },
127 SDL_KEYDOWN() => sub { 105 SDL_KEYDOWN() => sub {
106 Client::Widget::feed_sdl_key_down_event ($SDL_EV);
128 }, 107 },
129 SDL_KEYUP() => sub { 108 SDL_KEYUP() => sub {
109 Client::Widget::feed_sdl_key_up_event ($SDL_EV);
130 }, 110 },
131 SDL_MOUSEMOTION() => sub { 111 SDL_MOUSEMOTION() => sub {
132 warn "sdl motion\n";#d# 112 warn "sdl motion\n";#d#
133 }, 113 },
134 SDL_MOUSEBUTTONDOWN() => sub { 114 SDL_MOUSEBUTTONDOWN() => sub {
115 Client::Widget::feed_sdl_button_down_event ($SDL_EV);
135 }, 116 },
136 SDL_MOUSEBUTTONUP() => sub { 117 SDL_MOUSEBUTTONUP() => sub {
118 Client::Widget::feed_sdl_button_up_event ($SDL_EV);
137 }, 119 },
138 SDL_ACTIVEEVENT() => sub { 120 SDL_ACTIVEEVENT() => sub {
139 warn "active\n";#d# 121 warn "active\n";#d#
140 }, 122 },
141); 123);
193 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr; 175 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr;
194} 176}
195 177
196############################################################################# 178#############################################################################
197 179
180my $mapwidget = Client::MapWidget->new;
181
182$mapwidget->activate;
183$mapwidget->focus_in;
184
198Client::Util::read_cfg "$Crossfire::VARDIR/pclientrc"; 185Client::Util::read_cfg "$Crossfire::VARDIR/pclientrc";
199 186
200$CFG ||= { 187$CFG ||= {
201 width => 640, 188 width => 640,
202 height => 480, 189 height => 480,
203 fullscreen => 0, 190 fullscreen => 0,
204 host => "crossfire.schmorp.de", 191 host => "crossfire.schmorp.de",
205 port => 13327, 192 port => 13327,
206}; 193};
207 194
208Client::Util::run_config_dialog; 195Client::Util::run_config_dialog
196 login => sub { start_game },
197 logout => sub { stop_game };
209 198
210main Gtk2; 199main Gtk2;
211

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines