Skip to content

Commit

Permalink
Added display options and changed selector panel
Browse files Browse the repository at this point in the history
Added some options for display size
Added filter on selector panel
Changed the layout of the recipe selector panel
  • Loading branch information
Helfima committed Dec 11, 2016
1 parent b85f4e3 commit 93cdd03
Show file tree
Hide file tree
Showing 16 changed files with 712 additions and 151 deletions.
6 changes: 6 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ function proxy_gui_click(event)
helmod:on_gui_click(event)
end

function proxy_gui_text_changed(event)
helmod:on_gui_text_changed(event)
end


script.on_init(proxy_init)
script.on_load(proxy_load)
script.on_configuration_changed(proxy_configuration_changed)
script.on_event(defines.events.on_tick, proxy_tick)
script.on_event(defines.events.on_player_created, proxy_player_created)
script.on_event(defines.events.on_gui_click,proxy_gui_click)
script.on_event(defines.events.on_gui_text_changed,proxy_gui_text_changed)

8 changes: 6 additions & 2 deletions core/elementGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ end
-- @param #string key unique id
-- @param #string text input text
-- @param #string style style of text
-- @param #string tooltip displayed text
--
-- @return #LuaGuiElement the LuaGuiElement added
--
function ElementGui.methods:addGuiText(parent, key, text, style)
Logging:trace("ElementGui:addGuiText", parent, key, text, style)
function ElementGui.methods:addGuiText(parent, key, text, style, tooltip)
Logging:trace("ElementGui:addGuiText", parent, key, text, style, tooltip)
local options = {}
options.type = "textfield"
options.name = key
Expand All @@ -71,6 +72,9 @@ function ElementGui.methods:addGuiText(parent, key, text, style)
if style ~= nil then
options.style = style
end
if tooltip ~= nil then
options.tooltip = tooltip
end
return parent.add(options)
end

Expand Down
50 changes: 36 additions & 14 deletions helmod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@ Logging.console = false
-- @module helmod
--

helmod = {}
helmod = {
name = "helmod",
version = "0.2.17"
}


-------------------------------------------------------------------------------
-- On configuration changed
-- On init
--
-- @function [parent=#helmod] on_init
--
-- @param #table event
--
function helmod:on_init(event)
Logging:trace("helmod:on_init(event)", event)
Logging:debug("helmod_data", global)
self.name = "helmod"
self.version = "0.2.16"

self.playerController = PlayerController:new()
end

Expand Down Expand Up @@ -66,6 +65,7 @@ function helmod:on_configuration_changed(data)
-- Upgrade 0.2.17
if old_version ~= nil and old_version < "0.2.17" then
helmod:upgrade_0_2_17()
Logging:debug("helmod_data after upgrade_0_2_17", global)
end

if global["HMModel"] ~= nil then
Expand All @@ -78,7 +78,7 @@ function helmod:on_configuration_changed(data)
end

-------------------------------------------------------------------------------
-- On configuration changed
-- On load
--
-- @function [parent=#helmod] on_load
--
Expand All @@ -89,7 +89,7 @@ function helmod:on_load(event)
end

-------------------------------------------------------------------------------
-- On configuration changed
-- On tick
--
-- @function [parent=#helmod] on_tick
--
Expand All @@ -104,14 +104,17 @@ function helmod:on_tick(event)
end

-------------------------------------------------------------------------------
-- On configuration changed
-- Init player controller
--
-- @function [parent=#helmod] init_playerController
--
-- @param #LuaPlayer player
--
function helmod:init_playerController(player)
Logging:trace("helmod:init_playerController(player)")
if self.playerController == nil then
self.playerController = PlayerController:new()
end
local globalPlayer = self.playerController:getGlobal(player)
if globalPlayer.isActive == nil or globalPlayer.isActive == false then
if player.valid then
Expand All @@ -123,7 +126,7 @@ function helmod:init_playerController(player)
end

-------------------------------------------------------------------------------
-- On configuration changed
-- On click event
--
-- @function [parent=#helmod] on_gui_click
--
Expand All @@ -139,7 +142,23 @@ function helmod:on_gui_click(event)
end

-------------------------------------------------------------------------------
-- On configuration changed
-- On text changed
--
-- @function [parent=#helmod] on_gui_text_changed
--
-- @param #table event
--
function helmod:on_gui_text_changed(event)
if self.playerController ~= nil then
local player = game.players[event.player_index]
if self.playerController ~= nil then
self.playerController:on_gui_text_changed(event)
end
end
end

-------------------------------------------------------------------------------
-- On player created
--
-- @function [parent=#helmod] on_player_created
--
Expand Down Expand Up @@ -168,22 +187,25 @@ function helmod:upgrade_0_2_17()
data.model.products = nil
data.model.input = nil
data.model.recipes = nil
data.model.currentTab = nil
-- move gui value
data.gui = {}
data.gui.currentTab = "product-line"
if data.model.order ~= nil then
data.gui.order = data.model.order
end
if data.model.currentTab ~= nil then
data.gui.currentTab = data.model.currentTab
data.model.order = nil
end
if data.model.moduleListRefresh ~= nil then
data.gui.moduleListRefresh = data.model.moduleListRefresh
data.model.moduleListRefresh = nil
end
if data.model.module_panel ~= nil then
data.gui.module_panel = data.model.module_panel
data.model.module_panel = nil
end
if data.recipeGroupSelected ~= nil then
data.gui.recipeGroupSelected = data.recipeGroupSelected
data.recipeGroupSelected = nil
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{
"name": "helmod",
"version": "0.2.16",
"version": "0.2.17",
"title": "Helmod: Assistant to plan its base.",
"author": "Helfima",
"contact": "Helfima",
Expand Down
6 changes: 6 additions & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ block=Block
blocks=Blocks
energy=Energy
efficiency=Efficiency
filter=Filter
recipe=Recipe
recipes=Recipes
ingredients=Ingredients
product=Product
products=Products
production=Production
beacon=Beacon
Expand Down Expand Up @@ -81,6 +83,10 @@ model-filter-factory=Filter on factory
model-filter-beacon=Filter on beacon
other-speed-panel=Display game speed panel
real-name=Real name
display-section=Display
display-size=Screen size
display-product-cols=Product column base
display-ingredient-cols=Ingredient column base

[helmod_result-panel]
back-button-production-line=Back Production line
Expand Down
6 changes: 6 additions & 0 deletions locale/fr/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ block=Bloc
blocks=Blocs
energy=Effort
efficiency=Efficacité
filter=Filtre
recipe=Recette
recipes=Recettes
ingredients=Ingrédients
product=Produit
products=Produits
production=Production
beacon=Diffuseur
Expand Down Expand Up @@ -81,6 +83,10 @@ model-filter-factory=Filtre sur les usines
model-filter-beacon=Filtre sur les diffuseurs
other-speed-panel=Affichage panneau de vitesse du jeu
real-name=Nom réel
display-section=Affichage
display-size=Taille écran
display-product-cols=Base colonnes produit
display-ingredient-cols=Base colonnes ingredient

[helmod_result-panel]
back-button-production-line=Retour ligne de production
Expand Down
6 changes: 6 additions & 0 deletions locale/ru/local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ block=Блок
blocks=Блоки
energy=Энергия
efficiency=Эффективность
filter=Filter
recipe=Рецепт
recipes=Рецепты
ingredients=Ингредиенты
product=Продукт
products=Продукты
production=Производство
beacon=Маяк
Expand Down Expand Up @@ -81,6 +83,10 @@ model-filter-factory=Фильтровать по фабрике
model-filter-beacon=Фильтровать по маяку
other-speed-panel=Показывать кнопки скорости
real-name=Настоящее имя
display-section=Display
display-size=Screen size
display-product-cols=Product column base
display-ingredient-cols=Ingredient column base

[helmod_result-panel]
back-button-production-line=Назад к произв.линии
Expand Down
42 changes: 39 additions & 3 deletions planner/plannerController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function PlannerController.methods:init(parent)
self.controllers = {}
self.modelFilename = "helmod-planner-model.data"
self.model = PlannerModel:new(self)

self.locate = "center"
end

Expand Down Expand Up @@ -94,6 +94,22 @@ function PlannerController.methods:on_gui_click(event)
end
end


-------------------------------------------------------------------------------
-- On text changed event
--
-- @function [parent=#PlannerController] on_gui_text_changed
--
-- @param event
--
function PlannerController.methods:on_gui_text_changed(event)
if self.controllers ~= nil then
for r, controller in pairs(self.controllers) do
controller:on_gui_click(event)
end
end
end

-------------------------------------------------------------------------------
-- Send event dialog
--
Expand Down Expand Up @@ -173,11 +189,14 @@ end
-- @param #LuaPlayer player
--
function PlannerController.methods:getMainPanel(player)
local displaySize = self.parent:getGlobalSettings(player, "display_size")
Logging:debug("PlannerController:getMainPanel():",displaySize)
local guiMain = player.gui[self.locate]
if guiMain["helmod_planner_main"] ~= nil and guiMain["helmod_planner_main"].valid then
return guiMain["helmod_planner_main"]
end
return self:addGuiFlowH(guiMain, "helmod_planner_main", "helmod_flow_main")
return self:addGuiFlowH(guiMain, "helmod_planner_main", "helmod_flow_main_"..displaySize)
--return self:addGuiFrameH(guiMain, "helmod_planner_main", "helmod_frame_main_"..displaySize)
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -233,11 +252,12 @@ end
-- @param #LuaPlayer player
--
function PlannerController.methods:getDataPanel(player)
local displaySize = self.parent:getGlobalSettings(player, "display_size")
local infoPanel = self:getInfoPanel(player)
if infoPanel["helmod_planner_data"] ~= nil and infoPanel["helmod_planner_data"].valid then
return infoPanel["helmod_planner_data"]
end
return self:addGuiFlowV(infoPanel, "helmod_planner_data", "helmod_flow_data")
return self:addGuiFlowV(infoPanel, "helmod_planner_data", "helmod_flow_data_"..displaySize)
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -265,3 +285,19 @@ function PlannerController.methods:refreshDisplayData(player, item, item2, item3
end
end
end

-------------------------------------------------------------------------------
-- Refresh display
--
-- @function [parent=#PlannerController] refreshDisplay
--
-- @param #LuaPlayer player
-- @param #string item first item name
-- @param #string item2 second item name
-- @param #string item3 third item name
--
function PlannerController.methods:refreshDisplay(player, item, item2, item3)
Logging:debug("PlannerController:refreshDisplayData():",player, item, item2, item3)
self:main(player)
self:main(player)
end
1 change: 0 additions & 1 deletion planner/plannerDialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ end
-- @function [parent=#PlannerDialog] on_gui_click
--
-- @param #table event
-- @param #string label displayed text
--
function PlannerDialog.methods:on_gui_click(event)
if event.element.valid and string.find(event.element.name, self:classname()) then
Expand Down
9 changes: 6 additions & 3 deletions planner/plannerModel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function PlannerModel.methods:getModel(player)

if model.resources == nil then model.resources = {} end

if model.time == nil then model.time = 60 end
if model.time == nil then model.time = 1 end

return model
end
Expand Down Expand Up @@ -419,9 +419,11 @@ end
-- @param #string blockId production block id
-- @param #string key recipe name
--
function PlannerModel.methods:addRecipeIntoProductionBlock(player, blockId, key)
Logging:debug("PlannerModel:addRecipeIntoProductionBlock():",player, blockId, key)
function PlannerModel.methods:addRecipeIntoProductionBlock(player, key)
Logging:debug("PlannerModel:addRecipeIntoProductionBlock():",player, key)
local model = self:getModel(player)
local globalGui = self.player:getGlobalGui(player)
local blockId = globalGui.currentBlock
local recipe = self.player:getRecipe(player, key);

if model.blocks[blockId] == nil then
Expand All @@ -430,6 +432,7 @@ function PlannerModel.methods:addRecipeIntoProductionBlock(player, blockId, key)
modelBlock.index = index
model.blocks[modelBlock.id] = modelBlock
blockId = modelBlock.id
globalGui.currentBlock = blockId
end

if model.blocks[blockId].recipes[key] == nil then
Expand Down
Loading

0 comments on commit 93cdd03

Please sign in to comment.