Skip to content

Commit

Permalink
Bodge to move it when toggling remote view
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Jan 21, 2025
1 parent bd97016 commit c0a8bcd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 2.0.1
Date: ????
Date: 2025. 01. 21
Info:
- ' => "
- Bodge to move it when toggling remote view
---------------------------------------------------------------------------------------------------
Version: 2.0.0
Date: 2025. 01. 10
Expand Down
31 changes: 21 additions & 10 deletions mods_2.0/052_show-missing-bottles-for-current-research/control.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
local util = require("util")

local Flasks = {}

Flasks.frame_name = "show_missing_bottles_for_current_research_frame"
Flasks.window_name = "show_missing_bottles_for_current_research_window"
Flasks.label_name = "show_missing_bottles_for_current_research_label"

local function on_configuration_changed(event)
storage.lab_inputs = {}
for _, entity_prototype in pairs(prototypes.get_entity_filtered({{filter = "type", type = "lab"}})) do
storage.lab_inputs[entity_prototype.name] = util.list_to_map(entity_prototype.lab_inputs)
end

for _, player in pairs(game.players) do
if player.gui.screen[Flasks.frame_name] then
player.gui.screen[Flasks.frame_name].destroy()
end
end
end

script.on_configuration_changed(on_configuration_changed)
Expand Down Expand Up @@ -42,12 +54,6 @@ for _, event in ipairs({
})
end

local Flasks = {}

Flasks.frame_name = "show_missing_bottles_for_current_research_frame"
Flasks.window_name = "show_missing_bottles_for_current_research_window"
Flasks.label_name = "show_missing_bottles_for_current_research_label"

function Flasks.update_player(player, caption)
if script.level.is_simulation then return end

Expand All @@ -60,10 +66,6 @@ function Flasks.update_player(player, caption)
direction = "horizontal",
ignored_by_interaction = true,
})
else
-- canceling a research causes the "press T to start a new research" to come ontop layer-wise,
-- so to bodge that we'll just bring the frame to front when there's ever no pending research.
frame.bring_to_front()
end

local window = frame[Flasks.window_name]
Expand All @@ -80,6 +82,14 @@ function Flasks.update_player(player, caption)
window.style.top_padding = 46
end

if player.controller_type == defines.controllers.remote then
window.style.top_padding = 46 + 40
window.style.right_margin = 12
else
window.style.top_padding = 46
window.style.right_margin = 0
end

local label = window[Flasks.label_name]
if not label or not label.valid then
label = window.add({
Expand Down Expand Up @@ -187,6 +197,7 @@ end

script.on_event(defines.events.on_player_display_resolution_changed, Flasks.resize_player)
script.on_event(defines.events.on_player_display_scale_changed, Flasks.resize_player)
script.on_event(defines.events.on_player_controller_changed, on_active_research_changed)

for _, event in ipairs({
defines.events.on_research_cancelled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "show-missing-bottles-for-current-research",
"title": "Show missing bottles for current research",
"description": "Research-kun why are you stuck?",
"version": "2.0.0",
"version": "2.0.1",
"author": "Quezler",
"factorio_version": "2.0",
"dependencies": [
Expand Down

0 comments on commit c0a8bcd

Please sign in to comment.