Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function enterName()
- print (" ENTER NAME ")
- print (" SAVEDISK:" .. FinalOverWriteDisk)
- group.mm.elements.Text_header.text = ( rosetta:getString("Enter a name") )
- group.mm.groups.Text_1.isVisible = false
- group.mm.groups.Text_2.isVisible = false
- group.mm.groups['GarbageGroup'].isVisible = false
- group.mm.groups['DiskManager1'].isVisible = false
- group.mm.groups['DiskManager2'].isVisible = false
- group.mm.groups['DiskManager3'].isVisible = false
- group.mm.groups['YesNo'].isVisible = false
- -- string:sub(1, 14)
- -- s:sub(1, 14):gsub([[\]], [[\]])
- local ui = require("ui")
- -------------------------------------------
- -- General event handler for fields
- -------------------------------------------
- -- You could also assign different handlers for each textfield
- local defaultField
- local fields = display.newGroup()
- local function fieldHandler( event )
- if ( "began" == event.phase ) then
- -- This is the "keyboard has appeared" event
- -- In some cases you may want to adjust the interface when the keyboard appears.
- elseif ( "ended" == event.phase ) then
- -- This event is called when the user stops editing a field: for example, when they touch a different field
- elseif ( "submitted" == event.phase ) then
- -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard
- -- Hide keyboard
- playerName = defaultField.text
- fields:removeSelf()
- verifyName()
- native.setKeyboardFocus( playerName )
- end
- end
- -- Predefine local objects for use later
- -------------------------------------------
- -- *** Buttons Presses ***
- -------------------------------------------
- -- Default Button Pressed
- --defaultField:removeSelf()
- -- fields:remove( defaultField )
- -- Number Button Pressed
- ------------------------------------------
- -- *** Create native input textfields ***
- -------------------------------------------
- -- Note: currently this feature works in device builds or Xcode simulator builds only
- -- Note: currently this feature works in device builds only
- local isAndroid = "Android" == system.getInfo("platformName")
- local inputFontSize = 18
- local inputFontHeight = 30
- if isAndroid then
- -- Android text fields have more chrome. It's either make them bigger, or make the font smaller.
- -- We'll do both
- inputFontSize = 14
- inputFontHeight = 42
- end
- defaultField = native.newTextField( 10, 80, 300, 30, fieldHandler )
- defaultField.font = native.newFont( native.systemFontBold, inputFontSize )
- defaultField.align = "center"
- -- Add fields to our new group
- fields:insert(defaultField)
- local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
- bkgd:setFillColor( 0, 0, 0, 0 ) -- set Alpha = 0 so it doesn't cover up our buttons/fields
- end
- local function AlertOverWrite()
- -- Handler that gets notified when the alert closes
- -- print ("WARNING FOR SAVEDISK:" .. disk2overwrite)
- local function onComplete( event )
- print( "index => ".. event.index .. " action => " .. event.action )
- local action = event.action
- if "clicked" == event.action then
- if 1 == event.index then
- -- Open url if "Learn More" was clicked by the user
- NewGame()
- FinalOverWriteDisk = 0
- end
- if 2 == event.index then
- -- Open url if "Learn More" was clicked by the user
- enterName()
- end
- --elseif "cancelled" == event.action then
- end
- end
- local alert = native.showAlert( rosetta:getString("Overwrite?"), rosetta:getString("This Save Will Be Erased!"), { rosetta:getString("No"), rosetta:getString("Yes") }, onComplete )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement