Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Nov 24, 2015
2 parents a3e0dd0 + 9fc4933 commit 4df9485
Show file tree
Hide file tree
Showing 32 changed files with 3,262 additions and 507 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ packages/
# The auto-generated palette
palettes/LAST_EXPORT.zip

# Error file
BEE2-error.log

# Ignore dev output
test_out.vmf
preview_styled.vmf

#These folders are generated automatically by the BEE2
images/cache/
inst_cache/
Expand All @@ -75,5 +68,6 @@ config/item_configs.cfg
config/config.cfg
config/games.cfg
config/compile.cfg
config/packages.cfg
config/voice/
config/screenshot.jpg
4 changes: 2 additions & 2 deletions src/BEE2.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if __name__ == '__main__':
# BEE2_config creates this config file to allow easy cross-module access
from BEE2_config import GEN_OPTS

from tk_root import TK_ROOT
from tk_tools import TK_ROOT
import UI
import loadScreen
import paletteLoader
Expand Down Expand Up @@ -62,7 +62,7 @@ if __name__ == '__main__':
'log_missing_ent_count': '0',
},
}
loadScreen.main_loader.set_length('UI', 9)
loadScreen.main_loader.set_length('UI', 14)
loadScreen.main_loader.show()

if utils.MAC:
Expand Down
23 changes: 16 additions & 7 deletions src/BEE2_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os.path

from configparser import ConfigParser
from configparser import ConfigParser, NoOptionError


class ConfigFile(ConfigParser):
"""A version of ConfigParser which can easily save itself.
The config will track whether any values change, and only resave
if modified.
get_val, get_bool, and get_int are modified to return defaults instead
of erroring.
"""
def __init__(self, filename, root='../config', auto_load=True):
"""Initialise the config file.
Expand Down Expand Up @@ -79,9 +86,10 @@ def getboolean(self, section, value, default=False) -> bool:
"""
if section not in self:
self[section] = {}
if value in self[section]:
try:
return super().getboolean(section, value)
else:
except (ValueError, NoOptionError):
# Invalid boolean, or not found
self.has_changed = True
self[section][value] = str(int(default))
return default
Expand All @@ -95,9 +103,9 @@ def getint(self, section, value, default=0) -> int:
"""
if section not in self:
self[section] = {}
if value in self[section]:
try:
return super().getint(section, value)
else:
except (ValueError, NoOptionError):
self.has_changed = True
self[section][value] = str(int(default))
return default
Expand All @@ -114,9 +122,10 @@ def remove_section(self, section):

def set(self, section, option, value=None):
orig_val = self.get(section, option, fallback=None)
if orig_val is None or orig_val is not value:
value = str(value)
if orig_val is None or orig_val != value:
self.has_changed = True
super().set(section, option, str(value))
super().set(section, option, value)

add_section.__doc__ = ConfigParser.add_section.__doc__
remove_section.__doc__ = ConfigParser.remove_section.__doc__
Expand Down
Loading

0 comments on commit 4df9485

Please sign in to comment.