lavalevel

QuestLister

Jun 18th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.48 KB | None | 0 0
  1. function QuestLister() -- CREATES A LIST OF THE PLAYERS QUESTS
  2.  
  3.     group.maps.elements.Text_Header.text = ( rosetta:getString("Quests") )
  4.     group.maps.elements.Text_Sub1.text = ( " " )
  5.  
  6.     local questNames = {}
  7.  
  8.     group.maps.groups['ScrollHandle1'].isVisible = false
  9.     group.maps.groups['ScrollHandle2'].isVisible = false
  10.     group.maps.groups['ScrollMap'].isVisible = true
  11.     group.maps.groups['AtlasMap'].isVisible = false
  12.     group.maps.groups['Lists'].isVisible = true
  13.  
  14.     group.maps.elements.btnScroll.isVisible = false
  15.     group.maps.elements.btnScroll:setEnabled(false, 'up')
  16.  
  17.     group.maps.elements.btnWorld.isVisible = false
  18.     group.maps.elements.btnWorld:setEnabled(false, 'up')
  19.  
  20.     group.maps.elements.btnQuests.isVisible = false
  21.     group.maps.elements.btnQuests:setEnabled(false, 'up')
  22.  
  23.     group.maps.elements.btnSpellbook.isVisible = false
  24.     group.maps.elements.btnSpellbook:setEnabled(false, 'up')
  25.  
  26.     group.maps.elements.btnLeft.onTap = returnToGameFromList
  27.  
  28.     if #playerData.playerQuests > 0 then -- if the player has any quests complete or active...
  29.         for i= 1, #playerData.playerQuests do
  30.         print ("Quest# " .. i .. " is " .. playerData.playerQuests[i].QuestName )
  31.         table.insert (questNames, playerData.playerQuests[i].QuestName )
  32.         atrace (xinspect(questNames))
  33.         end
  34.     else -- if the player doesnt have any quest at all
  35.     group.maps.elements.Text_Header.text = ( rosetta:getString("No quests...") )
  36.     group.maps.elements.Text_Sub1.text = ( rosetta:getString("Search for quests.") )
  37.     end
  38.  
  39.     local tableView = require("tableView")
  40.  
  41. --initial values
  42.     local screenOffsetW, screenOffsetH = display.contentWidth -  display.viewableContentWidth, display.contentHeight - display.viewableContentHeight
  43.     local myList, backBtn
  44.  
  45.  
  46. -- you might want to move this to layout
  47.     local backgroundBox = display.newRect(1, 1, 320, 412)
  48.     backgroundBox:setFillColor(tonumber("27", 16), tonumber("27", 16), tonumber("27", 16))
  49.     group.maps.groups['Lists']:insert( backgroundBox )
  50.  
  51. --setup functions to execute on touch of the list view items
  52.     function listButtonRelease( event )
  53.  
  54.  
  55.         local function returnToList()
  56.             group.maps.elements.btnYes.isVisible = false
  57.             print "remove self on return to LIST"
  58.             textBox:removeSelf()
  59.             textBox=nil
  60.             myList.isVisible = true
  61.         end
  62.  
  63.         myList.isVisible = false -- get rid of the list
  64.  
  65.         -- add a description of what the quest is...
  66.         textBox = native.newTextBox( 15, 100, 280, 300 )
  67.         textBox.font = native.newFont( native.systemFontBold, 24 / display.contentScaleX  )
  68.         textBox:setTextColor( 200, 200, 200, 255 )
  69.         textBox.isEditable = false
  70.         textBox.align = "center"
  71.         textBox.text = "Defeat the Necromancer East of the Village of Kyre." -- TEMP, Change to Character's Quest Text
  72.         textBox.hasBackground = false
  73.  
  74.         group.maps.elements.btnYes.isVisible = true
  75.         group.maps.elements.btnYes.onTap = returnToList
  76.  
  77.         self = event.target
  78.         local id = self.id
  79.         print("This is the Self.id:" .. self.id)
  80.        
  81.         group.maps.elements.Text_Header.text = ( rosetta:getString(questNames[self.id]) )
  82.         print ("questNames[self.id]:" .. questNames[self.id])
  83.        
  84.     end
  85.  
  86.  
  87.  
  88.  
  89. -- setup the data
  90.     local data = questNames
  91.     local topBoundary = display.screenOriginY + 46
  92.     local bottomBoundary = display.screenOriginY + 0
  93. -- Create a list with no backgroundIMG, allowing the backgroundIMG image to show through
  94.     myList = tableView.newList{
  95.     data=data,
  96.     default="huge_button_up.png",
  97.     over="huge_button_down.png",
  98.     onRelease=listButtonRelease,
  99.     top=topBoundary,
  100.     bottom=bottomBoundary,
  101.     callback=function(row)
  102.  
  103.         local t = display.newGroup()
  104.  
  105.         --[[     **** Put Quest Complete image or Quest Current image here ***
  106.         local img = display.newImage("Quest.png")
  107.            
  108.         img.x = math.floor(img.width/2) + 12
  109.         img.y = 46
  110.         t:insert(img)
  111.         ]]
  112.         local txt = display.newText(row, 0, 0, native.systemFontBold, 18)
  113.        
  114.         txt:setTextColor(255, 255, 255)
  115.         txt.x = math.floor(txt.width/2) + 82
  116.         txt.y = 46
  117.    
  118.         t:insert(txt)
  119.  
  120.         return t
  121.         end
  122.     }
  123.  
  124.     group.maps.groups['Lists']:insert(myList)
  125.     group.maps.groups['ScrollHandle1'].isVisible = false
  126.     group.maps.groups['ScrollHandle2'].isVisible = false
  127.     group.maps.groups['ScrollMap'].isVisible = false
  128.     group.maps.groups['AtlasMap'].isVisible = false
  129.     group.maps.groups['Lists'].isVisible = true
  130.     group.maps.elements.btnQuests.isVisible = false
  131.     group.maps.elements.btnSpellbook.isVisible = false
  132.     group.maps.elements.btnLeft:toFront()
  133.     group.maps.elements.btnQuests.isVisible = false
  134.     group.maps.elements.btnWorld.isVisible = false
  135.  
  136. end
Advertisement
Add Comment
Please, Sign In to add comment