-
Notifications
You must be signed in to change notification settings - Fork 4
jq #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jq #20
Changes from all commits
6e2c9d4
343ec17
c680efd
2a38397
3dd8fa0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooh, didn't know that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a pattern of "keying" into a dictionary, instead of using if statements. can be changed to, |
||
| 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": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, interesting! again, didn't know that was a thing |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah previously that section was kinda badly written, thanks for rewriting it in a clearer way- |
||
| 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() | ||
| editor.loop() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, thanks-