Skip to content

Commit

Permalink
Improved editing performance with very large BCM's, fixed child/sibli…
Browse files Browse the repository at this point in the history
…ng indexes cutting off at 32767
  • Loading branch information
KyonkoYuuki committed Jun 5, 2020
1 parent 894645f commit e784797
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ This tool is here to help out with creating and modifying BCMs. In addition to g
allow limited multi select for deleting multiple entries, removed prompt asking to keep children when deleting.
0.2.1 - Fixed bug where entry0 wasn't added when saving. Improved performance on copying large entries.
0.2.2 - Add automatic backup creation on saving
0.2.3 - Improved editing performance with very large BCM's, fixed child/sibling indexes cutting off at 32767
```
2 changes: 1 addition & 1 deletion YaBCM Organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from yabcm.dlg.replace import ReplaceDialog
from pyxenoverse.gui.file_drop_target import FileDropTarget

VERSION = '0.2.2'
VERSION = '0.2.3'


class MainWindow(wx.Frame):
Expand Down
18 changes: 9 additions & 9 deletions yabcm/panels/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def __init__(self, parent):
sizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND, 10)

self.address = DummyCtrl()
self.sibling = self.add_num_entry(misc_panel, 'Sibling Idx')
self.sibling = self.add_num_entry(misc_panel, 'Sibling Idx', min=0, max=0x7FFFFFFF)
self.parent = DummyCtrl()
self.child = self.add_num_entry(misc_panel, 'Child Idx')
self.child = self.add_num_entry(misc_panel, 'Child Idx', min=0, max=0x7FFFFFFF)
self.root = DummyCtrl()

# u_00
Expand Down Expand Up @@ -183,9 +183,9 @@ def add_num_entry(self, panel, _, unsigned=False, *args, **kwargs):
if 'size' not in kwargs:
kwargs['size'] = (150, -1)
if unsigned:
kwargs['min'], kwargs['max'] = 0, 65535
kwargs['min'], kwargs['max'] = kwargs.get('min', 0), kwargs.get('max', 65535)
else:
kwargs['min'], kwargs['max'] = -32768, 32767
kwargs['min'], kwargs['max'] = kwargs.get('min', -32768), kwargs.get('max', 32767)
return wx.SpinCtrl(panel, *args, **kwargs)

@add_entry
Expand Down Expand Up @@ -229,11 +229,11 @@ def save_entry(self, _):
self.edit_thread = None
if not self.entry:
return
reindex = False
relabel = False
for name in self.entry.__fields__:
# SpinCtrlDoubles suck
control = self[name]
old_value = self[name]
old_value = self.entry[name]
if isinstance(control, wx.SpinCtrlDouble):
try:
new_value = float(control.Children[0].GetValue())
Expand All @@ -252,10 +252,10 @@ def save_entry(self, _):
if old_value != new_value:
self.entry[name] = new_value
if name == "child" or name == "sibling":
reindex = True
relabel = True

if reindex:
pub.sendMessage('reindex')
if relabel:
pub.sendMessage('relabel', index=address_to_index(self.entry.address))

def focus(self, entry):
page = self.notebook.FindPage(self[entry].GetParent())
Expand Down
23 changes: 19 additions & 4 deletions yabcm/panels/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, parent):

pub.subscribe(self.on_select, 'on_select')
pub.subscribe(self.reindex, 'reindex')
pub.subscribe(self.reindex, 'expand_parents')
pub.subscribe(self.relabel, 'relabel')

# Use some sizers to see layout options
sizer = wx.BoxSizer(wx.VERTICAL)
Expand Down Expand Up @@ -305,6 +305,24 @@ def on_paste(self, _):
pub.sendMessage('load_entry', entry=self.entry_list.GetItemData(item))
pub.sendMessage('set_status_bar', text='Pasted to ' + self.entry_list.GetItemText(item))

def relabel(self, index):
item = self.entry_list.GetRootItem()

for _ in range(index):
item = get_next_item(self.entry_list, item)

entry = self.entry_list.GetItemData(item)
sibling = self.entry_list.GetNextSibling(item)
child, _ = self.entry_list.GetFirstChild(item)
sibling_address = self.entry_list.GetItemData(sibling).address if sibling.IsOk() else 0
child_address = self.entry_list.GetItemData(child).address if child.IsOk() else 0
text = f'Entry {index}'
if sibling_address != entry.sibling:
text += f", Sibling: {address_to_index(entry.sibling)}"
if child_address != entry.child:
text += f", Child: {address_to_index(entry.child)}"
self.entry_list.SetItemText(item, text)

def reindex(self):
# Set indexes first
item, _ = get_first_item(self.entry_list)
Expand Down Expand Up @@ -359,6 +377,3 @@ def reindex(self):
entries.append(entry)
item = get_next_item(self.entry_list, item)
self.parent.bcm.entries = entries



0 comments on commit e784797

Please sign in to comment.