… | |
… | |
41 | |
41 | |
42 | our @GL_INIT; # hooks called on every gl init |
42 | our @GL_INIT; # hooks called on every gl init |
43 | |
43 | |
44 | our $ALT_ENTER_MESSAGE; |
44 | our $ALT_ENTER_MESSAGE; |
45 | |
45 | |
46 | our $tw; |
46 | our $tw; # Test widget #d# |
47 | |
47 | |
48 | sub init_screen { |
48 | sub init_screen { |
49 | $SDL_APP = new SDL::App |
49 | $SDL_APP = new SDL::App |
50 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
50 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
51 | -title => "Crossfire+ Client", |
51 | -title => "Crossfire+ Client", |
… | |
… | |
62 | %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; |
62 | %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; |
63 | |
63 | |
64 | $GL_EXT{GL_ARB_texture_non_power_of_two} |
64 | $GL_EXT{GL_ARB_texture_non_power_of_two} |
65 | or warn "WARNING: non-power-of-two opengl extension required"; |
65 | or warn "WARNING: non-power-of-two opengl extension required"; |
66 | |
66 | |
67 | $UIFONT = SDL::TTFOpenFont Crossfire::Client::find_rcfile "uifont.ttf", $HEIGHT / 40 |
|
|
68 | or die "TTFOpenFont: $!"; |
|
|
69 | |
|
|
70 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Alt-Enter toggles fullscreen mode"; |
67 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Alt-Enter toggles fullscreen mode"; |
71 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); |
68 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); |
72 | $ALT_ENTER_MESSAGE->activate; |
69 | $ALT_ENTER_MESSAGE->activate; |
73 | |
70 | |
|
|
71 | # Test code #d# |
|
|
72 | my $frm = new Crossfire::Client::Widget::Frame; |
74 | $tw = new Crossfire::Client::Widget::Window; |
73 | $tw = new Crossfire::Client::Widget::Window; |
75 | $tw->add (my $lbl = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"); |
74 | $frm->add (new Crossfire::Client::Widget::Label 0, 0, 10, $UIFONT, "Foo in the garden!"); |
76 | # $tw = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"; |
75 | $tw->add ($frm); |
77 | |
76 | |
78 | $tw->move (0, $HEIGHT - 50); |
77 | $tw->move (0, $HEIGHT - 120); |
79 | $tw->activate; |
78 | $tw->activate; |
|
|
79 | # Test code end #d# |
80 | |
80 | |
81 | glClearColor 0, 0, 0, 0; |
81 | glClearColor 0, 0, 0, 0; |
82 | |
82 | |
83 | glEnable GL_TEXTURE_2D; |
83 | glEnable GL_TEXTURE_2D; |
|
|
84 | glEnable GL_COLOR_MATERIAL; |
84 | glShadeModel GL_FLAT; |
85 | glShadeModel GL_FLAT; |
85 | glDisable GL_DEPTH_TEST; |
86 | glDisable GL_DEPTH_TEST; |
86 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
87 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
87 | |
|
|
88 | glMatrixMode GL_PROJECTION; |
|
|
89 | glLoadIdentity; |
|
|
90 | glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100; |
|
|
91 | |
|
|
92 | glMatrixMode GL_MODELVIEW; |
|
|
93 | |
88 | |
94 | $_->() for @GL_INIT; |
89 | $_->() for @GL_INIT; |
95 | } |
90 | } |
96 | |
91 | |
97 | sub start_game { |
92 | sub start_game { |
… | |
… | |
110 | |
105 | |
111 | $CONN = new conn |
106 | $CONN = new conn |
112 | host => $CFG->{host}, |
107 | host => $CFG->{host}, |
113 | port => $CFG->{port}, |
108 | port => $CFG->{port}, |
114 | user => $CFG->{user}, |
109 | user => $CFG->{user}, |
115 | pass => $CFG->{password}; |
110 | pass => $CFG->{password}, |
|
|
111 | mapw => 50, |
|
|
112 | maph => 37, |
|
|
113 | ; |
116 | } |
114 | } |
117 | |
115 | |
118 | sub stop_game { |
116 | sub stop_game { |
119 | remove Glib::Source $SDL_TIMER; |
117 | remove Glib::Source $SDL_TIMER; |
120 | |
118 | |
… | |
… | |
123 | } |
121 | } |
124 | |
122 | |
125 | |
123 | |
126 | sub force_refresh { |
124 | sub force_refresh { |
127 | glViewport 0, 0, $WIDTH, $HEIGHT; |
125 | glViewport 0, 0, $WIDTH, $HEIGHT; |
|
|
126 | |
|
|
127 | glMatrixMode GL_PROJECTION; |
|
|
128 | glLoadIdentity; |
|
|
129 | glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100; |
|
|
130 | glMatrixMode GL_MODELVIEW; |
|
|
131 | |
128 | glClear GL_COLOR_BUFFER_BIT; |
132 | glClear GL_COLOR_BUFFER_BIT; |
129 | |
133 | |
130 | $_->draw for @Crossfire::Client::Widget::ACTIVE_WIDGETS; |
134 | $_->draw for @Crossfire::Client::Widget::ACTIVE_WIDGETS; |
131 | |
135 | |
132 | SDL::GLSwapBuffers; |
136 | SDL::GLSwapBuffers; |
… | |
… | |
207 | my ($self, $face) = @_; |
211 | my ($self, $face) = @_; |
208 | |
212 | |
209 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
213 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
210 | |
214 | |
211 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
215 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
|
|
216 | } |
|
|
217 | |
|
|
218 | sub conn::query { |
|
|
219 | my ($self, $flags, $prompt) = @_; |
|
|
220 | |
|
|
221 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
212 | } |
222 | } |
213 | |
223 | |
214 | sub gtk_add_cfg_field { |
224 | sub gtk_add_cfg_field { |
215 | my ($tbl, $cfg, $klbl, $key, $value) = @_; |
225 | my ($tbl, $cfg, $klbl, $key, $value) = @_; |
216 | my $i = $cfg->{_i}++; |
226 | my $i = $cfg->{_i}++; |
… | |
… | |
304 | |
314 | |
305 | |
315 | |
306 | ############################################################################# |
316 | ############################################################################# |
307 | |
317 | |
308 | SDL::Init SDL_INIT_EVERYTHING; |
318 | SDL::Init SDL_INIT_EVERYTHING; |
309 | SDL::TTFInit; |
|
|
310 | |
319 | |
311 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
320 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
312 | |
321 | |
313 | $mapwidget->activate; |
322 | $mapwidget->activate; |
314 | $mapwidget->focus_in; |
323 | $mapwidget->focus_in; |