123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- import glob
- import os
- import pygame
-
- def draw_header(o):
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_text(o.header_text, o.h1, o.width, 25, o.light_grey)
- o.center_text("----------------------", o.h2, o.width, 55, o.light_grey)
-
- def play_seq(o, message):
- _id = 0
- o.clear_notes_on()
- for s in o.soundSlots:
- if s.notes[message[0]][message[1]][0] == 1:
- if o.erase:
- if _id in o.erase_buf:
- #pass
- s.notes[message[0]][message[1]][0] = 0
- print('erasing')
- #o.undo_buf.append(s.notes[message[0]][message[1]][0])
- else:
- o.notes_on[_id] = 1
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- elif o.mute:
- if _id in o.mute_buf:
- #pass
- #s.notes[message[0]][message[1]][0] = 0
- print('muting')
- #o.undo_buf.append(s.notes[message[0]][message[1]][0])
- else:
- o.notes_on[_id] = 1
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- else:
-
- o.notes_on[_id] = 1
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- _id += 1
-
- def erase_note(o, message, pressed):
- _id = 0
- #o.clear_notes_on()
-
- for s in o.soundSlots:
- if s.notes[message[0]][message[1]][0] == 1:
- o.notes_on[_id] = 1
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- _id += 1
-
-
- def text_box1(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box2(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box3(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box4(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_center(o, a, b):
- w1 = 0
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_block(a, o.h1, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h1, [w1,h1+20,w2,h2+45], o.light_grey)
-
-
-
- def breakup_song_text(song):
- line1 = ""
- line2 = ""
- line3 = ""
- line4 = ""
- if len(song) < 9:
- for x in song:
- line1 += str(x) + '.'
- elif len(song) < 17:
- _iter = 0
- for x in song:
- if _iter < 8:
- line1 += str(x) + '.'
- else:
- line2 += str(x) + '.'
- _iter += 1
- elif len(song) < 25:
- _iter = 0
- for x in song:
- if _iter < 8:
- line1 += str(x) + '.'
- elif _iter < 16:
- line2 += str(x) + '.'
- else:
- line3 += str(x) + '.'
- _iter += 1
- elif len(song) < 33:
- _iter = 0
- for x in song:
- if _iter < 8:
- line1 += str(x) + '.'
- elif _iter < 16:
- line2 += str(x) + '.'
- elif _iter < 24:
- line3 += str(x) + '.'
- else:
- line4 += str(x) + '.'
- _iter += 1
- else:
- _iter = 0
- cur_id = len(song) - 1
- _iter = 0
- ns = song.copy()
- while len(ns) > 31:
- del ns[0]
- for x in ns:
- if _iter < 7:
- line1 += str(x) + '.'
- elif _iter < 15:
- line2 += str(x) + '.'
- elif _iter < 23:
- line3 += str(x) + '.'
- else:
- line4 += str(x) + '.'
- _iter += 1
- line1 = ".." + line1
- return [line1, line2, line3, line4]
-
- def get_folders(path):
- globbed = glob.glob(path + "/*/")
- globbed.sort()
-
-
- # dirs = os.listdir(o.load_sound_dir)
- # dirs.sort()
- # for i in dirs:
- # if os.path.isdir(o.load_sound_dir + i):
- # i += "/asdfasdfasf"
- # print(i, ' is a directory')
- # else:
- # print(i, ' is not a directory')
- # print(dirs)
- # return dirs
-
-
-
- return globbed
-
- def get_files(path, ext):
- path += '/'
- out = []
- files = os.listdir(path)
- files.sort()
- print('from utils ', files)
- for file in files:
- if os.path.isdir(path + file):
- out.append(file)
- else:
- pass
-
- for file in files:
- if file.lower().endswith(ext):
- print(file, ' does end with ext')
- if os.path.isdir(path + file):
- #out.append(file)
- pass
- else:
- #pass
- out.append(file)
- else:
- print(file, ' does not end with ext')
- #pass
-
- return out
-
- def scroll_ud(o, self):
- since_up = 0
- if o.keyState[0] == 2:
- if o.press_ticks_up == None:
- o.press_ticks_up = pygame.time.get_ticks()
- since_up = pygame.time.get_ticks() - o.press_ticks_up
- else:
- o.press_ticks_up = None
- o.press_ticks_up = pygame.time.get_ticks()
-
- if o.keyState[0] == 1 or since_up > 250:
- if self.cur_el > 0:
- self.cur_el -= 1
- self.draw_main(o)
- o.update_display(0)
- o.press_ticks_up = pygame.time.get_ticks()
-
- since_down = 0
- if o.keyState[1] == 2:
- if o.press_ticks_down == None:
- o.press_ticks_down = pygame.time.get_ticks()
- since_down = pygame.time.get_ticks() - o.press_ticks_down
- else:
- o.press_ticks_down = None
- o.press_ticks_down = pygame.time.get_ticks()
-
- if o.keyState[1] == 1 or since_down > 250:
- if self.cur_el < (len(self.menu) - 1):
- self.cur_el += 1
- self.draw_main(o)
- o.update_display(0)
- o.press_ticks_down = pygame.time.get_ticks()
|