Ejemplo n.º 1
0
def EditorMenu():
    Config.screen.blit(Config.zinfo, (Config.bords.width, 0))
    # le titre
    Tools.MsgCenter("Briks!", 60, 0, "red", True)
    # le logo
    Config.screen.blit(Config.logo, (Config.bords.width, 70))
    Tools.MsgCenter("Editeur", 32, 150, "cyan", True)

    # le niveau courant
    font = pygame.font.Font(None, 32)
    cy = 200
    txt_lvl = font.render("Lvl: ", True, THECOLORS["red"])
    txt_nlv = font.render("{0:03d}/{1:03d}".format(Config.level, Config.maxlevel), True, THECOLORS["white"])
    pos_lvl = txt_lvl.get_rect()
    pos_nlv = txt_nlv.get_rect()
    # on centre
    ctx  = Config.bords.width + ((Config.screenWidth - Config.bords.width) // 2)
    ctx -= (pos_lvl.width + pos_nlv.width) // 2
    pos_lvl.x = ctx
    pos_lvl.y = cy
    Config.screen.blit(txt_lvl, pos_lvl)
    pos_nlv.x = pos_lvl.x + pos_lvl.width
    pos_nlv.y = cy
    Config.screen.blit(txt_nlv, pos_nlv)

    # les boutons prev/next
    if Ced.b_prev is None:
        Ced.b_prev = Gui.Button((pos_lvl.centerx - (pos_lvl.width // 2) - 12 - 10, pos_lvl.centery), 'prev.png', 'prev-clicked.png')
    Ced.b_prev.draw()
    if Ced.b_next is None:
        Ced.b_next = Gui.Button((pos_nlv.centerx + (pos_nlv.width // 2) + 12 + 11, pos_nlv.centery), 'next.png', 'next-clicked.png')
    Ced.b_next.draw()

    # les briques
    cx = Config.bords.width
    cy = 250
    for i in range(1, len(Ced.ico_br)):
        if Ced.ico_br[i][0] is None:
            # premier passage, chargement de l'image
            (Ced.ico_br[i][0], Ced.ico_br[i][1]) = Tools.load_png(Ced.ico_br[i][2])
        Tools.Msg("{0:2x}".format(i), 32, cx, cy, "white", False)
        Ced.ico_br[i][1].x = cx + 30
        Ced.ico_br[i][1].y = cy
        Config.screen.blit(Ced.ico_br[i][0], Ced.ico_br[i][1])
        cy += 30
        # on affiche sur 2 colonnes
        if i == (len(Ced.ico_br) // 2):
            cx = Config.bords.width + 115
            cy = 250

    # la brique pour les niveaux avec un boss
    cx = Config.bords.width + 115
    cy = 250 + (30 * ((len(Ced.ico_br) - 1) // 2))
    if Ced.boss_br[0] is None:
        # premier passage, chargement de l'image
        (Ced.boss_br[0], Ced.boss_br[1]) = Tools.load_png(Ced.boss_br[2])
    Ced.boss_br[1].x = cx + 30
    Ced.boss_br[1].y = cy
    Config.screen.blit(Ced.boss_br[0], Ced.boss_br[1])
    Tools.Msg(" X", 32, cx, cy, "white", False)

    # on dessine un rectangle autour de la brique sélectionnée
    if Ced.bsel_i > 0:
        rect       = Ced.ico_br[Ced.bsel_i][1]
        rect.x    -= 30
        rect.width = Config.brw + 30
        pygame.draw.rect(Config.screen, THECOLORS["white"], rect, 1)
    elif Config.bossLevel:
        rect       = Ced.boss_br[1]
        rect.x    -= 30
        rect.width = Config.brw + 30
        pygame.draw.rect(Config.screen, THECOLORS["white"], rect, 1)

    # les boutons
    cy = 450
    if Ced.b_save is None:
        Ced.b_save = Gui.Button((Config.bords.width + 24 + 5, cy + 24), 'save.png', 'save-clicked.png')
    Ced.b_save.draw()
    if Ced.b_load is None:
        Ced.b_load = Gui.Button((Config.bords.width + Config.zinfo.get_rect().width - 24 - 5, cy + 24), 'load.png', 'load-clicked.png')
    Ced.b_load.draw()
    # le reset centré entre les 2
    bspc = ((Ced.b_load.rect.x - (Ced.b_save.rect.x + Ced.b_save.rect.width)) - 48) // 2
    if Ced.b_raz is None:
        Ced.b_raz = Gui.Button((Config.bords.width + Ced.b_save.rect.width + 5 + bspc + 24, cy + 24), 'reset.png', 'reset-clicked.png')
    Ced.b_raz.draw()

    cy = 530
    if Ced.b_select is None:
        Ced.b_select = Gui.Button((Config.bords.width + 24 + 5, cy + 24), 'select.png', 'select-clicked.png')
    Ced.b_select.draw()
    if Ced.b_cut is None:
        Ced.b_cut = Gui.Button((Config.bords.width + Config.zinfo.get_rect().width - 24 - 5, cy + 24), 'cut.png', 'cut-clicked.png')
    Ced.b_cut.draw()
    # le copy centré entre les 2
    bspc = ((Ced.b_cut.rect.x - (Ced.b_select.rect.x + Ced.b_select.rect.width)) - 48) // 2
    if Ced.b_copy is None:
        Ced.b_copy = Gui.Button((Config.bords.width + Ced.b_select.rect.width + 5 + bspc + 24, cy + 24), 'copy.png', 'copy-clicked.png')
    Ced.b_copy.draw()

    cy = 600
    if Ced.b_paste is None:
        Ced.b_paste = Gui.Button((Config.bords.width + 24 + 5, cy + 24), 'paste.png', 'paste-clicked.png')
    Ced.b_paste.draw()
    if Ced.b_cancel is None:
        Ced.b_cancel = Gui.Button((Config.bords.width + Config.zinfo.get_rect().width - 24 - 5, cy + 24), 'cancel.png', 'cancel-clicked.png')
    Ced.b_cancel.draw()
    # le undo centré entre les 2
    bspc = ((Ced.b_cancel.rect.x - (Ced.b_paste.rect.x + Ced.b_paste.rect.width)) - 48) // 2
    if Ced.b_undo is None:
        Ced.b_undo = Gui.Button((Config.bords.width + Ced.b_paste.rect.width + 5 + bspc + 24, cy + 24), 'undo.png', 'undo-clicked.png')
    Ced.b_undo.draw()

    cy = 680
    if Ced.b_grid is None:
        Ced.b_grid = Gui.Button((Config.bords.width + 24 + 5, cy + 24), 'grid-off.png', 'grid-on.png')
        Ced.b_grid.setClicked(Ced.view_grid)
    Ced.b_grid.draw()
    if Ced.b_test is None:
        Ced.b_test = Gui.Button((Config.bords.width + Config.zinfo.get_rect().width - 24 - 5, cy + 24), 'test.png', 'test-clicked.png')
    Ced.b_test.draw()
    
    # les touches diverses
    cy = Config.screenHeight - 15
    Tools.MsgCenter("ESC: quitter", 18, cy, "white", False)