Notifications
Clear all

[Closed] UI-Shifter little gift for the community

I dont know if there is anything like this have been created before, I thought I would share this wonder to those who are creating ui-s for their script. Sometimes it could be quite time consuming work, to shift some part of the ui down or left or any other direction in order to squeze in a button, or some other type of ui element.

usage:

copy the ui code into the clipboard,
type the positive or negative value into the spinner, then press shift ui button.
The new code will be in the clipboard. If you like to print out to the listener window then tick the lstner checkbox.

Tick the horiz. checkbox for horizontal shift.

So feel free to use it, and update it with new features if you like.

Thanks for all the help!



clearlistener()
global mainroll
global cond = true
global com = 0
global bra = 0
global nr = ""
global cnt = 0	
global ff
global strarray = #()
function shiftui = (
ff = ""
ff = getclipboardText() as stringstream
cnt = 0
seek ff 0
while cond do (
	try (
	strarray[cnt+=1] = readLine ff
	)
	catch exit
)
cond = true
for d=1 to strarray.count do (
	
nr = ""	
init = findString (strarray[d] as string) "pos:["
if init == undefined do continue

while cond do (
com = findString (strarray[d] as string) ","
if com > init then exit
)

while cond do (
bra = findString (strarray[d] as string) "]"
if bra > init then exit
)

if mainroll.hori.checked == true do (
bra = com
com = init+4
)

for i=(com+1) to (bra-1) do (
	nr = nr+(strarray[d] as string)[i]
)

nr = nr as integer
nr = nr + (mainroll.val.value as integer)
nr = nr as string

strarray[d] = replace strarray[d] (com+1) ((bra)-(com+1)) nr
)

ff = stringstream ""
for k=1 to strarray.count do (
format "% 
" strarray[k] to:ff
)
clearlistener()
if mainroll.list.checked == true then (
for k=1 to strarray.count do (
format "% 
" strarray[k]
)
)
setclipboardText ""
setclipboardText ff
)

rollout mainroll "default:vertical" width:85 height:50 (
checkbox hori "horiz." checked:false pos:[4,22] width:40
checkbox list "lstner" checked:false pos:[49,22]
button shft "shift ui" width:50 height:16 pos:[4,4]
spinner val "" fieldwidth:25 pos:[55,4] range:[-1000,1000,1] scale:1
on shft pressed do (
	shiftui()
)
)
if uishifter != undefinied then CloseRolloutFloater uishifter 
uishifter = newrolloutfloater "UI-SFT" 110 70
addrollout mainroll uishifter