34
35
#define DIALOG_WIDTH (360)
37
// we need this trick, with the function pointer.
38
// Since during initialisations virtual functions do not work yet
39
// in derived classes (since the object in question is not full initialized yet)
40
// this functions returns true for files to be added.
41
38
savegame_frame_t::savegame_frame_t(const char *suffix, const char *path, bool only_directories ) :
42
gui_frame_t("Load/Save"),
39
gui_frame_t( translator::translate("Load/Save") ),
44
41
fnlabel("Filename"),
45
42
scrolly(&button_frame)
47
44
this->suffix = suffix;
48
45
this->fullpath = path;
49
46
this->only_directories = only_directories;
50
use_pak_extension = suffix==NULL || strcmp( suffix, ".sve" )==0;
53
49
// both NULL is not acceptable
54
50
assert(suffix!=path);
56
fnlabel.set_pos (koord(10,12));
52
fnlabel.set_pos (koord(10,4));
57
53
add_komponente(&fnlabel);
59
55
// Input box for game name
60
56
tstrncpy(ibuf, "", lengthof(ibuf));
61
57
input.set_text(ibuf, 128);
62
input.set_pos(koord(75,8));
63
input.set_groesse(koord(DIALOG_WIDTH-75-10-10, 14));
58
input.set_pos(koord(75,2));
59
input.set_groesse(koord(DIALOG_WIDTH-75-scrollbar_t::BAR_SIZE-1, BUTTON_HEIGHT));
64
60
add_komponente(&input);
66
62
// needs to be scrollable
67
scrolly.set_pos( koord(0,30) );
68
scrolly.set_show_scroll_x(false);
63
scrolly.set_pos( koord(0,20) );
64
scrolly.set_scroll_amount_y(BUTTON_HEIGHT);
69
65
scrolly.set_size_corner(false);
70
scrolly.set_groesse( koord(DIALOG_WIDTH-12,30) );
74
button_frame.set_groesse( koord( DIALOG_WIDTH-1, y ) );
75
66
add_komponente(&scrolly);
78
divider1.set_pos(koord(10,y));
79
divider1.set_groesse(koord(DIALOG_WIDTH-20,0));
80
68
add_komponente(÷r1);
83
savebutton.set_pos(koord(10,y));
84
savebutton.set_groesse(koord(BUTTON_WIDTH, 14));
70
savebutton.set_groesse(koord(BUTTON_WIDTH, BUTTON_HEIGHT));
85
71
savebutton.set_text("Ok");
86
72
savebutton.set_typ(button_t::roundbox);
87
73
savebutton.add_listener(this);
88
74
add_komponente(&savebutton);
90
cancelbutton.set_pos(koord(DIALOG_WIDTH-BUTTON_WIDTH-10,y));
91
cancelbutton.set_groesse(koord(BUTTON_WIDTH, 14));
76
cancelbutton.set_groesse(koord(BUTTON_WIDTH, BUTTON_HEIGHT));
92
77
cancelbutton.set_text("Cancel");
93
78
cancelbutton.set_typ(button_t::roundbox);
94
79
cancelbutton.add_listener(this);
95
80
add_komponente(&cancelbutton);
97
82
set_focus( &input );
98
set_fenstergroesse(koord(DIALOG_WIDTH, y + 40));
84
set_min_windowsize(koord(2*(BUTTON_WIDTH+scrollbar_t::BAR_SIZE)+BUTTON_SPACER, get_fenstergroesse().y+1));
85
set_fenstergroesse(koord(DIALOG_WIDTH, TITLEBAR_HEIGHT+20+3*BUTTON_HEIGHT+30+1));
87
set_resizemode(diagonal_resize);
104
92
void savegame_frame_t::fill_list()
106
94
char searchpath[1024];
183
167
button_t* button2 = i->button;
184
168
gui_label_t* label = i->label;
186
button1->set_groesse(koord(14, 14));
170
button1->set_groesse(koord(14, BUTTON_HEIGHT));
187
171
button1->set_text("X");
188
172
button1->set_pos(koord(5, y));
189
173
button1->set_tooltip("Delete this file.");
191
175
button2->set_pos(koord(25, y));
192
button2->set_groesse(koord(140, 14));
176
button2->set_groesse(koord(140, BUTTON_HEIGHT));
194
label->set_pos(koord(170, y+3));
178
label->set_pos(koord(170, y+2));
196
180
button1->add_listener(this);
197
181
button2->add_listener(this);
200
184
button_frame.add_komponente(button2);
201
185
button_frame.add_komponente(label);
205
189
// since width was maybe increased, we only set the heigth.
206
190
button_frame.set_groesse( koord( get_fenstergroesse().x-1, y ) );
207
set_fenstergroesse(koord(get_fenstergroesse().x, y + 90));
191
set_fenstergroesse(koord(get_fenstergroesse().x, TITLEBAR_HEIGHT+12+y+30+1));
212
195
savegame_frame_t::~savegame_frame_t()
214
197
for (slist_tpl<entry>::const_iterator i = entries.begin(), end = entries.end(); i != end; ++i) {
253
234
button->set_no_translate(true);
254
235
button->set_text(name); // to avoid translation
256
const std::string compare_to = umgebung_t::objfilename.size()>0 ? umgebung_t::objfilename.substr( 0, umgebung_t::objfilename.size()-1 ) + " -" : std::string();
237
std::string const compare_to = !umgebung_t::objfilename.empty() ? umgebung_t::objfilename.substr(0, umgebung_t::objfilename.size() - 1) + " -" : std::string();
257
238
// sort by date descending:
258
239
slist_tpl<entry>::iterator i = entries.begin();
259
240
slist_tpl<entry>::iterator end = entries.end();
313
294
if(komp == &input || komp == &savebutton) {
314
295
// Save/Load Button or Enter-Key pressed
315
296
//---------------------------------------
317
297
if (strstr(ibuf,"net:")==ibuf) {
318
298
tstrncpy(buf,ibuf,lengthof(buf));
321
tstrncpy(buf, SAVE_PATH_X, lengthof(buf));
302
tstrncpy(buf, fullpath, lengthof(buf));
322
307
strcat(buf, ibuf);
325
312
set_focus( NULL );
391
376
void savegame_frame_t::set_fenstergroesse(koord groesse)
393
if(groesse.y>display_get_height()-64) {
378
if(groesse.y>display_get_height()-70) {
395
groesse.y = display_get_height()-64;
380
groesse.y = ((display_get_height()-TITLEBAR_HEIGHT-12-30-1)/BUTTON_HEIGHT)*BUTTON_HEIGHT+TITLEBAR_HEIGHT+12+30+1-70;
396
381
// position adjustment will be done automatically ... nice!
398
383
gui_frame_t::set_fenstergroesse(groesse);
399
input.set_groesse(koord(groesse.x-75-10-10, 14));
384
groesse = get_fenstergroesse();
386
input.set_groesse(koord(groesse.x-75-scrollbar_t::BAR_SIZE-1, BUTTON_HEIGHT));
402
389
for (slist_tpl<entry>::const_iterator i = entries.begin(), end = entries.end(); i != end; ++i) {
407
394
button_t* button2 = i->button;
408
395
gui_label_t* label = i->label;
409
396
button2->set_pos( koord( button2->get_pos().x, y ) );
410
button2->set_groesse(koord( groesse.x/2-40, 14));
411
label->set_pos(koord(groesse.x/2-40+30, y));
397
button2->set_groesse(koord( groesse.x/2-40, BUTTON_HEIGHT));
398
label->set_pos(koord(groesse.x/2-40+30, y+2));
416
button_frame.set_groesse( koord( groesse.x, y ) );
417
scrolly.set_groesse( koord(groesse.x,groesse.y-30-40-8) );
419
divider1.set_pos(koord(10,groesse.y-44));
420
divider1.set_groesse(koord(groesse.x-20,0));
421
savebutton.set_pos(koord(10,groesse.y-34));
422
cancelbutton.set_pos(koord(groesse.x-BUTTON_WIDTH-10,groesse.y-34));
403
button_frame.set_groesse(koord(groesse.x,y));
404
scrolly.set_groesse(koord(groesse.x,groesse.y-TITLEBAR_HEIGHT-12-30-1));
406
divider1.set_pos(koord(4,groesse.y-36));
407
divider1.set_groesse(koord(groesse.x-8-1,0));
409
savebutton.set_pos(koord(scrollbar_t::BAR_SIZE,groesse.y-BUTTON_HEIGHT-2-16-1));
410
cancelbutton.set_pos(koord(groesse.x-BUTTON_WIDTH-scrollbar_t::BAR_SIZE,groesse.y-BUTTON_HEIGHT-2-16-1));
428
414
bool savegame_frame_t::infowin_event(const event_t *ev)
430
416
if(ev->ev_class == INFOWIN && ev->ev_code == WIN_OPEN && entries.empty()) {