Cafu Engine
ReplaceMat.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_COMMAND_REPLACE_MAT_HPP_INCLUDED
8 #define CAFU_COMMAND_REPLACE_MAT_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 
12 
13 class EditorMaterialI;
14 class MapBezierPatchT;
15 class MapBrushT;
16 class MapDocumentT;
17 class MapElementT;
18 class CommandSelectT;
19 
20 
22 {
23  public:
24 
26  {
27  ExactMatches=0, ///< Find and replace exact matches only.
28  PartialMatchesFull, ///< Find partial matches and replace the entire string.
29  PartialMatchesSubst ///< Find partial matches and replace the matching portion.
30  };
31 
32  /// Constructor to replace or just mark materials in the current selection of the map document or all map objects.
33  /// @param MapDoc_ The map document in which the replace/mark should be performed.
34  /// @param Selection_ The set of elements to apply the mark or replace to.
35  /// @param Find_ What should be found.
36  /// @param Replace_ What it should be replaced with.
37  /// @param Action_ The replace action to be taken.
38  /// @param MarkOnly_ Whether matches should be replaced or just marked.
39  /// @param SearchSelection Whether we should search the current selection or all objects.
40  /// If this is true, the SearchBrushes, SearchBPatches and SearchHidden parameters have no effect.
41  /// @param SearchBrushes Whether brushes should be included in the search. Only effective if SearchSelection is false.
42  /// @param SearchBPatches Whether bezier patches should be included in the search. Only effective if SearchSelection is false.
43  /// @param SearchHidden Whether also hidden groups should be searched. Only effective if SearchSelection is false.
44  CommandReplaceMatT(MapDocumentT& MapDoc_, const ArrayT<MapElementT*>& Selection_, const wxString& Find_, const wxString& Replace_,
45  ReplaceActionT Action_, bool MarkOnly_, bool SearchSelection, bool SearchBrushes, bool SearchBPatches, bool SearchHidden);
46 
48 
49  /// Returns a string describing the result after the command has been run (that is, Do() has been called).
50  /// Useful for user feedback after the first run.
51  const wxString& GetResultString() const;
52 
53  // Implementation of the CommandT interface.
54  bool Do();
55  void Undo();
56  wxString GetName() const;
57 
58 
59  private:
60 
61  ArrayT<MapBrushT*> m_Brushes;
62  ArrayT<MapBezierPatchT*> m_BezierPatches;
63 
64  ArrayT< ArrayT<EditorMaterialI*> > m_OldBrushMats;
65  ArrayT<EditorMaterialI*> m_OldBezierPatchMats;
66 
67  MapDocumentT& MapDoc;
68  const wxString Find;
69  const wxString Replace;
70  const ReplaceActionT Action;
71  const bool MarkOnly;
72  CommandSelectT* CommandSelect; ///< Subcommand used by this command to change the selection.
73  wxString m_ResultString;
74 };
75 
76 #endif
Find partial matches and replace the entire string.
Definition: ReplaceMat.hpp:28
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
CommandReplaceMatT(MapDocumentT &MapDoc_, const ArrayT< MapElementT * > &Selection_, const wxString &Find_, const wxString &Replace_, ReplaceActionT Action_, bool MarkOnly_, bool SearchSelection, bool SearchBrushes, bool SearchBPatches, bool SearchHidden)
Constructor to replace or just mark materials in the current selection of the map document or all map...
Definition: ReplaceMat.cpp:22
ReplaceActionT
Definition: ReplaceMat.hpp:25
Find and replace exact matches only.
Definition: ReplaceMat.hpp:27
void Undo()
This method un-does the command.
Definition: ReplaceMat.cpp:277
const wxString & GetResultString() const
Returns a string describing the result after the command has been run (that is, Do() has been called)...
Definition: ReplaceMat.cpp:83
Find partial matches and replace the matching portion.
Definition: ReplaceMat.hpp:29
bool Do()
This method executes the command.
Definition: ReplaceMat.cpp:89
Definition: Select.hpp:18
Definition: MapBrush.hpp:15
This class represents a bezier patch.
Definition: MapBezierPatch.hpp:44
Definition: EditorMaterial.hpp:21
Definition: ReplaceMat.hpp:21
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
wxString GetName() const
Returns the name (a description) of the command.
Definition: ReplaceMat.cpp:305
This is the base class for all elements ("objects") that can exist in a map.
Definition: MapElement.hpp:57