Ejemplo n.º 1
0
 def fset(self, value):
     pW, pH = self._displayWidth, self._displayHeight
     displayX, displayY, displayWidth, displayHeight = value
     self._displayX = int(round(displayX))
     self._displayY = int(round(displayY))
     self._displayWidth = int(round(displayX + displayWidth)) - self._displayX
     self._displayHeight = int(round(displayY + displayHeight)) - self._displayY
     ro = self.renderObject
     if ro:
         ro.displayX = self._displayX
         ro.displayY = self._displayY
         ro.displayWidth = self._displayWidth
         ro.displayHeight = self._displayHeight
     if self._displayWidth != pW or self._displayHeight != pH:
         if self._backgroundlist and len(self.background):
             self.UpdateBackgrounds()
         if self.outline:
             self.DrawOutline()
         if self.gridSprite:
             baseCellSize = hexUtil.hex_slot_size(self.isFlatTop, self.hexGridSize)
             tileTextureWidth = 288.0
             tileTextureHeight = 333.0
             textureScaling = tileTextureHeight / baseCellSize[1]
             self.gridSprite.rectSecondary = ((self.sizeUnscaled[0] * 2 % (self.hexGridSize * 6) - self.hexGridSize) * textureScaling + self.hexGridSize * textureScaling * 0.75,
              0.0,
              tileTextureWidth / self.globalScaling / self.localScaling * textureScaling * 0.5,
              tileTextureHeight / self.globalScaling / self.localScaling * textureScaling * 0.5)
Ejemplo n.º 2
0
 def fset(self, value):
     pW, pH = self._displayWidth, self._displayHeight
     displayX, displayY, displayWidth, displayHeight = value
     self._displayX = int(round(displayX))
     self._displayY = int(round(displayY))
     self._displayWidth = int(
         round(displayX + displayWidth)) - self._displayX
     self._displayHeight = int(
         round(displayY + displayHeight)) - self._displayY
     ro = self.renderObject
     if ro:
         ro.displayX = self._displayX
         ro.displayY = self._displayY
         ro.displayWidth = self._displayWidth
         ro.displayHeight = self._displayHeight
     if self._displayWidth != pW or self._displayHeight != pH:
         if self._backgroundlist and len(self.background):
             self.UpdateBackgrounds()
         if self.outline:
             self.DrawOutline()
         if self.gridSprite:
             baseCellSize = hexUtil.hex_slot_size(
                 self.isFlatTop, self.hexGridSize)
             tileTextureWidth = 288.0
             tileTextureHeight = 333.0
             textureScaling = tileTextureHeight / baseCellSize[1]
             self.gridSprite.rectSecondary = (
                 (self.sizeUnscaled[0] * 2 %
                  (self.hexGridSize * 6) - self.hexGridSize) *
                 textureScaling +
                 self.hexGridSize * textureScaling * 0.75, 0.0,
                 tileTextureWidth / self.globalScaling /
                 self.localScaling * textureScaling * 0.5,
                 tileTextureHeight / self.globalScaling /
                 self.localScaling * textureScaling * 0.5)
Ejemplo n.º 3
0
 def SetMapSize(self, size):
     size = self.setMapSize or size
     size += size & 1
     self.mapsize = size
     baseSize = hexUtil.hex_slot_size(self.isFlatTop, self.hexGridSize * size)
     if baseSize != (self.width, self.height):
         self.sizeUnscaled = baseSize
         self.morphGlobalScaling = 0.0
         self.morphGlobalScaling = 1.0
Ejemplo n.º 4
0
 def SetMapSize(self, size):
     size = self.setMapSize or size
     size += size & 1
     self.mapsize = size
     baseSize = hexUtil.hex_slot_size(self.isFlatTop,
                                      self.hexGridSize * size)
     if baseSize != (self.width, self.height):
         self.sizeUnscaled = baseSize
         self.morphGlobalScaling = 0.0
         self.morphGlobalScaling = 1.0
Ejemplo n.º 5
0
    def PreparePathFinder(self):
        xStep, yStep = hexUtil.hex_slot_size(self.isFlatTop, self.hexGridSize / 2.0)
        xRange = int(self.width / xStep)
        yRange = int(self.height / yStep)
        xRange = xRange - xRange % 3 + 3
        yRange = yRange - yRange % 3 + 3
        pathMap = pyEvePathfinder.EveMap()
        pathMap.CreateRegion(-1)
        pathMap.CreateConstellation(-2, -1)
        self.pathMap = pathMap
        pathfinder = EvePathfinderCore(pathMap)
        pathfinderState = HexMapPathfinderInterface()
        self.avoidPathFinderState = HexMapPathfinderInterface()

        def ConvertPathFinderIDMock(ret):
            return ret

        self.pathfinderHandler = ClientPathfinder(pathfinder, pathfinderState, self.avoidPathFinderState, ConvertPathFinderIDMock, ConvertPathFinderIDMock)
        self.avoidPathFinderState.blockedSpots = []
        self.avoidPathFinderState.usedSpots = []
        if getattr(self, 'pathFindingPairs', None):
            for i in xrange(yRange * xRange):
                pathMap.CreateSolarSystem(i, -2, -1)

            self.AddToPathFinding(self.pathFindingPairs)
            return
        self.column_row_to_pathfinder = column_row_to_pathfinder = {}
        self.pathfinder_to_xy = pathfinder_to_xy = []
        self.pathfinderIndexGrid = indexGrid = []
        self.pathFindingPairs = pathFindingPairs = set()
        self.pathFindingPairSequence = pathFindingPairSequence = {}
        showDebug = not self.isChild and settings.user.ui.Get('mapDebugSubdivision', 0)
        self.pathfinderSize = (xRange, yRange)
        i = 0
        for y in xrange(yRange):
            row = []
            indexGrid.append(row)
            yOdd = y & 1
            for x in xrange(xRange):
                row.append(i)
                posX = x * xStep
                posY = y * yStep
                if y % 2:
                    posX += xStep / 2
                isPrimary = not (x - yOdd + self.mapsize / 2 % 3) % 3
                if isPrimary:
                    px_hx = hexUtil.pixel_to_hex(posX - self.width / 2, posY - self.height / 2, self.hexGridSize, isFlatTop=self.isFlatTop)
                    ax_cu = hexUtil.axial_to_cube_coordinate(*px_hx)
                    ax_cu_rounded = hexUtil.hex_round(*ax_cu)
                    cu_ax = hexUtil.cube_to_odd_q_axial_coordinate(*ax_cu_rounded)
                    column_row_to_pathfinder[cu_ax] = i
                for cMod, rMod in ((-1, 0), (-1 + yOdd, -1), (yOdd, -1)):
                    cIndex = x + cMod
                    rIndex = y + rMod
                    if rIndex >= 0 and cIndex >= 0:
                        try:
                            pathFindingPairs.add((i, indexGrid[rIndex][cIndex]))
                        except IndexError:
                            pass

                if showDebug:
                    if isPrimary:
                        textColor = (1, 0, 0, 1)
                    else:
                        textColor = (0, 1, 0, 1)
                    EveLabelSmall(parent=self, text=str(i), left=posX - self.width / 2, top=posY - self.height / 2, align=uiconst.CENTER, color=textColor)
                pathfinder_to_xy.append((posX, posY))
                pathMap.CreateSolarSystem(i, -2, -1)
                i += 1

        self.AddToPathFinding(self.pathFindingPairs, showDebug)
Ejemplo n.º 6
0
    def PreparePathFinder(self):
        xStep, yStep = hexUtil.hex_slot_size(self.isFlatTop,
                                             self.hexGridSize / 2.0)
        xRange = int(self.width / xStep)
        yRange = int(self.height / yStep)
        xRange = xRange - xRange % 3 + 3
        yRange = yRange - yRange % 3 + 3
        pathMap = pyEvePathfinder.EveMap()
        pathMap.CreateRegion(-1)
        pathMap.CreateConstellation(-2, -1)
        self.pathMap = pathMap
        pathfinder = EvePathfinderCore(pathMap)
        pathfinderState = HexMapPathfinderInterface()
        self.avoidPathFinderState = HexMapPathfinderInterface()

        def ConvertPathFinderIDMock(ret):
            return ret

        self.pathfinderHandler = ClientPathfinder(pathfinder, pathfinderState,
                                                  self.avoidPathFinderState,
                                                  ConvertPathFinderIDMock,
                                                  ConvertPathFinderIDMock)
        self.avoidPathFinderState.blockedSpots = []
        self.avoidPathFinderState.usedSpots = []
        if getattr(self, 'pathFindingPairs', None):
            for i in xrange(yRange * xRange):
                pathMap.CreateSolarSystem(i, -2, -1)

            self.AddToPathFinding(self.pathFindingPairs)
            return
        self.column_row_to_pathfinder = column_row_to_pathfinder = {}
        self.pathfinder_to_xy = pathfinder_to_xy = []
        self.pathfinderIndexGrid = indexGrid = []
        self.pathFindingPairs = pathFindingPairs = set()
        self.pathFindingPairSequence = pathFindingPairSequence = {}
        showDebug = not self.isChild and settings.user.ui.Get(
            'mapDebugSubdivision', 0)
        self.pathfinderSize = (xRange, yRange)
        i = 0
        for y in xrange(yRange):
            row = []
            indexGrid.append(row)
            yOdd = y & 1
            for x in xrange(xRange):
                row.append(i)
                posX = x * xStep
                posY = y * yStep
                if y % 2:
                    posX += xStep / 2
                isPrimary = not (x - yOdd + self.mapsize / 2 % 3) % 3
                if isPrimary:
                    px_hx = hexUtil.pixel_to_hex(posX - self.width / 2,
                                                 posY - self.height / 2,
                                                 self.hexGridSize,
                                                 isFlatTop=self.isFlatTop)
                    ax_cu = hexUtil.axial_to_cube_coordinate(*px_hx)
                    ax_cu_rounded = hexUtil.hex_round(*ax_cu)
                    cu_ax = hexUtil.cube_to_odd_q_axial_coordinate(
                        *ax_cu_rounded)
                    column_row_to_pathfinder[cu_ax] = i
                for cMod, rMod in ((-1, 0), (-1 + yOdd, -1), (yOdd, -1)):
                    cIndex = x + cMod
                    rIndex = y + rMod
                    if rIndex >= 0 and cIndex >= 0:
                        try:
                            pathFindingPairs.add(
                                (i, indexGrid[rIndex][cIndex]))
                        except IndexError:
                            pass

                if showDebug:
                    if isPrimary:
                        textColor = (1, 0, 0, 1)
                    else:
                        textColor = (0, 1, 0, 1)
                    EveLabelSmall(parent=self,
                                  text=str(i),
                                  left=posX - self.width / 2,
                                  top=posY - self.height / 2,
                                  align=uiconst.CENTER,
                                  color=textColor)
                pathfinder_to_xy.append((posX, posY))
                pathMap.CreateSolarSystem(i, -2, -1)
                i += 1

        self.AddToPathFinding(self.pathFindingPairs, showDebug)