mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Implemented requested changes
* Pressing `Discard changes` removes warp if it has been pressed after `New warp`. * Changed `not_available` (not in range) status icon to a cross, fits the sizing of the other icons better. * Renamed locals key `'warp-list.discard-tooltip'` to `'warp-list.remove-tooltip'` * Added textfield squashable and strechable to make it dynamic to the container size. * Container size changes depending on permissiong `'allow_add_warp'`
This commit is contained in:
@@ -97,9 +97,9 @@ main-caption=Warp List [img=info]
|
||||
main-tooltip=Warp List; Must be within __1__ tiles to use
|
||||
sub-tooltip=Warps can only be used every __1__ seconds and when within __2__ tiles\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__
|
||||
sub-tooltip-current= - __1__ This is the warp you are currently standing on;
|
||||
sub-tooltip-connected= - __1__ This warp is connected to the same network as the warp you're standing on;
|
||||
sub-tooltip-connected= - __1__ This warp is in the same electricity network;
|
||||
sub-tooltip-different= - __1__ This warp is not connected to the one u are standing on;
|
||||
sub-tooltip-bypass= - __1__ This warp is out of range or in another network (but because of the permission you have you're able to warp to this warp);
|
||||
sub-tooltip-bypass= - __1__ Because your role you are allowed to go to this warp;
|
||||
sub-tooltip-not_available= - __1__ This warp is out of range;
|
||||
sub-tooltip-cooldown= - __1__ You are currently on cooldown;
|
||||
too-close=Can't make warp; too close to warp: __1__
|
||||
@@ -112,7 +112,7 @@ confirm-tooltip=Save changes
|
||||
cancel-tooltip=Discard changes
|
||||
edit-tooltip=Currently being edited by: __1__
|
||||
edit-tooltip-none=Currently being edited by: Nobody
|
||||
discard-tooltip=Remove warp
|
||||
remove-tooltip=Remove warp
|
||||
timer-tooltip=Warp cooldown takes __1__ seconds
|
||||
goto-tooltip=Go to x __1__ y __2__
|
||||
goto-bypass=Go to x __1__ y __2__, bypass mode
|
||||
|
||||
@@ -46,6 +46,7 @@ end
|
||||
-- When a warp is updated change its chat tag and resort the warp order
|
||||
WrapData:on_update(function(warp_id, warp, old_warp)
|
||||
if warp then
|
||||
warp.updates = warp.updates + 1
|
||||
-- Update the map chart tag if there is one
|
||||
if warp.tag then
|
||||
Warps.make_warp_tag(warp_id)
|
||||
@@ -327,7 +328,8 @@ function Warps.add_warp(force_name, surface, position, player_name, warp_name)
|
||||
},
|
||||
last_edit_name = player_name or '<server>',
|
||||
last_edit_time = game.tick,
|
||||
currently_editing = editing
|
||||
currently_editing = editing,
|
||||
updates = 0,
|
||||
})
|
||||
|
||||
return warp_id
|
||||
|
||||
@@ -36,7 +36,7 @@ local Styles = {
|
||||
--- Status icon of a warp
|
||||
local warp_status_icons = {
|
||||
cooldown = '[img=utility/multiplayer_waiting_icon]',
|
||||
not_available = '[img=utility/not_available]',
|
||||
not_available = '[img=utility/set_bar_slot]',
|
||||
bypass = '[img=utility/side_menu_bonus_icon]',
|
||||
current = '[img=utility/side_menu_map_icon]',
|
||||
connected = '[img=utility/logistic_network_panel_white]',
|
||||
@@ -210,7 +210,7 @@ Gui.element(function(event_trigger, parent, warp)
|
||||
}
|
||||
end)
|
||||
:style{
|
||||
single_line = false,
|
||||
single_line = true,
|
||||
left_padding = 2,
|
||||
right_padding = 2,
|
||||
horizontally_stretchable = true
|
||||
@@ -235,6 +235,8 @@ Gui.element(function(event_trigger, parent)
|
||||
}
|
||||
end)
|
||||
:style{
|
||||
-- when editing mode because textbox is larger the icon would move up.
|
||||
top_padding = 1,
|
||||
single_line = false,
|
||||
}
|
||||
|
||||
@@ -251,7 +253,12 @@ Gui.element(function(event_trigger, parent, warp)
|
||||
}
|
||||
end)
|
||||
:style{
|
||||
maximal_width = 73,
|
||||
-- Needed fields to make it squashable and strechable.
|
||||
minimal_width = 10,
|
||||
maximal_width = 300,
|
||||
horizontally_squashable = "on",
|
||||
horizontally_stretchable = "on",
|
||||
-- Other styling
|
||||
height = 22,
|
||||
padding = -2,
|
||||
left_margin = 2,
|
||||
@@ -296,6 +303,12 @@ Gui.element{
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player, element)
|
||||
local warp_id = element.parent.caption
|
||||
-- Check if this is this is the first edit, if so remove the warp.
|
||||
local warp = Warps.get_warp(warp_id)
|
||||
if warp.updates == 1 then
|
||||
Warps.remove_warp(warp_id)
|
||||
return
|
||||
end
|
||||
Warps.set_editing(warp_id, player.name)
|
||||
end)
|
||||
|
||||
@@ -305,7 +318,7 @@ local remove_warp_button =
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'utility/trash',
|
||||
tooltip = {'warp-list.discard-tooltip'},
|
||||
tooltip = {'warp-list.remove-tooltip'},
|
||||
style = 'shortcut_bar_button_red'
|
||||
}
|
||||
:style(Styles.sprite22)
|
||||
@@ -615,8 +628,12 @@ end
|
||||
-- @element warp_list_container
|
||||
warp_list_container =
|
||||
Gui.element(function(event_trigger, parent)
|
||||
local player = Gui.get_player_from_element(parent)
|
||||
-- Check if user has permission to add warps
|
||||
local allow_add_warp = check_player_permissions(player, 'allow_add_warp')
|
||||
|
||||
-- Draw the internal container
|
||||
local container = Gui.container(parent, event_trigger, 220)
|
||||
local container = Gui.container(parent, event_trigger, allow_add_warp and 268 or 220)
|
||||
|
||||
-- Draw the header
|
||||
local header = Gui.header(
|
||||
@@ -637,9 +654,8 @@ Gui.element(function(event_trigger, parent)
|
||||
)
|
||||
|
||||
-- Draw the new warp button
|
||||
local player = Gui.get_player_from_element(parent)
|
||||
local add_new_warp_element = add_new_warp(header)
|
||||
add_new_warp_element.visible = check_player_permissions(player, 'allow_add_warp')
|
||||
add_new_warp_element.visible = allow_add_warp
|
||||
|
||||
-- Draw the scroll table for the warps
|
||||
local scroll_table = Gui.scroll_table(container, 250, 3)
|
||||
@@ -835,6 +851,11 @@ local function role_update_event(event)
|
||||
local player = game.players[event.player_index]
|
||||
local container = Gui.get_left_element(player, warp_list_container).container
|
||||
|
||||
-- Check if user has permission to add warps
|
||||
local allow_add_warp = check_player_permissions(player, 'allow_add_warp')
|
||||
-- Update container size depending on if the player is allowed to add warps
|
||||
container.parent.style.width = allow_add_warp and 268 or 220
|
||||
|
||||
-- Update the warps, incase the user can now edit them
|
||||
local scroll_table = container.scroll.table
|
||||
update_all_warps(player, scroll_table)
|
||||
|
||||
Reference in New Issue
Block a user