/usr/share/games/tpclient-pywx/windows/main/winIdleFinder.py is in tpclient-pywx 0.3.1.1-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | """\
This module contains the idle objects finder display.
"""
# wxPython imports
import wx
import wx.gizmos
#from wx import *
import wx.lib.anchors
# Local imports
from windows.winBase import winReportXRC, ShiftMixIn
from windows.xrc.winIdleFinder import IdleFinderBase
# Shows messages from the game system to the player.
from extra.StateTracker import TrackerObject
# tp imports
from tp.netlib.objects import Object, OrderDescs
from tp.netlib.objects.ObjectExtra.Universe import Universe
from tp.netlib.objects.ObjectExtra.Galaxy import Galaxy
from tp.netlib.objects.ObjectExtra.StarSystem import StarSystem
from tp.netlib.objects.ObjectExtra.Planet import Planet
from tp.netlib.objects.ObjectExtra.Fleet import Fleet
class winIdleFinder(winReportXRC, IdleFinderBase, TrackerObject):
title = _("Objects Without Orders")
def __init__(self, application, parent):
IdleFinderBase.__init__(self, parent)
winReportXRC.__init__(self, application, parent)
self.application = application
self.oid = -1
# Create a panel for the current window.
self.idlelist.InsertColumn(0, "Item ID", width = 100)
self.idlelist.InsertColumn(1, "Item Name", width = 200)
self.idlelist.InsertColumn(2, "Item Type", width = 100)
self.ascending = 1
self.Bind(wx.EVT_SHOW, self.OnShow)
self.Bind(wx.EVT_ACTIVATE, self.OnShow)
self.idlelist.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.SelectObject)
self.idlelist.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
def OnShow(self, evt):
"""\
Runs when the window is shown.
"""
self.idlelist.DeleteAllItems()
numinlist = 0
universe = self.application.cache.objects.keys()
for object in universe:
numorders = 0
# The object must have an owner to have orders
if not hasattr(self.application.cache.objects[object], "owner"):
continue
# Only show objects owned by this player
if self.application.cache.objects[object].owner != self.application.cache.players[0].id:
continue
if object in self.application.cache.orders.keys():
# Find any orders for this object
for listpos, node in enumerate(self.application.cache.orders[object]):
numorders = numorders + 1
# If the object has no orders, add it to the list
if numorders == 0:
self.idlelist.InsertStringItem(numinlist, "%d" % object)
self.idlelist.SetStringItem(numinlist, 1, self.application.cache.objects[object].name)
self.idlelist.SetItemData(numinlist, object)
# Determine object's type
if isinstance(self.application.cache.objects[object], Universe):
self.idlelist.SetStringItem(numinlist, 2, "Universe")
elif isinstance(self.application.cache.objects[object], Galaxy):
self.idlelist.SetStringItem(numinlist, 2, "Galaxy")
elif isinstance(self.application.cache.objects[object], StarSystem):
self.idlelist.SetStringItem(numinlist, 2, "System")
elif isinstance(self.application.cache.objects[object], Planet):
self.idlelist.SetStringItem(numinlist, 2, "Planet")
elif isinstance(self.application.cache.objects[object], Fleet):
self.idlelist.SetStringItem(numinlist, 2, "Fleet")
else:
self.idlelist.SetStringItem(numinlist, 2, "Unknown")
numinlist = numinlist + 1
def Sort(self, d1, d2):
data1 = self.GetColData(d1, self.col)
data2 = self.GetColData(d2, self.col)
if data1 == data2:
return 0
elif data1 > data2:
return self.ascending*1
else:
return self.ascending*-1
def GetColData(self, obj, col):
if col == 0:
return obj
elif col == 1:
return self.application.cache.objects[obj].name.lower()
elif col == 2:
return self.application.cache.objects[obj].subtype
def OnColClick(self, event):
# Reverse sort order, then re-sort, when list column heading is clicked.
self.col = event.GetColumn()
self.ascending *= -1
self.idlelist.SortItems(self.Sort)
def OnClose(self, evt):
"""\
Runs when the window is closed.
"""
self.Hide()
# Config Functions (required by winBase.py) -----------------------------------------------------------------------------
def ConfigDefault(self, config=None):
"""\
Fill out the config with defaults (if the options are not valid or nonexistant).
"""
return {}
def ConfigSave(self):
"""\
Returns the configuration of the Window (and it's children).
"""
return {}
def ConfigLoad(self, config={}):
"""\
Loads the configuration of the Window (and it's children).
"""
pass
def ConfigUpdate(self):
"""\
Updates the config details using external sources.
"""
pass
def ConfigDisplay(self, panel, sizer):
"""\
Display a config panel with all the config options.
"""
pass
def ConfigDisplayUpdate(self, evt):
"""\
Update the Display because it's changed externally.
"""
pass
def SelectObject(self, id):
"""
Called to select an object.
"""
TrackerObject.SelectObject(self, int(id.GetText()))
|