Issues (229)

client/osci/dialog/StarSystemDlg.py (3 issues)

1
#
2
#  Copyright 2001 - 2016 Ludek Smid [http://www.ospace.net/]
3
#
4
#  This file is part of Outer Space.
5
#
6
#  Outer Space is free software; you can redistribute it and/or modify
7
#  it under the terms of the GNU General Public License as published by
8
#  the Free Software Foundation; either version 2 of the License, or
9
#  (at your option) any later version.
10
#
11
#  Outer Space is distributed in the hope that it will be useful,
12
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
#  GNU General Public License for more details.
15
#
16
#  You should have received a copy of the GNU General Public License
17
#  along with Outer Space; if not, write to the Free Software
18
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
#
20
21
import pygameui as ui
22
from osci import client, res, gdata
23
from osci.SystemMapWidget import SystemMapWidget
24
from NewTaskDlg import NewTaskDlg
25
from StructTaskDlg import StructTaskDlg
26
from RenameSysDlg import RenameSysDlg
27
from TechInfoDlg import TechInfoDlg
28
from ConfirmDlg import ConfirmDlg
29
from BuoyDlg import BuoyDlg
30
from ConstructionDlg import ConstructionDlg
31
from FleetRedirectionDlg import FleetRedirectionDlg
32
from FleetMassRedirectionDlg import FleetMassRedirectionDlg
33
from MinefieldDlg import MinefieldDlg
34
from ChangeQtyDlg import ChangeQtyDlg
35
from LocateDlg import LocateDlg
36
import ige
37
import ige.ospace.Const as Const
38
from ige.ospace import Rules
39
from ige import log
40
import math
41
import Utils
42
43
INFO_NONE = 0
44
INFO_TASK = 1
45
INFO_SLOT = 2
46
INFO_PLANET = 3
47
48
class StarSystemDlg:
49
50
    def __init__(self, app):
51
        self.wormhole = 0
52
        self.app = app
53
        self.createUI()
54
        self.newTaskDlg = NewTaskDlg(self.app)
55
        self.structTaskDlg = StructTaskDlg(self.app)
56
        self.renameSysDlg = RenameSysDlg(self.app)
57
        self.techInfoDlg = TechInfoDlg(app)
58
        self.confirmDlg = ConfirmDlg(app)
59
        self.changeQtyDlg = ChangeQtyDlg(app)
60
        self.constructionDlg = ConstructionDlg(app)
61
        self.minefieldDlg = MinefieldDlg(app)
62
        self.locateDlg = LocateDlg(app)
63
        self.buoyDlg = BuoyDlg(app)
64
        self.fleetRedirectionDlg = FleetRedirectionDlg(app)
65
        self.fleetMassRedirectionDlg = FleetMassRedirectionDlg(app)
66
67
        self.planetID = None
68
        self.systemID = None
69
        self.wormhole = None
70
        self.plInfoType = None
71
        self.plInfoTypeSelected = None
72
        self.plInfoData = None
73
        self.plInfoDataSelected = None
74
        self.playerOwnsSomePlanet = False
75
76
    def display(self, objID):
77
        # set initial state
78
        obj = client.get(objID, noUpdate = 1)
79
        if obj.type == Const.T_PLANET:
80
            self.systemID = obj.compOf
81
            self.planetID = objID
82
        elif obj.type in (Const.T_SYSTEM, Const.T_WORMHOLE):
83
            self.systemID = objID
84
            self.planetID = None
85
            if obj.type == Const.T_WORMHOLE:
86
                self.wormhole = 1
87
                self.win.vSFWHExit.tags=['sys']
88
                self.win.vSRedirect.tags=['hidden']
89
        else:
90
            raise 'Unsupported type of object %d' % obj.type
91
        self.plInfoType = INFO_PLANET
92
        self.plInfoTypeSelected = INFO_PLANET
93
        self.plInfoData = None
94
        self.plInfoDataSelected = None
95
        #
96
        self.win.vSystemMap.systemID = self.systemID
97
        self.win.vSystemMap.precompute()
98
99
        # check, if player owns at least one planet in system
100
        self.playerOwnsSomePlanet = False
101
        playerID = client.getPlayerID()
102
        system = client.get(self.systemID, noUpdate = True)
103
        if hasattr(system, 'planets'):
104
            for planetID in system.planets:
105
                planet = client.get(planetID, noUpdate = True)
106
                if getattr(planet, "owner", None) == playerID:
107
                    self.playerOwnsSomePlanet = True
108
                    break
109
110
        # show window
111
        if not self.win.visible:
112
            self.win.show()
113
        # display planet or system info
114
        self.update()
115
        # register for updates
116
        if self not in gdata.updateDlgs:
117
            gdata.updateDlgs.append(self)
118
119
    def hide(self):
120
        self.win.setStatus(_("Ready."))
121
        self.win.hide()
122
        # unregister updates
123
        if self in gdata.updateDlgs:
124
            gdata.updateDlgs.remove(self)
125
126
    def update(self):
127
        if self.win.visible:
128
            system = client.get(self.systemID,noUpdate =1)
129
            name = getattr(system,'name',res.getUnknownName());
130
            if gdata.config.defaults.showcoords == 'yes':
131
                self.win.title = _('System: %s [%.02f, %.02f]') % (name,system.x,system.y)
132
            else:
133
                self.win.title = _('System: %s') % name
134
            # clean up info area
135
            self.plInfoType = INFO_PLANET
136
            self.plInfoData = None
137
            if self.planetID:
138
                self.showPlanet()
139
            else:
140
                self.showSystem()
141
            self.win.vSystemMap.precompute()
142
143
    def appendTechIcon(self, index, planet, task, items, extraSlot = False, setIndex = True):
144
        if index < planet.plSlots:
145
            shift = res.whiteShift
146
        else:
147
            shift = res.redShift
148
149
        if type(task) == int:
150
            imgID = task
151
        else:
152
            imgID = task.techID + shift
153
154
        if setIndex:
155
            indexToSet = index
156
        else:
157
            indexToSet = None
158
159
        icons = ((res.getTechImg(imgID), ui.ALIGN_NONE),)
160
        item = ui.Item(None, icons = icons, index = indexToSet, extraSlot = extraSlot)
161
        items.append(item)
162
163
    def showPlanet(self):
164
        self.win.setTagAttr('pl', 'visible', 1)
165
        self.win.setTagAttr('sys', 'visible', 0)
166
        self.win.setTagAttr('hidden', 'visible', 0)
167
        planet = client.get(self.planetID, noUpdate = 1)
168
        player = client.getPlayer()
169
170
        if hasattr(planet, 'revoltLen') and planet.revoltLen > 0:
171
            self.win.vPName.text = _('Planet %s: POPULATION IS REVOLTING') % \
172
                getattr(planet, 'name', res.getUnknownName())
173
        elif hasattr(planet, 'morale') and hasattr(planet, "morale"):
174
            prodState = gdata.moraleStates[Rules.moraleProdBonus[int(planet.morale / Rules.moraleProdStep)]]
175
            self.win.vPName.text = _('Planet %s: %s') % \
176
                (getattr(planet, 'name', res.getUnknownName()), _(prodState))
177
        else:
178
            self.win.vPName.text = _('Planet %s') % \
179
                getattr(planet, 'name', res.getUnknownName())
180
            self.win.vPName.foreground = None
181
        # structures
182
        items = []
183
        if hasattr(planet, 'slots'):
184
            index = 0
185
            for struct in planet.slots:
186
                tech = client.getTechInfo(struct[Const.STRUCT_IDX_TECHID])
187
                icons = [(res.getTechImg(struct[Const.STRUCT_IDX_TECHID]), ui.ALIGN_NONE)]
188
                if not struct[Const.STRUCT_IDX_STATUS] & Const.STRUCT_STATUS_ON:
189
                    icons.append((res.structOffImg, ui.ALIGN_NE))
190
                elif struct[Const.STRUCT_IDX_STATUS] & ~Const.STRUCT_STATUS_ON & ~Const.STRUCT_STATUS_REPAIRING:
191
                    icons.append((res.structProblemImg, ui.ALIGN_NE))
192
                item = ui.Item(None, icons = icons, tooltip = tech.name, statustip = tech.name, index = index,
193
                    align = ui.ALIGN_W, techID = struct[Const.STRUCT_IDX_TECHID])
194
                items.append(item)
195
                index += 1
196
197
            # add production queue items to planet slots
198
            if hasattr(planet, 'prodQueue'):
199
                for task in planet.prodQueue:
200
                    if not task.isShip and self.planetID == task.targetID and task.demolishStruct == 0:
201
                        tech = client.getFullTechInfo(task.techID)
202
                        if tech.isStructure:
203
                            for i in range(0, task.quantity):
204
                                self.appendTechIcon(index, planet, task, items, False, False)
205
                                index += 1
206
207
            # add production queue items from other planets to this planet slots
208
            system = client.get(self.systemID, noUpdate = 1)
209
            if hasattr(system, "planets"):
210
                for aPlanetID in system.planets:
211
                    if aPlanetID == self.planetID:
212
                        continue
213
                    aPlanet = client.get(aPlanetID, noUpdate = 1)
214
                    if hasattr(aPlanet, "prodQueue"):
215
                        for aTask in aPlanet.prodQueue:
216
                            if not aTask.isShip and self.planetID == aTask.targetID and aTask.demolishStruct == 0:
217
                                aTech = client.getFullTechInfo(aTask.techID)
218
                                if aTech.isStructure:
219
                                    taskQuantity = min(aTask.quantity,30) #30 is max displayable slots, including the line that "shouldn't be used" - fixes breakage of accidental million-slot build command!
220
                                    for i in range(0, taskQuantity):
221
                                        self.appendTechIcon(index, planet, aTask, items, False, False)
222
                                        index += 1
223
224
            while index < planet.plSlots:
225
                self.appendTechIcon(None, planet, 1, items)
226
                index += 1
227
228
            if planet.owner == player.oid and Rules.Tech.ADDSLOT3 in player.techs:
229
                while index < planet.plMaxSlots:
230
                    self.appendTechIcon(None, planet, 2, items, True)
231
                    index += 1
232
233
        self.win.vPSlots.items = items
234
        self.win.vPSlots.itemsChanged()
235
        # enable/disable button for moving and destroying structures
236
        # show / hide global queue selector
237
        if hasattr(planet, "owner") and planet.owner == client.getPlayerID():
238
            enabled = 1
239
            self.win.vQueueSelector.visible = 1
240
            self.win.vTaskTitleWithQueue.visible = 1
241
            self.win.vTaskTitleNoQueue.visible = 0
242
            self.win.vQueueSelector.text = _('Queue \"{0}\"'.format(res.globalQueueName(planet.globalQueue)))
243
        else:
244
            self.win.vQueueSelector.visible = 0
245
            self.win.vTaskTitleWithQueue.visible = 0
246
            self.win.vTaskTitleNoQueue.visible = 1
247
            enabled = 0
248
        self.win.vISOnOff.enabled = enabled
249
        self.win.vISDemolish.enabled = enabled
250
        self.win.vQueueSelector.enabled = enabled
251
        # construction queue
252
        items = []
253
        if hasattr(planet, 'prodQueue'):
254
            index = 0
255
            for task in planet.prodQueue:
256
                if task.isShip:
257
                    tech = player.shipDesigns[task.techID]
258
                    icons = ((res.getShipImg(tech.combatClass, tech.isMilitary), ui.ALIGN_NONE),)
259
                else:
260
                    tech = client.getFullTechInfo(task.techID)
261
                    icons = ((res.getTechImg(task.techID), ui.ALIGN_NONE),)
262
263
                if task.targetID != self.planetID:
264
                    mod = Rules.buildOnAnotherPlanetMod
265
                else:
266
                    mod = Rules.buildOnSamePlanetMod
267
268
                perc = 100.0 * task.currProd / (tech.buildProd * mod)
269
                if planet.effProdProd > 0:
270
                    if task.targetID != self.planetID:
271
                        etc = math.ceil(float(tech.buildProd * Rules.buildOnAnotherPlanetMod - task.currProd) / planet.effProdProd)
272
                    else:
273
                        etc = math.ceil(float(tech.buildProd - task.currProd) / planet.effProdProd)
274
                    text = _("%s") % res.formatTime(etc)
275
                else:
276
                    text = _('N/A')
277
                item = ui.Item(text, font = 'small', align = ui.ALIGN_NE, icons = icons, tooltip = tech.name, statustip = tech.name, index = index)
278
                if task.isShip:
279
                    item.background = None
280
                else:
281
                    item.background = (0x44, 0x44, 0x44)
282
                items.append(item)
283
                index += 1
284
            icons = ((res.getTechImg(1), ui.ALIGN_NONE),)
285
            item = ui.Item(_('New'), font = 'small-bold', align = ui.ALIGN_SW, icons = icons, index = None)
286
            items.append(item)
287
        self.win.vPQueue.items = items
288
        self.win.vPQueue.itemsChanged()
289
        # planet data
290
        self.win.vPPType.text = gdata.planetTypes[getattr(planet, 'plType', None)]
291
        self.win.vPDiameter.text = getattr(planet, 'plDiameter', '?')
292
        self.win.vPBioAbund.text = getattr(planet, 'plBio', '?')
293
        if hasattr(planet, 'plBio') and hasattr(planet, 'plEn'):
294
            spec = Rules.planetSpec[planet.plType]
295
            if spec.upgradeTo and planet.plEn >= spec.upgradeEnReqs[0] and \
296
                planet.plEn <= spec.upgradeEnReqs[1]:
297
                if planet.plBio >= spec.maxBio:
298
                    info = _('Planet downgrade limit %d, upgrade limit %d.\nCan be terraformed to a %s.') % (
299
                        spec.minBio,
300
                        spec.maxBio,
301
                        gdata.planetTypes[spec.upgradeTo]
302
                    )
303
                else:
304
                    info = _('Planet downgrade limit %d, upgrade limit %d.\nCan terraformed to a %s in the future.') % (
305
                        spec.minBio,
306
                        spec.maxBio,
307
                        gdata.planetTypes[spec.upgradeTo]
308
                    )
309
            else:
310
                info = _('Planet downgrade limit %d, upgrade limit %d.') % (spec.minBio, spec.maxBio)
311
        else:
312
            info = None
313
        self.win.vPBioAbund.tooltip = info
314
        self.win.vPBioAbund.statustip = info
315
        self.win.vPMinAbund.text = getattr(planet, 'plMin', '?')
316
        self.win.vPEnAbund.text = getattr(planet, 'plEn', '?')
317
        info = _("For average EMR level is %s.") % getattr(planet, 'plEn', '?')
318
        self.win.vPEnAbund.tooltip = info
319
        self.win.vPEnAbund.statustip = info
320
        # used slots
321
        if hasattr(planet, 'slots'):
322
            usedSlots = planet.plSlots - len(planet.slots)
323
        else:
324
            usedSlots = '?'
325
        self.win.vPSlotsAbund.text = _('%s / %s') % (
326
            usedSlots,
327
            getattr(planet, 'plSlots', '?'),
328
        )
329
        info = _('Planet has %s free, %s usable out of maximum %s slots .') % (
330
            usedSlots,
331
            getattr(planet, 'plSlots', '?'),
332
            getattr(planet, 'plMaxSlots', '?'),
333
        )
334
        self.win.vPSlotsAbund.tooltip = info
335
        self.win.vPSlotsAbund.statustip = info
336
        # colony data
337
        # population
338
        self.win.vPCPop.text = getattr(planet, 'storPop', '?')
339
        tip = _('Population: %s (max. %s, %+d last turn)') % (
340
            str(getattr(planet, 'storPop', '?')),
341
            str(getattr(planet, 'maxPop', '?')),
342
            getattr(planet, 'changePop', 0)
343
        )
344
        self.win.vPCPop.tooltip = tip
345
        self.win.vPCPop.statustip = tip
346
        # bio
347
        self.win.vPCStorBio.text = getattr(planet, 'storBio', '?')
348
        tip = _('Biomatter reserve: %s (max. %s, %+d last turn)') % (
349
            str(getattr(planet, 'storBio', '?')),
350
            str(getattr(planet, 'maxBio', '?')),
351
            getattr(planet, 'changeBio', 0),
352
        )
353
        self.win.vPCStorBio.tooltip = tip
354
        self.win.vPCStorBio.statustip = tip
355
        # en
356
        self.win.vPCStorEn.text = getattr(planet, 'storEn', '?')
357
        tip = _('Energy reserve: %s (max. %s, %+d last turn)') % (
358
            str(getattr(planet, 'storEn', '?')),
359
            str(getattr(planet, 'maxEn', '?')),
360
            getattr(planet, 'changeEn', 0),
361
        )
362
        self.win.vPCStorEn.tooltip = tip
363
        self.win.vPCStorEn.statustip = tip
364
        # prod & sci
365
        self.win.vPCUnempl.text = str(getattr(planet, 'unemployedPop', '?'))
366
        if hasattr(planet, "owner") and planet.owner == player.oid:
367
            moraleBonus = Rules.moraleProdBonus[int(planet.morale / Rules.moraleProdStep)]
368
            self.win.vPCProd.text = _("%d / %d") % (
369
                int(planet.effProdProd),
370
                planet.prodProd,
371
            )
372
            info = _("Effective / raw construction points. Empire efficiency %+d %%, %+d %% because of morale.") % (
373
                player.prodEff * 100 - 100,
374
                moraleBonus * 100,
375
            )
376
            self.win.vPCProd.statustip = info
377
            self.win.vPCProd.tooltip = info
378
        else:
379
            self.win.vPCProd.text = str(getattr(planet, 'prodProd', '?'))
380
        if hasattr(planet, "owner") and planet.owner == player.oid:
381
            moraleBonus = Rules.moraleProdBonus[int(planet.morale / Rules.moraleProdStep)]
382
            self.win.vPCSci.text = _("%d / %d") % (
383
                planet.effProdSci,
384
                planet.prodSci,
385
            )
386
            info = _("Effective / raw research points. Empire efficiency %+d %%, %+d %% because of morale.") % (
387
                player.sciEff * 100 - 100,
388
                moraleBonus * 100,
389
            )
390
            self.win.vPCSci.statustip = info
391
            self.win.vPCSci.tooltip = info
392
        else:
393
            self.win.vPCSci.text = str(getattr(planet, 'effProdSci', '?'))
394
        if hasattr(planet, 'plEnv'):
395
            maxVal = Rules.envInterval
396
            if planet.changeEnv > 0:
397
                time = int((maxVal - planet.plEnv) / planet.changeEnv)
398
                tip = _('Enviroment (%d / %d) is improving (%d per turn), %s turns to improve.') \
399
                    % (planet.plEnv, maxVal, planet.changeEnv, res.formatTime(time))
400
                self.win.vPCEnvStatus.foreground = None
401
            elif planet.changeEnv < 0:
402
                time = - int(planet.plEnv / planet.changeEnv)
403
                tip = _('Enviroment (%d / %d) is deteriorating (%d per turn), %s turns to deteriorate.') % \
404
                    (planet.plEnv, maxVal, -planet.changeEnv, res.formatTime(time))
405
                self.win.vPCEnvStatus.foreground = gdata.sevColors[gdata.CRI]
406
            else:
407
                tip = _('Enviroment (%d / %d) is stable.') % (planet.plEnv, maxVal)
408
                self.win.vPCEnvStatus.foreground = None
409
            if maxVal > 0:
410
                self.win.vPCEnvStatus.text = _('%d %%') % (planet.plEnv * 100 / maxVal)
411
            else:
412
                self.win.vPCEnvStatus.text = _('0 %')
413
            self.win.vPCEnvStatus.tooltip = tip
414
            self.win.vPCEnvStatus.statustip = tip
415
        else:
416
            self.win.vPCEnvStatus.foreground = None
417
            self.win.vPCEnvStatus.text = '?'
418
            self.win.vPCEnvStatus.tooltip = None
419
            self.win.vPCEnvStatus.statustip = None
420
        # morale
421
        if hasattr(planet, 'morale'):
422
            self.win.vPCMorale.text = _('%d / %d') % (
423
                planet.morale, planet.moraleTrgt)
424
        elif hasattr(planet, 'morale'):
425
            self.win.vPCMorale.text = _('%d') % planet.morale
426
        else:
427
            self.win.vPCMorale.text = _('?')
428
        if hasattr(planet, 'shield'):
429
            if not planet.shield:
430
                self.win.vPCShield.visible = False
431
            else:
432
                self.win.vPCShield.visible = True
433
            self.win.vPCShield.text = _('%d') % planet.shield
434
            shieldTip = True
435
            if hasattr(planet,'prevShield'):
436
                if planet.prevShield < 0: #server reset your data becuase you went to war
437
                                    shieldTip = False
438
            if hasattr(planet,'prevShield') and hasattr(planet,'maxShield') and shieldTip:
439
                delta = planet.shield - planet.prevShield
440
                if (planet.shield > planet.prevShield):
441
                    info = _('Shield (%d/%d) charged by %+d last turn.') % (
442
                    planet.shield,
443
                    planet.maxShield,
444
                    delta
445
                    )
446
                elif (planet.shield < planet.prevShield):
447
                    info = _('Shield (%d/%d) was damaged by %+d last turn.') % (
448
                    planet.shield,
449
                    planet.maxShield,
450
                    delta
451
                    )
452
                elif (planet.shield < planet.maxShield):
453
                    info = _('Shield (%d/%d) is unable to charge.') % (
454
                    planet.shield,
455
                    planet.maxShield,
456
                    )
457
                else:
458
                    info = _('Shield (%d/%d) is fully charged.') % (
459
                    planet.shield,
460
                    planet.maxShield,
461
                    )
462
            else:
463
                info = _('Shield (%d/unknown)') % (
464
                    planet.shield,
465
                )
466
            self.win.vPCShield.tooltip = info
467
            self.win.vPCShield.statustip = info
468
        else:
469
            self.win.vPCShield.text = _('?')
470
        if hasattr(planet, 'revoltLen') and planet.revoltLen > 0:
471
            self.win.vPCMorale.foreground = gdata.sevColors[gdata.CRI]
472
        else:
473
            self.win.vPCMorale.foreground = None
474
        if hasattr(planet, 'changeMorale'):
475
            if planet.changeMorale > 0:
476
                info = _('M rise %+d, Base %d + Build %d + Pop %d + Unemp %d = %d, revolt under %d.') % (
477
                    planet.changeMorale,planet.moraleModifiers[0],planet.moraleModifiers[1],planet.moraleModifiers[2],planet.moraleModifiers[3],planet.moraleModifiers[4], Rules.revoltThr,
478
                )
479
            elif planet.changeMorale < 0:
480
                info = _('M fall %+d, Base %d + Build %d + Pop %d + Unemp %d = %d, revolt under %d.') % (
481
                    planet.changeMorale,planet.moraleModifiers[0],planet.moraleModifiers[1],planet.moraleModifiers[2],planet.moraleModifiers[3],planet.moraleModifiers[4], Rules.revoltThr,
482
                )
483
            else:
484
                info = _('Morale is stable. Base %d + Build. %d + Pop. %d + Unemp %d = %d, revolt under %d.') % (
485
                    planet.moraleModifiers[0],planet.moraleModifiers[1],planet.moraleModifiers[2],planet.moraleModifiers[3],planet.moraleModifiers[4], Rules.revoltThr,
486
                )
487
            self.win.vPCMorale.tooltip = info
488
            self.win.vPCMorale.statustip = info
489
        # strategic resource
490
        if hasattr(planet, "plStratRes"):
491
            if planet.plStratRes:
492
                self.win.vPCSRes.visible = True
493
                self.win.vPCSRes.text = _(gdata.stratRes[planet.plStratRes])
494
            else:
495
                self.win.vPCSRes.visible = False
496
        else:
497
            self.win.vPCSRes.text = _("?")
498
        # show info
499
        self.showPlInfo()
500
501
    def showSystem(self):
502
        self.win.setTagAttr('pl', 'visible', 0)
503
        self.win.setTagAttr('sys', 'visible', 1)
504
        self.win.setTagAttr('hidden', 'visible', 0)
505
        system = client.get(self.systemID, noUpdate = 1)
506
        self.win.vSystemMap.activeObjID = self.systemID
507
        # star info
508
        if hasattr(system, 'starClass'):
509
            title = _('System overview for star %s [%s]') % (
510
                system.starClass[1:],
511
                gdata.starTypes[system.starClass[0]],
512
            )
513
        else:
514
            title = _('System overview')
515
        self.win.vSTitle.text = title
516
        player = client.getPlayer()
517
        # planets
518
        info = []
519
        tStorBio = 0
520
        tChangeBio = 0
521
        tStorEn = 0
522
        tChangeEn = 0
523
        tProdProd = 0
524
        tProdSci = 0
525
        hasPlanet = 0
526
        if hasattr(system, 'planets'):
527
            for planetID in system.planets:
528
                planet = client.get(planetID, noUpdate = 1)
529
                owner = res.getUnknownName()
530
                #rel = Const.REL_UNDEF
531
                ownerID = Const.OID_NONE
532
                if hasattr(planet, 'owner'):
533
                    ownerID = planet.owner
534
                    #if planet.owner != Const.OID_NONE:
535
                    if planet.owner == Const.OID_NONE:
536
                        #rel = client.getRelationTo(planet.owner)
537
                    #else:
538
                        owner = _('[Nobody]')
539
                if hasattr(planet, 'prodQueue'):
540
                    if planet.prodQueue:
541
                        item = planet.prodQueue[0]
542
                        if item.isShip:
543
                            tech = client.getPlayer().shipDesigns[item.techID]
544
                        else:
545
                            tech = client.getTechInfo(item.techID)
546
                        constrInfo = _('%d x %s') % (item.quantity, tech.name)
547
                    else:
548
                        constrInfo = _('-')
549
                else:
550
                    constrInfo = '?'
551
                # used slots
552
                if hasattr(planet, 'slots'):
553
                    usedSlots = planet.plSlots - len(planet.slots)
554
                else:
555
                    usedSlots = '?'
556
                item = ui.Item(
557
                    getattr(planet, 'name', res.getUnknownName()).split(' ')[-1],
558
                    plType = gdata.planetTypes[getattr(planet, 'plType', None)],
559
                    plBio = getattr(planet, 'plBio', '?'),
560
                    plMin = getattr(planet, 'plMin', '?'),
561
                    plEn = getattr(planet, 'plEn', '?'),
562
                    storBio = getattr(planet, 'storBio', '?'),
563
                    changeBio = getattr(planet, 'changeBio', '?'),
564
                    storEn = getattr(planet, 'storEn', '?'),
565
                    changeEn = getattr(planet, 'changeEn', '?'),
566
                    constrInfo = constrInfo,
567
                    space = _('%s / %s') % (
568
                        usedSlots,
569
                        getattr(planet, 'plSlots', '?'),
570
                    ),
571
                    consci = _('%s / %s') % (
572
                        getattr(planet, 'effProdProd', '?'),
573
                        getattr(planet, 'effProdSci', '?'),
574
                    ),
575
                    planetID = planetID,
576
                    plOwner = owner,
577
                    #foreground = res.getFFColorCode(rel),
578
                    foreground = res.getPlayerColor(ownerID)
579
                )
580
                # show effective con/sci pts
581
                if hasattr(planet, "owner") and planet.owner == player.oid:
582
                    con = int(planet.effProdProd)
583
                    sci = int(planet.effProdSci)
584
                    item.consci = _("%d / %d") % (con, sci)
585
                    hasPlanet = 1
586
                if getattr(planet, 'plType', None) in ("G", "A"):
587
                    item.foreground = gdata.sevColors[gdata.DISABLED]
588
                info.append(item)
589
                # compute sums
590
                if hasattr(planet, 'owner') and planet.owner == client.getPlayerID():
591
                    tStorBio += getattr(planet, 'storBio', 0)
592
                    tChangeBio += getattr(planet, 'changeBio', 0)
593
                    tStorEn += getattr(planet, 'storEn', 0)
594
                    tChangeEn += getattr(planet, 'changeEn', 0)
595
                    tProdProd += getattr(planet, 'effProdProd', 0)
596
                    tProdSci += getattr(planet, 'effProdSci', 0)
597
598
        self.win.vSSOver.items = info
599
        self.win.vSSOver.itemsChanged()
600
        # show totals
601
        self.win.vSTStorBio.text = tStorBio
602
        if tChangeBio >= 0: foreground = None
603
        else: foreground = gdata.sevColors[gdata.CRI]
604
        self.win.vSTChangeBio.text = tChangeBio
605
        self.win.vSTChangeBio.foreground = foreground
606
        self.win.vSTStorEn.text = tStorEn
607
        if tChangeEn >= 0: foreground = None
608
        else: foreground = gdata.sevColors[gdata.CRI]
609
        self.win.vSTChangeEn.foreground = foreground
610
        self.win.vSTChangeEn.text = tChangeEn
611
        self.win.vSTConSci.text = _('%d / %d') % (tProdProd, tProdSci)
612
        # redirection
613
        if hasPlanet:
614
            if self.systemID in player.shipRedirections:
615
                targetName = getattr(client.get(player.shipRedirections[self.systemID]), "name", _("[Unknown]"))
616
                self.win.vSRedirect.text = _("Redirect to %s") % targetName
617
                self.win.vSRedirect.enabled = 1
618
                self.win.vSMassRedirect.enabled = 1
619
            else:
620
                self.win.vSRedirect.text = _("Redirection OFF")
621
                self.win.vSRedirect.enabled = 1
622
                self.win.vSMassRedirect.enabled = 1
623
        else:
624
            self.win.vSRedirect.text = _("Redirection OFF")
625
            self.win.vSRedirect.enabled = 0
626
            self.win.vSMassRedirect.enabled = 0
627
628
        if hasattr(player, "buoys"):
629
            if self.systemID in player.buoys.keys():
630
                self.win.vSBuoy.text = _("Edit buoy")
631
                self.win.vSDeleteBuoy.enabled = 1
632
            else:
633
                self.win.vSBuoy.text = _("Add buoy")
634
                self.win.vSDeleteBuoy.enabled = 0
635
        if hasattr(system, "minefield"):
636
            if len(system.minefield) > 0:
637
                self.win.vSViewMinefield.enabled = 1
638
            else:
639
                self.win.vSViewMinefield.enabled = 0
640
        else:
641
            self.win.vSViewMinefield.enabled = 0
642
643
    def showPlInfo(self):
644
        if self.plInfoType in [INFO_NONE, INFO_PLANET]:
645
            self.win.setTagAttr('task', 'visible', 0)
646
            self.win.setTagAttr('terra', 'visible', 1)
647
            self.win.setTagAttr('slot', 'visible', 0)
648
            self.win.vITitle.text = _('Planet Upgrade/Downgrade Data')
649
            planet = client.get(self.planetID, noUpdate = 1)
650
            pltype = getattr(planet, 'plType', None)
651
            if (pltype):
652
                spec = Rules.planetSpec[pltype]
653
                upgradeTo = spec.upgradeTo
654
                downgradeTo = spec.downgradeTo
655
                if upgradeTo:
656
                    self.win.vTerraUpEN.text = _('%d - %d EN' % (spec.upgradeEnReqs[0],spec.upgradeEnReqs[1]))
657
                    self.win.vTerraUpEnv.text = spec.maxBio
658
                    self.win.vTerraUpTo.text = gdata.planetTypes[upgradeTo]
659
                else:
660
                    self.win.vTerraUpEN.text = _('N/A')
661
                    self.win.vTerraUpEnv.text = _('N/A')
662
                    self.win.vTerraUpTo.text = _('N/A')
663
                if downgradeTo:
664
                    downgradeSpec = Rules.planetSpec[downgradeTo]
665
                    self.win.vTerraEN.text = _('%d - %d EN' % (downgradeSpec.upgradeEnReqs[0],downgradeSpec.upgradeEnReqs[1]))
666
                    self.win.vTerraDownEnv.text = spec.minBio
667
                    self.win.vTerraDownTo.text = gdata.planetTypes[downgradeTo]
668
                else:
669
                    self.win.vTerraEN.text = _('0 - 200 EN')
670
                    self.win.vTerraDownEnv.text = _('N/A')
671
                    self.win.vTerraDownTo.text = _('N/A')
672
            else:
673
                self.win.vTerraUpEN.text = _('?')
674
                self.win.vTerraUpEnv.text = _('?')
675
                self.win.vTerraUpTo.text = _('?')
676
                self.win.vTerraEN.text = _('?')
677
                self.win.vTerraDownEnv.text = _('?')
678
                self.win.vTerraDownTo.text = _('?')
679
        elif self.plInfoType == INFO_TASK:
680
            self.win.setTagAttr('task', 'visible', 1)
681
            self.win.setTagAttr('terra', 'visible', 0)
682
            self.win.setTagAttr('slot', 'visible', 0)
683
            planet = client.get(self.planetID, noUpdate = 1)
684
            task = planet.prodQueue[self.plInfoData]
685
            if task.isShip:
686
                tech = client.getPlayer().shipDesigns[task.techID]
687
                self.win.vITInfo.enabled = Utils.enableConstruction(client)
688
            else:
689
                self.win.vITInfo.enabled = True
690
                tech = client.getFullTechInfo(task.techID)
691
            self.win.vITitle.text = _('Task info: %s') % tech.name
692
693
            if task.targetID != self.planetID: mod = Rules.buildOnAnotherPlanetMod
694
            else: mod = Rules.buildOnSamePlanetMod
695
            perc = 100.0 * task.currProd / (tech.buildProd * mod)
696
            self.win.vITCompl.text = _('%d %% [%+d %%]') % (int(perc), task.changePerc / 100)
697
            if planet.effProdProd > 0:
698
                if task.targetID != self.planetID:
699
                    etc = math.ceil(float(tech.buildProd * Rules.buildOnAnotherPlanetMod - task.currProd) / planet.effProdProd)
700
                else:
701
                    etc = math.ceil(float(tech.buildProd - task.currProd) / planet.effProdProd)
702
                self.win.vITEtc.text = res.formatTime(etc)
703
            else:
704
                self.win.vITEtc.text = _('N/A')
705
            self.win.vITProd.text = _('%d / %d') % (task.currProd, tech.buildProd * mod)
706
            self.win.vITQuantity.text = _('%d') % task.quantity
707
            self.win.vITTarget.text = getattr(client.get(task.targetID, noUpdate = 1), 'name', res.getUnknownName())
708
            if hasattr(task, "demolishStruct") and task.demolishStruct != 0:
709
                structTech = client.getFullTechInfo(task.demolishStruct)
710
                self.win.vITTargetSlot.text = structTech.name
711
            else:
712
                self.win.vITTargetSlot.text = _("None")
713
714
            self.win.vITFirst.enabled = self.win.vITPrev.enabled = self.plInfoData > 0
715
            self.win.vITNext.enabled = self.win.vITLast.enabled = self.plInfoData < len(planet.prodQueue) - 1
716
            # self.win.vITInfo.enabled = not task.isShip
717
        elif self.plInfoType == INFO_SLOT:
718
            self.win.setTagAttr('task', 'visible', 0)
719
            self.win.setTagAttr('terra', 'visible', 0)
720
            self.win.setTagAttr('slot', 'visible', 1)
721
            planet = client.get(self.planetID, noUpdate = 1)
722
            struct = planet.slots[self.plInfoData]
723
            tech = client.getFullTechInfo(struct[Const.STRUCT_IDX_TECHID])
724
            self.win.vITitle.text = _('Slot info: %s') % tech.name
725
            if not struct[Const.STRUCT_IDX_STATUS] & ~Const.STRUCT_STATUS_ON:
726
                info = _('None')
727
                text = _('No problems.')
728
                self.win.vISStatus.foreground = None
729
            elif not struct[Const.STRUCT_IDX_STATUS] & Const.STRUCT_STATUS_ON:
730
                info = _('Switched OFF')
731
                text = _('Structure is switched OFF.')
732
                self.win.vISStatus.foreground = gdata.sevColors[gdata.CRI]
733
            else:
734
                self.win.vISStatus.foreground = gdata.sevColors[gdata.CRI]
735
                # extended status
736
                status = struct[Const.STRUCT_IDX_STATUS]
737
                info = ''
738
                text = ''
739
                if status & Const.STRUCT_STATUS_NOBIO:
740
                    text += _('Insufficient biomatter, ')
741
                    info += _('Bio/')
742
                if status & Const.STRUCT_STATUS_NOEN:
743
                    text += _('Insufficient energy, ')
744
                    info += _('En/')
745
                if status & Const.STRUCT_STATUS_NOPOP:
746
                    text += _('Insufficient workers, ')
747
                    info += _('Wrk/')
748
                if status & Const.STRUCT_STATUS_DETER:
749
                    text += _('Deteriorating, ')
750
                    info += _('Deter/')
751
                if status & Const.STRUCT_STATUS_REPAIRING:
752
                    text += _('Repairing, ')
753
                    info += _('Rep/')
754
                if status & Const.STRUCT_STATUS_NEW:
755
                    text += _('New structure, ')
756
                    info += _('New/')
757
                text = text[:-2]
758
                info = info[:-1]
759
            self.win.vISStatus.text = info
760
            self.win.vISStatus.statustip = text
761
            self.win.vISStatus.tooltip = text
762
            # this is taken from server's code (IPlanet)
763
            if planet.owner != Const.OID_NONE:
764
                player = client.get(planet.owner, noUpdate = 1)
765
                if hasattr(player, 'techs'):
766
                    techEff = Rules.techImprEff[player.techs.get(struct[Const.STRUCT_IDX_TECHID], Rules.techBaseImprovement)]
767
                else:
768
                    techEff = Rules.techImprEff[Rules.techBaseImprovement]
769
            else:
770
                techEff = Rules.techImprEff[Rules.techBaseImprovement]
771
            opStatus = struct[Const.STRUCT_IDX_OPSTATUS] / 100.0
772
            if hasattr(tech, 'maxHP') and planet.owner == client.getPlayerID():
773
                self.win.vISHp.text = _('%d / %d') % (struct[Const.STRUCT_IDX_HP], int(tech.maxHP * techEff))
774
            else:
775
                self.win.vISHp.text = _('%d / ?') % struct[Const.STRUCT_IDX_HP]
776
            if hasattr(tech, 'prodBioMod'):
777
                # bio
778
                b, m, e, d = tech.prodBioMod
779
                prodMod = (b * planet.plBio + m * planet.plMin + e * planet.plEn + d * 100) / 100
780
                bioPC = int(tech.prodBio * prodMod * techEff * opStatus) - int(tech.operBio * opStatus)
781
                # en
782
                b, m, e, d = tech.prodEnMod
783
                prodMod = (b * planet.plBio + m * planet.plMin + e * planet.plEn + d * 100) / 100
784
                enPC = int(tech.prodEn * prodMod * techEff * opStatus) - int(tech.operEn * opStatus)
785
                if bioPC < 0: self.win.vISBioPC.foreground = gdata.sevColors[gdata.CRI]
786
                else: self.win.vISBioPC.foreground = None
787
                self.win.vISBioPC.text = _('%d') % bioPC
788
                if enPC < 0: self.win.vISEnPC.foreground = gdata.sevColors[gdata.CRI]
789
                else: self.win.vISEnPC.foreground = None
790
                self.win.vISEnPC.text = _('%d') % enPC
791
                self.win.vISWorkers.text = _('%d') % int(tech.operWorkers * opStatus)
792
                # prod
793
                b, m, e, d = tech.prodProdMod
794
                prodMod = (b * planet.plBio + m * planet.plMin + e * planet.plEn + d * 100) / 100
795
                self.win.vISConstr.text = _('%d') % int(tech.prodProd * prodMod * techEff * opStatus)
796
                # sci
797
                b, m, e, d = tech.prodSciMod
798
                prodMod = (b * planet.plBio + m * planet.plMin + e * planet.plEn + d * 100) / 100
799
                self.win.vISSci.text = _('%d') % int(tech.prodSci * prodMod * techEff * opStatus)
800
                # op. status
801
                self.win.vISOpStatus.text = _("%d %%") % (opStatus * 100)
802
                info = _("Operational status of the structure.")
803
                self.win.vISOpStatus.tooltip = info
804
                self.win.vISOpStatus.statustip = info
805
            else:
806
                self.win.vISBioPC.text = '?'
807
                self.win.vISEnPC.text = '?'
808
                self.win.vISWorkers.text = '?'
809
                self.win.vISConstr.text = '? / ?'
810
                self.win.vISSci.text = "?"
811
            # buttons
812
            if hasattr(planet, "owner") and planet.owner == client.getPlayerID():
813
                self.win.vISPrev.enabled = self.win.vISFirst.enabled = self.plInfoData > 0
814
                self.win.vISNext.enabled = self.win.vISLast.enabled = self.plInfoData < len(planet.slots) - 1
815
            else:
816
                self.win.vISPrev.enabled = self.win.vISFirst.enabled = 0
817
                self.win.vISNext.enabled = self.win.vISLast.enabled = 0
818
        tChangeBio = 0
819
        tChangeEn = 0
820
        tProdProd = 0
821
        tProdSci = 0
822
        system = client.get(self.systemID, noUpdate = 1)
823
        # System Data Display
824
        if hasattr(system, 'planets'):
825
            for planetID in system.planets:
826
                planet = client.get(planetID, noUpdate = 1)
827
                # compute sums
828
                if hasattr(planet, 'owner') and planet.owner == client.getPlayerID():
829
                    tChangeBio += getattr(planet, 'changeBio', 0)
830
                    tChangeEn += getattr(planet, 'changeEn', 0)
831
                    tProdProd += getattr(planet, 'effProdProd', 0)
832
                    tProdSci += getattr(planet, 'effProdSci', 0)
833
        self.win.vSTPBio.text = tChangeBio
834
        self.win.vSTPEn.text = tChangeEn
835
        self.win.vSTPProd.text = tProdProd
836
        self.win.vSTPSci.text = tProdSci
837
838
    def onSelectMapObj(self, widget, action, data):
839
        self.win.vSystemMap.selectedObjID = data
840
        self.win.vSystemMap.activeObjID = data
841
        self.win.vPQueue.selectItem(None)
842
        self.win.vPSlots.selectItem(None)
843
        self.display(data)
844
845
    def onHighlightMapObj(self, widget, action, data):
846
        self.win.vSystemMap.activeObjID = data
847
        self.display(data)
848
849
    def onSelectPlanet(self, widget, action, data):
850
        if data.planetID != Const.OID_NONE:
851
            self.display(data.planetID)
852
853
    def onSlotHighlighted(self, widget, action, data):
854
        self.onItemHighlighted(data, INFO_SLOT)
855
856
    def onSlotSelected(self, widget, action, data):
857
        self.win.vPQueue.selectItem(None)
858
        if not data:
859
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
860
            self.plInfoData = self.plInfoDataSelected = None
861
        elif data.index != None:
862
            self.plInfoType = self.plInfoTypeSelected = INFO_SLOT
863
            self.plInfoData = self.plInfoDataSelected = data.index
864
        else:
865
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
866
            self.plInfoData = self.plInfoDataSelected = None
867
            if self.playerOwnsSomePlanet:
868
                # display task dialog (select stuctures only)
869
                self.structTaskDlg.display(self, self.planetID, data.extraSlot)
870
                self.win.vPSlots.selectItem(None)
871
        self.showPlInfo()
872
873
    def onSlotRSelected(self, widget, action, data):
874
        # unselect struct
875
        self.win.vPQueue.selectItem(None)
876
877
        if data and data.index != None:
878
            #do not permit upgrade non-owned structures
879
            if client.getPlayerID() == getattr(client.get(self.planetID, noUpdate = True), "owner", 0):
880
                self.structTaskDlg.display(self, self.planetID, False, data.techID)
881
                self.win.vPSlots.selectItem(None)
882
883
        self.plInfoType = self.plInfoTypeSelected = INFO_NONE
884
        self.plInfoData = self.plInfoDataSelected = None
885
        self.showPlInfo()
886
887
    def onQueueItemHighlighted(self, widget, action, data):
888
        self.onItemHighlighted(data, INFO_TASK)
889
890
    def onItemHighlighted(self, data, info_type):
891
        # unselect structure
892
        if not data or data.index is None:
893
            # unselected or new task
894
            self.plInfoType = self.plInfoTypeSelected
895
            self.plInfoData = self.plInfoDataSelected
896
        else:
897
            # info about task
898
            self.plInfoType = info_type
899
            self.plInfoData = data.index
900
        self.showPlInfo()
901
902
    def onQueueItemSelected(self, widget, action, data):
903
        # unselect structure
904
        self.win.vPSlots.selectItem(None)
905
        if not data:
906
            # unselected
907
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
908
            self.plInfoData = self.plInfoDataSelected = None
909
        elif data.index == None:
910
            # new task
911
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
912
            self.plInfoData = self.plInfoDataSelected = None
913
            self.win.vPQueue.selectItem(None)
914
            planet = client.get(self.planetID, noUpdate = 1)
915
            self.newTaskDlg.display(self, planet.effProdProd)
916
        else:
917
            # info about task
918
            self.plInfoType = self.plInfoTypeSelected = INFO_TASK
919
            self.plInfoData = self.plInfoDataSelected = data.index
920
        self.showPlInfo()
921
922
    def onTerraformDataSelect(self, widget, action, data):
923
        self.plInfoType = self.plInfoTypeSelected = INFO_PLANET
924
        self.plInfoData = self.plInfoDataSelected = None
925
        self.win.vPQueue.selectItem(None)
926
        self.showPlInfo()
927
928
    def onMoveStruct(self, widget, action, data):
929
        try:
930
            self.win.setStatus(_('Executing MOVE STRUCTURE command...'))
931
            planet = client.get(self.planetID, noUpdate = 1)
932
            planet.slots = client.cmdProxy.moveStruct(self.planetID, self.plInfoData, widget.data)
933
            self.plInfoData += widget.data
934
            self.plInfoDataSelected = self.plInfoData
935
            self.showPlanet()
936
            self.win.vPSlots.selectItem(self.win.vPSlots.items[self.plInfoData])
937
            self.win.setStatus(_('Command has been executed.'))
938
        except ige.GameException, e:
939
            self.win.setStatus(e.args[0])
940
            return
941
942 View Code Duplication
    def onMoveStructFirstLast(self, widget, action, data):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
943
        try:
944
            self.win.setStatus(_('Executing MOVE STRUCTURE command...'))
945
            planet = client.get(self.planetID, noUpdate = 1)
946
            if widget.data == -1:
947
                rel = -1 * self.plInfoData
948
                pos = 0
949
            else:
950
                rel = len(planet.slots) - self.plInfoData - 1
951
                pos = len(planet.slots) - 1
952
953
            planet.slots = client.cmdProxy.moveStruct(self.planetID, self.plInfoData, rel)
954
            self.plInfoData = self.plInfoDataSelected = pos
955
            self.showPlanet()
956
            self.win.vPSlots.selectItem(self.win.vPSlots.items[self.plInfoData])
957
            self.win.setStatus(_('Command has been executed.'))
958
        except ige.GameException, e:
959
            self.win.setStatus(e.args[0])
960
            return
961
962
    def onSwitchStructOnOff(self, widget, action, data):
963
        try:
964
            self.win.setStatus(_('Executing SWITCH STRUCTURE ON/OFF command...'))
965
            planet = client.get(self.planetID, noUpdate = 1)
966
            struct = planet.slots[self.plInfoData]
967
            planet.slots[self.plInfoData] = client.cmdProxy.setStructOn(self.planetID, self.plInfoData,
968
                not struct[Const.STRUCT_IDX_STATUS] & Const.STRUCT_STATUS_ON)
969
            self.showPlanet()
970
            self.win.vPSlots.selectItem(self.win.vPSlots.items[self.plInfoData])
971
            self.win.setStatus(_('Command has been executed.'))
972
        except ige.GameException, e:
973
            self.win.setStatus(e.args[0])
974
            return
975
976
    def onDemolishStruct(self, widget, action, data):
977
        self.confirmDlg.display(_("Demolish this structure?"),
978
            _("Yes"), _("No"), self.onDemolishStructConfirmed)
979
980
    def onDemolishStructConfirmed(self):
981
        try:
982
            self.win.setStatus(_('Executing DEMOLISH STRUCTURE command...'))
983
            planet = client.get(self.planetID, noUpdate = 1)
984
            planet.slots = client.cmdProxy.demolishStruct(self.planetID, self.plInfoData)
985
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
986
            self.plInfoData = self.plInfoDataSelected = None
987
            self.win.vPSlots.selectItem(None)
988
            self.win.setStatus(_('Command has been executed.'))
989
        except ige.GameException, e:
990
            self.win.setStatus(e.args[0])
991
            return
992
        self.showPlanet()
993
994
    def onStructInfo(self, widget, action, data):
995
        planet = client.get(self.planetID, noUpdate = 1)
996
        self.techInfoDlg.display(planet.slots[self.plInfoData][Const.STRUCT_IDX_TECHID])
997
998 View Code Duplication
    def onMoveTaskFirstLast(self, widget, action, data):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
999
        try:
1000
            self.win.setStatus(_('Executing MOVE TASK command...'))
1001
            planet = client.get(self.planetID, noUpdate = 1)
1002
1003
            if widget.data == -1:
1004
                rel = -1 * self.plInfoData
1005
                pos = 0
1006
            else:
1007
                rel = len(planet.prodQueue) - self.plInfoData - 1
1008
                pos = len(planet.prodQueue) - 1
1009
1010
            planet.prodQueue = client.cmdProxy.moveConstrItem(self.planetID, self.plInfoData, rel)
1011
            self.plInfoData = self.plInfoDataSelected = pos
1012
            self.showPlanet()
1013
            self.win.vPQueue.selectItem(self.win.vPQueue.items[self.plInfoData])
1014
            self.win.setStatus(_('Command has been executed.'))
1015
        except ige.GameException, e:
1016
            self.win.setStatus(e.args[0])
1017
            return
1018
1019
    def onMoveTask(self, widget, action, data):
1020
        try:
1021
            self.win.setStatus(_('Executing MOVE TASK command...'))
1022
            planet = client.get(self.planetID, noUpdate = 1)
1023
            planet.prodQueue = client.cmdProxy.moveConstrItem(self.planetID, self.plInfoData, widget.data)
1024
            self.plInfoData += widget.data
1025
            self.plInfoDataSelected = self.plInfoData
1026
            self.showPlanet()
1027
            self.win.vPQueue.selectItem(self.win.vPQueue.items[self.plInfoData])
1028
            self.win.setStatus(_('Command has been executed.'))
1029
        except ige.GameException, e:
1030
            self.win.setStatus(e.args[0])
1031
            return
1032
1033
    def onAbortTask(self, widget, action, data):
1034
        self.confirmDlg.display(_("Abort this construction task?"),
1035
            _("Yes"), _("No"), self.onAbortTaskConfirmed)
1036
1037
    def onQtyTask(self, widget, action, data):
1038
        planet = client.get(self.planetID, noUpdate = 1)
1039
        task = planet.prodQueue[self.plInfoData]
1040
        self.changeQtyDlg.display(task.quantity, self.onChangeQtyConfirmed)
1041
1042
    def onChangeQtyConfirmed(self):
1043
        if self.changeQtyDlg.quantity != None:
1044
            try:
1045
                self.win.setStatus(_('Executing CHANGE TASK command...'))
1046
                planet = client.get(self.planetID, noUpdate = 1)
1047
                player = client.getPlayer()
1048
                planet.prodQueue, player.stratRes = client.cmdProxy.changeConstruction(self.planetID, self.plInfoData, self.changeQtyDlg.quantity)
1049
                self.showPlanet()
1050
                self.win.setStatus(_('Command has been executed.'))
1051
            except ige.GameException, e:
1052
                self.win.setStatus(e.args[0])
1053
                return
1054
1055
    def onAbortTaskConfirmed(self):
1056
        try:
1057
            self.win.setStatus(_('Executing ABORT TASK command...'))
1058
            planet = client.get(self.planetID, noUpdate = 1)
1059
            player = client.getPlayer()
1060
            planet.prodQueue, player.stratRes = client.cmdProxy.abortConstruction(self.planetID, self.plInfoData)
1061
            self.plInfoType = self.plInfoTypeSelected = INFO_NONE
1062
            self.plInfoData = self.plInfoDataSelected = None
1063
            self.win.vPQueue.selectItem(None)
1064
            self.showPlanet()
1065
            self.win.setStatus(_('Command has been executed.'))
1066
        except ige.GameException, e:
1067
            self.win.setStatus(e.args[0])
1068
            return
1069
1070
    def onTaskInfo(self, widget, action, data):
1071
        planet = client.get(self.planetID, noUpdate = 1)
1072
        task = planet.prodQueue[self.plInfoData]
1073
        if not task.isShip:
1074
            self.techInfoDlg.display(task.techID)
1075
        else:
1076
            log.debug("Show ship info")
1077
            self.constructionDlg.selectedDesignID = task.techID;
1078
            self.constructionDlg.display()
1079
1080
    def onRenameSystem(self, widget, action, data):
1081
        self.renameSysDlg.display(self.systemID)
1082
1083
    def onRedirectFleets(self, widget, action, data):
1084
        self.fleetRedirectionDlg.display(self.systemID, self)
1085
1086
    def onMassRedirectFleets(self, widget, action, data):
1087
        self.fleetMassRedirectionDlg.display(self.systemID, self)
1088
1089
    def onFindWormholeExit(self, widget, action, data):
1090
        source = client.get(self.systemID, noUpdate = 1)
1091
        try:
1092
            dest = client.get(source.destinationOid)
1093
            try:
1094
                gdata.mainGameDlg.win.vStarMap.highlightPos = (dest.x, dest.y)
1095
                gdata.mainGameDlg.win.vStarMap.setPos(dest.x, dest.y)
1096
                self.hide()
1097
                return
1098
            except:
1099
                log.debug("Invalid object information during wormhole find. Obj. Type: ", dest.typeID)
1100
                self.win.setStatus(_("Destination not explored")) #don't show the end user this error
1101
        except:
1102
            self.win.setStatus(_("Destination not explored"))
1103
1104
    def onBuoy(self, widget, action, data):
1105
        buoyText = ""
1106
        buoyType = Const.BUOY_PRIVATE
1107
        player = client.getPlayer()
1108
        if hasattr(player, "buoys"):
1109
            if self.systemID in player.buoys.keys():
1110
                buoyText = player.buoys[self.systemID][0]
1111
                buoyType = player.buoys[self.systemID][1]
1112
        self.buoyDlg.display(buoyText, buoyType, self.onBuoyConfirmed)
1113
1114
    def onBuoyConfirmed(self):
1115
        try:
1116
            self.win.setStatus(_('Executing ADD BUOY command...'))
1117
            player = client.getPlayer()
1118
            player.buoys = client.cmdProxy.addBuoy(player.oid, self.systemID, self.buoyDlg.buoyText, self.buoyDlg.buoyType)
1119
            gdata.mainGameDlg.update()
1120
            self.win.vSystemMap.computeBuoy()
1121
            self.showSystem()
1122
            self.win.setStatus(_('Command has been executed.'))
1123
        except ige.GameException, e:
1124
            self.win.setStatus(e.args[0])
1125
            return
1126
1127
    def onDeleteBuoy(self, widget, action, data):
1128
        try:
1129
            self.win.setStatus(_('Executing DELETE BUOY command...'))
1130
            player = client.getPlayer()
1131
            player.buoys = client.cmdProxy.addBuoy(player.oid, self.systemID, "", 0)
1132
            gdata.mainGameDlg.update()
1133
            self.win.vSystemMap.computeBuoy()
1134
            self.showSystem()
1135
            self.win.setStatus(_('Command has been executed.'))
1136
        except ige.GameException, e:
1137
            self.win.setStatus(e.args[0])
1138
            return
1139
1140
    def onViewMinefield(self, widget, action, data):
1141
        self.minefieldDlg.display(self.systemID)
1142
1143
    def onLocateSystem(self, widget, action, data):
1144
        self.locateDlg.display(self.systemID, self)
1145
1146
    def onGlobalQueuesMenu(self, widget, action, data):
1147
        items = []
1148
        for queue in xrange(5):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable xrange does not seem to be defined.
Loading history...
1149
            items.append(ui.Item(res.globalQueueName(queue),tQue = queue))
1150
        self.queueWin.vGlobalQueues.items = items
1151
        self.queueWin.vGlobalQueues.itemsChanged()
1152
        self.queueWin.show()
1153
1154
    def onGlobalQueueSelect(self, widget, action, data):
1155
        if not self.queueWin.vGlobalQueues.selection:
1156
            return
1157
        newQueue = self.queueWin.vGlobalQueues.selection[0].tQue
1158
        player = client.getPlayer()
1159
        planet = client.get(self.planetID, noUpdate = 1)
1160
        try:
1161
            self.win.setStatus(_('Executing CHANGE PLANETS GLOBAL QUEUE command...'))
1162
            newQueue = client.cmdProxy.changePlanetsGlobalQueue(planet.oid, newQueue)
1163
            planet.globalQueue = newQueue
1164
            self.win.vQueueSelector.text = res.globalQueueName(newQueue)
1165
            self.queueWin.hide()
1166
            self.win.setStatus(_('Command has been executed.'))
1167
            self.update()
1168
        except ige.GameException, e:
1169
            self.win.setStatus(e.args[0])
1170
            return
1171
1172
    def onGlobalQueueCancel(self, widget, action, data):
1173
        self.queueWin.hide()
1174
1175
    def onCloseDlg(self, widget, action, data):
1176
        self.win.vSystemMap.systemID = None
1177
        self.win.vSystemMap.activeObjID = None
1178
        self.win.vSystemMap.selectedObjID = None
1179
        self.hide()
1180
1181
    def createUI(self):
1182
        w, h = gdata.scrnSize
1183
1184
        self.win = ui.Window(self.app,
1185
            modal = 1,
1186
            escKeyClose = 1,
1187
            titleOnly = w == 800 and h == 600,
1188
            movable = 0,
1189
            rect = ui.Rect((w - 800 - 4 * (w != 800)) / 2, (h - 600 - 4 * (h != 600)) / 2, 800 + 4 * (w != 800), 580 + 4 * (h != 600)),
1190
            layoutManager = ui.SimpleGridLM(),
1191
        )
1192
        # system
1193
        self.win.subscribeAction('*', self)
1194
        SystemMapWidget(self.win,
1195
            id = 'vSystemMap',
1196
            action = 'onSelectMapObj',
1197
            hoverAction = 'onHighlightMapObj',
1198
            layout = (0, 0, 40, 10)
1199
        )
1200
1201
        ui.Title(self.win, layout = (0, 27, 30, 1), id = 'vStatusBar',
1202
            align = ui.ALIGN_W)
1203
        ui.TitleButton(self.win, layout = (35, 27, 5, 1), text = _('Close'),
1204
            action = 'onCloseDlg')
1205
        ui.TitleButton(self.win, layout = (30, 27, 5, 1), text = _('Locate'),
1206
            action = 'onLocateSystem')
1207
        ## system
1208
        ui.Title(self.win, layout = (0, 10, 40, 1), id = 'vSTitle',
1209
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['sys'])
1210
        ui.Listbox(self.win, layout = (0, 11, 40, 14), id = 'vSSOver',
1211
            columns = [(_('Planet'), 'text', 5, ui.ALIGN_W), (_('Type'), 'plType', 3.5, ui.ALIGN_W),
1212
            (_('Env'), 'plBio', 1.5, ui.ALIGN_E), (_('Min'), 'plMin', 1.5, ui.ALIGN_E), (_('En'), 'plEn', 1.5, ui.ALIGN_E),
1213
            (_('Biomatter'), 'storBio', 3, ui.ALIGN_E), (_('+/-'), 'changeBio', 2, ui.ALIGN_E),
1214
            (_('Energy'), 'storEn', 3, ui.ALIGN_E), (_('+/-'), 'changeEn', 2, ui.ALIGN_E),
1215
            (_('Space'), 'space', 3, ui.ALIGN_E), (_('Con / Res'), 'consci', 4, ui.ALIGN_E),
1216
            (_('Constructing'), 'constrInfo', 9, ui.ALIGN_W)],
1217
            columnLabels = 1, tags = ['sys'], action = 'onSelectPlanet')
1218
        ui.Title(self.win, layout = (0, 25, 13, 1), text = _('Total'), align = ui.ALIGN_W,
1219
            font = 'normal-bold', tags = ['sys'])
1220
        ui.Title(self.win, layout = (13, 25, 3, 1), id = 'vSTStorBio', align = ui.ALIGN_E, font = 'normal', tags = ['sys'])
1221
        ui.Title(self.win, layout = (16, 25, 2, 1), id = 'vSTChangeBio', align = ui.ALIGN_E, font = 'normal-bold', tags = ['sys'])
1222
        ui.Title(self.win, layout = (18, 25, 3, 1), id = 'vSTStorEn', align = ui.ALIGN_E, font = 'normal', tags = ['sys'])
1223
        ui.Title(self.win, layout = (21, 25, 2, 1), id = 'vSTChangeEn', align = ui.ALIGN_E, font = 'normal-bold', tags = ['sys'])
1224
        ui.Title(self.win, layout = (23, 25, 7, 1), id = 'vSTConSci', align = ui.ALIGN_E, font = 'normal', tags = ['sys'])
1225
        ui.Title(self.win, layout = (30, 25, 10, 1), tags = ['sys'])
1226
        ui.Button(self.win, layout = (0, 26, 5, 1), text = _('Rename'),
1227
            id = 'vSRename', tags = ['sys'], action = 'onRenameSystem')
1228
        ui.Button(self.win, layout = (5, 26, 10, 1), text = _('Find Wormhole Exit'),
1229
            id = 'vSFWHExit', tags = ['hidden'], action = 'onFindWormholeExit')
1230
        ui.Button(self.win, layout = (5, 26, 10, 1), text = _('Redirection OFF'),
1231
            id = 'vSRedirect', tags = ['sys'], action = 'onRedirectFleets')
1232
        ui.Button(self.win, layout = (15, 26, 5, 1), text = _('Mass Redirect'),
1233
            id = 'vSMassRedirect', tags = ['sys'], action = 'onMassRedirectFleets')
1234
        ui.Button(self.win, layout = (20, 26, 5, 1), text = _('Add buoy'),
1235
            id = 'vSBuoy', tags = ['sys'], action = 'onBuoy')
1236
        ui.Button(self.win, layout = (25, 26, 5, 1), text = _('Delete buoy'),
1237
            id = 'vSDeleteBuoy', tags = ['sys'], action = 'onDeleteBuoy')
1238
        ui.Button(self.win, layout = (30, 26, 5, 1), text = _('View Minefield'),
1239
            id = 'vSViewMinefield', tags = ['sys'], action = 'onViewMinefield')
1240
        ## planet
1241
        ui.Title(self.win, layout = (0, 10, 20, 1), id = 'vPName',
1242
            align = ui.ALIGN_W,    font = 'normal-bold', tags = ['pl'])
1243
        ui.Title(self.win, layout = (20, 10, 20, 1), text = _('Structures'),
1244
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1245
        ui.ButtonArray(self.win, layout = (20, 11, 20, 6), id = 'vPSlots',
1246
            buttonSize = (2, 2), showSlider = 0, tags = ['pl'], action = 'onSlotSelected', rmbAction = 'onSlotRSelected', hoverAction = 'onSlotHighlighted')
1247
        ui.Title(self.win, layout = (20, 17, 12, 1), id = 'vTaskTitleWithQueue', text = _('Task queue'),
1248
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1249
        ui.TitleButton(self.win, layout = (32, 17, 8, 1), id = 'vQueueSelector', align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'], action = 'onGlobalQueuesMenu')
1250
        ui.Title(self.win, layout = (20, 17, 20, 1), id = 'vTaskTitleNoQueue', text = _('Task queue'),
1251
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1252
        ui.ButtonArray(self.win, layout = (20, 18, 20, 2), id = 'vPQueue',
1253
            buttonSize = (2, 2), showSlider = 0, tags = ['pl'], action = 'onQueueItemSelected', hoverAction = 'onQueueItemHighlighted')
1254
        ui.Label(self.win, layout = (0, 11, 5, 1), text = _('Planet type'),
1255
            align = ui.ALIGN_W, tags = ['pl'])
1256
        ui.Label(self.win, layout = (5, 11, 5, 1), id = 'vPPType',
1257
            align = ui.ALIGN_E,    tags = ['pl'])
1258
        ui.Label(self.win, layout = (10, 11, 5, 1), text = _('Diameter'),
1259
            align = ui.ALIGN_W, tags = ['pl'])
1260
        ui.Label(self.win, layout = (15, 11, 5, 1), id = 'vPDiameter',
1261
            align = ui.ALIGN_E, tags = ['pl'])
1262
        # environment
1263
        ui.Label(self.win, layout = (0, 12, 5, 2), id = 'vPBioAbund',
1264
            icons=[(res.getUIIcon('planet_biomatter'), ui.ALIGN_W)],
1265
            tooltipTitle=_("Environment"),
1266
            align = ui.ALIGN_NONE, tags = ['pl'])
1267
        # minerals
1268
        ui.Label(self.win, layout = (5, 12, 5, 2), id = 'vPMinAbund',
1269
            icons=[(res.getUIIcon('planet_minerals'), ui.ALIGN_W)],
1270
            tooltipTitle=_("Mineral abundance"),
1271
            align = ui.ALIGN_NONE, tags = ['pl'])
1272
        # en. abundance
1273
        ui.Label(self.win, layout = (10, 12, 5, 2), id = 'vPEnAbund',
1274
            icons=[(res.getUIIcon('planet_energy'), ui.ALIGN_W)],
1275
            tooltipTitle=_("Energy abundance"),
1276
            align = ui.ALIGN_NONE, tags = ['pl'])
1277
        # available space
1278
        ui.Label(self.win, layout = (15, 12, 5, 2), id = 'vPSlotsAbund',
1279
            icons=[(res.getUIIcon('planet_free_slots'), ui.ALIGN_W)],
1280
            tooltipTitle=_("Available space"),
1281
            align = ui.ALIGN_NONE, tags = ['pl'])
1282
        ## colony data
1283
        ui.Title(self.win, layout = (0, 14, 20, 1), text = _('Colony data'),
1284
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1285
        ui.Label(self.win, layout = (0, 15, 5, 2), id = 'vPCPop',
1286
            icons=[(res.getUIIcon('population'), ui.ALIGN_W)],
1287
            tooltipTitle=_("Population"),
1288
            align = ui.ALIGN_NONE, tags = ['pl'])
1289
        ui.Label(self.win, layout = (5, 15, 5, 2), id = 'vPCUnempl',
1290
            icons=[(res.getUIIcon('unemployed'), ui.ALIGN_W)],
1291
            tooltipTitle=_("Free workers"),
1292
            align = ui.ALIGN_NONE, tags = ['pl'])
1293
        ui.Label(self.win, layout = (10, 15, 5, 2), id = 'vPCStorBio',
1294
            icons=[(res.getUIIcon('bio_stored'), ui.ALIGN_W)],
1295
            tooltipTitle=_("Biomatter"),
1296
            align = ui.ALIGN_NONE, tags = ['pl'])
1297
        ui.Label(self.win, layout = (15, 15, 5, 2), id = 'vPCStorEn',
1298
            icons=[(res.getUIIcon('en_stored'), ui.ALIGN_W)],
1299
            tooltipTitle=_("Energy"),
1300
            align = ui.ALIGN_NONE, tags = ['pl'])
1301
1302
1303
        ui.Label(self.win, layout = (0, 18, 7, 2), id = 'vPCProd',
1304
            icons=[(res.getUIIcon('planet_cp_production'), ui.ALIGN_W)],
1305
            tooltipTitle=_("Construction pts"),
1306
            align = ui.ALIGN_NONE, tags = ['pl'])
1307
        ui.Label(self.win, layout = (7, 18, 7, 2), id = 'vPCSci',
1308
            icons=[(res.getUIIcon('planet_rp_production'), ui.ALIGN_W)],
1309
            tooltipTitle=_("Research pts"),
1310
            align = ui.ALIGN_NONE, tags = ['pl'])
1311
        ui.Label(self.win, layout = (14, 18, 6, 2), id = 'vPCMorale',
1312
            icons=[(res.getUIIcon('morale'), ui.ALIGN_W)],
1313
            tooltipTitle=_("Morale"),
1314
            align = ui.ALIGN_NONE, tags = ['pl'])
1315
1316
1317
        ui.Label(self.win, layout = (0, 21, 7, 2), id = 'vPCEnvStatus',
1318
            icons=[(res.getUIIcon('environment_status'), ui.ALIGN_W)],
1319
            tooltipTitle=_("Environment status"),
1320
            align = ui.ALIGN_NONE, tags = ['pl'])
1321
        ui.Label(self.win, layout = (7, 21, 7, 2), id = 'vPCShield',
1322
            icons=[(res.getUIIcon('planetary_shield'), ui.ALIGN_W)],
1323
            tooltipTitle=_("Planetary shield"),
1324
            align = ui.ALIGN_NONE, tags = ['pl'])
1325
        ui.Label(self.win, layout = (14, 21, 6, 2), id = 'vPCSRes',
1326
            icons=[(res.getUIIcon('strategic_resource'), ui.ALIGN_W)],
1327
            tooltipTitle=_("Strategic resource"),
1328
            align = ui.ALIGN_NONE, tags = ['pl'])
1329
        ui.Button(self.win, layout = (10, 23, 10, 1), text = _('Show Terraforming Data'),
1330
            tags = ['pl'], action = 'onTerraformDataSelect')
1331
        ui.Title(self.win, layout = (0, 24, 20, 1), text = _('System data'),
1332
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1333
        ui.Label(self.win, layout = (0, 25, 5, 2), id = 'vSTPBio',
1334
            icons=[(res.getUIIcon('system_biomatter'), ui.ALIGN_W)],
1335
            tooltipTitle=_("Net Bio +/-"),
1336
            align = ui.ALIGN_NONE, tags = ['pl'])
1337
        ui.Label(self.win, layout = (5, 25, 5, 2), id = 'vSTPEn',
1338
            icons=[(res.getUIIcon('system_energy'), ui.ALIGN_W)],
1339
            tooltipTitle=_("Net Energy +/-"),
1340
            align = ui.ALIGN_NONE, tags = ['pl'])
1341
        ui.Label(self.win, layout = (10, 25, 5, 2), id = 'vSTPProd',
1342
            icons=[(res.getUIIcon('system_cp_production'), ui.ALIGN_W)],
1343
            tooltipTitle=_("Net Construction"),
1344
            align = ui.ALIGN_NONE, tags = ['pl'])
1345
        ui.Label(self.win, layout = (15, 25, 5, 2), id = 'vSTPSci',
1346
            icons=[(res.getUIIcon('system_rp_production'), ui.ALIGN_W)],
1347
            tooltipTitle=_("Net Research"),
1348
            align = ui.ALIGN_NONE, tags = ['pl'])
1349
        ## info
1350
        ui.Title(self.win, layout = (20, 20, 20, 1), id = 'vITitle',
1351
            align = ui.ALIGN_W, font = 'normal-bold', tags = ['pl'])
1352
        # slot
1353
        ui.Label(self.win, layout = (20, 21, 5, 1), text = _('Hit points'),
1354
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1355
        ui.Label(self.win, layout = (25, 21, 5, 1), id = 'vISHp', align = ui.ALIGN_E,
1356
            tags = ['slot', 'pl'])
1357
        ui.Label(self.win, layout = (20, 22, 5, 1), text = _('Status'),
1358
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1359
        ui.Label(self.win, layout = (25, 22, 5, 1), id = 'vISOpStatus', align = ui.ALIGN_E,
1360
            tags = ['slot', 'pl'])
1361
        ui.Title(self.win, layout = (20, 23, 10, 1), text = _('Problems'),
1362
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1363
        ui.Label(self.win, layout = (20, 24, 10, 1), id = 'vISStatus', align = ui.ALIGN_W,
1364
            tags = ['slot', 'pl'])
1365
        ui.Label(self.win, layout = (30, 21, 5, 1), text = _('Biomatter p/c'),
1366
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1367
        ui.Label(self.win, layout = (35, 21, 5, 1), id = 'vISBioPC', align = ui.ALIGN_E,
1368
            tags = ['slot', 'pl'])
1369
        ui.Label(self.win, layout = (30, 22, 5, 1), text = _('Energy p/c'),
1370
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1371
        ui.Label(self.win, layout = (35, 22, 5, 1), id = 'vISEnPC', align = ui.ALIGN_E,
1372
            tags = ['slot', 'pl'])
1373
        ui.Label(self.win, layout = (30, 23, 5, 1), text = _('Constr pts'),
1374
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1375
        ui.Label(self.win, layout = (35, 23, 5, 1), id = 'vISConstr', align = ui.ALIGN_E,
1376
            tags = ['slot', 'pl'])
1377
        ui.Label(self.win, layout = (30, 24, 5, 1), text = _('Research pts'),
1378
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1379
        ui.Label(self.win, layout = (35, 24, 5, 1), id = 'vISSci', align = ui.ALIGN_E,
1380
            tags = ['slot', 'pl'])
1381
        ui.Label(self.win, layout = (30, 25, 5, 1), text = _('Workers'),
1382
            align = ui.ALIGN_W, tags = ['slot', 'pl'])
1383
        ui.Label(self.win, layout = (35, 25, 5, 1), id = 'vISWorkers', align = ui.ALIGN_E,
1384
            tags = ['slot', 'pl'])
1385
        ui.Button(self.win, layout = (20, 26, 2, 1), id = 'vISFirst', text = _('<<'),
1386
            tags = ['slot', 'pl'], action = 'onMoveStructFirstLast', data = -1,
1387
            tooltipTitle = _('Move structure to first slot'))
1388
        ui.Button(self.win, layout = (22, 26, 2, 1), id = 'vISPrev', text = _('<'),
1389
            tags = ['slot', 'pl'], action = 'onMoveStruct', data = -1,
1390
            tooltipTitle = _('Move structure to previous slot'))
1391
        ui.Button(self.win, layout = (24, 26, 2, 1), id = 'vISNext', text = _('>'),
1392
            tags = ['slot', 'pl'], action = 'onMoveStruct', data = 1,
1393
            tooltipTitle = _('Move structure to next slot'))
1394
        ui.Button(self.win, layout = (26, 26, 2, 1), id = 'vISLast', text = _('>>'),
1395
            tags = ['slot', 'pl'], action = 'onMoveStructFirstLast', data = 1,
1396
            tooltipTitle = _('Move structure to last slot'))
1397
        ui.Button(self.win, layout = (28, 26, 4, 1), text = _('ON/OFF'), id = 'vISOnOff',
1398
            tags = ['slot', 'pl'], action = 'onSwitchStructOnOff',
1399
            tooltipTitle = _('Switch structure ON or OFF'))
1400
        ui.Button(self.win, layout = (32, 26, 4, 1), text = _('Info'), id = 'vISTechInfo',
1401
            tags = ['slot', 'pl'], action = 'onStructInfo',
1402
            tooltipTitle = _('Show structure information'))
1403
        ui.Button(self.win, layout = (36, 26, 4, 1), text = _('Demolish'), id = 'vISDemolish',
1404
            tags = ['slot', 'pl'], action = 'onDemolishStruct',
1405
            tooltipTitle = _('Demolish structure'))
1406
        # terraform
1407
        ui.Label(self.win, layout = (20, 22, 9, 1), text = _('Class Range En. Abundance'),
1408
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1409
        ui.Label(self.win, layout = (30, 22, 5, 1), id = 'vTerraEN', align = ui.ALIGN_E,
1410
            tags = ['terra', 'pl'])
1411
        ui.Label(self.win, layout = (20, 23, 9, 1), text = _('Upgrade Range En. Abund.'),
1412
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1413
        ui.Label(self.win, layout = (30, 23, 5, 1), id = 'vTerraUpEN', align = ui.ALIGN_E,
1414
            tags = ['terra', 'pl'])
1415
        ui.Label(self.win, layout = (20, 24, 5, 1), text = _('Downgrade Env.'),
1416
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1417
        ui.Label(self.win, layout = (25, 24, 5, 1), id = 'vTerraDownEnv', align = ui.ALIGN_E,
1418
            tags = ['terra', 'pl'])
1419
        ui.Label(self.win, layout = (31, 24, 4, 1), text = _('Upgrade Env.'),
1420
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1421
        ui.Label(self.win, layout = (35, 24, 5, 1), id = 'vTerraUpEnv', align = ui.ALIGN_E,
1422
            tags = ['terra', 'pl'])
1423
        ui.Label(self.win, layout = (20, 25, 5, 1), text = _('Downgrade To?'),
1424
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1425
        ui.Label(self.win, layout = (25, 25, 5, 1), id = 'vTerraDownTo', align = ui.ALIGN_E,
1426
            tags = ['terra', 'pl'])
1427
        ui.Label(self.win, layout = (31, 25, 4, 1), text = _('Upgrade To?'),
1428
            align = ui.ALIGN_W, tags = ['terra', 'pl'])
1429
        ui.Label(self.win, layout = (35, 25, 5, 1), id = 'vTerraUpTo', align = ui.ALIGN_E,
1430
            tags = ['terra', 'pl'])
1431
        # task
1432
        ui.Label(self.win, layout = (20, 21, 5, 1), text = _('Complete'),
1433
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1434
        ui.Label(self.win, layout = (26, 21, 5, 1), id = 'vITCompl', align = ui.ALIGN_E,
1435
            tags = ['task', 'pl'])
1436
        ui.Label(self.win, layout = (31, 21, 3, 1), text = _('ETC'),
1437
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1438
        ui.Label(self.win, layout = (35, 21, 5, 1), id = 'vITEtc', align = ui.ALIGN_E,
1439
            tags = ['task', 'pl'])
1440
        ui.Label(self.win, layout = (20, 22, 6, 1), text = _('Construction pts'),
1441
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1442
        ui.Label(self.win, layout = (26, 22, 5, 1), id = 'vITProd', align = ui.ALIGN_E,
1443
            tags = ['task', 'pl'])
1444
        ui.Label(self.win, layout = (20, 24, 5, 1), text = _('Quantity'),
1445
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1446
        ui.Label(self.win, layout = (26, 24, 5, 1), id = 'vITQuantity', align = ui.ALIGN_E,
1447
            tags = ['task', 'pl'])
1448
        ui.Label(self.win, layout = (20, 25, 5, 1), text = _('Target planet'),
1449
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1450
        ui.Label(self.win, layout = (25, 25, 5, 1), id = 'vITTarget', align = ui.ALIGN_E,
1451
            tags = ['task', 'pl'])
1452
        ui.Label(self.win, layout = (30, 25, 4, 1), text = _('Target slot'),
1453
            align = ui.ALIGN_W, tags = ['task', 'pl'])
1454
        ui.Label(self.win, layout = (34, 25, 6, 1), id = 'vITTargetSlot', align = ui.ALIGN_W,
1455
            tags = ['task', 'pl'])
1456
        ui.Button(self.win, layout = (20, 26, 2, 1), id = 'vITFirst', text = _('<<'),
1457
            tags = ['task', 'pl'], action = 'onMoveTaskFirstLast',
1458
            tooltipTitle = _('Move task to first position in queue'), data = -1)
1459
        ui.Button(self.win, layout = (22, 26, 2, 1), id = 'vITPrev', text = _('<'),
1460
            tags = ['task', 'pl'], action = 'onMoveTask', data = -1,
1461
            tooltipTitle = _('Move task to previous position in queue'))
1462
        ui.Button(self.win, layout = (24, 26, 2, 1), id = 'vITNext', text = _('>'),
1463
            tags = ['task', 'pl'], action = 'onMoveTask', data = 1,
1464
            tooltipTitle = _('Move task to next position in queue'))
1465
        ui.Button(self.win, layout = (26, 26, 2, 1), id = 'vITLast', text = _('>>'),
1466
            tags = ['task', 'pl'], action = 'onMoveTaskFirstLast',
1467
            tooltipTitle = _('Move task to last position in queue'), data = 1)
1468
        ui.Button(self.win, layout = (28, 26, 4, 1), text = _('Quantity'),
1469
            tags = ['task', 'pl'], action = 'onQtyTask',
1470
            tooltipTitle = _('Change task quantity'))
1471
        ui.Button(self.win, layout = (32, 26, 4, 1), text = _('Info'), id = "vITInfo",
1472
            tags = ['task', 'pl'], action = 'onTaskInfo',
1473
            tooltipTitle = _('Show task informations'))
1474
        ui.Button(self.win, layout = (36, 26, 4, 1), text = _('Abort'),
1475
            tags = ['task', 'pl'], action = 'onAbortTask',
1476
            tooltipTitle = _('Abort task construction'))
1477
1478
        # Global queue selector window
1479
        width = 304  # 15 * 20 + 4
1480
        height = 144 # 7 * 20 + 4
1481
        self.queueWin = ui.Window(self.app,
1482
            modal = 1,
1483
            escKeyClose = 1,
1484
            titleOnly = 0,
1485
            movable = 0,
1486
            title = _("Select global queue"),
1487
            rect = ui.Rect((w - width) / 2, (h - height) / 2, width, height),
1488
            layoutManager = ui.SimpleGridLM(),
1489
        )
1490
        self.queueWin.subscribeAction('*', self)
1491
        # rename
1492
        ui.Listbox(self.queueWin, layout = (0, 0, 15, 5), id = 'vGlobalQueues', columnLabels = 0,
1493
            columns = ((None, 'text', 0, ui.ALIGN_W),), multiselection = 0)
1494
        # status bar + submit/cancel
1495
        ui.TitleButton(self.queueWin, layout = (10, 5, 5, 1), text = _("Select"), action = 'onGlobalQueueSelect')
1496
        ui.TitleButton(self.queueWin, layout = (5, 5, 5, 1), text = _("Cancel"), action = 'onGlobalQueueCancel')
1497
        ui.Title(self.queueWin, id = 'vStatusBar', layout = (0, 5, 5, 1), align = ui.ALIGN_W)
1498
1499
1500