00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <time.h>
00021 #include "controller.hxx"
00022 #include "screen_manager.hxx"
00023 #include "gui_new_file_button.hxx"
00024
00025 GUINewFileButton::GUINewFileButton(const std::string& p)
00026 : GUIFileButton (p), pathname (p)
00027 {
00028
00029 }
00030
00031 void
00032 GUINewFileButton::draw(GraphicContext* parent_gc)
00033 {
00034 parent_gc->draw_fill_rect (x_pos, y_pos,
00035 x_pos + width, y_pos + height,
00036 Color (0x999900FF));
00037
00038 parent_gc->draw_string (x_pos + 20, y_pos + 75, "..:: Save to new file ::..");
00039
00040
00041 if (mouse_over)
00042 parent_gc->draw_rect (x_pos, y_pos,
00043 x_pos + width, y_pos + height,
00044 Color (0xFFFFFFFF));
00045 else
00046 parent_gc->draw_rect (x_pos, y_pos,
00047 x_pos + width, y_pos + height,
00048 Color (0xFF0000FF));
00049 }
00050
00051 std::string
00052 GUINewFileButton::generate_filename()
00053 {
00054 char buffer[32];
00055 time_t curtime;
00056 struct tm *loctime;
00057 curtime = time (NULL);
00058 loctime = localtime(&curtime);
00059 strftime(buffer, 32, "%Y%m%d-%H%M%S", loctime);
00060
00061 return pathname + "/" + std::string(buffer) + ".construo";
00062 }
00063
00064 void
00065 GUINewFileButton::on_click()
00066 {
00067 std::string filename = generate_filename();
00068 std::cout << "Saving to: " << filename << std::endl;
00069 Controller::instance()->save_world (filename);
00070 ScreenManager::instance()->set_gui(ScreenManager::WORLD_GUI);
00071 }
00072
00073