From 5c2c45df786bf2b3d3da32060d26d09cb783f73b Mon Sep 17 00:00:00 2001 From: Cegaiel Date: Sun, 15 Apr 2012 05:35:14 -0400 Subject: [PATCH 1/4] Changed 'Thistle Custom' layout from 5 windows per row to 4 (num_high value). 5 windows could not fit correctly at 1280x1024. Not even close to fitting a 5th window at a slighter higher resolution either. Much larger resolutions (1600x###) and higher can probably do 5. But this was set to 4 for best compatibility. --- VeggieTales/luaScripts/window_arranger.lua | 64 +++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/VeggieTales/luaScripts/window_arranger.lua b/VeggieTales/luaScripts/window_arranger.lua index be701bc..c4cba77 100644 --- a/VeggieTales/luaScripts/window_arranger.lua +++ b/VeggieTales/luaScripts/window_arranger.lua @@ -8,7 +8,7 @@ loadfile("luaScripts/ui_utils.inc")(); local window_w = 410; local window_h = 312; local dropdown_cur_value = 1; -local choice = "Brick Racks"; +local windowname = "Brick Racks"; local scale = 0.6; local z = 0.0; -- Only matters if there is overlapping elements on screen @@ -30,10 +30,8 @@ dropdown_values = {"Brick Rack", "Carpentry Shop", "Kettle", "Kiln", "Paper Pres function GetLayout() --- Add new sections here - -if (dropdown_cur_value == 1) then -choice = "Brick Racks"; + if (dropdown_cur_value == 1) then + windowname = "Brick Rack"; -- brick racks dx = 170; dy = 115; @@ -41,8 +39,8 @@ choice = "Brick Racks"; num_high = 7; -elseif (dropdown_cur_value == 2) then -choice = "Carpentry Shop"; + elseif (dropdown_cur_value == 2) then + windowname = "Carpentry Shop"; -- carpentry shop dx = 280; dy = 205; @@ -50,9 +48,8 @@ choice = "Carpentry Shop"; num_high = 4; - -elseif (dropdown_cur_value == 3) then -choice = "Kettles"; + elseif (dropdown_cur_value == 3) then + windowname = "Kettles"; -- kettles dx = 165; dy = 275; @@ -60,8 +57,8 @@ choice = "Kettles"; num_high = 3; -elseif (dropdown_cur_value == 4) then -choice = "Kilns"; + elseif (dropdown_cur_value == 4) then + windowname = "Kilns"; -- Kilns dx = 285; dy = 180; @@ -69,16 +66,17 @@ choice = "Kilns"; num_high = 4; -elseif (dropdown_cur_value == 5) then -choice = "Paper Press"; + elseif (dropdown_cur_value == 5) then + windowname = "Paper Press"; -- paper presses dx = 388; dy = 100; little_dx = 0; num_high = 8; -elseif (dropdown_cur_value == 6) then -choice = "Pottery Wheel"; + + elseif (dropdown_cur_value == 6) then + windowname = "Pottery Wheel"; -- pottery wheels dx = 190; dy = 150; @@ -86,9 +84,8 @@ choice = "Pottery Wheel"; num_high = 7; - -elseif (dropdown_cur_value == 7) then -choice = "Rock Saw"; + elseif (dropdown_cur_value == 7) then + windowname = "Rock Saw"; -- rock saws dx = 137; dy = 125; @@ -97,17 +94,17 @@ choice = "Rock Saw"; window_w = 340; -elseif (dropdown_cur_value == 8) then -choice = "Thistle Custom"; + elseif (dropdown_cur_value == 8) then + windowname = "Thistle"; -- thistle_custom - dx = 413; -- when wrapping + dx = 420; -- when wrapping dy = 190; little_dx = 0; -- for every window - num_high = 5; + num_high = 4; -elseif (dropdown_cur_value == 9) then -choice = "Thistle New"; + elseif (dropdown_cur_value == 9) then + windowname = "Thistle"; -- thistle_new dx = 413; -- when wrapping dy = 24; @@ -115,16 +112,19 @@ choice = "Thistle New"; num_high = 33; --- Add more layouts below, between this line and the 'else' statement below. --- The below 'else' statement is a copy of the original script, not sure what it's for, but added it just in case. - -- The subsequent/future layout statement would be 'elseif (dropdown_cur_value == 10) then' - -- The 2nd next subsequent/future layout statement would be 'elseif (dropdown_cur_value == 11) then', etc... + -- Add new sections here + -else + + + + + + else -- setting permissions dx = 413+55; -- when wrapping @@ -136,7 +136,7 @@ else -end + end end @@ -233,7 +233,7 @@ end GetLayout(); - askForWindow("Pin any number of " .. choice .. " windows. Will be arranged according to settings in window_arranger.lua. Press Shift to continue."); + askForWindow("Pin any number of \'" .. windowname .. "\' windows. They will be arranged according to settings in window_arranger.lua. Press Shift to continue."); From a1ac8a29a23af93764b69be5e814fbae25373797 Mon Sep 17 00:00:00 2001 From: Cegaiel Date: Sun, 15 Apr 2012 05:36:11 -0400 Subject: [PATCH 2/4] Now will close every window, no matter what scenario the windows are arranged. Even if multiple windows are hidden behind other windows, it will keep looking for windows, until no more are found. Removed all delays, so now it runs from beginning to end almost instantly. --- VeggieTales/luaScripts/window_unpin.lua | 136 ++++++------------------ 1 file changed, 31 insertions(+), 105 deletions(-) diff --git a/VeggieTales/luaScripts/window_unpin.lua b/VeggieTales/luaScripts/window_unpin.lua index 0ddaa53..766bee5 100644 --- a/VeggieTales/luaScripts/window_unpin.lua +++ b/VeggieTales/luaScripts/window_unpin.lua @@ -11,24 +11,39 @@ loadfile("luaScripts/ui_utils.inc")(); right_click = true; -- Set this boolean to 'true' to do right clicks. If this was blank or false, then it would do left clicks. -per_click_delay = 10; -- Time is in ms +per_click_delay = 0; -- Time is in ms + searchImage1 = "ThisIs.png" -- Method 1 searchImage2 = "Unpin.png" -- Method 2 - +repeatMethod1 = 1; +repeatMethod2 = 1; function doit() - -- Pause, say something to user, wait for Shift key to continue. Give opportunity to put ATITD in focus, if needed. - askForWindow("Press Shift key to right click all windows."); + askForWindow("This will right click all windows, attempting to close any pinned windows. Press Shift key continue."); + + --Keep looking for and closing windows with Image1 until no more found, then move to Method 2. + + while repeatMethod1 == 1 do + closeMethod1(); + end + + + --Keep looking for and closing windows with Image2 until no more found, then done. + while repeatMethod2 == 1 do + closeMethod2(); + end + +end ---------------------------------- METHOD 1 --------------------------------- +function closeMethod1() -- Search Method 1: @@ -41,75 +56,25 @@ function doit() local buttons = findAllImages(searchImage1); if #buttons == 0 then - - statusScreen("Search method 1/2 failed!"); - lsSleep(1000); - + repeatMethod1 = 0 else - statusScreen("Search method 1/2:\nFound " .. #buttons .. " windows"); - lsSleep(1000); - statusScreen("Search method 1/2:\nClicking " .. #buttons .. " windows"); - lsSleep(1000); for i=#buttons, 1, -1 do - srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click); lsSleep(per_click_delay); end - -- If any windows were found, with Method 1, then inform user when done clicking. - if #buttons > 0 then - statusScreen("Search method 1/2:\nDone clicking " .. #buttons .. " windows"); - lsSleep(1000); - end - - end + checkBreak(); +end - -- Done Method 1 - - - - ------------------------------------------------------------------------------- - - - --- Do another check (Method 2) for Unpin.png, if Thisis.png was not found, then it could mean 2 reasons: - --- Reason 1: Some buildings, like Warehouse, which shows 'This Small Warehouse' would fool Method 1. - -- Why don't I use this.png instead to avoid that? - -- Because many buildings may show 'This' twice. ie Kiln: "'This' is a True Kiln, 'This' True Kiln will survive 2 firings". - -- or "'This' is a greenhouse, 'This' greenhouse is growing Grass" - -- While the script would still work correctly with this.png, I use thisIs.png so that it doesn't make one window show as 2 in the status message. - -- In other words, if I had one greenhouse pinned, it would say it found 2 windows, because it found the word 'This' twice. - --- Reason 2: Maybe a flax bed window went to a seed. If you refresh a flax bed window, after going to seed, it would turn blank, only leaving the unpin.png method to find and close it. - - --- Why don't I use Method 2 only, instead of both Method 1 and 2? Wouldn't the unpin.png (Method 2) cover all scenarios? - - -- Yes it would, except for this scenario: the "thistle new" layout (from windows_arranger.lua)... - -- With this layout, Method 2 (Unpin.png) will only close one window out at a time :( I don't know why, but it does. I even tried changing the image, no luck :( - -- So this is the reason to the methods... - - ------------------------------------------------------------------------------- - - --- Why did I use #buttons2 below instead of using #buttons again? - -- Yes, I could have used #buttons again below, instead of #buttons2. - -- The only reason that I used #buttons2 instead of #buttons is to add the totals of #buttons + #buttons2 at bottom. I wanted 2 different values. - -- If I had used #buttons again, then the value (above) would have been overwritten on Method 2 (below). - -- If not for the 'Total clicked:' thing, I would not have needed to use #buttons2, just FYI. - +function closeMethod2() ---------------------------------- METHOD 2 --------------------------------- -- Search Method 2: @@ -117,60 +82,21 @@ function doit() -- Find pinned windows with searchImage2 srReadScreen(); - -- Count how many windows that were found and assign the value to #buttons2 - local buttons2 = findAllImages(searchImage2); + -- Count how many windows that were found and assign the value to #buttons + local buttons = findAllImages(searchImage2); - if #buttons2 == 0 then - - statusScreen("Search method 2/2 failed!"); - lsSleep(1000); - + if #buttons == 0 then + repeatMethod2 = 0 else - statusScreen("Search method 2/2:\nFound " .. #buttons2 .. " windows"); - lsSleep(1000); - statusScreen("Search method 2/2:\nClicking " .. #buttons2 .. " windows"); - lsSleep(1000); - - for i=#buttons2, 1, -1 do - srClickMouseNoMove(buttons2[i][0]+5, buttons2[i][1]+3, right_click); + for i=#buttons, 1, -1 do + srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click); lsSleep(per_click_delay); end - - -- If any windows were found, with Method 2, then inform user when done clicking. - if #buttons2 > 0 then - statusScreen("Search method 2/2:\nDone clicking " .. #buttons2 .. " windows"); - lsSleep(1000); - end - - end - - -- Done Method 2 - - - ------------------------------------------------------------------------------- - - - -- Just an unneeded/optional message to user, before we finish the doit() function - -- If any windows found, with either Method 1 (#buttons) or Method 2 (#buttons2), then show the total windows clicked. Else say Sorry, try again. - - if #buttons + #buttons2 > 0 then - --statusScreen("Total clicked: " .. #buttons + #buttons2 .. " windows"); - statusScreen("Method 1 clicked: " .. #buttons .. "\nMethod 2 clicked: " .. #buttons2 .. "\n---------------------------\nTotal clicked: " .. #buttons + #buttons2); - else - statusScreen("Sorry, didn't find any windows. Maybe try again with ATITD in focus!"); - end - lsSleep(5000); - - ------------------------------------------------------------------------------- - - - + checkBreak(); end From 875de72f963e6b7137cbc339c52777f06032a5f8 Mon Sep 17 00:00:00 2001 From: Cegaiel Date: Sun, 15 Apr 2012 06:01:21 -0400 Subject: [PATCH 3/4] Minor edit to the askforWindow (Press shift to continue) text. Typo corrected 'garden'. --- VeggieTales/luaScripts/thistle_custom.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VeggieTales/luaScripts/thistle_custom.lua b/VeggieTales/luaScripts/thistle_custom.lua index f8580fc..d6b3ddd 100644 --- a/VeggieTales/luaScripts/thistle_custom.lua +++ b/VeggieTales/luaScripts/thistle_custom.lua @@ -13,7 +13,7 @@ loadfile("luaScripts/ui_utils.inc")(); per_click_delay = 0; -local expected_gardens = 19; +local expected_gardens = 12; local last_sun = 99; instructions = { @@ -203,7 +203,7 @@ end function doit() num_loops = promptNumber("How many passes ?", 1); - askForWindow("Pin any number of thistle gardnes, edit thistle_custom with recipe."); + askForWindow("Pin any number of thistle gardens, edit thistle_custom with recipe."); if not ( #instructions == 41*5) then error 'Invalid instruction length'; From 310bcd55d31ca1367c4f5affa8a73aef97dba557 Mon Sep 17 00:00:00 2001 From: Cegaiel Date: Sun, 15 Apr 2012 06:02:15 -0400 Subject: [PATCH 4/4] Minor edit to the askforWindow (Press shift to continue) text. Typo corrected 'garden' and incorrectly stated to edit thistle_custom instead of thistle_new. --- VeggieTales/luaScripts/thistle_new.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VeggieTales/luaScripts/thistle_new.lua b/VeggieTales/luaScripts/thistle_new.lua index 6ac5ebf..7548c8d 100644 --- a/VeggieTales/luaScripts/thistle_new.lua +++ b/VeggieTales/luaScripts/thistle_new.lua @@ -273,7 +273,7 @@ end function doit() num_loops = promptNumber("How many passes ?", 1); - askForWindow("Pin any number of thistle gardnes, edit thistle_custom with recipe."); + askForWindow("Pin any number of thistle gardens, edit thistle_new with recipe."); if not ( #instructions == 41*5) then error 'Invalid instruction length';