Merge branch 'master' into ammo_graph

This commit is contained in:
DarkPhoenix
2019-11-25 13:56:16 +03:00
12 changed files with 74 additions and 17 deletions

View File

@@ -89,7 +89,7 @@ class BitmapLoader:
@classmethod
def loadBitmap(cls, name, location):
if cls.scaling_factor is None:
cls.scaling_factor = int(wx.GetApp().GetTopWindow().GetContentScaleFactor())
cls.scaling_factor = 1 if 'wxGTK' in wx.PlatformInfo else int(wx.GetApp().GetTopWindow().GetContentScaleFactor())
scale = cls.scaling_factor
filename, img = cls.loadScaledBitmap(name, location, scale)

View File

@@ -83,12 +83,12 @@ class MaxRange(ViewColumn):
lines.append('Missile flight range')
lowerRange, higherRange, higherChance = missileRangeData
if roundToPrec(higherChance, 3) not in (0, 1):
lines.append('{}% chance to fly {}'.format(
lines.append('{}% chance to fly {}m'.format(
formatAmount((1 - higherChance) * 100, prec=3, lowest=0, highest=0),
formatAmount(lowerRange, prec=3, lowest=0, highest=3, unitName='m')))
lines.append('{}% chance to fly {}'.format(
formatAmount(lowerRange, prec=3, lowest=0, highest=3)))
lines.append('{}% chance to fly {}m'.format(
formatAmount(higherChance * 100, prec=3, lowest=0, highest=0),
formatAmount(higherRange, prec=3, lowest=0, highest=3, unitName='m')))
formatAmount(higherRange, prec=3, lowest=0, highest=3)))
else:
lines.append("Optimal + Falloff")
return '\n'.join(lines)

View File

@@ -428,6 +428,31 @@ class SkillTreeView(wx.Panel):
# This cuases issues with GTK, see #1866
# self.Layout()
# For level keyboard shortcuts
self.ChangeLevelEvent, CHANGE_LEVEL_EVENT = wx.lib.newevent.NewEvent()
self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent)
self.Bind(CHANGE_LEVEL_EVENT, self.changeLevel)
def kbEvent(self, event):
keyLevelMap = {
# Regular number keys
48: 0, 49: 1, 50: 2, 51: 3, 52: 4, 53: 5,
# Numpad keys
wx.WXK_NUMPAD0: 0, wx.WXK_NUMPAD1: 1, wx.WXK_NUMPAD2: 2,
wx.WXK_NUMPAD3: 3, wx.WXK_NUMPAD4: 4, wx.WXK_NUMPAD5: 5}
keycode = event.GetKeyCode()
if keycode in keyLevelMap and event.GetModifiers() == wx.MOD_NONE:
level = keyLevelMap[keycode]
selection = self.skillTreeListCtrl.GetSelection()
if selection:
dataType, skillID = self.skillTreeListCtrl.GetItemData(selection)
if dataType == 'skill':
event = self.ChangeLevelEvent()
event.SetId(self.idLevels[level])
wx.PostEvent(self, event)
return
event.Skip()
def importSkills(self, evt):
with wx.MessageDialog(
@@ -611,6 +636,8 @@ class SkillTreeView(wx.Panel):
sChar = Character.getInstance()
char = self.charEditor.entityEditor.getActiveEntity()
if char.name in ("All 0", "All 5"):
return
selection = self.skillTreeListCtrl.GetSelection()
dataType, skillID = self.skillTreeListCtrl.GetItemData(selection)