mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 22:02:34 +00:00
Compare commits
3 Commits
43510faaa2
...
c4622fa563
| Author | SHA1 | Date | |
|---|---|---|---|
| c4622fa563 | |||
| d49938855d | |||
| 6554140acf |
1
Gemfile
1
Gemfile
@@ -1,7 +1,6 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "cyberarm_engine"
|
gem "cyberarm_engine"
|
||||||
gem "gosu_notifications"
|
|
||||||
|
|
||||||
group :packaging do
|
group :packaging do
|
||||||
gem "ocra"
|
gem "ocra"
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ GEM
|
|||||||
excon (~> 0.88)
|
excon (~> 0.88)
|
||||||
gosu (~> 1.1)
|
gosu (~> 1.1)
|
||||||
gosu_more_drawables (~> 0.3)
|
gosu_more_drawables (~> 0.3)
|
||||||
excon (0.105.0)
|
excon (0.109.0)
|
||||||
gosu (1.4.6)
|
gosu (1.4.6)
|
||||||
gosu_more_drawables (0.3.1)
|
gosu_more_drawables (0.3.1)
|
||||||
gosu_notifications (0.1.0)
|
|
||||||
ocra (1.3.11)
|
ocra (1.3.11)
|
||||||
rake (13.1.0)
|
rake (13.1.0)
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
cyberarm_engine
|
cyberarm_engine
|
||||||
gosu_notifications
|
|
||||||
ocra
|
ocra
|
||||||
releasy!
|
releasy!
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ module TAC
|
|||||||
@actions_menu = flow(width: 1.0, height: 36) do
|
@actions_menu = flow(width: 1.0, height: 36) do
|
||||||
label "Actions", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
label "Actions", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/barsHorizontal.png"), image_width: THEME_ICON_SIZE, tip: "Auto renumber engine actions", margin_right: 16, enabled: false do
|
||||||
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::MEDIA_PATH}/icons/up.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action up (and its children, if applicable)" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/up.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action up (and its children, if applicable)" do
|
||||||
if @active_group && @active_action
|
if @active_group && @active_action
|
||||||
shift_action(@active_action, :up)
|
shift_action(@active_action, :up)
|
||||||
@@ -126,6 +129,7 @@ module TAC
|
|||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, no action selected.")
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, no action selected.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::MEDIA_PATH}/icons/down.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action down (and its children, if applicable)" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/down.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action down (and its children, if applicable)" do
|
||||||
if @active_group && @active_action
|
if @active_group && @active_action
|
||||||
shift_action(@active_action, :down)
|
shift_action(@active_action, :down)
|
||||||
@@ -392,6 +396,12 @@ module TAC
|
|||||||
comment_label.value = comment.to_s
|
comment_label.value = comment.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if action_is_child?(action)
|
||||||
|
action_container.style.default[:margin_left] = 72
|
||||||
|
else
|
||||||
|
action_container.style.default[:margin_left] = 0
|
||||||
|
end
|
||||||
|
|
||||||
action_container.style.tag = name
|
action_container.style.tag = name
|
||||||
|
|
||||||
update_list_children(@actions_list)
|
update_list_children(@actions_list)
|
||||||
@@ -581,20 +591,7 @@ module TAC
|
|||||||
index = @active_group.actions.index(action)
|
index = @active_group.actions.index(action)
|
||||||
|
|
||||||
# Determine whether we should intent this action's container element because it is for a child state (i.e. 00-01)
|
# Determine whether we should intent this action's container element because it is for a child state (i.e. 00-01)
|
||||||
indent = false
|
indent = action_is_child?(action)
|
||||||
base, subbase = action.name.split("-", 2)
|
|
||||||
subbase_int = -1
|
|
||||||
|
|
||||||
if subbase
|
|
||||||
begin
|
|
||||||
Integer(base) # Convert to integer to verify that it is in fact, an integer.
|
|
||||||
subbase_int = Integer(subbase)
|
|
||||||
rescue ArgumentError
|
|
||||||
subbase_int = -1
|
|
||||||
end
|
|
||||||
|
|
||||||
indent = subbase_int > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING, margin_left: indent ? 72 : 0, tag: action.name do |container|
|
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING, margin_left: indent ? 72 : 0, tag: action.name do |container|
|
||||||
background action == @active_action ? THEME_HIGHLIGHTED_COLOR : (index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR)
|
background action == @active_action ? THEME_HIGHLIGHTED_COLOR : (index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR)
|
||||||
@@ -655,48 +652,22 @@ module TAC
|
|||||||
|
|
||||||
def shift_action(action, direction)
|
def shift_action(action, direction)
|
||||||
# Determine whether this action is named as required for this operation
|
# Determine whether this action is named as required for this operation
|
||||||
valid_name = false
|
valid_name = valid_engine_action_name?(action)
|
||||||
am_child = false
|
am_child = action_is_child?(action)
|
||||||
base, subbase = action.name.split("-", 2)
|
index = @active_group.actions.index(action)
|
||||||
base_int = -1
|
|
||||||
subbase_int = -1
|
|
||||||
|
|
||||||
if subbase
|
|
||||||
begin
|
|
||||||
base_int = Integer(base)
|
|
||||||
subbase_int = Integer(subbase)
|
|
||||||
rescue ArgumentError
|
|
||||||
base_int = -1
|
|
||||||
subbase_int = -1
|
|
||||||
end
|
|
||||||
|
|
||||||
valid_name = base_int >= 0
|
|
||||||
am_child = subbase_int > 0 # 00-00 is a 'base' action where as 00-01 is a 'subbase' action.
|
|
||||||
|
|
||||||
# Debug prints
|
|
||||||
# pp [base, subbase, base_int, subbase_int, valid_name, am_child]
|
|
||||||
end
|
|
||||||
|
|
||||||
unless valid_name
|
unless valid_name
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, incorrectly formated name.")
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, incorrectly formated name.\nExpected: name to be like '00-00' not '#{action.name}'")
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if am_child
|
base_int = valid_name[0]
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, cannot yet shift child actions.")
|
subbase_int = valid_name[1]
|
||||||
|
|
||||||
return
|
return if direction == :up && index.zero?
|
||||||
end
|
|
||||||
|
|
||||||
if direction == :up && base_int.zero?
|
index_before = index - 1 >= 0 ? index - 1 : nil
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action up, already first action.")
|
|
||||||
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
index = @active_group.actions.index(action)
|
|
||||||
index_before = index - 1 > 0 ? index - 1 : nil
|
|
||||||
index_next = index + 1 < @active_group.actions.size ? index + 1 : nil
|
index_next = index + 1 < @active_group.actions.size ? index + 1 : nil
|
||||||
|
|
||||||
mutated = false
|
mutated = false
|
||||||
@@ -704,53 +675,45 @@ module TAC
|
|||||||
case direction
|
case direction
|
||||||
when :up
|
when :up
|
||||||
if index_before
|
if index_before
|
||||||
a_before = @active_group.actions[index_before]
|
other = @active_group.actions[index_before]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
|
||||||
old_name = action.name
|
i = index
|
||||||
new_name = a_before.name
|
|
||||||
|
|
||||||
action.name = a_before.name
|
while(other && ((!am_child && other_is_child) || (am_child && !other_is_child)))
|
||||||
a_before.name = old_name
|
i -= 1
|
||||||
|
index_before = i - 1 >= 0 ? i - 1 : nil
|
||||||
|
|
||||||
action_container = find_element_by_tag(@actions_list, old_name)
|
return unless index_before
|
||||||
action_label = find_element_by_tag(action_container, "label")
|
return if am_child && valid_engine_action_name?(other).to_a[0].to_i != base_int
|
||||||
|
|
||||||
a_before_container = find_element_by_tag(@actions_list, new_name)
|
other = @active_group.actions[index_before]
|
||||||
a_before_label = find_element_by_tag(a_before_container, "label")
|
other_is_child = action_is_child?(other)
|
||||||
|
end
|
||||||
action_container.style.tag = action.name
|
|
||||||
a_before_container.style.tag = a_before.name
|
|
||||||
action_label.value = action.name
|
|
||||||
a_before_label.value = a_before.name
|
|
||||||
|
|
||||||
|
swap_action(action, other)
|
||||||
mutated = true
|
mutated = true
|
||||||
else
|
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action up, already last action.")
|
|
||||||
end
|
end
|
||||||
when :down
|
when :down
|
||||||
if index_next
|
if index_next
|
||||||
a_next = @active_group.actions[index_next]
|
other = @active_group.actions[index_next]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
|
||||||
old_name = action.name
|
i = index
|
||||||
new_name = a_next.name
|
|
||||||
|
|
||||||
action.name = a_next.name
|
while(other && ((!am_child && other_is_child) || (am_child && !other_is_child)))
|
||||||
a_next.name = old_name
|
i += 1
|
||||||
|
index_next = i + 1 < @active_group.actions.size ? i + 1 : nil
|
||||||
|
|
||||||
action_container = find_element_by_tag(@actions_list, old_name)
|
return unless index_next
|
||||||
action_label = find_element_by_tag(action_container, "label")
|
return if am_child && valid_engine_action_name?(other).to_a[0].to_i != base_int
|
||||||
|
|
||||||
a_next_container = find_element_by_tag(@actions_list, new_name)
|
other = @active_group.actions[index_next]
|
||||||
a_next_label = find_element_by_tag(a_next_container, "label")
|
other_is_child = action_is_child?(other)
|
||||||
|
end
|
||||||
action_container.style.tag = action.name
|
|
||||||
a_next_container.style.tag = a_next.name
|
|
||||||
action_label.value = action.name
|
|
||||||
a_next_label.value = a_next.name
|
|
||||||
|
|
||||||
|
swap_action(action, other)
|
||||||
mutated = true
|
mutated = true
|
||||||
else
|
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action down, already last action.")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -767,6 +730,63 @@ module TAC
|
|||||||
scroll_into_view(action)
|
scroll_into_view(action)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def swap_action(action, other)
|
||||||
|
old_name = action.name
|
||||||
|
new_name = other.name
|
||||||
|
|
||||||
|
action.name = other.name
|
||||||
|
other.name = old_name
|
||||||
|
|
||||||
|
action_container = find_element_by_tag(@actions_list, old_name)
|
||||||
|
action_label = find_element_by_tag(action_container, "label")
|
||||||
|
|
||||||
|
other_container = find_element_by_tag(@actions_list, new_name)
|
||||||
|
other_label = find_element_by_tag(other_container, "label")
|
||||||
|
|
||||||
|
action_container.style.tag = action.name
|
||||||
|
other_container.style.tag = other.name
|
||||||
|
action_label.value = action.name
|
||||||
|
other_label.value = other.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid_engine_action_name?(action)
|
||||||
|
base, subbase = action.name.split("-", 2)
|
||||||
|
base_int = -1
|
||||||
|
subbase_int = -1
|
||||||
|
|
||||||
|
if subbase
|
||||||
|
begin
|
||||||
|
base_int = Integer(base)
|
||||||
|
subbase_int = Integer(subbase)
|
||||||
|
rescue ArgumentError
|
||||||
|
base_int = -1
|
||||||
|
subbase_int = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
return [base_int, subbase_int] if base_int >= 0 && subbase_int >= 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def action_is_child?(action)
|
||||||
|
base, subbase = action.name.split("-", 2)
|
||||||
|
subbase_int = -1
|
||||||
|
|
||||||
|
if subbase
|
||||||
|
begin
|
||||||
|
Integer(base)
|
||||||
|
subbase_int = Integer(subbase)
|
||||||
|
rescue ArgumentError
|
||||||
|
subbase_int = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
return subbase_int > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
super
|
super
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user