Skip to content

Commit

Permalink
Fixed issue with autoexec being spammed with exec jam.cfg, fixed bi…
Browse files Browse the repository at this point in the history
…nds breaking the next song.
  • Loading branch information
10se1ucgo committed Mar 12, 2016
1 parent 3d32fca commit 149725a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 10 additions & 3 deletions jam.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def __init__(self):
icon = wx.Icon('pyjam.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)

self.Bind(wx.EVT_MENU, panel.settings, settings)
self.Bind(wx.EVT_MENU, lambda x: jam_about.about_dialog(self), about)
self.Bind(wx.EVT_MENU, lambda x: jam_about.Licenses(self), licenses)
self.Bind(wx.EVT_MENU, handler=panel.settings, source=settings)
self.Bind(wx.EVT_MENU, handler=lambda x: jam_about.about_dialog(self), source=about)
self.Bind(wx.EVT_MENU, handler=lambda x: jam_about.Licenses(self), source=licenses)
self.Bind(wx.EVT_CLOSE, handler=panel.on_exit)
self.Show()


Expand Down Expand Up @@ -147,6 +148,7 @@ def __init__(self, parent):
self.Bind(wx.EVT_MENU, handler=self.clear_all, source=clear_all)

self.Bind(wx.EVT_SIZE, handler=self.on_size)
self.Bind(wx.EVT_CLOSE, handler=self.on_exit)

def game_select(self, event):
self.game = self.games[self.profile.GetSelection()]
Expand Down Expand Up @@ -307,6 +309,11 @@ def on_size(self, event):
if self.GetAutoLayout():
self.Layout()

def on_exit(self, event):
if self.game_watcher:
self.game_watcher.stop()
event.Skip()


class SetupDialog(wx.Dialog):
def __init__(self, parent):
Expand Down
10 changes: 9 additions & 1 deletion jam_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ def stop(self):
except (FileNotFoundError, IOError):
logger.exception("Could not remove some files:")

with open(os.path.normpath(os.path.join(self.game.mod_path, "cfg/autoexec.cfg"))) as cfg:
autoexec = cfg.readlines()

with open(os.path.normpath(os.path.join(self.game.mod_path, "cfg/autoexec.cfg")), "w") as cfg:
for line in autoexec:
if "exec jam" not in line:
cfg.write(line)

def load_song(self, path):
song_id = self.poll_song(path)
try:
Expand Down Expand Up @@ -337,7 +345,7 @@ def write_configs(path, tracks, play_key, relay_key, use_aliases):
for alias in track.aliases:
cfg.write('alias {alias} {x}\n'.format(alias=alias, x=x))
if track.bind:
cfg.write('bind {bind} {x}'.format(bind=track.bind, x=x))
cfg.write('bind {bind} {x}\n'.format(bind=track.bind, x=x))
cfg.write('voice_enable 1; voice_modenable 1\n')
cfg.write('voice_forcemicrecord 0\n')
cfg.write('voice_fadeouttime 0.0\n')
Expand Down

0 comments on commit 149725a

Please sign in to comment.