Skip to content

Commit 8639e05

Browse files
committed
Buttons color change once clicked + customised scrolling speed
1 parent 07b5dca commit 8639e05

2 files changed

Lines changed: 56 additions & 12 deletions

File tree

‎main.py‎

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
window_buttons.minsize(size[0], size[1])
1313
window_buttons.maxsize(size[0], size[1])
1414

15+
file = open("settings.txt", mode="r")
16+
the_settings = file.readlines()
17+
file.close()
18+
19+
font = ("Arial, 15")
20+
bg = "#ffffff"
21+
fg = "#000000"
22+
changed_bg = str(the_settings[2].replace("CLICKED_BUTTONS=", "").replace("\n", ""))
23+
width = 17
24+
1525
global structures
1626
structures = []
1727
for filenames in os.walk("assets/BLOCS/"):
@@ -22,78 +32,114 @@
2232

2333
def buttons_function():
2434
def bastion():
35+
button_bastion.configure(bg=changed_bg, fg=fg)
2536
if "bastion.png" in structures_copy:
2637
structures_copy.pop(structures_copy.index("bastion.png"))
2738

2839
def burried_treasure():
40+
button_burried_treasure.configure(bg=changed_bg, fg=fg)
2941
if "burried_treasure.png" in structures_copy:
3042
structures_copy.pop(structures_copy.index("burried_treasure.png"))
3143

3244
def desert_pyramid():
45+
button_desert_pyramid.configure(bg=changed_bg, fg=fg)
3346
if "desert_pyramid.png" in structures_copy:
3447
structures_copy.pop(structures_copy.index("desert_pyramid.png"))
3548

3649
def end_city():
50+
button_end_city.configure(bg=changed_bg, fg=fg)
3751
if "end_city.png" in structures_copy:
3852
structures_copy.pop(structures_copy.index("end_city.png"))
3953

4054
def igloo():
55+
button_igloo.configure(bg=changed_bg, fg=fg)
4156
if "igloo.png" in structures_copy:
4257
structures_copy.pop(structures_copy.index("igloo.png"))
4358

4459
def jungle_temple():
60+
button_jungle_temple.configure(bg=changed_bg, fg=fg)
4561
if "jungle_temple.png" in structures_copy:
4662
structures_copy.pop(structures_copy.index("jungle_temple.png"))
4763

4864
def mineshaft():
65+
button_mineshaft.configure(bg=changed_bg, fg=fg)
4966
if "mineshaft.png" in structures_copy:
5067
structures_copy.pop(structures_copy.index("mineshaft.png"))
5168

5269
def nether_fortress():
70+
button_nether_fortress.configure(bg=changed_bg, fg=fg)
5371
if "nether_fortress.png" in structures_copy:
5472
structures_copy.pop(structures_copy.index("nether_fortress.png"))
5573

5674
def nether_fossil():
75+
button_nether_fossil.configure(bg=changed_bg, fg=fg)
5776
if "nether_fossil.png" in structures_copy:
5877
structures_copy.pop(structures_copy.index("nether_fossil.png"))
5978

6079
def ocean_monument():
80+
button_ocean_monument.configure(bg=changed_bg, fg=fg)
6181
if "ocean_monument.png" in structures_copy:
6282
structures_copy.pop(structures_copy.index("ocean_monument.png"))
6383

6484
def ocean_ruins():
85+
button_ocean_ruins.configure(bg=changed_bg, fg=fg)
6586
if "ocean_ruins.png" in structures_copy:
6687
structures_copy.pop(structures_copy.index("ocean_ruins.png"))
6788

6889
def pillager_outpost():
90+
button_pillager_outpost.configure(bg=changed_bg, fg=fg)
6991
if "pillager_outpost.png" in structures_copy:
7092
structures_copy.pop(structures_copy.index("pillager_outpost.png"))
7193

7294
def ruined_portal():
95+
button_ruined_portal.configure(bg=changed_bg, fg=fg)
7396
if "ruined_portal.png" in structures_copy:
7497
structures_copy.pop(structures_copy.index("ruined_portal.png"))
7598

7699
def shipwreck():
100+
button_shipwreck.configure(bg=changed_bg, fg=fg)
77101
if "shipwreck.png" in structures_copy:
78102
structures_copy.pop(structures_copy.index("shipwreck.png"))
79103

80104
def stronghold():
105+
button_stronghold.configure(bg=changed_bg, fg=fg)
81106
if "stronghold.png" in structures_copy:
82107
structures_copy.pop(structures_copy.index("stronghold.png"))
83108

84109
def swamp_hut():
110+
button_swamp_hut.configure(bg=changed_bg, fg=fg)
85111
if "swamp_hut.png" in structures_copy:
86112
structures_copy.pop(structures_copy.index("swamp_hut.png"))
87113

88114
def village():
115+
button_village.configure(bg=changed_bg, fg=fg)
89116
if "village.png" in structures_copy:
90117
structures_copy.pop(structures_copy.index("village.png"))
91118

92119
def wooden_mansion():
120+
button_wooden_mansion.configure(bg=changed_bg, fg=fg)
93121
if "wooden_mansion.png" in structures_copy:
94122
structures_copy.pop(structures_copy.index("wooden_mansion.png"))
95123

96124
def clear():
125+
button_bastion.configure(bg=bg, fg=fg)
126+
button_burried_treasure.configure(bg=bg, fg=fg)
127+
button_desert_pyramid.configure(bg=bg, fg=fg)
128+
button_end_city.configure(bg=bg, fg=fg)
129+
button_igloo.configure(bg=bg, fg=fg)
130+
button_jungle_temple.configure(bg=bg, fg=fg)
131+
button_mineshaft.configure(bg=bg, fg=fg)
132+
button_nether_fortress.configure(bg=bg, fg=fg)
133+
button_nether_fossil.configure(bg=bg, fg=fg)
134+
button_ocean_monument.configure(bg=bg, fg=fg)
135+
button_ocean_ruins.configure(bg=bg, fg=fg)
136+
button_pillager_outpost.configure(bg=bg, fg=fg)
137+
button_ruined_portal.configure(bg=bg, fg=fg)
138+
button_shipwreck.configure(bg=bg, fg=fg)
139+
button_stronghold.configure(bg=bg, fg=fg)
140+
button_swamp_hut.configure(bg=bg, fg=fg)
141+
button_village.configure(bg=bg, fg=fg)
142+
button_wooden_mansion.configure(bg=bg, fg=fg)
97143
for i in range(0, len(structures_copy) - 1):
98144
structures_copy.pop()
99145
for i in structures:
@@ -102,11 +148,6 @@ def clear():
102148
def settings():
103149
subprocess.Popen('explorer "settings.txt"')
104150

105-
font = ("Arial, 15")
106-
bg = "#ffffff"
107-
fg = "#000000"
108-
width = 17
109-
110151
button_bastion = Button(text="Bastion Remnant", font=font, bg=bg, fg=fg, width=width, command=bastion)
111152
button_burried_treasure = Button(text="Burried Treasure", font=font, bg=bg, fg=fg, width=width, command=burried_treasure)
112153
button_desert_pyramid = Button(text="Desert Pyramid", font=font, bg=bg, fg=fg, width=width, command=desert_pyramid)
@@ -125,8 +166,8 @@ def settings():
125166
button_swamp_hut = Button(text="Swamp Hut", font=font, bg=bg, fg=fg, width=width, command=swamp_hut)
126167
button_village = Button(text="Village", font=font, bg=bg, fg=fg, width=width, command=village)
127168
button_wooden_mansion = Button(text="Woodland Mansion", font=font, bg=bg, fg=fg, width=width, command=wooden_mansion)
128-
button_clear = Button(text="Clear", font=font, bg=bg, fg=fg, width=width, command=clear)
129-
button_settings = Button(text="Settings", font=font, bg=bg, fg=fg, width=width, command=settings)
169+
button_clear = Button(text="Clear", font=font, bg="#cccccc", fg=fg, width=width, command=clear)
170+
button_settings = Button(text="Settings", font=font, bg="#cccccc", fg=fg, width=width, command=settings)
130171

131172
button_bastion.grid(row=0, column=0)
132173
button_burried_treasure.grid(row=0, column=1)
@@ -157,8 +198,9 @@ def overlay_function():
157198

158199
global display_number
159200
display_number = int(the_settings[1].replace("STRUCTURES_SHOWN=", "").replace("\n", ""))
160-
background_color = str(the_settings[2].replace("OVERLAY_BACKGROUND=", "").replace("\n", ""))
161-
displayed_icon = str(the_settings[3].replace("PREVIEWS=", "").replace("\n", ""))
201+
background_color = str(the_settings[3].replace("OVERLAY_BACKGROUND=", "").replace("\n", ""))
202+
displayed_icon = str(the_settings[4].replace("PREVIEWS=", "").replace("\n", ""))
203+
scrolling_speed = float(the_settings[5].replace("SCROLLING_SPEED=", "").replace("\n", ""))
162204

163205
window_overlay_icon = pygame.image.load('assets/icon.png')
164206
window_overlay = pygame.display.set_mode((display_number*120, 140))
@@ -202,7 +244,7 @@ def overlay_function():
202244
name = structures_copy[nb_index]
203245
image = pygame.transform.scale(dict_images[name], (120, 120))
204246
window_overlay.blit(image, (positions[i], 10))
205-
positions[i] = positions[i] - 0.1
247+
positions[i] = positions[i] - scrolling_speed
206248

207249
if positions[i] < -240:
208250
structures_copy.append(structures_copy[0])

‎settings.txt‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# You will need to restart the tracker once data changed. Previews can be "BLOCS" or "ICONS".
1+
# You will need to restart the tracker once data changed. Previews can be "BLOCS" or "ICONS". Scrolling speed is px per loop.
22
STRUCTURES_SHOWN=18
3+
CLICKED_BUTTONS=#00ff00
34
OVERLAY_BACKGROUND=#00ff00
4-
PREVIEWS=BLOCS
5+
PREVIEWS=BLOCS
6+
SCROLLING_SPEED=0.1

0 commit comments

Comments
 (0)