예제 #1
0
 def newDetailsButton(self):
     self.detailsButton = ButtonsFactory().newButton(
         self,
         "Show details",
         self.onShowDetails,
         hint=LogMessages.GRAPH_DETAILS_BTN_HINT)
     self.detailsButton.Enable(False)
     return self.detailsButton
예제 #2
0
 def newDeleteButton(self):
     self.delete_btn = ButtonsFactory().newButton(self,
                                                  "delete selected from " +
                                                  self.partName,
                                                  self.onDelete,
                                                  size=(200, 30))
     return self.delete_btn
예제 #3
0
 def newCreatorButton(self):
     self.creator_btn = ButtonsFactory().newButton(
         self,
         "Creator",
         self.onGoToCreator,
         hint=LogMessages.CREATOR_BTN_HINT)
     return self.creator_btn
예제 #4
0
 def newLoaderButton(self):
     self.loader_btn = ButtonsFactory().newButton(
         self,
         "Load and mount New Game",
         self.onGoToLoader,
         hint=LogMessages.LOADER_BTN_HINT)
     return self.loader_btn
예제 #5
0
 def newImageSelectorButton(self, onImgChangeCallback, btn_text):
     return ButtonsFactory().newButton(
         self,
         btn_text,
         onImgChangeCallback,
         size=(-1, 32),
         hint=LogMessages.BACKGROUND_TEXTURE_SELECTION_BTN_HINT)
예제 #6
0
 def newEditButton(self):
     self.edit_btn = ButtonsFactory().newButton(self,
                                                "edit selected from " +
                                                self.partName,
                                                self.onEdit,
                                                size=(200, 30))
     return self.edit_btn
예제 #7
0
 def newTutorialButton(self):
     self.tutorial_btn = ButtonsFactory().newButton(
         self,
         "Tutorial",
         self.goToTutorial,
         hint=LogMessages.TUTORIAL_BTN_HINT,
         size=(100, -1))
     return self.tutorial_btn
예제 #8
0
 def newExchangeButton(self):
     self.exchange_btn = ButtonsFactory().newButton(
         self,
         "Exchange",
         self.goToExchange,
         hint=LogMessages.EXCHANGE_BTN_HINT,
         size=(100, -1))
     return self.exchange_btn
예제 #9
0
 def newLoaderButton(self):
     self.loader_btn = ButtonsFactory().newButton(
         self,
         "Back to Loader",
         self.goToLoader,
         hint=LogMessages.MENU_BTN_HINT,
         size=(100, -1))
     return self.loader_btn
예제 #10
0
 def newLoadButton(self):
     return ButtonsFactory().newButton(self,
                                       "Load dependencies From File",
                                       self.loadDependencies,
                                       hint=LogMessages.LOAD_DEPS_BTN_HINT)
예제 #11
0
 def newGameButton(self):
     self.newgame_btn = ButtonsFactory().newButton(self,
                                                   "Game",
                                                   self.goToNewGame,
                                                   size=(100, -1))
     return self.newgame_btn
예제 #12
0
 def newSaveButton(self):
     self.save_btn = ButtonsFactory().newButton(self,
                                                "Save",
                                                size=(100, -1))
     return self.save_btn
예제 #13
0
 def newLoadButton(self):
     self.load_btn = ButtonsFactory().newButton(self,
                                                "Load",
                                                size=(100, -1))
     return self.load_btn
예제 #14
0
 def newShowGraphButton(self):
     self.show_graph_btn = ButtonsFactory().newButton(self, "Show Graph", self.onShowGraphClicked, hint = LogMessages.SHOW_GRAPH_BTN_HINT, size=(100,-1))
     return self.show_graph_btn
예제 #15
0
 def newExitButton(self):
     self.exit_btn = ButtonsFactory().newButton(
         self, "Exit", self.onExitSystem, hint=LogMessages.EXIT_BTN_HINT)
     return self.exit_btn
예제 #16
0
 def newCreateEntityButton(self, onSubmit):
     return ButtonsFactory().newButton(self, "Submit", onSubmit)
예제 #17
0
 def newAddButton(self):
     self.add_btn = ButtonsFactory().newButton(self,
                                               "add to " + self.partName,
                                               self.onAdd,
                                               size=(200, 30))
     return self.add_btn
예제 #18
0
 def newMenuButton(self):
     return ButtonsFactory().newButton(self,
                                       "Menu",
                                       self.retToMenu,
                                       hint=LogMessages.MENU_BTN_HINT)
예제 #19
0
 def newCancelButton(self, onCancel):
     return ButtonsFactory().newButton(self, "Cancel", onCancel)
예제 #20
0
 def newImageSelectorButton(self):
     return ButtonsFactory().newButton(self,
                                       "Choose another texture",
                                       self.selectImage,
                                       size=(-1, 32))
예제 #21
0
 def newSaveButton(self):
     return ButtonsFactory().newButton(self,
                                       "Save these dependencies to File",
                                       self.save,
                                       hint=LogMessages.SAVE_DEPS_BTN_HINT)
예제 #22
0
 def newCreateButton(self):
     return ButtonsFactory().newButton(
         self,
         "Create",
         self.createDependencies,
         hint=LogMessages.CREATE_DEPS_BTN_HINT)
예제 #23
0
 def newGameButton(self):
     self.new_game_btn = ButtonsFactory().newButton(self, "Game Menu", self.goToNewGameMenu, hint = LogMessages.MOUNT_GAME_BTN_HINT, size=(100,-1))
     return self.new_game_btn
예제 #24
0
 def newCleanButton(self):
     return ButtonsFactory().newButton(self,
                                       "Clean and Start Again",
                                       self.clean,
                                       hint=LogMessages.CLEAN_DEPS_BTN_HINT)
예제 #25
0
 def newMenuButton(self):
     self.menu_btn = ButtonsFactory().newButton(self, "Main Menu", self.goToMenu, hint = LogMessages.MENU_BTN_HINT, size=(100,-1))
     return self.menu_btn
예제 #26
0
class GraphPanel(ScrolledPanel):
    def __init__(self, parent, space_name):
        super(GraphPanel, self).__init__(
            parent,
            size=((wx.GetDisplaySize()[0] - GRAPH_SPACE_PADDING) / 3, 500),
            style=wx.SIMPLE_BORDER)
        self.space_name = space_name
        self.parent = parent
        self.jsonDesc = {"Dwellers": [], "Buildings": [], "Resources": []}
        self.SetForegroundColour((255, 255, 255))
        self.initRootSizer()
        self.Bind(wx.EVT_SHOW, self.onShow, self)

    def initRootSizer(self):
        self.rootSizer = wx.BoxSizer(wx.VERTICAL)
        self.rootSizer.Add(self.newHeaderSizer(), 0, wx.CENTER)
        self.SetSizer(self.rootSizer)

    def newHeaderSizer(self):
        header_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.parent.addToSizerWithSpace(header_sizer,
                                        self.newDescriptionLabel(),
                                        space=20)
        header_sizer.Add(self.newDetailsButton(), flag=wx.CENTER)
        return header_sizer

    def newDetailsButton(self):
        self.detailsButton = ButtonsFactory().newButton(
            self,
            "Show details",
            self.onShowDetails,
            hint=LogMessages.GRAPH_DETAILS_BTN_HINT)
        self.detailsButton.Enable(False)
        return self.detailsButton

    def onShowDetails(self, event):
        DetailsFrame(self, self.space_name).showDetailsFromJSON(self.jsonDesc)

    def newDescriptionLabel(self):
        return wx.StaticText(self, -1, self.space_name)

    def triggerGraphResetFromJSON(self, jsonGraphDesc):
        self.jsonDesc = jsonGraphDesc[self.space_name]
        self.Hide()
        self.Show()

    def onShow(self, ev):
        if ev.GetShow():
            self.resetViewFromJSON()

    def setupDetailsButton(self):
        self.detailsButton.Enable(self.jsonDesc != [])

    def resetViewFromJSON(self):
        self.setupRootSizer()
        self.setupDetailsButton()
        self.SetupScrolling()

    def setupRootSizer(self):
        self.rootSizer.Clear(True)
        rootVerticalSizer = self.rootSizer
        self.parent.addToSizerWithSpace(rootVerticalSizer,
                                        self.newHeaderSizer(),
                                        space=20)
        rootVerticalSizer.Add(
            self.newJSONTreeLvlVerticalSizer(0, self.jsonDesc), 0, wx.CENTER)
        rootVerticalSizer.Layout()

    def newJSONTreeLvlVerticalSizer(self, lvl_index, childrenJSONDesc):
        lvlVerticalSizer = wx.BoxSizer(wx.VERTICAL)
        self.attachHorizontalBranchesToSizer(lvlVerticalSizer,
                                             childrenJSONDesc, lvl_index)
        return lvlVerticalSizer

    def attachHorizontalBranchesToSizer(self, root, childrenJsonDesc,
                                        root_lvl):
        for childJsonDesc in childrenJsonDesc:
            self.parent.addToSizerWithSpace(root,
                                            self.newTreeLvlHorizontalSizer(
                                                root_lvl, childJsonDesc),
                                            alignment=wx.LEFT)

    def newScaledBmp(self, imagePath):
        img = wx.Image(name=imagePath)
        img = img.Scale(40, 32)
        return wx.StaticBitmap(self,
                               wx.ID_ANY,
                               wx.BitmapFromImage(img),
                               size=(40, 32))

    def newArrowBmp(self, lvl_index):
        return self.newScaledBmp(relative_textures_path +
                                 ("arrow_green_small.png" if lvl_index %
                                  2 == 0 else "arrow_light_small.png"))

    def newEntityBmp(self, tree_lvl_json_desc):
        return self.newScaledBmp(tree_lvl_json_desc["Texture path"])

    def newTreeLvlImagesSizer(self, lvl_index, tree):
        tree_lvl_images_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.parent.addToSizerWithSpace(tree_lvl_images_sizer,
                                        self.newArrowBmp(lvl_index))
        tree_lvl_images_sizer.Add(self.newEntityBmp(tree))
        return tree_lvl_images_sizer

    def newTreeLvlHorizontalSizer(self, lvl_index, tree_lvl_json_desc):
        lvlHorizontalSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.parent.addToSizerWithSpace(
            lvlHorizontalSizer,
            self.newTreeLvlImagesSizer(lvl_index, tree_lvl_json_desc))
        lvlHorizontalSizer.Add(
            self.newJSONTreeLvlVerticalSizer(lvl_index + 1,
                                             tree_lvl_json_desc["Children"]),
            0, wx.CENTER)
        return lvlHorizontalSizer