From 93cdd03eb8e845148b5f7928fabc820922f0d3dd Mon Sep 17 00:00:00 2001 From: Helfima Date: Sun, 11 Dec 2016 04:09:47 +0100 Subject: [PATCH] Added display options and changed selector panel Added some options for display size Added filter on selector panel Changed the layout of the recipe selector panel --- control.lua | 6 + core/elementGui.lua | 8 +- helmod.lua | 50 +++-- info.json | 2 +- locale/en/locale.cfg | 6 + locale/fr/locale.cfg | 6 + locale/ru/local.cfg | 6 + planner/plannerController.lua | 42 ++++- planner/plannerDialog.lua | 1 - planner/plannerModel.lua | 9 +- planner/plannerRecipeSelector.lua | 147 ++++++++++++--- planner/plannerResult.lua | 67 +++---- planner/plannerSettings.lua | 155 +++++++++++++--- player/playerController.lua | 62 ++++++- prototypes/style.lua | 292 ++++++++++++++++++++++++++---- speed/speedController.lua | 4 + 16 files changed, 712 insertions(+), 151 deletions(-) diff --git a/control.lua b/control.lua index 3ed79403..406a72cd 100644 --- a/control.lua +++ b/control.lua @@ -28,6 +28,10 @@ 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) @@ -35,3 +39,5 @@ 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) + diff --git a/core/elementGui.lua b/core/elementGui.lua index 0fc8a5ac..ab56e3fd 100644 --- a/core/elementGui.lua +++ b/core/elementGui.lua @@ -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 @@ -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 diff --git a/helmod.lua b/helmod.lua index a157448f..e196a8a2 100644 --- a/helmod.lua +++ b/helmod.lua @@ -21,11 +21,14 @@ Logging.console = false -- @module helmod -- -helmod = {} +helmod = { + name = "helmod", + version = "0.2.17" + } ------------------------------------------------------------------------------- --- On configuration changed +-- On init -- -- @function [parent=#helmod] on_init -- @@ -33,10 +36,6 @@ helmod = {} -- 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 @@ -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 @@ -78,7 +78,7 @@ function helmod:on_configuration_changed(data) end ------------------------------------------------------------------------------- --- On configuration changed +-- On load -- -- @function [parent=#helmod] on_load -- @@ -89,7 +89,7 @@ function helmod:on_load(event) end ------------------------------------------------------------------------------- --- On configuration changed +-- On tick -- -- @function [parent=#helmod] on_tick -- @@ -104,7 +104,7 @@ function helmod:on_tick(event) end ------------------------------------------------------------------------------- --- On configuration changed +-- Init player controller -- -- @function [parent=#helmod] init_playerController -- @@ -112,6 +112,9 @@ end -- 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 @@ -123,7 +126,7 @@ function helmod:init_playerController(player) end ------------------------------------------------------------------------------- --- On configuration changed +-- On click event -- -- @function [parent=#helmod] on_gui_click -- @@ -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 -- @@ -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 diff --git a/info.json b/info.json index e0ffee58..52fb6cd9 100644 --- a/info.json +++ b/info.json @@ -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", diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index a485eeec..a9b61ce2 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -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 @@ -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 diff --git a/locale/fr/locale.cfg b/locale/fr/locale.cfg index f1f4d156..4632c7f5 100644 --- a/locale/fr/locale.cfg +++ b/locale/fr/locale.cfg @@ -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 @@ -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 diff --git a/locale/ru/local.cfg b/locale/ru/local.cfg index 263d6b2b..38e5995b 100644 --- a/locale/ru/local.cfg +++ b/locale/ru/local.cfg @@ -8,9 +8,11 @@ block=Блок blocks=Блоки energy=Энергия efficiency=Эффективность +filter=Filter recipe=Рецепт recipes=Рецепты ingredients=Ингредиенты +product=Продукт products=Продукты production=Производство beacon=Маяк @@ -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=Назад к произв.линии diff --git a/planner/plannerController.lua b/planner/plannerController.lua index e706488f..ac60749c 100644 --- a/planner/plannerController.lua +++ b/planner/plannerController.lua @@ -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 @@ -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 -- @@ -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 ------------------------------------------------------------------------------- @@ -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 ------------------------------------------------------------------------------- @@ -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 diff --git a/planner/plannerDialog.lua b/planner/plannerDialog.lua index fc6ee367..fd037f97 100644 --- a/planner/plannerDialog.lua +++ b/planner/plannerDialog.lua @@ -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 diff --git a/planner/plannerModel.lua b/planner/plannerModel.lua index 826922b6..adec3e28 100644 --- a/planner/plannerModel.lua +++ b/planner/plannerModel.lua @@ -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 @@ -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 @@ -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 diff --git a/planner/plannerRecipeSelector.lua b/planner/plannerRecipeSelector.lua index 071a197c..b79f7cf3 100644 --- a/planner/plannerRecipeSelector.lua +++ b/planner/plannerRecipeSelector.lua @@ -7,6 +7,7 @@ PlannerRecipeSelector = setclass("HMPlannerRecipeSelector", PlannerDialog) +local recipeGroups = {} ------------------------------------------------------------------------------- -- On initialization -- @@ -32,6 +33,38 @@ function PlannerRecipeSelector.methods:getParentPanel(player) return self.parent:getDialogPanel(player) end +------------------------------------------------------------------------------- +-- Get or create filter panel +-- +-- @function [parent=#PlannerRecipeSelector] getFilterPanel +-- +-- @param #LuaPlayer player +-- +function PlannerRecipeSelector.methods:getFilterPanel(player) + local panel = self:getPanel(player) + if panel["filter-panel"] ~= nil and panel["filter-panel"].valid then + return panel["filter-panel"] + end + return self:addGuiFrameH(panel, "filter-panel", "helmod_frame_resize_row_width", ({"helmod_common.filter"})) +end + +------------------------------------------------------------------------------- +-- Get or create scroll panel +-- +-- @function [parent=#PlannerRecipeSelector] getSrollPanel +-- +-- @param #LuaPlayer player +-- +function PlannerRecipeSelector.methods:getSrollPanel(player) + local displaySize = self.player:getGlobalSettings(player, "display_size") + local panel = self:getPanel(player) + if panel["main-panel"] ~= nil and panel["main-panel"].valid then + return panel["main-panel"]["scroll-panel"] + end + local mainPanel = self:addGuiFrameV(panel, "main-panel", "helmod_frame_resize_row_width") + return self:addGuiScrollPane(mainPanel, "scroll-panel", "helmod_scroll_recipe_selector_"..displaySize, "auto", "auto") +end + ------------------------------------------------------------------------------- -- Get or create groups panel -- @@ -40,12 +73,11 @@ end -- @param #LuaPlayer player -- function PlannerRecipeSelector.methods:getGroupsPanel(player) - local panel = self:getPanel(player) + local panel = self:getSrollPanel(player) if panel["groups-panel"] ~= nil and panel["groups-panel"].valid then - return panel["groups-panel"]["scroll-groups"] + return panel["groups-panel"] end - local groupsPanel = self:addGuiFrameV(panel, "groups-panel", "helmod_frame_resize_row_width") - return self:addGuiScrollPane(groupsPanel, "scroll-groups", "helmod_scroll_recipe_selector_group", "auto", "auto") + return self:addGuiFlowV(panel, "groups-panel", "helmod_flow_resize_row_width") end ------------------------------------------------------------------------------- @@ -56,12 +88,11 @@ end -- @param #LuaPlayer player -- function PlannerRecipeSelector.methods:getItemListPanel(player) - local panel = self:getPanel(player) + local panel = self:getSrollPanel(player) if panel["item-list-panel"] ~= nil and panel["item-list-panel"].valid then - return panel["item-list-panel"]["scroll-list"] + return panel["item-list-panel"] end - local listPanel = self:addGuiFrameV(panel, "item-list-panel", "helmod_frame_resize_row_width") - return self:addGuiScrollPane(listPanel, "scroll-list", "helmod_scroll_recipe_selector_list", "auto", "auto") + return self:addGuiFlowV(panel, "item-list-panel", "helmod_flow_resize_row_width") end ------------------------------------------------------------------------------- @@ -79,6 +110,13 @@ end -- @return #boolean if true the next call close dialog -- function PlannerRecipeSelector.methods:on_open(player, element, action, item, item2, item3) + Logging:debug("PlannerRecipeSelector:on_open():",player, element, action, item, item2, item3) + local globalPlayer = self.player:getGlobal(player) + if item3 ~= nil then + globalPlayer.recipeFilterProduct = item3:lower():gsub("[-]"," ") + else + globalPlayer.recipeFilterProduct = nil + end -- close si nouvel appel return true end @@ -117,21 +155,22 @@ function PlannerRecipeSelector.methods:on_event(player, element, action, item, i Logging:debug("PlannerRecipeSelector:on_event():",player, element, action, item, item2, item3) local globalPlayer = self.player:getGlobal(player) if action == "recipe-group" then - globalPlayer.recipeGroupSelected = item2 + globalPlayer.recipeGroupSelected = item self:on_update(player, element, action, item, item2, item3) end if action == "recipe-select" then - local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, item, item2) + local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, item) self.parent.model:update(player) - local globalGui = self.player:getGlobalGui(player) - globalGui.currentBlock = productionBlock.id - self.parent:refreshDisplayData(player) - --self.parent:send_event(player, "HMPlannerRecipeUpdate", "OPEN", item, nil) self:close(player) end + if action == "recipe-filter" then + globalPlayer.recipeFilterProduct = element.text + self:on_update(player, element, action, item, item2, item3) + end + end ------------------------------------------------------------------------------- @@ -148,10 +187,64 @@ end -- function PlannerRecipeSelector.methods:on_update(player, element, action, item, item2, item3) Logging:trace("PlannerRecipeSelector:on_update():",player, element, action, item, item2, item3) + local globalPlayer = self.player:getGlobal(player) + -- recuperation recipes + recipeGroups = {} + local firstGroup = nil + for key, recipe in pairs(self.player:getRecipes(player)) do + local find = false + if globalPlayer.recipeFilterProduct ~= nil and globalPlayer.recipeFilterProduct ~= "" then + for key, product in pairs(recipe.products) do + local search = product.name:lower():gsub("[-]"," ") + if string.find(search, globalPlayer.recipeFilterProduct) then + find = true + end + end + else + find = true + end + + if find == true and recipe.enabled == true then + if firstGroup == nil then firstGroup = recipe.group.name end + if recipeGroups[recipe.group.name] == nil then recipeGroups[recipe.group.name] = {} end + if recipeGroups[recipe.group.name][recipe.subgroup.name] == nil then recipeGroups[recipe.group.name][recipe.subgroup.name] = {} end + table.insert(recipeGroups[recipe.group.name][recipe.subgroup.name], recipe) + end + end + + if recipeGroups[globalPlayer.recipeGroupSelected] == nil then + globalPlayer.recipeGroupSelected = firstGroup + end + self:updateFilter(player, element, action, item, item2, item3) self:updateGroupSelector(player, element, action, item, item2, item3) self:updateItemList(player, element, action, item, item2, item3) end +------------------------------------------------------------------------------- +-- Update filter +-- +-- @function [parent=#PlannerRecipeSelector] updateFilter +-- +-- @param #LuaPlayer player +-- @param #LuaGuiElement element button +-- @param #string action action name +-- @param #string item first item name +-- @param #string item2 second item name +-- @param #string item3 third item name +-- +function PlannerRecipeSelector.methods:updateFilter(player, element, action, item, item2, item3) + Logging:trace("PlannerRecipeSelector:updateFilter():",player, element, action, item, item2, item3) + local globalPlayer = self.player:getGlobal(player) + local panel = self:getFilterPanel(player) + local globalSettings = self.player:getGlobal(player, "settings") + + if panel["filter-label"] == nil then + self:addGuiLabel(panel, "filter-label", ({"helmod_common.product"})) + self:addGuiText(panel, self:classname().."=recipe-filter=ID=product", globalPlayer.recipeFilterProduct) + end + +end + ------------------------------------------------------------------------------- -- Update item list -- @@ -170,19 +263,27 @@ function PlannerRecipeSelector.methods:updateItemList(player, element, action, i local panel = self:getItemListPanel(player) local globalSettings = self.player:getGlobal(player, "settings") - if panel["recipe-table"] ~= nil and panel["recipe-table"].valid then - panel["recipe-table"].destroy() + if panel["recipe-list"] ~= nil and panel["recipe-list"].valid then + panel["recipe-list"].destroy() end - local guiRecipeSelectorTable = self:addGuiTable(panel, "recipe-table", 10) - for key, recipe in pairs(self.player:getRecipes(player)) do - if recipe.group.name == globalPlayer.recipeGroupSelected then + -- recuperation recipes et subgroupes + local recipeSubgroups = {} + if recipeGroups[globalPlayer.recipeGroupSelected] ~= nil then + recipeSubgroups = recipeGroups[globalPlayer.recipeGroupSelected] + end + --local guiRecipeSelectorTable = self:addGuiTable(panel, "recipe-table", 10) + local guiRecipeSelectorList = self:addGuiFlowV(panel, "recipe-list", "helmod_flow_recipe_selector") + for key, subgroup in pairs(recipeSubgroups) do + -- boucle subgroup + local guiRecipeSubgroup = self:addGuiTable(guiRecipeSelectorList, "recipe-table-"..key, 10, "helmod_table_recipe_selector") + for key, recipe in spairs(subgroup,function(t,a,b) return t[b]["order"] > t[a]["order"] end) do local localised_name = recipe.localised_name if globalSettings.real_name == true then localised_name = recipe.name end Logging:trace("PlannerRecipeSelector:on_update",recipe.name) - self:addSelectSpriteIconButton(guiRecipeSelectorTable, self:classname().."=recipe-select=ID="..item.."=", self.player:getRecipeIconType(player, recipe), recipe.name, recipe.name, nil, localised_name) + self:addSelectSpriteIconButton(guiRecipeSubgroup, self:classname().."=recipe-select=ID=", self.player:getRecipeIconType(player, recipe), recipe.name, recipe.name, nil, localised_name) end end @@ -210,8 +311,8 @@ function PlannerRecipeSelector.methods:updateGroupSelector(player, element, acti end -- ajouter de la table des groupes de recipe - local guiRecipeSelectorGroups = self:addGuiTable(panel, "recipe-groups", 6) - for group, name in pairs(self.player:getRecipeGroups(player)) do + local guiRecipeSelectorGroups = self:addGuiTable(panel, "recipe-groups", 6, "helmod_table_recipe_selector") + for group, element in pairs(recipeGroups) do -- set le groupe if globalPlayer.recipeGroupSelected == nil then globalPlayer.recipeGroupSelected = group end local color = nil @@ -220,7 +321,7 @@ function PlannerRecipeSelector.methods:updateGroupSelector(player, element, acti end local tooltip = group -- ajoute les icons de groupe - local action = self:addXxlSelectSpriteIconButton(guiRecipeSelectorGroups, self:classname().."=recipe-group=ID="..item.."=", "item-group", group, group, color, tooltip) + local action = self:addXxlSelectSpriteIconButton(guiRecipeSelectorGroups, self:classname().."=recipe-group=ID=", "item-group", group, group, color, tooltip) end end diff --git a/planner/plannerResult.lua b/planner/plannerResult.lua index a921f3ad..758dbe1d 100644 --- a/planner/plannerResult.lua +++ b/planner/plannerResult.lua @@ -51,7 +51,7 @@ function PlannerResult.methods:getDataPanel(player) if parentPanel["data"] ~= nil and parentPanel["data"].valid then return parentPanel["data"] end - return self:addGuiFlowV(parentPanel, "data", "helmod_flow_resize_row_width") + return self:addGuiFlowV(parentPanel, "data", "helmod_flow_default") end ------------------------------------------------------------------------------- @@ -62,11 +62,12 @@ end -- @param #LuaPlayer player -- function PlannerResult.methods:getMenuPanel(player, caption) + local displaySize = self.player:getGlobalSettings(player, "display_size") local dataPanel = self:getDataPanel(player) if dataPanel["menu"] ~= nil and dataPanel["menu"].valid then return dataPanel["menu"] end - return self:addGuiFrameH(dataPanel, "menu", "helmod_frame_data", caption) + return self:addGuiFrameH(dataPanel, "menu", "helmod_frame_data_menu_"..displaySize, caption) end ------------------------------------------------------------------------------- @@ -93,11 +94,12 @@ end -- @param #string caption -- function PlannerResult.methods:getResultPanel(player, caption) + local displaySize = self.player:getGlobalSettings(player, "display_size") local dataPanel = self:getDataPanel(player) if dataPanel["result"] ~= nil and dataPanel["result"].valid then return dataPanel["result"] end - return self:addGuiFrameV(dataPanel, "result", "helmod_frame_data", caption) + return self:addGuiFrameV(dataPanel, "result", "helmod_frame_data_"..displaySize, caption) end ------------------------------------------------------------------------------- @@ -215,6 +217,9 @@ function PlannerResult.methods:on_event(player, element, action, item, item2, it if action == "change-tab" then globalGui.currentTab = item + if globalGui.currentTab == self.PRODUCTION_LINE_TAB then + globalGui.currentBlock = "new" + end globalGui.currentBlock = item2 self:update(player, item, item2, item3) self.parent:send_event(player, "HMPlannerRecipeSelector", "CLOSE") @@ -238,15 +243,13 @@ function PlannerResult.methods:on_event(player, element, action, item, item2, it local recipes = self.player:searchRecipe(player, item2) Logging:debug("line recipes:",recipes) if #recipes == 1 then - local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, "new", recipes[1].name) + local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, recipes[1].name) self.parent.model:update(player) globalGui.currentTab = self.PRODUCTION_BLOCK_TAB - globalGui.currentBlock = productionBlock.id - self:update(player, self.PRODUCTION_BLOCK_TAB, productionBlock.id, recipes[1].name) + self:update(player, self.PRODUCTION_BLOCK_TAB) else globalGui.currentTab = self.PRODUCTION_BLOCK_TAB - globalGui.currentBlock = "new" - self.parent:send_event(player, "HMPlannerRecipeSelector", "OPEN", "new") + self.parent:send_event(player, "HMPlannerRecipeSelector", "OPEN", item, item2, item3) end end end @@ -281,11 +284,11 @@ function PlannerResult.methods:on_event(player, element, action, item, item2, it Logging:debug("block recipes:",recipes) if #recipes == 1 then Logging:debug("recipe name:", recipes[1].name) - local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, item, recipes[1].name) + local productionBlock = self.parent.model:addRecipeIntoProductionBlock(player, recipes[1].name) self.parent.model:update(player) - self:update(player, self.PRODUCTION_LINE_TAB, productionBlock.id, recipes[1].name) + self:update(player, self.PRODUCTION_LINE_TAB) else - self.parent:send_event(player, "HMPlannerRecipeSelector", "OPEN", item) + self.parent:send_event(player, "HMPlannerRecipeSelector", "OPEN", item, item2, item3) end end end @@ -363,6 +366,7 @@ end -- function PlannerResult.methods:updateProductionLine(player, item, item2, item3) Logging:debug("PlannerResult:updateLine():", player, item, item2, item3) + local displaySize = self.player:getGlobalSettings(player, "display_size") local model = self.model:getModel(player) local globalGui = self.player:getGlobalGui(player) -- data @@ -375,7 +379,7 @@ function PlannerResult.methods:updateProductionLine(player, item, item2, item3) if countBlock > 0 then local resultPanel = self:getResultPanel(player, ({"helmod_common.blocks"})) -- data panel - local scrollPanel = self:addGuiScrollPane(resultPanel, "scroll-data", "helmod_scroll_block_list", "auto", "auto") + local scrollPanel = self:addGuiScrollPane(resultPanel, "scroll-data", "helmod_scroll_block_list_"..displaySize, "auto", "auto") local globalSettings = self.player:getGlobal(player, "settings") @@ -428,6 +432,7 @@ end -- function PlannerResult.methods:updateProductionBlock(player, item, item2, item3) Logging:debug("PlannerResult:updateProductionBlock():", player, item, item2, item3) + local displaySize = self.player:getGlobalSettings(player, "display_size") local model = self.model:getModel(player) local globalGui = self.player:getGlobalGui(player) Logging:debug("model:", model) @@ -467,7 +472,7 @@ function PlannerResult.methods:updateProductionBlock(player, item, item2, item3) local elementPanel = self:addGuiFlowV(infoPanel, "elements", "helmod_flow_default") -- ouput panel local outputPanel = self:addGuiFrameV(elementPanel, "output", "helmod_frame_resize_row_width", ({"helmod_common.output"})) - local outputScroll = self:addGuiScrollPane(outputPanel, "output-scroll", "helmod_scroll_block_element", "auto", "auto") + local outputScroll = self:addGuiScrollPane(outputPanel, "output-scroll", "helmod_scroll_block_element_"..displaySize, "auto", "auto") local outputTable = self:addGuiTable(outputScroll,"output-table",6) if element.products ~= nil then for r, product in pairs(element.products) do @@ -498,7 +503,7 @@ function PlannerResult.methods:updateProductionBlock(player, item, item2, item3) -- input panel local inputPanel = self:addGuiFrameV(elementPanel, "input", "helmod_frame_resize_row_width", ({"helmod_common.input"})) - local outputScroll = self:addGuiScrollPane(inputPanel, "output-scroll", "helmod_scroll_block_element", "auto", "auto") + local outputScroll = self:addGuiScrollPane(inputPanel, "output-scroll", "helmod_scroll_block_element_"..displaySize, "auto", "auto") local inputTable = self:addGuiTable(outputScroll,"input-table",6) if element.ingredients ~= nil then for r, ingredient in pairs(element.ingredients) do @@ -511,7 +516,7 @@ function PlannerResult.methods:updateProductionBlock(player, item, item2, item3) local resultPanel = self:getResultPanel(player, ({"helmod_common.recipes"})) -- data panel - local scrollPanel = self:addGuiScrollPane(resultPanel, "scroll-data", "helmod_scroll_block_list", "auto", "auto") + local scrollPanel = self:addGuiScrollPane(resultPanel, "scroll-data", "helmod_scroll_block_list_"..displaySize, "auto", "auto") local globalSettings = self.player:getGlobal(player, "settings") @@ -724,16 +729,6 @@ function PlannerResult.methods:addProductionBlockRow(player, guiTable, blockId, local guiIndex = self:addGuiFlowH(guiTable,"index"..recipe.name) self:addGuiLabel(guiIndex, "index", recipe.index, "helmod_label-right-40") end - -- col level - if globalSettings.display_data_col_level then - local guiLevel = self:addGuiFlowH(guiTable,"level"..recipe.name) - self:addGuiLabel(guiLevel, "level", recipe.level) - end - -- col weight - if globalSettings.display_data_col_weight then - local guiLevel = self:addGuiFlowH(guiTable,"weight"..recipe.name) - self:addGuiLabel(guiLevel, "weight", recipe.weight) - end -- col id if globalSettings.display_data_col_id then local guiId = self:addGuiFlowH(guiTable,"id"..recipe.name) @@ -804,7 +799,8 @@ function PlannerResult.methods:addProductionBlockRow(player, guiTable, blockId, self:addGuiLabel(guiEnergy, recipe.name, self:formatNumberKilo(recipe.energy_total, "W"), "helmod_label-right-70") -- products - local tProducts = self:addGuiTable(guiTable,"products_"..recipe.name, 3) + local display_product_cols = self.player:getGlobalSettings(player, "display_product_cols") + local tProducts = self:addGuiTable(guiTable,"products_"..recipe.name, display_product_cols) if recipe.products ~= nil then for r, product in pairs(recipe.products) do local cell = self:addGuiFlowH(tProducts,"cell_"..product.name, "helmod_flow_default") @@ -814,7 +810,8 @@ function PlannerResult.methods:addProductionBlockRow(player, guiTable, blockId, end end -- ingredients - local tIngredient = self:addGuiTable(guiTable,"ingredients_"..recipe.name, 3) + local display_ingredient_cols = self.player:getGlobalSettings(player, "display_ingredient_cols") + local tIngredient = self:addGuiTable(guiTable,"ingredients_"..recipe.name, display_ingredient_cols) if recipe.ingredients ~= nil then for r, ingredient in pairs(recipe.ingredients) do local cell = self:addGuiFlowH(tIngredient,"cell_"..ingredient.name, "helmod_flow_default") @@ -850,16 +847,6 @@ function PlannerResult.methods:addProductionLineRow(player, guiTable, element) local guiIndex = self:addGuiFlowH(guiTable,"index"..element.id) self:addGuiLabel(guiIndex, "index", element.index, "helmod_label-right-40") end - -- col level - if globalSettings.display_data_col_level then - local guiLevel = self:addGuiFlowH(guiTable,"level"..element.id) - self:addGuiLabel(guiLevel, "level", element.level) - end - -- col weight - if globalSettings.display_data_col_weight then - local guiLevel = self:addGuiFlowH(guiTable,"weight"..element.id) - self:addGuiLabel(guiLevel, "weight", element.weight) - end -- col id if globalSettings.display_data_col_id then local guiId = self:addGuiFlowH(guiTable,"id"..element.id) @@ -879,7 +866,8 @@ function PlannerResult.methods:addProductionLineRow(player, guiTable, element) self:addGuiLabel(guiEnergy, element.id, self:formatNumberKilo(element.power, "W"), "helmod_label-right-70") -- products - local tProducts = self:addGuiTable(guiTable,"products_"..element.id, 4) + local display_product_cols = self.player:getGlobalSettings(player, "display_product_cols") + 1 + local tProducts = self:addGuiTable(guiTable,"products_"..element.id, display_product_cols) if element.products ~= nil then for r, product in pairs(element.products) do if bit32.band(product.state, 1) > 0 then @@ -907,7 +895,8 @@ function PlannerResult.methods:addProductionLineRow(player, guiTable, element) end end -- ingredients - local tIngredient = self:addGuiTable(guiTable,"ingredients_"..element.id, 5) + local display_ingredient_cols = self.player:getGlobalSettings(player, "display_ingredient_cols") + 2 + local tIngredient = self:addGuiTable(guiTable,"ingredients_"..element.id, display_ingredient_cols) if element.ingredients ~= nil then for r, ingredient in pairs(element.ingredients) do -- ingredient = {type="item", name="steel-plate", amount=8} diff --git a/planner/plannerSettings.lua b/planner/plannerSettings.lua index 230c600b..c54e1c53 100644 --- a/planner/plannerSettings.lua +++ b/planner/plannerSettings.lua @@ -97,6 +97,21 @@ function PlannerSettings.methods:getAboutSettingsPanel(player) return self:addGuiFrameV(panel, "about-settings", "helmod_frame_resize_row_width", ({"helmod_settings-panel.about-section"})) end +------------------------------------------------------------------------------- +-- Get or create display settings panel +-- +-- @function [parent=#PlannerSettings] getDisplaySettingsPanel +-- +-- @param #LuaPlayer player +-- +function PlannerSettings.methods:getDisplaySettingsPanel(player) + local panel = self:getPanel(player) + if panel["display-settings"] ~= nil and panel["display-settings"].valid then + return panel["display-settings"] + end + return self:addGuiFrameV(panel, "display-settings", "helmod_frame_resize_row_width", ({"helmod_settings-panel.display-section"})) +end + ------------------------------------------------------------------------------- -- Get or create data settings panel -- @@ -105,11 +120,11 @@ end -- @param #LuaPlayer player -- function PlannerSettings.methods:getDataSettingsPanel(player) - local panel = self:getPanel(player) - if panel["data-settings"] ~= nil and panel["data-settings"].valid then - return panel["data-settings"] - end - return self:addGuiFrameV(panel, "data-settings", "helmod_frame_resize_row_width", ({"helmod_settings-panel.data-section"})) + local panel = self:getPanel(player) + if panel["data-settings"] ~= nil and panel["data-settings"].valid then + return panel["data-settings"] + end + return self:addGuiFrameV(panel, "data-settings", "helmod_frame_resize_row_width", ({"helmod_settings-panel.data-section"})) end ------------------------------------------------------------------------------- @@ -196,11 +211,25 @@ function PlannerSettings.methods:on_event(player, element, action, item, item2, self.parent:refreshDisplayData(player, item, item2, item3) end - if action == "change-number-settings" then - local panel = self:getPanel(player)[item]["settings"] - globalSettings[item2] = self:getInputNumber(panel[item2]) - self.parent:refreshDisplayData(player, item, item2, item3) - end + if action == "change-number-settings" then + local panel = self:getPanel(player)[item]["settings"] + globalSettings[item2] = self:getInputNumber(panel[item2]) + self.parent:refreshDisplayData(player, item, item2, item3) + end + + if action == "change-display-settings" then + if globalSettings[item] == nil then globalSettings[item] = defaultSettings[item] end + globalSettings[item] = item2 + self:updateDisplaySettings(player, element, action, item, item2, item3) + self.parent:refreshDisplay(player, item, item2, item3) + end + + if action == "change-column-settings" then + if globalSettings[item] == nil then globalSettings[item] = defaultSettings[item] end + globalSettings[item] = tonumber(item2) + self:updateDisplaySettings(player, element, action, item, item2, item3) + self.parent:refreshDisplayData(player, item, item2, item3) + end end ------------------------------------------------------------------------------- @@ -221,7 +250,8 @@ function PlannerSettings.methods:after_open(player, element, action, item, item2 self.parent:send_event(player, "HMPlannerProductEdition", "CLOSE") self:updateAboutSettings(player, element, action, item, item2, item3) - self:updateDataSettings(player, element, action, item, item2, item3) + self:updateDisplaySettings(player, element, action, item, item2, item3) + self:updateDataSettings(player, element, action, item, item2, item3) self:updateModelSettings(player, element, action, item, item2, item3) self:updateOtherSettings(player, element, action, item, item2, item3) end @@ -288,6 +318,75 @@ function PlannerSettings.methods:updateAboutSettings(player, element, action, it end +------------------------------------------------------------------------------- +-- Update display settings +-- +-- @function [parent=#PlannerSettings] updateDisplaySettings +-- +-- @param #LuaPlayer player +-- @param #LuaGuiElement element button +-- @param #string action action name +-- @param #string item first item name +-- @param #string item2 second item name +-- @param #string item3 third item name +-- +function PlannerSettings.methods:updateDisplaySettings(player, element, action, item, item2, item3) + Logging:debug("PlannerSettings:updateDisplaySettings():",player, element, action, item, item2, item3) + + local globalSettings = self.player:getGlobal(player, "settings") + local defaultSettings = self.player:getDefaultSettings() + + local displaySettingsPanel = self:getDisplaySettingsPanel(player) + + for k,guiName in pairs(displaySettingsPanel.children_names) do + displaySettingsPanel[guiName].destroy() + end + + + local sizeSettingsTable = self:addGuiTable(displaySettingsPanel, "size", 3) + + local display_size = defaultSettings.display_size + if globalSettings.display_size ~= nil then display_size = globalSettings.display_size end + self:addGuiLabel(sizeSettingsTable, self:classname().."=display_size", ({"helmod_settings-panel.display-size"})) + + local display_size = defaultSettings.display_size + if globalSettings.display_size ~= nil then display_size = globalSettings.display_size end + if display_size == "1920x1200" then + self:addGuiLabel(sizeSettingsTable, self:classname().."=change-display-settings=ID=display_size=", "1920x1200", "helmod_label_time") + else + self:addGuiButton(sizeSettingsTable, self:classname().."=change-display-settings=ID=display_size=", "1920x1200", "helmod_button-default", "1920x1200") + end + if display_size == "1680x1050" then + self:addGuiLabel(sizeSettingsTable, self:classname().."=change-display-settings=ID=display_size=", "1680x1050", "helmod_label_time") + else + self:addGuiButton(sizeSettingsTable, self:classname().."=change-display-settings=ID=display_size=", "1680x1050", "helmod_button-default", "1680x1050") + end + + local columnSettingsTable = self:addGuiTable(displaySettingsPanel, "column", 5) + self:addGuiLabel(columnSettingsTable, self:classname().."=display_product_cols", ({"helmod_settings-panel.display-product-cols"})) + local display_product_cols = defaultSettings.display_product_cols + if globalSettings.display_product_cols ~= nil then display_product_cols = globalSettings.display_product_cols end + for i = 2, 5, 1 do + if display_product_cols == i then + self:addGuiLabel(columnSettingsTable, self:classname().."=change-column-settings=ID=display_product_cols=", i, "helmod_label_time") + else + self:addGuiButton(columnSettingsTable, self:classname().."=change-column-settings=ID=display_product_cols=", i, "helmod_button-default", i) + end + end + + self:addGuiLabel(columnSettingsTable, self:classname().."=display_ingredient_cols", ({"helmod_settings-panel.display-ingredient-cols"})) + local display_ingredient_cols = defaultSettings.display_ingredient_cols + if globalSettings.display_ingredient_cols ~= nil then display_ingredient_cols = globalSettings.display_ingredient_cols end + for i = 2, 5, 1 do + if display_ingredient_cols == i then + self:addGuiLabel(columnSettingsTable, self:classname().."=change-column-settings=ID=display_ingredient_cols=", i, "helmod_label_time") + else + self:addGuiButton(columnSettingsTable, self:classname().."=change-column-settings=ID=display_ingredient_cols=", i, "helmod_button-default", i) + end + end + +end + ------------------------------------------------------------------------------- -- Update data settings -- @@ -301,29 +400,29 @@ end -- @param #string item3 third item name -- function PlannerSettings.methods:updateDataSettings(player, element, action, item, item2, item3) - Logging:debug("PlannerSettings:updateDataSettings():",player, element, action, item, item2, item3) + Logging:debug("PlannerSettings:updateDataSettings():",player, element, action, item, item2, item3) - local globalSettings = self.player:getGlobal(player, "settings") - local defaultSettings = self.player:getDefaultSettings() + local globalSettings = self.player:getGlobal(player, "settings") + local defaultSettings = self.player:getDefaultSettings() - local dataSettingsPanel = self:getDataSettingsPanel(player) + local dataSettingsPanel = self:getDataSettingsPanel(player) - local dataSettingsTable = self:addGuiTable(dataSettingsPanel, "settings", 2) + local dataSettingsTable = self:addGuiTable(dataSettingsPanel, "settings", 2) - local display_data_col_name = defaultSettings.display_data_col_name - if globalSettings.display_data_col_name ~= nil then display_data_col_name = globalSettings.display_data_col_name end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_name", ({"helmod_settings-panel.data-col-name"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_name", display_data_col_name) + local display_data_col_name = defaultSettings.display_data_col_name + if globalSettings.display_data_col_name ~= nil then display_data_col_name = globalSettings.display_data_col_name end + self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_name", ({"helmod_settings-panel.data-col-name"})) + self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_name", display_data_col_name) - local display_data_col_id = defaultSettings.display_data_col_id - if globalSettings.display_data_col_id ~= nil then display_data_col_id = globalSettings.display_data_col_id end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_id", ({"helmod_settings-panel.data-col-id"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_id", display_data_col_id) + local display_data_col_id = defaultSettings.display_data_col_id + if globalSettings.display_data_col_id ~= nil then display_data_col_id = globalSettings.display_data_col_id end + self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_id", ({"helmod_settings-panel.data-col-id"})) + self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_id", display_data_col_id) - local display_data_col_index = defaultSettings.display_data_col_index - if globalSettings.display_data_col_index ~= nil then display_data_col_index = globalSettings.display_data_col_index end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_index", ({"helmod_settings-panel.data-col-index"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_index", display_data_col_index) + local display_data_col_index = defaultSettings.display_data_col_index + if globalSettings.display_data_col_index ~= nil then display_data_col_index = globalSettings.display_data_col_index end + self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_index", ({"helmod_settings-panel.data-col-index"})) + self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_index", display_data_col_index) end diff --git a/player/playerController.lua b/player/playerController.lua index e0a186eb..4b51e768 100644 --- a/player/playerController.lua +++ b/player/playerController.lua @@ -82,6 +82,21 @@ function PlayerController.methods:on_gui_click(event) end end +------------------------------------------------------------------------------- +-- On text change event +-- +-- @function [parent=#PlayerController] on_gui_text_changed +-- +-- @param event +-- +function PlayerController.methods:on_gui_text_changed(event) + if self.controllers ~= nil then + for r, controller in pairs(self.controllers) do + controller:on_gui_text_changed(event) + end + end +end + ------------------------------------------------------------------------------- -- Return force's player -- @@ -147,6 +162,9 @@ end -- function PlayerController.methods:getDefaultSettings() return { + display_size = "1680x1050", + display_product_cols = 2, + display_ingredient_cols = 2, display_data_col_name = false, display_data_col_id = false, display_data_col_index = false, @@ -172,6 +190,25 @@ function PlayerController.methods:getGlobalGui(player) return self:getGlobal(player, "gui") end +------------------------------------------------------------------------------- +-- Get global settings +-- +-- @function [parent=#PlayerController] getGlobalSettings +-- +-- @param #LuaPlayer player +-- +function PlayerController.methods:getGlobalSettings(player, property) + local settings = self:getGlobal(player, "settings") + if settings ~= nil and property ~= nil then + local guiProperty = settings[property] + if guiProperty == nil then + guiProperty = self:getDefaultSettings()[property] + end + return guiProperty + end + return settings +end + ------------------------------------------------------------------------------- -- Get sorted style -- @@ -183,7 +220,8 @@ end -- @return #string style -- function PlayerController.methods:getSortedStyle(player, key) - local globalGui = self:getGlobalGui(player, key) + local globalGui = self:getGlobalGui(player) + if globalGui.order == nil then globalGui.order = {name="index",ascendant="true"} end local style = "helmod_button-sorted-none" if globalGui.order.name == key and globalGui.order.ascendant then style = "helmod_button-sorted-up" end if globalGui.order.name == key and not(globalGui.order.ascendant) then style = "helmod_button-sorted-down" end @@ -225,6 +263,27 @@ function PlayerController.methods:getRecipeGroups(player) return recipeGroups end +------------------------------------------------------------------------------- +-- Return recipe subgroups +-- +-- @function [parent=#PlayerController] getRecipeSubgroups +-- +-- @param #LuaPlayer player +-- +-- @return #table recipe subgroups +-- +function PlayerController.methods:getRecipeSubgroups(player) + -- recuperation des groupes avec les recipes + local recipeSubgroups = {} + for key, recipe in pairs(self:getRecipes(player)) do + if recipe.subgroup ~= nil then + if recipeSubgroups[recipe.subgroup.name] == nil then recipeSubgroups[recipe.subgroup.name] = {} end + table.insert(recipeSubgroups[recipe.subgroup.name], recipe.name) + end + end + return recipeSubgroups +end + ------------------------------------------------------------------------------- -- Return list of productions -- @@ -521,3 +580,4 @@ function PlayerController.methods:getRecipeLocalisedName(player, recipe) return recipe.name end + diff --git a/prototypes/style.lua b/prototypes/style.lua index af799d8b..1388eb19 100644 --- a/prototypes/style.lua +++ b/prototypes/style.lua @@ -428,6 +428,21 @@ default_gui["helmod_table_recipe_modules"] = { minimal_height = 36 } +------------------------------------------------------------------------------- +-- Style of recipe selector +-- +-- @field [parent=#Table] recipe_selector + +default_gui["helmod_table_recipe_selector"] = { + type = "table_style", + horizontal_spacing = 2, + vertical_spacing = 2, + top_padding = 1, + right_padding = 0, + bottom_padding = 1, + left_padding = 0 +} + ------------------------------------------------------------------------------- -- Style label -- @@ -492,6 +507,18 @@ default_gui["helmod_label_time"] = { -- |--------------------------------------------------| -- +local width_info=492 +local width_scroll=8 +local width_block_info=290 +local height_block_header = 400 +local height_selector_header = 149 + +local width_1920 = math.ceil(1920*0.85) -- 1632 +local height_1200 = math.ceil(1200*0.85) -- 1020 +local width_1680 = math.ceil(1680*0.85) -- 1388 +local height_1050 = math.ceil(1050*0.85) -- 893 + + ------------------------------------------------------------------------------- -- Style flow -- @@ -512,16 +539,41 @@ default_gui["helmod_flow_default"] = { ------------------------------------------------------------------------------- -- Style of main panel --- --- @field [parent=#Flow] main +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Flow] main_1920x1200 -default_gui["helmod_flow_main"] = { +default_gui["helmod_flow_main_1920x1200"] = { type = "flow_style", parent = "helmod_flow_default", - minimal_width = 1600, - minimal_height = 900 + minimal_width = width_1920, + minimal_height = height_1200 } +------------------------------------------------------------------------------- +-- Style of main panel +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Flow] main_1680x1050 + +default_gui["helmod_flow_main_1680x1050"] = { + type = "flow_style", + parent = "helmod_flow_default", + minimal_width = width_1680, + minimal_height = height_1050, +} +------------------------------------------------------------------------------- +-- Style of main panel +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Flow] main_1440x900 + +default_gui["helmod_flow_main_1440x900"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = 1224, + minimal_height = 765, +} ------------------------------------------------------------------------------- -- Style of full resize row panel -- @@ -568,16 +620,41 @@ default_gui["helmod_flow_dialog"] = { ------------------------------------------------------------------------------- -- Style of data panel -- --- @field [parent=#Flow] data +-- @field [parent=#Flow] data_1920x1200 -default_gui["helmod_flow_data"] = { +default_gui["helmod_flow_data_1920x1200"] = { type = "flow_style", parent = "helmod_flow_resize_row_width", - minimal_width = 1140, - maximal_width = 1140, + minimal_width = width_1920 - width_info, + maximal_width = width_1920 - width_info, minimal_height = 600 } +------------------------------------------------------------------------------- +-- Style of data panel +-- +-- @field [parent=#Flow] data_1680x1050 + +default_gui["helmod_flow_data_1680x1050"] = { + type = "flow_style", + parent = "helmod_flow_resize_row_width", + minimal_width = width_1680 - width_info, + maximal_width = width_1680 - width_info, + minimal_height = 600 +} + +------------------------------------------------------------------------------- +-- Style of recipe selector +-- +-- @field [parent=#Flow] recipe_selector + +default_gui["helmod_flow_recipe_selector"] = { + type = "flow_style", + parent = "flow_style", + horizontal_spacing = 0, + vertical_spacing = 0 +} + ------------------------------------------------------------------------------- -- Style frame -- @@ -613,6 +690,108 @@ default_gui["helmod_frame_default"] = { } } +------------------------------------------------------------------------------- +-- Style of main panel (only testing) +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Frame] main_1920x1200 + +default_gui["helmod_frame_main_1920x1200"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = width_1920, + minimal_height = height_1200, + -- marge interieure + top_padding = 0, + right_padding = 0, + bottom_padding = 0, + left_padding = 0, + + -- padding title + title_top_padding = 0, + title_left_padding = 0, + title_bottom_padding = 0, + title_right_padding = 0 +} + +------------------------------------------------------------------------------- +-- Style of main panel (only testing) +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Frame] main_1680x1050 + +default_gui["helmod_frame_main_1680x1050"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = width_1680, + minimal_height = height_1050, + -- marge interieure + top_padding = 0, + right_padding = 0, + bottom_padding = 0, + left_padding = 0, + + -- padding title + title_top_padding = 0, + title_left_padding = 0, + title_bottom_padding = 0, + title_right_padding = 0 +} + +------------------------------------------------------------------------------- +-- Style of main panel +-- minimal_width = screen width * 85% +-- minimal_height = screen height * 85% +-- @field [parent=#Frame] main_1440x900 + +default_gui["helmod_frame_main_1440x900"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = 1224, + minimal_height = 765, + -- marge interieure + top_padding = 0, + right_padding = 0, + bottom_padding = 0, + left_padding = 0, + + -- padding title + title_top_padding = 0, + title_left_padding = 0, + title_bottom_padding = 0, + title_right_padding = 0 +} + +------------------------------------------------------------------------------- +-- Style of main panel (only testing) +-- @field [parent=#Frame] data_menu_1920x1200 + +default_gui["helmod_frame_data_menu_1920x1200"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = width_1920 - width_info, + -- marge interieure + top_padding = 0, + right_padding = 0, + bottom_padding = 0, + left_padding = 0, +} + +------------------------------------------------------------------------------- +-- Style of main panel (only testing) +-- @field [parent=#Frame] data_menu_1680x1050 + +default_gui["helmod_frame_data_menu_1680x1050"] = { + type = "frame_style", + parent = "frame_style", + minimal_width = width_1680 - width_info, + -- marge interieure + top_padding = 0, + right_padding = 0, + bottom_padding = 0, + left_padding = 0, +} + ------------------------------------------------------------------------------- -- Style of main menu panel -- @@ -663,14 +842,27 @@ default_gui["helmod_frame_full_resize_row"] = { ------------------------------------------------------------------------------- -- Style of data panel -- --- @field [parent=#Frame] data +-- @field [parent=#Frame] data_1920x1200 -- -default_gui["helmod_frame_data"] = { +default_gui["helmod_frame_data_1920x1200"] = { type = "frame_style", parent = "helmod_frame_resize_row_width", - minimal_width = 1140, - maximal_width = 1140 + minimal_width = width_1920 - width_info, + maximal_width = width_1920 - width_info +} + +------------------------------------------------------------------------------- +-- Style of data panel +-- +-- @field [parent=#Frame] data_1680x1050 +-- + +default_gui["helmod_frame_data_1680x1050"] = { + type = "frame_style", + parent = "helmod_frame_resize_row_width", + minimal_width = width_1680 - width_info, + maximal_width = width_1680 - width_info } ------------------------------------------------------------------------------- @@ -752,16 +944,30 @@ default_gui["helmod_frame_recipe_factory"] = { ------------------------------------------------------------------------------- -- Style of block list --- --- @field [parent=#Scroll] block_list +-- +-- @field [parent=#Scroll] block_list_1920x1200 + +default_gui["helmod_scroll_block_list_1920x1200"] = { + type = "scroll_pane_style", + parent = "scroll_pane_style", + minimal_width = width_1920 - width_info - width_scroll, + maximal_width = width_1920 - width_info - width_scroll, + minimal_height = height_1200 - height_block_header, + maximal_height = height_1200 - height_block_header +} + +------------------------------------------------------------------------------- +-- Style of block list +-- +-- @field [parent=#Scroll] block_list_1680x1050 -default_gui["helmod_scroll_block_list"] = { +default_gui["helmod_scroll_block_list_1680x1050"] = { type = "scroll_pane_style", parent = "scroll_pane_style", - minimal_width = 1132, - maximal_width = 1132, - minimal_height = 516, - maximal_height = 516 + minimal_width = width_1680 - width_info - width_scroll, + maximal_width = width_1680 - width_info - width_scroll, + minimal_height = height_1050 - height_block_header, + maximal_height = height_1050 - height_block_header } ------------------------------------------------------------------------------- @@ -772,8 +978,8 @@ default_gui["helmod_scroll_block_list"] = { default_gui["helmod_scroll_block_info"] = { type = "scroll_pane_style", parent = "scroll_pane_style", - minimal_width = 290, - maximal_width = 290, + minimal_width = width_block_info, + maximal_width = width_block_info, minimal_height = 72, maximal_height = 150 } @@ -781,13 +987,27 @@ default_gui["helmod_scroll_block_info"] = { ------------------------------------------------------------------------------- -- Style of block element -- --- @field [parent=#Scroll] block_element +-- @field [parent=#Scroll] block_element_1920x1200 -default_gui["helmod_scroll_block_element"] = { +default_gui["helmod_scroll_block_element_1920x1200"] = { type = "scroll_pane_style", parent = "scroll_pane_style", - minimal_width = 833, - maximal_width = 833, + minimal_width = width_1920 - width_info - width_block_info - width_scroll - 10, + maximal_width = width_1920 - width_info - width_block_info - width_scroll - 10, + minimal_height = 72, + maximal_height = 72 +} + +------------------------------------------------------------------------------- +-- Style of block element +-- +-- @field [parent=#Scroll] block_element_1680x1050 + +default_gui["helmod_scroll_block_element_1680x1050"] = { + type = "scroll_pane_style", + parent = "scroll_pane_style", + minimal_width = width_1680 - width_info - width_block_info - width_scroll - 9, + maximal_width = width_1680 - width_info - width_block_info - width_scroll - 9, minimal_height = 72, maximal_height = 72 } @@ -807,31 +1027,31 @@ default_gui["helmod_scroll_recipe_module_list"] = { } ------------------------------------------------------------------------------- --- Style of recipe selector group +-- Style of recipe selector -- --- @field [parent=#Scroll] recipe_selector_group +-- @field [parent=#Scroll] recipe_selector_1920x1200 -default_gui["helmod_scroll_recipe_selector_group"] = { +default_gui["helmod_scroll_recipe_selector_1920x1200"] = { type = "scroll_pane_style", parent = "scroll_pane_style", minimal_width = 400, maximal_width = 400, - minimal_height = 60, - maximal_height = 134 + minimal_height = height_1200 - height_selector_header, + maximal_height = height_1200 - height_selector_header } ------------------------------------------------------------------------------- --- Style of recipe selector list +-- Style of recipe selector -- --- @field [parent=#Scroll] recipe_selector_list +-- @field [parent=#Scroll] recipe_selector_1680x1050 -default_gui["helmod_scroll_recipe_selector_list"] = { +default_gui["helmod_scroll_recipe_selector_1680x1050"] = { type = "scroll_pane_style", parent = "scroll_pane_style", minimal_width = 400, maximal_width = 400, - minimal_height = 200, - maximal_height = 600 + minimal_height = height_1050 - height_selector_header, + maximal_height = height_1050 - height_selector_header } ------------------------------------------------------------------------------- diff --git a/speed/speedController.lua b/speed/speedController.lua index 249406c3..46594a91 100644 --- a/speed/speedController.lua +++ b/speed/speedController.lua @@ -81,3 +81,7 @@ function SpeedController.methods:on_gui_click(event) end end end + +function SpeedController.methods:on_gui_text_changed(event) + +end