예제 #1
0
    def init_graphics(self):
        self.title = draw.create_text(x=self.gw.screen_width - 80,
                                      y=376,
                                      align='left',
                                      t='map editor',
                                      c=(255, 255, 255),
                                      s=10,
                                      group=groups.menu_text)
        self.add_obj(self.title, draw.go.TEXT)

        self.text_load = draw.create_text(x=20,
                                          y=340,
                                          align='left',
                                          t='load map',
                                          c=(255, 255, 255),
                                          s=10,
                                          group=groups.menu_text)
        self.add_obj(self.text_load, draw.go.TEXT)

        self.topbar = draw.create_rect(x=0,
                                       y=self.gw.screen_width - 30,
                                       w=self.gw.screen_width,
                                       h=30,
                                       color=(50, 50, 50, 255),
                                       group=groups.menu_rect_back)
        self.add_obj(self.topbar, draw.go.RECT)

        self.button_new = button.Button(0, 370, 80, 30, text="new map")
        self.add_obj(self.button_new, draw.go.BUTTON)

        utils.mkdir2("maps")
        #create buttons for every map
        map_names = utils.list_dirs("./maps")

        if len(map_names) == 0:
            draw.change_text(self.text_load, "no maps found")
        map_names = sorted(map_names)
        print(map_names)

        offset = 0
        grid = 4
        offx = 20
        offy = 300
        # TODO use utils.grid_coords() method!
        for mn in map_names:
            x = int(math.fmod(offset, grid))
            y = math.floor(offset / grid)
            mb = button.Button(offx + (x * 90),
                               offy - (y * 40),
                               80,
                               30,
                               text=mn)
            self.add_obj(mb, draw.go.BUTTON)
            self.buttons_maps.append(mb)
            offset += 1
예제 #2
0
    def subinit(self):
        self.menutitle = draw.create_text(x=self.gw.screen_width / 2,
                                          y=378,
                                          align='center',
                                          t='select edit layer',
                                          c=(255, 255, 255),
                                          s=10,
                                          group=groups.menu_text)
        self.add_obj(self.menutitle, draw.go.TEXT)

        self.button_tiles = button.Button(10, 300, 80, 30, text="floor")
        self.add_obj(self.button_tiles, draw.go.BUTTON)

        self.button_walls = button.Button(10, 260, 80, 30, text="walls")
        self.add_obj(self.button_walls, draw.go.BUTTON)
예제 #3
0
    def init_graphics(self):
        self.title = draw.create_text(x=10,
                                      y=self.gw.screen_height - 15,
                                      xc='left',
                                      yc='bottom',
                                      t='map editor settings',
                                      c=(200, 200, 200),
                                      s=10)
        self.add_obj(self.title, draw.go.TEXT)

        self.topbar = draw.create_rect(x=0,
                                       y=self.gw.screen_height - 30,
                                       w=self.gw.screen_width,
                                       h=30,
                                       color=(50, 50, 50, 255),
                                       group=groups.RECT)
        self.add_obj(self.topbar, draw.go.RECT)

        self.button_back = button.Button(10, 10, 100, 30, text='back')
        self.add_obj(self.button_back, draw.go.BUTTON)
예제 #4
0
    def __init__(self,
                 x,
                 y,
                 w,
                 h,
                 text="none",
                 color=(100, 100, 100, 255),
                 switch=False,
                 allow_offset=True):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.text = text
        self.c = color
        self.ch = utils.brighten_color(color)
        self.co = (150, 150, 100, 255)
        global button_status
        self.status = button_status.NORMAL
        self.switch = switch
        self.bg = None
        self.allow_offset = allow_offset
        self.switch_status = False  # false - off, true - on
        # a menu will add an unique id to each button added for identification
        self.tid = draw.create_text(x=x + w / 2,
                                    y=y + h / 2 - 5,
                                    align='center',
                                    t=text,
                                    c=(255, 255, 255),
                                    s=12,
                                    group=groups.button_text)
        self.visible = True

        self.rect = draw.create_rect(x=x,
                                     y=y,
                                     w=w,
                                     h=h,
                                     color=color,
                                     group=groups.buttons)
예제 #5
0
    def subinit(self):
        self.menutitle = draw.create_text(x=self.gw.screen_width / 2,
                                          y=378,
                                          align='center',
                                          t='edit walls layer',
                                          c=(255, 255, 255),
                                          s=10,
                                          group=groups.menu_text)
        self.add_obj(self.menutitle, draw.go.TEXT)

        self.button_back = button.Button(10, 10, 80, 30, text="back")
        self.add_obj(self.button_back, draw.go.BUTTON)

        self.text_current_tile = draw.create_text(x=50,
                                                  y=330,
                                                  align="center",
                                                  t="none",
                                                  s=10)
        self.add_obj(self.text_current_tile, draw.go.TEXT)

        # select wall sprite + shadowbuttons

        self.bg_wall = buttongroup.Button_group()

        self.select_wall = []
        do = utils.distribute_objects(4, 16, 100)
        for xy in utils.grid_coords(objects.walls.length(), 4, do[1], 250,
                                    do[0], -25):
            b = button.Shadowbutton(xy[1] - 2,
                                    xy[2] - 2,
                                    20,
                                    36,
                                    switch=True,
                                    group=groups.menu_img_back)
            self.add_obj(b, draw.go.BUTTON)
            self.bg_wall.add(b, xy[0])
            sp = pyg.sprite.Sprite(test_image_load.name_map[objects.walls.name(
                xy[0])],
                                   x=xy[1],
                                   y=xy[2],
                                   batch=groups.batch_mapedit,
                                   group=groups.menu_img_front)
            self.select_wall.append(sp)

        self.bg_wall.activate()

        # draw mode selection buttons

        self.bg_edit = buttongroup.Button_group()

        self.select_drawmode = []
        do = utils.distribute_objects(2, 40, 100)
        for xy in utils.grid_coords(4, 2, do[1], 100, do[0], -25):
            b = button.Button(xy[1],
                              xy[2],
                              40,
                              20,
                              text=editmode.name(xy[0]),
                              switch=True)
            self.add_obj(b, draw.go.BUTTON)
            self.bg_edit.add(b, xy[0])

        self.bg_edit.activate()

        self.last_tile_edit = (-1, -1)
        self.line_axis = -1  # -1 == none, 0 == x, 1 == y
        self.rect_start_pos = None
예제 #6
0
    def init_graphics(self):
        self.title = draw.create_text(x=self.gw.screen_width - 80,
                                      y=376,
                                      align='left',
                                      t='map editor',
                                      c=(255, 255, 255),
                                      s=10,
                                      group=groups.menu_text)
        self.add_obj(self.title, draw.go.TEXT)

        self.text_move = draw.create_text(x=self.gw.screen_width - 50,
                                          y=340,
                                          align='center',
                                          t='move map',
                                          c=(255, 255, 255),
                                          s=10,
                                          group=groups.menu_text)
        self.add_obj(self.text_move, draw.go.TEXT)
        self.text_move2 = draw.create_text(x=self.gw.screen_width - 50,
                                           y=325,
                                           align='center',
                                           t='with arrows',
                                           c=(255, 255, 255),
                                           s=10,
                                           group=groups.menu_text)
        self.add_obj(self.text_move2, draw.go.TEXT)

        self.text_editing = draw.create_text(x=self.gw.screen_width - 50,
                                             y=290,
                                             align='center',
                                             t='editing',
                                             c=(255, 255, 255),
                                             s=10,
                                             group=groups.menu_text)
        self.add_obj(self.text_editing, draw.go.TEXT)
        self.text_mapname = draw.create_text(x=self.gw.screen_width - 50,
                                             y=275,
                                             align='center',
                                             t=self.map.name,
                                             c=(255, 255, 255),
                                             s=10,
                                             group=groups.menu_text)
        self.add_obj(self.text_mapname, draw.go.TEXT)

        self.text_changes = draw.create_text(x=self.gw.screen_width - 50,
                                             y=100,
                                             align='center',
                                             t="_",
                                             c=(200, 20, 20),
                                             s=10,
                                             group=groups.menu_text)
        self.add_obj(self.text_changes, draw.go.TEXT)

        self.topbar = draw.create_rect(x=0,
                                       y=self.gw.screen_height - 30,
                                       w=self.gw.screen_width,
                                       h=30,
                                       color=(50, 50, 50, 255),
                                       group=groups.menu_rect_back)
        self.add_obj(self.topbar, draw.go.RECT)

        self.left_sidebar = draw.create_rect(x=0,
                                             y=0,
                                             w=100,
                                             h=self.gw.screen_height,
                                             color=(50, 50, 50, 255),
                                             group=groups.menu_rect_back)
        self.add_obj(self.left_sidebar, draw.go.RECT)

        self.right_sidebar = draw.create_rect(x=self.gw.screen_width - 100,
                                              y=0,
                                              w=100,
                                              h=self.gw.screen_height,
                                              color=(50, 50, 50, 255),
                                              group=groups.menu_rect_back)
        self.add_obj(self.right_sidebar, draw.go.RECT)

        if not self.map.isinit:
            self.map.init_graphics()
        self.map.update_graphics()

        self.button_save = button.Button(self.gw.screen_width - 90,
                                         50,
                                         80,
                                         30,
                                         text="save map")
        self.add_obj(self.button_save, draw.go.BUTTON)

        self.button_exit = button.Button(self.gw.screen_width - 90,
                                         10,
                                         80,
                                         30,
                                         text="exit map")
        self.add_obj(self.button_exit, draw.go.BUTTON)

        self.subinit()

        self.timer_changes = utils.Timer(interval=2.0)