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.80 by root, Wed Apr 12 02:00:07 2006 UTC vs.
Revision 1.81 by root, Wed Apr 12 02:05:46 2006 UTC

51 51
52my $last_refresh; 52my $last_refresh;
53my %ANIMATE; 53my %ANIMATE;
54my $refresh_handler; 54my $refresh_handler;
55 55
56our ($tw, $te); # Test widget #d# 56sub config_dialog {
57 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
58 child => (my $vbox = new CFClient::UI::VBox);
59 $vbox->add (new CFClient::UI::Label align => 0, text => "Setup");
60 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
61
62 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode");
63 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
64
65 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
66 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8);
67
68 $mode_slider->connect (changed => sub {
69 my ($self, $value) = @_;
70
71 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
72 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
73 });
74 $mode_slider->emit (changed => $mode_slider->{range}[0]);
75
76 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Host");
77 $table->add (1, 1, my $host = new CFClient::UI::Entry text => $CFG->{host});
78
79 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Port");
80 $table->add (1, 2, my $port = new CFClient::UI::Entry text => $CFG->{port});
81
82 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Username");
83 $table->add (1, 3, my $user = new CFClient::UI::Entry text => $CFG->{user});
84
85 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Password");
86 $table->add (1, 4, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1);
87
88 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Map Size");
89 $table->add (1, 5, new CFClient::UI::Slider
90 req_w => 100,
91 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
92 connect_changed => sub {
93 my ($self, $value) = @_;
94
95 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
96 },
97 );
98
99 $vbox->add (my $hbox = new CFClient::UI::HBox);
100 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
101 warn "save\n";
102 });
103 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
104 warn "login\n";
105 });
106 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
107 warn "apply\n";
108 });
109
110 $CFClient::UI::TOPLEVEL->add ($dialog);
111}
57 112
58sub init_screen { 113sub init_screen {
59 $SDL_APP = new SDL::App 114 $SDL_APP = new SDL::App
60 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 115 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
61 -title => "Crossfire+ Client", 116 -title => "Crossfire+ Client",
104 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 159 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
105 160
106 $MAPWIDGET = new CFClient::UI::MapWidget; 161 $MAPWIDGET = new CFClient::UI::MapWidget;
107 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); 162 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET);
108 $MAPWIDGET->focus_in; 163 $MAPWIDGET->focus_in;
164
165 config_dialog;
109} 166}
110 167
111sub destroy_screen { 168sub destroy_screen {
169 $CFClient::UI::TOPLEVEL->{children} = [];
112 remove Glib::Source $SDL_TIMER; 170 remove Glib::Source $SDL_TIMER;
113 undef $SDL_APP; 171 undef $SDL_APP;
114 undef $SDL_EV; 172 undef $SDL_EV;
115 SDL::Quit; 173 SDL::Quit;
116} 174}
117 175
118sub config_dialog {
119 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
120 child => (my $vbox = new CFClient::UI::VBox);
121 $vbox->add (new CFClient::UI::Label align => 0, text => "Setup");
122 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
123
124 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode");
125 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
126
127 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
128 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8);
129
130 $mode_slider->connect (changed => sub {
131 my ($self, $value) = @_;
132
133 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
134 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
135 });
136 $mode_slider->emit (changed => $mode_slider->{range}[0]);
137
138 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Host");
139 $table->add (1, 1, my $host = new CFClient::UI::Entry text => $CFG->{host});
140
141 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Port");
142 $table->add (1, 2, my $port = new CFClient::UI::Entry text => $CFG->{port});
143
144 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Username");
145 $table->add (1, 3, my $user = new CFClient::UI::Entry text => $CFG->{user});
146
147 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Password");
148 $table->add (1, 4, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1);
149
150 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Map Size");
151 $table->add (1, 5, new CFClient::UI::Slider
152 req_w => 100,
153 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
154 connect_changed => sub {
155 my ($self, $value) = @_;
156
157 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
158 },
159 );
160
161 $vbox->add (my $hbox = new CFClient::UI::HBox);
162 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
163 warn "save\n";
164 });
165 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
166 warn "login\n";
167 });
168 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
169 warn "apply\n";
170 });
171
172 $CFClient::UI::TOPLEVEL->add ($dialog);
173}
174
175sub start_game { 176sub start_game {
176 $WIDTH = $CFG->{width}; 177 $WIDTH = $CFG->{width};
177 $HEIGHT = $CFG->{height}; 178 $HEIGHT = $CFG->{height};
178 $FULLSCREEN = 0; 179 $FULLSCREEN = 0;
179 180
180 init_screen; 181 init_screen;
181
182 config_dialog;
183 182
184 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 183 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
185 184
186 $CONN = new conn 185 $CONN = new conn
187 host => $CFG->{host}, 186 host => $CFG->{host},
286 }, 285 },
287 SDL_KEYDOWN() => sub { 286 SDL_KEYDOWN() => sub {
288 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 287 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
289 # alt-enter 288 # alt-enter
290 $FULLSCREEN = !$FULLSCREEN; 289 $FULLSCREEN = !$FULLSCREEN;
290 destroy_screen;
291 init_screen; 291 init_screen;
292 } else { 292 } else {
293 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 293 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
294 } 294 }
295 }, 295 },

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines