Changed choose_elem from item type to signal

This commit is contained in:
badgamernl
2020-11-07 00:42:34 +01:00
parent 9e150aff79
commit bd59342497
3 changed files with 31 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ return {
-- General config
update_smoothing = 10, --- @setting update_smoothing the amount of smoothing applied to updates to the cooldown timer, higher is better, max is 60
minimum_distance = 100, --- @setting minimum_distance the minimum distance that is allowed between warps on the same force
default_icon = 'discharge-defense-equipment', --- @setting default_icon the default icon that will be used for warps
default_icon = { type = 'item', name = 'discharge-defense-equipment' }, --- @setting default_icon the default icon that will be used for warps
-- Warp cooldowns
bypass_warp_cooldown = 'expcore.roles', --- @setting bypass_warp_cooldown dictates who the warp cooldown is applied to; values: all, admin, expcore.roles, none

View File

@@ -90,7 +90,7 @@ function Warps.make_warp_tag(warp_id)
local tag = warp.tag
if tag and tag.valid then
tag.text = 'Warp: '..name
tag.icon = {type='item', name=icon}
tag.icon = icon
return false
end
@@ -102,7 +102,7 @@ function Warps.make_warp_tag(warp_id)
tag = force.add_chart_tag(surface, {
position = {position.x+0.5, position.y+0.5},
text = 'Warp: '..name,
icon = {type='item', name=icon}
icon = icon
})
-- Add the tag to this warp, store.update not needed as we dont want it to trigger
@@ -221,15 +221,17 @@ function Warps.remove_warp_area(warp_id)
end
surface.set_tiles(tiles)
-- Remove all the entities that are in the area
local entities = surface.find_entities_filtered{
force='neutral',
area={
{position.x-radius, position.y-radius},
{position.x+radius, position.y+radius}
}
local area = {
{position.x-radius, position.y-radius},
{position.x+radius, position.y+radius}
}
-- Remove all the entities that are in the area
local entities = surface.find_entities_filtered{ force='neutral', area=area }
for _, entity in pairs(entities) do if entity and entity.valid and entity.name ~= 'player' then entity.destroy() end end
-- Rechart map area, usefull if warp is not covered by a radar
game.forces[warp.force_name].chart(surface, area)
end
--[[-- Set a warp to be the spawn point for a force, force must own this warp
@@ -323,7 +325,7 @@ function Warps.add_warp(force_name, surface, position, player_name, warp_name)
warp_id = warp_id,
force_name = force_name,
name = warp_name,
icon = config.default_icon,
icon = { type = config.default_icon.type, name = config.default_icon.name },
surface = surface,
position = {
x = math.floor(position.x),

View File

@@ -249,11 +249,18 @@ local update_wrap_buttons
warp_icon_button =
Gui.element(function(event_trigger, parent, warp)
local warp_position = warp.position
-- The SpritePath type is not the same as the SignalID type
local sprite = warp.icon.type .. '/' ..warp.icon.name
if warp.icon.type == 'virtual' then
sprite = 'virtual-signal/' ..warp.icon.name
end
-- Draw the element
return parent.add{
name = event_trigger,
type = 'sprite-button',
sprite = 'item/'..warp.icon,
sprite = sprite,
tooltip = {'warp-list.goto-tooltip', warp_position.x, warp_position.y},
style = 'slot_button'
}
@@ -278,9 +285,9 @@ Gui.element(function(_, parent, warp)
return parent.add{
name = warp_icon_button.name,
type = 'choose-elem-button',
elem_type = 'item',
item = warp.icon,
tooltip = {'warp-list.goto-edit'},
elem_type = 'signal',
signal = {type = warp.icon.type, name = warp.icon.name},
tooltip = {'warp-list.goto-edit'}
}
end)
:style(Styles.sprite32)
@@ -373,7 +380,12 @@ local function update_warp(player, warp_table, warp_id)
local last_edit_time = warp.last_edit_time
warp_label_element.caption = warp_name
warp_label_element.tooltip = {'warp-list.last-edit', last_edit_name, format_time(last_edit_time)}
icon_entry.sprite = 'item/'..warp_icon
-- The SpritePath type is not the same as the SignalID type
local sprite = warp_icon.type .. '/' ..warp_icon.name
if warp_icon.type == 'virtual' then
sprite = 'virtual-signal/' ..warp_icon.name
end
icon_entry.sprite = sprite
elseif player_was_editing and not player_is_editing then
-- Player was editing but is no longer, remove text field and add label
@@ -475,7 +487,7 @@ end)
--- Button on the top flow used to toggle the warp list container
-- @element warp_list_toggle
Gui.left_toolbar_button('item/'..config.default_icon, {'warp-list.main-tooltip', config.standard_proximity_radius}, warp_list_container, function(player)
Gui.left_toolbar_button(config.default_icon.type ..'/'..config.default_icon.name, {'warp-list.main-tooltip', config.standard_proximity_radius}, warp_list_container, function(player)
return Roles.player_allowed(player, 'gui/warp-list')
end)
:on_custom_event(Gui.events.on_visibility_changed_by_click, function(player, _,event)