Skip to content

Commit

Permalink
Merge pull request unknown-horizons#49 from srijanmishra/master
Browse files Browse the repository at this point in the history
Conflicts:
	horizons/gui/keylisteners/mainlistener.py
  • Loading branch information
squiddy committed Apr 16, 2012
2 parents 982f06e + 6c8eccf commit 6083d41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
9 changes: 2 additions & 7 deletions horizons/gui/keylisteners/mainlistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,8 @@ def keyPressed(self, evt):
self.gui.session.ingame_gui.message_widget.add(None, None, 'SCREENSHOT', \
{'file': screenshotfilename})
elif action == _Actions.QUICKLOAD:
if self.gui.session is not None:
# let the session do it for proper cleanup
self.gui.session.quickload()
else:
# no session to clean up, do it directly
from horizons.main import _load_last_quicksave
_load_last_quicksave()
from horizons.main import _load_last_quicksave
_load_last_quicksave(self.gui.session)
else:
key_event_handled = False # nope, nothing triggered

Expand Down
16 changes: 12 additions & 4 deletions horizons/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,21 @@ def _load_map(savegame, ai_players, human_ai, force_player_id=None):
load_game(savegame=map_file, force_player_id=force_player_id)
return True

def _load_last_quicksave(force_player_id=None):
def _load_last_quicksave(session=None, force_player_id=None):
"""Load last quicksave
@param session: value of session
@return: bool, whether loading succeded"""
save_files = SavegameManager.get_quicksaves()[0]
if not save_files:
print "Error: No quicksave found."
return False
if session is not None:
if not save_files:
session.gui.show_popup(_("No quicksaves found"), _("You need to quicksave before you can quickload."))
return False
else:
session.ingame_gui.on_escape() # close widgets that might be open
else:
if not save_files:
print "Error: No quicksave found."
return False
save = max(save_files)
load_game(savegame=save, force_player_id=force_player_id)
return True
Expand Down
9 changes: 0 additions & 9 deletions horizons/spsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ def quicksave(self):
u"unknown-horizons.org/support/"
self.gui.show_error_popup(headline, descr, advice)

def quickload(self):
"""Loads last quicksave"""
files = SavegameManager.get_quicksaves(include_displaynames = False)[0]
if len(files) == 0:
self.gui.show_popup(_("No quicksaves found"), _("You need to quicksave before you can quickload."))
return
self.ingame_gui.on_escape() # close widgets that might be open
horizons.main.load_game(savegame=files[0])

def save(self, savegamename=None):
"""Saves a game
@param savegamename: string with the full path of the savegame file or None to let user pick one
Expand Down

0 comments on commit 6083d41

Please sign in to comment.