Skip to content

Commit

Permalink
Fixed a bug with dynamic platoon creation/join.
Browse files Browse the repository at this point in the history
Removed unused imports.
Added PluginLoader source code.
  • Loading branch information
Tey committed May 19, 2016
1 parent 557e3a2 commit 04242d0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Python 2.7 (decompiled from Python 2.7)
# Embedded file name: PluginLoader.py
# Compiled at: 2015-07-15 18:55:47
import os
import imp
import sys
import importlib
import traceback
from plugins.Engine.ModUtils import FileUtils
from debug_utils import LOG_ERROR, LOG_CURRENT_EXCEPTION, LOG_DEBUG, LOG_NOTE, LOG_WARNING
PluginFolder = FileUtils.getRealPluginsPath()

def getPlugins():
plugins = []
sys.path.append(PluginFolder)
possibleplugins = os.listdir(PluginFolder)
for i in possibleplugins:
location = os.path.join(PluginFolder, i)
if not os.path.isdir(location) or i == 'Engine':
continue
plugins.append(i)

return plugins


def loadPlugin(i):
try:
module = __import__(i)
my_class = getattr(module, i.replace('_plugin', ''))
getattr(my_class, 'init')()
getattr(my_class, 'readConfig')()
if getattr(my_class, 'pluginEnable'):
print '---> Loading ' + i
getattr(my_class, 'run')()
except:
LOG_ERROR('plugin "' + i + '" contains errors!')
traceback.print_exc()


map(loadPlugin, getPlugins())
# okay decompiling PluginLoader.pyc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import SoundGroups
import BigWorld
import ResMgr
import GUI
from gui.Scaleform.Battle import Battle
# Importing gui.Scaleform.Battle breaks the dynamic platoon feature, so we use BattleWindow instead
from gui.Scaleform.windows import BattleWindow
from gui.shared import g_eventBus, events
from gui.app_loader.settings import APP_NAME_SPACE as _SPACE
from debug_utils import LOG_ERROR, LOG_CURRENT_EXCEPTION, LOG_DEBUG, LOG_NOTE
from debug_utils import LOG_DEBUG, LOG_NOTE
from functools import partial
from gui.shared.utils.HangarSpace import _HangarSpace
from gui import GUI_SETTINGS
import re
from plugins.Engine.ModUtils import BattleUtils,MinimapUtils,FileUtils,HotKeysUtils,DecorateUtils
from plugins.Engine.ModUtils import FileUtils,DecorateUtils
import subprocess
import threading
from CurrentVehicle import g_currentVehicle
Expand Down Expand Up @@ -101,10 +101,15 @@ def new_playSound2D(self, event):
old_playSound2D(self, event)

@staticmethod
def new_showSixthSenseIndicator(self, isShow):
if SixthSenseDuration.myConf['DisplayOriginalIcon'] or not isShow:
old_showSixthSenseIndicatorFromSixthSenseDuration(self, isShow)

def new_BattleWindow_call(self, methodName, args = None):
if methodName != 'sixthSenseIndicator.show':
old_BattleWindow_call(self, methodName, args)
return

isShow = args[0]
if SixthSenseDuration.myConf['DisplayOriginalIcon'] or not isShow:
old_BattleWindow_call(self, methodName, args)

SixthSenseDuration.initGuiSpotted()
SixthSenseDuration.initGuiUnspotted()
SixthSenseDuration.guiSpotted.visible = isShow
Expand Down Expand Up @@ -293,18 +298,18 @@ def run(cls):
cls.addEventHandler(SixthSenseDuration.myConf['reloadConfigKey'],cls.reloadConfig)
saveOldFuncs()
injectNewFuncs()

def saveOldFuncs():
global old_showSixthSenseIndicatorFromSixthSenseDuration,old_changeDoneFromSixthSenseDuration,old_playSound2D
DecorateUtils.ensureGlobalVarNotExist('old_showSixthSenseIndicatorFromSixthSenseDuration')
global old_BattleWindow_call,old_changeDoneFromSixthSenseDuration,old_playSound2D
DecorateUtils.ensureGlobalVarNotExist('old_BattleWindow_call')
DecorateUtils.ensureGlobalVarNotExist('old_changeDoneFromSixthSenseDuration')
DecorateUtils.ensureGlobalVarNotExist('old_playSound2D')
old_showSixthSenseIndicatorFromSixthSenseDuration = Battle._showSixthSenseIndicator
old_BattleWindow_call = BattleWindow.call
old_changeDoneFromSixthSenseDuration = _HangarSpace._HangarSpace__changeDone
old_playSound2D = SoundGroups.SoundGroups.playSound2D

def injectNewFuncs():
Battle._showSixthSenseIndicator = SixthSenseDuration.new_showSixthSenseIndicator
BattleWindow.call = SixthSenseDuration.new_BattleWindow_call
_HangarSpace._HangarSpace__changeDone = SixthSenseDuration.new_changeDone
SoundGroups.SoundGroups.playSound2D = SixthSenseDuration.new_playSound2D
add = g_eventBus.addListener
Expand Down

0 comments on commit 04242d0

Please sign in to comment.