Skip to content

Commit

Permalink
Rename cNone too.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Nov 11, 2023
1 parent a9a7b67 commit 953660f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
26 changes: 13 additions & 13 deletions src/editor/editloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ enum class EditorActionType {
};

enum EditorOverlays {
cNone,
cUnpassable,
cNoBuildingAllowed,
cElevation,
cOpaque
NoOverlays,
Unpassable,
NoBuildingAllowed,
Elevation,
Opaque
};
struct EditorAction {
EditorActionType Type;
Expand Down Expand Up @@ -851,7 +851,7 @@ static void DrawIntoButtonArea()

static void DrawInfoHighlightedOverlay()
{
if (overlaysDropdown->getSelected() == EditorOverlays::cElevation) {
if (overlaysDropdown->getSelected() == EditorOverlays::Elevation) {
CLabel(GetGameFont())
.Draw(overlaysDropdown->getX() + overlaysDropdown->getWidth() + 5,
2,
Expand Down Expand Up @@ -1548,13 +1548,13 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
}
break;
case ']': /// Increace highlighted elevation level
if (overlaysDropdown->getSelected() == EditorOverlays::cElevation
if (overlaysDropdown->getSelected() == EditorOverlays::Elevation
&& Editor.HighlightElevationLevel < 255) {
Editor.HighlightElevationLevel++;
}
break;
case '[': /// Decreace highlighted elevation level
if (overlaysDropdown->getSelected() == EditorOverlays::cElevation
if (overlaysDropdown->getSelected() == EditorOverlays::Elevation
&& Editor.HighlightElevationLevel > 0) {
Editor.HighlightElevationLevel--;
}
Expand Down Expand Up @@ -2153,20 +2153,20 @@ void EditorMainLoop()
auto overlaysDropdownListener = std::make_unique<LambdaActionListener>([&overlaysListStrings](const std::string&) {
const int selected = overlaysDropdown->getSelected();
switch (selected) {
case EditorOverlays::cNone:
case EditorOverlays::NoOverlays:
Editor.OverlayHighlighter = nullptr;
return;
case EditorOverlays::cUnpassable:
case EditorOverlays::Unpassable:
Editor.OverlayHighlighter = OverlayUnpassable;
return;
case EditorOverlays::cNoBuildingAllowed:
case EditorOverlays::NoBuildingAllowed:
Editor.OverlayHighlighter = OverlayNoBuildingAllowed;
return;
case EditorOverlays::cElevation:
case EditorOverlays::Elevation:
Editor.HighlightElevationLevel = 1;
Editor.OverlayHighlighter = OverlayElevation;
return;
case EditorOverlays::cOpaque:
case EditorOverlays::Opaque:
Editor.OverlayHighlighter = OverlayOpaque;
return;
default:
Expand Down
4 changes: 2 additions & 2 deletions src/include/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ class CTilesetGraphicGenerator
return image;
}
private:
enum class SrcImageOption { cNone = 0, cBaseGraphics = 1, cNewGraphics = 2 };
enum class ESrcImageOption { NoGraphics = 0, BaseGraphics = 1, NewGraphics = 2 };

private:
uint16_t checkForLayers(lua_State *luaStack) const;
std::vector<tile_index> parseSrcRange(lua_State *luaStack, SrcImageOption &isImg) const;
std::vector<tile_index> parseSrcRange(lua_State *luaStack, ESrcImageOption &isImg) const;
auto parseLayer(lua_State *luaStack, const bool isSingleLayer = false) const;
std::set<uint32_t> parseArgsAsColors(lua_State *luaStack, const int firstArgPos = 2) const;
uint32_t getPixel(const void *const pixel, const uint8_t bpp) const;
Expand Down
37 changes: 17 additions & 20 deletions src/map/script_tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,28 +769,29 @@ uint16_t CTilesetGraphicGenerator::checkForLayers(lua_State *luaStack) const
** @param isImg if 'img' tag is exist then it will be setted by this function to true, false otherwise
** @return vector of parsed indexes
**/
std::vector<tile_index> CTilesetGraphicGenerator::parseSrcRange(lua_State *luaStack, SrcImageOption &isImg) const
std::vector<tile_index> CTilesetGraphicGenerator::parseSrcRange(lua_State *luaStack, ESrcImageOption &isImg) const
{
isImg = SrcImageOption::cNone;
isImg = ESrcImageOption::NoGraphics;

if (lua_istable(luaStack, -1)) {

lua_rawgeti(luaStack, -1, 1); /// #1<
lua_rawgeti(luaStack, -1, 1); /// #1<
/// check if "img"/"img-base" tag is present
if (lua_isstring_strict(luaStack, -1)) {
const std::string parsingValue { LuaToString(luaStack, -1) };
const auto parsingValue = LuaToString(luaStack, -1);
if (parsingValue == "img") {
isImg = SrcImageOption::cNewGraphics;
isImg = ESrcImageOption::NewGraphics;
} else if (parsingValue == "img-base") {
isImg = SrcImageOption::cBaseGraphics;
isImg = ESrcImageOption::BaseGraphics;
} else {
ErrorPrint("Unknown tag '%s'", parsingValue.data());
}
}
lua_pop(luaStack, 1); /// #1>
lua_pop(luaStack, 1); /// #1>
} else if (!lua_isnumber(luaStack, -1)) {
LuaError(luaStack, "incorrect argument");
}

return { CTilesetParser::parseTilesRange(luaStack, isImg != SrcImageOption::cNone ? 2 : 1) };
return { CTilesetParser::parseTilesRange(luaStack, isImg != ESrcImageOption::NoGraphics ? 2 : 1) };
}

/**
Expand Down Expand Up @@ -822,36 +823,32 @@ auto CTilesetGraphicGenerator::parseLayer(lua_State *luaStack, const bool isSing
}
}

SrcImageOption isImg = SrcImageOption::cNone;
ESrcImageOption isImg = ESrcImageOption::NoGraphics;
std::vector<tile_index> srcIndexes { parseSrcRange(luaStack, isImg) };

if (needToPopSrcBack) {
lua_pop(luaStack, 1); /// #1>
}

const bool isUntouchedSrcGraphicsOnly = (isSingleLayer /* there is an only layer */
&& isImg != SrcImageOption::cNewGraphics /* this leyer consist of indexes of base graphics */
&& !withModifier) /* there are no any modifiers */
? true
: false;
const bool isUntouchedSrcGraphicsOnly =
isSingleLayer && isImg != ESrcImageOption::NewGraphics && !withModifier;

std::vector<graphic_index> parsedIndexes;
sequence_of_images parsedImages;

for (auto const srcIndex : srcIndexes) {
if (isImg == SrcImageOption::cNone
if (isImg == ESrcImageOption::NoGraphics
&& (srcIndex == 0 || SrcTileset->tiles[srcIndex].tile == 0)) { /// empty frame|separator
parsedIndexes.push_back(0);
continue;
}
const graphic_index frameIdx =
isImg != SrcImageOption::cNone ? srcIndex : SrcTileset->tiles[srcIndex].tile;
isImg != ESrcImageOption::NoGraphics ? srcIndex : SrcTileset->tiles[srcIndex].tile;
if (isUntouchedSrcGraphicsOnly) {
parsedIndexes.push_back(frameIdx);

} else {
const CGraphic *srcGraphic = isImg == SrcImageOption::cNewGraphics ? SrcImgGraphic
: SrcTilesetGraphic;
const CGraphic *srcGraphic =
isImg == ESrcImageOption::NewGraphics ? SrcImgGraphic : SrcTilesetGraphic;
auto image { newBlankImage() };
srcGraphic->DrawFrame(frameIdx, 0, 0, image.get());
parsedImages.push_back(std::move(image));
Expand Down

0 comments on commit 953660f

Please sign in to comment.