Skip to content

Commit

Permalink
Added system setting for hiding profile buttons.
Browse files Browse the repository at this point in the history
Addon categories sorted alphabetically.

Reintroduced automatic 0-9, A-G, etc. subcategories for Maps.

All Addons root category expanded automatically.
  • Loading branch information
skyjake committed Jan 5, 2007
1 parent 2b7526f commit 6775fec
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 22 deletions.
6 changes: 6 additions & 0 deletions snowberry/lang/english.lang
Expand Up @@ -316,6 +316,11 @@ category-gamedata: Game Data
category-gamedata-doomsday: Doomsday Game Files
category-gamedata-primary: Primary Data Files
category-gamedata-maps: Maps
category-gamedata-maps-ag: A-G
category-gamedata-maps-hm: H-M
category-gamedata-maps-ns: N-S
category-gamedata-maps-tz: T-Z
category-gamedata-maps-09: 0-9
category-gamedata-lumps: Data Lumps
category-patches: DeHackEd Patches
category-definitions: Doomsday Engine Definitions
Expand Down Expand Up @@ -458,6 +463,7 @@ addon-paths-add-prompt: Add to My Addon Paths
ui-parts: User Interface
main-hide-title: Hide title banner
main-hide-help: Hide help panel
profile-hide-buttons: Hide profile buttons
summary-profile-change-autoselect: Profile change shows Summary
profile-large-icons: Large profile icons

Expand Down
3 changes: 2 additions & 1 deletion snowberry/plugins/preferences.py
Expand Up @@ -109,8 +109,9 @@ def removeAddonPath():
# TODO: Create widgets for all system settings?
box.createSetting(st.getSystemSetting('main-hide-title'))
box.createSetting(st.getSystemSetting('main-hide-help'))
box.createSetting(st.getSystemSetting('summary-profile-change-autoselect'))
box.createSetting(st.getSystemSetting('profile-hide-buttons'))
box.createSetting(st.getSystemSetting('profile-large-icons'))
box.createSetting(st.getSystemSetting('summary-profile-change-autoselect'))

box.createText('restart-required', align=wt.Text.RIGHT).setSmallStyle()

Expand Down
39 changes: 21 additions & 18 deletions snowberry/plugins/profilelist.py
Expand Up @@ -33,6 +33,8 @@
from ui import ALIGN_HORIZONTAL

profileList = None
deleteButton = None
dupeButton = None

# If set to true, the profile list won't be updated on notifications.
profileListDisabled = False
Expand Down Expand Up @@ -123,22 +125,23 @@ def init():
global profileList
profileList = area.createFormattedList("profile-list")

# 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)
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 deleteButton
deleteButton = controls.createButton('delete-profile',
wg.Button.STYLE_MINI)

global dupeButton
dupeButton = controls.createButton('duplicate-profile',
wg.Button.STYLE_MINI)
global dupeButton
dupeButton = controls.createButton('duplicate-profile',
wg.Button.STYLE_MINI)

# Set the title graphics.
global bannerImage
Expand Down Expand Up @@ -225,17 +228,17 @@ def notifyHandler(event):
profileList.selectItem(pr.getActive().getId())

if pr.getActive() is pr.getDefaults():
deleteButton.disable()
dupeButton.disable()
if deleteButton: deleteButton.disable()
if dupeButton: dupeButton.disable()
ui.disableMenuCommand('rename-profile')
ui.disableMenuCommand('delete-profile')
ui.disableMenuCommand('hide-profile')
ui.disableMenuCommand('duplicate-profile')
profileList.setPopupMenu(defaultsMenu)
else:
isSystem = pr.getActive().isSystemProfile()
deleteButton.enable(not isSystem)
dupeButton.enable()
if deleteButton: deleteButton.enable(not isSystem)
if dupeButton: dupeButton.enable()
ui.enableMenuCommand('rename-profile')
ui.enableMenuCommand('delete-profile', not isSystem)
ui.enableMenuCommand('hide-profile')
Expand Down
3 changes: 3 additions & 0 deletions snowberry/plugins/tab30.plugin/Contents/tab30/main.py
Expand Up @@ -200,6 +200,7 @@ def refreshCategories():
tree.clear()
# Start populating from the root category.
buildCategories(tree, 'category-tree-root', ao.getRootCategory())
tree.expandItem('category-tree-root')
tree.unfreeze()


Expand All @@ -211,6 +212,8 @@ def buildCategories(tree, parentId, parentCategory):
tree.addItem(id, parentId)
buildCategories(tree, id, cat)

tree.sortItemChildren(parentId)


def refreshListIfVisible():
global mustRefreshList
Expand Down
19 changes: 18 additions & 1 deletion snowberry/sb/addon.py
Expand Up @@ -649,6 +649,9 @@ def readMetaData(self):

# Look at the path where the WAD file is located.
path = self.getContentPath().lower()
# But ignore the user addon path.
if path.find(paths.getUserPath(paths.ADDONS).lower()) == 0:
path = path[len(paths.getUserPath(paths.ADDONS)) + 1:]

if 'heretic' in path or 'htic' in path:
game = 'jheretic'
Expand Down Expand Up @@ -726,7 +729,21 @@ def readMetaData(self):

if maps or episodic:
category += 'maps/'


# Category based on the name.
base = paths.getBase(self.getContentPath()).lower()

if base[0] in string.digits:
category += '09/'
if base[0] in 'abcdefg':
category += 'ag/'
if base[0] in 'hijklm':
category += 'hm/'
if base[0] in 'nopqrs':
category += 'ns/'
if base[0] in 'tuvwxyz':
category += 'tz/'

metadata += "category: %s\n" % category

# Game component.
Expand Down
2 changes: 2 additions & 0 deletions snowberry/sb/confdb.py
Expand Up @@ -592,6 +592,8 @@ def init():
_newSystemSetting(tog)
tog = conf.ToggleSetting('profile-large-icons', '', 'no', '')
_newSystemSetting(tog)
tog = conf.ToggleSetting('profile-hide-buttons', '', 'no', '')
_newSystemSetting(tog)

# Load all .conf files.
for path in paths.listPaths(paths.CONF, False):
Expand Down
16 changes: 14 additions & 2 deletions snowberry/sb/widget/tree.py
Expand Up @@ -98,8 +98,7 @@ def addItem(self, identifier, parentId=None):
w = self.getWxWidget()
try:
parentItem = self.items[parentId]
item = w.AppendItem(parentItem,
language.translate(identifier))
item = w.AppendItem(parentItem, language.translate(identifier))
except:
item = w.AddRoot(language.translate(identifier))

Expand Down Expand Up @@ -183,3 +182,16 @@ def selectItem(self, identifier):
"""
tree = self.getWxWidget()
tree.SelectItem(self.items[identifier])

def expandItem(self, identifier, doExpand=True):
tree = self.getWxWidget()
if doExpand:
tree.Expand(self.items[identifier])
else:
tree.Collapse(self.items[identifier])

def collapseItem(self, identifier):
self.expandItem(identifier, False)

def sortItemChildren(self, identifier):
self.getWxWidget().SortChildren(self.items[identifier])

0 comments on commit 6775fec

Please sign in to comment.