[*] Applied Dinky's patch to icons.cpp
[-] EOL fix in script_map.cpp
This commit is contained in:
parent
2e0652a04e
commit
e68a4a291a
2 changed files with 72 additions and 67 deletions
|
@ -473,71 +473,71 @@ static int CclSetTileFlags(lua_State *l)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Get the name of the terrain of the tile.
|
||||
**
|
||||
** @param l Lua state.
|
||||
**
|
||||
** @return The name of the terrain of the tile.
|
||||
*/
|
||||
static int CclGetTileTerrainName(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 2);
|
||||
|
||||
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
|
||||
|
||||
const CMapField &mf = *Map.Field(pos);
|
||||
const CTileset &tileset = *Map.Tileset;
|
||||
const int index = tileset.findTileIndexByTile(mf.getGraphicTile());
|
||||
Assert(index != -1);
|
||||
const int baseTerrainIdx = tileset.tiles[index].tileinfo.BaseTerrain;
|
||||
|
||||
lua_pushstring(l, tileset.getTerrainName(baseTerrainIdx).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if the tile's terrain has a particular flag.
|
||||
**
|
||||
** @param l Lua state.
|
||||
**
|
||||
** @return True if has the flag, false if not.
|
||||
*/
|
||||
static int CclGetTileTerrainHasFlag(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 3);
|
||||
|
||||
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
|
||||
|
||||
unsigned short flag = 0;
|
||||
const char *flag_name = LuaToString(l, 3);
|
||||
if (!strcmp(flag_name, "water")) {
|
||||
flag = MapFieldWaterAllowed;
|
||||
} else if (!strcmp(flag_name, "land")) {
|
||||
flag = MapFieldLandAllowed;
|
||||
} else if (!strcmp(flag_name, "coast")) {
|
||||
flag = MapFieldCoastAllowed;
|
||||
} else if (!strcmp(flag_name, "no-building")) {
|
||||
flag = MapFieldNoBuilding;
|
||||
} else if (!strcmp(flag_name, "unpassable")) {
|
||||
flag = MapFieldUnpassable;
|
||||
} else if (!strcmp(flag_name, "wall")) {
|
||||
flag = MapFieldWall;
|
||||
} else if (!strcmp(flag_name, "rock")) {
|
||||
flag = MapFieldRocks;
|
||||
} else if (!strcmp(flag_name, "forest")) {
|
||||
flag = MapFieldForest;
|
||||
}
|
||||
|
||||
const CMapField &mf = *Map.Field(pos);
|
||||
|
||||
if (mf.getFlag() & flag) {
|
||||
lua_pushboolean(l, 1);
|
||||
} else {
|
||||
lua_pushboolean(l, 0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
/**
|
||||
** Get the name of the terrain of the tile.
|
||||
**
|
||||
** @param l Lua state.
|
||||
**
|
||||
** @return The name of the terrain of the tile.
|
||||
*/
|
||||
static int CclGetTileTerrainName(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 2);
|
||||
|
||||
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
|
||||
|
||||
const CMapField &mf = *Map.Field(pos);
|
||||
const CTileset &tileset = *Map.Tileset;
|
||||
const int index = tileset.findTileIndexByTile(mf.getGraphicTile());
|
||||
Assert(index != -1);
|
||||
const int baseTerrainIdx = tileset.tiles[index].tileinfo.BaseTerrain;
|
||||
|
||||
lua_pushstring(l, tileset.getTerrainName(baseTerrainIdx).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if the tile's terrain has a particular flag.
|
||||
**
|
||||
** @param l Lua state.
|
||||
**
|
||||
** @return True if has the flag, false if not.
|
||||
*/
|
||||
static int CclGetTileTerrainHasFlag(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 3);
|
||||
|
||||
const Vec2i pos(LuaToNumber(l, 1), LuaToNumber(l, 2));
|
||||
|
||||
unsigned short flag = 0;
|
||||
const char *flag_name = LuaToString(l, 3);
|
||||
if (!strcmp(flag_name, "water")) {
|
||||
flag = MapFieldWaterAllowed;
|
||||
} else if (!strcmp(flag_name, "land")) {
|
||||
flag = MapFieldLandAllowed;
|
||||
} else if (!strcmp(flag_name, "coast")) {
|
||||
flag = MapFieldCoastAllowed;
|
||||
} else if (!strcmp(flag_name, "no-building")) {
|
||||
flag = MapFieldNoBuilding;
|
||||
} else if (!strcmp(flag_name, "unpassable")) {
|
||||
flag = MapFieldUnpassable;
|
||||
} else if (!strcmp(flag_name, "wall")) {
|
||||
flag = MapFieldWall;
|
||||
} else if (!strcmp(flag_name, "rock")) {
|
||||
flag = MapFieldRocks;
|
||||
} else if (!strcmp(flag_name, "forest")) {
|
||||
flag = MapFieldForest;
|
||||
}
|
||||
|
||||
const CMapField &mf = *Map.Field(pos);
|
||||
|
||||
if (mf.getFlag() & flag) {
|
||||
lua_pushboolean(l, 1);
|
||||
} else {
|
||||
lua_pushboolean(l, 0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -568,7 +568,7 @@ void MapCclRegister()
|
|||
lua_register(Lua, "SetTileFlags", CclSetTileFlags);
|
||||
lua_register(Lua, "BuildTilesetTables", CclBuildTilesetTables);
|
||||
|
||||
lua_register(Lua, "GetTileTerrainName", CclGetTileTerrainName);
|
||||
lua_register(Lua, "GetTileTerrainName", CclGetTileTerrainName);
|
||||
lua_register(Lua, "GetTileTerrainHasFlag", CclGetTileTerrainHasFlag);
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,9 @@ void CIcon::DrawUnitIcon(const ButtonStyle &style, unsigned flags,
|
|||
|
||||
if (flags & IconClicked) { // Shift the icon a bit to make it look like it's been pressed.
|
||||
DrawUIButton(&s, flags, pos.x + 1, pos.y + 1, text, player);
|
||||
|
||||
if (flags & IconSelected) {
|
||||
Video.DrawRectangle(ColorGreen, pos.x + 1, pos.y + 1, 46, 38);
|
||||
}
|
||||
Video.DrawRectangle(ColorGray, pos.x, pos.y, 48, 40);
|
||||
Video.DrawVLine(ColorDarkGray, pos.x - 1, pos.y - 1, 40);
|
||||
Video.DrawHLine(ColorDarkGray, pos.x - 1, pos.y - 1, 49);
|
||||
|
@ -222,6 +224,9 @@ void CIcon::DrawUnitIcon(const ButtonStyle &style, unsigned flags,
|
|||
Video.DrawRectangle(ColorGray, pos.x - 4, pos.y - 4, 54, 46);
|
||||
} else {
|
||||
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
|
||||
if (flags & IconSelected) {
|
||||
Video.DrawRectangle(ColorGreen, pos.x, pos.y, 46, 38);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
|
||||
|
|
Loading…
Reference in a new issue