Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Draw
- --Friend
- --v 0.4
- --| Public:
- --| construct
- --| define
- --| update
- --| select
- --| unselect
- --| render
- -- Buddy data:
- property pData
- property pID
- property pName
- --property pSex
- property pCustomText
- property pOnline
- property pLocation
- property pLastTime
- property pMsgCount
- -- Layout data:
- property pTopMarg
- property pLeftMarg
- property pWidth
- property pHeight
- property pLineHeight
- property pMsgLinkRect
- property pSelected
- property pNeedUpdate
- -- Cached images and update requests:
- property pCacheImage
- property pDotLineImg
- property pCacheOnlineImg
- property pCacheNameImg
- property pCacheMsgsImg
- property pCacheUnitImg
- property pCacheLastTimeImg
- property pCacheMissionImg
- property pNameNeedUpdate
- property pMsgsNeedUpdate
- property pLocationNeedUpdate
- property pLastNeedUpdate
- property pMissNeedUpdate
- -- Direct pointers to writer objects:
- property pWriterName
- property pWriterMsgs
- property pWriterLast
- property pWriterText
- --additional offsets defined in the patch file
- property pFriendNameOffset
- property pFriendLastOffset
- property pFriendPerMsgOffset
- on construct(me)
- pData = [:]
- pID = EMPTY
- pCustomText = EMPTY
- pOnline = FALSE
- pLocation = EMPTY
- pLastTime = EMPTY
- pMsgCount = "0"
- pTopMarg = 3
- pLeftMarg = 29
- pLineHeight = 10
- pMsgLinkRect = rect(0, 0, 0, 0)
- pSelected = FALSE
- pDotLineImg = member(getMemNum("meswhitedottedline")).image
- pCacheOnlineImg = member(getMemNum("mes_smallbuddy_head")).image
- pNameNeedUpdate = TRUE
- pMsgsNeedUpdate = TRUE
- pLocationNeedUpdate = TRUE
- pLastNeedUpdate = TRUE
- pMissNeedUpdate = TRUE
- -- Check if offsets are set
- pFriendNameOffset = 0
- if (variableExists("messenger_friend_name_offset")) then pFriendNameOffset = getVariable("messenger_friend_name_offset")
- pFriendLastOffset = 0
- if (variableExists("messenger_friend_last_offset")) then pFriendLastOffset = getVariable("messenger_friend_last_offset")
- pFriendPerMsgOffset = 0
- if (variableExists("messenger_friend_permsg_offset")) then pFriendPerMsgOffset = getVariable("messenger_friend_permsg_offset")
- return(TRUE)
- end
- on define(me, tData, tProps)
- pData = tData
- pID = tData.id
- pName = tData.name
- pOnline = tData.online
- --pSex = tData.sex
- pWidth = tProps.width
- pHeight = tProps.height
- pCacheImage = image(pWidth, pHeight, 8)
- pWriterName = getWriter(tProps.writer_name)
- pWriterMsgs = getWriter(tProps.writer_msgs)
- pWriterLast = getWriter(tProps.writer_last)
- pWriterText = getWriter(tProps.writer_text)
- pNeedUpdate = TRUE
- me.update()
- end
- on update(me)
- pOnline = pData.online
- -- Mission...
- if(pData.customText <> pCustomText) then
- pCustomText = pData.customText
- pMissNeedUpdate = TRUE
- pNeedUpdate = TRUE
- end if
- if(pOnline) then
- -- Unit...
- if(pData.location <> pLocation) then
- pLocation = pData.location
- pLocationNeedUpdate = TRUE
- pNeedUpdate = TRUE
- end if
- else
- -- Last visit...
- if(pData.lastAccess <> pLastTime) then
- pLastTime = pData.lastAccess
- pLastNeedUpdate = TRUE
- pNeedUpdate = TRUE
- end if
- end if
- -- Message count...
- if(pData.msgs <> pMsgCount) then
- pMsgCount = string(pData.msgs)
- pMsgsNeedUpdate = TRUE
- pNeedUpdate = TRUE
- end if
- end
- on select(me, tClickPoint, tBuffer, tPosition)
- if(integer(pMsgCount.word[1]) > 0 and inside(tClickPoint, pMsgLinkRect)) then
- tMsgStruct = getThread(#messenger).getComponent().getMessageBySenderID(pID)
- getThread(#messenger).getInterface().renderMessage(tMsgStruct)
- else
- tPos = tPosition * pHeight
- tRect = pCacheImage.rect + rect(0, 1,-4,-2) + [0, tPos, 0, tPos]
- if(pSelected) then
- pSelected = FALSE
- tBuffer.draw(tRect, [#shapeType:#rect, #lineSize:1, #color:rgb("#FFFFFF")])
- else
- pSelected = TRUE
- tBuffer.draw(tRect, [#shapeType:#rect, #lineSize:1, #color:rgb("#EEEEEE")])
- end if
- getThread(#messenger).getInterface().buddySelectOrNot(pName, pID, pSelected)
- end if
- end
- on unselect(me)
- pSelected = FALSE
- end
- on render(me, tBuffer, tPosition)
- tPosition = tPosition - 1
- if(pData.update) then pNeedUpdate = TRUE
- if(not pNeedUpdate) then
- -- Render cached image...
- tDstRect = pCacheImage.rect + rect(0, tPosition * pHeight, 0, tPosition * pHeight)
- tBuffer.copyPixels(pCacheImage, tDstRect, pCacheImage.rect)
- else
- pNeedUpdate = FALSE
- --tt = the milliseconds
- -- Create and render cached name image...
- if(pNameNeedUpdate) then
- tText = pName && "-"
- pCacheNameImg = pWriterName.render(tText).duplicate()
- pNameNeedUpdate = FALSE
- tX1 = pLeftMarg
- tX2 = tX1 + pCacheNameImg.width
- tY1 = pTopMarg + pFriendNameOffset
- tY2 = tY1 + pCacheNameImg.height
- tDstRect = rect(tX1, tY1, tX2, tY2)
- pCacheImage.copyPixels(pCacheNameImg, tDstRect, pCacheNameImg.rect)
- end if
- -- Create messages count image...
- if(pMsgsNeedUpdate) then
- tMsgsImg = pWriterMsgs.render(pMsgCount)
- tX1 = pLeftMarg + pCacheNameImg.width + 5
- tX2 = tX1 + tMsgsImg.width
- tY1 = pTopMarg + pFriendNameOffset
- tY2 = tY1 + tMsgsImg.height
- tDstRect = rect(tX1, tY1, tX2, tY2)
- pCacheImage.fill(tDstRect, rgb(255, 255, 255))
- pCacheImage.copyPixels(tMsgsImg, tDstRect, tMsgsImg.rect)
- pMsgLinkRect = tDstRect
- pMsgNeedUpdate = FALSE
- end if
- -- Create last visit image...
- if(pLastNeedUpdate OR pLocationNeedUpdate) then -- T�ss� varmaan pit�� olla location my�s -Antti
- if(not(pOnline)) then
- tText = getText("console_lastvisit") && pLastTime
- else
- tLocation = pLocation
- -- Begin legacy code, can be removed in r9 b3 and on
- if(tLocation contains "Floor1") then tLocation = getText("console_inprivateroom")
- if(tLocation = "") then tLocation = getText("console_onfrontpage") -- This was 'ENTERPRISESERVER'
- -- /Legacy
- -- Tuota ei voinut viel� poistaa kommentista huolimatta (R9 b12) -Antti
- tText = getText("console_online") && tLocation
- end if
- tLastTimeImg = pWriterLast.render(tText)
- tX1 = pLeftMarg
- tX2 = tX1 + tLastTimeImg.width
- tY1 = pLineHeight + pTopMarg + pFriendLastOffset
- tY2 = tY1 + tLastTimeImg.height
- tDstRect = rect(tX1, tY1, tX2, tY2)
- pCacheImage.fill(rect(tX1, tY1, pCacheImage.width, tY2), rgb(255, 255, 255))
- pCacheImage.copyPixels(tLastTimeImg, tDstRect, tLastTimeImg.rect)
- pLastNeedUpdate = FALSE
- end if
- -- Render online-head image...
- tX1 = 6
- tX2 = tX1 + pCacheOnlineImg.width
- tY1 = 4
- tY2 = tY1 + pCacheOnlineImg.height
- tDstRect = rect(tX1, tY1, tX2, tY2)
- if(pOnline) then
- pCacheImage.copyPixels(pCacheOnlineImg, tDstRect, pCacheOnlineImg.rect)
- else
- pCacheImage.fill(tDstRect, rgb(255, 255, 255))
- end if
- -- Create mission image...
- if(pMissNeedUpdate) then
- tMissionImg = pWriterText.render(QUOTE & pCustomText & QUOTE)
- tX1 = pLeftMarg
- tX2 = tX1 + tMissionImg.width
- tY1 = pLineHeight * 2 + pTopMarg + pFriendPerMsgOffset
- tY2 = tY1 + tMissionImg.height
- tDstRect = rect(tX1, tY1, tX2, tY2)
- pCacheImage.fill(rect(tX1, tY1, tX1 + pWidth, tY2), rgb(255, 255, 255))
- pCacheImage.copyPixels(tMissionImg, tDstRect, tMissionImg.rect)
- pMissNeedUpdate = FALSE
- end if
- -- Render dotline...
- tX1 = 0
- tX2 = pDotLineImg.width
- tY1 = pCacheImage.height - 1
- tY2 = tY1 + 1
- tDstRect = rect(tX1, tY1, tX2, tY2)
- pCacheImage.copyPixels(pDotLineImg, tDstRect, pDotLineImg.rect)
- -- Update BufferImage...
- tDstRect = pCacheImage.rect + rect(0, tPosition * pHeight, 0, tPosition * pHeight)
- tBuffer.copyPixels(pCacheImage, tDstRect, pCacheImage.rect)
- pData.update = FALSE
- --tt = (the milliseconds - tt)
- --put "buddy image took:" && tt
- end if
- end
- --Draw Friend Class
- --Antti Kaseva
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement