-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Painting layers in GUI should now show all available layers for each …
…specific map
- Loading branch information
scfmod
committed
Jan 4, 2022
1 parent
98a2c50
commit 4f39d0d
Showing
6 changed files
with
78 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
---@class TerraFarmGroundTypes | ||
---@field items GroundTypeItem[] | ||
TerraFarmGroundTypes = {} | ||
|
||
TerraFarmGroundTypes.items = {} | ||
TerraFarmGroundTypes.TYPES_LIST = {} | ||
|
||
local function isValidGroundTypeName(name) | ||
return name == string.upper(name) | ||
end | ||
|
||
function TerraFarmGroundTypes:init() | ||
for name, layerId in pairs(g_groundTypeManager.terrainLayerMapping) do | ||
if isValidGroundTypeName(name) then | ||
local index = #self.items + 1 | ||
local item = { | ||
index = index, | ||
name = name, | ||
layerId = layerId | ||
} | ||
table.insert(self.items, item) | ||
table.insert(self.TYPES_LIST, name) | ||
end | ||
end | ||
|
||
g_terraFarm:updatePaintLayerData() | ||
end | ||
|
||
function TerraFarmGroundTypes:getIndexByName(name) | ||
for index, item in ipairs(self.items) do | ||
if item.name == name then | ||
return index | ||
end | ||
end | ||
return 1 | ||
end | ||
|
||
function TerraFarmGroundTypes:getNameByIndex(index) | ||
if self.items[index] ~= nil then | ||
return self.items[index].name | ||
end | ||
end | ||
|
||
function TerraFarmGroundTypes:getLayerByName(name) | ||
for _, item in ipairs(self.items) do | ||
if item.name == name then | ||
return item.layerId | ||
end | ||
end | ||
|
||
return 0 | ||
end | ||
|
||
GroundTypeManager.initTerrain = Utils.appendedFunction(GroundTypeManager.initTerrain, | ||
function () | ||
TerraFarmGroundTypes:init() | ||
end | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters