From c06e164fb18ee31142b74a8e46a8763dee776119 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Sun, 28 Nov 2010 11:43:32 +0200 Subject: [PATCH] Use NumCtrl instead of IntCtrl (we want floats in dmg pattern editor), ignore bad data in dmg pattern import service --- gui/patternEditor.py | 23 ++++++++++------------- service/damagePattern.py | 19 +++++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gui/patternEditor.py b/gui/patternEditor.py index bdd79e16a..7e0e3d857 100644 --- a/gui/patternEditor.py +++ b/gui/patternEditor.py @@ -20,6 +20,7 @@ import wx import bitmapLoader from wx.lib.intctrl import IntCtrl +from wx.lib.masked.numctrl import NumCtrl import service from util import toClipboard, fromClipboard ########################################################################### @@ -103,22 +104,26 @@ class DmgPatternEditorDlg (wx.Dialog): self.bmpEM = wx.StaticBitmap(self, wx.ID_ANY, self.embitmap) dmgeditSizer.Add(self.bmpEM, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 5) - self.editEm = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize) + self.editEm = NumCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize) + self.editEm.SetFractionWidth(2) dmgeditSizer.Add(self.editEm, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpTHERM = wx.StaticBitmap(self, wx.ID_ANY, self.thermbitmap) dmgeditSizer.Add(self.bmpTHERM, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT, 25) - self.editThermal = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) + self.editThermal = NumCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) + self.editThermal.SetFractionWidth(2) dmgeditSizer.Add(self.editThermal, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpKIN = wx.StaticBitmap(self, wx.ID_ANY, self.kinbitmap) dmgeditSizer.Add(self.bmpKIN, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 5) - self.editKinetic = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize) + self.editKinetic = NumCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize) + self.editKinetic.SetFractionWidth(2) dmgeditSizer.Add(self.editKinetic, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5) self.bmpEXP = wx.StaticBitmap(self, wx.ID_ANY, self.expbitmap) dmgeditSizer.Add(self.bmpEXP, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT, 25) - self.editExplosive = IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) + self.editExplosive = NumCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize, 0) + self.editExplosive.SetFractionWidth(2) dmgeditSizer.Add(self.editExplosive, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5) contentSizer.Add(dmgeditSizer, 1, wx.EXPAND | wx.ALL, 5) @@ -136,12 +141,6 @@ class DmgPatternEditorDlg (wx.Dialog): self.totSizer = wx.BoxSizer(wx.VERTICAL) -# self.stTotal = wx.StaticText(self, wx.ID_ANY, u"LOL") -# self.stTotal.Wrap(-1) -# self.totSizer.Add(self.stTotal, 0, wx.ALIGN_RIGHT | wx.BOTTOM | wx.RIGHT, 5) - -# footerSizer.Add(self.totSizer, 1, 0, 5) - contentSizer.Add(footerSizer, 0, wx.EXPAND, 5) mainSizer.Add(contentSizer, 1, wx.EXPAND, 0) @@ -214,9 +213,7 @@ class DmgPatternEditorDlg (wx.Dialog): else: ltext = format %(0, 0, 0, 0) - #ttext = "Total: % 6d" % (total) self.stPercentages.SetLabel(ltext) - #self.stTotal.SetLabel(ttext) self.totSizer.Layout() if event is not None: @@ -297,7 +294,7 @@ class DmgPatternEditorDlg (wx.Dialog): def processRename(self, event): newName = self.namePicker.GetLineText(0) self.stPercentages.SetLabel("") -# self.stTotal.SetLabel("") + p = self.getActivePattern() for pattern in self.choices: if pattern.name == newName and p != pattern: diff --git a/service/damagePattern.py b/service/damagePattern.py index e67746ee2..0b96c7a2f 100644 --- a/service/damagePattern.py +++ b/service/damagePattern.py @@ -69,14 +69,17 @@ class DamagePattern(): current = self.getDamagePatternList() for pattern in current: lookup[pattern.name] = pattern - imports = eos.types.DamagePattern.importPatterns(text) - for pattern in imports: - if pattern.name in lookup: - match = lookup[pattern.name] - match.__dict__.update(pattern.__dict__) - else: - eos.db.save(pattern) - eos.db.commit() + try: + imports = eos.types.DamagePattern.importPatterns(text) + for pattern in imports: + if pattern.name in lookup: + match = lookup[pattern.name] + match.__dict__.update(pattern.__dict__) + else: + eos.db.save(pattern) + eos.db.commit() + except: + pass def exportPatterns(self): patterns = self.getDamagePatternList()