diff --git a/index.py b/index.py index c342a1b..e654219 100644 --- a/index.py +++ b/index.py @@ -213,6 +213,7 @@ def populate_enum(self): displayedValues = [locales[loc]("lang") for loc in locales] self.menuOptions[3]["populatedValues"] = localeNames self.menuOptions[3]["displayedValues"] = displayedValues + self.menuOptions[7]["displayedValues"] = layoutNames self.menuOptions[7]["populatedValues"] = layoutNames def translate(self): diff --git a/requirements.txt b/requirements.txt index e81a903..278e1a3 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/src/editor.py b/src/editor.py index e587e7a..47d5be6 100644 --- a/src/editor.py +++ b/src/editor.py @@ -216,7 +216,7 @@ def create_text(self, atPos = 0, lasts = 1, text = "", anchor = CENTER, align = "text": text, "anchor": anchor, "align": align, - "offset": [0,0] + "offset": [0,0], } self.mapToEdit["notes"].append(newNote) self.mapToEdit["notes"] = sorted(self.mapToEdit["notes"], key=lambda d: d['beatpos'][0]*4+d['beatpos'][1]) @@ -263,12 +263,12 @@ def input_colorPicker(self, val): if val.name == "KEY_ESCAPE" or val.name == "KEY_ENTER": self.colorPickerFieldSelected = False else: - if val.name == "KEY_RIGHT" and self.colorPickerSelectedCol < 3: - self.colorPickerColor[self.colorPickerSelectedCol] += 1 + if val.name in ("KEY_RIGHT", "KEY_SRIGHT") and self.colorPickerSelectedCol < 3: + self.colorPickerColor[self.colorPickerSelectedCol] += {'KEY_RIGHT': 1, 'KEY_SRIGHT': 10}[val.name] self.colorPickerColor[self.colorPickerSelectedCol] = min(self.colorPickerColor[self.colorPickerSelectedCol], 255) self.colorPickerFieldContent = hexcode_from_color_code(self.colorPickerColor) - if val.name == "KEY_LEFT" and self.colorPickerSelectedCol < 3: - self.colorPickerColor[self.colorPickerSelectedCol] -= 1 + if val.name in ("KEY_LEFT", "KEY_SLEFT") and self.colorPickerSelectedCol < 3: + self.colorPickerColor[self.colorPickerSelectedCol] -= {'KEY_LEFT': 1, 'KEY_SLEFT': 10}[val.name] self.colorPickerColor[self.colorPickerSelectedCol] = max(self.colorPickerColor[self.colorPickerSelectedCol], 0) self.colorPickerFieldContent = hexcode_from_color_code(self.colorPickerColor) if val.name == "KEY_DOWN": @@ -1146,11 +1146,13 @@ def handle_input(self): self.localConduc.currentBeat = 0 if val.name == "KEY_ESCAPE": self.pauseMenuEnabled = True - if val.name == "KEY_RIGHT": - self.localConduc.currentBeat += (1/self.snap)*4 + if val.name in ("KEY_RIGHT", "KEY_SRIGHT"): + multiplier = {"KEY_RIGHT": 1, "KEY_SRIGHT": 4}[val.name] + self.localConduc.currentBeat += (1/self.snap)*4*multiplier print_at(0,term.height-4, term.clear_eol) - if val.name == "KEY_LEFT": - self.localConduc.currentBeat = max(self.localConduc.currentBeat - (1/self.snap)*4, 0) + if val.name in ("KEY_LEFT", "KEY_SLEFT"): + multiplier = {"KEY_LEFT": 1, "KEY_SLEFT": 4}[val.name] + self.localConduc.currentBeat = max(self.localConduc.currentBeat - (1/self.snap)*4*multiplier, 0) print_at(0,term.height-4, term.clear_eol) if val == "z": self.keyPanelEnabled = True @@ -1175,14 +1177,16 @@ def handle_input(self): if self.mapToEdit["notes"] != []: note = self.mapToEdit["notes"][self.selectedNote] - if val.name == "KEY_DOWN": + if val.name in ("KEY_DOWN", "KEY_SDOWN"): + multiplier = {"KEY_DOWN": 1, "KEY_SDOWN": 4}[val.name] print_at(0,term.height-4, term.clear_eol) - self.selectedNote = min(self.selectedNote + 1, len(self.mapToEdit["notes"])-1) + self.selectedNote = min(self.selectedNote + (1*multiplier), len(self.mapToEdit["notes"])-1) note = self.mapToEdit["notes"][self.selectedNote] self.localConduc.currentBeat = (note["beatpos"][0] * 4 + note["beatpos"][1]) - if val.name == "KEY_UP": + if val.name in ("KEY_UP", "KEY_SUP"): + multiplier = {"KEY_UP": 1, "KEY_SUP": 4}[val.name] print_at(0,term.height-4, term.clear_eol) - self.selectedNote = max(self.selectedNote - 1, 0) + self.selectedNote = max(self.selectedNote - (1*multiplier), 0) note = self.mapToEdit["notes"][self.selectedNote] self.localConduc.currentBeat = (note["beatpos"][0] * 4 + note["beatpos"][1]) @@ -1195,36 +1199,34 @@ def handle_input(self): print_at(0,term.height-4, term.clear_eol) note["beatpos"] = [self.localConduc.currentBeat//4, self.localConduc.currentBeat%4] - if val == "d": + if val == "d" and "key" in note: self.selectedNote = self.create_note( note["beatpos"][0]*4 + note["beatpos"][1], note["key"] ) self.mapToEdit["notes"][self.selectedNote] = copy.deepcopy(note) - if note["type"] == "hit_object": + if note["type"] == "hit_object" and val: screenPos = note["screenpos"] calculatedPos = Game.calculatePosition(screenPos, 5, 3, term.width-10, term.height-11) - if val == "h": + # erase hitbox + if val in "hjklHJKL": print_at(calculatedPos[0]-1, calculatedPos[1]-1, f"{term.normal} ") print_at(calculatedPos[0]-1, calculatedPos[1]+0, f"{term.normal} ") print_at(calculatedPos[0]-1, calculatedPos[1]+1, f"{term.normal} ") - note["screenpos"][0] = max(round(note["screenpos"][0] - 1/(defaultSize[0]-1), 3), 0) - if val == "j": - print_at(calculatedPos[0]-1, calculatedPos[1]-1, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+0, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+1, f"{term.normal} ") - note["screenpos"][1] = min(round(note["screenpos"][1] + 1/defaultSize[1], 3), 1) - if val == "k": - print_at(calculatedPos[0]-1, calculatedPos[1]-1, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+0, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+1, f"{term.normal} ") - note["screenpos"][1] = max(round(note["screenpos"][1] - 1/defaultSize[1], 3), 0) - if val == "l": - print_at(calculatedPos[0]-1, calculatedPos[1]-1, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+0, f"{term.normal} ") - print_at(calculatedPos[0]-1, calculatedPos[1]+1, f"{term.normal} ") - note["screenpos"][0] = min(round(note["screenpos"][0] + 1/(defaultSize[0]-1), 3), 1) + # calculate new x/y position + if val in "hH": + multiplier = {"h": 1, "H": 3}[val] + note["screenpos"][0] = max(round(note["screenpos"][0] - multiplier/(defaultSize[0]-1), 3), 0) + if val in "jJ": + multiplier = {"j": 1, "J": 2}[val] + note["screenpos"][1] = min(round(note["screenpos"][1] + multiplier/defaultSize[1], 3), 1) + if val in "kK": + multiplier = {"k": 1, "K": 2}[val] + note["screenpos"][1] = max(round(note["screenpos"][1] - multiplier/defaultSize[1], 3), 0) + if val in "lL": + multiplier = {"l": 1, "L": 3}[val] + note["screenpos"][0] = min(round(note["screenpos"][0] + multiplier/(defaultSize[0]-1), 3), 1) if val == "e": self.run_noteSettings(note, self.selectedNote, 0) if val == "E": @@ -1235,33 +1237,31 @@ def handle_input(self): if val == "X": note["color"] -= 1 note["color"] %= len(colors) - if note["type"] == "text": - if val == "h": - print(term.clear) - note["offset"][0] -= 1 - if val == "j": - print(term.clear) - note["offset"][1] += 1 - if val == "k": - print(term.clear) - note["offset"][1] -= 1 - if val == "l": - print(term.clear) - note["offset"][0] += 1 + if note["type"] == "text" and val: + if val in "hH": + multiplier = 3 if val.isupper() else 1 + note["offset"][0] = note["offset"][0] - multiplier + if val in "jJ": + multiplier = 2 if val.isupper() else 1 + note["offset"][1] = note["offset"][1] + multiplier + if val in "kK": + multiplier = 2 if val.isupper() else 1 + note["offset"][1] = note["offset"][1] - multiplier + if val in "lL": + multiplier = 3 if val.isupper() else 1 + note["offset"][0] = note["offset"][0] + multiplier if val == "U": - print(term.clear) note["length"] = max(note["length"] - (1/self.snap)*4, 0) if val == "I": - print(term.clear) note["length"] += (1/self.snap)*4 if val == "e": self.run_noteSettings(note, self.selectedNote, 0) if val == "x": - note["color"] += 1 + note["color"] = note.get('color', -1) + 1 note["color"] %= len(colors) if val == "X": - note["color"] -= 1 + note["color"] = note.get('color', len(colors)) - 1 note["color"] %= len(colors) if val == "c": self.run_noteSettings(note, self.selectedNote, 2) @@ -1385,4 +1385,4 @@ def __init__(self) -> None: # loadedMenus["Editor"] = editor editor.layoutname = "qwerty" editor.layout = Game.setupKeys(None, editor.layoutname) - editor.loop() \ No newline at end of file + editor.loop() diff --git a/src/termutil.py b/src/termutil.py index b8bb5a9..0060436 100644 --- a/src/termutil.py +++ b/src/termutil.py @@ -159,7 +159,7 @@ def print_lines_at(x, y, text, center = False, eol = False, color = None): def print_image(x,y,imagePath,scale): if os.path.exists(imagePath): - image = from_file(imagePath, width=scale) + image = BlockImage.from_file(imagePath, width=scale) stringifiedImage = str(image) print_lines_at(x, y, stringifiedImage) return True @@ -235,4 +235,4 @@ def __init__(self, x, y, width, height) -> None: self.y = y self.width = width self.height = height - pass \ No newline at end of file + pass