Skip to content

Commit

Permalink
now possible to add drop to the previous run
Browse files Browse the repository at this point in the history
  • Loading branch information
oskros committed Oct 28, 2020
1 parent 4ee304f commit 5303740
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from main_frame import MainFrame

if win32gui.FindWindow(None, 'MF run counter'):
resp = tk_utils.mbox(msg='It seems like you already have an instance of MF run counter open.\n'
resp = tk_utils.mbox(msg='It seems like you already have an instance of MF Run Counter open.\n'
'Opening another instance will make the app unstable (If this is a false positive, just ignore it)\n\n'
'Do you wish to continue anyway?', title='WARNING')
if not resp:
Expand Down
1 change: 1 addition & 0 deletions main_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self):
self.auto_upload_herokuapp = other_utils.safe_eval(self.cfg['OPTIONS']['auto_upload_herokuapp'])
self.auto_archive_hours = other_utils.safe_eval(self.cfg['OPTIONS']['auto_archive_hours'])
self.autocompletion_unids = other_utils.safe_eval(self.cfg['OPTIONS']['autocompletion_unids'])
self.add_to_last_run = other_utils.safe_eval(self.cfg['OPTIONS']['add_to_last_run'])

# UI config
self.show_buttons = other_utils.safe_eval(self.cfg['UI']['show_buttons'])
Expand Down
14 changes: 7 additions & 7 deletions memory_reader/stat_mappings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import csv
import os
import sys
from init import media_path


def load_stat_map():
lib_path = os.path.join(media_path + 'stat_map.csv')
with open(lib_path, 'r') as fo:
with open(media_path + 'stat_map.csv', 'r') as fo:
out = {int(row['ID']): row for row in csv.DictReader(fo)}
return out

Expand All @@ -32,7 +29,7 @@ def load_stat_map():
42: 'Ele Skills (Druid)',
48: 'Trap Skills (Assa)',
49: 'Shadow Skills (Assa)',
50: 'Martial Skills (Assa)'
50: 'Martial Skills (Assa)',
}

CLASSSKILLS = {
Expand All @@ -42,11 +39,14 @@ def load_stat_map():
3: 'Paladin Skills',
4: 'Barbarian Skills',
5: 'Druid Skills',
6: 'Assassin Skills'
6: 'Assassin Skills',
}

ELEMENTALSKILLS = {
1: 'Fire Skills'
0: 'ELEMENTAL_SKILLS_0',
1: 'Fire Skills',
2: 'ELEMENTAL_SKILLS_2',
3: 'ELEMENTAL_SKILLS_3',
}

SKILLS = {
Expand Down
7 changes: 6 additions & 1 deletion modules/drops.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def _make_widgets(self):
scrollbar.pack(side=tk.RIGHT, fill=tk.Y, pady=(2, 1), padx=0)

def add_drop(self):
drop = autocompletion.acbox(enable=True, title='Add drop', unid_mode=self.main_frame.autocompletion_unids)
drop = autocompletion.acbox(enable=True, title='Add drop', unid_mode=self.main_frame.autocompletion_unids, add_to_last_run=self.main_frame.add_to_last_run)
if not drop or drop['input'] == '':
return

if drop['item_name'] is not None:
for i, item in enumerate(self.main_frame.grail_tab.grail):
if item['Item'] == drop['item_name']:
Expand Down Expand Up @@ -71,9 +72,13 @@ def add_drop(self):
drop['Item Class'] = item.get('Item Class', '')
break

last_run = drop.pop('last_run', False)
run_no = len(self.main_frame.timer_tab.laps)
if self.main_frame.timer_tab.is_running:
run_no += 1
if last_run and run_no > 0:
run_no -= 1
self.main_frame.add_to_last_run = last_run

drop['Real time'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
drop['Profile'] = self.main_frame.active_profile
Expand Down
13 changes: 7 additions & 6 deletions utils/autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def comparison(self, var, eth=False):


class ACMbox(object):
def __init__(self, title, enable=True, unid_mode=False):
def __init__(self, title, enable=True, unid_mode=False, add_to_last_run=False):
self.root = tk.Toplevel()
self.root.geometry(
'200x145+%s+%s' % (self.root.winfo_screenwidth() // 2 - 100, self.root.winfo_screenheight() // 2 - 72))
'200x146+%s+%s' % (self.root.winfo_screenwidth() // 2 - 100, self.root.winfo_screenheight() // 2 - 72))
self.root.update_idletasks()
self.root.focus_set()
self.root.iconbitmap(media_path + 'icon.ico')
Expand All @@ -132,7 +132,8 @@ def __init__(self, title, enable=True, unid_mode=False):
frm_1 = tk.Frame(self.root)
frm_1.pack(ipadx=4, ipady=2, fill=tk.BOTH, expand=tk.Y)

tk.Label(frm_1, text='Input your drop...').pack()
self.last_run_var = tk.IntVar(value=add_to_last_run)
tk.Checkbutton(frm_1, variable=self.last_run_var, text='Add to last run').pack()

tw = tk.StringVar()
self.entry = AutocompleteEntry(frm_1, width=32, textvariable=tw, enable=enable, unid_mode=unid_mode)
Expand Down Expand Up @@ -163,7 +164,7 @@ def b1_action(self, event=None):
eth_item = True
user_input = self.entry.var.get().strip()
extra_input = user_input.replace(item_name, '').strip().replace(' ', ' ') if item_name is not None else ''
self.returning = {'item_name': item_name, 'input': user_input, 'extra': extra_input, 'eth': eth_item}
self.returning = {'item_name': item_name, 'input': user_input, 'extra': extra_input, 'eth': eth_item, 'last_run': self.last_run_var.get()}
self.root.quit()

def close_mod(self, event=None):
Expand All @@ -175,8 +176,8 @@ def close_mod(self, event=None):
self.root.quit()


def acbox(title='Drop', enable=True, unid_mode=False):
msgbox = ACMbox(title, enable=enable, unid_mode=unid_mode)
def acbox(title='Drop', enable=True, unid_mode=False, add_to_last_run=False):
msgbox = ACMbox(title, enable=enable, unid_mode=unid_mode, add_to_last_run=add_to_last_run)
msgbox.root.mainloop()

# the function pauses here until the mainloop is quit
Expand Down
2 changes: 2 additions & 0 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def default_config(self):
config['OPTIONS']['auto_upload_herokuapp'] = '0'
config['OPTIONS']['auto_archive_hours'] = '0.0'
config['OPTIONS']['autocompletion_unids'] = '0'
config['OPTIONS']['add_to_last_run'] = '0'

config.add_section('AUTOMODE')
config['AUTOMODE']['automode'] = '0'
Expand Down Expand Up @@ -169,6 +170,7 @@ def update_config(self, parent):
cfg['OPTIONS']['auto_upload_herokuapp'] = str(parent.auto_upload_herokuapp)
cfg['OPTIONS']['auto_archive_hours'] = str(parent.auto_archive_hours)
cfg['OPTIONS']['autocompletion_unids'] = str(parent.autocompletion_unids)
cfg['OPTIONS']['add_to_last_run'] = str(parent.add_to_last_run)

# Update automodes
cfg['AUTOMODE']['automode'] = str(parent.automode)
Expand Down
2 changes: 1 addition & 1 deletion utils/tk_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,4 @@ def add_circle(parent, pixels, color):
if __name__ == '__main__':
# r = tk.Tk()

print(mbox('hi', disabled_btn_input='DELETE'))
print(mbox('hi', entry=True, disabled_btn_input='DELETE'))

0 comments on commit 5303740

Please sign in to comment.