Beispiel #1
0
	def show(self):
		player = client.getPlayer()
		items = []
		index = 0
		# copy
		msgs = player.messages[:]
		msgs.reverse()
		currTurn = client.getTurn()
		for sourceID, msgID, locationID, turn, data in msgs:
			item = ui.Item(None, index = index)
			item.tTime = res.formatTime(turn - currTurn)
			item.message = (sourceID, msgID, locationID, turn, data)
			item.tSourceID = sourceID
			if sourceID != OID_NONE and sourceID != player.oid:
				obj = client.get(sourceID, noUpdate = 1)
				if obj:
					item.tSource = getattr(obj, 'name', res.getUnknownName())
				else:
					item.tSource = _('N/A')
			else:
				item.tSource = _('-')
			item.tLocationID = locationID
			if locationID != OID_NONE:
				obj = client.get(locationID, noUpdate = 1)
				item.tLocation = getattr(obj, 'name', res.getUnknownName())
			else:
				item.tLocation = _('-')
			item.tMessage = messages.getMsgText(msgID, data)
			sev = messages.getMsgSeverity(msgID)
			if sev == messages.CRI:
				item.foreground = (0xd0, 0x20, 0x20)
			elif sev == messages.MAJ:
				item.foreground = (0xff, 0xff, 0x00)
			elif sev == messages.MIN:
				item.foreground = None
				if not self.showMIN:
					continue
			elif sev == messages.INFO:
				item.foreground = (0xc0, 0xc0, 0xc0)
				if not self.showInfo:
					continue
			index += 1
			items.append(item)
		self.win.vMessages.items = items
		self.win.vMessages.itemsChanged()
		self.win.vDelete.enabled = 0
Beispiel #2
0
 def show(self):
     player = client.getPlayer()
     items = []
     index = 0
     # copy
     msgs = player.messages[:]
     msgs.reverse()
     currTurn = client.getTurn()
     for sourceID, msgID, locationID, turn, data in msgs:
         item = ui.Item(None, index=index)
         item.tTime = res.formatTime(turn - currTurn)
         item.message = (sourceID, msgID, locationID, turn, data)
         item.tSourceID = sourceID
         if sourceID != OID_NONE and sourceID != player.oid:
             obj = client.get(sourceID, noUpdate=1)
             if obj:
                 item.tSource = getattr(obj, 'name', res.getUnknownName())
             else:
                 item.tSource = _('N/A')
         else:
             item.tSource = _('-')
         item.tLocationID = locationID
         if locationID != OID_NONE:
             obj = client.get(locationID, noUpdate=1)
             item.tLocation = getattr(obj, 'name', res.getUnknownName())
         else:
             item.tLocation = _('-')
         item.tMessage = messages.getMsgText(msgID, data)
         sev = messages.getMsgSeverity(msgID)
         if sev == messages.CRI:
             item.foreground = (0xd0, 0x20, 0x20)
         elif sev == messages.MAJ:
             item.foreground = (0xff, 0xff, 0x00)
         elif sev == messages.MIN:
             item.foreground = None
             if not self.showMIN:
                 continue
         elif sev == messages.INFO:
             item.foreground = (0xc0, 0xc0, 0xc0)
             if not self.showInfo:
                 continue
         index += 1
         items.append(item)
     self.win.vMessages.items = items
     self.win.vMessages.itemsChanged()
     self.win.vDelete.enabled = 0
	def onForumSelected(self, widget, action, data):
		selItem = self.win.vForums.selection[0]
		if selItem.tObjID == OID_NONE:
			# select last valid
			for item in self.win.vForums.items:
				if item.tObjID == self.selectedObjID and \
					item.tForum == self.selectedForum:
						self.win.vForums.selectItem(item)
						break
			return
		self.selectedObjID = selItem.tObjID
		self.selectedForum = selItem.tForum
		self.selectedType = selItem.tType
		self.win.vNewTopic.enabled = 1
		self.win.vAllReaded.enabled = 1
		self.win.vDeleteAll.enabled = 1
		player = client.getPlayer()
		playerid = player.oid
		objMessages = client.get(selItem.tObjID)._messages
		ids = objMessages.keys()
		ids.sort()
		ids.reverse()
		topics = []
		items = []
		for messageID in ids:
			message = objMessages[messageID]
			if message["forum"] == selItem.tForum:
				# ignore by universe, local (private messages), or galaxy
				if selItem.tObjID == OID_UNIVERSE:
					if message["sender"] in self.uignore:
						continue;
				elif selItem.tObjID == playerid:
					if message["sender"] in self.lignore:
						continue;
				else:
					if message["sender"] in self.gignore:
						continue;
				# regenerate topics for messages with data
				if message.has_key("data") and message["topic"] == "EVENT":
					sourceID, msgID, locationID, turn, data = message["data"]
					message["topic"] = messages.getMsgText(msgID, data).split("\n")[0]
				topic = message["topic"]
				item = ui.Item(topic)
				if topic not in topics:
					topics.append(topic)
					#item = ui.Item(topic, tObjID = selItem.tObjID, tForum = selItem.tForum,
					#	tMgsId = -1, font = "normal-bold")
					#items.append(item)
				if message.has_key("data"):
					sourceID, msgID, locationID, turn, data = message["data"]
					item.tLocationID = locationID
					item.tSourceID = sourceID
					obj = client.get(sourceID, noUpdate = 1, publicOnly = 1)   #Custom name in "sender"
					if hasattr(obj,'customname') and obj.customname:
						item.tSender = _('"%s"') % obj.customname
					else:					
						item.tSender = message["sender"]
					foreground = gdata.sevColors[messages.getMsgSeverity(msgID)]
					if message["readed"]:
						state = _(" ")
					else:
						state = _("N")
				else:
					item.tSender = message["sender"]
					if message["readed"]:
						foreground = gdata.sevColors[gdata.NONE]
						if message["replied"]:
							state = _("R")
						else:
							state = _(" ")
					else:
						foreground = gdata.sevColors[gdata.MIN]
						state = _("N")
				date = time.strftime(_("%m-%d %H:%M"), time.localtime(message["time"]))
				#if date == time.strftime(_("%Y-%m-%d"), time.localtime()):
				#	date = time.strftime(_("%H:%M"), time.localtime(message["time"]))
				item.tObjID = selItem.tObjID
				item.tForum = selItem.tForum
				item.tMsgID = messageID
				item.foreground = foreground
				item.tState = state
				item.tDate = date
				item.tDate_raw = message["time"]
				item.tType = selItem.tType
				items.append(item)
		self.win.vMessages.items = items
		self.win.vMessages.itemsChanged()
		if self.selectedForum != "EVENTS":
			# reset messages scrollbar position
			self.win.vMessages.bar.slider.position = 0
		self.win.vMessages.itemsChanged()
		self.win.vMessage.text = [""]
		self.win.vReply.enabled = 0
		self.win.vNewTopic.enabled = gdata.mailboxSpec[selItem.tType, selItem.tForum][1] != None
		self.win.vDelete.enabled = len(self.win.vMessages.selection) > 0
Beispiel #4
0
 def onForumSelected(self, widget, action, data):
     selItem = self.win.vForums.selection[0]
     if selItem.tObjID == OID_NONE:
         # select last valid
         for item in self.win.vForums.items:
             if item.tObjID == self.selectedObjID and \
              item.tForum == self.selectedForum:
                 self.win.vForums.selectItem(item)
                 break
         return
     self.selectedObjID = selItem.tObjID
     self.selectedForum = selItem.tForum
     self.selectedType = selItem.tType
     self.win.vNewTopic.enabled = 1
     self.win.vAllReaded.enabled = 1
     self.win.vDeleteAll.enabled = 1
     player = client.getPlayer()
     playerid = player.oid
     objMessages = client.get(selItem.tObjID)._messages
     ids = objMessages.keys()
     ids.sort()
     ids.reverse()
     topics = []
     items = []
     for messageID in ids:
         message = objMessages[messageID]
         if message["forum"] == selItem.tForum:
             # ignore by universe, local (private messages), or galaxy
             if selItem.tObjID == OID_UNIVERSE:
                 if message["sender"] in self.uignore:
                     continue
             elif selItem.tObjID == playerid:
                 if message["sender"] in self.lignore:
                     continue
             else:
                 if message["sender"] in self.gignore:
                     continue
             # regenerate topics for messages with data
             if message.has_key("data") and message["topic"] == "EVENT":
                 sourceID, msgID, locationID, turn, data = message["data"]
                 message["topic"] = messages.getMsgText(msgID,
                                                        data).split("\n")[0]
             topic = message["topic"]
             item = ui.Item(topic)
             if topic not in topics:
                 topics.append(topic)
                 #item = ui.Item(topic, tObjID = selItem.tObjID, tForum = selItem.tForum,
                 #	tMgsId = -1, font = "normal-bold")
                 #items.append(item)
             if message.has_key("data"):
                 sourceID, msgID, locationID, turn, data = message["data"]
                 item.tLocationID = locationID
                 item.tSourceID = sourceID
                 obj = client.get(sourceID, noUpdate=1,
                                  publicOnly=1)  #Custom name in "sender"
                 if hasattr(obj, 'customname') and obj.customname:
                     item.tSender = _('"%s"') % obj.customname
                 else:
                     item.tSender = message["sender"]
                 foreground = gdata.sevColors[messages.getMsgSeverity(
                     msgID)]
                 if message["readed"]:
                     state = _(" ")
                 else:
                     state = _("N")
             else:
                 item.tSender = message["sender"]
                 if message["readed"]:
                     foreground = gdata.sevColors[gdata.NONE]
                     if message["replied"]:
                         state = _("R")
                     else:
                         state = _(" ")
                 else:
                     foreground = gdata.sevColors[gdata.MIN]
                     state = _("N")
             date = time.strftime(_("%m-%d %H:%M"),
                                  time.localtime(message["time"]))
             #if date == time.strftime(_("%Y-%m-%d"), time.localtime()):
             #	date = time.strftime(_("%H:%M"), time.localtime(message["time"]))
             item.tObjID = selItem.tObjID
             item.tForum = selItem.tForum
             item.tMsgID = messageID
             item.foreground = foreground
             item.tState = state
             item.tDate = date
             item.tDate_raw = message["time"]
             item.tType = selItem.tType
             items.append(item)
     self.win.vMessages.items = items
     self.win.vMessages.itemsChanged()
     if self.selectedForum != "EVENTS":
         # reset messages scrollbar position
         self.win.vMessages.bar.slider.position = 0
     self.win.vMessages.itemsChanged()
     self.win.vMessage.text = [""]
     self.win.vReply.enabled = 0
     self.win.vNewTopic.enabled = gdata.mailboxSpec[
         selItem.tType, selItem.tForum][1] != None
     self.win.vDelete.enabled = len(self.win.vMessages.selection) > 0