Changeset 776


Ignore:
Timestamp:
06/08/12 16:27:43 (3 years ago)
Author:
ecoughlan
Message:

Added images, adding tutorial parts

Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • resources/data/tutorial/Tutorial.txt

    r762 r776  
    11Tutorial-00
    2 CLICK THE RESEARCH BUTTON!
     2Research allows us to learn about technologies.
     3475
     4500
     5up
     6Tutorial-01
     7So, let's research a power source.
     8475
     9500
     10up
     11Tutorial-02
     12First, click on the "Research" button.
    31380
    414400
    515left
    6 Tutorial-01
    7 Now the power button...
     16Tutorial-03
     17We need to research power, so click the "Power" button.
    818200
    919250
    1020left
    11 Tutorial-02
    12 Now click research.
     21Tutorial-04
     22We can research a windmill for $10. Click the "Research" Button.
    1323650
    1424200
    1525up
    16 Tutorial-03
    17 Now switch to the build menu.
     26Tutorial-05
     27Now, let's build our new windmill.
     28475
     29500
     30up
     31Tutorial-06
     32Click the "Build" button.
    183380
    1934210
    2035left
    21 Tutorial-04
    22 Click on power
     36Tutorial-07
     37The windmill is a power source, so click "Power".
    2338200
    2439250
    2540left
    26 Tutorial-05
    27 Make that windmill.
     41Tutorial-08
     42Then, click the picture of the windmill.
    2843200
    2944250
    3045left
    31 Tutorial-06
    32 Click build to confirm it.
     46Tutorial-09
     47The windmill will cost $50 and 40 material, which we have!
     48475
     49500
     50up
     51Tutorial-10
     52So, click on the "Build" button.
    3353650
    3454200
    3555up
    36 Tutorial-07
    37 Now hit end turn to begin construction on your windmill!
     56Tutorial-11
     57It takes time for the aliens to build the windmill.
     58475
     59500
     60up
     61Tutorial-12
     62If you do not want the windmill after all, click "Undo Turn".
     6380
     64570
     65left
     66Tutorial-13
     67This allows you to go back to the beginning of this turn.
     68475
     69500
     70up
     71Tutorial-14
     72Let's not actually undo though. Click "Cancel".
     73650
     74375
     75up
     76Tutorial-15
     77Now, hit "End Turn" to construct your windmill.
    387880
    3979610
  • src/main.py

    r770 r776  
    7575
    7676    # Cut from here and put into top.py
    77    
     77
    7878    top.render(screenSurface)
    7979    pygame.display.update()
  • src/onScreenButton.py

    r674 r776  
    2424        Window.__init__(self, pos, visible)
    2525        self.isDepressed = isDepressed
     26        self.title = title
    2627
    2728        for button in BUTTON_LUT:
  • src/top.py

    r771 r776  
    4545from loadDialogue import LoadDialogue
    4646
     47
    4748class Top:
    4849    '''
     
    7071        self.inMainMenu = True
    7172        self.hoverDescripRect = Rectangle(HOVER_DIM.POS, HOVER_DIM.W, HOVER_DIM.H)
    72         self.map = Map(True, self.deleteBuilding,(self.mainScreen,))
    73        
     73        self.map = Map(True, self.deleteBuilding, (self.mainScreen,))
     74
    7475        self.initialize()
     76        #self.initializeTutorial()
    7577
    7678    def initialize(self):
     
    8183        return type: none
    8284        """
    83        
     85
    8486        ###########################################################################
    85        
     87
    8688        gameBackground = Background(MAIN_DIM.GAME_BG_POS, True, None, True)
    87        
     89
    8890        ###########################################################################
    8991
     
    214216        menuButton.setHover(STR.MAIN_MENU_HOVER)
    215217
    216         ###########################################################################
     218        #######################################################################
    217219
    218220        statsWindow = StatDisplaySpec(self.getSpec(True))
    219221
    220         ###########################################################################
     222        #######################################################################
    221223
    222224        self.addMenuWindow(menuBackground)
     
    231233        gameBackground.addWindow(self.map)
    232234
    233         ###########################################################################
    234         '''
    235         # Setup tutorial
    236         tutorial = Tutorial()
    237 
    238         # Research button
    239         tutorial.addWindow(TutBut(rButton))
    240 
    241         # Research power button
    242         rPowButtonIndex = rCatMenu.getElementByAttr(ResearchMenuEntry, "researchCat", POWER)
    243         tutorial.addWindow(TutBut(rCatMenu.subwindows[rPowButtonIndex]))
    244 
    245         # Research power description research button
    246         tutorial.addWindow(TutBut(rCatMenu.subwindows[rPowButtonIndex].getElementByAttrRecursive(SimpleButton, "affirmative")))
    247 
    248         # Build Button
    249         tutorial.addWindow(TutBut(bButton))
    250 
    251         # Build power button
    252         tutorial.addWindow(TutBut(bCatMenu.subwindows[POWER + 1]))
    253 
    254         # Build power windmill button
    255         pageOffset = bTutList[POWER].pageOffset
    256         windmillIndex = bTutList[POWER].subwindows[pageOffset].getElementByAttr(BuildMenuEntry, "buildingName", "windmill")
    257         tutorial.addWindow(TutBut(bTutList[POWER].subwindows[pageOffset].subwindows[windmillIndex]))
    258 
    259         # Build power windmill description build button
    260         windmillBuildButton = bTutList[POWER].subwindows[pageOffset].subwindows[windmillIndex].getElementByAttrRecursive(SimpleButton, "affirmative")
    261         tutorial.addWindow(TutBut(windmillBuildButton))
    262         #tutorial.addWindow(TutBut(bTutList[0].subwindows[2].subwindows[2].\
    263         #                            subwindows[0].subwindows[0]))
    264         # EndTurn Button
    265         tutorial.addWindow(TutBut(endTurnButton))
    266 
    267         self.addTutorialWindow(tutorial)
    268         '''
     235        #######################################################################
     236
    269237        self.gameWindows = []
    270238        self.addGameWindow(gameBackground)
    271239
    272         ###########################################################################
     240        #######################################################################
    273241
    274242        self.event(pygame.event.Event(VIDEORESIZE, {'w': DIM.SCREEN_W,
    275                                                       'h': DIM.SCREEN_H}))                                             
    276                                                      
     243                                                      'h': DIM.SCREEN_H}))
     244
     245    def initializeTutorial(self):
     246        # Setup tutorial
     247        window = self.gameWindows[0]
     248        tutorial = Tutorial(window)
     249
     250        lookUpList = [None,
     251                      None,
     252                      [0, OnScreenButton, "title", "RESEARCH"],
     253                      [3, ResearchMenuEntry, "researchCat", POWER],
     254                      [4, SimpleButton, "affirmative"],
     255                      None,
     256                      [0, OnScreenButton, "title", "BUILD"],
     257                      [7, BuildMenu, "category", POWER],
     258                      [8, BuildMenuEntry, "buildingName", "windmill"],
     259                      None,
     260                      [9, SimpleButton, "affirmative"],
     261                      None,
     262                      [0, OnScreenButton, "title", "UNDO TURN"],
     263                      None,
     264                      [13, SimpleButton, "affirmative", False],
     265                      [0, OnScreenButton, "title", "END TURN"]]
     266
     267        tutorial.addLookUpList(lookUpList)
     268
     269        self.addTutorialWindow(tutorial)
     270
    277271    def event(self, e):
    278272        """
     
    570564        self.map = Map(True, self.deleteBuilding,(self.mainScreen,))
    571565        self.initialize()
     566        self.initializeTutorial()
    572567        self.handleScene()
    573568
  • src/tutorial.py

    r677 r776  
    33from fileio import loadText
    44from globals import *
     5from tutorialButton import TutorialButton as TutBut
    56
    67
    78class Tutorial(Window):
    8     def __init__(self):
     9    def __init__(self, startWindow):
    910        """
    1011            Initalizes a tutorial
     
    1819        self.step = 2
    1920
    20     def addWindow(self, window):
     21        self.windowList = [startWindow]
     22        self.lookUpList = []
     23
     24    def addWindow(self, functionTuple):
    2125        """
    2226            Adds a window with a blank window object.
    2327
    24             input type: Window(window)
     28            input type: Function Tuple(window)
    2529            return type: none
    2630        """
    27         window.addResponse((self.nextBlank, ))
    28         self.subwindows.append(window)
     31        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
     32        print "adding window", self.currentIndex
     33        if functionTuple is not None:
     34            print "function tuple is not None: ", functionTuple
     35            baseWindow = self.windowList[functionTuple[0]]
     36            window = baseWindow.getElementByAttrRecursive(*functionTuple[1:])
     37            if window is None:
     38                print "Window is None"
     39        else:
     40            print "function tuple is None"
     41            window = None
     42
     43        if window is not None:
     44            print "window responses: ", window.responses
     45        self.windowList.append(window)
     46        tutWindow = TutBut(window)
     47
     48        tutWindow.addResponse((self.nextBlank, ))
     49        if window is not None:
     50            print "tutorial responses: ", tutWindow.responses
     51        self.subwindows.append(tutWindow)
    2952        self.subwindows.append(self.blanks[self.length])
    3053
    3154        self.length += 1
     55
     56    def addLookUpList(self, lookUpList):
     57        """
     58            Adds a list of functions to get windows.
     59
     60            input type: [functionTuples]
     61            return type: none
     62        """
     63        self.lookUpList = lookUpList
    3264
    3365    def nextBlank(self):
     
    3870            return type: none
    3971        """
    40         if self.currentIndex < self.length - 1:
     72        if self.currentIndex < len(self.lookUpList) - 1:
    4173            self.closeCurrentIndex()
    4274            self.currentIndex += 1
     
    71103        """
    72104            opens the current part of the tutorial
    73            
     105
    74106            input type: None
    75107            return type: None
    76108        """
     109        self.addWindow(self.lookUpList[self.currentIndex])
    77110        for i in range(self.step):
    78111            self.subwindows[self.currentIndex * self.step + i].open()
     
    100133        else:
    101134            return False
     135   
     136    def update(self, state):
     137        """
     138            takes in a state and updates window as neccesary.
     139
     140            input type: State(state)
     141            return type: none
     142        """
     143        for window in self.subwindows:
     144            if window.visible:
     145                window.update(state)
     146        self.windowList[0].update(state)
    102147
    103148
  • src/tutorialButton.py

    r614 r776  
    66
    77from window import Window
     8from rectangle import Rectangle
     9from text import Text
     10from image import Image
     11from globals import *
    812
    913
    1014class TutorialButton(Window):
    11     def __init__(self, object):
     15    def __init__(self, object=None):
    1216        """
    1317            initializes the components of the TutorialButton subclass
     
    1620            input type: Window(object)
    1721        """
    18         Window.__init__(self, object.pos, True)
    19         self.text = object.text
    20         self.images = object.images
    21         self.rectangles = object.rectangles
    22         self.addResponse((object.runResponses,))
     22
     23        if object is not None:
     24            Window.__init__(self, object.pos, True)
     25            self.text = object.text
     26            self.images = object.images
     27            self.rectangles = object.rectangles
     28            self.addResponse((object.runResponses,))
     29            #self.addRect(Rectangle(self.pos, 50, 50, (255, 0, 0)))
     30
     31        else:
     32            Window.__init__(self, (500, 450), True)
     33            self.addImg(Image(self.pos, 200, 50, buttonDir + "stat"))
     34            self.addText(Text(self.pos, "CONTINUE", 42, (255, 255, 255), 200, True))
     35
     36    def runResponses(self):
     37        """
     38            call response responses that had been designated to window
     39
     40            input type: none
     41            return type: none
     42        """
     43        print "running tutorial responses: ", self.responses
     44        for functionTuple in self.responses:
     45            functionTuple[0](*functionTuple[1:])
     46       
  • src/window.py

    r677 r776  
    128128                for r in self.rectangles:
    129129                    r.resize(xScale, yScale)
    130    
     130
    131131                for i in self.images:
    132132                    i.resize(xScale, yScale)
    133    
     133
    134134                for t in self.text:
    135135                    t.resize(xScale, yScale)
Note: See TracChangeset for help on using the changeset viewer.