from naja.gamestate import GameState
from naja.options import options
from naja.scenes.scene import Scene
+from naja.sound import sound
from naja.widgets.save_slot import SaveSlotWidget
from naja.widgets.selector import SelectorWidget
SceneChangeEvent.post(MenuScene)
return
+ def fail(self):
+ sound.play_sound('error.ogg')
+ InvalidateTheWorld.post()
+
+ def succeed(self):
+ from naja.scenes.menu import MenuScene
+ sound.play_sound('chirp.ogg', volume=0.5)
+ SceneChangeEvent.post(MenuScene)
+
def perform_action(self, slot_num):
raise NotImplementedError("Nothing to see here.")
json.dump(save_data, save_file)
except Exception as e:
print "Error saving game in slot %s: %s" % (slot_num, e)
- self.slots[slot_num].game_data = self.get_game_data(slot_num)
- InvalidateTheWorld.post()
+ self.fail()
+ else:
+ self.succeed()
class LoadGameScene(LoadSaveGameBase):
def perform_action(self, slot_num):
game_data = self.get_game_data(slot_num)
- state = GameState(game_data['data'])
if game_data is not None:
+ state = GameState(game_data['data'])
LoadGameEvent.post(state)
+ self.succeed()
+ else:
+ self.fail()