Skip to content

Commit

Permalink
Clear function works properly again
Browse files Browse the repository at this point in the history
organic toggle is also now affected by status lock, might change
  • Loading branch information
Vhou-Atroph committed May 10, 2024
1 parent 01a0c92 commit 35391bf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
14 changes: 2 additions & 12 deletions src/tt_damage_calculator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@
window.bind('<' + settings.keybinds.organic + '>', lambda par: [window.toggle_organic()])

# Clear inputs function
def clear_inputs(*arg):
window.history.box.add(tt_damage_calculator.CalculationResults(int(window.results.damage_counter.cget("text")), tt_damage_calculator.lvl_ind(int(window.results.damage_counter.cget("text"))), window.lure.get(), window.defense_buff.get(), window.defense_debuff.get()).build())
if window.organic.get():
window.toggle_organic()
window.reset_tracks()
for i in gag_btns:
i.configure(text='0')
if not window.status_lock.get():
window.reset_vars()
window.calculate()
window.toggles.clear.configure(command=clear_inputs)
window.bind('<' + settings.keybinds.reset + '>', clear_inputs)
window.toggles.clear.configure(command=window.reset_calculation)
window.bind('<' + settings.keybinds.reset + '>', lambda par: [window.reset_calculation()])

# Geometry - Main Columns
window.column_0.grid(column=0, row=0, padx=5)
Expand Down
73 changes: 43 additions & 30 deletions src/tt_damage_calculator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,51 +186,51 @@ def __init__(self, window:Tk, parent:Frame):
self.opera = GagButton(self.window, self.sound, image=self.opera_image, gag=tt_damage_calculator.Gag("Gag", "Opera Singer", "Sound", 6, 90))

self.throw = GagFrame(self, 2)
self.cupcake_image = PhotoImage(file=self.window.asset_path + '/assets/img/cupcake.png')
self.cupcake_image = PhotoImage(file=self.window.asset_path + "/assets/img/cupcake.png")
self.cupcake = GagButton(self.window, self.throw, image=self.cupcake_image, gag=tt_damage_calculator.Gag("Gag", "Cupcake", "Throw", 0, 6))
self.fruit_pie_slice_image = PhotoImage(file=self.window.asset_path + '/assets/img/fruit-pie-slice.png')
self.fruit_pie_slice_image = PhotoImage(file=self.window.asset_path + "/assets/img/fruit-pie-slice.png")
self.fruit_pie_slice = GagButton(self.window, self.throw, image=self.fruit_pie_slice_image, gag=tt_damage_calculator.Gag("Gag", "Fruit Pie Slice", "Throw", 1, 10))
self.cream_pie_slice_image = PhotoImage(file=self.window.asset_path + '/assets/img/cream-pie-slice.png')
self.cream_pie_slice_image = PhotoImage(file=self.window.asset_path + "/assets/img/cream-pie-slice.png")
self.cream_pie_slice = GagButton(self.window, self.throw, image=self.cream_pie_slice_image, gag=tt_damage_calculator.Gag("Gag", "Cream Pie Slice", "Throw", 2, 17))
self.whole_fruit_pie_image = PhotoImage(file=self.window.asset_path + '/assets/img/whole-fruit-pie.png')
self.whole_fruit_pie_image = PhotoImage(file=self.window.asset_path + "/assets/img/whole-fruit-pie.png")
self.whole_fruit_pie = GagButton(self.window, self.throw, image=self.whole_fruit_pie_image, gag=tt_damage_calculator.Gag("Gag", "Whole Fruit Pie", "Throw", 3, 27))
self.whole_cream_pie_image = PhotoImage(file=self.window.asset_path + '/assets/img/whole-cream-pie.png')
self.whole_cream_pie_image = PhotoImage(file=self.window.asset_path + "/assets/img/whole-cream-pie.png")
self.whole_cream_pie = GagButton(self.window, self.throw, image=self.whole_cream_pie_image, gag=tt_damage_calculator.Gag("Gag", "Whole Cream Pie", "Throw", 4, 40))
self.birthday_cake_image = PhotoImage(file=self.window.asset_path + '/assets/img/birthday-cake.png')
self.birthday_cake_image = PhotoImage(file=self.window.asset_path + "/assets/img/birthday-cake.png")
self.birthday_cake = GagButton(self.window, self.throw, image=self.birthday_cake_image, gag=tt_damage_calculator.Gag("Gag", "Birthday Cake", "Throw", 5, 100))
self.wedding_cake_image = PhotoImage(file=self.window.asset_path + '/assets/img/wedding-cake.png')
self.wedding_cake_image = PhotoImage(file=self.window.asset_path + "/assets/img/wedding-cake.png")
self.wedding_cake = GagButton(self.window, self.throw, image=self.wedding_cake_image, gag=tt_damage_calculator.Gag("Gag", "Wedding Cake", "Throw", 6, 120))

self.squirt = GagFrame(self, 3)
self.squirting_flower_image = PhotoImage(file=self.window.asset_path + '/assets/img/squirting-flower.png')
self.squirting_flower_image = PhotoImage(file=self.window.asset_path + "/assets/img/squirting-flower.png")
self.squirting_flower = GagButton(self.window, self.squirt, image=self.squirting_flower_image, gag=tt_damage_calculator.Gag("Gag", "Squirting Flower", "Squirt", 0, 4))
self.glass_of_water_image = PhotoImage(file=self.window.asset_path + '/assets/img/glass-of-water.png')
self.glass_of_water_image = PhotoImage(file=self.window.asset_path + "/assets/img/glass-of-water.png")
self.glass_of_water = GagButton(self.window, self.squirt, image=self.glass_of_water_image, gag=tt_damage_calculator.Gag("Gag", "Glass of Water", "Squirt", 1, 8))
self.squirt_gun_image = PhotoImage(file=self.window.asset_path + '/assets/img/squirt-gun.png')
self.squirt_gun_image = PhotoImage(file=self.window.asset_path + "/assets/img/squirt-gun.png")
self.squirt_gun = GagButton(self.window, self.squirt, image=self.squirt_gun_image, gag=tt_damage_calculator.Gag("Gag", "Squirt Gun", "Squirt", 2, 12))
self.seltzer_bottle_image = PhotoImage(file=self.window.asset_path + '/assets/img/seltzer-bottle.png')
self.seltzer_bottle_image = PhotoImage(file=self.window.asset_path + "/assets/img/seltzer-bottle.png")
self.seltzer_bottle = GagButton(self.window, self.squirt, image=self.seltzer_bottle_image, gag=tt_damage_calculator.Gag("Gag", "Seltzer Bottle", "Squirt", 3, 21))
self.firehose_image = PhotoImage(file=self.window.asset_path + '/assets/img/fire-hose.png')
self.firehose_image = PhotoImage(file=self.window.asset_path + "/assets/img/fire-hose.png")
self.firehose = GagButton(self.window, self.squirt, image=self.firehose_image, gag=tt_damage_calculator.Gag("Gag", "Fire Hose", "Squirt", 4, 30))
self.storm_cloud_image = PhotoImage(file=self.window.asset_path + '/assets/img/storm-cloud.png')
self.storm_cloud_image = PhotoImage(file=self.window.asset_path + "/assets/img/storm-cloud.png")
self.storm_cloud = GagButton(self.window, self.squirt, image=self.storm_cloud_image, gag=tt_damage_calculator.Gag("Gag", "Storm Cloud", "Squirt", 5, 80))
self.geyser_image = PhotoImage(file=self.window.asset_path + '/assets/img/geyser.png')
self.geyser_image = PhotoImage(file=self.window.asset_path + "/assets/img/geyser.png")
self.geyser = GagButton(self.window, self.squirt, image=self.geyser_image, gag=tt_damage_calculator.Gag("Gag", "Geyser", "Squirt", 6, 105))

self.drop = GagFrame(self, 4)
self.flowerpot_image = PhotoImage(file=self.window.asset_path + '/assets/img/flower-pot.png')
self.flowerpot_image = PhotoImage(file=self.window.asset_path + "/assets/img/flower-pot.png")
self.flowerpot = GagButton(self.window, self.drop, image=self.flowerpot_image, gag=tt_damage_calculator.Gag("Gag", "Flower Pot", "Drop", 0, 10))
self.sandbag_image = PhotoImage(file=self.window.asset_path + '/assets/img/sandbag.png')
self.sandbag_image = PhotoImage(file=self.window.asset_path + "/assets/img/sandbag.png")
self.sandbag = GagButton(self.window, self.drop, image=self.sandbag_image, gag=tt_damage_calculator.Gag("Gag", "Sandbag", "Drop", 1, 18))
self.anvil_image = PhotoImage(file=self.window.asset_path + '/assets/img/anvil.png')
self.anvil_image = PhotoImage(file=self.window.asset_path + "/assets/img/anvil.png")
self.anvil = GagButton(self.window, self.drop, image=self.anvil_image, gag=tt_damage_calculator.Gag("Gag", "Anvil", "Drop", 2, 30))
self.big_weight_image = PhotoImage(file=self.window.asset_path + '/assets/img/big-weight.png')
self.big_weight_image = PhotoImage(file=self.window.asset_path + "/assets/img/big-weight.png")
self.big_weight = GagButton(self.window, self.drop, image=self.big_weight_image, gag=tt_damage_calculator.Gag("Gag", "Big Weight", "Drop", 3, 45))
self.safe_image = PhotoImage(file=self.window.asset_path + '/assets/img/safe.png')
self.safe_image = PhotoImage(file=self.window.asset_path + "/assets/img/safe.png")
self.safe = GagButton(self.window, self.drop, image=self.safe_image, gag=tt_damage_calculator.Gag("Gag", "Safe", "Drop", 4, 70))
self.grand_piano_image = PhotoImage(file=self.window.asset_path + '/assets/img/grand-piano.png')
self.grand_piano_image = PhotoImage(file=self.window.asset_path + "/assets/img/grand-piano.png")
self.grand_piano = GagButton(self.window, self.drop, image=self.grand_piano_image, gag=tt_damage_calculator.Gag("Gag", "Grand Piano", "Drop", 5, 170))
self.toontanic_image = PhotoImage(file=self.window.asset_path + '/assets/img/toontanic.png')
self.toontanic_image = PhotoImage(file=self.window.asset_path + "/assets/img/toontanic.png")
self.toontanic = GagButton(self.window, self.drop, image=self.toontanic_image, gag=tt_damage_calculator.Gag("Gag", "Toontanic", "Drop", 6, 180))

self.list= [
Expand Down Expand Up @@ -258,27 +258,27 @@ def __init__(self, window:Tk):
Frame.__init__(self, window)

self.trap = GagFrame(self, 0)
self.clerk_will_image = PhotoImage(file=window.asset_path + '/assets/img/clerkwill.png')
self.clerk_will_image = PhotoImage(file=window.asset_path + "/assets/img/clerkwill.png")
self.clerk_will = GagButton(window, self.trap, image=self.clerk_will_image, gag=tt_damage_calculator.Gag("Sos", "Clerk Will", "Trap", 0, 60))
self.clerk_penny_image = PhotoImage(file=window.asset_path + '/assets/img/clerkpenny.png')
self.clerk_penny_image = PhotoImage(file=window.asset_path + "/assets/img/clerkpenny.png")
self.clerk_penny = GagButton(window, self.trap, image=self.clerk_penny_image, gag=tt_damage_calculator.Gag("Sos", "Clerk Penny", "Trap", 1, 120))
self.clerk_clara_image = PhotoImage(file=window.asset_path + '/assets/img/clerkclara.png')
self.clerk_clara_image = PhotoImage(file=window.asset_path + "/assets/img/clerkclara.png")
self.clerk_clara = GagButton(window, self.trap, image=self.clerk_clara_image, gag=tt_damage_calculator.Gag("Sos", "Clerk Clara", "Trap", 2, 180))

self.sound = GagFrame(self, 1)
self.barbara_seville_image = PhotoImage(file=window.asset_path + '/assets/img/barbaraseville.png')
self.barbara_seville_image = PhotoImage(file=window.asset_path + "/assets/img/barbaraseville.png")
self.barbara_seville = GagButton(window, self.sound ,image=self.barbara_seville_image, gag=tt_damage_calculator.Gag("Sos", "Barbara Seville", "Sound", 0, 35))
self.sid_sonata_image = PhotoImage(file=window.asset_path + '/assets/img/sidsonata.png')
self.sid_sonata_image = PhotoImage(file=window.asset_path + "/assets/img/sidsonata.png")
self.sid_sonata = GagButton(window, self.sound, image=self.sid_sonata_image, gag=tt_damage_calculator.Gag("Sos", "Sid Sonata", "Sound", 1, 55))
self.moe_zart_image = PhotoImage(file=window.asset_path + '/assets/img/moezart.png')
self.moe_zart_image = PhotoImage(file=window.asset_path + "/assets/img/moezart.png")
self.moe_zart = GagButton(window, self.sound, image=self.moe_zart_image, gag=tt_damage_calculator.Gag("Sos", "Moe Zart", "Sound", 2, 75))

self.drop = GagFrame(self, 2)
self.clumsy_ned_image = PhotoImage(file=window.asset_path + '/assets/img/clumsyned.png')
self.clumsy_ned_image = PhotoImage(file=window.asset_path + "/assets/img/clumsyned.png")
self.clumsy_ned = GagButton(window, self.drop, image=self.clumsy_ned_image, gag=tt_damage_calculator.Gag("Sos", "Clumsy Ned", "Drop", 0, 60))
self.franz_neckvein_img = PhotoImage(file=window.asset_path + '/assets/img/franzneckvein.png')
self.franz_neckvein_img = PhotoImage(file=window.asset_path + "/assets/img/franzneckvein.png")
self.franz_neckvein = GagButton(window, self.drop, image=self.franz_neckvein_img, gag=tt_damage_calculator.Gag("Sos", "Franz Neckvein", "Drop", 1, 100))
self.barnacle_bessie_image = PhotoImage(file=window.asset_path + '/assets/img/barnaclebessie.png')
self.barnacle_bessie_image = PhotoImage(file=window.asset_path + "/assets/img/barnaclebessie.png")
self.barnacle_bessie = GagButton(window, self.drop, image=self.barnacle_bessie_image, gag=tt_damage_calculator.Gag("Sos", "Barnacle Bessie", "Drop", 2, 170))

class HideableBottom():
Expand Down Expand Up @@ -373,6 +373,19 @@ def calculate(self):
self.results.damage_counter.configure(text=str(damage))
self.results.level_counter.configure(text=tt_damage_calculator.lvl_ind_string(tt_damage_calculator.lvl_ind(damage), int(self.defense_buff.get() * 100), int(self.defense_debuff.get() * 100)))

def reset_calculation(self):
"""Resets the current calculation."""

self.history.box.add(tt_damage_calculator.CalculationResults(int(self.results.damage_counter.cget("text")), tt_damage_calculator.lvl_ind(int(self.results.damage_counter.cget("text"))), self.lure.get(), self.defense_buff.get(), self.defense_debuff.get()).build())
if not self.status_lock.get():
self.reset_vars()
if self.organic.get():
self.toggle_organic()
self.reset_tracks()
for i in self.gags.list:
i.configure(text="0")
self.calculate()

def pin(self):
"""Pin or unpin the gag calculator depending on the 'pinned' variable."""

Expand Down

0 comments on commit 35391bf

Please sign in to comment.