def show_demoselect(): w = glass.GUI_GetWidget('mainmenu:Demos'); if w != None: w.setVisible(True) return window = glass.GlassWindow('Demos'); window.setTitleVisible(0); window.setSizePct(.7, .4); window.centerWindow(); demos = File_ListFiles("/demos/", "*.demo", 0); demoList = glass.GlassListBox(); demoList.setSizePct(200,200); for f in demos: demoList.addItem(f[7:]); demoScroll = glass.GlassScrollArea(demoList); window.add(demoScroll); demoScroll.setPositionPct(.01, .03); demoScroll.setSizePct(.5, .9); demoScroll.setId('list'); demoPlay = glass.GlassButton("Play Demo"); demoPlay.setClickAction('thelist = glass.GUI_GetWidgetTyped("mainmenu:Demos:list", glass.GlassScrollArea).getContent(glass.GlassListBox);demo=thelist.getItem(thelist.getSelected());Demo_Play(demo[:demo.rfind(".")]);'); window.add(demoPlay); demoPlay.setPositionPct(.6, .85); demoClose = glass.GlassButton("Close"); demoClose.setClickAction("glass.GUI_GetWidget('mainmenu:Demos').setVisible(False);"); window.add(demoClose); demoClose.setPositionPct(.8, .85); glass.GUI_ScreenAddWidget("mainmenu", window);
def __init__(self, playerName): glass.GlassWindow.__init__(self, playerName + " Stats & Rankings") self.httpHandle = -1 self.player = playerName self.setBackgroundColor(glass.Color(0, 0, 0, 128)) self.spinner = glass.GlassLabel() self.spinner.setImage("textures/econs/loading/loading0000.s2g") self.spinner.setSize(32, 32) self.add(self.spinner) self.title = glass.GlassLabel(self.player + " Stats & Rankings") self.add(self.title) #create the tabs self.tabs = glass.GlassTabbedContainer() self.tabs.setOpaque(0) self.add(self.tabs) self.tabs.setSizePct(1, .9) self.setTitleVisible(0) button = glass.GlassButton("Close") self.add(button) button.addActionListener(self) gblEventHandler.addHttpListener(self)
def setVisible(self,yes): glass.GlassWindow.setVisible(self, yes); if self.first == False: return; self.first = False; close = glass.GlassButton("Close"); close.addActionListener(self); self.add(close); close.setPosition(self.getWidth()-close.getWidth(), self.getHeight()-close.getHeight()); #create the tabs tabHolder = glass.GlassTabbedContainer(); tabHolder.setForegroundColor(white); #TODO doesn't work: we want tab labels that are white self.add(tabHolder); tabHolder.setSize(self.getWidth(),close.getY()); #Controls, Config, Graphics, Sound, Network controlsTab = self.build_controls(tabHolder); tabHolder.addTab("Controls", controlsTab); configTab = self.build_config(); graphicsTab = self.build_graphics(); soundTab = self.build_sound(); networkTab = self.build_network(); names = ("Config", "Graphics", "Sound", "Network"); internalHeight = tabHolder.getTabArea().height; #controlsTab sorts itself out for i, scrollArea in enumerate((configTab,graphicsTab,soundTab,networkTab)): bar = scrollArea.getScrollbarWidth(); scrollArea.setWidth(min( scrollArea.getWidth() + bar , tabHolder.getWidth() )); scrollArea.setHeight(min( scrollArea.getHeight() + bar , internalHeight )); tabHolder.addTab(names[i],scrollArea);
def createControls(self, table, controlList, profile): bindHandler = BindHandler(profile); for i, action in enumerate(controlList): text = glass.GlassTextField(); text.setSize(150, 25); text.setLocked(1); text.setId(action); bindFields[profile].append(text); text.setText(makePretty(action, profile)); text.addMouseListener(bindHandler); clear = glass.GlassButton("Clear"); args = str(i)+", "+str(profile); clear.setClickAction("clearBinds("+args+")"); default = glass.GlassButton("Default"); default.setClickAction("defaultBinds(" +args+ ")"); table.addRow( action, text, default, clear );
def build_controls(self,topTC): #these heights are broken again tabHolder = glass.GlassTabbedContainer(); tabHolder.setForegroundColor(white); tabHolder.setSize(topTC.getWidth(),topTC.getTabArea().height); tabs = []; names = ("Player","Commander","Spectator"); for i in range(3): table = GlassTablePlus(); table.horizontalJustification = glass.Graphics.LEFT; table.setFrame(0); self.createControls(table, getBindActions(i), i); table.adjustSizeTo(); scrollArea = glass.GlassScrollArea(table); scrollArea.setSize(table.getWidth(),table.getHeight()); internalHeight = tabHolder.getTabArea().height; bar = scrollArea.getScrollbarWidth(); scrollArea.setWidth(min( scrollArea.getWidth() + bar , tabHolder.getWidth() )); scrollArea.setHeight(min( scrollArea.getHeight() + bar , internalHeight )); tabHolder.addTab(names[i], scrollArea); table = GlassTablePlus(); table.horizontalJustification = glass.Graphics.LEFT; table.setFrame(0); resets = [ glass.GlassButton("Player"), glass.GlassButton("Commander"), glass.GlassButton("Spectator")]; for i, button in enumerate(resets): button.setClickAction("defaultBindProfile("+str(i)+");"); table.addRow("Reset to defaults: ", *resets); table.adjustSizeTo(); scrollArea = glass.GlassScrollArea(table); scrollArea.setSize(table.getWidth(),table.getHeight()); scrollArea.setWidth(min( scrollArea.getWidth() + bar , tabHolder.getWidth() )); scrollArea.setHeight(min( scrollArea.getHeight() + bar , internalHeight )); tabHolder.addTab("Other", scrollArea); return tabHolder;
def build_sound(self): table = GlassTablePlus(); table.setFrame(0); table.horizontalJustification = glass.Graphics.LEFT; MasterVolume = glass.GlassSlider(); MasterVolume.linkCvar( "sound_mastervolume" ); MasterVolume.setScaleEnd(1.0); MasterVolume.setScaleStart(0); table.addRow("Master Volume", MasterVolume); MusicVolume = glass.GlassSlider(); MusicVolume.linkCvar( "sound_musicvolume" ); MusicVolume.setScaleEnd(1.0); MusicVolume.setScaleStart(0); table.addRow("Music Volume", MusicVolume); SoundVolume = glass.GlassSlider(); SoundVolume.linkCvar( "sound_sfxVolume" ); SoundVolume.setScaleEnd(1.0); SoundVolume.setScaleStart(0); TestSoundButton = glass.GlassButton("Test"); TestSoundButton.setClickAction("Sound_PlaySound('/sound/human/player/male/good_game_1.ogg');"); table.addRow("Sound Effect Volume", SoundVolume,TestSoundButton); #TODO play this sound when the slider loses focus, ie when the car is released softwareMode = glass.GlassCheckbox(); softwareMode.linkCvar("sound_softwareMode"); table.addRow("Software Mode", softwareMode); mixrate = glass.GlassDropMenu(); mixrate.linkCvar("sound_mixrate"); mixrate.addOption("22050", "22050") mixrate.addOption("44100", "44100") mixrate.addOption("48000", "48000") table.addRow("Sampling Rate", mixrate); channels = glass.GlassSpinner(); channels.linkCvar("sound_numChannels"); channels.setStep(32); channels.setWidth(50); table.addRow("Sound Channels", channels); VoIPVolume = glass.GlassSlider(); VoIPVolume.linkCvar( "sound_voipvolume" ); VoIPVolume.setScaleEnd(1.0); VoIPVolume.setScaleStart(0); table.addRow("Voice Volume", VoIPVolume); table.adjustSizeTo(); tableHolder = glass.GlassScrollArea(table); tableHolder.setSize(table.getWidth(), table.getHeight()); return tableHolder;
def __init__(self): glass.GlassWindow.__init__(self, 'Options'); self.first=True; #build the restart window w = glass.GlassWindow('Restart'); glass.GUI_ScreenAddWidget("mainmenu", w); w.setSizePct(.4, .15); w.centerWindow(); w.setBackgroundColor(glass.Color(0,0,0,128)); w.setMovable(0); w.setTitleVisible(0); w.setVisible(False); l = glass.GlassLabel("This change will not take effect until you restart.\nWould you like to restart now?"); w.add(l, 10, 10); b = glass.GlassButton("Restart"); b.setClickAction("shutdown(1);"); w.add(b, 50, 60); b = glass.GlassButton("Cancel"); b.setClickAction("w=glass.GUI_GetWindow('mainmenu:Restart');w.setVisible(False);w.releaseModalFocus()"); w.add(b, 150, 60); self.setBackgroundColor(glass.Color(0,0,0,128)) self.setTitleVisible(0) self.nickname = None;
def __init__(self): glass.GlassContainer.__init__(self) gblBuddyManager.addList(self) self.setSizePct(self.WIDTH_PROPORTION, self.HEIGHT_PROPORTION) self.toggle = glass.GlassButton("0") #either add in a custom button background here, including the buddy logo #or just bodge it with ^icon^ #wtf was I thinking, GlassButton accepts an icon param self.toggle.setY(self.getHeight() - self.toggle.getHeight()) self.toggle.addMouseListener(self) self.add(self.toggle) self.window = glass.GlassWindow() self.window.setCaption("Buddies") self.window.setAlpha(0) self.window.setVisible(False) self.window.setMovable(0) self.window.setSize(self.getWidth(), self.getHeight() - self.toggle.getHeight()) self.window.setPosition(0, 0) self.add(self.window) ca = self.window.getChildrenArea() self.new = glass.ImageButton() self.new.setImage("/gui/standard/icons/plus.s2g") self.new.setX(ca.width - self.PADDING - self.new.getWidth()) self.new.addMouseListener(self) self.window.add(self.new) self.input = glass.GlassTextField("Add new...") self.input.setX(self.PADDING) self.input.setWidth(self.new.getX() - self.PADDING - self.input.getX()) self.input.addMouseListener(self) self.window.add(self.input) y2 = max(self.new.getHeight(), self.input.getHeight()) y1 = ca.height - y2 self.new.setY(y1 + (y2 - self.new.getHeight()) // 2) self.input.setY(y1 + (y2 - self.input.getHeight()) // 2) self.listbox = glass.GlassListBox() self.listbox.setBackgroundColor(transparency) self.scroll = glass.GlassScrollArea(self.listbox) self.scroll.setSize(ca.width, y1 - self.PADDING) self.window.add(self.scroll) self.listbox.setWidth(ca.width - self.scroll.getScrollbarWidth())
def frame(): pass; def onShow(): pass; glass.GUI_CreateScreen('guitest'); bg = glass.GlassLabel(); 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);
def __init__(self): DefaultWindow.__init__(self) self.alertWindow = None self.setBackgroundColor(transparency) self.setSize(980, 530) self.sectionStack = {} self.currentSection = "serverlist" self.previousSection = None msgs = [ "Confirm making a huge mistake in your life?", "You want to quit? Then thou hast lost an eighth!", "Yeah, get to your Fortnite-addicts anonymous meeting. Addict.", "Don't quit! Savage makes a great chat client!", "Press Cancel to quit. Psych!", "You've almost reached that achievement, just play a bit longer...", "Very well then, be that way! We won't even bother with the traditional royal farewell!", "No one likes a quitter." ] msg = M_Randnum() % len(msgs) self.quitConfirm = DefaultConfirm(msgs[msg], "shutdown();", "Quit") self.add(self.quitConfirm, "center", "center") class ButtonGroup: def __init__(self, buttonList): self.buttons = buttonList self.selectionListeners = [] self.selected = 0 for i, button in enumerate(self.buttons): button.addActionListener(self) self.buttons[self.selected].setState( glass.ImageButton.GB_PRESSED) def onAction(self, e): self.buttons[self.selected].setState(glass.ImageButton.GB_IDLE) self.selected = self.buttons.index(e.widget) self.buttons[self.selected].setState( glass.ImageButton.GB_PRESSED) e = glass.ValueChangedEvent(self) for l in self.selectionListeners: l.onValueChanged(e) def addSelectionListener(self, listener): self.selectionListeners.append(listener) def getSelection(self): return self.buttons[self.selected] joinGame = glass.GlassButton("JOIN A GAME") joinGame.setStyle("main") joinGame.setSize(264, 42) joinGame.setFont(fontSizeLarge) self.add(joinGame, 0, 0) hostGame = glass.GlassButton("HOST GAME") hostGame.setStyle("main") hostGame.setSize(264, 42) hostGame.setFont(fontSizeLarge) self.add(hostGame, 0, 52) options = glass.GlassButton("OPTIONS") options.setStyle("main") options.setSize(264, 42) options.setFont(fontSizeLarge) self.add(options, 0, 104) self.buttonGroup = ButtonGroup([joinGame, hostGame, options]) self.buttonGroup.addSelectionListener(self) self.quit = glass.GlassButton("QUIT") self.quit.setStyle("main") self.quit.setSize(264, 42) self.quit.setClickAction( "mainmenu.modules['menu'].quitConfirm.setVisible(True)") self.quit.setFont(fontSizeLarge) self.add(self.quit, 0, 156) # Until big fixes windows: class NewsWindow(DefaultWindow): def __init__(self): DefaultWindow.__init__(self) self.setFrameStyle("TrimmedEight") self.httpHandle = -1 gblEventHandler.addHttpListener(self) self.setSize(265, 200) self.setVisible(False) self.setTitleVisible(False) self.setBackgroundColor(windowBackground) top = DefaultContainer() self.add(top, 0, 0) top.setSize(self.getWidth(), 35) top.setBackgroundColor(windowTop) """ title = DefaultImage(); title.setImage("txt_savagenews.png"); top.add(title, "center", "center"); content = DefaultContainer(); self.add(content, 10, 42); content.setSize(245, 148); self.heading = DefaultLabel("Savage Rebirth Pre-Beta has begun!") content.add(self.heading, 0, 0); self.heading.setFont(fontSizeSmall); """ title = DefaultLabel("Important Bulletin") title.setForegroundColor(tangoYellowDark) title.setFont(fontSizeLarge) top.add(title, "center", "center") self.text = DefaultTextBox("No News.") self.text.setSize(245, 200) self.text.setBackgroundColor(transparency) self.text.setForegroundColor(glass.Color(211, 201, 168)) self.text.setFont(fontSizeSmall) self.text.setEditable(False) self.add(self.text, 10, 50) """ self.date = DefaultLabel("7:16pm, 3.11.2011"); self.date.setFont(fontSizeSmall); content.add(self.date, "left", "bottom"); self.readMore = DefaultLabel("...read more"); self.readMore.setFont(fontSizeSmall); self.readMore.setForegroundColor(tangoYellow); self.readMore.addActionListener(self); content.add(self.readMore, "right", "bottom"); """ def getNews(self): self.httpHandle = HTTP_Get( "http://savagerebirth.com/misc/news") def onEvent(self, e): if e.handle == self.httpHandle: self.httpHandle = -1 msg = e.responseMessage #.replace("\n", " "); if len(msg) == 0: self.setVisible(False) else: self.setVisible(True) self.text.setText(msg) #else: # self.setVisible(False); div = DefaultDivider() div.setForegroundColor(tangoRed) self.add(div, 0, self.quit.getY() + self.quit.getHeight() + 10) div.setWidth(self.quit.getWidth()) self.news = NewsWindow() self.add(self.news, 0, div.getY() + div.getHeight() + 10) if int(cvar_get("con_developer")): #execwindow.newExecWindow("mainmenu"); #self.add(DevTools(), 0, self.quit.getY() + self.quit.getHeight() + 10); pass
fave_unit.setSizePct(0.075,0); fave_unit.setHeight( vbreakpx - fave_unit.getY() - PADDING); fave_unit.rotateModel(160); glass.GUI_ScreenAddWidget("endgame",fave_unit); name = glass.GlassLabel(allyColorCode + "Player Name"); name.setPosition( fave_unit.getX() + fave_unit.getWidth() + PADDING, fave_unit.getY() ); name.setWidth( hbreak1px - PADDING - name.getX() ); glass.GUI_ScreenAddWidget("endgame",name); score = glass.GlassLabel("Score: ^g0^w/^r0^w/^y0"); score.setPosition( name.getX(), name.getY() + name.getHeight() + PADDING ); score.setWidth( name.getWidth() ); glass.GUI_ScreenAddWidget("endgame",score); accuracy = glass.GlassButton("Accuracy"); accuracy.setClickAction("endgame.accuracy_window.setVisible(True); ActionSequence(FadeInAction(endgame.accuracy_window))"); accuracy.setY( score.getY() + score.getHeight() + PADDING); glass.GUI_ScreenAddWidget("endgame",accuracy); accuracy_window = AccuracyWindow(); glass.GUI_ScreenAddWidget("endgame", accuracy_window); #TODO: whatever yeti does to enable the close button (or change what the accuracy button does) career = glass.GlassButton("Career Stats"); career.setY( accuracy.getY() + accuracy.getHeight() + PADDING); career.setClickAction(""); #TODO glass.GUI_ScreenAddWidget("endgame",career); w = max( career.getWidth(), accuracy.getWidth() ); for widget in (accuracy, career):
name = glass.GlassLabel("Placeholder Name"); inventoryContainer.add(name); name.setWidth( slot.getWidth() ); name.setPosition( slot.getX(), slot.getY() + slot.getHeight() ); name.setAlignment( glass.Graphics.CENTER ); inventoryNames.append(name); button = glass.ImageButton("textures/econs/transparent.s2g"); inventoryContainer.add(button); button.setSize( slot.getWidth(), slot.getHeight()); button.setPosition( slot.getX(), slot.getY()); button.setClickAction("CL_RequestGiveback("+str(i)+")"); back = glass.GlassButton("Back to Lobby") back.setClickAction("CL_RequestLobby()") main.add(back) back.setPositionPct(.1,.92) spawn = glass.GlassButton("Spawn") spawn.setId("spawnbutton"); spawn.setClickAction("CL_RequestSpawn(-1)") main.add(spawn) spawn.setPositionPct(.8,.92) comm = glass.GlassButton("Command") comm.setId("commbutton"); comm.setClickAction(""" import savage; CL_RequestSpawn(savage.Team(savage.getLocalPlayer().getTeam()).getCommandCenter().objectId);
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); interfaceSpectatorButton.setPositionPct(0.5,0); interfaceChatBox = HUDChatBox(); interfaceChatBox.alwaysShowInput(1); interfaceChatBox.inputType.setVisible(False); interface.add( interfaceChatBox );
scroll.setContent(notifyBuffer); notifyBuffer.setSize(scroll.getWidth(), scroll.getHeight()); notifyBuffer.setFadeTop(1); notifyBuffer.setFadeBottom(0); notifyBuffer.showTime(0); for i in range(10): notifyBuffer.addRow(" "); ## QUICKBAR ## quickbar = glass.GlassContainer(); quickbar.setBackgroundColor(glass.Color(0,0,0,128)); glass.GUI_ScreenAddWidget("commhud",quickbar); quickbar.setPositionPct(.25,.9); quickbar.setSizePct(.5,.1); resign = glass.GlassButton("Resign"); quickbar.add(resign); resign.setPositionPct(0,.01); resign.setClickAction("CL_RequestResign()"); research = glass.GlassButton("Research"); quickbar.add(research); research.setPositionPct(.15,.01); research.setClickAction(""" if commhud.researchWindow.isVisible(): commhud.researchWindow.close(); else: commhud.researchWindow.open(); """); researchWindow = CommResearchWindow();
#window w = glass.GlassWindow("list") w.setBackgroundColor(glass.Color(0, 0, 0, 128)) w.setSizePct(.8, .35) w.setPositionPct(0.1, 0.325) w.setTitleVisible(0) glass.GUI_ScreenAddWidget("serverlist", w) list = GlassListPlus() scr = glass.GlassScrollArea(list) w.add(scr) scr.setSizePct(1, .8) back = glass.GlassButton("Back") w.add(back) back.setClickAction("GUI_ShowScreen('mainmenu')") back.setPositionPct(.10, .0) back.setY(w.getHeight() - back.getHeight() - 5) host = glass.GlassButton("Host Server") w.add(host) host.setClickAction("serverlist.hostServerWindow.showHostServerWindow()") host.setPositionPct(0.6, 0) host.setY(w.getHeight() - host.getHeight() - 5) connect = glass.GlassButton("Connect") w.add(connect) connect.setClickAction( "connect(serverlist.list.getItem(serverlist.list.getSelected(), 1))")
noMap.setX(overlay.getX() + (overlay.getWidth() - noMap.getWidth()) // 2) noMap.setY(overlay.getY() + overlay.getHeight() // 2 - noMap.getHeight() - pxpadding // 2) glass.GUI_ScreenAddWidget("demos", noMap) noOverhead = glass.GlassLabel("^rMinimap file missing!") noOverhead.setPosition(noMap.getX(), noMap.getY() + noMap.getHeight() + pxpadding) glass.GUI_ScreenAddWidget("demos", noOverhead) size = glass.GlassLabel("Length: xy.ab MB") size.setPosition(server.getX(), overlay.getY() + overlay.getHeight() + pxpadding * 2) glass.GUI_ScreenAddWidget("demos", size) play = glass.GlassButton("PLAY DEMO") play.setPosition(size.getX(), size.getY() + size.getHeight() + pxpadding) h = play.getHeight() play.setSizePct(1.0 - xoffset - 2 * padding, 0) play.setWidth(play.getWidth() - pxpadding) play.setHeight(h) play.setClickAction("demos.handler.play()") glass.GUI_ScreenAddWidget("demos", play) rename = glass.GlassButton("Rename") rename.setClickAction("demos.handler.confirmRename()") rename.setPosition(play.getX(), play.getY() + play.getHeight() + pxpadding) rename.setWidth((play.getWidth() - pxpadding) // 2) glass.GUI_ScreenAddWidget("demos", rename)