Return to repo list

opet

Oblivion Proton .esp Tool
Return to HMagellan.com

commit 9f24e836551a3f5d2e4b78a3c02e42a861a86889
parent 93a3f6504c86a994daa1edb9cfc60f68ec7cd531
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri,  8 Jan 2021 00:30:55 -0600

added custom data class

Diffstat:
Asrc/datas.py | 32++++++++++++++++++++++++++++++++
Msrc/opet.py | 41+++++++++++++++++++++--------------------
2 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/src/datas.py b/src/datas.py @@ -0,0 +1,32 @@ +############ +# datas.py # +############ + +# This file contains: +# 1. Various data structures used in OPET + +###################################### +# Section 1 - Custom data structures # +###################################### + +class OrderList(object): + """ + Data structure representing an organized list + of esp files along with their activation status, + and comments about them. + """ + + def __init__(self, manager, order, enabled, comments = {}): + + # Setup + self.manager = manager + self.init_order = order + self.init_enabled = enabled + self.init_comments = comments + + self.data = [] + for e in order: + self.data.append({ "name" : e, "enabled" : True if e in enabled else False, "comments" : comments[e] if e in comments.keys() else "" }) + + def get_data(self): + return self.data diff --git a/src/opet.py b/src/opet.py @@ -1,6 +1,5 @@ import wx, os -from wx.lib import scrolledpanel -from . import filer, tools, wxcustom +from . import filer, tools, wxcustom, datas ########### # opet.py # @@ -25,13 +24,24 @@ class OPET(object): # Various tools self.filer = filer.Filer(self, "environment.json") + self.environment = self.filer.get_environment() self.esp_tool = tools.DataPackTool(self) + # Data + rel = self.filer.read_raw_file(os.path.join(os.path.expanduser(self.environment["OblivionPrefixAppdata"]), "Plugins.txt")) + enabled_list = [] + for l in rel: + if not l == '\n' and l[0] != "#": + if l[len(l) - 1] == '\n': + l = l[0:len(l) - 1] + enabled_list.append(l) + self.esp_data = datas.OrderList(self, self.esp_tool.get_load_order_list(os.path.expanduser(self.environment["OblivionDataPath"])), enabled_list) + # Load up app and frame components self.app = wx.App() self.app_frame = OPETFrame(self, None, title = "OPET", size = (800, 600)) - self.app_frame.Show() self.app_frame.load() + self.app_frame.Show() self.app.MainLoop() ################################ @@ -92,38 +102,29 @@ class OPETFrame(wx.Frame): self.menu_bar.Append(self.help_menu, "&Help") self.SetMenuBar(self.menu_bar) - # Load info from files/other utilities - self.espjson = self.manager.filer.read_json(os.path.join("default", "DefaultPlugins.json")) - rel = self.manager.filer.read_raw_file(os.path.join(os.path.expanduser(self.manager.filer.get_environment()["OblivionPrefixAppdata"]), "Plugins.txt")) - self.enabled_list = [] - for l in rel: - if not l == '\n' and l[0] != "#": - if l[len(l) - 1] == '\n': - l = l[0:len(l) - 1] - self.enabled_list.append(l) - - self.load_order = self.manager.esp_tool.get_load_order_list(os.path.expanduser(self.manager.filer.get_environment()["OblivionDataPath"])) - - # Construct esp list + # Construct sub-panel self.sub_panel = wx.Panel(self.main_panel) self.sub_panel_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_panel.SetSizer(self.sub_panel_sizer) + self.sub_panel.SetSize(4, 4, 860, 800) + + # Construct esp list self.esp_list_panel = wx.Panel(self.sub_panel) self.esp_list_sizer = wx.BoxSizer(wx.VERTICAL) self.esp_list_panel.SetSizer(self.esp_list_sizer) self.esp_list_ctrl = wxcustom.ESPListCtrl(self.esp_list_panel, size = (500, 400)) index = 0 - for e in self.load_order: - entry = ["", index, e, self.espjson["comments"][e] if e in self.espjson["comments"] else ""] + esp_data = self.manager.esp_data.get_data() + for e in esp_data: + entry = ["", index, e["name"], e["comments"]] self.esp_list_ctrl.Append(entry) - if e in self.enabled_list: + if e["enabled"]: self.esp_list_ctrl.CheckItem(index, True) index += 1 self.esp_buttons_panel = wx.Panel(self.sub_panel) self.esp_buttons_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) self.esp_buttons_panel.SetSizer(self.esp_buttons_panel_sizer) self.esp_apply_button = wxcustom.ESPApplyButton(self.esp_buttons_panel) - self.sub_panel.SetSize(4, 4, 860, 800) self.esp_list_panel.SetSize(4, 4, 550, 450) self.esp_buttons_panel.SetSize(4, 430, 550, 200)