def __init__(self): ShowBase.__init__(self) self.scene = self.loader.loadModel("field_1.obj", noCache=True) # Reparent the model to render. self.scene.reparentTo(self.render) self.scene.setPos(0, 0, 0) self.insertLight("MainLight", 25, 0, 75) self.insertLight("ExtraLight1", -25, 0, 75) self.resetSim() self.robot = SwerveBot() self.robot.loadModel() self.setupCones() self.overlay = Overlay() self.gamepad = GamePad_Logitech() self.gamepad.setupGamePad(self) #self.gamepad.startReportLoop() self.skidtrack = SkidTrack(nrects=100, wheel_width=1, zpos=4) self.skid_pos = (-5, -5) self.counter = 0 self.accept('r', self.reportStatus) self.accept('i', self.resetSim) self.accept('a', self.robot.toggleAutoDrive) self.accept('c', self.count) self.accept('s', self.skidtrackAdd) self.accept('escape', sys.exit)
def main(): """Just used to set up the engine and screen""" league.Settings.width = 800 league.Settings.height = 640 "Sets the size of the window. 800 x 640 is 25 x 20 32bit sprites" engine = league.Engine("Gricelda") engine.init_pygame() user = Player(engine, 5, 10) engine.objects.append(user) screen = Screen(user, engine) over = Overlay(user) engine.drawables.add(over) engine.objects.append(over) "Screen is passed the player to allow them to be changed by the world" " and engine to allow all world updates" engine.objects.append(screen) pygame.mixer.init() background_track = pygame.mixer.Sound("../assets/track6.ogg") background_track.play(-1) engine.drawables.remove(user) showTitleScreen(screen, engine) engine.drawables.add(user) engine.events[pygame.QUIT] = engine.stop engine.run()
def main() : e = league.Engine("Spook City") e.init_pygame() timer = pygame.time.set_timer(pygame.USEREVENT + 1, 1000 // league.Settings.gameTimeFactor) count = 0 p = Player(1, 400, 300) spawner = EnemySpawner(e,p) crate = createInteract(e,p) spawner.createEnemy(2,128,128) crate.createLanternContainer(2,128,300) crate.createBeartrapContainer(2,256,300) mapRenderer = MapRenderer("first room", e) world_size = mapRenderer.renderBackground() p.world_size = world_size mapRenderer.renderForeGround() d = Door(2, 300, 4, 300, 416, "second room", e) e.light_points = p.raycast_points e.player = p overlay = Overlay(p) e.overlay = overlay e.objects.append(p) e.objects.append(overlay) e.objects.append(d) # any objects to be created on the fly p.items = e.dynamic_instances p.interactables.add(d) # add all drawables e.drawables.add(p) e.drawables.add(d) mapRenderer.renderForeGround() p.resetx = 300 p.resety = 416 bgm = BackgroundMusic("lavender town") bgm.start_music() # add all impassable sprites to classes which need them for impassable in mapRenderer.getAllImpassables(): p.blocks.add(impassable) # create room object in engine e.room = Room(p, e, overlay) p.room = e.room e.key_events[pygame.K_a] = p.move_left e.key_events[pygame.K_d] = p.move_right e.key_events[pygame.K_w] = p.move_up e.key_events[pygame.K_s] = p.move_down e.key_events[pygame.K_e] = p.interact e.key_events[pygame.K_SPACE] = p.use_active_item e.key_events[pygame.K_ESCAPE] = e.stop e.events[pygame.QUIT] = e.stop e.run()
def open_overlay(self): view = ui.View(name='Trio') view.frame = (0, 0, 200, 1) view.flex = 'WH' view.background_color = 'white' o = Overlay(content=view, parent=AppWindows.root()) o.close_callback = self.close_down return o
def main(): engine = LeagueEngine.Engine("Tercio", '../Assets/Sprites/Branding/icon.png') engine.init_pygame() sprites = LeagueEngine.Spritesheet("./assets/base_chip_pipo.png", LeagueEngine.Settings.tile_size, 8) terrainFoliage = LeagueEngine.Tilemap("./assets/world.csv", "./assets/Collidables.csv", 30, 25, sprites, layer=1) terrainBackground = LeagueEngine.Tilemap("./assets/background.csv", "./assets/Collidables.csv", 30, 25, sprites, layer=0) world_size = ( terrainFoliage.wide * LeagueEngine.Settings.tile_size, terrainFoliage.high * LeagueEngine.Settings.tile_size, ) engine.drawables.add(terrainFoliage.passable.sprites()) engine.drawables.add(terrainBackground.passable.sprites()) ourPlayer = Player(2, 400, 300) o = Overlay(ourPlayer) ourPlayer.blocks.add(terrainFoliage.impassable) ourPlayer.world_size = world_size ourPlayer.rect = ourPlayer.image.get_rect() q = Player(10, 100, 100) q.image = ourPlayer.image engine.objects.append(ourPlayer) engine.objects.append(q) engine.drawables.add(ourPlayer) engine.drawables.add(q) engine.drawables.add(o) c = LeagueEngine.LessDumbCamera(800, 600, ourPlayer, engine.drawables, world_size) # c = LeagueEngine.DumbCamera(800, 600, p, e.drawables, world_size) engine.objects.append(c) engine.objects.append(o) engine.collisions[ourPlayer] = (q, ourPlayer.ouch) pygame.time.set_timer(pygame.USEREVENT + 1, 1000 // LeagueEngine.Settings.gameTimeFactor) # engine.key_events[pygame.K_a] = ourPlayer.move_left # engine.key_events[pygame.K_d] = ourPlayer.move_right # engine.key_events[pygame.K_w] = ourPlayer.move_up # engine.key_events[pygame.K_s] = ourPlayer.move_down engine.player = ourPlayer engine.events[pygame.USEREVENT + 1] = q.move_right engine.events[pygame.QUIT] = engine.stop engine.run()
def display_unit(block: PyJavaCodeBlock, parent: QWidget, pos_x, pos_y): popup = Overlay(parent, OverlayUnit(None, block)) popup.setGeometry(pos_x, pos_y, popup.size().width(), popup.size().height()) popup.show() popup.widget.setFocus() return popup
def display_overlay(self, parent, pos_x, pos_y): popup = Overlay(parent, CtmWidget()) # pos = QPoint(pos_x, pos_y) # self._popup.setGeometry(pos) popup.setGeometry(pos_x, pos_y, 320, 40) popup.show() return popup
def __init__(self, geometry, grid_update): self.x1 = 0 self.y1 = 0 self.x2 = geometry.width - 1 self.y2 = geometry.height - 1 self.click_type = 0 self.grid_update = grid_update self.overlay = Overlay(geometry, handler=self.key_event) self.update_overlay()
def __init__(self, dimensions, kbd, frame): self.frame = frame self.time = TimeHandler() self.time.pause() self.lastFrameTime = self.time.time() self.dimensions = dimensions self.back = Bg(dimensions, self.time) #creates a school of 30 fish self.fish = School(30, dimensions, self.time, self) self.keyboard = kbd self.overlay = Overlay(kbd, self, dimensions, self.frame) self.start(False)
def calWeight(self, x0, y0, x1, y1, angle_of_wheel): """ Returns a weight factor between zero and one depending on the direction of wheel travel and the direction of skid motion. """ angle_of_wheel = math.fmod(angle_of_wheel, 360.0) if angle_of_wheel < 0.0: angle_of_wheel = angle_of_wheel + 360 dy, dx = y1 - y0, x1 - x0 angle_of_motion = math.atan2(dy, dx) * 180 / math.pi if angle_of_motion < -360 or angle_of_motion > 360: print("WOW Angle of motion out of range: ", angle_of_motion, dy, dx) if angle_of_motion < 0.0: angle_of_motion = angle_of_motion + 360 # Calculate closest angle between angle = 180 - math.fabs( math.fabs(angle_of_wheel - angle_of_motion) - 180) Overlay().setText(5, "wheel: %5.1f" % angle_of_wheel) Overlay().setText(4, "motion: %5.1f" % angle_of_motion) Overlay().setText(3, "angle: %5.1f" % angle) Overlay().setText(2, "motion: %5.1f" % angle_of_motion) return angle / 180
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.viewport_y = 0 # top visible line self.imagemode = False self.image = None self.scroll_height = 0 self.scroll_width = 0 self.timer = QTimer(self) self.backuptimer = QTimer(self) self.connect(self.timer, SIGNAL("timeout()"), self.analysis_timer) self.connect(self.backuptimer, SIGNAL("timeout()"), self.backup_timer) self.backuptimer.start(30000) self.undotimer = QTimer(self) self.connect(self.undotimer, SIGNAL("timeout()"), self.trigger_undotimer) self.blinktimer = QTimer(self) self.blinktimer.start(500) self.connect(self.blinktimer, SIGNAL("timeout()"), self.trigger_blinktimer) self.show_cursor = True self.boxcolors = [ QColor("#DC322F"), QColor("#268BD2"), QColor("#2Ac598"), QColor("#D33682"), QColor("#B58900"), QColor("#859900") ] self.setCursor(Qt.IBeamCursor) # Semi-transparent overlay. # Used to display heat-map visualisation of profiler info, etc. self.overlay = Overlay(self) # Always show the overlay, users hide visualisations with the HUD. self.overlay.show() # Show / don't show HUD visualisations. self.hud_callgraph = False self.hud_eval = False self.hud_heat_map = False self.hud_types = False self.autolboxlines = {}
def display_default(block: PyJavaCodeBlock, parent: QWidget, pos_x, pos_y): popup = Overlay( parent, OverlayTip(None, lambda: TipCommand.on_tip_unit(block), lambda: TipCommand.on_tip_bb(block), lambda: TipCommand.on_tip_int(block), lambda: TipCommand.on_tip_float(block), lambda: TipCommand.on_tip_if(block), lambda: TipCommand.on_tip_for(block))) popup.setGeometry(pos_x, pos_y, popup.size().width(), popup.size().height()) popup.show() popup.widget.setFocus() return popup
def __init__(self, handler): threading.Thread.__init__(self) self.max_rate = 60 self.rate = Rate(self.max_rate) self.cursor_pos = (0, 0) self.image = cv2.imread('test.png') self.width = self.image.shape[1] self.height = self.image.shape[0] self.screen = None self.overlay = Overlay() self.name = "Roundabout Map" cv2.namedWindow(self.name) cv2.setMouseCallback(self.name, self.mouse_event) self.event = 200 self.handler = handler handler.overlay=self.overlay
def __init__(self, handler): threading.Thread.__init__(self) self.max_rate = 60 self.rate = Rate(self.max_rate) self.cursor_pos = (0, 0) # self.image = cv2.imread('test2.jpg') self.image = np.zeros((800, 800, 3)) self.width = self.image.shape[1] self.height = self.image.shape[0] self.screen = None self.zero = (400, 400) self.meter2pix_scale = 5.0 self.overlay = Overlay() self.name = "Roundabout Map" cv2.namedWindow(self.name) cv2.setMouseCallback(self.name, self.mouse_event) self.event = 200 self.handler = handler self.scenario = Scenario(handler) handler.overlay = self.overlay
def run(nsjail_bin, chroot, source_dir, command, android_target, dist_dir=None, build_id=None, max_cpus=None, user_id=None, group_id=None): """Run inside an NsJail sandbox. Args: nsjail_bin: A string with the path to the nsjail binary. chroot: A string with the path to the chroot. source_dir: A string with the path to the Android platform source. command: A list of strings with the command to run. android_target: A string with the name of the target to be prepared inside the container. dist_dir: A string with the path to the dist directory. build_id: A string with the build identifier. max_cpus: An integer with maximum number of CPUs. user_id: An integer with the user ID to run the build process under. group_id: An integer with the group ID to run the build process under. Returns: A list of commands that were executed. Each command is a list of strings. """ executed_commands = [] if user_id and group_id: commands = create_user(user_id, group_id) executed_commands.extend(commands) os.setgid(group_id) os.setuid(user_id) overlay = None # Apply the overlay for the selected Android target # to the source directory if overlays are present if os.path.exists(os.path.join(source_dir, 'overlays')): overlay = Overlay(android_target, source_dir) script_dir = os.path.dirname(os.path.abspath(__file__)) config_file = os.path.join(script_dir, 'nsjail.cfg') nsjail_command = [ nsjail_bin, '--bindmount', source_dir + ':/src', '--chroot', chroot, '--env', 'USER=android-build', '--config', config_file ] if dist_dir: nsjail_command.extend([ '--bindmount', dist_dir + ':/dist', '--env', 'DIST_DIR=/dist' ]) if build_id: nsjail_command.extend(['--env', 'BUILD_NUMBER=%s' % build_id]) if max_cpus: nsjail_command.append('--max_cpus=%i' % max_cpus) nsjail_command.append('--') nsjail_command.extend(command) print('NsJail command:') print(' '.join(nsjail_command)) subprocess.check_call(nsjail_command) executed_commands.append(nsjail_command) # Strip out overlay del overlay return executed_commands
def main(): e = league.Engine("The Lone Ranger") e.init_pygame() sprites = league.Spritesheet('./assets/base_chip_pipo.png', league.Settings.tile_size, 8) t = league.Tilemap('./assets/world.lvl', sprites, layer=1) b = league.Tilemap('./assets/background.lvl', sprites, layer=0) world_size = (t.wide * league.Settings.tile_size, t.high * league.Settings.tile_size) e.drawables.add(t.passable.sprites()) e.drawables.add(b.passable.sprites()) p = Player(2, 400, 300) o = Overlay(p) p.blocks.add(t.impassable) p.world_size = world_size p.rect = p.image.get_rect() e.drawables.add(p) e.drawables.add(o) c = league.LessDumbCamera(800, 600, p, e.drawables, world_size) e.objects.append(c) e.objects.append(o) wave = 1 zombieCount = 0 #Register events? pygame.time.set_timer(pygame.USEREVENT + 0, 250 // league.Settings.gameTimeFactor) pygame.time.set_timer(pygame.USEREVENT + 1, 250 // league.Settings.gameTimeFactor) #Player movements zombies = [] def shoot(time): now = pygame.time.get_ticks() if now - p.lastShot > 500: bullet = Bullet(p.direction, 10, p.x, p.y) e.objects.append(bullet) e.drawables.add(bullet) for z in zombies: e.collisions[z] = (bullet, z.ouch) p.lastShot = now ''' Spawns Zombies with a 25% freqency every 250ms ''' def spwanZombies(time): if p.zombieCount < p.wave * 5: if random.randint(1, 100) > 75: z = Zombie(p, 10, p.x, p.y) e.drawables.add(z) e.objects.append(z) e.collisions[z] = (p, p.ouch) p.zombieCount = p.zombieCount + 1 zombies.append(z) def moveAndShoot(time): keys = pygame.key.get_pressed() if keys[pygame.K_w] or keys[pygame.K_a] or keys[pygame.K_s] or keys[ pygame.K_d]: p.move(time, pygame.key.get_pressed()) if keys[pygame.K_SPACE]: shoot(time) ''' Moves zombies every 250ms ''' def updateZoms(time): for i in e.objects: if isinstance(i, Zombie): if random.randint(1, 100) > 25: i.move_towards_player(time) if i.health <= 0: e.objects.remove(i) e.drawables.remove(i) if isinstance(i, Bullet): if i.ttl > 10: i.kill() e.objects.remove(c) e.objects.append(c) e.key_events[pygame.K_a] = moveAndShoot e.key_events[pygame.K_d] = moveAndShoot e.key_events[pygame.K_w] = moveAndShoot e.key_events[pygame.K_s] = moveAndShoot e.key_events[pygame.K_SPACE] = moveAndShoot #Register zombie movements in event list e.events[pygame.USEREVENT] = updateZoms e.events[pygame.USEREVENT + 1] = spwanZombies #Sets up exit button to quit game e.events[pygame.QUIT] = e.stop #Runs the main game loop e.run()
def main(): """ Sets up all the relevent object needed to run the game. This includes the game engine, player, and all enemies in the game. The player and enemies load thier sprites from a list of paths in a json file that is loaded and referenced in a dict at the start. Once initalization finishes the game loop is run until the user exits. """ engine = neon_engine.NeonEngine('Neon Souls') engine.init_pygame() with open('player_sprites.json', 'r') as p_file: player_sprites = json.load(p_file) with open('sentinal_sprites.json') as file: sentinal_sprites = json.load(file) player_static = player_sprites['static_sprites'] player_walking = player_sprites['walking_sprites'] player_running = player_sprites['running_sprites'] sentinal_sprites = sentinal_sprites['sprite_list'] player = Player(player_static, player_walking, player_running, (128, 128), 'default', 2, 300, 400) engine.player_instance = player sentinal1 = SentinalEnemy(sentinal_sprites, (100, 100), [(400, 500), (600, 500)], engine.kill_enemy, 2, 300, 475) sentinal2 = SentinalEnemy(sentinal_sprites, (100, 100), [(1100, 0), (1300, 0)], engine.kill_enemy, 2, 1200, 400) sentinal3 = SentinalEnemy(sentinal_sprites, (100, 100), [(1500, 0), (1700, 0)], engine.kill_enemy, 2, 1600, 450) engine.enemy_list.append(sentinal1) engine.enemy_list.append(sentinal2) engine.enemy_list.append(sentinal3) gravity_manager = GravityManager() gravity_manager.add_gravity('default', (0, 15)) gravity_manager.add_object(player) # create background and level init_map(engine, player, gravity_manager) overlay = Overlay(player) engine.objects.append(overlay) engine.drawables.add(overlay) pygame.time.set_timer(pygame.USEREVENT + 1, 1000 // league.Settings.gameTimeFactor) engine.movement_function = player.move_player engine.action_function = fire engine.physics_functions.append(player.process_gravity) engine.events[pygame.QUIT] = engine.stop engine.run()
def __init__(self): super(OverlayParser, self).__init__() self.__sub_overlays = [] self.__sub_overlays.append( Overlay([['\.']], [Node(0.5, 0.5)], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.', '[^\.]'], ['[^\.]', '\.']], [ Edge(Node(0.5, 0.5, fusable=False), Node(1.5, 1.5, fusable=False)) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['[^\.]', '\.'], ['\.', '[^\.]']], [ Edge(Node(1.5, 0.5, fusable=False), Node(0.5, 1.5, fusable=False)) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.', '\.']], [ Edge(Node(0.5, 0.5, fusable=False), Node(1.5, 0.5, fusable=False)) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.'], ['\.']], [ Edge(Node(0.5, 0.5, fusable=False), Node(0.5, 1.5, fusable=False)) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.', '\|', '\.']], [ Edge(Node(0.5, 0.5), Node(2.5, 0.5), below=Edge(Node(1.5, 0), Node(1.5, 1))) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.'], ['-'], ['\.']], [ Edge(Node(0.5, 0.5), Node(0.5, 2.5), below=Edge(Node(0, 1.5), Node(1, 1.5))) ], options=['dotted'])) self.__sub_overlays.append( Overlay([['\.'], ['v']], [Edge(Node(0.5, 0.5), Node(0.5, 1.5))])) self.__sub_overlays.append( Overlay([['\^'], ['\.']], [Edge(Node(0.5, 0.5), Node(0.5, 1.5))])) self.__sub_overlays.append( Overlay([['\.', '>']], [Edge(Node(0.5, 0.5), Node(1.0, 0.5))])) self.__sub_overlays.append( Overlay([['<', '\.']], [Edge(Node(1.5, 0.5), Node(1.0, 0.5))])) self.__sub_overlays.append( Overlay([['=']], [Edge(Node(0, 0.5), Node(1, 0.5))], options=['emph'])) self.__sub_overlays.append( Overlay([['=', '[\|\.]', '=']], [ Edge(Node(1, 0.5), Node(2, 0.5), below=Edge(Node(1.5, 0), Node(1.5, 1))) ], options=['emph'])) self.__sub_overlays.append(Overlay([['\+']], [Node(0.5, 0.5)])) self.__sub_overlays.append( Overlay([['-']], [Edge(Node(0, 0.5), Node(1, 0.5))])) self.__sub_overlays.append( Overlay([['\|']], [Edge(Node(0.5, 0), Node(0.5, 1))])) self.__sub_overlays.append( Overlay([['/']], [Edge(Node(0, 1), Node(1, 0))])) self.__sub_overlays.append( Overlay([["\\\\"]], [Edge(Node(1, 1), Node(0, 0))])) self.__sub_overlays.append( Overlay([["[^-]", '\|', '-']], [Edge(Node(1.5, 0.5), Node(2, 0.5))])) self.__sub_overlays.append( Overlay([['-', '\|', "[^-]"]], [Edge(Node(1.5, 0.5), Node(1, 0.5))])) self.__sub_overlays.append( Overlay([["[^\|]"], ['-'], ['\|']], [Edge(Node(0.5, 1.5), Node(0.5, 2))])) self.__sub_overlays.append( Overlay([['\|'], ['-'], ["[^\|]"]], [Edge(Node(0.5, 1.5), Node(0.5, 1))])) self.__sub_overlays.append( Overlay([['-', '[\|\.]', '-']], [ Edge(Node(1, 0.5), Node(2, 0.5), below=Edge(Node(1.5, 0), Node(1.5, 1))) ])) self.__sub_overlays.append( Overlay([['\|'], ['[-\.=]'], ['\|']], [ Edge(Node(0.5, 1), Node(0.5, 2), below=Edge(Node(0, 1.5), Node(1, 1.5))) ])) self.__sub_overlays.append( Overlay([['\+', '-']], [Edge(Node(0.5, 0.5, fusable=False), Node(1, 0.5))])) self.__sub_overlays.append( Overlay([['-', '\+']], [Edge(Node(1, 0.5), Node(1.5, 0.5, fusable=False))])) self.__sub_overlays.append( Overlay([['\+'], ['\|']], [Edge(Node(0.5, 0.5, fusable=False), Node(0.5, 1))])) self.__sub_overlays.append( Overlay([['\|'], ['\+']], [Edge(Node(0.5, 1), Node(0.5, 1.5, fusable=False))])) self.__sub_overlays.append( Overlay([[None, '/'], ['\+', None]], [Edge(Node(1, 1), Node(0.5, 1.5, fusable=False))])) self.__sub_overlays.append( Overlay( [['[^\+\*]', '\*'], ['\+', '[^\+\*]']], [Edge(Node(1.5, 0.5, 'curve'), Node(0.5, 1.5, fusable=False)) ])) self.__sub_overlays.append( Overlay( [['\*', '[^\+\*]'], ['[^\+\*]', '\+']], [Edge(Node(0.5, 0.5, 'curve'), Node(1.5, 1.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([['\+', '[^\+\*]'], ['[^\+\*]', '\+']], [ Edge(Node(0.5, 0.5, fusable=False), Node(1.5, 1.5, fusable=False)) ])) self.__sub_overlays.append( Overlay( [['[^\+\*]', '\+'], ['\*', '[^\+\*]']], [Edge(Node(1.5, 0.5), Node(0.5, 1.5, 'curve', fusable=False)) ])) self.__sub_overlays.append( Overlay([['[^\+\*]', '\+'], ['\+', '[^\+\*]']], [ Edge(Node(1.5, 0.5, fusable=False), Node(0.5, 1.5, fusable=False)) ])) self.__sub_overlays.append( Overlay( [['\+', '[^\+\*]'], ['[^\+\*]', '\*']], [Edge(Node(0.5, 0.5), Node(1.5, 1.5, 'curve', fusable=False)) ])) self.__sub_overlays.append( Overlay([["\\\\", None], [None, '\+']], [Edge(Node(1, 1), Node(1.5, 1.5, fusable=False))])) self.__sub_overlays.append( Overlay([['\+', None], [None, "\\\\"]], [Edge(Node(0.5, 0.5, fusable=False), Node(1, 1))])) self.__sub_overlays.append( Overlay([[None, '\+'], ['/', None]], [Edge(Node(1.5, 0.5, fusable=False), Node(1, 1))])) self.__sub_overlays.append( Overlay([['\|'], ['\*']], [Edge(Node(0.5, 1), Node(0.5, 1.5, 'curve'))])) self.__sub_overlays.append( Overlay([['\*'], ['\|']], [Edge(Node(0.5, 0.5, 'curve'), Node(0.5, 1))])) self.__sub_overlays.append( Overlay([['\*', '-']], [Edge(Node(0.5, 0.5, 'curve'), Node(1, 0.5))])) self.__sub_overlays.append( Overlay([['-', '\*']], [Edge(Node(1, 0.5), Node(1.5, 0.5, 'curve'))])) self.__sub_overlays.append( Overlay([['\+', '\+']], [ Edge(Node(0.5, 0.5, fusable=False), Node(1.5, 0.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([['\+'], ['\+']], [ Edge(Node(0.5, 0.5, fusable=False), Node(0.5, 1.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([['\|'], ['v']], [Edge(Node(0.5, 1), Node(0.5, 1.5))])) self.__sub_overlays.append( Overlay([['\^'], ['\|']], [Edge(Node(0.5, 0.5), Node(0.5, 1))])) # self.__sub_overlays.append(Overlay([['-', '>']], [Edge(Node(1, 0.5), Node(1.5, 0.5))])) # self.__sub_overlays.append(Overlay([['<', '-']], [Edge(Node(1, 0.5), Node(0.5, 0.5))])) self.__sub_overlays.append( Overlay([['\+'], ['v']], [Edge(Node(0.5, 0.5), Node(0.5, 1.5))])) self.__sub_overlays.append( Overlay([['\^'], ['\+']], [Edge(Node(0.5, 0.5), Node(0.5, 1.5))])) self.__sub_overlays.append( Overlay([['\+', '>']], [Edge(Node(0.5, 0.5), Node(1.0, 0.5))])) self.__sub_overlays.append( Overlay([['<', '\+']], [Edge(Node(1.5, 0.5), Node(1.0, 0.5))])) self.__sub_overlays.append( Overlay([['\*', '\*']], [Edge(Node(0.5, 0.5, 'curve'), Node(1.5, 0.5, 'curve'))])) self.__sub_overlays.append( Overlay([['\*'], ['\*']], [Edge(Node(0.5, 0.5, 'curve'), Node(0.5, 1.5, 'curve'))])) self.__sub_overlays.append( Overlay([['[^\+\*]', '\*'], ['\*', '[^\+\*]']], [Edge(Node(1.5, 0.5, 'curve'), Node(0.5, 1.5, 'curve'))])) self.__sub_overlays.append( Overlay([['\*', '[^\+\*]'], ['[^\+\*]', '\*']], [Edge(Node(0.5, 0.5, 'curve'), Node(1.5, 1.5, 'curve'))])) crossing_top = (1.0 - OverlayParser.CROSSING_LENGTH) / 2.0 crossing_bottom = 1.0 - (1.0 - OverlayParser.CROSSING_LENGTH) / 2.0 crossing_top_curve = crossing_top + OverlayParser.CROSSING_LENGTH / 5.0 crossing_bottom_curve = crossing_bottom - OverlayParser.CROSSING_LENGTH / 5.0 crossing_left = 0.5 - OverlayParser.CROSSING_HEIGHT crossing_right = 0.5 + OverlayParser.CROSSING_HEIGHT left_bracked_node_list = [ Edge(Node(0.5, 0), Node(0.5, crossing_top)), Edge(Node(0.5, crossing_top), Node(crossing_left, crossing_top)), Edge(Node(crossing_left, crossing_top), Node(crossing_left, crossing_bottom), z_order='above'), Edge(Node(0.5, crossing_bottom), Node(crossing_left, crossing_bottom)), Edge(Node(0.5, 1), Node(0.5, crossing_bottom)) ] right_bracket_node_list = [ Edge(Node(0.5, 0), Node(0.5, crossing_top)), Edge(Node(0.5, crossing_top), Node(crossing_right, crossing_top)), Edge(Node(crossing_right, crossing_top), Node(crossing_right, crossing_bottom), z_order='above'), Edge(Node(0.5, crossing_bottom), Node(crossing_right, crossing_bottom)), Edge(Node(0.5, 1), Node(0.5, crossing_bottom)) ] left_parentheses_node_list = [ Edge(Node(0.5, 0, 'curve', fusable=False), Node(0.5, crossing_top, 'curve')), Edge(Node(0.5, crossing_top, 'curve'), Node(crossing_left, crossing_top_curve, 'curve')), Edge(Node(crossing_left, crossing_top_curve, 'curve'), Node(crossing_left, crossing_bottom_curve, 'curve'), z_order='above'), Edge(Node(0.5, crossing_bottom, 'curve'), Node(crossing_left, crossing_bottom_curve, 'curve')), Edge(Node(0.5, 1, 'curve', fusable=False), Node(0.5, crossing_bottom, 'curve', fusable=False)) ] right_parentheses_node_list = [ Edge(Node(0.5, 0, 'curve', fusable=False), Node(0.5, crossing_top, 'curve')), Edge(Node(0.5, crossing_top, 'curve'), Node(crossing_right, crossing_top_curve, 'curve')), Edge(Node(crossing_right, crossing_top_curve, 'curve'), Node(crossing_right, crossing_bottom_curve, 'curve'), z_order='above'), Edge(Node(0.5, crossing_bottom, 'curve'), Node(crossing_right, crossing_bottom_curve, 'curve')), Edge(Node(0.5, 1, 'curve', fusable=False), Node(0.5, crossing_bottom, 'curve', fusable=False)) ] self.__sub_overlays.append(Overlay([['\[']], left_bracked_node_list)) self.__sub_overlays.append(Overlay([['\]']], right_bracket_node_list)) self.__sub_overlays.append( Overlay([['\(']], left_parentheses_node_list)) self.__sub_overlays.append( Overlay([['\)']], right_parentheses_node_list)) crossing_left = (1.0 - OverlayParser.CROSSING_LENGTH) / 4.0 crossing_right = 1.0 - (1.0 - OverlayParser.CROSSING_LENGTH) / 4.0 crossing_left_curve = crossing_left + OverlayParser.CROSSING_LENGTH / 5.0 crossing_right_curve = crossing_right - OverlayParser.CROSSING_LENGTH / 5.0 crossing_top = 0.5 - OverlayParser.CROSSING_HEIGHT / 2 tilde_node_list = [ Edge(Node(0, 0.5, 'curve', fusable=False), Node(crossing_left, 0.5, 'curve')), Edge(Node(crossing_left, 0.5, 'curve'), Node(crossing_left_curve, crossing_top, 'curve')), Edge(Node(crossing_left_curve, crossing_top, 'curve'), Node(crossing_right_curve, crossing_top, 'curve'), z_order='above'), Edge(Node(crossing_right_curve, crossing_top, 'curve'), Node(crossing_right, 0.5, 'curve')), Edge(Node(crossing_right, 0.5, 'curve'), Node(1, 0.5, 'curve', fusable=False)) ] self.__sub_overlays.append(Overlay([['\~']], tilde_node_list)) for crossing_indicator in ['\[', '\]', '\(', '\)']: self.__sub_overlays.append( Overlay([['-', crossing_indicator]], [ Edge(Node(1, 0.5, fusable=False), Node(1.5, 0.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([[crossing_indicator, '-']], [ Edge(Node(0.5, 0.5, fusable=False), Node(1, 0.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([['\~'], ['\|']], [ Edge(Node(0.5, 1, fusable=False), Node(0.5, 0.5, fusable=False)) ])) self.__sub_overlays.append( Overlay([['\|'], ['\~']], [ Edge(Node(0.5, 1, fusable=False), Node(0.5, 1.5, fusable=False)) ])) return
def __init__(self): # PREPARE LOGGING FIRST TO ENSURE # THE ABILITY TO OUTPUT ERROR LOGS # # create logging folders self._makeLogDirs() # initialise the logger self.logger = self._setLogger() # catch exceptions to log them try: # call parent class constructor Configurable.__init__(self, self.SLF_PATH) # initialise overlay self.overlay = Overlay(f'{self.PRG_NAME.upper()} {self.PRG_VERS}') # point pytesseract at tesseract installation self._setPyTesseract() # initialise a lobby reader self.lobby_reader = LobbyReader() # initialise a loot reader self.loot_reader = LootReader() # initialise a bounty reader self.bounty_reader = BountyReader() # initialise a data sender self.data_sender = DataSender() # read user from config file self.user = self._setUser() # read game patch self.patch = self._setGamePatch() # initialise screen capture as empty self.screen_capture = None # data holders self.bounty_data = {} self.lobby_data = {} self.loot_data = [] # exception counter for repeated issue handling self.exc_counter = 0 # welcome the user self.welcomeMessage() except Exception as e: # log the exception self.logger.error(str(e)) # shut down the app quit()
from PyQt5.QtCore import QTimer from fbs_runtime.application_context.PyQt5 import ApplicationContext from overlay import Overlay if __name__ == '__main__': app_context = ApplicationContext() overlay = Overlay(app_context) gui_updater_timer = QTimer(overlay) gui_updater_timer.timeout.connect(overlay.gui_updater) gui_updater_timer.start(100) overlay.show() app_context.app.exec_()