Documented and exported cMap
This commit is contained in:
parent
a96eea5e66
commit
866fde81ca
@ -1485,6 +1485,55 @@ a_Player:OpenWindow(Window);
|
||||
Inherits = "cWindow",
|
||||
}, -- cLuaWindow
|
||||
|
||||
cMap =
|
||||
{
|
||||
Desc = [[
|
||||
This class encapsulates a single in-game colored map.</p>
|
||||
<p>
|
||||
The contents (i.e. pixel data) of a cMap are dynamically updated by each
|
||||
tracked {{cPlayer}} instance. Furthermore, a cMap maintains and periodically
|
||||
updates a list of map decorators, which are objects drawn on the map that
|
||||
can freely move (e.g. Player and item frame pointers).
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
EraseData = { Params = "", Return = "", Notes = "Erases all pixel data." },
|
||||
GetCenterX = { Params = "", Return = "number", Notes = "Returns the X coord of the map's center." },
|
||||
GetCenterZ = { Params = "", Return = "number", Notes = "Returns the Y coord of the map's center." },
|
||||
GetDimension = { Params = "", Return = "eDimension", Notes = "Returns the dimension of the associated world." },
|
||||
GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the map." },
|
||||
GetID = { Params = "", Return = "number", Notes = "Returns the numerical ID of the map. (The item damage value)" },
|
||||
GetName = { Params = "", Return = "string", Notes = "Returns the name of the map." },
|
||||
GetNumPixels = { Params = "", Return = "number", Notes = "Returns the number of pixels in this map." },
|
||||
GetPixel = { Params = "PixelX, PixelZ", Return = "ColorID", Notes = "Returns the color of the specified pixel." },
|
||||
GetPixelWidth = { Params = "", Return = "number", Notes = "Returns the width of a single pixel in blocks." },
|
||||
GetScale = { Params = "", Return = "number", Notes = "Returns the scale of the map. Range: [0,4]" },
|
||||
GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the map." },
|
||||
GetWorld = { Params = "", Return = "cWorld", Notes = "Returns the associated world." },
|
||||
Resize = { Params = "Width, Height", Return = "", Notes = "Resizes the map. WARNING: This will erase the pixel data." },
|
||||
SetPixel = { Params = "PixelX, PixelZ, ColorID", Return = "bool", Notes = "Sets the color of the specified pixel. Returns false on error (Out of range)." },
|
||||
SetPosition = { Params = "CenterX, CenterZ", Return = "", Notes = "Relocates the map. The pixel data will not be modified." },
|
||||
SetScale = { Params = "number", Return = "", Notes = "Rescales the map. The pixel data will not be modified." },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
E_BASE_COLOR_BLUE = { Notes = "" },
|
||||
E_BASE_COLOR_BROWN = { Notes = "" },
|
||||
E_BASE_COLOR_DARK_BROWN = { Notes = "" },
|
||||
E_BASE_COLOR_DARK_GRAY = { Notes = "" },
|
||||
E_BASE_COLOR_DARK_GREEN = { Notes = "" },
|
||||
E_BASE_COLOR_GRAY_1 = { Notes = "" },
|
||||
E_BASE_COLOR_GRAY_2 = { Notes = "" },
|
||||
E_BASE_COLOR_LIGHT_BROWN = { Notes = "" },
|
||||
E_BASE_COLOR_LIGHT_GRAY = { Notes = "" },
|
||||
E_BASE_COLOR_LIGHT_GREEN = { Notes = "" },
|
||||
E_BASE_COLOR_PALE_BLUE = { Notes = "" },
|
||||
E_BASE_COLOR_RED = { Notes = "" },
|
||||
E_BASE_COLOR_TRANSPARENT = { Notes = "" },
|
||||
E_BASE_COLOR_WHITE = { Notes = "" },
|
||||
},
|
||||
}, -- cMap
|
||||
|
||||
cMonster =
|
||||
{
|
||||
Desc = [[
|
||||
|
@ -73,6 +73,7 @@ $cfile "../CraftingRecipes.h"
|
||||
$cfile "../UI/Window.h"
|
||||
$cfile "../Mobs/Monster.h"
|
||||
$cfile "../CompositeChat.h"
|
||||
$cfile "../Map.h"
|
||||
|
||||
|
||||
|
||||
|
49
src/Map.cpp
49
src/Map.cpp
@ -323,7 +323,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
|
||||
ASSERT(m_World != NULL);
|
||||
m_World->DoWithChunk(ChunkX, ChunkZ, CalculatePixelCb);
|
||||
|
||||
m_Data[a_Z + (a_X * m_Height)] = CalculatePixelCb.GetPixelData();
|
||||
SetPixel(a_X, a_Z, CalculatePixelCb.GetPixelData());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -516,11 +516,6 @@ void cMap::Resize(unsigned int a_Width, unsigned int a_Height)
|
||||
|
||||
void cMap::SetPosition(int a_CenterX, int a_CenterZ)
|
||||
{
|
||||
if ((m_CenterX == a_CenterX) && (m_CenterZ == a_CenterZ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_CenterX = a_CenterX;
|
||||
m_CenterZ = a_CenterZ;
|
||||
}
|
||||
@ -548,6 +543,40 @@ void cMap::SetScale(unsigned int a_Scale)
|
||||
|
||||
|
||||
|
||||
bool cMap::SetPixel(unsigned int a_X, unsigned int a_Z, cMap::ColorID a_Data)
|
||||
{
|
||||
if ((a_X < m_Width) && (a_Z < m_Height))
|
||||
{
|
||||
m_Data[a_Z + (a_X * m_Height)] = a_Data;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cMap::ColorID cMap::GetPixel(unsigned int a_X, unsigned int a_Z)
|
||||
{
|
||||
if ((a_X < m_Width) && (a_Z < m_Height))
|
||||
{
|
||||
return m_Data[a_Z + (a_X * m_Height)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_BASE_COLOR_TRANSPARENT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMap::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendMapInfo(m_ID, m_Scale);
|
||||
@ -575,6 +604,14 @@ unsigned int cMap::GetNumPixels(void) const
|
||||
|
||||
|
||||
|
||||
unsigned int cMap::GetNumDecorators(void) const
|
||||
{
|
||||
return m_Decorators.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int cMap::GetPixelWidth(void) const
|
||||
{
|
||||
return pow(2, m_Scale);
|
||||
|
12
src/Map.h
12
src/Map.h
@ -155,6 +155,10 @@ public:
|
||||
|
||||
void SetScale(unsigned int a_Scale);
|
||||
|
||||
bool SetPixel(unsigned int a_X, unsigned int a_Z, ColorID a_Data);
|
||||
|
||||
ColorID GetPixel(unsigned int a_X, unsigned int a_Z);
|
||||
|
||||
unsigned int GetWidth (void) const { return m_Width; }
|
||||
unsigned int GetHeight(void) const { return m_Height; }
|
||||
|
||||
@ -171,14 +175,16 @@ public:
|
||||
|
||||
eDimension GetDimension(void) const;
|
||||
|
||||
const cColorList & GetData(void) const { return m_Data; }
|
||||
|
||||
unsigned int GetNumPixels(void) const;
|
||||
|
||||
unsigned int GetPixelWidth(void) const;
|
||||
|
||||
// tolua_end
|
||||
|
||||
unsigned int GetNumDecorators(void) const;
|
||||
|
||||
const cColorList & GetData(void) const { return m_Data; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -247,7 +253,7 @@ private:
|
||||
|
||||
friend class cMapSerializer;
|
||||
|
||||
};
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user