Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _development/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ReadOnlyException(Exception):
return helper

# noinspection PyUnresolvedReferences,PyUnusedLocal
@pytest.fixture
@pytest.fixture(name='DB')
def DBInMemory():
print("Creating database in memory")

Expand Down
Binary file added eve.db
Binary file not shown.
20 changes: 20 additions & 0 deletions gui/ammoBreakdown/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================

from .frame import AmmoBreakdownFrame
160 changes: 160 additions & 0 deletions gui/ammoBreakdown/frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================

import csv
# noinspection PyPackageRequirements
import wx

import gui.globalEvents as GE
import gui.mainFrame
from gui.auxWindow import AuxiliaryFrame
from service.ammoBreakdown import get_ammo_breakdown
from service.fit import Fit

_t = wx.GetTranslation

COL_AMMO_NAME = 0
COL_DAMAGE_TYPE = 1
COL_OPTIMAL = 2
COL_FALLOFF = 3
COL_ALPHA = 4
COL_DPS = 5


class AmmoBreakdownFrame(AuxiliaryFrame):

def __init__(self, parent):
super().__init__(parent, title=_t('Ammo Breakdown'), size=(640, 400), resizeable=True)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self._data = []

mainSizer = wx.BoxSizer(wx.VERTICAL)

self.listCtrl = wx.ListCtrl(
self, wx.ID_ANY,
style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.BORDER_SUNKEN
)
self.listCtrl.AppendColumn(_t('Ammo Name'), wx.LIST_FORMAT_LEFT, 180)
self.listCtrl.AppendColumn(_t('Damage Type'), wx.LIST_FORMAT_LEFT, 110)
self.listCtrl.AppendColumn(_t('Optimal'), wx.LIST_FORMAT_LEFT, 120)
self.listCtrl.AppendColumn(_t('Falloff'), wx.LIST_FORMAT_LEFT, 120)
self.listCtrl.AppendColumn(_t('Alpha'), wx.LIST_FORMAT_RIGHT, 90)
self.listCtrl.AppendColumn(_t('DPS'), wx.LIST_FORMAT_RIGHT, 90)
mainSizer.Add(self.listCtrl, 1, wx.EXPAND | wx.ALL, 5)

self.emptyLabel = wx.StaticText(self, wx.ID_ANY, _t('No ammo in cargo usable by fitted weapons.'))
self.emptyLabel.Hide()
mainSizer.Add(self.emptyLabel, 0, wx.ALL, 10)

btnSizer = wx.BoxSizer(wx.HORIZONTAL)
self.exportBtn = wx.Button(self, wx.ID_ANY, _t('Export…'))
self.exportBtn.Bind(wx.EVT_BUTTON, self.OnExport)
btnSizer.Add(self.exportBtn, 0, wx.RIGHT, 5)
self.copyBtn = wx.Button(self, wx.ID_ANY, _t('Copy to clipboard'))
self.copyBtn.Bind(wx.EVT_BUTTON, self.OnCopyToClipboard)
btnSizer.Add(self.copyBtn, 0)
mainSizer.Add(btnSizer, 0, wx.ALL, 5)

self.SetSizer(mainSizer)

self.mainFrame.Bind(GE.FIT_CHANGED, self.OnFitChanged)
self.Bind(wx.EVT_CLOSE, self.OnClose)

self.refresh()

def _get_fit(self):
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return None
return Fit.getInstance().getFit(fitID)

def refresh(self):
fit = self._get_fit()
self._data = get_ammo_breakdown(fit) if fit else []
self.listCtrl.DeleteAllItems()
if not self._data:
self.listCtrl.Hide()
self.emptyLabel.Show()
self.exportBtn.Enable(False)
self.copyBtn.Enable(False)
else:
self.emptyLabel.Hide()
self.listCtrl.Show()
for row in self._data:
idx = self.listCtrl.InsertItem(self.listCtrl.GetItemCount(), row['ammoName'])
self.listCtrl.SetItem(idx, COL_DAMAGE_TYPE, row['damageType'])
self.listCtrl.SetItem(idx, COL_OPTIMAL, row['optimal'])
self.listCtrl.SetItem(idx, COL_FALLOFF, row['falloff'])
self.listCtrl.SetItem(idx, COL_ALPHA, '{:.1f}'.format(row['alpha']))
self.listCtrl.SetItem(idx, COL_DPS, '{:.1f}'.format(row['dps']))
self.exportBtn.Enable(True)
self.copyBtn.Enable(True)
self.Layout()

def OnFitChanged(self, event):
event.Skip()
self.refresh()

def OnClose(self, event):
self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.OnFitChanged)
event.Skip()

def _get_csv_content(self):
lines = []
lines.append([_t('Ammo Name'), _t('Damage Type'), _t('Optimal'), _t('Falloff'), _t('Alpha'), _t('DPS')])
for row in self._data:
lines.append([
row['ammoName'],
row['damageType'],
row['optimal'],
row['falloff'],
'{:.1f}'.format(row['alpha']),
'{:.1f}'.format(row['dps']),
])
return lines

def OnExport(self, event):
if not self._data:
return
fit = self._get_fit()
defaultFile = 'ammo_breakdown.csv'
if fit and fit.ship and fit.ship.item:
defaultFile = '{} - ammo_breakdown.csv'.format(fit.ship.item.name.replace('/', '-'))
with wx.FileDialog(
self, _t('Export ammo breakdown'), '', defaultFile,
_t('CSV files') + ' (*.csv)|*.csv', wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
) as dlg:
if dlg.ShowModal() != wx.ID_OK:
return
path = dlg.GetPath()
with open(path, 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f, delimiter=',')
for line in self._get_csv_content():
writer.writerow(line)
event.Skip()

def OnCopyToClipboard(self, event):
if not self._data:
return
lines = self._get_csv_content()
text = '\n'.join(','.join(str(c) for c in row) for row in lines)
if wx.TheClipboard.Open():
wx.TheClipboard.SetData(wx.TextDataObject(text))
wx.TheClipboard.Close()
event.Skip()
5 changes: 5 additions & 0 deletions gui/mainFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from eos.config import gamedata_date, gamedata_version
from eos.modifiedAttributeDict import ModifiedAttributeDict
from graphs import GraphFrame
from gui.ammoBreakdown import AmmoBreakdownFrame
from gui.additionsPane import AdditionsPane
from gui.bitmap_loader import BitmapLoader
from gui.builtinMarketBrowser.events import ItemSelected
Expand Down Expand Up @@ -434,6 +435,9 @@ def ShowAboutBox(self, evt):
def OnShowGraphFrame(self, event):
GraphFrame.openOne(self)

def OnShowAmmoBreakdownFrame(self, event):
AmmoBreakdownFrame.openOne(self)

def OnShowGraphFrameHidden(self, event):
GraphFrame.openOne(self, includeHidden=True)

Expand Down Expand Up @@ -566,6 +570,7 @@ def registerMenu(self):
# Graphs
self.Bind(wx.EVT_MENU, self.OnShowGraphFrame, id=menuBar.graphFrameId)
self.Bind(wx.EVT_MENU, self.OnShowGraphFrameHidden, id=self.hiddenGraphsId)
self.Bind(wx.EVT_MENU, self.OnShowAmmoBreakdownFrame, id=menuBar.ammoBreakdownFrameId)

toggleSearchBoxId = wx.NewId()
toggleShipMarketId = wx.NewId()
Expand Down
4 changes: 4 additions & 0 deletions gui/mainMenuBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, mainFrame):
self.targetProfileEditorId = wx.NewId()
self.implantSetEditorId = wx.NewId()
self.graphFrameId = wx.NewId()
self.ammoBreakdownFrameId = wx.NewId()
self.backupFitsId = wx.NewId()
self.exportSkillsNeededId = wx.NewId()
self.importCharacterId = wx.NewId()
Expand Down Expand Up @@ -93,6 +94,8 @@ def __init__(self, mainFrame):

fitMenu.AppendSeparator()
fitMenu.Append(self.optimizeFitPrice, _t("&Optimize Fit Price") + "\tCTRL+D")
fitMenu.Append(self.ammoBreakdownFrameId, _t("Ammo Break&down"), _t("Cargo ammo stats and export"))
self.Enable(self.ammoBreakdownFrameId, False)
graphFrameItem = wx.MenuItem(fitMenu, self.graphFrameId, _t("&Graphs") + "\tCTRL+G")
graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
fitMenu.Append(graphFrameItem)
Expand Down Expand Up @@ -191,6 +194,7 @@ def fitChanged(self, event):
self.Enable(self.revertCharId, char.isDirty)

self.Enable(self.toggleIgnoreRestrictionID, enable)
self.Enable(self.ammoBreakdownFrameId, enable)

if activeFitID:
sFit = Fit.getInstance()
Expand Down
48 changes: 48 additions & 0 deletions locale/lang.pot
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ msgstr ""
msgid "&Global"
msgstr ""

#: gui/mainMenuBar.py:97
msgid "Ammo Break&down"
msgstr ""

#: gui/mainMenuBar.py:97
msgid "Cargo ammo stats and export"
msgstr ""

#: gui/mainMenuBar.py:96
msgid "&Graphs"
msgstr ""
Expand Down Expand Up @@ -1756,6 +1764,46 @@ msgstr ""
msgid "Exporting skills needed..."
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Ammo Breakdown"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Ammo Name"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Optimal"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Falloff"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Alpha"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "DPS"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "No ammo in cargo usable by fitted weapons."
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Export…"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Copy to clipboard"
msgstr ""

#: gui/ammoBreakdown/frame.py
msgid "Export ammo breakdown"
msgstr ""

#: gui/builtinPreferenceViews/pyfaGeneralPreferences.py:160
msgid "Extra info in Additions panel tab names"
msgstr ""
Expand Down
Loading