Example #1
0
def displayConsole(handle, xpos, ypos):
    """Opens console for display and editing
	   This loop catches *all* input until you exit.
	   Always returns True"""
    # Bugs have been fixed but I need to spend some more
    # time with this to make it actually fit for some purpose
    console_surface = pygame.Surface((SPQR.CONSOLE_WIDTH, SPQR.CONSOLE_HEIGHT))
    console = pyconsole.Console(
        console_surface, (0, 0, SPQR.CONSOLE_WIDTH, SPQR.CONSOLE_HEIGHT),
        vars={"gui": SGFX.gui},
        functions={
            "exit": SGFX.gui.exitConsole,
            "dunits": SGFX.gui.cfuncs.showUnits,
            "drunits": SGFX.gui.cfuncs.showRomanUnits,
            "dpeople": SGFX.gui.cfuncs.showPeople,
            "windows": SGFX.gui.cfuncs.showWindows
        })
    # console needs to stay displayed
    SGFX.gui.console = True
    while (True):
        console.process_input()
        console.draw()
        SGFX.gui.screen.blit(console_surface, (0, SPQR.WINSZ_TOP - 2))
        pygame.display.flip()
        # are we still drawing the console?
        if SGFX.gui.console == False:
            break
        pygame.time.wait(10)
    # clean up the screen
    # since we only ever draw over the map, simply re-draw that
    SGFX.gui.updateMap()
    return True
Example #2
0
        def __init__(self):
            gimpui.Dialog.__init__(self, title=_("Python Console"),
                                   role=PROC_NAME, help_id=PROC_NAME,
                                   buttons=(gtk.STOCK_SAVE,  RESPONSE_SAVE,
                                            gtk.STOCK_CLEAR, RESPONSE_CLEAR,
                                            _("_Browse..."), RESPONSE_BROWSE,
                                            gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))

            self.set_alternative_button_order((gtk.RESPONSE_CLOSE,
                                               RESPONSE_BROWSE,
                                               RESPONSE_CLEAR,
                                               RESPONSE_SAVE))

            banner = ('Gimp %s Python Console\nPython %s\n' %
                      (gimp.pdb.gimp_version(), sys.version))

            self.cons = pyconsole.Console(locals=namespace, banner=banner,
                                          quit_func=lambda: gtk.main_quit())

            self.connect('response', self.response)

            self.browse_dlg = None
            self.save_dlg = None

            vbox = gtk.VBox(False, 12)
            vbox.set_border_width(12)
            self.vbox.pack_start(vbox)

            scrl_win = gtk.ScrolledWindow()
            scrl_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
            vbox.pack_start(scrl_win)

            scrl_win.add(self.cons)

            self.set_default_size(500, 500)
Example #3
0
 def show_console(self, *args):
     if not pyconsole:
         return
     window = gtk.Window()
     window.set_title("Gll Python Console")
     swin = gtk.ScrolledWindow()
     swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
     window.add(swin)
     console = pyconsole.Console(locals=globals())
     swin.add(console)
     window.set_default_size(500, 400)
     window.show_all()
Example #4
0
def startGame():
    game.map = None
    if game.mapFilename:
        game.map = mapgen.generator.Map(game.mapFilename)
        game.map.init()
        if game.shouldSaveImage:
            game.log.warn("Drawing the entire map was broken as part " +
                          "of the OpenGL transition. Sorry; I'll fix " +
                          "it when I can.")
            game.map.drawAll('%d.png' % game.seed)
        if game.shouldExitAfterMapgen:
            sys.exit()
    else:
        for i in xrange(0, game.numMaps):
            game.envEffectManager.reset()
            game.sceneryManager.reset()
            logger.inform("Making map %d of %d" % (i + 1, game.numMaps))
            if game.numMaps == 1:
                logger.inform("Using seed", game.seed)
                random.seed(str(game.seed))
            else:
                game.seed = int(time.time())
                logger.inform("Using seed", game.seed)
                random.seed(str(game.seed))
            game.map = mapgen.generator.Map()
            game.map.init()
            if game.shouldSaveImage:
                game.map.drawAll(str(game.seed) + '.png')
        if game.shouldExitAfterMapgen:
            sys.exit()
    game.gameObjectManager.setup()
    game.player = game.gameObjectManager.addNewObject(
        os.path.join('creatures', 'player', 'player'))
    #    game.gameObjectManager.addNewObject('creatures/darkclone/darkclone',
    #            game.player.loc.add(Vector2D(300, 0)))
    game.mapEditor.init()
    consoleFunctions = {
        'saveMap': game.map.writeMap,
        'edit': game.mapEditor.toggleActive,
        'editCon': game.mapEditor.toggleControlDisplay,
        'editGrid': game.mapEditor.toggleGridDisplay,
        'editType': game.mapEditor.setEditMode,
        'setTerrain': game.mapEditor.setTerrain,
        'setLogLevel': logger.setLogLevel,
        'setZoom': setZoom,
    }
    game.console = pyconsole.Console(
        game.screen, pygame.rect.Rect(0, 0, constants.sw, constants.sh),
        consoleFunctions)
    game.console.set_active(False)
Example #5
0
 def __init__(self, screen, grid):
     self.grid = grid
     self.top    = TopPane((LEFTINSET,TOPINSET))
     self.middle = MiddlePane((LEFTINSET, (TOPINSET + PANE_HEIGHT + PANE_SPACING)))
     self.bottom = BottomPane((LEFTINSET, (TOPINSET + 2 *(PANE_HEIGHT + PANE_SPACING))))
     #the name battle is hardcoded into pyconsole.py
     #self.defender = battle.Player()
     #self.attacker = battle.Player()
     
     self.battle = BattlePane((242, TOPINSET + 1), self.grid, tilesize=51, tiles=(16,16))
     self.game = Game(self.grid, self.battle.defender, self.battle.attacker,
                             self.battle)
     #console code
     self.console = pyconsole.Console(screen, (2,398,794,200))
     self.console.set_interpreter()
     self.last_action_type = None
Example #6
0
    def startup(self, api):
        """
		Initializes the extension.
		
		Parameters:
			api -- reference to the Jokosher extension API.
		"""
        self.api = api
        self.menuItem = self.api.add_menu_item("Extension Console",
                                               self.OnMenuItemClick)

        xmlString = pkg_resources.resource_string(__name__, "ConsoleDialog.ui")
        self.gtkBuilder = gtk.Builder()
        self.gtkBuilder.add_from_string(xmlString)

        self.savedStdin = sys.stdin
        sys.stdin = StdinWrapper()

        self.signals = {
            "OnClose": self.OnClose,
            "OnSearch": self.OnSearch,
        }

        self.gtkBuilder.connect_signals(self.signals)

        #the default namespace for the console
        self.namespace = {"jokosher": self.api.mainapp, "api": self.api}

        self.window = self.gtkBuilder.get_object("ConsoleDialog")
        self.vbox = self.gtkBuilder.get_object("ConsoleVBox")
        self.search = None
        self.swin = gtk.ScrolledWindow()
        self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.vbox.pack_start(self.swin)

        self.console = pyconsole.Console(banner=self.CONSOLE_BANNER,
                                         use_rlcompleter=False,
                                         locals=self.namespace)
        self.console.modify_font(pango.FontDescription("Monospace"))

        self.swin.add(self.console)
        self.window.hide()
Example #7
0
            if self.rect.bottom == bottom - 1: self.going_down = False
            elif self.rect.top == 0: self.going_down = True
            
            if self.going_down: self.rect.top += 1
            else: self.rect.top -= 1
        
            self.next_update_time = current_time + 10
        
pygame.init()
boxes = pygame.sprite.Group()
for color, location in [([255, 0, 0], [0, 0]), ([0, 255, 0], [60, 60]),
([0, 0, 255], [120, 120])]:
    boxes.add(UpDownBox(color, location))

screen = pygame.display.set_mode([800, 600])
console = pyconsole.Console(screen, (2,0,796,596),)
pygame.mouse.set_pos(300,240)
console.set_interpreter()

while pygame.key.get_pressed()[K_ESCAPE] == False:
    pygame.event.pump()
    screen.fill([0, 0, 0])
    console.process_input()
    boxes.update(pygame.time.get_ticks(), 150)
    for b in boxes: screen.blit(b.image, b.rect)
    console.draw()
    if console.active == 0:    
        for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key == K_w:
                    if pygame.key.get_mods() & KMOD_CTRL:
Example #8
0
newgame.init(root)
dialog.init(root)
quests.init(root)
eb.init_grufs(root)
faction.init(root)
lang.init()

import music
music.init()

root.gfxcursor = gfxcursor.GfxCursor(root, root.screen.screen)

root.particlemanager = particles.ParticleManager()

root.state_manager = state.StateManager(root)
root.console = pyconsole.Console(screen.image, (0, 0, 1300, 200),
                                 localsx=locals())

root.igconsole = overlay_gui.IngameRenderedConsole(root, 5)
root.igconsole.enable_debug()

root.game_time = 0
root.fps = 999

debug("Loaded all SG extensions")

root.renderspace_size = renderspace_size

info("Loading loader packages")
extention_loader.load_all_packages(root, 'loader')
info("Loading core packages")
root.loader_renderer = overlay_gui.IngameRenderedConsole(