Skip to content

Commit 037c36d

Browse files
committed
Draw result selection box in remote view
1 parent 584bfd7 commit 037c36d

4 files changed

Lines changed: 26 additions & 13 deletions

File tree

control.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ require "scripts.remote"
107107
---@field position MapPosition
108108
---@field surface SurfaceName
109109
---@field selection_boxes BoundingBox[]
110+
---@field group_selection_box BoundingBox
110111

111112
DEBOUNCE_TICKS = 60
112113

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"description": "Search your factory for items, fluids, entities, signals, tags and more with Shift + F. Displays a list of matching buildings: clicking on a result opens it in the map. Can search all planets/surfaces (Space Age, Space Exploration, etc).\nAlt + Shift + Click on anything (e.g. built entity, inventory item, recipe) to open the search with that item selected.\nSimilar to BeastFinder and Where is it Made?",
88
"factorio_version": "2.0",
99
"dependencies": [
10-
"base",
10+
"base >= 2.0.35",
1111
"? space-age"
1212
],
1313
"package": {

scripts/result-location.lua

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,31 @@ function ResultLocation.draw_markers(player, surface, selection_boxes)
7777
players = {player},
7878
}
7979
end
80-
--[[game.get_surface(surface).create_entity{
81-
name = "highlight-box",
82-
position = {0, 0}, -- Ignored by game
83-
bounding_box = selection_box,
84-
box_type = "copy", -- Green
85-
render_player_index = player.index,
86-
time_to_live = 600,
87-
88-
}]]
8980
end
9081
end
9182

83+
---@param player LuaPlayer
84+
---@param surface SurfaceName
85+
---@param selection_box BoundingBox
86+
function ResultLocation.draw_chart_marker(player, surface, selection_box)
87+
local time_to_live = player.mod_settings["fs-highlight-duration"].value * 60
88+
rendering.draw_rectangle{
89+
color = LINE_COLOR,
90+
width = LINE_WIDTH * 16,
91+
filled = false,
92+
left_top = selection_box.left_top,
93+
right_bottom = selection_box.right_bottom,
94+
surface = surface,
95+
time_to_live = time_to_live,
96+
players = {player},
97+
render_mode = "chart",
98+
}
99+
end
100+
92101
---@param player LuaPlayer
93102
---@param surface SurfaceName
94103
---@param position MapPosition
95-
function ResultLocation.draw_arrows(player, surface, position)
104+
function ResultLocation.draw_arrow(player, surface, position)
96105
local character = player.character
97106
if (not character) and remote.interfaces["space-exploration"] then
98107
character = remote.call("space-exploration", "get_player_character", { player = player })
@@ -124,7 +133,10 @@ function ResultLocation.highlight(player, data)
124133
if not game.surfaces[surface_name] then return end
125134

126135
ResultLocation.draw_markers(player, surface_name, data.selection_boxes)
127-
ResultLocation.draw_arrows(player, surface_name, data.position)
136+
ResultLocation.draw_arrow(player, surface_name, data.position)
137+
if helpers.compare_versions(helpers.game_version, "2.0.56") >= 0 then
138+
ResultLocation.draw_chart_marker(player, surface_name, data.group_selection_box)
139+
end
128140
end
129141

130142
---@param player LuaPlayer

scripts/search-gui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function SearchGui.build_surface_category_results(surface_name, entity_groups)
8686
tooltip = {"", "[font=default-bold]", group.localised_name, "[/font]", distance_info, extra_info, "\n", {"search-gui.result-tooltip"}},
8787
style = "slot_button",
8888
number = group.resource_count or group.count,
89-
tags = {position = group.avg_position, surface = surface_name, selection_boxes = group.selection_boxes},
89+
tags = {position = group.avg_position, surface = surface_name, selection_boxes = group.selection_boxes, group_selection_box = group.selection_box},
9090
handler = {[defines.events.on_gui_click] = SearchGui.open_location_on_map}
9191
}
9292
)

0 commit comments

Comments
 (0)