From d5ceed8ebb5493ad0a73a9f0c1c9a2df43db1eba Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 15:00:37 +0100 Subject: [PATCH 01/10] Create position_manager.lua --- addons/position_manager/position_manager.lua | 83 ++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 addons/position_manager/position_manager.lua diff --git a/addons/position_manager/position_manager.lua b/addons/position_manager/position_manager.lua new file mode 100644 index 000000000..f9ee5f4b3 --- /dev/null +++ b/addons/position_manager/position_manager.lua @@ -0,0 +1,83 @@ +--Copyright (c) 2020, Lili +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of position_manager nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL Lili BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_addon.name = 'position_manager' +_addon.author = 'Lili' +_addon.version = '1.0.0' +_addon.command = 'pm' + +if not windower.file_exists(windower.windower_path .. '\\plugins\\WinControl.dll') then + print('position_manager: error - Please install the WinControl plugin in the launcher.') + windower.send_command('lua u position_manager') + return +end + +config = require 'config' + +default = { + x = 0, + y = 0, +} + +settings = config.load(default) + +function move(settings) + windower.send_command('load wincontrol') + coroutine.sleep(0.5) + windower.send_command('wincontrol move %s %s':format(settings.x,settings.y)) + coroutine.sleep(0.5) + windower.send_command('unload wincontrol') +end + +function handle_commands(cmd,name,pos_x,pos_y) + local cmd = cmd or 'help' + + if cmd == 'r' then + windower.send_command('lua r position_manager') + elseif cmd == 'set' then + if name and pos_x and pos_y then + settings.x = tonumber(pos_x) + settings.y = tonumber(pos_y) + config.save(settings,name) + + if windower.ffxi.get_info().logged_in then + player_name = windower.ffxi.get_player().name + if name:lower() == player_name:lower() then + move(settings) + end + -- TODO: add IPC + end + end + elseif cmd == 'help' then + windower.add_to_chat(207,'position_manager: Usage: //pm set ') + else + windower.add_to_chat(207,'position_manager: %s command not found.':format(cmd)) + windower.send_command('pm help') + end +end + +config.register(settings,move) +windower.register_event('addon command',handle_commands) From 36195509ad1feb72bc688854711b9491e82983e4 Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 15:02:51 +0100 Subject: [PATCH 02/10] Create README.md --- addons/position_manager/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 addons/position_manager/README.md diff --git a/addons/position_manager/README.md b/addons/position_manager/README.md new file mode 100644 index 000000000..1dc1dda64 --- /dev/null +++ b/addons/position_manager/README.md @@ -0,0 +1,24 @@ +# Position Manager + +Set and save screen position per-character. + +Command: //pm set pos_x pos_y + +### Examples: +`//pm set all 0 60` +Will set the default positioning for all characters to X: 0 and Y: 60 (the height of the Windows 10 taskbar with 150% UI scaling.) + +`//pm set Yourname 1920 0` +Will set the default position for the character called "Yourname" to X: 1920 and Y: 0. +This will make the character appear on the secondary screen that is to the right of the main screen - useful for multi-screen setups. + +`//pm set Yourmain 0 40` +`//pm set Youralt 800 40` +Will set your main to X: 0, Y: 40, and your alt to the X: 800, Y: 40. +If your laptop screen is 1600px wide, and your instances are both set at 800x600, this will put them side by side. + +Note: Characters are only moved after they're logged in. The position will be used for the character login screen as well. + +**Warning:** the `all` name will delete every other character-specific settings that are already saved! It's best to use it only once after you install the addon, to set default position for non-specified characters. + +Enjoy. From 8645df2d0ee31cfee4c7d457e7f00d60485d4c2c Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:28:23 +0100 Subject: [PATCH 03/10] Update position_manager.lua --- addons/position_manager/position_manager.lua | 31 ++++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/addons/position_manager/position_manager.lua b/addons/position_manager/position_manager.lua index f9ee5f4b3..f313d8d10 100644 --- a/addons/position_manager/position_manager.lua +++ b/addons/position_manager/position_manager.lua @@ -1,4 +1,4 @@ ---Copyright (c) 2020, Lili +--Copyright © 2020, Lili --All rights reserved. --Redistribution and use in source and binary forms, with or without @@ -33,9 +33,11 @@ if not windower.file_exists(windower.windower_path .. '\\plugins\\WinControl.dll print('position_manager: error - Please install the WinControl plugin in the launcher.') windower.send_command('lua u position_manager') return +else + windower.send_command('load wincontrol') end -config = require 'config' +config = require('config') default = { x = 0, @@ -45,24 +47,26 @@ default = { settings = config.load(default) function move(settings) - windower.send_command('load wincontrol') - coroutine.sleep(0.5) windower.send_command('wincontrol move %s %s':format(settings.x,settings.y)) - coroutine.sleep(0.5) - windower.send_command('unload wincontrol') end -function handle_commands(cmd,name,pos_x,pos_y) - local cmd = cmd or 'help' - +function handle_commands(cmd,pos_x,pos_y,name) + cmd = cmd:lower() or 'help' + if cmd == 'r' then windower.send_command('lua r position_manager') elseif cmd == 'set' then + if not name or name == ':current' then + name = windower.ffxi.get_player().name + elseif name == ':all' then + name = 'all' + end + if name and pos_x and pos_y then settings.x = tonumber(pos_x) settings.y = tonumber(pos_y) config.save(settings,name) - + if windower.ffxi.get_info().logged_in then player_name = windower.ffxi.get_player().name if name:lower() == player_name:lower() then @@ -72,11 +76,12 @@ function handle_commands(cmd,name,pos_x,pos_y) end end elseif cmd == 'help' then - windower.add_to_chat(207,'position_manager: Usage: //pm set ') - else + windower.add_to_chat(207,'position_manager: Usage: //pm set [Charactername|:all|:current]') + windower.add_to_chat(207,'position_manager: See the readme for details.') + else windower.add_to_chat(207,'position_manager: %s command not found.':format(cmd)) windower.send_command('pm help') - end + end end config.register(settings,move) From ca8715d6b20febb7dfc1b872ff67ba8ef6cbc94c Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:29:21 +0100 Subject: [PATCH 04/10] Update position_manager.lua --- addons/position_manager/position_manager.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/position_manager/position_manager.lua b/addons/position_manager/position_manager.lua index f313d8d10..0ea5da058 100644 --- a/addons/position_manager/position_manager.lua +++ b/addons/position_manager/position_manager.lua @@ -34,6 +34,7 @@ if not windower.file_exists(windower.windower_path .. '\\plugins\\WinControl.dll windower.send_command('lua u position_manager') return else + print('position_manager: loading WinControl...') windower.send_command('load wincontrol') end From fa3dc0ef125b06e61dcea8c2eb82032edd75970a Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:38:19 +0100 Subject: [PATCH 05/10] Update README.md --- addons/position_manager/README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/addons/position_manager/README.md b/addons/position_manager/README.md index 1dc1dda64..d1e197a85 100644 --- a/addons/position_manager/README.md +++ b/addons/position_manager/README.md @@ -2,13 +2,22 @@ Set and save screen position per-character. -Command: //pm set pos_x pos_y +Command: `//pm set pos_x pos_y [name]` + +`pos_x` and `pos_y` are obligatory and must be numbers. +The `name` parameter is optional. If no name is provided, settings will be saved for the current character. +`:all` is a special name that can be used to set the default position. + +**Note**: Characters are only moved after they're logged in. The `:all` position will be used for the character login screen as well. ### Examples: -`//pm set all 0 60` -Will set the default positioning for all characters to X: 0 and Y: 60 (the height of the Windows 10 taskbar with 150% UI scaling.) +`//pm set 0 0` +Will set your _current_ character to the position X: 0, Y: 0. -`//pm set Yourname 1920 0` +`//pm set 0 60 :all` +Will set the default positioning for all characters to X: 0 and Y: 60 (the height of the Windows 10 taskbar with 150% UI scaling.), and delete all other character-specific settings. + +`//pm set 1920 0 Yourname` Will set the default position for the character called "Yourname" to X: 1920 and Y: 0. This will make the character appear on the secondary screen that is to the right of the main screen - useful for multi-screen setups. @@ -17,8 +26,6 @@ This will make the character appear on the secondary screen that is to the right Will set your main to X: 0, Y: 40, and your alt to the X: 800, Y: 40. If your laptop screen is 1600px wide, and your instances are both set at 800x600, this will put them side by side. -Note: Characters are only moved after they're logged in. The position will be used for the character login screen as well. - **Warning:** the `all` name will delete every other character-specific settings that are already saved! It's best to use it only once after you install the addon, to set default position for non-specified characters. Enjoy. From 0d2751cc90bcb4235ab283a03c03a34d45a027ef Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:39:45 +0100 Subject: [PATCH 06/10] Update README.md --- addons/position_manager/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/position_manager/README.md b/addons/position_manager/README.md index d1e197a85..7d99c83e4 100644 --- a/addons/position_manager/README.md +++ b/addons/position_manager/README.md @@ -5,7 +5,7 @@ Set and save screen position per-character. Command: `//pm set pos_x pos_y [name]` `pos_x` and `pos_y` are obligatory and must be numbers. -The `name` parameter is optional. If no name is provided, settings will be saved for the current character. +`name` is optional. If no name is provided, settings will be saved for the current character. `:all` is a special name that can be used to set the default position. **Note**: Characters are only moved after they're logged in. The `:all` position will be used for the character login screen as well. From 2f5f5f84fa7445d8bd62d99f76d751c2e0943f0a Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:40:00 +0100 Subject: [PATCH 07/10] Update README.md --- addons/position_manager/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/position_manager/README.md b/addons/position_manager/README.md index 7d99c83e4..541d0c4e4 100644 --- a/addons/position_manager/README.md +++ b/addons/position_manager/README.md @@ -2,7 +2,7 @@ Set and save screen position per-character. -Command: `//pm set pos_x pos_y [name]` +Command: `//pm set [name]` `pos_x` and `pos_y` are obligatory and must be numbers. `name` is optional. If no name is provided, settings will be saved for the current character. From 27344f544328d9e2685b5f0c3a5b31da5fa8f487 Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:47:15 +0100 Subject: [PATCH 08/10] Update position_manager.lua --- addons/position_manager/position_manager.lua | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/position_manager/position_manager.lua b/addons/position_manager/position_manager.lua index 0ea5da058..ccfe9d356 100644 --- a/addons/position_manager/position_manager.lua +++ b/addons/position_manager/position_manager.lua @@ -56,28 +56,30 @@ function handle_commands(cmd,pos_x,pos_y,name) if cmd == 'r' then windower.send_command('lua r position_manager') - elseif cmd == 'set' then - if not name or name == ':current' then + elseif cmd == 'set' and type(pos_x) == 'number' and type(pos_y) == 'number' then + if name ~= nil and type(name) ~= 'string' then + windower.add_to_chat(207,'plugin_manager: ERROR - invalid name provided.') + windower.send_command('pm help') + return + elseif not name then name = windower.ffxi.get_player().name elseif name == ':all' then name = 'all' end - if name and pos_x and pos_y then - settings.x = tonumber(pos_x) - settings.y = tonumber(pos_y) - config.save(settings,name) + settings.x = tonumber(pos_x) + settings.y = tonumber(pos_y) + config.save(settings,name) - if windower.ffxi.get_info().logged_in then - player_name = windower.ffxi.get_player().name - if name:lower() == player_name:lower() then - move(settings) - end - -- TODO: add IPC + -- TODO: possibly add IPC + if windower.ffxi.get_info().logged_in then + player_name = windower.ffxi.get_player().name + if name:lower() == player_name:lower() then + move(settings) end end elseif cmd == 'help' then - windower.add_to_chat(207,'position_manager: Usage: //pm set [Charactername|:all|:current]') + windower.add_to_chat(207,'position_manager: Usage: //pm set [name]') windower.add_to_chat(207,'position_manager: See the readme for details.') else windower.add_to_chat(207,'position_manager: %s command not found.':format(cmd)) From 13ed86f7e9d2527b4f49c0fab3d202a1cec180b9 Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:51:40 +0100 Subject: [PATCH 09/10] Space after commas --- addons/position_manager/position_manager.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/position_manager/position_manager.lua b/addons/position_manager/position_manager.lua index ccfe9d356..3aa3d2b27 100644 --- a/addons/position_manager/position_manager.lua +++ b/addons/position_manager/position_manager.lua @@ -48,17 +48,17 @@ default = { settings = config.load(default) function move(settings) - windower.send_command('wincontrol move %s %s':format(settings.x,settings.y)) + windower.send_command('wincontrol move %s %s':format(settings.x, settings.y)) end -function handle_commands(cmd,pos_x,pos_y,name) +function handle_commands(cmd, pos_x, pos_y, name) cmd = cmd:lower() or 'help' if cmd == 'r' then windower.send_command('lua r position_manager') elseif cmd == 'set' and type(pos_x) == 'number' and type(pos_y) == 'number' then if name ~= nil and type(name) ~= 'string' then - windower.add_to_chat(207,'plugin_manager: ERROR - invalid name provided.') + windower.add_to_chat(207, 'plugin_manager: ERROR - invalid name provided.') windower.send_command('pm help') return elseif not name then @@ -69,7 +69,7 @@ function handle_commands(cmd,pos_x,pos_y,name) settings.x = tonumber(pos_x) settings.y = tonumber(pos_y) - config.save(settings,name) + config.save(settings, name) -- TODO: possibly add IPC if windower.ffxi.get_info().logged_in then @@ -79,13 +79,13 @@ function handle_commands(cmd,pos_x,pos_y,name) end end elseif cmd == 'help' then - windower.add_to_chat(207,'position_manager: Usage: //pm set [name]') - windower.add_to_chat(207,'position_manager: See the readme for details.') + windower.add_to_chat(207, 'position_manager: Usage: //pm set [name]') + windower.add_to_chat(207, 'position_manager: See the readme for details.') else - windower.add_to_chat(207,'position_manager: %s command not found.':format(cmd)) + windower.add_to_chat(207, 'position_manager: %s command not found.':format(cmd)) windower.send_command('pm help') end end -config.register(settings,move) -windower.register_event('addon command',handle_commands) +config.register(settings, move) +windower.register_event('addon command', handle_commands) From 6ca7e33b5fb529f579a031e9ecd72d0245ffdcd8 Mon Sep 17 00:00:00 2001 From: lili-ffxi <40600148+lili-ffxi@users.noreply.github.com> Date: Sun, 14 Jun 2020 16:54:59 +0100 Subject: [PATCH 10/10] Update addons.xml --- addons/addons.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/addons.xml b/addons/addons.xml index 6286a66f4..bee570b84 100644 --- a/addons/addons.xml +++ b/addons/addons.xml @@ -819,8 +819,15 @@ IndiNope Lili - Block graphical effects from Geomancer's Indi- spells. + Blocks graphical effects from Geomancer's Indi- spells. https://github.com/Windower/Lua/issues https://github.com/lili-ffxi + + position_manager + Lili + Allows you to set a screen position per character name. Each character will be moved to that screen position on login. Requires the WinControl plugin to be installed. + https://github.com/Windower/Lua/issues + https://github.com/lili-ffxi +