Rebuild autotool system
[construo.git] / gui_new_file_button.cxx
blob7c0e7275a7e63a5c2973ec481bf08a01600e3ce0
1 // $Id: gui_new_file_button.cxx,v 1.2 2003/07/25 11:07:44 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
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.
20 #include <time.h>
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)
31 void
32 GUINewFileButton::draw(GraphicContext* parent_gc)
34 parent_gc->draw_fill_rect (x_pos, y_pos,
35 x_pos + width, y_pos + height,
36 Color (0x999900FF));
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);
41 if (mouse_over)
42 parent_gc->draw_rect (x_pos, y_pos,
43 x_pos + width, y_pos + height,
44 Color (0xFFFFFFFF));
45 else
46 parent_gc->draw_rect (x_pos, y_pos,
47 x_pos + width, y_pos + height,
48 Color (0xFF0000FF));
51 std::string
52 GUINewFileButton::generate_filename()
54 char buffer[32];
55 time_t curtime;
56 struct tm *loctime;
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";
64 void
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);
73 /* EOF */