def onMouseClick(self, e): w = e.widget.getWidth(); h = e.widget.getHeight(); wsize = World_GetGridSize()*100; mapx, mapy, z = savage.getLocalPlayer().getPosition(); mapx = (e.x / float(w)) * wsize; mapy = wsize - (e.y / float(h)) * wsize; savage.getLocalPlayer().setPosition(Vec3(mapx, mapy, z));
def newPreset(self, name): filteredname = "" for char in name: filteredname += char if Preset.PRESET_NAME_FILTER.match( char) else "_" name = filteredname file = File_Open("/presets/" + name + ".prs", "w") File_Write(file, "name:" + name + "\r\n") player = savage.getLocalPlayer() unit = player.getType().getName() race = savage.Team(player.getTeam()).getRace() File_Write(file, "race:" + race + "\r\n") File_Write(file, "unit:" + unit + "\r\n") for i in range(5): #well, modders won't like this slot_objType = player.getInventorySlot(i) ammo = player.getAmmoSlot(i) name = slot_objType.getName() if slot_objType != None else "" File_Write(file, str(i) + ":" + name) if ammo != None: quantity = int( math.ceil(ammo / slot_objType.getValue("ammoStart"))) else: quantity = 1 File_Write(file, ":" + str(quantity) + "\r\n") File_Close(file) self.reloadPresets()
def updateInventory(): player = savage.getLocalPlayer(); for i in range(5): slot_objType = player.getInventorySlot(i); slot = loadout.inventorySlots[i]; name = loadout.inventoryNames[i]; ammo = loadout.inventoryAmmos[i]; w , h = slot.getWidth() , slot.getHeight(); if slot_objType != None: slot.setImage( slot_objType.getValue("icon")+".s2g" ); name.setCaption( slot_objType.getValue("description") ); if slot_objType.isManaWeapon(): ammoCount = str(player.getManaUsesSlot(i, True)); else: ammoCount = str(player.getAmmoSlot(i)); if ammoCount == "None": ammoCount = ""; ammo.setCaption( str( ammoCount ) ); else: slot.setImage("/gui/standard/black.s2g"); name.setCaption( loadout.SLOT_NAMES[i] ); ammo.setCaption(""); slot.setSize(w, h);
def update(self): gobjs = savage.getActiveObjects(); myteam = savage.getLocalPlayer().getTeam(); self.buttons.erase(); for go in gobjs: if go.isSpawnPoint() and ((cvar_getvalue("sv_allowWarmupAllSpawnLocs") == 1 and savage.getGameStatus()<=GAME_STATUS_WARMUP) or go.getTeam() == myteam): pos = go.getPosition(); #create a button with the appropriate color and image button = glass.ImageButton(); #and place it in the correct position button.setImage(go.getMapIcon()); button.setSize(screenWidthPct(0.025),screenWidthPct(0.025)); if go.getTeam() == myteam: button.setForegroundColor(white); if go.isComplete() == False: button.setForegroundColor(glass.Color(0,255,0)); else: button.setClickAction("CL_RequestSpawn("+str(go.objectId)+")"); else: if cvar_getvalue("sv_allowWarmupAllSpawnLocs") == 1 and savage.getGameStatus()<=GAME_STATUS_WARMUP: button.setClickAction("CL_RequestSpawn("+str(go.objectId)+")"); else: button.setForegroundColor(glass.Color(255,0,0)); scale = float(World_GetGridSize()*100.0); button.setX(int( self.minimap.getWidth()* pos[0]/scale - button.getWidth()/2 )); button.setY(int( self.minimap.getHeight()*(1-pos[1]/scale) - button.getHeight()/2 )); self.buttons.add(button);
def frame(self): instantStr = "Instant: " + str(round( cvar_getvalue("cl_fpsClient"))) + "\n" averageStr = "Average: " + str(round( cvar_getvalue("cl_fpsClientAvg"))) + "\n" serverStr = "Server: " + str(round( cvar_getvalue("cl_fpsServer"))) + "\n" pingStr = "Ping: " + str(savage.getLocalPlayer().getPing()) + " \n" out = "" clientFps = cvar_getvalue("cl_showfps") if clientFps in (1, 3): out += instantStr if clientFps in (2, 3): out += averageStr #Big: because it's not anyway, it's just the network send rate #if cvar_getvalue("cl_showfpsserver") == 1: # out += serverStr; if cvar_getvalue("cl_showping") == 1: out += pingStr if out == "": self.setVisible(0) return self.label.setCaption(out) self.label.adjustSize() self.setHeight(self.label.getHeight() - 10)
def senderStr(self, e): returnstr = "" myteam = 0 sourceteam = e.source.getTeam() try: myteam = savage.getLocalPlayer().getTeam() except: pass #refs and comms always have the tag added to the end of their name if e.source.isCommander(): returnstr = "[C]" + returnstr elif e.source.isReferee(): returnstr = "[REF]" + returnstr returnstr = e.sourceName + returnstr #private messages don't respect colouring #spectators see all names as white #non-specs see enemies as red #ally comms are green #any other ally is blue #any spec-refs are gold #anyone else (specs) are white if e.scope == "msg_private": returnstr = privColorCode + returnstr elif e.source.isReferee() and e.source.getTeam() == 0: returnstr = refColorCode + returnstr elif sourceteam == myteam and e.source.isCommander(): returnstr = commColorCode + returnstr else: returnstr = e.source.getNameColorCode() + returnstr returnstr = "^w" + e.clanIcon + returnstr return returnstr
def update(self): player = savage.getLocalPlayer(); team = savage.getTeamObject(player.getTeam()); self.setAlpha(255); self.image.setAlpha(255); self.request.setVisible(False); if not self.objtype.isResearched(): self.setVisible(False); else: self.setVisible(True); #self.image.setProgress(1.0); if self.objtype in team.getResearch(): self.setVisible(True); for r in team.getResearch(): if r == self.objtype: con_println("progressing \n") self.image.setProgress(r.getBuildProgress()); break; if player.getGold() < self.objtype.getValue("playerCost"): self.request.setVisible(True); if self.objtype.isWeaponType(): obj1 = player.getInventorySlot(1); if obj1 is not None and player.getGold() + obj1.getValue("playerCost") >= self.objtype.getValue("playerCost"): self.request.setVisible(False); self.maxDeployment.setCaption(""); if self.objtype.getValue("maxDeployment") > 0: md = self.objtype.getValue("maxDeployment")-team.getDeployedCount(self.objtype.typeId); self.maxDeployment.setCaption(str(md).rjust(2));
def updateHealth(): player = savage.getLocalPlayer(); healthProportion = player.getHealthPct() hud.healthValue.setCaption( str(player.getHealth() )); hud.healthForeground.setHeight( int( hud.healthBackground.getHeight()*healthProportion ) ); hud.healthForeground.setY( hud.healthBackground.getHeight() + hud.healthBackground.getY() - hud.healthForeground.getHeight() );
def frame(): gametime = getGameTimeString(cvar_getvalue("game_timeLimitSeconds")); if gametime != "": if cvar_getvalue("game_timeLimitSeconds") < 45: gametime = "^900"+gametime; hud.timer.setCaption("^icon ../../gui/standard/icons/timer^" + gametime); hud.timer.adjustSize(); else: hud.timer.setCaption(""); player = savage.getLocalPlayer(); hud.teamStatus.update(); hud.updateGold(); hud.updateHealth(); hud.updateStamina(); hud.updateInventory(); hud.stateContainer.update(); hud.updateCrosshairLimits(); hud.minimap.setAlpha(int(cvar_getvalue('cl_minimap_brightness')*255)); hud.updateWaypoint(); hud.updateGameStatus(); hud.crosshair.update(); hud.voteWindow.frame(); if hud.scoreboard.isVisible(): hud.scoreboard.update(); hud.fpswindow.update();
def onMouseClick(self, e): if e.widget == self.color: return if e.button == MOUSE_LEFTBUTTON: w = e.widget.getWidth() h = e.widget.getHeight() wsize = World_GetGridSize() * 100 mapx, mapy, z = savage.getLocalPlayer().getPosition() mapx = (e.x / float(w)) * wsize mapy = wsize - (e.y / float(h)) * wsize savage.getLocalPlayer().setPosition(Vec3(mapx, mapy, z))
def update( self ): self.table.erase(); player = savage.getLocalPlayer(); shots, hits, siege = player.getAccuracy(); weapons = [w for w in shots if shots[w] > 0]; self.addRow("Weapon","Shots","Hit%","Siege%"); for w in sorted(weapons): weapon_shots = shots[w]; if weapon_shots != 0: weapon_hit = 100*hits[w] /weapon_shots; weapon_siege = 100*siege[w]/weapon_shots; self.addRow("Weapon", str(weapon_shots), str(weapon_hit), str(weapon_siege)); weapon_shots = sum(shots.values()); if weapon_shots != 0: weapon_hit = 100*sum(hits.values() )/weapon_shots; weapon_siege = 100*sum(siege.values())/weapon_shots; else: weapon_hit = weapon_siege = 0; self.addRow("Total" ,str(weapon_shots), str(weapon_hit), str(weapon_siege)); self.table.adjustSize(); self.setSize(self.table.getWidth() + 2, self.table.getHeight() + 2 + self.getTitleBarHeight());
def rebuildUnits(): player = savage.getLocalPlayer(); team = savage.getTeamObject(player.getTeam()); loadout.unitContainer.erase(); viewers = []; unitNames = []; unitPrices = []; unitList = team.getUnits(); for unit in unitList: price = str( unit.getValue("playerCost") ); if price == "0": price = "FREE"; if price == "-1": continue; modelContainer = glass.GlassContainer(); #Store the button and the viewer in a container modelContainer.setSizePct( 0.075, 0.15 ); viewer = glass.GlassViewer(); viewer.setModel(unit.getValue("model")); viewer.setOpaque(0); modelContainer.add( viewer, 0, 0 ); viewer.rotateModel(160); viewer.setCameraFOV(45); viewer.setSizePct(1,1); viewer.setAnimation("idle"); viewer.fitCameraToModel(2); #viewer.setCameraPosition(0,0,16); #viewer.setCameraDistance(40); button = glass.ImageButton("textures/econs/transparent.s2g"); #Create clickable, invisible button over the viewer. button.setClickAction( "CL_RequestUnit('" + str(unit.getValue('name')) + "');" ); modelContainer.add( button ); button.setSizePct(1,1); button.setPosition(0,0); viewers.append( modelContainer ); price = glass.GlassLabel("^icon ../../gui/standard/icons/gold/gold_icon^" + price); price.setForegroundColor( gold ); price.setFont(fontSizeSmall); unitPrices.append(price); name = glass.GlassLabel(unit.getValue("description")); unitNames.append(name); loadout.unitContainer.addRow(*viewers); loadout.unitContainer.addRow(*unitNames); loadout.unitContainer.addRow(*unitPrices); loadout.unitContainer.adjustHeightTo(int(0.2*loadout.main.getHeight())); loadout.unitContainer.setX( int( 0.69*loadout.main.getWidth() - loadout.unitContainer.getWidth()/2) ); loadout.unitContainer.adjustJustification();
def updateGold(): player = savage.getLocalPlayer() gold = player.getGold() if gold != None: spechud.player_money.setCaption( "^icon ../../gui/standard/icons/gold/gold_icon^" + str(gold)) else: spechud.player_money.setCaption("")
def onAction(self, e): player = savage.getLocalPlayer(); refund = player.getType().getValue("playerCost"); if player.getGold()+refund < self.objtype.getValue("playerCost"): CL_RequestGrant(self.objtype.getName()); else: CL_RequestUnit(self.objtype.getName());
def update(self): player = savage.getLocalPlayer() stateList = player.getStateList() stateCount = len(stateList) timerCount = len(self.timers) #first, ensure that we have enough 'state slots' for j in range(stateCount - timerCount): self.newState() widthToUse = (self.timers[0].getWidth() + 5) * stateCount #xOffset = (self.getWidth() - widthToUse )// 2; xOffset = 0 for i in range(stateCount): state = stateList[i] timer = self.timers[i] counter = self.counters[i] progress = self.progresses[i] w = timer.getWidth() h = timer.getHeight() timer.setImage(state.getIcon()) progress.setImage(state.getIcon()) timer.setSize(w, h) progress.setSize(w, h) timer.setVisible(True) #timer.update(); #or whatever will update the GlassTimer timer.setX(xOffset + i * (timer.getWidth() + 5)) inflictor = state.getInflictor() if inflictor == None or inflictor.getTeam() == player.getTeam(): progress.setForegroundColor(tangoBlue) else: progress.setForegroundColor(tangoRed) #Big: counters disabled #counter.setVisible(True); #counter.setCaption( state.getTimeRemaining() ); counter.setX(timer.getX() + timer.getWidth() - counter.getWidth()) progress.setVisible(True) try: progress.setProgress(1.0 - state.getTimeRemaining(False) / state.getDuration()) except ZeroDivisionError: progress.setProgress(1.0) progress.setX((timer.getX() + timer.getWidth() // 2) - progress.getWidth() // 2) progress.setY((timer.getY() + timer.getHeight() // 2) - progress.getHeight() // 2) for i in range(stateCount, timerCount): timer = self.timers[i] counter = self.counters[i] progress = self.progresses[i] timer.setVisible(False) counter.setVisible(False) progress.setVisible(False)
def areTechRequirementsMet(self): #so here is the hard part! team = savage.Team(savage.getLocalPlayer().getTeam()); builderAvailable = False; value = self.objtype.getValue("builder1"); if value != "": reqtype = savage.getObjectType(value); for builder in team.getBuildings(): if builder.getType() == reqtype and not builder.isBeingBuilt(): builderAvailable = True; break; elif builder.getType() == self.objtype or self.objtype.getValue("selfBuild") == 1: builderAvailable = True; break; if self.objtype.getValue("selfBuild") == 1: builderAvailable = True; if value == "human_worker" or value == "beast_worker": builderAvailable = True; if builderAvailable == False: value = self.objtype.getValue("builder2"); if value != "": reqtype = savage.getObjectType(value); for builder in team.getBuildings(): if builder.getType() == reqtype and not builder.isBeingBuilt(): builderAvailable = True; break; reqbasepoints = self.objtype.getValue("needBasePoints"); basepoints = team.getCommandCenter().getType().getValue("basePointValue"); if basepoints < reqbasepoints: builderAvailable = False; if builderAvailable == False: return False; teamObjects = team.getAvailableTech(); for b in ("requirement1","requirement2"): value = self.objtype.getValue(b); if value != "": reqtype = savage.getObjectType(value); if reqtype not in teamObjects: return False; else: if reqtype.isBuildingType(): builderAvailable = False; for builder in team.getBuildings(): if builder.getType() == reqtype and not builder.isBeingBuilt(): builderAvailable = True; break; #does this cover everything? return builderAvailable;
def update(self): player = savage.getLocalPlayer(); team = savage.getTeamObject(player.getTeam()); self.kills.setCaption("^g"+("% 3d"%player.getKills())); self.losses.setCaption("^900"+str(player.getDeaths())); self.levelLabel.setCaption("LEVEL: "+("% 3d"%player.getLevel())); self.level.setProgress(player.getXp()/float(savage.getXPForLevel(team.getRace(), player.getLevel()+1)));
def getNameColorCode(self): #determines how the local player will view the object (ally, netural, enemy) and returns the corresponding color code player = savage.getLocalPlayer(); if player.getTeam() == 0 or self.getTeam() == 0: return "^w"; #specs are see evertything as white, and everything sees specs as white elif player.getTeam() == self.getTeam(): return allyColorCode; else: return enemyColorCode;
def updateStamina(): player = savage.getLocalPlayer() staminaProportion = player.getStaminaPct() spechud.staminaForeground.setHeight( int(spechud.staminaBackground.getHeight() * staminaProportion)) spechud.staminaForeground.setY(spechud.staminaBackground.getHeight() + spechud.staminaBackground.getY() - spechud.staminaForeground.getHeight())
def onEvent(self, e): if e.eventType == "research_complete" or e.eventType == "inventory_changed": #\ #and GUI_IsScreenVisible('loadout'): TODO player = savage.getLocalPlayer(); team = savage.getTeamObject(player.getTeam()); if team.getRace() == "human": loadout.buildLoadout(['NULL', 'magnetic', 'electric', 'chemical']); elif team.getRace() == "beast": loadout.buildLoadout(['NULL', 'entropy', 'strata', 'fire']);
def update(self): #0. don't show if we're free if getMouseMode() == MOUSE_FREE: self.setVisible(False) else: self.setVisible(True) player = savage.getLocalPlayer() #1. get the object behind the crosshair obj = savage.getObjectUnder(*Input_GetMouseXY()) #2. if we're not pointing at anything, hide! if obj == None: self.status = self.STATUS_INACTIVE self.adjustAlpha() self.reposition() return #3. else, get ready to do something self.status = self.STATUS_ACTIVE self.lastObject = obj obj_type = obj.getType() name = "" showHealth = False showBuild = False #4. if it's a unit (includes players and vehicles and NPCS) if obj_type.isUnitType(): name = obj.getNameColorCode() + obj.getName() if obj.isPlayer(): name = "^w" + obj.getClanIcon() + name if obj_type.getValue("tier") == 5 or obj.getTeam( ) == player.getTeam() or player.getTeam() == 0: #second level of siege, or our team (or NPC) showHealth = True #5. if it's a building elif obj_type.isBuildingType(): name = obj.getNameColorCode() + obj_type.getValue("description") showHealth = True showBuild = obj.isBeingBuilt() #6. Anything else else: name = obj.getName() if (cvar_getvalue("sv_numTeams") > 3 or player.getTeam() == 0) and obj.getTeam() != 0: self.teamNum.setCaption("Team " + str(obj.getTeam())) else: self.teamNum.setCaption("") self.targetName.setCaption(name) self.updateHealth(showHealth, obj) self.updateBuild(showBuild, obj) self.adjustAlpha() self.reposition()
def frame(): if spechud.hud.isVisible(): gametime = getGameTimeString(cvar_getvalue("game_timeLimitSeconds")) if gametime != "": if cvar_getvalue("game_timeLimitSeconds") < 45: gametime = "^900" + gametime spechud.timer.setCaption("^icon ../../gui/standard/icons/timer^" + gametime) spechud.timer.adjustSize() else: spechud.timer.setCaption("") player = savage.getLocalPlayer() #when spectating someone bu has said this will represent the spectee and not the spectator #I hope it does if player.getTeam() != 0: for widget in spechud.nonSpecWidgets: widget.setVisible(True) spechud.teamStatus.update() spechud.updateGold() spechud.updateHealth() spechud.updateStamina() spechud.updateInventory() spechud.stateContainer.update() spechud.updateCrosshairLimits() spechud.researchinfowindow1.setVisible(False) spechud.researchinfowindow2.setVisible(False) spechud.unitinfowindow1.setVisible(False) spechud.unitinfowindow2.setVisible(False) spechud.teamStats.setVisible(False) else: for widget in spechud.nonSpecWidgets: widget.setVisible(False) spechud.teamStatus.setVisible(False) spechud.compass.setVisible(False) if spechud.researchinfowindow1.isVisible(): spechud.researchinfowindow1.updateResearch() if spechud.researchinfowindow2.isVisible(): spechud.researchinfowindow2.updateResearch() spechud.unitinfowindow1.updateUnitInfo() spechud.unitinfowindow2.updateUnitInfo() spechud.updateTeamStats() spechud.updateGameStatus() spechud.crosshair.update() spechud.voteWindow.frame() if spechud.scoreboard.isVisible(): spechud.scoreboard.update() spechud.compass.update() spechud.fpswindow.update() else: spechud.lobby.update()
def updateCrosshairLimits(): player = savage.getLocalPlayer(); player_objType = player.getType(); xmin = player_objType.getValue("minAimX"); xmax = player_objType.getValue("maxAimX"); ymin = player_objType.getValue("minAimY"); ymax = player_objType.getValue("maxAimY"); hud.crosshairLimits.setPosition(int( screenWidth * xmin) - hud.crosshairLimitsPadding , int( screenHeight * ymin) - hud.crosshairLimitsPadding ); hud.crosshairLimits.setWidth(int( screenWidth * (xmax-xmin)) + 2*hud.crosshairLimitsPadding); hud.crosshairLimits.setHeight(int( screenHeight * (ymax-ymin))+ 2*hud.crosshairLimitsPadding);
def areResourceRequirementsMet(self): team = savage.Team(savage.getLocalPlayer().getTeam()); teamRes = team.getResources(); #a dictionary of integers #yarr be entering stubby code now laddie! only for the brave! acch! Get me some haggis! for key, value in teamRes.items(): cost = self.objtype.getCost(key); if cost > value and value != -1: #for a human team, entropy is -1 #which is probably a silly idea, in hindsight should be 0 :P return False; return True;
def updateInventory(): #see also loadout's updateInventory, it's similar player = savage.getLocalPlayer() primaryRanged = None for i in range(5): slot_objType = player.getInventorySlot(i) slot = spechud.inventorySlots[i] w, h = slot.getWidth(), slot.getHeight() ammo = spechud.inventoryAmmos[i] ammoCount = "" if slot_objType != None: slot.setImage(slot_objType.getValue("icon") + ".s2g") if slot_objType.isManaWeapon(): ammoCount = str(player.getManaUsesSlot(i)) else: ammoCount = str(player.getAmmoSlot(i)) if ammoCount == "None": ammoCount = "" if primaryRanged == None and slot_objType.isWeaponType(): primaryRanged = i primaryAmmo = ammoCount else: #empty slot slot.setImage("/textures/black.s2g") ammo.setCaption(ammoCount) slot.setSize(w, h) currentSlotIndex = player.getCurrentInventorySlotIndex() slotWidget = spechud.inventorySlots[currentSlotIndex] spechud.invselected.setPosition(slotWidget.getX(), slotWidget.getY()) if primaryRanged != None: slot_objType = player.getInventorySlot(primaryRanged) w, h = spechud.ammoGraphic.getWidth(), spechud.ammoGraphic.getHeight() spechud.ammoValue.setCaption(primaryAmmo) if slot_objType.isManaWeapon(): pass #spechud.ammoGraphic.setImage( glorious mana icon ); else: #it must use ammo pass #spechud.ammoGraphic.setImage( glorious ammunition icon ); spechud.ammoGraphic.setSize(w, h) spechud.ammoValue.setVisible(True) spechud.ammoGraphic.setVisible(True) else: spechud.ammoValue.setVisible(False) spechud.ammoGraphic.setVisible(False)
def onShow(): commcontexts.buildContextsIfNeeded(); commhud.contextmenu.setVisible(False); commhud.contextmenu.close(); commhud.resourcesPanel.resetDiffCounters(); commhud.resourcesPanel.update(); commhud.chatBox.deactivate(); commhud.minimap.setMap(cvar_get("world_overhead")); commhud.unitinfowindow.buildUnitInfo(savage.Team( savage.getLocalPlayer().getTeam() )); commhud.researchWindow.onTeamChange(); commhud.scoreboard.arrange(); commhud.scoreboard.update(); #remove the placeholders in scoreboard
def ResearchSimple(typename): objtype = savage.getObjectType(typename); team = savage.Team(savage.getLocalPlayer().getTeam()); value = objtype.getValue("builder1"); if value != "": candidates = team.getObjectsByType(value); con_println("candidates:"+str(len(candidates))+"\n"); if len(candidates) == 0: return False; else: #TODO: base this on which building will be available first builder = candidates[int(M_Randnum(0, len(candidates)))]; gblQueue.addResearch(savage.ResearchItem(objtype.typeId, builder.objectId, 0,0));
def update(self): player = savage.getLocalPlayer(); refund = player.getType().getValue("playerCost"); self.request.setVisible(False); if player.getGold()+refund < self.objtype.getValue("playerCost"): self.request.setVisible(True); if not self.objtype.isResearched(): self.setVisible(False); else: self.setVisible(True); #this is because the model loading might be delayed self.viewer.fitCameraToModel(30);
def frame(): player = savage.getLocalPlayer(); team = savage.getTeamObject(player.getTeam()); teamNum = player.getTeam(); if loadout.lastTeamNum != teamNum and teamNum != 0: if team.getRace() == "human": loadout.buildLoadout(['NULL', 'magnetic', 'electric', 'chemical']); elif team.getRace() == "beast": loadout.buildLoadout(['NULL', 'entropy', 'strata', 'fire']); loadout.lastTeamNum = teamNum; loadout.updateInventory(); loadout.updateMainViewer(); loadout.goldLabel.setCaption("^icon ../../gui/standard/icons/gold/gold_icon^" + str(player.getGold()) );
def getTooltipFor(self, objtype): #TODO this generates the tooltips, but when do we need to set them? In frame? """General format <icon> <name> (possible coloured by tech type) <gold> <gold cost> <stone> <stone cost> <one line description> Requires: - <Requisite 1> - <Requisite 2> Colour them green if they're met, red if they're not met and yellow if they're being researched/will be met soon """ team = savage.Team(savage.getLocalPlayer().getTeam()) tooltip = "^icon " + objtype.getValue( "icon") + "^ " + objtype.getValue("description") + "\n" tooltip += "^w^icon ../../gui/standard/icons/gold/gold_icon^^y" + str( objtype.getValue("goldCost")) tooltip += " ^w^icon ../../gui/standard/icons/redstone^^900" + str( objtype.getValue("stoneCost")) + "\n" tooltip += "^w" + objtype.getValue("tooltip") + "\n" tooltip += "Requires:\n" for requirement in ("builder1", "builder2", "requirement1", "requirement2"): value = objtype.getValue(requirement) if value == "": continue notMet = True inProgress = False if requirement.startwith("builder"): notMet = not team.hasBuilding(value) #TODO inProgress = notMet and team.isBuilding(value) #TODO elif requirement.startswith("requirement"): currentResearch = [ot.getName() for ot in team.getResearch()] inProgress = value in currentResearch notMet = not team.isResearched(value) color = "^y" if inProgress else "^r" if notMet else "^g" tooltip += color + " - " + value + "\n" return tooltip