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 add(obj, x=None, y=None): if x is not None: if x == "left": obj.setX(5) elif x == "right": obj.setX(screenWidth - obj.getWidth() - 5) elif x == "center": obj.setX(screenWidthPct(0.5) - obj.getWidth() // 2) else: obj.setX(x) if y == "top": obj.setY(5) elif y == "bottom": obj.setY(screenHeight - obj.getHeight() - 5) elif y == "center": obj.setY(screenHeightPct(0.5) - obj.getHeight() // 2) else: obj.setY(y) glass.GUI_ScreenAddWidget("commhud", obj)
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 onMouseClick(self, e): if isinstance(e.widget, glass.GlassWindow): w = glass.GUI_GetWindow("mainmenu:binder"); w.erase(); w.close(); bindKeyAction(e.button+199, self.action, self.profile); #ain't I a stinker? self.controlwidget.setText(makePretty(self.action, self.profile)); else: self.action = e.widget.getId(); self.controlwidget = e.widget; w = glass.GlassWindow('binder'); glass.GUI_ScreenAddWidget("mainmenu", w); label = glass.GlassLabel("Press a key to bind..."); label.setForegroundColor(glass.Color(255,255,255)); w.add(label); w.addMouseListener(self); w.addKeyListener(self); w.setTitleVisible(0); w.setBackgroundColor(glass.Color(0,0,0,50)); w.setSizePct(.25,.1); w.requestModalFocus(); w.centerWindow();
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))); gblEventHandler.addGameListener(SpawnSelectHandler()); ## CREATE SCREEN ## glass.GUI_CreateScreen("loadout"); overlay = DefaultImage(); overlay.setImage("/gui/main/images/loading_overlay.png", False); overlay.setSizePct(1.0,1.0); glass.GUI_ScreenAddWidget("loadout", overlay); activeWindow = None; humanLoadout = LoadoutWindow("human"); glass.GUI_ScreenAddWidget("loadout", humanLoadout); beastLoadout = LoadoutWindow("beast"); glass.GUI_ScreenAddWidget("loadout", beastLoadout); #well, here's a fine hack. #glass.GUI_ScreenAddWidget("loadout", gblPresetManager); #stats that are interesting while in loadout expWindow = LoadoutStatsWindow(); expWindow.setPosition(humanLoadout.getX(), int(screenHeight*.0976563)); glass.GUI_ScreenAddWidget("loadout", expWindow);
loading.mapback.setImage(cvar_get("world_overhead")) loading.mapback.setPositionPct(.25, .16667) loading.mapback.setSizePct(.5, .6667) loading.loadingbk.setPositionPct(.25, .16667) loading.loadingLabel.setCaption("Loading " + cvar_get("world_name") + "...") loading.loadingLabel.setPositionPct(.4, .69) loading.loadingbk.setSizePct(.5, .6667) loading.loadingProgress.setPositionPct(.3, .72) glass.GUI_CreateScreen('loading') loadingbk = glass.GlassLabel() loadingbk.setImage('/gui/standard/black.s2g') glass.GUI_ScreenAddWidget('loading', loadingbk) loadingbk.setSizePct(1, 1) mapback = glass.GlassLabel() mapback.setId('mapback') glass.GUI_ScreenAddWidget('loading', mapback) loadingbk = glass.GlassLabel() loadingbk.setImage('/textures/loading/nfm_mapoverlay.s2g') #uncomment this when a solution is found to resolution not being set when #these scripts are run #loadingbk.setPosition(int(Vid_GetScreenW()/2.0-256),int(Vid_GetScreenH()/2.0-256)) glass.GUI_ScreenAddWidget('loading', loadingbk) loadingLabel = glass.GlassLabel("Loading xxxxxxxxxxxxxxxxxxxxxxxxx") loadingLabel.setForegroundColor(glass.Color(59, 45, 25))
from silverback import *; import glass; 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");
## Defining both teams here as they should not change team1 = savage.Team(1) team2 = savage.Team(2) #starting from the gold to the right of the minimap and proceeding anti clockwise ## MAP and surrounding things ## minimap = glass.GlassMiniMap() minimap.setPositionPct(0, 0.025) minimap.setX(10) minimap.setSize(int(0.208 * screenHeight), int(0.208 * screenHeight)) #same number of pixels so it's square #well assuming the pixel aspect ratio is 1:1 glass.GUI_ScreenAddWidget("spechud", minimap) player_money = glass.GlassLabel("_ABCDE ") player_money.setForegroundColor(gold) player_money.setPosition(int(minimap.getWidth() + 10 + screenWidth * 0.01875), int(screenHeight * 0.025)) glass.GUI_ScreenAddWidget("spechud", player_money) timer = glass.GlassLabel("_AB:CD ") timer.setFont(glass.GUI_GetFont(20)) timer.setPosition(10, minimap.getHeight() + 20) glass.GUI_ScreenAddWidget("spechud", timer) ## TEAM STATUS ##
def onValueChanged(self, e): modeltest.modelviewer.setModel( modeltest.modeldropmenu.getSelectedValue()) class AnimChangeHandler: def onValueChanged(self, e): modeltest.modelviewer.setAnimation( modeltest.animdropmenu.getSelectedValue()) bg = glass.GlassLabel() bg.setBackgroundColor(glass.Color(0, 0, 0, 255)) bg.setSizePct(1, 1) bg.setPosition(0, 0) glass.GUI_ScreenAddWidget("modeltest", bg) modelviewer = glass.GlassViewer() modelviewer.setModel("/models/null.model") modelviewer.setCameraPosition(0, 10, 10) modelviewer.setCameraTarget(0, 0, 10) modelviewer.setPosition(0, 0) modelviewer.setSizePct(1, 1) glass.GUI_ScreenAddWidget("modeltest", modelviewer) modeldropmenu = glass.GlassDropMenu() modeldropmenu.setPositionPct(0.2, 0) modeldropmenu.linkCvar("gui_modelviewermodel") modeldropmenu.addSelectionListener(ModelChangeHandler()) glass.GUI_ScreenAddWidget("modeltest", modeldropmenu)
loadout.map_window.setAlpha(0); loadout.map_window.setVisible(False); techColumns = []; lastTeamNum = -1; glass.GUI_CreateScreen("loadout"); goldLabel = glass.GlassLabel("^icon ../../gui/standard/icons/gold/gold_icon^" + "_____"); goldLabel.setFont(fontSizeLarge); goldLabel.setForegroundColor(gold); 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);
import savage; def frame(): lobby.update(); def onShow(): lobby.arrange(); glass.GUI_CreateScreen('lobby'); 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");
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); minimap.setSize(int(0.208*screenHeight),int(0.208*screenHeight)); minimap.addMouseListener(MapClickHandler()); ## TIMER ## timer = glass.GlassLabel("_AB:CD "); timer.setFont(glass.GUI_GetFont(20)); timer.setPositionPct(0.01875, 0.025+0.208); glass.GUI_ScreenAddWidget("commhud", timer); ## VOTES ##
glass.GUI_CreateScreen("serverlist") httpHandle = -1 gblEventHandler.addHttpListener(ServerListHandler()) #build the viewer background v = glass.GlassViewer() v.showWorld(1) v.setOpaque(0) v.setEnabled(0) v.setSizePct(1, .80) v.setPositionPct(0, 0) v.setCameraPosition(4720, 1830, 297) v.setCameraTarget(100, 500, 550) glass.GUI_ScreenAddWidget("serverlist", v) l = glass.GlassLabel() l.setImage("/gui/standard/maintitle.png") l.setSizePct(1, 1) glass.GUI_ScreenAddWidget("serverlist", l) topstatus = GlassTopStatusBar() glass.GUI_ScreenAddWidget("serverlist", topstatus) gblEventHandler.addNotifyListener(topstatus) #window w = glass.GlassWindow("list") w.setBackgroundColor(glass.Color(0, 0, 0, 128)) w.setSizePct(.8, .35) w.setPositionPct(0.1, 0.325)
#remove any other placeholders def setMode(m): if m == "lobby": spechud.hud.setVisible(False) spechud.lobby.setVisible(True) elif m == "hud": spechud.lobby.setVisible(False) spechud.hud.setVisible(True) glass.GUI_CreateScreen('spechud') lobby = LobbyWindow() glass.GUI_ScreenAddWidget("spechud", lobby) # Main container that contains all widgets that are show when NOT in lobby hud = DefaultContainer() hud.setOpaque(False) glass.GUI_ScreenAddWidget("spechud", hud) hud.setSizePct(1, 1) ## Defining both teams here as they should not change team1 = savage.Team(1) team2 = savage.Team(2) #starting from the gold to the right of the minimap and proceeding anti clockwise ## MAP and surrounding things ##
hud.scoreboard.arrange(); hud.scoreboard.update(); #remove the placeholders in scoreboard hud.crosshair.reset(); hud.voteWindow.reset(); hud.timer.setCaption(""); hud.frame(); #remove any other placeholders glass.GUI_CreateScreen('hud'); ## ORDER/WAYPOINT ## waypoint = glass.GlassLabel(); waypoint.setImage("null.s2g"); waypoint.setVisible(False); waypoint.setSize(48,48); glass.GUI_ScreenAddWidget("hud", waypoint); waypointObject = None; class WaypointHandler: def onEvent(self, e): if isinstance(e, WaypointEvent): if e.eventType == 'waypoint_complete' or e.eventType == 'waypoint_cancel' or e.eventType == 'waypoint_destroy': hud.waypoint.setVisible(False); else: hud.waypoint.setImage(CL_GetWaypointImage()); hud.waypoint.setSize(48,48); hud.waypoint.setVisible(True); if e.targetId != -1: hud.waypointObject = savage.getGameObject(e.targetId); else: hud.waypointObject = None;
endgame.accuracy_window.centerWindow(); endgame.updateGameInfo(); endgame.updateOutcome(); endgame.rebuildAwards(savage.getGameStats()); #gblEventHandler.addHttpListener(endgame.statsHandler); #endgame.statsHandler.httpHandle = HTTP_Get("http://savagerebirth.com/api/index.php/map/"+cvar_get("svr_world")); glass.GUI_CreateScreen('endgame'); bg = glass.GlassLabel(); bg.setBackgroundColor(glass.Color(0,0,0,64)); bg.setSizePct(1,1); glass.GUI_ScreenAddWidget("endgame",bg); PADDING = int(screenHeight*0.01); vbreak = 0.2; vbreakpx = int(vbreak * screenHeight); hbreak1 = 0.25; hbreak1px = int(hbreak1 * screenWidth); hbreak2 = 0.75; hbreak2px = int(hbreak2 * screenWidth); #1. Personal Information fave_unit = glass.GlassViewer(); fave_unit.setBackgroundColor(transparency); fave_unit.setEnabled(False); fave_unit.setPosition(PADDING, PADDING); fave_unit.setSizePct(0.075,0); fave_unit.setHeight( vbreakpx - fave_unit.getY() - PADDING); fave_unit.rotateModel(160);
def add(obj, x=None, y=None): if x is not None: obj.setPosition(x, y) glass.GUI_ScreenAddWidget("loading", obj)
demos.list.addRow(demo) #TODO: maybe add the Demo_GetInfo here demos.list.adjustWidthTo(demos.listWidth) self.done = True def isDone(self): return self.done bg = glass.GlassLabel() bg.setOpaque(1) bg.setBackgroundColor(black) bg.setSize(screenWidth, screenHeight) bg.setPosition(0, 0) glass.GUI_ScreenAddWidget("demos", bg) scroll = glass.GlassScrollArea() scroll.setSizePct(xoffset - 2 * padding, 1.0 - 2 * padding) scroll.setPositionPct(padding, padding) scroll.setVerticalScrollPolicy(scroll.SHOW_ALWAYS) glass.GUI_ScreenAddWidget("demos", scroll) list = GlassListPlus() list.autoAdjust = False listWidth = scroll.getWidth() - scroll.getScrollbarWidth() scroll.setContent(list) name = glass.GlassLabel("demo_name_here") name.setFont(fontSizeLarge) name.setPositionPct(xoffset + padding, padding)