1 // $Id: gui_new_file_button.cxx,v 1.2 2003/07/25 11:07:44 grumbel Exp $
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "controller.hxx"
22 #include "screen_manager.hxx"
23 #include "gui_new_file_button.hxx"
25 GUINewFileButton::GUINewFileButton(const std::string
& p
)
26 : GUIFileButton (p
), pathname (p
)
32 GUINewFileButton::draw(GraphicContext
* parent_gc
)
34 parent_gc
->draw_fill_rect (x_pos
, y_pos
,
35 x_pos
+ width
, y_pos
+ height
,
38 parent_gc
->draw_string (x_pos
+ 20, y_pos
+ 75, "..:: Save to new file ::..");
39 //parent_gc->draw_string (x_pos + 30, y_pos + 40, filename);
42 parent_gc
->draw_rect (x_pos
, y_pos
,
43 x_pos
+ width
, y_pos
+ height
,
46 parent_gc
->draw_rect (x_pos
, y_pos
,
47 x_pos
+ width
, y_pos
+ height
,
52 GUINewFileButton::generate_filename()
57 curtime
= time (NULL
);
58 loctime
= localtime(&curtime
);
59 strftime(buffer
, 32, "%Y%m%d-%H%M%S", loctime
);
61 return pathname
+ "/" + std::string(buffer
) + ".construo";
65 GUINewFileButton::on_click()
67 std::string filename
= generate_filename();
68 std::cout
<< "Saving to: " << filename
<< std::endl
;
69 Controller::instance()->save_world (filename
);
70 ScreenManager::instance()->set_gui(ScreenManager::WORLD_GUI
);