(self.get_configuration("mouse", "resets") and event.type == MOUSEBUTTONDOWN and
(1 <= event.button <= 3)):
self.reset()
- elif self.delegate.compare(event, "context"):
- if not self.editor.active:
- self.editor.activate()
- else:
- self.editor.deactivate()
def reset(self):
self.title.reset()
# self.tile_load_preview_background.location.topright = self.tile_load_background.location.topright
self.loaded = True
self.current_level_is_default = False
+ self.level_index = len(self.levels) - 1
+ self.set_level_title()
+ for level in self.levels:
+ print "path:", level.path
def draw_tile_database(self):
padding = self.TILE_LOAD_MENU_PADDING
def deactivate(self):
self.active = False
+ self.get_game().interface.reset()
def respond(self, event):
if self.active:
if compare(event, "cancel"):
if self.at_level_select:
self.deactivate()
+ self.get_game().title.activate()
elif self.at_view:
self.at_view = False
self.at_level_select = True
+ self.set_level_title()
self.tile_index = 0
self.palette_index = 0
elif self.at_tile_bar:
self.level_index += 1
if self.level_index >= len(self.levels):
self.level_index = 0
+ self.set_level_title()
if self.at_tile_bar:
self.tile_index += 1
if self.tile_index == Interface.MAX_TILE_COUNT or \
self.tile_index = 0
if self.at_tile_menu:
self.tile_menu_index += 1
- if self.tile_menu_index > 2:
+ if self.tile_menu_index > 2 or (self.add_tile_selected() and self.tile_menu_index > 1):
self.tile_menu_index = 0
if self.at_tile_edit or self.at_box:
dx = 1
self.level_index -= 1
if self.level_index < 0:
self.level_index = len(self.levels) - 1
+ self.set_level_title()
if self.at_tile_bar:
self.tile_index -= 1
if self.tile_index < 0:
if self.at_tile_menu:
self.tile_menu_index -= 1
if self.tile_menu_index < 0:
- self.tile_menu_index = 2
+ if self.add_tile_selected():
+ self.tile_menu_index = 1
+ else:
+ self.tile_menu_index = 2
if self.at_tile_edit or self.at_box:
dx = -1
if self.at_tile_edit:
elif self.palette_index < 0:
self.palette_index = self.get_palette_cell_count() - 1
+ def set_level_title(self):
+ level = self.get_current_level()
+ if level.path is None:
+ text = "DEFAULT"
+ else:
+ text = basename(self.get_current_level().path)
+ rect = self.get_current_level().preview.get_rect()
+ rect.center = self.get_display_surface().get_rect().center
+ self.label_title = self.get_label("ID: %s" % text)
+ self.label_title.location.bottomright = rect.right, rect.bottom - 3
+
def delete_tile(self, index):
level = self.get_current_level()
level.tiles.pop(index)
rect = preview.get_rect()
rect.center = ds.get_rect().center
ds.blit(preview, rect)
+ self.label_title.update()
self.level_select_cursor.update()
if len(self.levels) > 1:
self.label_left.update()
if self.is_countdown_active():
self.countdown_plate.toggle_hidden()
if self.countdown_plate.is_hidden():
- self.set_title_plate_visibility(False)
- else:
self.set_title_plate_visibility(True)
+ else:
+ self.set_title_plate_visibility(False)
def set_title_plate_visibility(self, visible=True):
title_plate = self.get_title_plate()
self.set_countdown_plate()
if self.is_countdown_active():
self.countdown_plate.unhide()
- self.set_title_plate_visibility(True)
+ self.set_title_plate_visibility(False)
self.reset_timer(self.blink_countdown)
else:
- self.set_title_plate_visibility(False)
+ self.set_title_plate_visibility(True)
self.countdown_plate.hide()
elif not self.get_game().editor.active:
effects.play("clear")
MENU_OFFSET = 100
MENU_WIDTH = 440
ADVANCE_TEXT = "PRESS ENTER", "PRESS START"
- MENU_OPTIONS = "NEW GAME", "CONTINUE"
+ MENU_OPTIONS = "NEW GAME", "CONTINUE", "EDITOR"
MENU_MARGIN = 12
MENU_PADDING = 16
TRANSPARENT_COLOR = (128, 128, 128)
if self.get_game().get_progress()[0] > 0:
option_texts = self.MENU_OPTIONS
else:
- option_texts = self.MENU_OPTIONS[:1]
+ option_texts = [self.MENU_OPTIONS[0], self.MENU_OPTIONS[2]]
height = glyphs.get_tile(0).get_height() * len(option_texts) + \
self.MENU_MARGIN * (len(option_texts) - 1) + \
self.MENU_PADDING * 2 + 3
(len(options) - 1) * self.MENU_MARGIN
indicator = self.indicator = Sprite(self)
indicator.add_frame(self.get_game().glyphs.get_tile(16))
+ self.option_texts = option_texts
def respond(self, event):
if self.active and not self.get_game().editor.active:
self.menu_index += 1
elif delegate.compare(event, "advance") or delegate.compare(event, "action"):
self.get_game().sound_effects.play("start")
- if self.menu_index == 0:
+ if self.get_selected_option() == "NEW GAME":
self.deactivate()
self.get_game().introduction.load()
self.get_game().write_progress(0, 0)
- elif self.menu_index == 1:
+ elif self.get_selected_option() == "CONTINUE":
self.deactivate()
self.get_game().levels.\
levels[self.get_game().get_progress()[0]].begin()
+ elif self.get_selected_option() == "EDITOR":
+ self.deactivate()
+ self.get_game().editor.activate()
else:
pass
event.dict["command"] = ""
elif self.menu_index >= len(self.options):
self.menu_index = 0
+ def get_selected_option(self):
+ return self.option_texts[self.menu_index]
+
def deactivate(self):
self.active = False
self.audio_loop.stop()
self.register(self.unsuppress_advance)
def respond(self, event):
- if self.active and not self.suppress_commands and not self.get_game().editor.active \
+ if self.active and not self.suppress_commands and not self.get_game().editor.active and \
((self.get_game().is_gamepad_mode() and self.get_game().delegate.compare(event, "advance")) or \
(not self.get_game().is_gamepad_mode() and self.get_game().delegate.compare(event, "action"))):
self.deactivate()