-
Notifications
You must be signed in to change notification settings - Fork 9
Fixes 26 : add modulable size light and display the value of the size and the colors in the light editor #26
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
Merged
Osman-Kahraman
merged 4 commits into
Osman-Kahraman:main
from
Hazim-AS:6-enhancement-save-button-light-editor
Mar 18, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -784,48 +784,61 @@ def __init__(self): | |
| coords = list(self.unconverted_objectCoords) | ||
| coords[0] += self.objectSize[0] * self.win_scale | ||
| R_initial, G_initial, B_initial = 0, 0, 0 | ||
| size_initial = 0 | ||
|
|
||
| with open("items/info.json", "r") as json_file: | ||
| data = json.loads(json_file.read()) | ||
| light = data[self.objectName]["lights"] | ||
|
|
||
| if light: | ||
| R_initial, G_initial, B_initial = light["RGB"] | ||
| size_initial = light["size"] | ||
|
|
||
| scrollbar_area = "{}_scrollbar_area".format(self.objectName) | ||
| light_editor_surf, light_editor_coor = UI.window("light_editor", coords, (230, 220), (30, 30, 30), 2) | ||
| light_editor_surf, light_editor_coor = UI.window("light_editor", coords, (330, 250), (30, 30, 30), 2) | ||
| UI.window("light_editor_close_button", (5, 5), (20, 20), (0, 30, 5), "button", win_name="light_editor") | ||
| UI.add_images({(0, 0): IMAGES.closeButton}, "light_editor_close_button") | ||
| UI.window(scrollbar_area, (5, 25), (200, 120), (30, 30, 30), text_bool=False, win_name="light_editor") | ||
| UI.text("R\nG\nB", 25, (70, 12), (200, 200, 200), scrollbar_area, font="impact") | ||
| UI.window("R", (100, 20), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| UI.window("G", (100, 50), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| UI.window("B", (100, 80), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| R = UI.listen("R") | ||
| G = UI.listen("G") | ||
| B = UI.listen("B") | ||
| UI.window(scrollbar_area, (5, 25), (300, 140), (30, 30, 30), text_bool=False, win_name="light_editor") | ||
|
|
||
| UI.window("Size", (170, 20), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| UI.window("R", (170, 50), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| UI.window("G", (170, 80), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| UI.window("B", (170, 110), (100, 20), (200, 200, 200), "scrollbar", win_name=scrollbar_area) | ||
| size = UI.listen("Size") * 5 | ||
| R = UI.listen("R") * 255 / 100 | ||
| G = UI.listen("G") * 255 / 100 | ||
| B = UI.listen("B") * 255 / 100 | ||
| UI.text( | ||
| f"Size : {size}\n R : {int(R)}\n G : {int(G)}\n B : {int(B)}", | ||
| 25, | ||
| (70, 12), | ||
| (200, 200, 200), | ||
| scrollbar_area, | ||
| font="impact", | ||
| ) | ||
| UI.window( | ||
| "light_editor_save_button", (45, 145), (130, 40), (110, 110, 110), "button", win_name="light_editor" | ||
| "light_editor_save_button", (100, 175), (130, 40), (110, 110, 110), "button", win_name="light_editor" | ||
| ) | ||
| UI.text("SAVE", 25, (32, 5), (200, 200, 200), "light_editor_save_button", font="impact") | ||
|
|
||
| color_view = pygame.Surface((40, 100)) | ||
| color_view = pygame.Surface((40, 130)) | ||
| color_view.fill((R, G, B)) | ||
| UI.add_images({(10, 10): color_view}, scrollbar_area) | ||
|
|
||
| try: | ||
| self.screen.blit(light_editor_surf, light_editor_coor) | ||
| except TypeError: # It will trigger when one of the buttons clicked. | ||
| if not self.light_editor_prompt_bool: | ||
| if light_editor_surf.item_coords == (45, 145): | ||
| light.update({"coords": [0, 0], "size": 100, "RGB": (int(R), int(G), int(B))}) | ||
| if light_editor_surf.item_coords == (100, 175): | ||
| light.update({"coords": [0, 0], "size": int(size), "RGB": (int(R), int(G), int(B))}) | ||
| R_initial, G_initial, B_initial = int(R), int(G), int(B) | ||
| size_initial = int(size) | ||
|
|
||
| with open("items/info.json", "w") as json_file_w: | ||
| json.dump(data, json_file_w) | ||
|
|
||
| elif light_editor_surf.item_coords == (5, 5): | ||
| if R == R_initial and B == B_initial and G == G_initial: | ||
| if R == R_initial and B == B_initial and G == G_initial and size == size_initial: | ||
| self.light_editor_bool = False | ||
| else: | ||
| self.light_editor_prompt_bool = True | ||
|
|
@@ -882,8 +895,9 @@ def __init__(self): | |
| elif light_editor_prompt_surf.item_coords == (140, 135): | ||
| self.light_editor_prompt_bool = False | ||
| elif light_editor_prompt_surf.item_coords == (260, 135): | ||
| light.update({"coords": [0, 0], "size": 100, "RGB": (int(R), int(G), int(B))}) | ||
| light.update({"coords": [0, 0], "size": int(size), "RGB": (int(R), int(G), int(B))}) | ||
|
Owner
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. perfectly added dynamic value, thanks for this improvement @Hazim-AS |
||
| R_initial, G_initial, B_initial = int(R), int(G), int(B) | ||
| size_initial = int(size) | ||
|
|
||
| with open("items/info.json", "w") as json_file_w: | ||
| json.dump(data, json_file_w) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I liked the way you implemented and adjusted the new
scrollbar_area.Tested. And works as intended. 👍