Skip to content

Commit

Permalink
CalculationResults
Browse files Browse the repository at this point in the history
new class to hold calc results frame
  • Loading branch information
Vhou-Atroph committed Mar 26, 2024
1 parent c83fb0e commit d899970
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
18 changes: 5 additions & 13 deletions src/tt_damage_calculator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
# Total damage calculation
def calc_dmg(*args):
tot_dmg = tt_damage_calculator.full_calc(trp_used, snd_used, trw_used, sqt_used, drp_used, no_group.get(), lured.get(), dmg_down.get(), dmg_up.get())
cog_level_indicator.configure(text=tt_damage_calculator.lvl_ind_string(tt_damage_calculator.lvl_ind(tot_dmg), int(dmg_down.get() * 100), int(dmg_up.get() * 100)))
dmg_indicator.configure(text=str(tot_dmg))
calc_results.level_counter.configure(text=tt_damage_calculator.lvl_ind_string(tt_damage_calculator.lvl_ind(tot_dmg), int(dmg_down.get() * 100), int(dmg_up.get() * 100)))
calc_results.damage_counter.configure(text=str(tot_dmg))

# Pin window to top
def pin():
Expand Down Expand Up @@ -226,11 +226,7 @@ def use_groupless(name:str, damage:int):
cog_calc = Button(hist, text="Show Health and\n SOS Cards")

# Calculation results
calc_results = Frame(col0)
dmg_this_round = Label(calc_results, text="Damage this round:", font=('Arial', 16, 'normal'))
dmg_indicator = Label(calc_results, text="0", font=('Arial', 16, 'bold'))
cog_level_indicator = Label(calc_results, text="Level 0", font=('Arial', 8, 'normal'))
org_indicator = Label(calc_results, text="Organic = OFF", font=('Arial', 10, 'bold'))
calc_results = widgets.CalculationResults(col0)

# Cog HP
cog_health_sheet = Frame(window)
Expand Down Expand Up @@ -272,7 +268,7 @@ def use_groupless(name:str, damage:int):
def organic_toggle(*arg):
data = tt_damage_calculator.orgswap(organic.get())
organic.set(data[0])
org_indicator.configure(text="Organic = " + data[1])
calc_results.organic_indicator.configure(text="Organic = " + data[1])
for i in gag_btns:
i.configure(bg=data[2], activebackground=data[3])
org_btn.configure(command=organic_toggle)
Expand All @@ -285,7 +281,7 @@ def clear_inputs(*arg):
global sqt_used
global drp_used
global trp_used
hist_box.add(tt_damage_calculator.CalculationResults(int(dmg_indicator.cget("text")), tt_damage_calculator.lvl_ind(int(dmg_indicator.cget("text"))), lured.get(), dmg_down.get(), dmg_up.get()).build())
hist_box.add(tt_damage_calculator.CalculationResults(int(calc_results.damage_counter.cget("text")), tt_damage_calculator.lvl_ind(int(calc_results.damage_counter.cget("text"))), lured.get(), dmg_down.get(), dmg_up.get()).build())
if organic.get():
organic_toggle()
snd_used = []
Expand Down Expand Up @@ -349,10 +345,6 @@ def cog_health_calc_show():

# Geometry - Calculation Results
calc_results.grid(column=0, row=0)
dmg_this_round.grid(column=0, row=0)
dmg_indicator.grid(column=1, row=0)
cog_level_indicator.grid(column=2, row=0)
org_indicator.grid(column=0, row=1, columnspan=3)

### Custom Gags ###
global custom_track
Expand Down
23 changes: 19 additions & 4 deletions src/tt_damage_calculator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
TT-Damage-Calculator
Copyright (C) 2022-2024 Vhou-Atroph
"""
from tkinter import BooleanVar, Frame, Text, Button, PhotoImage, NORMAL, DISABLED, WORD, END
from tkinter import BooleanVar, Frame, Label, Text, Button, PhotoImage, NORMAL, DISABLED, WORD, END

from . import tt_damage_calculator

class CalculationResults(Frame):
"""Class for the Calculation Results frame."""

def __init__(self, parent:Frame):
Frame.__init__(self, parent)
self.damage_label = Label(self, text="Damage this round:", font=('Arial', 16, 'normal'))
self.damage_counter = Label(self, text="0", font=('Arial', 16, 'bold'))
self.level_counter = Label(self, text="Level 0", font=('Arial', 8, 'normal'))
self.organic_indicator = Label(self, text="Organic = OFF", font=('Arial', 10, 'bold'))

self.damage_label.grid(column=0, row=0)
self.damage_counter.grid(column=1, row=0)
self.level_counter.grid(column=2, row=0)
self.organic_indicator.grid(column=0, row=1, columnspan=3)

class HistoryBox(Text):
"""Class for the History Box widget, a more complicated version of the normal tkinter Text widget."""

def __init__(self, frame: Frame):
Text.__init__(self, frame)
def __init__(self, parent:Frame):
Text.__init__(self, parent)
self['width'] = 25
self['height'] = 22
self['state'] = DISABLED
Expand Down Expand Up @@ -67,7 +82,7 @@ def recolor(self, orgstate:bool):

def press(self, output:HistoryBox, orgstate:bool):
"""Function to execute when Gag Button is pressed."""

gaginfo = self.gag.button_press(orgstate)
self.configure(text=int(self.cget("text")) + 1)
output.add("Gag used: " + gaginfo[1] + " (" + str(gaginfo[0]) + ")\n")
Expand Down

0 comments on commit d899970

Please sign in to comment.