Merge branch 'master' into wx3
Conflicts: config.py staticdata/icons/icon01_08.png staticdata/icons/icon02_11.png staticdata/icons/icon105_46.png staticdata/icons/icon105_47.png staticdata/icons/icon105_48.png staticdata/icons/icon105_49.png staticdata/icons/icon108_5.png staticdata/icons/icon113_64_1.png staticdata/icons/icon113_64_2.png staticdata/icons/icon113_64_3.png staticdata/icons/icon34_16.png staticdata/icons/iconMarketIcon_16px_Amarr.png staticdata/icons/iconMarketIcon_16px_Caldari.png staticdata/icons/iconMarketIcon_16px_Gallente.png staticdata/icons/iconMarketIcon_16px_Minmatar.png
This commit is contained in:
@@ -45,13 +45,34 @@ class CharacterImportThread(threading.Thread):
|
||||
sCharacter = Character.getInstance()
|
||||
for path in paths:
|
||||
try:
|
||||
# we try to parse api XML data first
|
||||
with open(path, mode='r') as charFile:
|
||||
sheet = service.ParseXML(charFile)
|
||||
charID = sCharacter.new()
|
||||
sCharacter.rename(charID, sheet.name+" (imported)")
|
||||
sCharacter.apiUpdateCharSheet(charID, sheet)
|
||||
sCharacter.apiUpdateCharSheet(charID, sheet.skills)
|
||||
except:
|
||||
continue
|
||||
# if it's not api XML data, try this
|
||||
# this is a horrible logic flow, but whatever
|
||||
try:
|
||||
charFile = open(path, mode='r').read()
|
||||
doc = minidom.parseString(charFile)
|
||||
if doc.documentElement.tagName != "SerializableCCPCharacter":
|
||||
raise RuntimeError("Incorrect EVEMon XML sheet")
|
||||
name = doc.getElementsByTagName("name")[0].firstChild.nodeValue
|
||||
skill_els = doc.getElementsByTagName("skill")
|
||||
skills = []
|
||||
for skill in skill_els:
|
||||
skills.append({
|
||||
"typeID": int(skill.getAttribute("typeID")),
|
||||
"level": int(skill.getAttribute("level")),
|
||||
})
|
||||
charID = sCharacter.new()
|
||||
sCharacter.rename(charID, name+" (EVEMon)")
|
||||
sCharacter.apiUpdateCharSheet(charID, skills)
|
||||
except:
|
||||
continue
|
||||
|
||||
wx.CallAfter(self.callback)
|
||||
|
||||
class SkillBackupThread(threading.Thread):
|
||||
@@ -269,19 +290,18 @@ class Character(object):
|
||||
|
||||
sheet = auth.character(charID).CharacterSheet()
|
||||
|
||||
dbChar.apiUpdateCharSheet(sheet)
|
||||
dbChar.apiUpdateCharSheet(sheet.skills)
|
||||
eos.db.commit()
|
||||
|
||||
def apiUpdateCharSheet(self, charID, sheet):
|
||||
def apiUpdateCharSheet(self, charID, skills):
|
||||
char = eos.db.getCharacter(charID)
|
||||
char.apiUpdateCharSheet(sheet)
|
||||
char.apiUpdateCharSheet(skills)
|
||||
eos.db.commit()
|
||||
|
||||
def changeLevel(self, charID, skillID, level):
|
||||
char = eos.db.getCharacter(charID)
|
||||
skill = char.getSkill(skillID)
|
||||
if isinstance(level, basestring) or level > 5 or level < 0:
|
||||
skill.learned = False
|
||||
skill.level = None
|
||||
else:
|
||||
skill.level = level
|
||||
|
||||
@@ -36,7 +36,7 @@ from service.fleet import Fleet
|
||||
from service.settings import SettingsProvider
|
||||
from service.port import Port
|
||||
|
||||
logger = logging.getLogger("pyfa.service.fit")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class FitBackupThread(threading.Thread):
|
||||
def __init__(self, path, callback):
|
||||
@@ -175,10 +175,14 @@ class Fit(object):
|
||||
fit = eos.db.getFit(fitID)
|
||||
sFleet = Fleet.getInstance()
|
||||
sFleet.removeAssociatedFleetData(fit)
|
||||
self.removeProjectedData(fitID)
|
||||
|
||||
eos.db.remove(fit)
|
||||
|
||||
# refresh any fits this fit is projected onto. Otherwise, if we have
|
||||
# already loaded those fits, they will not reflect the changes
|
||||
for projection in fit.projectedOnto.values():
|
||||
eos.db.saveddata_session.refresh(projection.victim_fit)
|
||||
|
||||
def copyFit(self, fitID):
|
||||
fit = eos.db.getFit(fitID)
|
||||
newFit = copy.deepcopy(fit)
|
||||
@@ -193,14 +197,6 @@ class Fit(object):
|
||||
fit.clear()
|
||||
return fit
|
||||
|
||||
def removeProjectedData(self, fitID):
|
||||
"""Removes projection relation from ships that have fitID as projection. See GitHub issue #90"""
|
||||
fit = eos.db.getFit(fitID)
|
||||
fits = eos.db.getProjectedFits(fitID)
|
||||
|
||||
for projectee in fits:
|
||||
projectee.projectedFits.remove(fit)
|
||||
|
||||
def toggleFactorReload(self, fitID):
|
||||
if fitID is None:
|
||||
return None
|
||||
@@ -236,6 +232,7 @@ class Fit(object):
|
||||
return None
|
||||
fit = eos.db.getFit(fitID)
|
||||
inited = getattr(fit, "inited", None)
|
||||
|
||||
if inited is None or inited is False:
|
||||
sFleet = Fleet.getInstance()
|
||||
f = sFleet.getLinearFleet(fit)
|
||||
@@ -322,9 +319,14 @@ class Fit(object):
|
||||
eager=("attributes", "group.category"))
|
||||
|
||||
if isinstance(thing, eos.types.Fit):
|
||||
if thing.ID == fitID:
|
||||
if thing in fit.projectedFits:
|
||||
return
|
||||
fit.projectedFits.append(thing)
|
||||
|
||||
fit.__projectedFits[thing.ID] = thing
|
||||
|
||||
# this bit is required -- see GH issue # 83
|
||||
eos.db.saveddata_session.flush()
|
||||
eos.db.saveddata_session.refresh(thing)
|
||||
elif thing.category.name == "Drone":
|
||||
drone = None
|
||||
for d in fit.projectedDrones.find(thing):
|
||||
@@ -363,6 +365,21 @@ class Fit(object):
|
||||
thing.state = self.__getProposedState(thing, click)
|
||||
if not thing.canHaveState(thing.state, fit):
|
||||
thing.state = State.OFFLINE
|
||||
elif isinstance(thing, eos.types.Fit):
|
||||
projectionInfo = thing.getProjectionInfo(fitID)
|
||||
if projectionInfo:
|
||||
projectionInfo.active = not projectionInfo.active
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
|
||||
def changeAmount(self, fitID, projected_fit, amount):
|
||||
"""Change amount of projected fits"""
|
||||
fit = eos.db.getFit(fitID)
|
||||
amount = min(20, max(1, amount)) # 1 <= a <= 20
|
||||
projectionInfo = projected_fit.getProjectionInfo(fitID)
|
||||
if projectionInfo:
|
||||
projectionInfo.amount = amount
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
@@ -374,7 +391,8 @@ class Fit(object):
|
||||
elif isinstance(thing, eos.types.Module):
|
||||
fit.projectedModules.remove(thing)
|
||||
else:
|
||||
fit.projectedFits.remove(thing)
|
||||
del fit.__projectedFits[thing.ID]
|
||||
#fit.projectedFits.remove(thing)
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
@@ -921,8 +939,9 @@ class Fit(object):
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
|
||||
def recalc(self, fit, withBoosters=False):
|
||||
def recalc(self, fit, withBoosters=True):
|
||||
logger.debug("="*10+"recalc"+"="*10)
|
||||
if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]:
|
||||
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
|
||||
fit.clear()
|
||||
fit.calculateModifiedAttributes(withBoosters=withBoosters, dirtyStorage=self.dirtyFitIDs)
|
||||
fit.clear()
|
||||
fit.calculateModifiedAttributes(withBoosters=withBoosters)
|
||||
|
||||
@@ -425,7 +425,7 @@ class Port(object):
|
||||
return fits
|
||||
|
||||
@staticmethod
|
||||
def exportEft(fit):
|
||||
def _exportEftBase(fit):
|
||||
offineSuffix = " /OFFLINE"
|
||||
export = "[%s, %s]\n" % (fit.ship.item.name, fit.name)
|
||||
stuff = {}
|
||||
@@ -452,24 +452,40 @@ class Port(object):
|
||||
export += "\n\n"
|
||||
for drone in fit.drones:
|
||||
export += "%s x%s\n" % (drone.item.name, drone.amount)
|
||||
if len(fit.cargo) > 0:
|
||||
for cargo in fit.cargo:
|
||||
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
|
||||
|
||||
if export[-1] == "\n":
|
||||
export = export[:-1]
|
||||
|
||||
return export
|
||||
|
||||
@classmethod
|
||||
def exportEft(cls, fit):
|
||||
export = cls._exportEftBase(fit)
|
||||
|
||||
if len(fit.cargo) > 0:
|
||||
export += "\n\n\n"
|
||||
for cargo in fit.cargo:
|
||||
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
|
||||
if export[-1] == "\n":
|
||||
export = export[:-1]
|
||||
|
||||
return export
|
||||
|
||||
@classmethod
|
||||
def exportEftImps(cls, fit):
|
||||
export = cls.exportEft(fit)
|
||||
export = cls._exportEftBase(fit)
|
||||
|
||||
if len(fit.implants) > 0:
|
||||
export += "\n\n\n"
|
||||
for implant in fit.implants:
|
||||
export += "%s\n" % implant.item.name
|
||||
if export[-1] == "\n":
|
||||
export = export[:-1]
|
||||
|
||||
if len(fit.cargo) > 0:
|
||||
export += "\n\n\n"
|
||||
for cargo in fit.cargo:
|
||||
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
|
||||
if export[-1] == "\n":
|
||||
export = export[:-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user