Skip to content

Commit

Permalink
Model version modified at 2, migration to implement quality in the mo…
Browse files Browse the repository at this point in the history
…dules
  • Loading branch information
Helfima committed Nov 17, 2024
1 parent 3573077 commit b020580
Show file tree
Hide file tree
Showing 8 changed files with 913 additions and 623 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 2.0.7
Date: 2024-11-14
Date: 2024-11-17
Features:
- Added quality selector for machine and module in recipe edition
Changes:
- Changed default Amount affect one = 1, Beacon by factory = 1/8 and Constant beacon = 0 (new game)
- Model version modified at 2, migration to implement quality in the modules
Bugfixes:
- Fix error on accumulator recipe
---------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion data/Model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
local Model = {
---single-line comment
classname = "HMModel",
version = 1,
version = 2,
beacon_combo = 4,
beacon_factory = 0.5,
beacon_factory_constant = 3
Expand Down
2 changes: 2 additions & 0 deletions edition/RecipeEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ function RecipeEdition:onEvent(event)
if event.action == "factory-quality-select" then
recipe.factory.quality = event.item4
ModelCompute.update(model)
self:updateFactoryInfoTool(event)
self:updateFactoryInfo(event)
Controller:send("on_gui_recipe_update", event)
end
Expand All @@ -539,6 +540,7 @@ function RecipeEdition:onEvent(event)
local beacon = ModelBuilder.getCurrentBeacon(recipe)
beacon.quality = event.item4
ModelCompute.update(model)
self:updateBeaconInfoTool(event)
self:updateBeaconInfo(event)
Controller:send("on_gui_recipe_update", event)
end
Expand Down
23 changes: 21 additions & 2 deletions gui/GuiElement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ end
-------------------------------------------------------------------------------
---Get sprite string
---@param type string
---@param name string
---@param format string?
---@param name? string
---@param format? string
---@return string
function GuiElement.getSprite(type, name, format)
local sprite = ""
Expand Down Expand Up @@ -137,6 +137,25 @@ function GuiElement.getSprite(type, name, format)
return sprite
end

-------------------------------------------------------------------------------
---Get sprite string
---@param type string
---@param name string
---@param quality string?
---@return string
function GuiElement.getSpriteWithQuality(type, name, quality)
local sprite = ""
if type == "resource" then type = "entity" end
if type == "rocket" then type = "item" end
if Player.is_valid_sprite_path(string.format("%s/%s", type, name)) then
if quality == nil then
sprite = string.format("[%s=%s]", type, name)
else
sprite = string.format("[%s=%s,quality=%s]", type, name, quality)
end
end
return sprite
end
-------------------------------------------------------------------------------
---Get options
---@return table
Expand Down
Loading

0 comments on commit b020580

Please sign in to comment.