File: MapFileManager.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (60 lines) | stat: -rw-r--r-- 1,569 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include <string>
#include "imapformat.h"

namespace map
{

class MapFileSelection
{
public:
	// The full path of the selected file
	std::string fullPath;

	// For save dialogs, a specific map format might have been selected
	std::string mapFormatName;

	// The reference to the named mapformat above. Can be an empty pointer.
	MapFormatPtr mapFormat;
};

/**
 * Service class to handle the directory and filenames used for loading and
 * saving maps. Provides persistence for the maps directory, so that the
 * default save directory is the same as the last load directory, and handles
 * querying the user for a load/save filename using GTK dialogs.
 *
 * The class exists as a singleton, with all public interface exposed via
 * static methods.
 */
class MapFileManager
{
public:
	/**
	 * Query the user for a map file to load or save.
	 *
	 * @param open
	 * Whether this is an open operation or a save operation (changes file
	 * dialog behaviour).
	 *
	 * @param title
	 * The title to display on the dialog, such as "Open map" or "Export
	 * selection".
	 *
	 * @param type: the file type to be loaded ("map", "prefab" or "region")
	 *
	 * @returns
	 * The info structure of the file selection, the member fullPath of which will
	 * be empty string if no selection was made.
	 */
   static MapFileSelection getMapFileSelection(bool open,
										 const std::string& title,
										 const std::string& type,
										 const std::string& defaultFile = "");

   // Register the file types during startup
   static void registerFileTypes();
};

}