-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,4 @@ empty_values: | |
weapon_training: {} | ||
whirlwind_trainables: [] | ||
zombie: {} | ||
script_watch_ignored_scripts: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
=begin | ||
Creates a script window and keeps list of scripts in it | ||
It can be clickable to pause/unpause scripts as well\ | ||
=end | ||
|
||
# custom_require | ||
|
||
no_pause_all | ||
no_kill_all | ||
hide_me | ||
|
||
class ScriptWatch | ||
def initialize() | ||
settings = get_settings | ||
@display_hidden = settings.script_watch_display_hidden | ||
@display_arguments = settings.script_watch_display_arguments | ||
@enable_links = settings.script_watch_enable_links | ||
@ignored_scripts = settings.script_watch_ignored_scripts | ||
@passive_timer = settings.script_watch_cycle_time | ||
|
||
@script_prefix = settings.script_watch_script_prefix | ||
@script_postfix = settings.script_watch_script_postfix | ||
@script_separator = settings.script_watch_script_separator | ||
|
||
@script_argument_separator = settings.script_watch_script_argument_separator | ||
|
||
@argument_prefix = settings.script_watch_argument_prefix | ||
@argument_postfix = settings.script_watch_argument_postfix | ||
@argument_separator = settings.script_watch_argument_separator | ||
@last_update = Time.now | ||
|
||
# hide myself | ||
@ignored_scripts.push(Script.current.name) | ||
|
||
@script_list = [] | ||
@script_output = '' | ||
_respond("<streamWindow id='LichScripts' title='LichScripts' location='center' save='true' resident='true' />") | ||
_respond("<exposeStream id='LichScripts'/>") | ||
|
||
loop do | ||
output_scripts() | ||
pause @passive_timer | ||
end | ||
end | ||
|
||
def output_scripts() | ||
temp_list = @display_hidden ? Script.running + Script.hidden : Script.running | ||
|
||
@script_list = temp_list | ||
|
||
temp_output = temp_list.select { |s| !(@ignored_scripts.include?(s.name)) } | ||
.collect { |s| | ||
output = "" | ||
output.concat @script_prefix | ||
if @enable_links | ||
case $frontend | ||
when 'genie' | ||
# use alternate link syntax for genie, so end users don't need to enable it globally | ||
# enabling links generally in genie can cause issus with .NET UI. This link syntax | ||
# bypasses the global setting, which *shouldn't* cause the kind of problems enabling | ||
# links globally in genie can cause | ||
# genie alternate link syntax: {<text to display>:<link command>} | ||
output.concat "{#{s.name}:#{$clean_lich_char}#{s.paused? ? 'unpause' : 'pause'} #{s.name}}" | ||
else | ||
# standard link syntax for Wrayth (and maybe others?) | ||
# in theory frostbite should use this, but there is a bug with multiple links in one | ||
# line with current version at this time - (DD: 2023-08-22) | ||
# v1.16.0-beta was released 2023-02-05 | ||
output.concat "<d cmd='#{$clean_lich_char}#{s.paused? ? 'unpause' : 'pause'} #{s.name}'>#{s.name}</d>" | ||
end | ||
else | ||
output.concat s.name | ||
end | ||
output.concat @script_postfix | ||
output.concat " (paused)" if s.paused? | ||
|
||
if @display_arguments && !(s.vars.empty?) | ||
output.concat @script_argument_separator | ||
output.concat @argument_prefix | ||
output.concat s.vars.drop(1).join("#{@argument_postfix}#{@argument_separator}#{@argument_prefix}") | ||
output.concat @argument_postfix | ||
end | ||
|
||
output | ||
} | ||
.join(@script_separator) | ||
|
||
# attempt to short circuit to keep from sending unneeded xml, still update every 300s (5 min) | ||
return if @script_output == temp_output && ( (Time.now - @last_update) < 300 ) | ||
@script_output = temp_output | ||
|
||
_respond("<clearStream id=\"LichScripts\"/>\r\n") | ||
_respond("<pushStream id=\"LichScripts\"/>#{@script_output}\r\n<popStream/>\r\n") | ||
@last_update = Time.now | ||
end | ||
end | ||
|
||
before_dying do | ||
# clear window | ||
_respond("<clearStream id=\"LichScripts\"/>\r\n") | ||
end | ||
|
||
ScriptWatch.new |