def selectSquare(self, x=None, y=None):
     if x != None and y != None:
         self.x = x
         self.y = y
     GUI.get().topMenu().setEnabled(True)
     GUI.get().topMenu().setShowing(True)
     self.state = MapEditorCursor.SELECTED
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         choice = self.getSelection()
         if choice == TopMenu.TILE_INFO:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().tileInfoDisplayer().setShowing(True)
             Input.get().setInDialog(True)
             return 'tileInfo'
         elif choice == TopMenu.SET_TAG:
             GUI.get().tagMenu().setShowing(True)
             return 'setTag'
         elif choice == TopMenu.EDIT_TAG:
             GUI.get().chooseTagMenu().setShowing(True)
             return 'chooseTag'
         elif choice == TopMenu.NEW_TAG:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().addTagDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'addTag'
         elif choice == TopMenu.SAVE:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().saveDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'save'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'cursor'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
Example #3
0
 def handleEvent(self, event):
     if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
         self.state += 1
         if self.state >= len(self.inputBoxes):
             self.state = 0
             self.evalResult()
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             GUI.get().topMenu().setShowing(False)
             return 'cursor'
     elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
         if self.state > 0:
             #self.inputBoxes[self.state].setText('')
             self.state -= 1
         else:
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             return 'cursor'
     elif event.type == pygame.KEYDOWN:
         if event.key == pygame.K_BACKSPACE:
             self.inputBoxes[self.state].delChar()
         if ((event.key >= pygame.K_0 and event.key <= pygame.K_9)
                 or (event.key >= pygame.K_a and event.key <= pygame.K_z)
                 or event.key == pygame.K_PERIOD
                 or event.key == pygame.K_MINUS):
             self.inputBoxes[self.state].append(chr(event.key))
Example #4
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         choice = self.getSelection()
         if choice == TopMenu.TILE_INFO:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().tileInfoDisplayer().setShowing(True)
             Input.get().setInDialog(True)
             return 'tileInfo'
         elif choice == TopMenu.SET_TAG:
             GUI.get().tagMenu().setShowing(True)
             return 'setTag'
         elif choice == TopMenu.EDIT_TAG:
             GUI.get().chooseTagMenu().setShowing(True)
             return 'chooseTag'
         elif choice == TopMenu.NEW_TAG:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().addTagDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'addTag'
         elif choice == TopMenu.SAVE:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().saveDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'save'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'cursor'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
Example #5
0
 def selectSquare(self, x=None, y=None):
     if x != None and y != None:
         self.x = x
         self.y = y
     GUI.get().topMenu().setEnabled(True)
     GUI.get().topMenu().setShowing(True)
     self.state = MapEditorCursor.SELECTED
 def handleEvent(self, event):
     if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
         self.state += 1                
         if self.state >= len(self.inputBoxes):
             self.state = 0
             self.evalResult()
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             GUI.get().topMenu().setShowing(False)
             return 'cursor'
     elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
         if self.state > 0:
             #self.inputBoxes[self.state].setText('')
             self.state -= 1
         else:
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             return 'cursor'
     elif event.type == pygame.KEYDOWN:
         if event.key == pygame.K_BACKSPACE:
             self.inputBoxes[self.state].delChar()
         if ((event.key >= pygame.K_0 and event.key <= pygame.K_9) or
             (event.key >= pygame.K_a and event.key <= pygame.K_z) or
             event.key == pygame.K_PERIOD or event.key == pygame.K_MINUS):
             self.inputBoxes[self.state].append(chr(event.key))
Example #7
0
 def draw(self):
     glDisable(GL_LIGHTING)
     glPushMatrix()
     GLUtil.mapTrans(self.x, self.y, 0.0)
     glColor4f(0.0, 0.0, 0.75, GUI.get().highlightAlpha())
     GLUtil.makeCubeTop(self.mapSquare().z, self.mapSquare().cornerHeights)
     glPopMatrix()
     glEnable(GL_LIGHTING)
Example #8
0
 def evalResult(self):
     tags = GUI.get().m.tags
     tagName = self.inputBoxes[0].getText()
     texture = self.inputBoxes[1].getText()
     color = (float(self.inputBoxes[2].getText()),
              float(self.inputBoxes[3].getText()),
              float(self.inputBoxes[4].getText()))
     colorVar = (float(self.inputBoxes[5].getText()),
                 float(self.inputBoxes[6].getText()),
                 float(self.inputBoxes[7].getText()))
     if not tags.has_key(tagName):
         tags[tagName] = {}
     tag = tags[tagName]
     tag['name'] = tagName
     tag['texture'] = texture
     tag['color'] = color
     tag['colorVar'] = colorVar
     GUI.get().updateMap()
 def evalResult(self):
     tags = GUI.get().m.tags
     tagName = self.inputBoxes[0].getText()
     texture = self.inputBoxes[1].getText()
     color = (float(self.inputBoxes[2].getText()),
              float(self.inputBoxes[3].getText()),
              float(self.inputBoxes[4].getText()))
     colorVar = (float(self.inputBoxes[5].getText()),
                 float(self.inputBoxes[6].getText()),
                 float(self.inputBoxes[7].getText()))
     if not tags.has_key(tagName):
         tags[tagName] = {}
     tag = tags[tagName]
     tag['name'] = tagName
     tag['texture'] = texture
     tag['color'] = color
     tag['colorVar'] = colorVar
     GUI.get().updateMap()
 def draw(self):
     glDisable(GL_LIGHTING)
     glPushMatrix()
     GLUtil.mapTrans(self.x, self.y, 0.0)
     glColor4f(0.0, 0.0, 0.75,
               GUI.get().highlightAlpha())
     GLUtil.makeCubeTop(self.mapSquare().z,
                        self.mapSquare().cornerHeights)
     glPopMatrix()
     glEnable(GL_LIGHTING)
 def setShowing(self, show):
     self._showing = show
     if show == True:
         sq = GUI.get().cursor.mapSquare()
         self.outputBoxes[0].setText(sq.tagName())
         tag = GUI.get().m.tags[sq.tagName()]
         
         textures = tag['texture']
         sidetextures = []
         if type(textures) == type([]):
             sidetextures = textures[1:]
             textures = textures[0]
         self.outputBoxes[1].setText(str(textures))
         self.outputBoxes[3].setText(str(sidetextures))
         
         topcolorstr = "(%1.2f, %1.2f, %1.2f)" % (sq.color[0][0],sq.color[0][1],sq.color[0][2])
         self.outputBoxes[2].setText(topcolorstr)
         for i in xrange(1,5):
             sidecolorstr = ("(%1.2f, %1.2f, %1.2f)" % (sq.color[i][0],sq.color[i][1],sq.color[i][2]))
             self.outputBoxes[3+i].setText(sidecolorstr)
Example #12
0
 def evalResult(self):
     texture = self.inputBoxes[0].getText()
     color = (float(self.inputBoxes[1].getText()),
              float(self.inputBoxes[2].getText()),
              float(self.inputBoxes[3].getText()))
     colorVar = (float(self.inputBoxes[4].getText()),
                 float(self.inputBoxes[5].getText()),
                 float(self.inputBoxes[6].getText()))
     tag = self.tag
     if type(tag['texture']) == type([]):
         tag['texture'][0] = texture
     else:
         tag['texture'] = texture
     if type(tag['color']) == type([]):
         tag['color'][0] = color
     else:
         tag['color'] = color
     if type(tag['colorVar']) == type([]):
         tag['colorVar'][0] = colorVar
     else:
         tag['colorVar'] = colorVar
     GUI.get().updateMap()
 def evalResult(self):
     texture = self.inputBoxes[0].getText()
     color = (float(self.inputBoxes[1].getText()),
              float(self.inputBoxes[2].getText()),
              float(self.inputBoxes[3].getText()))
     colorVar = (float(self.inputBoxes[4].getText()),
                 float(self.inputBoxes[5].getText()),
                 float(self.inputBoxes[6].getText()))
     tag = self.tag
     if type(tag['texture']) == type([]):
         tag['texture'][0] = texture            
     else:
         tag['texture'] = texture
     if type(tag['color']) == type([]):
         tag['color'][0] = color
     else:
         tag['color'] = color
     if type(tag['colorVar']) == type([]):
         tag['colorVar'][0] = colorVar
     else:
         tag['colorVar'] = colorVar
     GUI.get().updateMap()
Example #14
0
    def setShowing(self, show):
        self._showing = show
        if show == True:
            sq = GUI.get().cursor.mapSquare()
            self.outputBoxes[0].setText(sq.tagName())
            tag = GUI.get().m.tags[sq.tagName()]

            textures = tag['texture']
            sidetextures = []
            if type(textures) == type([]):
                sidetextures = textures[1:]
                textures = textures[0]
            self.outputBoxes[1].setText(str(textures))
            self.outputBoxes[3].setText(str(sidetextures))

            topcolorstr = "(%1.2f, %1.2f, %1.2f)" % (
                sq.color[0][0], sq.color[0][1], sq.color[0][2])
            self.outputBoxes[2].setText(topcolorstr)
            for i in xrange(1, 5):
                sidecolorstr = (
                    "(%1.2f, %1.2f, %1.2f)" %
                    (sq.color[i][0], sq.color[i][1], sq.color[i][2]))
                self.outputBoxes[3 + i].setText(sidecolorstr)
Example #15
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         tagNum = self.getSelection()
         tags = GUI.get().m.tags
         tagName = self.options[tagNum]
         GUI.get().cursor.mapSquare().setTag(tags[tagName])
         GUI.get().updateMap()
         self.setShowing(False)
         GUI.get().topMenu().setShowing(False)
         return 'cursor'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'topMenu'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         tagNum = self.getSelection()
         tags = GUI.get().m.tags
         tagName = self.options[tagNum]
         GUI.get().cursor.mapSquare().setTag(tags[tagName])
         GUI.get().updateMap()
         self.setShowing(False)
         GUI.get().topMenu().setShowing(False)
         return 'cursor'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'topMenu'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
Example #17
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         tagNum = self.getSelection()
         tagName = self.options[tagNum]
         self.setSelectedOption(0)
         self.setShowing(False)
         GUI.get().topMenu().setSelectedOption(0)
         GUI.get().topMenu().setShowing(False)
         GUI.get().editTagDialog().setShowing(True, tagName)
         Input.get().setInDialog(True)
         return 'editTag'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'topMenu'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         tagNum = self.getSelection()
         tagName = self.options[tagNum]
         self.setSelectedOption(0)
         self.setShowing(False)
         GUI.get().topMenu().setSelectedOption(0)
         GUI.get().topMenu().setShowing(False)
         GUI.get().editTagDialog().setShowing(True, tagName)
         Input.get().setInDialog(True)
         return 'editTag'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'topMenu'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
 def setShowing(self, show, tagName=None):
     self._showing = show
     if show == True and tagName != None:
         self.title.setText("Edit Tag Dialog: " + str(tagName))
         tag = GUI.get().m.tags[tagName]
         self.tag = tag
         texture = tag['texture']
         if type(texture) == type([]):
             texture = texture[0]
         self.inputBoxes[0].setText(texture)
         color = tag['color']
         if type(color) == type([]):
             color = color[0]
         print str(color)
         self.inputBoxes[1].setText(str(color[0]))
         self.inputBoxes[2].setText(str(color[1]))
         self.inputBoxes[3].setText(str(color[2]))
         colorVar = tag['colorVar']
         if type(colorVar) == type([]):
             colorVar = colorVar[0]
         print str(colorVar)
         self.inputBoxes[4].setText(str(colorVar[0]))
         self.inputBoxes[5].setText(str(colorVar[1]))
         self.inputBoxes[6].setText(str(colorVar[2]))
Example #20
0
 def setShowing(self, show, tagName=None):
     self._showing = show
     if show == True and tagName != None:
         self.title.setText("Edit Tag Dialog: " + str(tagName))
         tag = GUI.get().m.tags[tagName]
         self.tag = tag
         texture = tag['texture']
         if type(texture) == type([]):
             texture = texture[0]
         self.inputBoxes[0].setText(texture)
         color = tag['color']
         if type(color) == type([]):
             color = color[0]
         print str(color)
         self.inputBoxes[1].setText(str(color[0]))
         self.inputBoxes[2].setText(str(color[1]))
         self.inputBoxes[3].setText(str(color[2]))
         colorVar = tag['colorVar']
         if type(colorVar) == type([]):
             colorVar = colorVar[0]
         print str(colorVar)
         self.inputBoxes[4].setText(str(colorVar[0]))
         self.inputBoxes[5].setText(str(colorVar[1]))
         self.inputBoxes[6].setText(str(colorVar[2]))
 def handleEvent(self, event):
     if event.type == Input.CURSOR_UP:
         self.move(GUI.get().camera.cursorMovement(0, -1))
     elif event.type == Input.CURSOR_DOWN:
         self.move(GUI.get().camera.cursorMovement(0, 1))
     elif event.type == Input.CURSOR_LEFT:
         self.move(GUI.get().camera.cursorMovement(-1, 0))
     elif event.type == Input.CURSOR_RIGHT:
         self.move(GUI.get().camera.cursorMovement(1, 0))
     elif event.type == Input.CURSOR_ACCEPT:
         return self.click()
     elif event.type == Input.CURSOR_CANCEL:
         return self.unclick()
     elif event.type == Input.RAISE_CENTER:
         self.plusCenterHeight()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_CENTER:
         self.minusCenterHeight()
         GUI.get().updateMap()
     elif event.type == Input.RAISE_TILE:
         self.plusTileHeight()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_TILE:
         self.minusTileHeight()
         GUI.get().updateMap()
     elif (event.type >= Input.RAISE_B_BL_CORNER and
           event.type <= Input.RAISE_F_FR_CORNER):
         self.plusCornerHeight(
             GUI.get().camera.getCorner(event.type - Input.RAISE_B_BL_CORNER))
         GUI.get().updateMap()
     elif (event.type >= Input.LOWER_B_BL_CORNER and
           event.type <= Input.LOWER_F_FR_CORNER):
         self.minusCornerHeight(
             GUI.get().camera.getCorner(event.type - Input.LOWER_B_BL_CORNER))
         GUI.get().updateMap()
     elif event.type == Input.RAISE_WATER:
         self.raiseWater()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_WATER:
         self.lowerWater()
         GUI.get().updateMap()
 def moveRight(self):
     if self.canMove() and self.x < self.map.width - 1:
         self.x += 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
 def moveLeft(self):
     if self.canMove() and self.x > 0:
         self.x -= 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
 def moveDown(self):
     if self.canMove() and self.y < self.map.height - 1:
         self.y += 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
 def click(self):
     if self.state == MapEditorCursor.DISABLED:
         return
     elif self.state == MapEditorCursor.FREE:
         Sound.cursorClick()
         GUI.get().topMenu().setShowing(True)
         return 'topMenu'
     elif self.state == MapEditorCursor.SELECTED:
         Sound.cursorClick()
         choice = GUI.get().topMenu().getSelection()
         if choice == Sprite.TopMenu.SET_TAG:
             self.state = MapEditorCursor.SETTING_TAG
             GUI.get().tagMenu().setShowing(True)
         elif choice == Sprite.TopMenu.NEW_TAG:
             self.state = MapEditorCursor.CREATING_TAG
             GUI.get().topMenu().setEnabled(False)
             #GUI.get().addTagDialog().setEnabled(True)
             #GUI.get().addTagDialog().setShowing(True)
             GUI.get().addTagDialog().execute()
             GUI.get().topMenu().setShowing(False)
             self.state = MapEditorCursor.FREE
         #elif choice == Sprite.TopMenu.EDIT_TAG:
         #    self.state = MapEditorCursor.EDITING_TAG
         #    GUI.get().topMenu().setEnabled(False)
         #    GUI.get().editTagDialog().setEnabled(True)
         #    GUI.get().editTagDialog().setShowing(True)
         #elif choice == Sprite.TopMenu.SAVE:
         #    self.state = MapEditorCursor.SETTING_TAG
         #    GUI.get().topMenu().setEnabled(False)
         #    GUI.get().saveMapDialog().setEnabled(True)
         #    GUI.get().saveMapDialog().setShowing(True)
         else:
             print "ERROR: menu option %s not implemented yet" % choice
     elif self.state == MapEditorCursor.SETTING_TAG:
         tagNum = GUI.get().tagMenu().getSelection()
         tags = GUI.get().m.tags
         tagName = tags.keys()[tagNum]
         self.mapSquare().setTag(tags[tagName])
         GUI.get().updateMap()
         GUI.get().topMenu().setEnabled(False)
         GUI.get().topMenu().setShowing(False)
         GUI.get().tagMenu().setEnabled(False)
         GUI.get().tagMenu().setShowing(False)
         self.state = MapEditorCursor.FREE
         #GUI.get().clearTopText() # from special menu
         #GUI.get().clearHighlights()
     #    if ability == None:
     #        Sound.cursorInvalid()
     #        return
     #    self.selectedAbility = ability
     #    Sound.cursorClick()
     #    self.state = MapEditorCursor.CHOOSING_ABILITY_TARGET
     #    GUI.get().showAbilityRange(self.activeUnit,
     #                                       self.selectedAbility)
     #    GUI.get().battleMenu().setEnabled(False)             
     #    GUI.get().specialMenu().setEnabled(False)             
     #elif self.state == MapEditorCursor.CHOOSING_ABILITY_TARGET:
     #    Sound.cursorClick()
     #    a = self.selectedAbility
     #    if (self.x, self.y) not in a.range(self.map,
     #                                       self.activeUnit):
     #        Sound.cursorInvalid()
     #        return
     #    if not a.hasEffect(self.map, self.activeUnit, self.posn3d()):
     #        Sound.cursorInvalid()
     #        return
     #    self.state = MapEditorCursor.UNIT_SELECTED
     #    Battle.get().unitActed(a, self.posn3d())
     #    GUI.get().topMenu().setSelectedOption(0)
     #    GUI.get().topMenu().setEnabled(True)
     #    GUI.get().specialMenu().setEnabled(False)
     #    GUI.get().specialMenu().setShowing(False)
     #    GUI.get().clearHighlights()
     #    self.x = self.activeUnit.x()
     #    self.y = self.activeUnit.y()
     #elif self.state == MapEditorCursor.CHOOSING_MOVE_TARGET:
     #    if self.map.squares[self.x][self.y].unit != None:
     #        Sound.cursorInvalid()                
     #        return
     #    u = self._selectedUnit
     #    reachable = self.map.reachable(u)
     #    if (self.x, self.y) not in reachable:
     #        Sound.cursorInvalid()                
     #        return
     #    Sound.cursorClick()
     #    ScenarioGUI.get().moveUnit(u, (self.x, self.y))
     #    self.state = MapEditorCursor.UNIT_MOVING
     #elif self.state == MapEditorCursor.UNIT_MOVING:
     #    return
     else:
         print 'Error: unhandled click() call in MapEditorCursor'
    def unclick(self):
        if self.state == MapEditorCursor.DISABLED:
            return
        elif self.state == MapEditorCursor.FREE:
            Sound.cursorCancel()
#            if self.selectedSquare != None:
#                pass#for now
        elif self.state == MapEditorCursor.SELECTED:
            Sound.cursorCancel()
            self.state = MapEditorCursor.FREE
            self._selectedUnit = None
            GUI.get().topMenu().setSelectedOption(0)
            GUI.get().topMenu().setEnabled(False)
            GUI.get().topMenu().setShowing(False)
        elif (self.state == MapEditorCursor.IN_DIALOG):
            Sound.cursorCancel()
            GUI.get().topMenu().setEnabled(True)
            GUI.get().clearTopText() # from special menu
            GUI.get().clearHighlights()
        elif (self.state == MapEditorCursor.SETTING_TAG):
            Sound.cursorCancel()
            self.state = MapEditorCursor.SELECTED
            GUI.get().topMenu().setEnabled(True)
            GUI.get().tagMenu().setEnabled(False)
            GUI.get().tagMenu().setShowing(False)
            GUI.get().clearTopText() # from special menu
            GUI.get().clearHighlights()
        else:
            print 'Error: unhandled unclick() call in MapEditorCursor'
 def evalResult(self):
     GUI.get().saveMap(self.inputBoxes[0].getText())
Example #28
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_UP:
         self.move(GUI.get().camera.cursorMovement(0, -1))
     elif event.type == Input.CURSOR_DOWN:
         self.move(GUI.get().camera.cursorMovement(0, 1))
     elif event.type == Input.CURSOR_LEFT:
         self.move(GUI.get().camera.cursorMovement(-1, 0))
     elif event.type == Input.CURSOR_RIGHT:
         self.move(GUI.get().camera.cursorMovement(1, 0))
     elif event.type == Input.CURSOR_ACCEPT:
         return self.click()
     elif event.type == Input.CURSOR_CANCEL:
         return self.unclick()
     elif event.type == Input.RAISE_CENTER:
         self.plusCenterHeight()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_CENTER:
         self.minusCenterHeight()
         GUI.get().updateMap()
     elif event.type == Input.RAISE_TILE:
         self.plusTileHeight()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_TILE:
         self.minusTileHeight()
         GUI.get().updateMap()
     elif (event.type >= Input.RAISE_B_BL_CORNER
           and event.type <= Input.RAISE_F_FR_CORNER):
         self.plusCornerHeight(
             GUI.get().camera.getCorner(event.type -
                                        Input.RAISE_B_BL_CORNER))
         GUI.get().updateMap()
     elif (event.type >= Input.LOWER_B_BL_CORNER
           and event.type <= Input.LOWER_F_FR_CORNER):
         self.minusCornerHeight(
             GUI.get().camera.getCorner(event.type -
                                        Input.LOWER_B_BL_CORNER))
         GUI.get().updateMap()
     elif event.type == Input.RAISE_WATER:
         self.raiseWater()
         GUI.get().updateMap()
     elif event.type == Input.LOWER_WATER:
         self.lowerWater()
         GUI.get().updateMap()
Example #29
0
 def moveRight(self):
     if self.canMove() and self.x < self.map.width - 1:
         self.x += 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
Example #30
0
 def moveLeft(self):
     if self.canMove() and self.x > 0:
         self.x -= 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
Example #31
0
 def moveDown(self):
     if self.canMove() and self.y < self.map.height - 1:
         self.y += 1
         Sound.cursorMove()
         GUI.get().scrollTo((self.x, self.y))
Example #32
0
 def click(self):
     if self.state == MapEditorCursor.DISABLED:
         return
     elif self.state == MapEditorCursor.FREE:
         Sound.cursorClick()
         GUI.get().topMenu().setShowing(True)
         return 'topMenu'
     elif self.state == MapEditorCursor.SELECTED:
         Sound.cursorClick()
         choice = GUI.get().topMenu().getSelection()
         if choice == Sprite.TopMenu.SET_TAG:
             self.state = MapEditorCursor.SETTING_TAG
             GUI.get().tagMenu().setShowing(True)
         elif choice == Sprite.TopMenu.NEW_TAG:
             self.state = MapEditorCursor.CREATING_TAG
             GUI.get().topMenu().setEnabled(False)
             #GUI.get().addTagDialog().setEnabled(True)
             #GUI.get().addTagDialog().setShowing(True)
             GUI.get().addTagDialog().execute()
             GUI.get().topMenu().setShowing(False)
             self.state = MapEditorCursor.FREE
         #elif choice == Sprite.TopMenu.EDIT_TAG:
         #    self.state = MapEditorCursor.EDITING_TAG
         #    GUI.get().topMenu().setEnabled(False)
         #    GUI.get().editTagDialog().setEnabled(True)
         #    GUI.get().editTagDialog().setShowing(True)
         #elif choice == Sprite.TopMenu.SAVE:
         #    self.state = MapEditorCursor.SETTING_TAG
         #    GUI.get().topMenu().setEnabled(False)
         #    GUI.get().saveMapDialog().setEnabled(True)
         #    GUI.get().saveMapDialog().setShowing(True)
         else:
             print "ERROR: menu option %s not implemented yet" % choice
     elif self.state == MapEditorCursor.SETTING_TAG:
         tagNum = GUI.get().tagMenu().getSelection()
         tags = GUI.get().m.tags
         tagName = tags.keys()[tagNum]
         self.mapSquare().setTag(tags[tagName])
         GUI.get().updateMap()
         GUI.get().topMenu().setEnabled(False)
         GUI.get().topMenu().setShowing(False)
         GUI.get().tagMenu().setEnabled(False)
         GUI.get().tagMenu().setShowing(False)
         self.state = MapEditorCursor.FREE
         #GUI.get().clearTopText() # from special menu
         #GUI.get().clearHighlights()
     #    if ability == None:
     #        Sound.cursorInvalid()
     #        return
     #    self.selectedAbility = ability
     #    Sound.cursorClick()
     #    self.state = MapEditorCursor.CHOOSING_ABILITY_TARGET
     #    GUI.get().showAbilityRange(self.activeUnit,
     #                                       self.selectedAbility)
     #    GUI.get().battleMenu().setEnabled(False)
     #    GUI.get().specialMenu().setEnabled(False)
     #elif self.state == MapEditorCursor.CHOOSING_ABILITY_TARGET:
     #    Sound.cursorClick()
     #    a = self.selectedAbility
     #    if (self.x, self.y) not in a.range(self.map,
     #                                       self.activeUnit):
     #        Sound.cursorInvalid()
     #        return
     #    if not a.hasEffect(self.map, self.activeUnit, self.posn3d()):
     #        Sound.cursorInvalid()
     #        return
     #    self.state = MapEditorCursor.UNIT_SELECTED
     #    Battle.get().unitActed(a, self.posn3d())
     #    GUI.get().topMenu().setSelectedOption(0)
     #    GUI.get().topMenu().setEnabled(True)
     #    GUI.get().specialMenu().setEnabled(False)
     #    GUI.get().specialMenu().setShowing(False)
     #    GUI.get().clearHighlights()
     #    self.x = self.activeUnit.x()
     #    self.y = self.activeUnit.y()
     #elif self.state == MapEditorCursor.CHOOSING_MOVE_TARGET:
     #    if self.map.squares[self.x][self.y].unit != None:
     #        Sound.cursorInvalid()
     #        return
     #    u = self._selectedUnit
     #    reachable = self.map.reachable(u)
     #    if (self.x, self.y) not in reachable:
     #        Sound.cursorInvalid()
     #        return
     #    Sound.cursorClick()
     #    ScenarioGUI.get().moveUnit(u, (self.x, self.y))
     #    self.state = MapEditorCursor.UNIT_MOVING
     #elif self.state == MapEditorCursor.UNIT_MOVING:
     #    return
     else:
         print 'Error: unhandled click() call in MapEditorCursor'
Example #33
0
 def evalResult(self):
     GUI.get().saveMap(self.inputBoxes[0].getText())
Example #34
0
    def unclick(self):
        if self.state == MapEditorCursor.DISABLED:
            return
        elif self.state == MapEditorCursor.FREE:
            Sound.cursorCancel()
#            if self.selectedSquare != None:
#                pass#for now
        elif self.state == MapEditorCursor.SELECTED:
            Sound.cursorCancel()
            self.state = MapEditorCursor.FREE
            self._selectedUnit = None
            GUI.get().topMenu().setSelectedOption(0)
            GUI.get().topMenu().setEnabled(False)
            GUI.get().topMenu().setShowing(False)
        elif (self.state == MapEditorCursor.IN_DIALOG):
            Sound.cursorCancel()
            GUI.get().topMenu().setEnabled(True)
            GUI.get().clearTopText()  # from special menu
            GUI.get().clearHighlights()
        elif (self.state == MapEditorCursor.SETTING_TAG):
            Sound.cursorCancel()
            self.state = MapEditorCursor.SELECTED
            GUI.get().topMenu().setEnabled(True)
            GUI.get().tagMenu().setEnabled(False)
            GUI.get().tagMenu().setShowing(False)
            GUI.get().clearTopText()  # from special menu
            GUI.get().clearHighlights()
        else:
            print 'Error: unhandled unclick() call in MapEditorCursor'