1
// $Id: editorobj.hxx,v 1.18 2002/11/28 20:09:54 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
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
#ifndef HEADER_PINGUS_EDITOR_EDITOROBJ_HXX
21
#define HEADER_PINGUS_EDITOR_EDITOROBJ_HXX
23
#include "../pingus.hxx"
34
typedef std::vector<EditorObj*> EditorObjLst;
40
} // namespace EditorNS
42
/** Interface for all objects which can be shown in the editor */
46
static EditorNS::Editor* editor;
49
/** Set the parent editor of all objects */
50
static void set_editor(EditorNS::Editor* e) { editor = e; }
52
static EditorNS::Editor* get_editor () { return editor; }
55
virtual ~EditorObj ();
57
/** Draw the object to the given view */
58
virtual void draw (EditorNS::EditorView * view) =0;
60
/** Called once a game loop, the delta is the time passed since the
61
last update in seconds */
62
virtual void update (float /*delta*/) {};
64
/** Draw a rectangle or shape around the object to the given view */
65
virtual void draw_mark (EditorNS::EditorView * view) =0;
67
/** Return true when the object is under the given coordinates */
68
virtual bool is_over(const Vector&) =0;
70
/** Return true if the object is inside the given rectangle */
71
virtual bool is_in_rect(const CL_Rect& rect) =0;
73
/** Return the z-position of the object, the objects are sorted
75
virtual float get_z_pos() =0;
77
/** Move the object to the given offset */
78
virtual void set_position_offset(const Vector& offset) =0;
80
/** Generic operations that can make an object larger, what exactly
81
happens is object dependend. Default is to do nothing */
82
virtual void make_larger () {}
84
/** Generic operations that can make an object smaller, what exactly
85
happens is object dependend. Default is to do nothing */
86
virtual void make_smaller () {}
88
/** Flip the object vertical */
89
virtual void vertical_flip () {}
91
/** Flip the object horizontal */
92
virtual void horizontal_flip () {}
94
/** Rotate the object 90 degrees */
95
virtual void rotate_90 () {}
97
/** Rotate the object -90 degrees */
98
virtual void rotate_270 () {}
100
/** This function is called once at the start of an interactive move */
101
virtual void drag () {}
103
/** This function is called once at the end of an interactive move */
104
virtual void drop () {}
106
/** Write the given object down into a XML file */
107
virtual void write_xml(std::ostream& xml) =0;
109
/** Return a string that is shown in the status line */
110
virtual std::string status_line();
112
/** Duplicate the given editor object and return a the copied
114
virtual EditorObj* duplicate() =0;
116
/** Return a pointer to a CL_Component which can be used to
117
manipulate the properties of this gameobject. The caller is
118
responsible for deleting the object after usage. The
119
CL_Component* should/must be a CL_Frame so that it can get
120
embedded in the properties window */
121
virtual EditorNS::PropertyFrame* get_gui_dialog (EditorNS::Editor* parent) =0;
124
EditorObj (const EditorObj&) { }
125
EditorObj& operator= (const EditorObj&) { return *this; }