mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 13:52:34 +00:00
Presets are now actually created, added notifications when creating preset.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -1,6 +1,7 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "cyberarm_engine"
|
||||
gem "gosu_notifications"
|
||||
gem "ffi"
|
||||
gem "clipboard"
|
||||
|
||||
|
||||
@@ -53,7 +53,13 @@ module TAC
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save group as preset" do
|
||||
if @active_group
|
||||
push_state(Dialog::NamePromptDialog, title: "Save Group Preset", renaming: @active_group, accept_label: "Save", list: window.backend.config.presets.actions, callback_method: proc { |action, name|
|
||||
push_state(Dialog::NamePromptDialog, title: "Save Group Preset", renaming: @active_group, accept_label: "Save", list: window.backend.config.presets.groups, callback_method: proc { |group, name|
|
||||
clone = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
|
||||
clone.name = "#{name}"
|
||||
window.backend.config.presets.groups << clone
|
||||
window.backend.config_changed!
|
||||
|
||||
window.toast("Saved Group Preset", "Saved preset: #{name}")
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -92,6 +98,12 @@ module TAC
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save action as preset" do
|
||||
if @active_action
|
||||
push_state(Dialog::NamePromptDialog, title: "Save Action Preset", renaming: @active_action, accept_label: "Save", list: window.backend.config.presets.actions, callback_method: proc { |action, name|
|
||||
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
||||
clone.name = "#{name}"
|
||||
window.backend.config.presets.actions << clone
|
||||
window.backend.config_changed!
|
||||
|
||||
window.toast("Saved Action Preset", "Saved preset: #{name}")
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,22 +31,22 @@ module TAC
|
||||
|
||||
button group.name, width: 0.895
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group preset" do
|
||||
push_state(
|
||||
Dialog::NamePromptDialog,
|
||||
title: "Rename Group",
|
||||
title: "Rename Group Preset",
|
||||
renaming: group,
|
||||
list: window.backend.config.presets.groups,
|
||||
callback_method: method(:update_group)
|
||||
callback_method: method(:update_group_preset)
|
||||
)
|
||||
end
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group preset", **THEME_DANGER_BUTTON do
|
||||
push_state(
|
||||
Dialog::ConfirmDialog,
|
||||
title: "Are you sure?",
|
||||
message: "Delete group and all of its actions and variables?",
|
||||
callback_method: proc { delete_group(group) }
|
||||
message: "Delete group preset and all of its actions and variables?",
|
||||
callback_method: proc { delete_group_preset(group) }
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -62,28 +62,56 @@ module TAC
|
||||
|
||||
button action.name, width: 0.895
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action preset" do
|
||||
push_state(
|
||||
Dialog::NamePromptDialog,
|
||||
title: "Rename Group",
|
||||
renaming: group,
|
||||
list: window.backend.config.presets.groups,
|
||||
callback_method: method(:update_group)
|
||||
title: "Rename Action Preset",
|
||||
renaming: action,
|
||||
list: window.backend.config.presets.actions,
|
||||
callback_method: method(:update_action_preset)
|
||||
)
|
||||
end
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action preset", **THEME_DANGER_BUTTON do
|
||||
push_state(
|
||||
Dialog::ConfirmDialog,
|
||||
title: "Are you sure?",
|
||||
message: "Delete group and all of its actions and variables?",
|
||||
callback_method: proc { delete_group(group) }
|
||||
message: "Delete action preset and all of its actions and variables?",
|
||||
callback_method: proc { delete_action_preset(action) }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_group_preset(group, name)
|
||||
group.name = name
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_group_presets
|
||||
end
|
||||
|
||||
def delete_group_preset(group)
|
||||
window.backend.config.presets.groups.delete(group)
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_group_presets
|
||||
end
|
||||
|
||||
def update_action_preset(action, name)
|
||||
action.name = name
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_group_presets
|
||||
end
|
||||
|
||||
def delete_action_preset(action)
|
||||
window.backend.config.presets.action.delete(action)
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_action_presets
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -12,7 +12,7 @@ module TAC
|
||||
@animator = CyberarmEngine::Animator.new(start_time: 0, duration: 3_000, from: 0, to: 255)
|
||||
@transition_color = Gosu::Color.new(0x00_000000)
|
||||
|
||||
@next_state = USE_REDESIGN ? NewEditor : Editor
|
||||
@next_state = NewEditor
|
||||
end
|
||||
|
||||
def draw
|
||||
|
||||
@@ -99,6 +99,8 @@ class NewEditor < CyberarmEngine::GuiState
|
||||
end
|
||||
end
|
||||
|
||||
@window_controls.hide unless BORDERLESS
|
||||
|
||||
page(TAC::Pages::Home)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module TAC
|
||||
THEME_FONT = "#{TAC::ROOT_PATH}/media/fonts/DejaVuSansCondensed.ttf"
|
||||
THEME = {
|
||||
Label: {
|
||||
font: "#{TAC::ROOT_PATH}/media/fonts/DejaVuSansCondensed.ttf",
|
||||
font: THEME_FONT,
|
||||
text_size: 22,
|
||||
color: Gosu::Color.new(0xee_ffffff),
|
||||
},
|
||||
@@ -55,4 +56,8 @@ module TAC
|
||||
TAC::Palette::TIMECRAFTERS_PRIMARY, TAC::Palette::TIMECRAFTERS_PRIMARY,
|
||||
TAC::Palette::TIMECRAFTERS_SECONDARY, TAC::Palette::TIMECRAFTERS_SECONDARY,
|
||||
]
|
||||
THEME_NOTIFICATION_EDGE_COLOR = Gosu::Color.new(0xff_008000)
|
||||
THEME_NOTIFICATION_BACKGROUND = Gosu::Color.new(0xff_102010)
|
||||
THEME_NOTIFICATION_TITLE_COLOR = Gosu::Color::WHITE
|
||||
THEME_NOTIFICATION_TAGLINE_COLOR = Gosu::Color::WHITE
|
||||
end
|
||||
@@ -1,19 +1,49 @@
|
||||
module TAC
|
||||
class Window < CyberarmEngine::Window
|
||||
attr_reader :backend
|
||||
attr_reader :backend, :notification_manager
|
||||
def initialize(**args)
|
||||
super(**args)
|
||||
|
||||
self.caption = "#{TAC::NAME} v#{TAC::VERSION} (#{TAC::RELEASE_NAME})"
|
||||
@backend = Backend.new
|
||||
@notification_manager = GosuNotifications::NotificationManager.new(window: self, edge: :bottom)
|
||||
|
||||
push_state(TAC::States::Boot)
|
||||
end
|
||||
|
||||
def draw
|
||||
super
|
||||
|
||||
Gosu.flush
|
||||
@notification_manager.draw
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
|
||||
@notification_manager.update
|
||||
end
|
||||
|
||||
def needs_cursor?
|
||||
true
|
||||
end
|
||||
|
||||
def toast(title, message = nil)
|
||||
@notification_manager.create_notification(
|
||||
priority: GosuNotifications::Notification::PRIORITY_HIGH,
|
||||
title: title,
|
||||
|
||||
tagline: message ? message : "",
|
||||
edge_color: THEME_NOTIFICATION_EDGE_COLOR,
|
||||
background_color: THEME_NOTIFICATION_BACKGROUND,
|
||||
title_color: THEME_NOTIFICATION_TITLE_COLOR,
|
||||
tagline_color: THEME_NOTIFICATION_TAGLINE_COLOR
|
||||
)
|
||||
end
|
||||
|
||||
def hit_test(x, y)
|
||||
return 0 unless BORDERLESS
|
||||
|
||||
if y <= 4
|
||||
return 2 if x <= 4
|
||||
return 4 if x >= width - 4
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
||||
require "gosu_notifications"
|
||||
require "socket"
|
||||
require "securerandom"
|
||||
require "json"
|
||||
@@ -48,7 +49,8 @@ require_relative "lib/tacnet/server"
|
||||
# Thread.abort_on_exception = true
|
||||
|
||||
USE_REDESIGN = ARGV.include?("--redesign")
|
||||
BORDERLESS = ARGV.include?("--borderless")
|
||||
|
||||
if not defined?(Ocra)
|
||||
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: false).show
|
||||
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: BORDERLESS).show
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user