*/
#include "asset.h"
+#include "bchash.h"
#include "confirmsave.h"
#include "language.h"
#include "mwindow.h"
#include "mwindowgui.h"
-
-
ConfirmSave::ConfirmSave()
{
}
{
}
+int ConfirmSave::get_save_path(MWindow *mwindow, char *filename)
+{
+ int result = 1;
+ char directory[BCTEXTLEN];
+ sprintf(directory, "~");
+ mwindow->defaults->get("DIRECTORY", directory);
+ while( result ) {
+ int mx, my; mwindow->gui->get_abs_cursor(mx, my);
+ my -= BC_WindowBase::get_resources()->filebox_h / 2;
+ char string[BCTEXTLEN];
+ sprintf(string, _("Enter a filename to save as"));
+ BC_FileBox *filebox = new BC_FileBox(mx, my, directory,
+ _(PROGRAM_NAME ": Save"), string);
+ filebox->lock_window("ConfirmSave::get_save_path");
+ filebox->create_objects();
+ filebox->unlock_window();
+ result = filebox->run_window();
+ mwindow->defaults->update("DIRECTORY", filebox->get_submitted_path());
+ strcpy(filename, filebox->get_submitted_path());
+ delete filebox;
+ if( result == 1 ) return 1; // user cancelled
+ if( !filename[0] ) return 1; // no filename given
+// Extend the filename with .xml
+ if( strlen(filename) < 4 ||
+ strcasecmp(&filename[strlen(filename) - 4], ".xml") ) {
+ strcat(filename, ".xml");
+ }
+ result = ConfirmSave::test_file(mwindow, filename);
+ }
+ return result;
+}
+
int ConfirmSave::test_file(MWindow *mwindow, char *path)
{
ArrayList<char*> paths;
}
-
-
-
-
-
-
+#define CSW_W xS(400)
+#define CSW_H yS(150)
ConfirmSaveWindow::ConfirmSaveWindow(MWindow *mwindow,
ArrayList<BC_ListBoxItem*> *list)
: BC_Window(_(PROGRAM_NAME ": File Exists"),
- mwindow->gui->get_abs_cursor_x(1) - 160,
- mwindow->gui->get_abs_cursor_y(1) - 120,
- 320,
- 320)
+ mwindow->gui->get_abs_cursor_x(1) - CSW_W/2,
+ mwindow->gui->get_abs_cursor_y(1) - CSW_H/2,
+ CSW_W, CSW_H)
{
this->list = list;
}
void ConfirmSaveWindow::create_objects()
{
- int x = 10, y = 10;
+ int xs10 = xS(10);
+ int ys10 = yS(10), ys30 = yS(30);
+ int x = xs10, y = ys10;
lock_window("ConfirmSaveWindow::create_objects");
add_subwindow(new BC_OKButton(this));
add_subwindow(new BC_CancelButton(this));
add_subwindow(title = new BC_Title(x,
y,
_("The following files exist. Overwrite them?")));
- y += 30;
- add_subwindow(listbox = new BC_ListBox(x,
- y,
- get_w() - x - 10,
- get_h() - y - BC_OKButton::calculate_h() - 10,
+ y += ys30;
+ add_subwindow(listbox = new BC_ListBox(x, y,
+ get_w() - x - xs10,
+ get_h() - y - BC_OKButton::calculate_h() - ys10,
LISTBOX_TEXT,
list));
- y = get_h() - 40;
add_subwindow(new BC_OKButton(this));
- x = get_w() - 100;
add_subwindow(new BC_CancelButton(this));
show_window(1);
unlock_window();
int ConfirmSaveWindow::resize_event(int w, int h)
{
- int x = 10, y = 10;
+ int xs10 = xS(10);
+ int ys10 = yS(10), ys30 = yS(30);
+ int x = xs10, y = ys10;
title->reposition_window(x, y);
- y += 30;
- listbox->reposition_window(x,
- y,
- w - x - 10,
- h - y - 50);
+ y += ys30;
+ listbox->reposition_window(x, y,
+ w - x - xs10,
+ h - y - BC_OKButton::calculate_h() - ys10);
return 1;
}
-
-
-
-
-