mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Merge pull request #183 from bbassie/feature/more-warp-icons
Changed choose_elem from item type to signal
This commit is contained in:
@@ -5,7 +5,7 @@ return {
|
|||||||
-- General config
|
-- 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
|
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
|
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
|
-- 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
|
bypass_warp_cooldown = 'expcore.roles', --- @setting bypass_warp_cooldown dictates who the warp cooldown is applied to; values: all, admin, expcore.roles, none
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function Warps.make_warp_tag(warp_id)
|
|||||||
local tag = warp.tag
|
local tag = warp.tag
|
||||||
if tag and tag.valid then
|
if tag and tag.valid then
|
||||||
tag.text = 'Warp: '..name
|
tag.text = 'Warp: '..name
|
||||||
tag.icon = {type='item', name=icon}
|
tag.icon = icon
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ function Warps.make_warp_tag(warp_id)
|
|||||||
tag = force.add_chart_tag(surface, {
|
tag = force.add_chart_tag(surface, {
|
||||||
position = {position.x+0.5, position.y+0.5},
|
position = {position.x+0.5, position.y+0.5},
|
||||||
text = 'Warp: '..name,
|
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
|
-- 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
|
end
|
||||||
surface.set_tiles(tiles)
|
surface.set_tiles(tiles)
|
||||||
|
|
||||||
-- Remove all the entities that are in the area
|
local area = {
|
||||||
local entities = surface.find_entities_filtered{
|
{position.x-radius, position.y-radius},
|
||||||
force='neutral',
|
{position.x+radius, position.y+radius}
|
||||||
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
|
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
|
end
|
||||||
|
|
||||||
--[[-- Set a warp to be the spawn point for a force, force must own this warp
|
--[[-- 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,
|
warp_id = warp_id,
|
||||||
force_name = force_name,
|
force_name = force_name,
|
||||||
name = warp_name,
|
name = warp_name,
|
||||||
icon = config.default_icon,
|
icon = { type = config.default_icon.type, name = config.default_icon.name },
|
||||||
surface = surface,
|
surface = surface,
|
||||||
position = {
|
position = {
|
||||||
x = math.floor(position.x),
|
x = math.floor(position.x),
|
||||||
|
|||||||
@@ -249,11 +249,18 @@ local update_wrap_buttons
|
|||||||
warp_icon_button =
|
warp_icon_button =
|
||||||
Gui.element(function(event_trigger, parent, warp)
|
Gui.element(function(event_trigger, parent, warp)
|
||||||
local warp_position = warp.position
|
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
|
-- Draw the element
|
||||||
return parent.add{
|
return parent.add{
|
||||||
name = event_trigger,
|
name = event_trigger,
|
||||||
type = 'sprite-button',
|
type = 'sprite-button',
|
||||||
sprite = 'item/'..warp.icon,
|
sprite = sprite,
|
||||||
tooltip = {'warp-list.goto-tooltip', warp_position.x, warp_position.y},
|
tooltip = {'warp-list.goto-tooltip', warp_position.x, warp_position.y},
|
||||||
style = 'slot_button'
|
style = 'slot_button'
|
||||||
}
|
}
|
||||||
@@ -278,9 +285,9 @@ Gui.element(function(_, parent, warp)
|
|||||||
return parent.add{
|
return parent.add{
|
||||||
name = warp_icon_button.name,
|
name = warp_icon_button.name,
|
||||||
type = 'choose-elem-button',
|
type = 'choose-elem-button',
|
||||||
elem_type = 'item',
|
elem_type = 'signal',
|
||||||
item = warp.icon,
|
signal = {type = warp.icon.type, name = warp.icon.name},
|
||||||
tooltip = {'warp-list.goto-edit'},
|
tooltip = {'warp-list.goto-edit'}
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
:style(Styles.sprite32)
|
:style(Styles.sprite32)
|
||||||
@@ -373,7 +380,12 @@ local function update_warp(player, warp_table, warp_id)
|
|||||||
local last_edit_time = warp.last_edit_time
|
local last_edit_time = warp.last_edit_time
|
||||||
warp_label_element.caption = warp_name
|
warp_label_element.caption = warp_name
|
||||||
warp_label_element.tooltip = {'warp-list.last-edit', last_edit_name, format_time(last_edit_time)}
|
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
|
elseif player_was_editing and not player_is_editing then
|
||||||
-- Player was editing but is no longer, remove text field and add label
|
-- 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
|
--- Button on the top flow used to toggle the warp list container
|
||||||
-- @element warp_list_toggle
|
-- @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')
|
return Roles.player_allowed(player, 'gui/warp-list')
|
||||||
end)
|
end)
|
||||||
:on_custom_event(Gui.events.on_visibility_changed_by_click, function(player, _,event)
|
:on_custom_event(Gui.events.on_visibility_changed_by_click, function(player, _,event)
|
||||||
|
|||||||
Reference in New Issue
Block a user