
If this works right, you should be able to click the image above and see the original 1024x768 screenshot!
Code: Select all
/*
** Clone Fields
**
** Clone the non-method fields of a table only for save methods
*/
Function p_CloneFields(data)
Local savebuf=CopyTable(data, True)
; kill the invariant methods
For k, v In Pairs(savebuf)
If (#FUNCTION=GetType(v)) Then savebuf[k]=Nil
Next
savebuf["slot"]=Nil
Return(savebuf)
EndFunction
Code: Select all
Function p_swapEntries(first, second, parent)
; swap entries
Local content=treeitems[parent.UID].contents
Local slot1=treeitems[first.UID].slot
Local slot2=treeitems[second.UID].slot
Local temp=content[slot2]
content[slot2]=content[slot1]
content[slot1]=temp
content[slot2].slot=slot1
content[slot1].slot=slot2
; move GUI items
moai.DoMethod("tree_hierarchy", "Remove", first.ID)
If first.Node
moai.DoMethod("tree_hierarchy", "InsertNode", first.ID, parent.ID, second.ID, Unpack(first.items))
Else
moai.DoMethod("tree_hierarchy", "InsertLeaf", first.ID, parent.ID, second.ID, Unpack(first.items))
EndIf
; refresh UID in treeitems
Local newUID=moai.Get(first.ID, "UID")
treeitems[newUID]=treeitems[first.UID]
treeitems[UID1]=Nil
EndFunction
Code: Select all
Function choice.handler(msg, len)
Local suffix$=UnRightstr(msg.id, len)
Switch suffix$
Case "add":
Local item$=moai.Get("ch_item", "Text")
moai.DoMethod("ch_list", "Insert", "Bottom", item$)
Case "remove":
moai.DoMethod("ch_list", "Remove", "Active")
Case "up":
Local pos=moai.Get("ch_list", "Active")
If pos>0
moai.DoMethod("ch_list", "Move", pos-1, pos)
moai.Set("ch_list", "Active", pos-1)
EndIf
Case "down":
Local pos=moai.Get("ch_list", "Active")
If pos<>-1 And pos<moai.Get("ch_list", "Entries")-1
moai.DoMethod("ch_list", "Move", pos+1, pos)
moai.Set("ch_list", "Active", pos+1)
EndIf
Case "ok"
choice.copyback()
ModalUserData.application.saved=False
choice.editorDone()
ModalUserData=nil
Case "cancel":
choice.editorDone()
ModalUserData=nil
Default:
DebugPrint("id="..msg.id.." is unhandled")
EndSwitch
EndFunction