def newRow(self, name="", icon=None, online=False): #icon for clan icons (#TODO) delete = glass.ImageButton() delete.setImage("/gui/standard/icons/minus.s2g") delete.setClickAction("gblBuddyManager.removeBuddy(" + name + ");") if icon == None: icon = "^icon transparent^" #else, determine the ^icon string for the user's clan icon label = glass.GlassLabel(icon + name) label.setX(delete.getX() + delete.getWidth() + self.PADDING) label.setWidth(self.listbox.getWidth() - label.getX()) label.setForegroundColor(tangoGrey3 if not online else white) container = glass.GlassContainer() container.add(label) container.add(delete) container.setWidth(self.listbox.getWidth()) h = max(label.getHeight(), delete.getHeight()) container.setHeight(h) label.setY((h - label.getHeight()) // 2) delete.setY((h - delete.getHeight()) // 2) self.listbox.addWidgetItem(container)
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 __init__(self): glass.GlassContainer.__init__(self) self.setBackgroundColor(transparency) #self.setSizePct(0.45, 0.2); #self.centerWindow(); #self.setVisible(0); #self.setAlpha(128); self.itemsContainer = glass.GlassContainer() self.itemsContainer.setSize(300, 150) self.scrollArea = glass.GlassScrollArea(self.itemsContainer) self.scrollArea.setScrollPolicy(glass.GlassScrollArea.SHOW_AUTO, glass.GlassScrollArea.SHOW_NEVER) self.add(self.scrollArea) self.items = []
def __init__(self): glass.GlassWindow.__init__(self); self.setCaption("Research Queue"); self.setBackgroundColor(black); self.setSizePct(0.45, 0.2); self.centerWindow(); self.setVisible(False); self.setAlpha(128); self.setTitleVisible(0); self.itemsContainer = glass.GlassContainer(); self.itemsContainer.setSize(300,150); self.scrollArea = glass.GlassScrollArea(self.itemsContainer); self.scrollArea.setScrollPolicy( glass.GlassScrollArea.SHOW_AUTO , glass.GlassScrollArea.SHOW_NEVER ); self.add(self.scrollArea); self.scrollArea.setSizePct(1,.85); self.items = [];
def __init__(self): DefaultWindow.__init__(self); self.setTitleVisible(False); self.setSizePct(1,1); self.setBackgroundColor(glass.Color(0,0,0,128)); self.setVisible(False); self.minimap = glass.GlassMiniMap(); self.minimap.setSize(screenHeightPct(0.667),screenHeightPct(0.667)); self.add(self.minimap, "center", "center"); self.buttons = glass.GlassContainer(); self.buttons.setSize(self.minimap.getWidth(), self.minimap.getHeight()); self.add(self.buttons, "center", "center"); back = DefaultButton("BACK"); back.setClickAction("loadout.mapWindow.hide();CL_RequestLoadout()"); self.add(back); back.setX(self.minimap.getX() + self.minimap.getWidth()-back.getWidth()); back.setY(self.minimap.getY() + self.minimap.getHeight() +5 );
staminaBackground.setBackgroundColor( glass.Color(10,115,110) ); staminaBackground.setOpaque(1); staminaBackground.setSizePct(0.012,0.13); staminaBackground.setPosition( screenWidth - staminaBackground.getWidth() - 10, healthBackground.getY() ); glass.GUI_ScreenAddWidget("hud",staminaBackground); staminaForeground = glass.GlassLabel(); staminaForeground.setOpaque(1); staminaForeground.setBackgroundColor( glass.Color(20,255,248) ); staminaForeground.setSizePct(0.012,0.13); staminaForeground.setPosition( staminaBackground.getX(), staminaBackground.getY()); glass.GUI_ScreenAddWidget("hud",staminaForeground); ## INVENTORY ## inventory = glass.GlassContainer(); inventory.setSize(int( 0.26*screenHeight ), int( 0.052*screenHeight ) ); inventory.setPosition( staminaBackground.getX() - 10 - inventory.getWidth() , screenHeight - 10 - inventory.getHeight()); inventory.setOpaque(0); glass.GUI_ScreenAddWidget("hud", inventory); inventorySlots = []; inventoryAmmos = []; for i in range(5): slot = glass.GlassLabel(); slot.setSize( int( 0.052*screenHeight ) , int( 0.052*screenHeight ) ); slot.setPosition( i*slot.getWidth(), 0); slot.setOpaque(1); slot.setBackgroundColor( black ); inventorySlots.append(slot); inventory.add(slot);
bg.setBackgroundColor(glass.Color(128,128,128)); bg.setOpaque(1); bg.setSizePct(1,1); glass.GUI_ScreenAddWidget("guitest", bg); tomain = glass.GlassButton("Main Menu"); tomain.setPosition(0,screenHeight-tomain.getHeight()); tomain.setClickAction("GUI_ShowScreen('mainmenu')"); glass.GUI_ScreenAddWidget("guitest", tomain); execwindow.newExecWindow("guitest"); # ############################## # Start testing stuff from here! testAlpha = glass.GlassContainer(); testAlpha.setAlpha(20); testAlpha.setSize(100,100) textAlpha = glass.GlassLabel("^crespect test"); testAlpha.add(textAlpha); glass.GUI_ScreenAddWidget("guitest", testAlpha); progress = glass.GlassProgressDisc(); progress.setPosition(50,50); progress.setSize(100,100); progress.setForegroundColor(glass.Color(0,0,255)); progress.setProgress(.47); glass.GUI_ScreenAddWidget("guitest", progress); state = glass.GlassLabel(); state.setImage("/models/human/weapons/ranged/icons/regenerate.s2g"); state.setPosition(75,75);
timer = glass.GlassLabel("_AB:CD ") timer.setFont(glass.GUI_GetFont(20)) timer.setPosition(10, minimap.getHeight() + 20) glass.GUI_ScreenAddWidget("spechud", timer) ## TEAM STATUS ## teamStatus = ResourcePanel() teamStatus.setVisible(False) glass.GUI_ScreenAddWidget("spechud", teamStatus) ## TEAM STATS ## teamStats = glass.GlassContainer() teamStats.setBackgroundColor(glass.Color(0, 0, 0, 128)) teamStats.setSizePct(1, 0.025) teamStats.setPosition(0, 0) glass.GUI_ScreenAddWidget("spechud", teamStats) team1healthBackground = glass.GlassLabel(" ") teamStats.add(team1healthBackground) team1healthBackground.setPositionPct(0.025, 0.05) team1healthBackground.setSizePct(0.2, 0.9) team1healthBackground.setBackgroundColor(tangoRedDark) team1healthBackground.setOpaque(1) team1healthForeground = glass.GlassLabel(" ") teamStats.add(team1healthForeground) team1healthForeground.setPositionPct(0.025, 0.05)
awardsTitle.setFont(fontSizeLarge); awardsTitle.adjustSize(); awardsTitle.setPosition(outcome.getX(), outcome.getY() + outcome.getHeight() + PADDING); awardsTitle.setWidth(outcome.getWidth()); awardsTitle.setForegroundColor(gold); glass.GUI_ScreenAddWidget("endgame", awardsTitle); awardsScroll = glass.GlassScrollArea(); awardsScroll.setBackgroundColor(tangoGrey6); awardsScroll.setPosition(awardsTitle.getX(), awardsTitle.getY() + awardsTitle.getHeight() + PADDING); #awardsScroll.setSize(outcome.getWidth(), screenHeight - awardsScroll.getY() - 2*PADDING - buddies.toggle.getHeight()); awardsScroll.setSize(outcome.getWidth(), screenHeight - awardsScroll.getY() - 2*PADDING) awardsScroll.setScrollPolicy(awardsScroll.SHOW_NEVER, awardsScroll.SHOW_ALWAYS); glass.GUI_ScreenAddWidget("endgame",awardsScroll); awards = glass.GlassContainer() awards.setWidth(awardsScroll.getWidth() - awardsScroll.getScrollbarWidth()); awardsScroll.setContent(awards); def rebuildAwards(data): """data = { "^gBest Commander^w (%.1f rating)": "0;0;0", "^gSadist^w (%d Kills)": "0;0;0", "^gUnbreakable^w": "0;0;0", "^gMost Violent^w (%d Player Damage)": "0;0;0", "^Minute Man^w (%.1f Kills/min)": "0;0;0", "^gSurvivor^w (%d Kills in a row)": "0;0;0", "^gHero^w (Last Hit)": "0;0;0", "^gHomewrecker^w (%d Building Damage)": "0;0;0", "^gOutpost Basher^w (%d Outpost Damage)": "0;0;0",
goldLabel.setPositionPct(0.4,0.05); goldLabel.setSizePct(0.2,0.1); goldLabel.setAlignment(glass.Graphics.CENTER); glass.GUI_ScreenAddWidget("loadout",goldLabel); main = glass.GlassWindow("selectwindow") main.setSizePct(.8, .6) main.setPositionPct(0.1,0.28) main.setBackgroundColor(glass.Color(0,0,0,128)) main.setTitleVisible(0) main.setTitleBarHeight(0); main.setMovable(0); main.setEnabled(0); glass.GUI_ScreenAddWidget("loadout", main) weaponContainer = glass.GlassContainer(); weaponContainer.setId("weaponContainer"); main.add(weaponContainer); weaponContainer.setPositionPct(.025, .025); weaponContainer.setSizePct(0.35, 0.52); weaponContainer.setBackgroundColor(tangoGrey2); itemContainer = glass.GlassContainer(); itemContainer.setId("itemContainer"); main.add(itemContainer); itemContainer.setPositionPct(.025, .55); itemContainer.setSizePct(.35, .35); itemContainer.setBackgroundColor(tangoGrey2); unitContainer = GlassTablePlus(); main.add( unitContainer );
bg = glass.GlassLabel(" "); bg.setBackgroundColor(black); bg.setOpaque(1); bg.setSizePct(1,1); bg.setPositionPct(0,0); glass.GUI_ScreenAddWidget("lobby", bg); boxWidth = 0.2; boxHeight = 0.5; buttonHeight = boxHeight / 10; totalPadding = 0.05; paddingPerBox = totalPadding / 8; centralPadding = 0.15; interface = glass.GlassContainer(); interface.setBackgroundColor( tangoGrey2 ); interface.setSizePct( 2 * boxWidth, 0.2); interface.setPositionPct((0.5 - boxWidth), ( 1 - 0.2)); glass.GUI_ScreenAddWidget("lobby", interface); interfaceMainMenu = glass.GlassButton(" << MAIN MENU"); interfaceMainMenu.setClickAction("GUI_ShowScreen('mainmenu');"); interface.add( interfaceMainMenu ); interfaceMainMenu.setSizePct(0.5,0.2); interfaceMainMenu.setPositionPct(0,0); interfaceSpectatorButton = glass.GlassButton(" Join Spectators "); interface.add( interfaceSpectatorButton ); interfaceSpectatorButton.setClickAction("CL_RequestTeam(0);CL_RequestLoadout();"); interfaceSpectatorButton.setSizePct(0.5,0.2);
def onMousePress(self, e): pass; def onMouseReleased(self, e): pass; def onMouseDrag(self, e): pass; canvas = glass.GlassCanvas(); comminputhandler = CommInputHandler(); canvas.addMouseListener(comminputhandler); selectionRect = glass.GlassContainer(); selectionRect.setBackgroundColor(tangoGreenLight); selectionRect.setAlpha(64); canvas.add(selectionRect); #starting from the top-centre (12 o'clock) of the screen and proceeding anti clockwise ## RESOURCES/INFO PANEL ## resourcesPanel = ResourcePanel(); glass.GUI_ScreenAddWidget("commhud", resourcesPanel); ## MINIMAP ## #Beard: skope suggests moving this to the bottom minimap = glass.GlassMiniMap(); minimap.setPositionPct(0.01875, 0.025);
next = glass.GlassButton("Next") uploadWin.add(next, (uploadWin.getWidth() - next.getWidth() - pxpadding), back.getY()) videoList = glass.GlassListBox() videoList.setSize(uploadWin.getWidth() - 2 * pxpadding, int(uploadWin.getHeight() / 1.5)) videoListScroll = glass.GlassScrollArea(videoList) videoListScroll.setSize(videoList.getWidth(), videoList.getHeight()) uploadWin.add(videoListScroll) videoListScroll.setPosition(pxpadding, title.getY() + title.getHeight() + pxpadding) contents.append([videoList, videoListScroll]) loginContainer = glass.GlassContainer() loginContainer.setVisible(False) uploadWin.add(loginContainer, pxpadding, title.getY() + title.getHeight() + pxpadding * 2) loginContainer.setWidth(uploadWin.getWidth() - pxpadding * 2) usernameLabel = glass.GlassLabel("Account email: ") loginContainer.add(usernameLabel, 0, 0) usernameInput = glass.GlassTextField() loginContainer.add( usernameInput, usernameLabel.getX() + usernameLabel.getWidth() + pxpadding * 2, usernameLabel.getY()) usernameInput.setSize( int(loginContainer.getWidth() - (4 * padding + usernameLabel.getWidth())),