Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a public API for the map editor (MPE)
  • Loading branch information
skyjake committed Jan 2, 2013
1 parent 00eac25 commit 9ea9bff
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 22 deletions.
7 changes: 4 additions & 3 deletions doomsday/engine/api/api_base.h
Expand Up @@ -30,9 +30,10 @@ enum {
DE_API_DEFINITIONS_v1 = 200, // 1.10
DE_API_DIRECT_DATA_ACCESS_v1 = 300, // 1.10
DE_API_FILE_SYSTEM_v1 = 400, // 1.10
DE_API_PLUGIN_v1 = 500, // 1.10
DE_API_URI_v1 = 600, // 1.10
DE_API_WAD_v1 = 700 // 1.10
DE_API_MAP_EDIT_v1 = 500, // 1.10
DE_API_PLUGIN_v1 = 600, // 1.10
DE_API_URI_v1 = 700, // 1.10
DE_API_WAD_v1 = 800 // 1.10
};

/**
Expand Down
49 changes: 49 additions & 0 deletions doomsday/engine/api/api_mpe.h
@@ -0,0 +1,49 @@
#ifndef DOOMSDAY_API_MAP_EDIT_H
#define DOOMSDAY_API_MAP_EDIT_H

#include <de/str.h>
#include <de/types.h>
#include "api_base.h"

/// @defgroup mapEdit Map Editor
/// @ingroup map
///@{

DENG_API_TYPEDEF(MPE)
{
de_api_t api;

boolean (*Begin)(const char* mapUri);
boolean (*End)(void);

uint (*VertexCreate)(coord_t x, coord_t y);
boolean (*VertexCreatev)(size_t num, coord_t* values, uint* indices);
uint (*SidedefCreate)(short flags, const ddstring_t* topMaterial, float topOffsetX, float topOffsetY, float topRed, float topGreen, float topBlue, const ddstring_t* middleMaterial, float middleOffsetX, float middleOffsetY, float middleRed, float middleGreen, float middleBlue, float middleAlpha, const ddstring_t* bottomMaterial, float bottomOffsetX, float bottomOffsetY, float bottomRed, float bottomGreen, float bottomBlue);
uint (*LinedefCreate)(uint v1, uint v2, uint frontSector, uint backSector, uint frontSide, uint backSide, int flags);
uint (*SectorCreate)(float lightlevel, float red, float green, float blue);
uint (*PlaneCreate)(uint sector, coord_t height, const ddstring_t* materialUri, float matOffsetX, float matOffsetY, float r, float g, float b, float a, float normalX, float normalY, float normalZ);
uint (*PolyobjCreate)(uint* lines, uint linecount, int tag, int sequenceType, coord_t originX, coord_t originY);
boolean (*GameObjProperty)(const char* objName, uint idx, const char* propName, valuetype_t type, void* data);
}
DENG_API_T(MPE);

#ifndef DENG_NO_API_MACROS_MAP_EDIT
#define MPE_Begin _api_MPE.Begin
#define MPE_End _api_MPE.End
#define MPE_VertexCreate _api_MPE.VertexCreate
#define MPE_VertexCreatev _api_MPE.VertexCreatev
#define MPE_SidedefCreate _api_MPE.SidedefCreate
#define MPE_LinedefCreate _api_MPE.LinedefCreate
#define MPE_SectorCreate _api_MPE.SectorCreate
#define MPE_PlaneCreate _api_MPE.PlaneCreate
#define MPE_PolyobjCreate _api_MPE.PolyobjCreate
#define MPE_GameObjProperty _api_MPE.GameObjProperty
#endif

#ifdef __DOOMSDAY__
DENG_USING_API(MPE);
#endif

///@}

#endif // DOOMSDAY_API_MAP_EDIT_H
17 changes: 1 addition & 16 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -88,6 +88,7 @@ struct font_s;
#include "api_def.h"
#include "api_filesys.h"
#include "api_console.h"
#include "api_mpe.h"

#include "filehandle.h"
#include <de/memoryzone.h>
Expand Down Expand Up @@ -284,22 +285,6 @@ int DD_Executef(int silent, char const* command, ...);
//
//------------------------------------------------------------------------

/// @defgroup mapEdit Map Editor
/// @ingroup map
///@{
boolean MPE_Begin(const char* mapUri);
boolean MPE_End(void);

uint MPE_VertexCreate(coord_t x, coord_t y);
boolean MPE_VertexCreatev(size_t num, coord_t* values, uint* indices);
uint MPE_SidedefCreate(short flags, const ddstring_t* topMaterial, float topOffsetX, float topOffsetY, float topRed, float topGreen, float topBlue, const ddstring_t* middleMaterial, float middleOffsetX, float middleOffsetY, float middleRed, float middleGreen, float middleBlue, float middleAlpha, const ddstring_t* bottomMaterial, float bottomOffsetX, float bottomOffsetY, float bottomRed, float bottomGreen, float bottomBlue);
uint MPE_LinedefCreate(uint v1, uint v2, uint frontSector, uint backSector, uint frontSide, uint backSide, int flags);
uint MPE_SectorCreate(float lightlevel, float red, float green, float blue);
uint MPE_PlaneCreate(uint sector, coord_t height, const ddstring_t* materialUri, float matOffsetX, float matOffsetY, float r, float g, float b, float a, float normalX, float normalY, float normalZ);
uint MPE_PolyobjCreate(uint* lines, uint linecount, int tag, int sequenceType, coord_t originX, coord_t originY);
boolean MPE_GameObjProperty(const char* objName, uint idx, const char* propName, valuetype_t type, void* data);
///@}

/// @addtogroup mobj
///@{
// Custom map object data types.
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/engine.pro
Expand Up @@ -80,6 +80,7 @@ DENG_API_HEADERS = \
api/api_console.h \
api/api_def.h \
api/api_filesys.h \
api/api_mpe.h \
api/api_plugin.h \
api/api_uri.h \
api/api_wad.h \
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/include/de_edit.h
Expand Up @@ -34,5 +34,6 @@
#endif

#include "edit_map.h"
#include "api_mpe.h"

#endif
18 changes: 18 additions & 0 deletions doomsday/engine/src/edit_map.cpp
Expand Up @@ -23,6 +23,8 @@
* 02110-1301 USA</small>
*/

#define DENG_NO_API_MACROS_MAP_EDIT

#include <math.h>

#include "de_base.h"
Expand Down Expand Up @@ -2082,3 +2084,19 @@ boolean MPE_GameObjProperty(const char* entityName, uint elementIndex,

return P_SetMapEntityProperty(map->entityDatabase, propertyDef, elementIndex, type, valueAdr);
}

DENG_DECLARE_API(MPE) =
{
{ DE_API_MAP_EDIT_v1 },

MPE_Begin,
MPE_End,
MPE_VertexCreate,
MPE_VertexCreatev,
MPE_SidedefCreate,
MPE_LinedefCreate,
MPE_SectorCreate,
MPE_PlaneCreate,
MPE_PolyobjCreate,
MPE_GameObjProperty
};
5 changes: 5 additions & 0 deletions doomsday/engine/src/library.cpp
Expand Up @@ -29,7 +29,9 @@
#include "m_misc.h"

#include "api_def.h"
#include "api_console.h"
#include "api_filesys.h"
#include "api_mpe.h"

struct library_s { // typedef Library
Str* path; ///< de::FS path of the library (e.g., "/bin/doom.dll").
Expand Down Expand Up @@ -168,8 +170,11 @@ void Library_PublishAPIs(Library *lib)
{
de::Library::deng_API setAPI = library.DENG2_SYMBOL(deng_API);

setAPI(DE_API_BASE_v1, &_api_Base);
setAPI(DE_API_CONSOLE_v1, &_api_Con);
setAPI(DE_API_DEFINITIONS_v1, &_api_Def);
setAPI(DE_API_FILE_SYSTEM_v1, &_api_F);
setAPI(DE_API_MAP_EDIT_v1, &_api_MPE);
setAPI(DE_API_PLUGIN_v1, &_api_Plug);
setAPI(DE_API_URI_v1, &_api_Uri);
setAPI(DE_API_WAD_v1, &_api_W);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/include/version.h
Expand Up @@ -34,7 +34,7 @@
#endif

#include "dengproject.h"
#include "dd_plugin.h"
#include "api_plugin.h"

#ifndef JDOOM64_VER_ID
# ifdef _DEBUG
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/version.h
Expand Up @@ -35,7 +35,7 @@
#endif

#include "dengproject.h"
#include "dd_plugin.h"
#include "api_plugin.h"

#ifndef JHERETIC_VER_ID
# ifdef _DEBUG
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/include/version.h
Expand Up @@ -35,7 +35,7 @@
#endif

#include "dengproject.h"
#include "dd_plugin.h"
#include "api_plugin.h"

#ifndef JHEXEN_VER_ID
# ifdef _DEBUG
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/wadmapconverter/include/wadmapconverter.h
Expand Up @@ -32,6 +32,7 @@
extern Id1Map* DENG_PLUGIN_GLOBAL(map);

DENG_USING_API(Base);
DENG_USING_API(MPE);
DENG_USING_API(Plug);
DENG_USING_API(Uri);
DENG_USING_API(W);
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/wadmapconverter/src/wadmapconverter.cpp
Expand Up @@ -285,12 +285,14 @@ extern "C" const char* deng_LibraryType(void)
}

DENG_DECLARE_API(Base);
DENG_DECLARE_API(MPE);
DENG_DECLARE_API(Plug);
DENG_DECLARE_API(Uri);
DENG_DECLARE_API(W);

DENG_API_EXCHANGE(
DENG_GET_API(DE_API_BASE_v1, Base);
DENG_GET_API(DE_API_MAP_EDIT_v1, MPE);
DENG_GET_API(DE_API_PLUGIN_v1, Plug);
DENG_GET_API(DE_API_URI_v1, Uri);
DENG_GET_API(DE_API_WAD_v1, W);
Expand Down
1 change: 1 addition & 0 deletions doomsday/server/server.pro
Expand Up @@ -74,6 +74,7 @@ DENG_API_HEADERS = \
$$SRC/api/api_console.h \
$$SRC/api/api_def.h \
$$SRC/api/api_filesys.h \
$$SRC/api/api_mpe.h \
$$SRC/api/api_plugin.h \
$$SRC/api/api_uri.h \
$$SRC/api/api_wad.h \
Expand Down

0 comments on commit 9ea9bff

Please sign in to comment.