Renamer

by GotLag

Adds hotkey to rename stations, locomotives, labs, roboports and radars.

Utilities
4 years ago
0.13 - 1.1
7.56K

i RU locale + name-fix

6 months ago

I was translating your mod into Russian and I had to modify something. I hope you understand and accept this.

locale\en

[controls]
rename=Rename entity
[controls-description]
rename=<insert description>

[renamer-gui-tooltips]
rename-title=Rename this entity
random=Pick random name
reset=Reset changes
commit=Save name
cancel=Cancel

locale\ru

[controls]
rename=Сменить название объекта
[controls-description]
rename=Укажите курсором на объект и нажмите указанное сочетание клавиш для того что бы получить возможность изменять установленные названия.\n\nРаботает с лабораториями, робопортами, радарами, локомотивами и станциями-ЖД (а так же с ещё некоторыми объектами имеющими названия).

[renamer-gui-tooltips]
rename-title=Сменить название объекта
random=Случайное название
reset=Сброс ввода
commit=Сохранить новое название
cancel=Отмена

control.lua - function SpawnGUI

function SpawnGUI(player)
    local frame = player.gui.screen.add{type = "frame", name = "renamer_frame", style = "frame", direction = "vertical"}
    frame.style.bottom_padding = 4
    local title = frame.add{type = "flow", name = "renamer_titlebar_flow", style = "renamer_titlebar_flow"}
    local label = title.add{type = "label", name = "renamer_titlebar_label", style = "frame_title", caption = {"renamer-gui-tooltips.rename-title"}}
    label.drag_target = frame
    local filler = title.add{type = "empty-widget", name = "renamer_title_filler", style = "draggable_space_header"}
    filler.style.horizontally_stretchable = true
    filler.style.natural_height = 24
    filler.style.right_margin = 7
    filler.style.left_margin = 7
    filler.drag_target = frame
    title.add{type = "sprite-button", name = "renamer_cancel", sprite = "utility/close_white", style = "frame_action_button", tooltip = {"renamer-gui-tooltips.cancel"}}
    local content = frame.add{type = "flow", name = "renamer_content_flow"}
    content.style.vertical_align = "center"
    local shuffle = content.add{type = "sprite-button", name = "renamer_random", sprite = "utility/shuffle", style = "tool_button", tooltip = {"renamer-gui-tooltips.random"}}
    shuffle.style.top_margin = 1
    -- end
    local reset = content.add{type = "sprite-button", name = "renamer_reset", sprite = "utility/refresh", style = "tool_button", tooltip = {"renamer-gui-tooltips.reset"}}
    reset.style.top_margin = 1
    local textfield = content.add{type = "textfield", name = "renamer_textfield", text = global.renamer[player.index].backer_name}
    local commit = content.add{type = "sprite-button", name = "renamer_commit", sprite = "renamer-black-check", style = "tool_button", tooltip = {"renamer-gui-tooltips.commit"}}
    commit.style.top_margin = 1
    textfield.select_all()
    textfield.focus()
    frame.force_auto_center()
    player.opened = textfield
end

Here I have added a localized link for the title and a tooltip for the cancel button.

New response