indexing description: "save the state of the current puzzle to an .puz file. later, you can load this file and resume the game" author: "Markus Neidhart and UC Team" date: "$Date$" revision: "$Revision$" class UC_SAVE_PUZZLE inherit SHARED_QUAD_CUTTER create make feature -- creation make (a_filename: STRING; situation: PUZZLE_START_WINDOW) is -- make an .puz file from `a_filename' require a_filename_not_Void_and_not_empty: a_filename /= Void and then not a_filename.is_empty situation_not_Void: situation /= Void do if (a_filename.count < 4) or else not (a_filename.substring (a_filename.count - 3,a_filename.count).is_equal (".puz")) then a_filename.append (".puz") create file.make_open_write (a_filename) -- creates an puz file else create file.make_open_write (a_filename) -- creates an puz file end -- now fill the puz file save_information (a_filename,situation) -- now close the file file.close end feature {NONE} -- Implementation save_information (name: STRING; sit: PUZZLE_START_WINDOW) is -- store the information in the puz file require name_not_Void_and_not_empty: name /= Void and then not name.is_empty sit_not_Void: sit /= Void do file.put_string (sit.image_file_name) -- write the name to the file file.put_new_line file.put_integer (sit.number_of_parts) -- write number of puzzle_parts to the file file.put_new_line -- now all the views of the parts will be saved -- first save the from_space file.put_string (sit.puzzle.save) file.put_new_line -- now save workspace1 file.put_string (sit.workspace1.save) file.put_new_line -- now save workspace2 file.put_string (sit.workspace2.save) file.put_new_line -- now save the to_space file.put_string (sit.to_field.save) file.put_new_line end feature {NONE} -- Access file: PLAIN_TEXT_FILE end -- class UC_SAVE_PUZZLE