Exemple #1
0
    def BuildToolbar(self):
        tb = wx.ToolBar(self)
        self.ToolBar = tb
        tb.SetToolBitmapSize((24,24))

        self.PointerTool = tb.AddRadioTool(wx.ID_ANY, bitmap=Resources.getPointerBitmap(), shortHelp = "Pointer")
        self.Bind(wx.EVT_TOOL, lambda evt : self.SetMode(Mode=self.GUIMouse), self.PointerTool)

        self.ZoomInTool = tb.AddRadioTool(wx.ID_ANY, bitmap=Resources.getMagPlusBitmap(), shortHelp = "Zoom In")
        self.Bind(wx.EVT_TOOL, lambda evt : self.SetMode(Mode=self.GUIZoomIn), self.ZoomInTool)
    
        self.ZoomOutTool = tb.AddRadioTool(wx.ID_ANY, bitmap=Resources.getMagMinusBitmap(), shortHelp = "Zoom Out")
        self.Bind(wx.EVT_TOOL, lambda evt : self.SetMode(Mode=self.GUIZoomOut), self.ZoomOutTool)

        self.MoveTool = tb.AddRadioTool(wx.ID_ANY, bitmap=Resources.getHandBitmap(), shortHelp = "Move")
        self.Bind(wx.EVT_TOOL, lambda evt : self.SetMode(Mode=self.GUIMove), self.MoveTool)

        tb.AddSeparator()

        self.ZoomButton = wx.Button(tb, label="Zoom To Fit")
        tb.AddControl(self.ZoomButton)
        self.ZoomButton.Bind(wx.EVT_BUTTON, self.ZoomToFit)

        tb.Realize()
        ## fixme: remove this when the bug is fixed!
        wx.CallAfter(self.HideShowHack) # this required on wxPython 2.8.3 on OS-X

        return tb
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 size=wx.DefaultSize,
                 **kwargs):  # The rest just get passed into FloatCanvas
        wx.Panel.__init__(self, parent, id, size=size)

        self.Modes = [
            ("Pointer", GUIMode.GUIMouse(), Resources.getPointerBitmap()),
            ("Zoom In", GUIMode.GUIZoomIn(), Resources.getMagPlusBitmap()),
            ("Zoom Out", GUIMode.GUIZoomOut(), Resources.getMagMinusBitmap()),
            ("Pan", GUIMode.GUIMove(), Resources.getHandBitmap()),
        ]

        self.BuildToolbar()
        ## Create the vertical sizer for the toolbar and Panel
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.ToolBar, 0, wx.ALL | wx.ALIGN_LEFT | wx.GROW, 4)

        self.Canvas = FloatCanvas.FloatCanvas(self, **kwargs)
        box.Add(self.Canvas, 1, wx.GROW)

        self.SetSizerAndFit(box)

        # default to first mode
        #self.ToolBar.ToggleTool(self.PointerTool.GetId(), True)
        self.Canvas.SetMode(self.Modes[0][1])

        return None
Exemple #3
0
    def __init__(
        self, parent, id=wx.ID_ANY, size=wx.DefaultSize, **kwargs
    ):  # The rest just get passed into FloatCanvas
        wx.Panel.__init__(self, parent, id, size=size)

        self.Modes = [
            ("Pointer", GUIMode.GUIMouse(), Resources.getPointerBitmap()),
            ("Zoom In", GUIMode.GUIZoomIn(), Resources.getMagPlusBitmap()),
            ("Zoom Out", GUIMode.GUIZoomOut(), Resources.getMagMinusBitmap()),
            ("Pan", GUIMode.GUIMove(), Resources.getHandBitmap()),
        ]

        self.BuildToolbar()
        ## Create the vertical sizer for the toolbar and Panel
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.ToolBar, 0, wx.ALL | wx.ALIGN_LEFT | wx.GROW, 4)

        self.Canvas = FloatCanvas.FloatCanvas(self, **kwargs)
        box.Add(self.Canvas, 1, wx.GROW)

        self.SetSizerAndFit(box)

        # default to first mode
        # self.ToolBar.ToggleTool(self.PointerTool.GetId(), True)
        self.Canvas.SetMode(self.Modes[0][1])

        return None
Exemple #4
0
def MergeTiles():
    ### STAGE 2 ###
    bsbScales = BsbScales(Resources.indir)
    sortList = bsbScales.getKapsSortedByScale(".zxy")
    for errorBsbFile in Resources.lstBsbErrorFiles:
        if sortList.__contains__(errorBsbFile + ".zxy"):
            sortList.remove(errorBsbFile + ".zxy")
    sortList.reverse()
    Resources.numChartsMerge = len(sortList)
    if Resources.numChartsMerge > 0:
        moPath = Resources.getTempDir() + "/mergeorder.txt"
        if os.path.isfile(moPath):
            os.remove(moPath)
        moFile = open(moPath, "w")
        for line in sortList:
            if os.path.isdir(Resources.getTempDir() + "/" + line):
                moFile.write(Resources.getTempDir() + "/" + line + "\n")
            else:
                pass
                #print "missing tileset: " + line
        moFile.close()
        
        Merge(Resources.getTempDir() + "/merge", moPath)
    
    if pleaseContinue:
        wx.PostEvent(app, InThreadEvent(advance=True))
Exemple #5
0
    def move(self):
        Resources.display()
        node = Resources.Node((self.row, Resources.BOARD))

        highest_val, best_move = search.search(node, self.row)
        print "%s moves" % self.name, best_move
        return do_move(best_move, self.row, Resources.BOARD)
    def compileMapSquareList(self, sq):
        if sq.guiData.has_key("listID"):
            glDeleteLists(sq.guiData["listID"], 1)

        textureNames = sq.texture()
        texIDt = Resources.texture(textureNames[0])
        sq.guiData["textureID"] = texIDt  # FIXME: update with the new amount of textures.

        texIDl = Resources.texture(textureNames[1])
        texIDb = Resources.texture(textureNames[2])
        texIDr = Resources.texture(textureNames[3])
        texIDf = Resources.texture(textureNames[4])

        textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]

        listID = glGenLists(1)
        sq.guiData["listID"] = listID
        glNewList(listID, GL_COMPILE)

        GLUtil.makeCube(
            sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight()
        )

        glEndList()

        topListID = glGenLists(1)
        sq.guiData["topListID"] = topListID
        glNewList(topListID, GL_COMPILE)
        GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
        glEndList()
Exemple #7
0
 def __init__(self,
              director,
              pausedScene,
              title='Warning!',
              message='Message',
              tooltip='Press here to continue'):
     Scene.__init__(self, director)
     self.bluredBackground = None
     self.b = 1
     self.pausedScene = pausedScene
     layer = Layer(director)
     backgroundImage = Resources.load_image("message_box.png")
     buttonImage = Resources.load_image("message_box_button.png")
     buttonWidth = 372
     style = MessageBox.createMessageBoxStyle(backgroundImage, buttonImage,
                                              buttonWidth)
     self.messageBox = MessageBox.MessageBox(
         self.director, (SCREEN_W / 2 - style['bg'].get_width() / 2,
                         SCREEN_H / 2 - style['bg'].get_height() / 2),
         style, True)
     self.messageBox.button.onMouseDown = lambda: self.popScene()
     self.messageBox.title = title
     self.messageBox.message = message
     self.messageBox.tooltip = tooltip
     layer.append(self.messageBox)
     self.layers.append(layer)
Exemple #8
0
def playTune(tuneName):
    """Plays a short tune. Returns whether it was actually played."""
    if _mixerInit and not _quiet:
        Resources.music(tuneName, loop=False)
        return True
    else:
        return False
Exemple #9
0
    def cancelHandler(self, event):
        if (event.attr1):
            print "Cancelling tasks and cleaning up... please wait."
            global pleaseContinue
            pleaseContinue = False
            if platform.system() == "Windows":
                self.Hide()
#            if platform.system() == "Linux":
#                msgDialog = GUI.Message2(None)
#                msgDialog.msg_staticText.SetLabel("Cleaning up... please wait.")
#                msgDialog.Show()
            
            for thread in enumerate():
                if thread.getName() != "MainThread":
                    if thread.isAlive():
                        #print "Joining thread: " + thread.getName()
                        thread.join()
            
            if os.path.isdir(Resources.getTempDir()):
                #print "Removing temporary directory", os.path.abspath(Resources.getTempDir())
                shutil.rmtree(os.path.abspath(Resources.getTempDir()))
                    
#            if platform.system() == "Linux":
#                msgDialog.Destroy()
                
            self.Destroy()
            blankParent.Destroy()
Exemple #10
0
 def setScenario(self, campaign, scenario):
     # FIXME SECURITY: scenarios and campaigns should only be a
     # simple string; for security reasons we need to make sure
     # they don't contain weird characters like "..", "/", or "."
     Resources.setCampaign(campaign)
     self.scenario = Resources.scenario(scenario)
     self.scenario.numPlayers = 2  # FIXME: should be defined by the scenario
Exemple #11
0
def playTune(tuneName):
    """Plays a short tune. Returns whether it was actually played."""
    if _mixerInit and not _quiet:
        Resources.music(tuneName, loop=False)
        return True
    else:
        return False
Exemple #12
0
	def __init__(self):
		screenWidth = 1000
		screenHeight = 600

		pygame.init()
		if(Resources.getOptionValue("fullscreen") == 1):
			pygame.display.set_mode((screenWidth, screenHeight), FULLSCREEN)
		else:
			pygame.display.set_mode((screenWidth, screenHeight))
		pygame.display.set_caption("Bump'N'Jump")

		pygame.mixer.music.load("resources/sound/music.wav")
		pygame.mixer.music.set_volume(float(Resources.getOptionValue("music"))/100)
		pygame.mixer.music.play(-1)

		currentScene = MainMenu()

		clock = pygame.time.Clock()

		game = True

		while game:
			game, currentScene = currentScene.update()

			clock.tick(60)
    def compileMapSquareList(self, sq):
        if sq.guiData.has_key("listID"):
            glDeleteLists(sq.guiData["listID"], 1)

        textureNames = sq.texture()
        texIDt = Resources.texture(textureNames[0])
        sq.guiData['textureID'] = texIDt #fix me: update with the new amount of textures.
        
        texIDl = Resources.texture(textureNames[1])
        texIDb = Resources.texture(textureNames[2])
        texIDr = Resources.texture(textureNames[3])
        texIDf = Resources.texture(textureNames[4])
        
        textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]
        
        listID = glGenLists(1)
        sq.guiData["listID"] = listID
        glNewList(listID, GL_COMPILE)

        GLUtil.makeCube(sq.z, sq.cornerHeights,
                        textureIDs, sq.cornerColors, sq.waterHeight,
                        sq.waterColor, sq.minHeight())
        #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        #glLineWidth(0.75)
        #GLUtil.makeCube(sq.z, (0.0,0.0,0.0,1.0), sq.cornerHeights, False)
        #glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        glEndList()

        topListID = glGenLists(1)
        sq.guiData['topListID'] = topListID
        glNewList(topListID, GL_COMPILE)
        GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
        glEndList()
Exemple #14
0
    def BuildToolbar(self):
        tb = wx.ToolBar(self,-1)
        self.ToolBar = tb
        
        tb.SetToolBitmapSize((24,24))
        
        tb.AddTool(ID_POINTER_BUTTON, Resources.getPointerBitmap(), isToggle=True, shortHelpString = "Pointer")
        wx.EVT_TOOL(self, ID_POINTER_BUTTON, self.SetToolMode)

        tb.AddTool(ID_ZOOM_IN_BUTTON, Resources.getMagPlusBitmap(), isToggle=True, shortHelpString = "Zoom In")
        wx.EVT_TOOL(self, ID_ZOOM_IN_BUTTON, self.SetToolMode)
        
        tb.AddTool(ID_ZOOM_OUT_BUTTON, Resources.getMagMinusBitmap(), isToggle=True, shortHelpString = "Zoom Out")
        wx.EVT_TOOL(self, ID_ZOOM_OUT_BUTTON, self.SetToolMode)
        
        tb.AddTool(ID_MOVE_MODE_BUTTON, Resources.getHandBitmap(), isToggle=True, shortHelpString = "Move")
        wx.EVT_TOOL(self, ID_MOVE_MODE_BUTTON, self.SetToolMode)
        
        tb.AddSeparator()
        
        tb.AddControl(wx.Button(tb, ID_ZOOM_TO_FIT_BUTTON, "Zoom To Fit",wx.DefaultPosition, wx.DefaultSize))
        wx.EVT_BUTTON(self, ID_ZOOM_TO_FIT_BUTTON, self.ZoomToFit)

        tb.Realize()
        S = tb.GetSize()
        tb.SetSizeHints(S[0],S[1])
        return tb
Exemple #15
0
    def compileMapSquareList(self, sq):
        if sq.guiData.has_key("listID"):
            glDeleteLists(sq.guiData["listID"], 1)

        textureNames = sq.texture()
        texIDt = Resources.texture(textureNames[0])
        sq.guiData[
            'textureID'] = texIDt  #fix me: update with the new amount of textures.

        texIDl = Resources.texture(textureNames[1])
        texIDb = Resources.texture(textureNames[2])
        texIDr = Resources.texture(textureNames[3])
        texIDf = Resources.texture(textureNames[4])

        textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]

        listID = glGenLists(1)
        sq.guiData["listID"] = listID
        glNewList(listID, GL_COMPILE)

        GLUtil.makeCube(sq.z, sq.cornerHeights, textureIDs, sq.cornerColors,
                        sq.waterHeight, sq.waterColor, sq.minHeight())
        #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        #glLineWidth(0.75)
        #GLUtil.makeCube(sq.z, (0.0,0.0,0.0,1.0), sq.cornerHeights, False)
        #glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        glEndList()

        topListID = glGenLists(1)
        sq.guiData['topListID'] = topListID
        glNewList(topListID, GL_COMPILE)
        GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
        glEndList()
Exemple #16
0
    def __init__(self, posn, width, nOptions):
        self.displayers = []
        self.options = []
        self.enabledOptions = []
        self.posn = posn
        for i in xrange(nOptions):
            td = TextDisplayer()
            td.setText("")
            td.setFont(Resources.font(size=16, bold=True))
            self.displayers.append(td)
        self.box = TextDisplayerBox(self.displayers,
                                    posn,
                                    width,
                                    nOptions)
        self.selectedOption = 0
        self._showing = False

        (textureID,
         image,
         renderedSize) = GLUtil.renderTextToTexture(Resources.font(size=16,
                                                                   bold=True),
                                                    (255,255,255,255),
                                                    ">",
                                                    False,
                                                    None)
        self.cursorImage = image
        self.cursorTexture = textureID
    def findMinerals(self, agent):
        mineralPrioList = []
        pos = agent.getPos()
        # Add all ores in the world and sort by closeness to spawn
        for ore in Resources.mineralLeft:
            if FogOfWar.fogOfWar[ore[0]][ore[1]]:
                mineralPrioList.append(
                    (ore[0], ore[1],
                     abs(ore[0] - pos[0]) + abs(ore[1] - pos[1])))
        mineralPrioList.sort(key=lambda x: x[2])

        # If agent has no path, go to closest found ore
        if not agent.getPath() and mineralPrioList:
            agent.setPath(
                Pathfinder.findPath(
                    agent, (mineralPrioList[0][0], mineralPrioList[0][1])))
            Resources.mineralFound(
                (mineralPrioList[0][0], mineralPrioList[0][1]))

        elif agent.getPath():
            self.move(agent, pos)

            if Resources.gatherMinerals(agent):
                agent.setTimer(time.time())
                agent.setState(returnHome())
Exemple #18
0
    def compileMapSquareList(self, sq):
        if sq.guiData.has_key("listID"):
            glDeleteLists(sq.guiData["listID"], 1)

          
        textureNames = sq.texture()
        texIDt = Resources.texture(textureNames[0])
        sq.guiData['textureID'] = texIDt # FIXME: update with the new amount of textures.
        
        texIDl = Resources.texture(textureNames[1])
        texIDb = Resources.texture(textureNames[2])
        texIDr = Resources.texture(textureNames[3])
        texIDf = Resources.texture(textureNames[4])
        
        textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]
		
        listID = glGenLists(1)
        sq.guiData["listID"] = listID
        glNewList(listID, GL_COMPILE)

        GLUtil.makeCube(sq.z, sq.cornerHeights,
                        textureIDs, sq.cornerColors, sq.waterHeight,
                        sq.waterColor, sq.minHeight())

        glEndList()

        topListID = glGenLists(1)
        sq.guiData['topListID'] = topListID
        glNewList(topListID, GL_COMPILE)
        GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
        glEndList()
Exemple #19
0
def runMapEditor(main, mapName):
    """Run the map editor.

    Arguments:

        main - A MainWindow classobj, this is the main window context.
        mapName - A string containing the name of the map to edit.
    """
    import gui.MapEditorGUI
    import Resources

    Resources.map = Resources.MapLoader()
    if mapName != None:
        #        try:
        m = Resources.map(mapName)


#        except Exception, e:
#            print 'Error loading map "%s":' % mapName
#            print e
#            sys.exit(1)
    else:
        m = Resources.map('random')

    # Start the map editor GUI
    mapEditorGUI = gui.MapEditorGUI.MapEditorGUI(m)
    main.setDelegate(mapEditorGUI)
Exemple #20
0
def rebokMembership(m):
    bot.send_document(m.chat.id,
                      Resources.doc["rebokGuide"],
                      caption=Resources.rebok(0))
    bot.send_document(m.chat.id,
                      Resources.doc["rebokFAQ"],
                      caption=Resources.rebok(1))
    bot.send_message(m.chat.id, Resources.rebok(2))
Exemple #21
0
    def __init__(self):
        GameSceneBase.__init__(self)

        self._header_font = Resources.GetFont(255, 0, 0)
        self._font = Resources.GetFont(255, 255, 255)
        self._start_time = time.time()
        self._tick = -1
        self._lineup = _lineup()
        self._blacks = pygame.Surface((220, 310))
Exemple #22
0
def MakeTiles():
    ### STAGE 1 ###
    
    for kapPath in Resources.lstBsbFiles:
        if pleaseContinue:
            
            #we need to wait for this process to finish before moving on
            kapToVrtProc = Process(target=KapToVrt, args=(kapPath,))
            kapToVrtProc.start()
            while kapToVrtProc.is_alive():
                sleep(.1)
            
            vrtPath = kapPath[0:-4] + ".vrt"
            #print vrtPath
            if os.path.isfile(vrtPath):
                
                zxyFullPath = Resources.getTempDir() + "/" + kapPath.split("/")[-1][0:-4] + ".zxy/"
                tileError = True
                
                try:
                    vrtToTilesProc = Process(target=VrtToTiles, args=(Resources.getTempDir(), vrtPath, FindZoom.getKapZoom(kapPath),))
                    vrtToTilesProc.start()
                    while vrtToTilesProc.is_alive():
                        sleep(.1)
                    if os.path.isdir(zxyFullPath):
        #                    if len(os.listdir(zxyFullPath)) > 0:
        #                        tileError = False
                        for subDir in os.listdir(zxyFullPath):
                            if os.path.isdir(zxyFullPath + subDir):
                                tileError = False
                except:
                    pass
                    print "VrtToTiles failed!"
                    
                if tileError:
                        print "ERROR gdal_tiler failed processing chart: ", kapPath.split("/")[-1]
                        Resources.lstBsbErrorFiles.append(kapPath.split("/")[-1][0:-4]) 
                ###
                
                os.remove(vrtPath) #clean up vrt files
            else:
                ###map2gdal failed because there is no vrt file...
                print vrtPath
                print "ERROR map2gdal failed processing chart: ", kapPath.split("/")[-1]
                Resources.lstBsbErrorFiles.append(kapPath.split("/")[-1][0:-4])
            
            
#            mp = Process(target=TileMap, args=(kapPath, parent.currentChart, resourcePipeB, signalPipeA))
#            mp.start()
            
            #Event is bound to Step4.nextStage(self, event)
            wx.PostEvent(app, InThreadEvent(advance=False))
    
    #posting this event signals to parent window that the task is finished
    if pleaseContinue:
        #Event is bound to Step4.nextStage(self, event)
        wx.PostEvent(app, InThreadEvent(advance=True))
 def __init__(self, color, messages, playScene):
     GameSceneBase.__init__(self)
     self.playScene = playScene
     self.font = Resources.GetFont(color[0], color[1], color[2])
     self.messages = messages
     self.border = Resources.CreateBorder(400, len(messages) * 20 + 60)
     self.x = (640 - self.border.get_width()) // 2
     self.y = 50
     self.close_x = self.x + self.border.get_width() - 24
     self.close_y = self.y + 24
Exemple #24
0
def _load():
    global _maleNames, _femaleNames, _neuterNames, _loaded
    _loaded = True
    _maleNames = Resources.text("names-male")
    _femaleNames = Resources.text("names-female")
    # FIXME: maintain a neuter file at some point
    _neuterNames = Resources.text("names-male")
    for n in [_maleNames, _femaleNames, _neuterNames]:
        for i in xrange(0, len(n)):
            n[i] = n[i].strip()
Exemple #25
0
 def _evtFinish(self, event):
     self.Hide()
     
     if os.path.isdir( os.path.abspath(Resources.getTempDir()) ):
         print "Cleaning up temporary directory: ", os.path.abspath(Resources.getTempDir())
         print "Please wait..."
         shutil.rmtree(os.path.abspath(Resources.getTempDir()))
     print "complete, bye now :)"
     self.Destroy()
     blankParent.Destroy()
Exemple #26
0
def moduleRegGuide(m):
    bot.send_photo(m.chat.id,
                   Resources.doc["modTimeflow"],
                   caption=Resources.modReg(0))
    bot.send_document(m.chat.id,
                      Resources.doc["modCalendar"],
                      caption=Resources.modReg(1))
    bot.send_document(m.chat.id,
                      Resources.doc["modRegGuide"],
                      caption=Resources.modReg(2))
Exemple #27
0
 def __init__(self, name):
     if name is "":
         name = "Forge"
     Room.__init__(self, name, RoomType.Forge)
     self.craft_list = Resources.get_many_by_type(
         'Weapon', requires_being_craftable=True)
     self.craft_list.update(
         Resources.get_many_by_type('Armor', requires_being_craftable=True))
     self.craft_list.update(
         Resources.get_many_by_type('Appearance',
                                    requires_being_craftable=True))
Exemple #28
0
 def pushH(self,prog_id):
     
     # define where and what 
     h_file_descriptor = os.path.join(self.get_local_solutions_dir(),'h*.[0-9][0-9][0-9][0-9][0-9]*');
     
     # query for file listing
     h_file_list = glob.glob(h_file_descriptor); 
     
     # push each snx file
     for h_file in h_file_list:
         print "pushing hfile: ",h_file
         Resources.pushSNX(self.get_solution_bucket(prog_id), h_file);
Exemple #29
0
 def pushZND(self,prog_id):
     
     # define where and what 
     file_descriptor = os.path.join(self.get_local_solutions_dir(),'*.znd*');
     
     # query for file listing
     file_list = glob.glob(file_descriptor); 
     
     # push each snx file
     for file in file_list:
         print "pushing znd file: ",file
         Resources.pushSNX(self.get_solution_bucket(prog_id), file);
    def __init__(self):
        Game.GameSceneBase.__init__(self)
        self._fontof = Resources.GetFont(220, 220, 255)
        self._fontw = Resources.GetFont(255, 255, 255)
        self._fontr = Resources.GetFont(255, 0, 0)
        self._fonty = Resources.GetFont(255, 255, 0)
        self._fontg = Resources.GetFont(0, 255, 0)
        self._counter = 0

        self._advance = None

        pygame.mixer.music.stop()
Exemple #31
0
	def resetColor(self, color):
		self.arrAnim = []
		for i in range(0, self.nbFrames):
			if i + 1 < 10:
				self.arrAnim.append(Resources.loadPNG(self.imageName + "000" + str(i + 1) + ".png", True))
			elif i + 1 < 100:
				self.arrAnim.append(Resources.loadPNG(self.imageName + "00" + str(i + 1) + ".png", True))
			else:
				self.arrAnim.append(Resources.loadPNG(self.imageName + "0" + str(i + 1) + ".png", True))

		for img in self.arrAnim:
			img[0].fill(color, special_flags = BLEND_MULT)
Exemple #32
0
    def pushZND(self, prog_id):

        # define where and what
        file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                       '*.znd*')

        # query for file listing
        file_list = glob.glob(file_descriptor)

        # push each snx file
        for file in file_list:
            print "pushing znd file: ", file
            Resources.pushSNX(self.get_solution_bucket(prog_id), file)
Exemple #33
0
    def pushH(self, prog_id):

        # define where and what
        h_file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                         'h*.[0-9][0-9][0-9][0-9][0-9]*')

        # query for file listing
        h_file_list = glob.glob(h_file_descriptor)

        # push each snx file
        for h_file in h_file_list:
            print "pushing hfile: ", h_file
            Resources.pushSNX(self.get_solution_bucket(prog_id), h_file)
Exemple #34
0
    def pushOUT(self, prog_id):

        # define where and what
        out_file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                           '*.out*')

        # query for file listing
        out_file_list = glob.glob(out_file_descriptor)

        # push each out file
        for out_file in out_file_list:
            #print "pushing out file: ",out_file
            Resources.pushSNX(self.get_solution_bucket(prog_id), out_file)
Exemple #35
0
    def move(self):
        b = Resources.BOARD
        s = Resources.BOARD_SIZE
        if not any(Resources.BOARD[self.row*s+1:(self.row+1)*s-1]):
            print "%s's row is empty. giving turn to next player" % self.name
            return (self.row+1)%Resources.NUM_PLAYERS, None
        
        Resources.display()
        node = Resources.Node((self.row, Resources.BOARD))

        highest_val, best_move = search.search(node, self)
        print '%s moves' % self.name, best_move
        return do_move(best_move, self.row, Resources.BOARD)
Exemple #36
0
    def pushSNX(self, prog_id):

        # define where and what
        snx_file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                           '*snx*')

        # query for file listing
        snx_file_list = glob.glob(snx_file_descriptor)

        # push each snx file
        for snx_file in snx_file_list:
            print "pushing solution: ", snx_file
            Resources.pushSNX(self.get_solution_bucket(prog_id), snx_file)
Exemple #37
0
    def pushSP3(self):

        # define where and what
        sp3_file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                           '*.sp3*')

        # query for file listing
        sp3_file_list = glob.glob(sp3_file_descriptor)

        # push each out file
        for sp3_file in sp3_file_list:
            #print "pushing sp3 file: ",sp3_file
            Resources.pushSP3(sp3_file)
Exemple #38
0
def ConcatTiles():
    ### STAGE 4 ###
    if Resources.numChartsMerge > 0:
        directory = Resources.getTempDir() + "/gemf"
        if not os.path.isdir(directory):
            os.mkdir(directory)
        shutil.move(Resources.getTempDir() + "/merge", directory)
        
        GemfBuilder( (directory,) )
        shutil.move(directory + "/map_data.gemf", Resources.outdir + "/" + Resources.name + ".gemf")
    
    if pleaseContinue:
        wx.PostEvent(app, InThreadEvent(advance=True))
    def __init__(self):
        if "wxMac" in wx.PlatformInfo:  # use 16X16 cursors for wxMac
            self.HandCursor = wx.CursorFromImage(Resources.getHand16Image())
            self.GrabHandCursor = wx.CursorFromImage(
                Resources.getGrabHand16Image())

            img = Resources.getMagPlus16Image()
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 6)
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 6)
            self.MagPlusCursor = wx.CursorFromImage(img)

            img = Resources.getMagMinus16Image()
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 6)
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 6)
            self.MagMinusCursor = wx.CursorFromImage(img)
        else:  # use 24X24 cursors for GTK and Windows
            self.HandCursor = wx.CursorFromImage(Resources.getHandImage())
            self.GrabHandCursor = wx.CursorFromImage(
                Resources.getGrabHandImage())

            img = Resources.getMagPlusImage()
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 9)
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 9)
            self.MagPlusCursor = wx.CursorFromImage(img)

            img = Resources.getMagMinusImage()
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 9)
            img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 9)
            self.MagMinusCursor = wx.CursorFromImage(img)
Exemple #40
0
 def __init__(self):
     if "wxMac" in wx.PlatformInfo: # use 16X16 cursors for wxMac
         self.HandCursor = wx.CursorFromImage(Resources.getHand16Image())
         self.GrabHandCursor = wx.CursorFromImage(Resources.getGrabHand16Image())
     
         img = Resources.getMagPlus16Image()
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 6)
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 6)
         self.MagPlusCursor = wx.CursorFromImage(img)
     
         img = Resources.getMagMinus16Image()
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 6)
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 6)
         self.MagMinusCursor = wx.CursorFromImage(img)
     else: # use 24X24 cursors for GTK and Windows
         self.HandCursor = wx.CursorFromImage(Resources.getHandImage())
         self.GrabHandCursor = wx.CursorFromImage(Resources.getGrabHandImage())
     
         img = Resources.getMagPlusImage()
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 9)
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 9)
         self.MagPlusCursor = wx.CursorFromImage(img)
     
         img = Resources.getMagMinusImage()
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 9)
         img.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 9)
         self.MagMinusCursor = wx.CursorFromImage(img)
Exemple #41
0
 def pushSp3Local(self,prog_id):
     
     #put a copy of the sp3 file in the solution directory
     
     # define where and what 
     file_descriptor = os.path.join(self.get_local_solutions_dir(),'*.sp3*');
     
     # query for file listing
     file_list = glob.glob(file_descriptor); 
     
     # push each snx file
     for file in file_list:
         print "pushing sp3 file: ",file
         Resources.pushSNX(self.get_solution_bucket(prog_id), file);
    def __init__(self):
        GameSceneBase.__init__(self)
        pygame.mixer.music.stop()
        self.whitefont = Resources.GetFont(255, 255, 255)
        self.yellowfont = Resources.GetFont(255, 255, 0)
        self._font = Resources.TTF_Font('Kallamar/KALLAMAR.TTF', 28)

        self.counter = 0
        pygame.mixer.music.stop()
        self._story_r = None
        self._custom_r = None
        self._intro_r = None
        self._credits_r = None
        self._quit_r = None
        self._hover = NONE
Exemple #43
0
    def pushSp3Local(self, prog_id):

        #put a copy of the sp3 file in the solution directory

        # define where and what
        file_descriptor = os.path.join(self.get_local_solutions_dir(),
                                       '*.sp3*')

        # query for file listing
        file_list = glob.glob(file_descriptor)

        # push each snx file
        for file in file_list:
            print "pushing sp3 file: ", file
            Resources.pushSNX(self.get_solution_bucket(prog_id), file)
Exemple #44
0
 def __init__(self, director, position, visible, player=None):
     bgStyle = createHUDStyle(Resources.load_image("HUD_bg.png"))
     Container.__init__(self, director, position, bgStyle, visible)
     buttonImage = Resources.load_image("active_button.png")
     objectImage = pygame.Surface((2, 2))
     activeButtonStyle = ContainerButton.createContainerButtonStyle(buttonImage, objectImage, 78)
     self.leftButton = ImageButton.ImageButton(self.director, (180, 15), activeButtonStyle)
     self.rightButton = ImageButton.ImageButton(self.director, (542, 15), activeButtonStyle)
     Container.addWidget(self, self.leftButton)
     Container.addWidget(self, self.rightButton)
     self.hidden = True
     self.player = player
     self.originalPosition = self.position
     self.lastEvent = None
     self.newEvent = False
	def __init__(self, server = False):
		self.screen = pygame.display.get_surface()

		self.server = server

		self.background = pygame.Surface(self.screen.get_size())
		self.background = self.background.convert()
		self.background.fill((50, 50, 50))

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.sliders = {}

		self.sliders["red"] = Slider(self.screen.get_width()/2 - 200/2, 100, 200, 200, 255)
		self.sliders["green"] = Slider(self.screen.get_width()/2 - 200/2, 150, 200, 50, 255)
		self.sliders["blue"] = Slider(self.screen.get_width()/2 - 200/2, 200, 200, 50, 255)

		self.currentSlider = None

		self.rabbit1 = Animation("rabbit", 30)
		self.rabbit1.updateColor((self.sliders["red"].getValue(), self.sliders["green"].getValue(), self.sliders["blue"].getValue()))
		self.rabbit1.setFrameRange(1, 8);
		self.rabbit1.flipAnim()
		self.rabbit1.setPos(self.screen.get_width()/2 - 21, 300)
		self.rabbit1Sprite = pygame.sprite.RenderPlain(self.rabbit1)

		self.buttons = {}

		self.buttons["play"] = Button(self.screen.get_width() - self.screen.get_width()/4 - 200/2, 450, 200, 40, "PLAY")
		self.buttons["back"] = Button(self.screen.get_width()/4 - 200/2, 450, 200, 40, "BACK")

		pygame.display.flip()
Exemple #46
0
    def __init__(self, fullscreen, width):
        """Initializes the main window."""
        global _mainWindow
        _mainWindow = self

        self._input = Input.Input(0)

        self._limitFPS = True

        self._fullscreen = fullscreen
        self._fullscreenSize = self._chooseDisplaySize()
        self._defaultSize = (width, width*3/4)

        if fullscreen:
            self._size = self._fullscreenSize
        else:
            self._size = self._defaultSize
        
        self._fpsDisplayer = Sprite.FPSDisplayer()
        self._delegate = None
        self._soundEnabled = True

        pygame.display.set_icon(Resources.image("icon-32"))
        self._setDisplayMode()
        self._resize()
        self._initOpenGL()

        if self._fullscreen:
            pygame.mouse.set_pos((0, 0))
Exemple #47
0
	def __init__(self, level):
		self.screen = pygame.display.get_surface()

		self.background = pygame.Surface(self.screen.get_size())
		self.background = self.background.convert()
		self.background.fill((50, 50, 50))

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.level = level

		self.buttons = {}

		pos = 25

		for f in glob.glob("save/maps/*.mabbit"):
			name = f.split("\\")[-1].split(".")[0]

			if(name != "last"):
				self.buttons[name] = Button(self.screen.get_width()/2 - 200/2, pos, 200, 40, name.upper())

				pos +=100

		self.buttons["new"] = Button(self.screen.get_width()/2 - 200/2, pos, 200, 40, "NEW")
		self.buttons["back"] = Button(self.screen.get_width()/2 - 200/2, pos + 100, 200, 40, "BACK")

		pygame.display.flip()
Exemple #48
0
    def __init__(self, text, font, size, color, x, y, center=False):
        self.font = Resources.load_font(font, size)
        self.color = color
        self.text = text

        img = Text.make_img(self.font, text, color)
        super().__init__(img, x, y, center)
Exemple #49
0
 def generateMapAndUnits():
     map_ = Resources.map('random')
     units = []
     nUnits = random.randint(4, 8)
     startColumn = random.randint(0, map_.width - (nUnits + 1) / 2)
     for i in xrange(0, nUnits):
         u = generateUnit(PLAYER_FACTION)
         if i < nUnits / 2:
             row = map_.height-1
             column = startColumn + i
         else:
             row = map_.height-2
             column = startColumn + (i - nUnits/2)
         map_.squares[column][row].setUnit(u)
         units.append(u)
     nUnits += additionalAIUnits
     startColumn = random.randint(0, map_.width - (nUnits + 1) / 2)
     for i in xrange(0, nUnits):
         u = generateUnit(NPC_HOSTILE_FACTION)
         if i < nUnits / 2:
             row = 0
             column = startColumn + i
         else:
             row = 1
             column = startColumn + (i - nUnits/2)
         map_.squares[column][row].setUnit(u)
         units.append(u)
     return (map_, units)
Exemple #50
0
 def MakeText(self, color, text):
     global _useFancyRender
     if _useFancyRender:
         return FancyRender(text, color)
     else:
         font = Resources.GetFont(color[0], color[1], color[2])
         return font.Render(text).convert_alpha()
Exemple #51
0
 def login(self):
     # Method will validate the input username and password from password stored in file.
     Logger.info(MSG_INFO_LOGIN_MESSAGE)
     while not self.logged_in:
         user_input = input(STR_INPUT_USERNAME + STR_SUFFIX)
         if user_input is None or len(user_input) == 0:
             exit()
         pass_input = getpass.getpass(STR_INPUT_PASSWD + STR_SUFFIX)
         if user_input is None or pass_input is None or len(user_input) == 0 or len(pass_input) == 0:
             Logger.warn(MSG_ERR_INVALID_INPUT)
         elif user_input not in self.passwdDict.keys():
             # user not exist
             Logger.warn(MSG_ERR_USER_NOT_EXIST)
         elif self.passwdDict[user_input].get(KEY_AWS_PASSWORD) != pass_input:
             # password incorrect
             Logger.warn(MSG_ERR_INCORRECT_PASSWORD)
         else:
             self.username = user_input
             self.logged_in = True
             self.aws_res = Resources.Resource(AWS_REGION, self.passwdDict[self.username].get(KEY_AWS_KEY),
                                               self.passwdDict[self.username].get(KEY_AWS_SECRET))
             self.ec2_res = self.aws_res.ec2_resource()
             # set ec2 resource
             self.s3_res = self.aws_res.s3_resource()
             # set S3 resource
             self.cw_client = self.aws_res.cw_client()
             # set cloud watch client
             self.ec2_client = self.aws_res.ec2_client()
             # set ec2 client
             self.sns_client = self.aws_res.sns_client()
             # set sns client
             self.rds_client = self.aws_res.rds_client()
             # set rds client
             Logger.info(MSG_INFO_LOGGED_IN_MESSAGE)
             self.main_menu.open()
Exemple #52
0
	def __init__(self, server, color, levelPreset = "empty"):
		self.server = server

		self.butterflies = []

		self.screen = pygame.display.get_surface()

		self.backgroundImage, self.backgroundRect = loadPNG("background.png")

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.active = True

		if levelPreset == "empty":
			self.level = Map()
		else:
			self.level = Map(True)

		self.toolbar = GameToolbar()

		self.regis = Rabbit(1, "regis" , color, self.level.objectList, self.level.objectSpritesList)

		self.server.accept()
		self.server.send(b"connexion avec client : OK")
		msg = self.server.recieve()

		mapStr = self.level.getMapStr()

		#MAP STRING SEND
		self.server.send(struct.pack(str(len(mapStr)) + "s", mapStr))

		#SERVER RABBIT COLOR SEND
		self.server.send(struct.pack("iii", self.regis.color[0], self.regis.color[1], self.regis.color[2]))

		#CLIENT RABBIT COLOR RECIEVE
		clientCol = self.server.recieve()
		clientCol = struct.unpack("iii", clientCol)

		#CREATE CLIENT RABBIT
		self.john = Rabbit(2, "john" , clientCol, self.level.objectList, self.level.objectSpritesList, True)

		self.regis.appendRabbit(self.john)
		self.john.appendRabbit(self.regis)

	 	self.pauseMenu = PauseGameMenu()

		self.deltaCarrot = 0
		self.timeCarrot = random.randint(1, 4)

	# 	for l in range(0, 6):
	# 		while True:
	# 			randPos = random.randint(0, 16)
	# 			if not self.level.isInBlock(self.level.objectList[randPos].getX() + 10, self.level.objectList[randPos].getY() - 26):
	# 				break

	# 		butterfly = Butterfly(self.level.objectList[randPos].getX() + 10, self.level.objectList[randPos].getY() - 26, (255, 10, 100), self.level.objectList, self.level.objectSpritesList)
	# 		self.butterflies.append(butterfly)

	 	pygame.display.flip()
Exemple #53
0
def FancyRender(text, color):
    global _font
    if _font == None:
        _font = Resources.TTF_Font('Kallamar/KALLAMAR.TTF', 18)

    c = pygame.Color(color[0], color[1], color[2])
    return _font.Render(text, c)
Exemple #54
0
	def __init__(self):
		self.screen = pygame.display.get_surface()

		if pygame.font:
			self.font = pygame.font.Font(None, 22)

		self.background = pygame.Surface(self.screen.get_size())
		self.background = self.background.convert()
		self.background.fill((50, 50, 50))

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.sliders = {}

		self.sliders["music"] = Slider(self.screen.get_width()/2 - 200/2, 100, 200, 100)
		self.sliders["sound"] = Slider(self.screen.get_width()/2 - 200/2, 200, 200, 100)

		self.currentSlider = None

		self.checkboxes = {}

		self.checkboxes["blood"] = Checkbox(self.screen.get_width()/2 - 50, 300, "Blood", True)
		self.checkboxes['fullscreen'] = Checkbox(self.screen.get_width()/2 - 50, 350, "Fullscreen", False)

		self.loadOptions()

		self.buttons = {}

		self.buttons["save"] = Button(self.screen.get_width() - self.screen.get_width()/4 - 200/2, 450, 200, 40, "SAVE")
		self.buttons["back"] = Button(self.screen.get_width()/4 - 200/2, 450, 200, 40, "BACK")

		pygame.display.flip()
Exemple #55
0
	def __init__(self, levelPreset = "empty"):
		self.screen = pygame.display.get_surface()

		self.backgroundImage, self.backgroundRect = loadPNG("background.png")

		self.blockList = [Object(type = "earth"), Object(type = "boing"), Object(type = "ice")]

		self.currentBlockNumber = 0
		self.currentBlock = self.blockList[self.currentBlockNumber]
		self.currentSpriteBlock = pygame.sprite.RenderPlain(self.currentBlock)

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.grid = False

		self.level = Map(True)

		self.active = True

		self.pauseMenu = PauseEditorMenu()

		self.toolbar = EditorToolbar()

		if levelPreset != "empty":
			self.level.load(levelPreset)
		
		pygame.display.flip()
Exemple #56
0
 def generateMapAndUnits():
     map_ = Resources.map('random')
     units = []
     nUnits = random.randint(4, 8)
     startColumn = random.randint(0, map_.width - (nUnits + 1) / 2)
     for i in xrange(0, nUnits):
         u = generateUnit(PLAYER_FACTION)
         if i < nUnits / 2:
             row = map_.height-1
             column = startColumn + i
         else:
             row = map_.height-2
             column = startColumn + (i - nUnits/2)
         map_.squares[column][row].setUnit(u)
         units.append(u)
     nUnits += additionalAIUnits
     startColumn = random.randint(0, map_.width - (nUnits + 1) / 2)
     for i in xrange(0, nUnits):
         u = generateUnit(NPC_HOSTILE_FACTION)
         if i < nUnits / 2:
             row = 0
             column = startColumn + i
         else:
             row = 1
             column = startColumn + (i - nUnits/2)
         map_.squares[column][row].setUnit(u)
         units.append(u)
     return (map_, units)
    def __init__(self):
        GameSceneBase.__init__(self)
        self._font = Resources.TTF_Font('Kallamar/KALLAMAR.TTF', 36)
        self._page = 0  # which BG page we're on
        self._bg = Resources.ImageLibrary.Get(
            'MapOptions/sc2.png')  # Background to draw
        self._args = {}

        self._map_size = 1
        self._map_sz1 = None
        self._font_r = None

        self._mode = 2
        self._mode_cont = None
        self._mode_cont_r = None
        self._mode_zoom_r = None

        self._time = -1
        self._time_right_r = None
        self._time_left_r = None

        self._zoom_level = 2
        self._zoom_size = 0
        self._zoom_right_r = None
        self._zoom_left_r = None

        #animation related
        self._transitioning = False  #should we be animating to the next option screen?
        self._animStart = None
        self._nextbg = None  #next background
        self._curScreenCache = None  # previous bg
        self._hover = None

        # set stuff up
        self._SetDefaults()
Exemple #58
0
    def initialize(self):

        # create date object
        self.date = pyDate.Date(year=self.options['year'], doy=self.options['doy'])

        # check for pre-existing solution if lazy
        (solutionAlreadyExists, key) = Resources.soln_exists(
            self.date,
            self.options['expt'],
            self.options['org'],
            self.options['network_id']
        )

        if solutionAlreadyExists and self.isLazy:
            raise Processing.LazyException("file exists: " + key)

        # do all the program independent stuff
        super(Session,self).initialize();
        
        # get the resource bucket path
        bucket = self.get_resources_path();
        
        # get the apr file 
        apr_file = glob.glob(os.path.join(bucket,'*.apr'));
        
        # yell about it if not found
        if len(apr_file) != 1:
            raise GamitException('problem identifying APR resources in '+bucket);
        
        # create apr file
        wlapr2apr(os.path.join(bucket,apr_file[0]));
        
        # get the binaries for gamit
        self.files['bin']    = Resources.get_bin   ('gamit', self.work_dir_path);
        
        # get the tables for gamit
        self.files['tables'] = Resources.get_tables('gamit', self.work_dir_path);
        
        # create custom setup shell script
        self.files['setup_script_path'   ] = self.__create_setup_script()   ;
        
        # create custom run script
        self.files['run_script_path'     ] = self.__create_run_script()     ;
        
        # create the custom cleanup script
        self.files['teardown_script_path'] = self.__create_teardown_script();