Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bnnm committed Nov 25, 2021
1 parent 371ffed commit 1ea8db8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Or from the command line: `wwiser [options] (files)`
- (loads all .bnk in the dir and starts the viewer)
- `wwiser -g bgm.bnk`
- (generates TXTP files from banks to use with vgmstream)
- `wwiser wwconfig.txt`
- (loads a text list of any CLI commands, to simplify complex usage)
- `wwiser -h`
- (shows all available actions)

Expand Down
27 changes: 17 additions & 10 deletions wwiser/wtxtp_namer.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class TxtpRenamer(object):

def __init__(self):
self._items = []
self._skips = []
self.skip = False

def add(self, items):
Expand All @@ -326,23 +327,19 @@ def add(self, items):
regex_in = regex_in.replace(key, val)
regex = re.compile(regex_in)

self._items.append( (text_in, text_out, regex) )
item = (text_in, text_out, regex)
if text_out == self.SKIP_FLAG:
self._skips.append(item)
else:
self._items.append(item)
return

def apply_renames(self, name):
if not self._items:
if not self._items and not self._skips:
return name

# special "skip this txtp if rename matches" flag (for variables), lasts until next call
self.skip = False

# base renames
for text_in, text_out, regex in self._items:
if text_out == self.SKIP_FLAG:
if text_in in name or regex and regex.match(name):
self.skip = True
continue

if regex:
name = regex.sub(text_out, name)
else:
Expand All @@ -356,4 +353,14 @@ def apply_renames(self, name):
name = name.replace(" ", " ")

name.strip()

# special "skip this txtp if rename matches" flag (for variables), lasts until next call
# at the end b/c it should go after cleanup (extra spaces) and final name
self.skip = False

for text_in, text_out, regex in self._skips:
if text_in in name or regex and regex.match(name):
self.skip = True
break

return name
6 changes: 6 additions & 0 deletions wwiser/wtxtp_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ def _get_ms(self, param, value_ms):
if not value_ms:
return ''
value_sec = value_ms / 1000

# useful when 2 musictrack using the same are slightly different?
# (ex. AC:B BORGIATOWERS 149.341643661262 vs 149.34014099656)
#if self._simpler:
# value_sec = round(value_sec, 2)

value_str = self._get_float_str(value_sec)
if not value_str:
return ''
Expand Down
2 changes: 1 addition & 1 deletion wwiser/wversion.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#autogenerated on build
WWISER_VERSION = "v20211121"
WWISER_VERSION = "v20211125"

0 comments on commit 1ea8db8

Please sign in to comment.