示例#1
0
def updateOutcome():
	w, h = endgame.outcome.getWidth(), endgame.outcome.getHeight();
	if savage.getLocalTeam().getWinStatus():
		endgame.outcome.setImage("/gui/standard/images/endgame_victory.s2g");
	else:
		endgame.outcome.setImage("/gui/standard/images/endgame_defeat.s2g");
	endgame.outcome.setSize(w,h);
示例#2
0
    def update(self):

        team = savage.getLocalTeam()
        resources = team.getResources()
        race = team.getRace()

        maxPool = [0, 0, 0]
        res = []

        if race == "beast":
            resourceNames = ["entropy", "strata", "fire"]

        elif race == "human":
            resourceNames = ["magnetic", "electric", "chemical"]
        else:
            return

        for i, item in enumerate(resourceNames):

            res.append(resources[item])
            rid = savage.getResourceId(item)

            for go in [b for b in team.getBuildings() if not b.isBeingBuilt()]:
                maxPool[i] += go.getCapacity(rid)

        for i, widgets in enumerate(self.widgetList):
            widgets[0].setCaption(str(res[i]))
            widgets[0].setX(widgets[2].getX() + (widgets[2].getWidth() // 2 -
                                                 widgets[0].getWidth() // 2))
            try:
                pct = float(res[i]) / float(maxPool[i])
                widgets[1].setProgress(pct)
            except ZeroDivisionError:
                widgets[1].setProgress(0)
示例#3
0
 def handleSelection(self):
     if self.currentSelection == None:
         return
     elif len(self.currentSelection.list) == 0:
         self.commandsMenu.buildContext(commcontexts.contextDict["global"])
         # Might use global commands here!
         self.commandsMenu.context.object = None
     elif len(self.currentSelection.list) == 1:
         # we have a single selection!
         obj = self.currentSelection.list[0]
         ot = obj.getType()
         if ot.isUnitType():
             self.commandsMenu.object = obj
             try:
                 self.commandsMenu.buildContext(
                     commcontexts.contextDict[ot.getName()])
             except KeyError:
                 self.commandsMenu.buildContext(
                     commcontexts.contextDict["global"])
         else:
             self.commandsMenu.object = None
             self.commandsMenu.buildContext(
                 commcontexts.contextDict["global"])
     else:
         if self.currentSelection.containsUnits():
             self.commandsMenu.buildContext(
                 commcontexts.contextDict[savage.getLocalTeam().getRace() +
                                          "_worker"])
         else:
             self.commandsMenu.object = None
             self.commandsMenu.buildContext(
                 commcontexts.contextDict["global"])
示例#4
0
 def onShow(self):
     # For now, always show the build context!
     self.buildMenu.buildContext(
         commcontexts.contextDict[savage.getLocalTeam().getRace() +
                                  "_build"])
     self.commandsMenu.buildContext(commcontexts.GlobalContext())
     self.handleSelection()
示例#5
0
    def __init__(self):
        CommAlert.__init__(self, self.PRIORITY, self.RATE, "")

        self.setVisible(False)

        team = savage.getLocalTeam()

        self.obj = team.getCommandCenter()
        self.pos = self.obj.getPosition()

        self.pic.setImage(self.obj.getType().getValue("icon") + ".s2g")
        self.pic.setSize(self.content.getHeight(), self.content.getHeight())

        self.bar = glass.GlassProgressBar()
        self.bar.setBackgroundColor(white)
        #self.bar.setForegroundColor(glass.Color(255,21,22, 128));
        self.bar.setForegroundColor(tools.HSLColor(0.33, 0.8, 0.66))
        self.bar.setSize(self.content.getWidth() - self.pic.getWidth() - 13,
                         self.content.getHeight() - 8)
        self.bar.setBackgroundImage("gui/base/images/progress_bg.tga")
        self.content.add(self.bar,
                         self.pic.getWidth() + 5, 4)

        self.label = DefaultLabel()
        self.label.setCaption("00000")
        self.label.setForegroundColor(glass.Color(255, 237, 237, 128))
        #self.label.setFont(fontSizeLarge);
        self.content.add(
            self.label,
            (self.bar.getWidth() // 2 - self.label.getWidth() // 2) +
            self.pic.getWidth() + 5, "center")

        # re-adding the btn to move it on top
        self.content.add(self.btn)
示例#6
0
 def onEvent(self, e):
     resources = savage.getLocalTeam().getResources()
     if e.eventType == "player_join":
         self.lastGold = resources["gold"]
         self.lastStone = resources["stone"]
         self.trackGold.clear()
         self.trackStone.clear()
         self.goldIncome.setCaption("%.2f" % (0.0) + "/m")
         self.stoneIncome.setCaption("%.2f" % (0.0) + "/m")
示例#7
0
    def setVisible(self, value):
        if value == True or value == 1:
            self.build()
        if savage.getLocalTeam().teamId != 0:
            self.play.setVisible(True)
        else:
            self.play.setVisible(False)

        DefaultWindow.setVisible(self, value)
示例#8
0
    def rebuild(self):
        team = savage.getLocalTeam()
        self.obj = team.getCommandCenter()
        self.pos = self.obj.getPosition()

        self.pic.setImage(self.obj.getType().getValue("icon") + ".s2g")
        self.pic.setSize(self.content.getHeight(), self.content.getHeight())

        self.setVisible(True)
示例#9
0
 def resetDiffCounters(self):
     resources = savage.getLocalTeam().getResources()
     self.trackStone.append(resources["stone"] - self.lastStone)
     self.trackGold.append(resources["gold"] - self.lastGold)
     self.lastGold = resources["gold"]
     self.lastStone = resources["stone"]
     #two minute rolling average
     if len(self.trackGold) > 12:
         self.trackGold.popleft()
         self.trackStone.popleft()
示例#10
0
def defaultAction(x, y):
	obj = savage.getObjectUnder(x,y);
	teamNum = savage.getLocalTeam().teamId;
	if obj == None:
		CL_CommanderLeftClick(); #send it thru to the hardcode to see if something is doing
	CL_SendSelection([ go.objectId for go in commhud.selectionList if go.getType().isUnitType() and go.getTeam() == teamNum]);
	if obj == None:
		CL_OrderWaypoint(x,y);
	else:
		CL_OrderWaypoint(x,y,obj.objectId);
示例#11
0
def defaultAction(x, y):
    obj = savage.getObjectUnder(x, y)
    if obj == None:
        CL_CommanderLeftClick()
        #send it thru to the hardcode to see if something is doing
    elif commhud.selection.empty():
        commhud.selection.selectObject(obj, False)
    commhud.selection.send(savage.getLocalTeam().teamId)
    if obj == None:
        CL_OrderWaypoint(x, y)
    else:
        CL_OrderWaypoint(x, y, obj.objectId)
示例#12
0
    def onEvent(self, e):
        #if isinstance(e, GameEvent):
        #con_println(str(e));
        #pass;
        # CommanderEvents

        if e.eventType == "under_attack":
            where = e.pos
            what = e.sourceId
            # Is it the CommandCenter?
            cc = savage.getLocalTeam().getCommandCenter()
            if cc.objectId == what:
                self.ccAlert.rebuild()
                self.ccAlert.flash()
                #Flash CommandCenter alert!
                return

            for alert in self.alertQueue:
                if isinstance(alert, AttackAlert):
                    if alert.buildingId == e.sourceId:
                        alert.expire()

            alert = AttackAlert(what, where)
            self.insertAlert(alert)

        # GameEvents
        elif e.eventType == "research_complete":
            objtype = savage.ObjectType(e.objtype)
            source = savage.getGameObject(e.sourceId)
            alert = ResearchAlert(objtype, source)
            self.insertAlert(alert)

        elif e.eventType == "player_join" or e.eventType == "player_leave":
            for alert in self.alertQueue:
                if isinstance(alert, ConnectionAlert):
                    if alert.playerId == e.sourceId:
                        alert.expire()

            what = "joined" if e.eventType == "player_join" else "left"
            alert = ConnectionAlert(what, e.sourceId, e.targetId)
            self.insertAlert(alert)

        elif e.eventType == "request_powerup" or e.eventType == "request_gold" or e.eventType == "request_promote":
            for alert in self.alertQueue:
                if isinstance(alert, RequestAlert):
                    if alert.playerId == e.sourceId:
                        alert.expire()

            alert = RequestAlert(e.sourceId, e.eventType, e.parameter)
            self.insertAlert(alert)
示例#13
0
    def rebuild(self):

        team = savage.getLocalTeam()
        resources = team.getResources()
        race = team.getRace()

        if race == "beast":
            res = [
                str(resources["entropy"]),
                str(resources["strata"]),
                str(resources["fire"])
            ]
            col = [tangoGreenLight, tangoBlue, tangoOrange]
            img = [
                "/gui/standard/icons/entropy.s2g",
                "/gui/standard/icons/strata.s2g",
                "/gui/standard/icons/fire.s2g"
            ]

        elif race == "human":
            res = [
                str(resources["magnetic"]),
                str(resources["electric"]),
                str(resources["chemical"])
            ]
            col = [tangoRedLight, tangoBlueLight, tangoGreenLight]
            img = [
                "/gui/standard/icons/magnetic.s2g",
                "/gui/standard/icons/electric.s2g",
                "/gui/standard/icons/chemical.s2g"
            ]

        else:
            # Should never happen, but who knows...
            self.setVisible(False)
            return

        for i, widgets in enumerate(self.widgetList):
            widgets[0].setForegroundColor(col[i])
            widgets[0].setCaption(res[i].zfill(3))

            #widgets[1].setProgress(0);
            widgets[1].setForegroundColor(col[i])

            x, y = widgets[2].getWidth(), widgets[2].getHeight()
            widgets[2].setImage(img[i])
            widgets[2].setSize(x, y)
示例#14
0
	def update(self):
		if self.object != None:
			self.recenter();
			self.info.hp.setProgress(self.object.getHealthPct());
			self.info.hpLabel.setCaption(str(self.object.getHealth()));

			research = savage.getLocalTeam().getResearch();
			active = False;
			for item in research:
				if item.builder == self.object.objectId:
					#self.info.icon.setVisible(True);
					self.info.progress.setProgress(item.percentComplete);
					self.info.icon.build(item);
					#if not self.action:
					active = True;
			if not active:
				self.info.progress.setProgress(0);
				self.info.icon.setVisible(False);
示例#15
0
    def onShow(self):
        self.team = savage.getLocalTeam()
        race = self.team.getRace()

        self.workerImg.setImage("gui/game/images/" + race + "_worker.s2g")
        self.workerImg.setSize(24, 24)
示例#16
0
 def resetDiffCounters(self):
     resources = savage.getLocalTeam().getResources()
     self.lastTime = Host_Milliseconds()
     self.lastGold = resources["gold"]
     self.lastStone = resources["stone"]