LUA V2 dialog functions and visibility of segment numbers
Case number: | 845813-991632 |
Topic: | Game: Tools |
Opened by: | Timo van der Laan |
Status: | Open |
Type: | Suggestion |
Opened on: | Wednesday, January 25, 2012 - 14:58 |
Last modified: | Monday, December 15, 2014 - 11:41 |
First of all, I love the new dialog possibilities but in order to make it easier to use I have 2 suggestions.
1. Create a number input box where users can type a number.
Sliders do work ok, but are not userfriendly when you are asked to enter a segmentnumber in a big protein.
2. Create a view option to make the segmentnumbers directly visible on the segment.
Repeatingly using TAB is also not userfriendly.
This would make the scripts I want to design to semiautomate things that are now done by hand a lot easier to use. F.i. Create or make bigger a helix by Rebuild and repositioning it back in place, requires now a lot of freezing and pulling. This can be semi-automated including options at the end for optimizing.
Thanks, I overlooked the textbox possibility. Will have to do some input checking, but I will use it instead of sliders for segmentnumbers.
I use textboxes for segment numbers and segment ranges. If you don't need to impose some sort of structure on the user input, the following will convert all the numbers in a string into a table, and then you can interpret the table however you want.
userinput='1,5 10 15-20' AnyInteger='-?%d+' -- - can be a minus sign NoNegatives='%d+' -- - is not part of a number nums = {} for v in string.gfind(userinput,NoNegatives) do table.insert(nums, tonumber(v)) end -- nums = {1,5,10,15,20}
Cool for setting numbers, not usable when want to get range.
Thanks for tip :)
Just written and tested, very usable for ranges:
function askSegPairs(title,struc,subtitle)
local Pairs={}
local Err={}
local Input=""
if struc==nil then struc="Pairs" end
repeat
local ask = dialog.CreateDialog(title)
-- Build resultstring from pairs found
local listP=""
for i=1,#Pairs do
if i>1 then listP=listP.."," end
listP=listP..Pairs[i][1].." "..Pairs[i][2]
end
if subtitle~=nil then ask.sub= dialog.AddLabel(subtitle) end
-- Present max 4 errors found
if #Err > 0 then ask.error1=dialog.AddLabel(Err[1]) end
if #Err > 1 then ask.error1=dialog.AddLabel(Err[2]) end
if #Err > 2 then ask.error1=dialog.AddLabel(Err[3]) end
if #Err > 3 then ask.error1=dialog.AddLabel(Err[4]) end
Err={}
if listP=="" then
ask.sub1=dialog.AddLabel("Input "..struc.. " of segmentnumbers between 1 and "..segCnt)
ask.nums=dialog.AddTextbox(struc,Input)
ask.OK = dialog.AddButton("OK",1)
ask.Cancel = dialog.AddButton("Cancel",0)
else
ask.conf=dialog.AddLabel(struc.." found: "..listP)
ask.OK = dialog.AddButton("Confirm",1)
ask.Cancel = dialog.AddButton("Again",0)
end
if dialog.Show(ask) > 0 then
if listP=="" then --Asking mode
local NoNegatives='%d+' -- - is not part of a number
local nums = {}
for v in string.gfind(ask.nums.value,NoNegatives) do
table.insert(nums, tonumber(v))
end
Input=ask.nums.value
-- Now checking
if #nums%2 ~= 0 then
Err[#Err+1]="Not an even number of segments found"
else
for i=1,#nums do
if nums[i]==0 or nums[i]>segCnt then
Err[#Err+1]="Number "..nums[i].." is not a segment"
end
end
if #Err==0 then
for i=1,#nums/2 do
Pairs[i]={nums[2*i-1],nums[2*i]}
end
end
end
else
return Pairs
end
else if listP=="" then return nil else Pairs={} end
end
until false
end
thanks for sharing
A version with proper layout is in my just posted recipe.
Status: Open » Closed |
Not longer needed i think
Status: Closed » Open |
Bump for the second part of the question (and also because the discussion here is useful and related):
2. Create a view option to make the segmentnumbers directly visible on the segment.
Repeatingly using TAB is also not user friendly
The full potential of the dialog tools mentioned above will be met when we'll be able to easily identify the needed segment on screen. A small black number on each segment would be enough, without loosing visibility for folding. Several recipes write info on specific segments. It would then be quick to find the segment we want to read.
User experience in density puzzles is horrible - hit tab, scroll to see the density for each and every segment - worse than eterna
For 1., you can use:
SegNum = 0
local ask = dialog.CreateDialog("Title")
ask.Instructions = dialog.AddLabel("Set these values:")
ask.SegmentNumber = dialog.AddSlider("for Segment:", 1, 1, SegCnt, 0) -- (default, min, max, 0=Int/1=Dec)
ask.SegNum = dialog.AddTextbox("Or seg #:", "")
ask.OK = dialog.AddButton("OK", 1)
ask.Cancel = dialog.AddButton("Exit recipe", 0)
if (dialog.Show(ask) > 0) then
if ask.SegNum.value == "" then
SegNum = ask.SegmentNumber.value
else
SegNum = ask.SegNum.value + 0 -- to force lua string to number conversion
end
else
SegNum = nil
print("Recipe cancelled")
end