def getIconSize(): """Determines the size of profile icons. @return Size of profile icons in pixels, as a string.""" if st.getSystemBoolean("profile-large-icons"): return 50 else: return 27
def getIconSize(): """Determines the size of profile icons. @return Size of profile icons in pixels, as a string.""" if st.getSystemBoolean('profile-large-icons'): return 50 else: return 27
def makeHTML(name, iconName, gameName=None, boldName=False): # The icon for the game component. iconSize = getIconSize() iconPath = widgets.iconManager.getBitmapPath(iconName, (iconSize, iconSize)) if boldName: nameStyle = ("<b>", "</b>") else: nameStyle = ("", "") if st.getSystemBoolean("profile-large-icons"): padding = 5 else: padding = 3 html = '<table width="100%%" border=0 cellspacing=2 cellpadding=%i>' % padding html += '<tr><td width="%i"' % iconSize + '><img width="%i"' % iconSize html += ' height="%i"' % iconSize + ' src="' + iconPath + '"></td><td>' html += '<font size="+1">' + nameStyle[0] + name + nameStyle[1] + "</font>" if gameName: html += '<br><font color="#808080" size="-1">' + gameName + "</font>" html += "</td></tr></table>" return html
def notifyHandler(event): if summaryDisabled: return if event.hasId('active-profile-changed'): p = pr.getActive() titleLabel.setText(p.getName()) # Update the summary entries. updateSummary(p) # Change to the Summary tab automatically. if event.hasId('active-profile-changed') and \ st.getSystemBoolean('summary-profile-change-autoselect'): if event.wasChanged(): # The profile did actually change. ui.selectTab(SUMMARY) elif event.hasId('value-changed') or \ event.hasId('addon-attached') or \ event.hasId('addon-detached'): # Resummarize due to a changed value of a setting. updateSummary(pr.getActive())
def makeHTML(name, iconName, gameName=None, boldName=False): # The icon for the game component. iconSize = getIconSize() iconPath = widgets.iconManager.getBitmapPath(iconName, (iconSize, iconSize)) if boldName: nameStyle = ('<b>', '</b>') else: nameStyle = ('', '') if st.getSystemBoolean('profile-large-icons'): padding = 5 else: padding = 3 html = '<table width="100%%" border=0 cellspacing=2 cellpadding=%i>' % padding html += '<tr><td width="%i"' % iconSize + '><img width="%i"' % iconSize html += ' height="%i"' % iconSize + ' src="' + iconPath + '"></td><td>' html += '<font size="+1">' + nameStyle[0] + name + nameStyle[1] + '</font>' if gameName: html += '<br><font color="#808080" size="-1">' + gameName + '</font>' html += '</td></tr></table>' return html
def init(): # Create the profile list and the profile control buttons. area = ui.getArea(ui.PROFILES) global profileList area.setBorder(0) if USE_MINIMAL_MODE: area.setWeight(1) area.addSpacer() area.setWeight(3) profileList = area.createDropList("profile-list") profileList.setSorted() area.setWeight(1) area.addSpacer() else: # Normal profile list mode. area.setWeight(1) profileList = area.createFormattedList("profile-list") if not st.getSystemBoolean("profile-hide-buttons"): # This should be a small button. area.setWeight(0) area.setBorder(3) controls = area.createArea(alignment=ALIGN_HORIZONTAL, border=2) controls.setExpanding(False) # area.setExpanding(False) controls.setWeight(0) controls.createButton("new-profile", wg.Button.STYLE_MINI) global deleteButton deleteButton = controls.createButton("delete-profile", wg.Button.STYLE_MINI) global dupeButton dupeButton = controls.createButton("duplicate-profile", wg.Button.STYLE_MINI) # Set the title graphics. global bannerImage try: area = ui.getArea(ui.TITLE) bannerImage = area.createImage("banner-default") except: # There is no title area. bannerImage = None # Register a listener for notifications. events.addNotifyListener( notifyHandler, ["quit", "language-changed", "profile-updated", "active-profile-changed", "profile-list-selected"], ) # Register a listener for commands. events.addCommandListener( commandHandler, [ "freeze", "unfreeze", "new-profile", "rename-profile", "reset-profile", "delete-profile", "duplicate-profile", "hide-profile", "unhide-profiles", ], ) # Commands for the menu. ui.addMenuCommand(ui.MENU_PROFILE, "new-profile", group=ui.MENU_GROUP_PROFDB) ui.addMenuCommand(ui.MENU_PROFILE, "unhide-profiles", group=ui.MENU_GROUP_PROFDB) ui.addMenuCommand(ui.MENU_PROFILE, "reset-profile", group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, "rename-profile", group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, "duplicate-profile", group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, "hide-profile", group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, "delete-profile", group=ui.MENU_GROUP_PROFILE)
# along with this program; if not: http://www.opensource.org/ ## @file profilelist.py Profile List import ui, events, widgets import sb.util.dialog import sb.widget.button as wg import sb.widget.text as wt import sb.widget.list import sb.profdb as pr import sb.confdb as st import language import paths from ui import ALIGN_HORIZONTAL USE_MINIMAL_MODE = st.getSystemBoolean("profile-minimal-mode") profileList = None deleteButton = None dupeButton = None # If set to true, the profile list won't be updated on notifications. profileListDisabled = False # Popup menus. defaultsMenu = ["reset-profile", "-", "new-profile", "unhide-profiles"] normalMenu = [ "hide-profile", "rename-profile", "duplicate-profile",
def init(): # Create the profile list and the profile control buttons. area = ui.getArea(ui.PROFILES) global profileList area.setBorder(0) if USE_MINIMAL_MODE: area.setWeight(1) area.addSpacer() area.setWeight(3) profileList = area.createDropList('profile-list') profileList.setSorted() area.setWeight(1) area.addSpacer() else: # Normal profile list mode. area.setWeight(1) profileList = area.createFormattedList("profile-list") if not st.getSystemBoolean('profile-hide-buttons'): # This should be a small button. area.setWeight(0) area.setBorder(3) controls = area.createArea(alignment=ALIGN_HORIZONTAL, border=2) controls.setExpanding(False) #area.setExpanding(False) controls.setWeight(0) controls.createButton('new-profile', wg.Button.STYLE_MINI) global deleteButton deleteButton = controls.createButton('delete-profile', wg.Button.STYLE_MINI) global dupeButton dupeButton = controls.createButton('duplicate-profile', wg.Button.STYLE_MINI) # Set the title graphics. global bannerImage try: area = ui.getArea(ui.TITLE) bannerImage = area.createImage('banner-default') except: # There is no title area. bannerImage = None # Register a listener for notifications. events.addNotifyListener(notifyHandler, [ 'quit', 'language-changed', 'profile-updated', 'active-profile-changed', 'profile-list-selected' ]) # Register a listener for commands. events.addCommandListener(commandHandler, [ 'freeze', 'unfreeze', 'new-profile', 'rename-profile', 'reset-profile', 'delete-profile', 'duplicate-profile', 'hide-profile', 'unhide-profiles' ]) # Commands for the menu. ui.addMenuCommand(ui.MENU_PROFILE, 'new-profile', group=ui.MENU_GROUP_PROFDB) ui.addMenuCommand(ui.MENU_PROFILE, 'unhide-profiles', group=ui.MENU_GROUP_PROFDB) ui.addMenuCommand(ui.MENU_PROFILE, 'reset-profile', group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, 'rename-profile', group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, 'duplicate-profile', group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, 'hide-profile', group=ui.MENU_GROUP_PROFILE) ui.addMenuCommand(ui.MENU_PROFILE, 'delete-profile', group=ui.MENU_GROUP_PROFILE)
# along with this program; if not: http://www.opensource.org/ ## @file profilelist.py Profile List import ui, events, widgets import sb.util.dialog import sb.widget.button as wg import sb.widget.text as wt import sb.widget.list import sb.profdb as pr import sb.confdb as st import language import paths from ui import ALIGN_HORIZONTAL USE_MINIMAL_MODE = st.getSystemBoolean('profile-minimal-mode') profileList = None deleteButton = None dupeButton = None # If set to true, the profile list won't be updated on notifications. profileListDisabled = False # Popup menus. defaultsMenu = ['reset-profile', '-', 'new-profile', 'unhide-profiles'] normalMenu = [ 'hide-profile', 'rename-profile', 'duplicate-profile', 'reset-profile', 'delete-profile', '-', 'new-profile', 'unhide-profiles' ]
# Border flags. BORDER_TOP = 1 BORDER_RIGHT = 2 BORDER_BOTTOM = 4 BORDER_LEFT = 8 BORDER_TOP_BOTTOM = (1 | 4) BORDER_LEFT_RIGHT = (2 | 8) BORDER_NOT_TOP = (2 | 4 | 8) BORDER_NOT_RIGHT = (1 | 4 | 8) BORDER_NOT_BOTTOM = (1 | 2 | 8) BORDER_NOT_LEFT = (1 | 2 | 4) BORDER_ALL = (1 | 2 | 4 | 8) # Optional areas. USE_TITLE_AREA = not st.getSystemBoolean('main-hide-title') USE_HELP_AREA = not st.getSystemBoolean('main-hide-help') USE_MINIMAL_PROFILE = st.getSystemBoolean('profile-minimal-mode') # A Windows kludge: background colour for tabs and the controls in them. #tabBgColour = wx.Colour(250, 250, 250) #st.getSystemInteger('tab-background-red'), # st.getSystemInteger('tab-background-green'), # st.getSystemInteger('tab-background-blue')) # An array of UI areas. uiAreas = {} mainPanel = None # Items for the popup menu. Up to seven menus. menuItems = [[], [], [], [], [], [], []]