mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Added filter for NamePromptDialog, configurations can now be renamed
This commit is contained in:
@@ -5,7 +5,7 @@ module TAC
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
flow width: 1.0 do
|
flow width: 1.0 do
|
||||||
label "Name", width: 0.25
|
label "Name", width: 0.25
|
||||||
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", width: 0.70
|
@name = edit_line @options[:renaming] ? @options[:renaming].name : "", filter: method(:filter), width: 0.70
|
||||||
end
|
end
|
||||||
@name_error = label "", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@name_error = label "", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@name_error.hide
|
@name_error.hide
|
||||||
@@ -37,6 +37,10 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter(text)
|
||||||
|
text.match(/[A-Za-z0-9,._\-]/) ? text : ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,10 +53,25 @@ module TAC
|
|||||||
|
|
||||||
name = File.basename(config_file, ".json")
|
name = File.basename(config_file, ".json")
|
||||||
|
|
||||||
button "#{name}", width: 0.965 do
|
button "#{name}", width: 0.94 do
|
||||||
change_config(name)
|
change_config(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Rename configuration" do
|
||||||
|
push_state(Dialog::NamePromptDialog, title: "Rename Config", callback_method: proc { |new_name|
|
||||||
|
FileUtils.mv(
|
||||||
|
"#{TAC::CONFIGS_PATH}/#{name}.json",
|
||||||
|
"#{TAC::CONFIGS_PATH}/#{new_name}.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
if window.backend.settings.config == name
|
||||||
|
change_config(new_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
populate_configs
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, **THEME_DANGER_BUTTON, tip: "Delete configuration" do
|
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, **THEME_DANGER_BUTTON, tip: "Delete configuration" do
|
||||||
push_state(Dialog::ConfirmDialog, title: "Delete Config?", callback_method: proc {
|
push_state(Dialog::ConfirmDialog, title: "Delete Config?", callback_method: proc {
|
||||||
File.delete("#{TAC::CONFIGS_PATH}/#{name}.json")
|
File.delete("#{TAC::CONFIGS_PATH}/#{name}.json")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
|||||||
require "socket"
|
require "socket"
|
||||||
require "securerandom"
|
require "securerandom"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "fileutils"
|
||||||
|
|
||||||
require_relative "lib/tac"
|
require_relative "lib/tac"
|
||||||
require_relative "lib/palette"
|
require_relative "lib/palette"
|
||||||
|
|||||||
Reference in New Issue
Block a user