Commits

dryatu mini  committed 0a3f194

Modified the binary creation script to create necessary build environment source fixes.

Removed some obsolete rageframe animation code.

  • Participants
  • Parent commits 5a0f9d6

Comments (0)

Files changed (2)

File FatxFast/gui/hud/rageframe.py

 from FatxFast.gui.boxwidget import BoxWidget
 from FatxFast.gui.textwidget import TextWidget
 from FatxFast.gui.hud.frame import Frame
-from FatxFast.objects.animation import Animation
 from FatxFast.objects.buffs import COFFEE_BUFF_ID
 from FatxFast.resource import resource_manager
 import pygame
     Base image for the progression bar has to be supplied."""
     def __init__(self, game, player, **kwargs):
         super(RageFrame, self).__init__(game, **kwargs)
-        self.animation = Animation("progressbar.png", 
-            tilewidth=self.rect.width,
-            tileheight=self.rect.height)
         self.player = player
         self.image = resource_manager.load_image("progressbar.png")
         self._buffcount = 0
     import glob, fnmatch
     import sys, os, shutil
     import operator
+    import re
 except ImportError, message:
     raise SystemExit,  "Unable to load module. %s" % message
  
         #Add font to list of extension to be copied
         extensions.append(Module("pygame.font", pygame_default_font))
         py2exe.build_exe.py2exe.copy_extensions(self, extensions)
- 
+
 class BuildExe:
     def __init__(self):
         #Name of starting .py
                         srcdir,
                         [os.path.basename(f) for f in glob.glob(self.opj(srcdir, '*'))])
         return file_list
- 
+
+    def _release_fix_main(self, line):
+        # Adds a pygame._view to the imports, fixes the pathing
+        line = re.sub(
+            "import pygame", "import pygame, pygame._view", line)
+        line = re.sub(
+            "os.path.abspath\(__file__\)", 
+            "os.path.abspath(sys.argv[0])", line)
+        return line
+
+    def _release_fix_resources(self, line):
+        # Fixes the rsc pathing problem for the binary file
+        line = re.sub(
+            "return os.path.join\(os.path.dirname\(__file__\), "+\
+                "\"rsc\", resource_name\)",
+            "return os.path.join(\"rsc\", resource_name)", line)
+        return line
+
+    def release_fix_bugs(self):
+        # Fixes the explicit binary generation releated source "bugs"
+        # File name : method for regexing the line, method returns regex'd line
+        # Does multiple regular expressions per method call
+        files_to_fix = {
+            self.script: self._release_fix_main,
+            "FatxFast/resource.py": self._release_fix_resources
+            }
+        for filename, method in files_to_fix.items():
+            with open(filename, 'r') as resources:
+                lines = resources.readlines()
+            with open(filename, 'w') as resources:
+                for line in lines:
+                    resources.write(method(line))
+
     def run(self):
+        self.release_fix_bugs()
         if os.path.isdir(self.dist_dir): #Erase previous destination dir
             shutil.rmtree(self.dist_dir)
         
         if os.path.isdir('build'): #Clean up build dir
             shutil.rmtree('build')
  
+        
+ 
 if __name__ == '__main__':
     if operator.lt(len(sys.argv), 2):
         sys.argv.append('py2exe')