async def f_add(ctx, shipid: int): """Add a ship to the user's fleet.""" if (not setting('features.fleets_enabled')): await ctx.send("That feature is not enabled.") return did = ctx.author.id fleet = userinfo.UserFleet.instance(1, did) inv = userinfo.get_user_inventory(did) ins = [x for x in inv.inventory if x.invid == shipid] if (len(ins) > 0): ins = ins.pop() if (shipid not in fleet.ships): if (not fleet.has_similar(ins.sid)): if (len(fleet.ships) < setting('fleets.fleet_capacity')): fleet.ships.append(shipid) fleet.update() await ctx.send(namesub("Added %s to <fleet> %s\n\n%s: *%s*") % ( ins.base().name, 1, ins.base().name, ins.base().get_quote('fleet_join'))) else: await ctx.send(namesub("<fleet.title> %s is full!" % (1))) else: await ctx.send(namesub("You already have another %s in <fleet> %s!") % (ins.base().name, 1)) else: await ctx.send(namesub("%s is already in <fleet> %s!") % (ins.base().name, 1)) else: await ctx.send(namesub("<ship.title> with ID %s not found in your inventory") % ( shipid))
async def cooldowns(ctx): """Show how much time left the user has before performing actions.""" did = ctx.author.id cd_check = [] if (setting('features.drop_enabled')): cd_check.append(("Last_Drop", "Drop", DROP_COOLDOWN)) if (setting('features.training_enabled')): cd_check.append(("Last_Training", namesub("<fleet.title> Training"), TRAINING_COOLDOWN)) if (setting('features.crafting_enabled')): cd_check.append(("Last_Craft", "Crafting", CRAFTING_COOLDOWN)) if (len(cd_check) == 0): await ctx.send("That feature is not enabled.") return msg = "Current cooldowns for %s:\n" % ctx.author.display_name msg += "```\n" for cd, name, cd_s in cd_check: t = userinfo.check_cooldown(did, cd, cd_s, set_if_off=False) if (t > 0): hrs = t // 3600 min = t // 60 % 60 sec = t % 60 msg += "%s: %dh%02dm%02ds remaining\n" % (name, hrs, min, sec) else: msg += "%s: Available!\n" % (name) msg += "```" await ctx.send(msg)
def logged(): db = mysql.connector.connect(host="35.229.93.150", user="******", passwd="Durks.321", database="app_login") cursor = db.cursor() delete_user = ("DELETE FROM user_login WHERE user_name = %s") loop = 1 while loop == 1: print("Main menu: ") choice = input( "1. Settings \n2. Delete User \n3. Exit \nEnter a Number from the menu: \n" ) if choice == '1': loop = 0 db.close settings.setting() else: if choice == '2': loop = 0 db.close user = input("Please enter your username to confirm: \n") cursor.execute(delete_user, [(user)]) else: if choice == '3': loop = 0 db.close exit else: print("Enter one of the numbers listed above.")
def __init__(self): self._id = 'grid' self._current_layout = int(setting('initial_layout_grid', 0)) self._current_diff_mode = int(setting('initial_diff_grid', 0)) self._current_scrollbind = boolsetting('initial_scrollbind_grid') self._number_of_diff_modes = 2 self._number_of_layouts = 3 return super(GridMode, self).__init__()
def setlocal_buffers(): buffers.original.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.one.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.two.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.result.open() if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.hud.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') vim.command('setlocal nobuflisted') vim.command('setlocal buftype=nofile') vim.command('setlocal noundofile') vim.command('setlocal nolist') vim.command('setlocal ft=splice') vim.command('setlocal nowrap') vim.command('resize ' + setting('hud_size', '3'))
def setlocal_buffers(): buffers.original.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.one.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.two.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.result.open() if setting('wrap'): vim.command('setlocal ' + setting('wrap')) buffers.hud.open() vim.command('setlocal noswapfile') vim.command('setlocal nomodifiable') vim.command('setlocal nobuflisted') vim.command('setlocal buftype=nofile') vim.command('setlocal noundofile') vim.command('setlocal nolist') vim.command('setlocal ft=threesome') vim.command('setlocal nowrap') vim.command('resize ' + setting('hud_size', '3'))
def __init__(self): self._id = 'loup' self._current_layout = int(setting('initial_layout_loupe', 0)) self._current_diff_mode = int(setting('initial_diff_loupe', 0)) self._current_scrollbind = boolsetting('initial_scrollbind_loupe') self._number_of_diff_modes = 1 self._number_of_layouts = 1 self._current_buffer = buffers.result return super(LoupeMode, self).__init__()
def __init__(self): self._id = 'path' self._current_layout = int(setting('initial_layout_path', 0)) self._current_diff_mode = int(setting('initial_diff_path', 0)) self._current_scrollbind = boolsetting('initial_scrollbind_path') self._number_of_diff_modes = 5 self._number_of_layouts = 2 self._current_mid_buffer = buffers.one return super(PathMode, self).__init__()
def __init__(self): self._id = 'comp' self._current_layout = int(setting('initial_layout_compare', 0)) self._current_diff_mode = int(setting('initial_diff_compare', 0)) self._current_scrollbind = boolsetting('initial_scrollbind_compare') self._number_of_diff_modes = 2 self._number_of_layouts = 2 self._current_buffer_first = buffers.original self._current_buffer_second = buffers.result return super(CompareMode, self).__init__()
def diffoff(self): with windows.remain(): for winnr in range(2, 2 + self._number_of_windows): windows.focus(winnr) curbuffer = buffers.current for buffer in buffers.all: buffer.open() vim.command('diffoff') if setting('wrap'): vim.command('setlocal ' + setting('wrap')) curbuffer.open()
async def craft(ctx, fuel: int, ammo: int, steel: int, bauxite: int): """Craft a random ship based on the user's inputted resources.""" did = ctx.author.id user = userinfo.get_user(did) if (not setting('features.crafting_enabled') or not setting('features.resources_enabled')): await ctx.send("That feature is not enabled.") return if (userinfo.has_space_in_inventory(did)): cd = userinfo.check_cooldown( did, 'Last_Craft', CRAFTING_COOLDOWN, set_if_off=False) if (cd == 0): min_craft = setting('resources.min_crafting') if (fuel >= min_craft[0] and ammo >= min_craft[1] and steel >= min_craft[2] and bauxite >= min_craft[3]): if (user.has_enough(fuel, ammo, steel, bauxite)): craft = craftinghandler.get_craft_from_resources( did, fuel, ammo, steel, bauxite) user.mod_fuel(-fuel) user.mod_ammo(-ammo) user.mod_steel(-steel) user.mod_bauxite(-bauxite) inv = userinfo.get_user_inventory(did) inv.add_to_inventory(craft) # set cooldown userinfo.check_cooldown( did, 'Last_Craft', CRAFTING_COOLDOWN, set_if_off=True) image_file = imggen.generate_ship_card(ctx.bot, craft) ship_base = craft.base() await ctx.send( file=discord.File(io.BytesIO(image_file.getvalue()), filename="image.png"), content="%s just crafted %s!\n\n%s: *%s*" % ( ctx.author.display_name, ship_base.name, ship_base.name, ship_base.get_quote('intro'))) logging.info("[Craft] %s (%s) crafted %s using recipe " "%s/%s/%s/%s" % (str(ctx.author), did, ship_base.name, fuel, ammo, steel, bauxite)) else: await ctx.send("Not enough resources!") else: await ctx.send("Use at least 30 of each resource") else: min = cd // 60 sec = cd % 60 await ctx.send("You have %dm%02ds remaining until you can craft " "another ship" % (min, sec)) else: await ctx.send(namesub("Your inventory is full! You can scrap a <ship.title> with " "`%sscrap [<ship.title> ID]`") % COMMAND_PREFIX)
async def on_message(message): """Run when a user sends a message that the bot can see.""" if (not message.author.bot): did = message.author.id if (isinstance(message.channel, discord.DMChannel)): targ_server = 245830822580453376 targ_channel = 446559630315749376 chnl = bot.get_guild(targ_server).get_channel(targ_channel) msg = "%s#%s: %s" % (message.author.name, message.author.discriminator, message.content) await chnl.send(msg) logging.info("[PM] %s" % msg) elif (userinfo.check_cooldown(did, 'Last_Bonus', BONUS_COOLDOWN) == 0): user = userinfo.get_user(did) user.mod_fuel(setting_random('resources.passive_gain.fuel')) user.mod_ammo(setting_random('resources.passive_gain.ammo')) user.mod_steel(setting_random('resources.passive_gain.steel')) user.mod_bauxite(setting_random('resources.passive_gain.bauxite')) fleet = userinfo.UserFleet.instance(1, did) if (setting('features.levels_enabled') and len(fleet.ships) > 0): si_flag = fleet.get_ship_instances()[0] flag_exp = setting_random('levels.passive_flag_bonus') lvl = si_flag.add_exp(flag_exp) if (lvl): await message.channel.send("**%s** - *%s* has leveled up! " "(Level %s!)" % (message.author.display_name, si_flag.base().name, si_flag.level)) await bot.process_commands(message)
async def remodel(ctx, shipid: int): """Remodel the given ship.""" if (not setting('features.levels_enabled')): await ctx.send("That feature is not enabled.") return did = ctx.author.id inv = userinfo.get_user_inventory(did) ins = [x for x in inv.inventory if x.invid == shipid] if (len(ins) > 0): ship_instance = ins.pop() base = ship_instance.base() if (base.remodels_into): if (ship_instance.is_remodel_ready()): old_name = base.name ship_instance.sid = base.remodels_into base = ship_instance.base() new_name = base.name userinfo.update_ship_sid(ship_instance) image_file = imggen.generate_ship_card(ctx.bot, ship_instance) await ctx.send(file=discord.File( io.BytesIO(image_file.getvalue()), filename="image.png"), content="%s: *%s*" % (new_name, base.get_quote('remodel') )) logging.info("[Remodel] %s (%s) remodelled %s into %s" % (str(ctx.author), did, old_name, new_name)) else: await ctx.send("%s isn't ready for a remodel just yet." % ( base.name)) else: await ctx.send("%s doesn't have another remodel." % (base.name)) else: await ctx.send(namesub("<ship.title> with ID %s not found in your inventory") % ( shipid))
def run_game(): #初始化游戏并创建一个屏幕对象 pygame.init() ai_settings = setting() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_heigh)) pygame.display.set_caption('Alien Invasion') #创建一艘飞船 ship = Ship(ai_settings, screen) #开始游戏主循环 while True: #监视鼠标和键盘 gf.check_events(ship) #更新飞机位置 ship.update() #重绘屏幕颜色 gf.update_screen(ai_settings, screen, ship) #最近绘制屏幕可见 pygame.display.flip()
async def fleet(ctx): """Base command for fleet management, shows the current fleet.""" if (not setting('features.fleets_enabled')): await ctx.send("That feature is not enabled.") return if (not ctx.invoked_subcommand): did = ctx.author.id fleet = userinfo.UserFleet.instance(1, did) if(len(fleet.ships) > 0): ins = fleet.get_ship_instances() fleet_lvl = sum(x.level for x in ins) // len(ins) embed = discord.Embed(title=namesub("%s's <fleet.title>") % str(ctx.author)) embed.color = 524358 flag = ins.pop(0) embed.add_field(name=namesub('<ship.title>'), value=flag.base().stype + " " + flag.base().name + " (*)\n" + "\n".join([x.base().stype + " " + x.base().name for x in ins]), inline=True) ins.insert(0, flag) embed.add_field(name="Level", value="\n".join( [str(x.level) for x in ins]), inline=True) embed.add_field(name="ID", value="\n".join( ["%04d" % (x.invid) for x in ins]), inline=True) embed.set_footer(text=namesub("<fleet.title> level %d") % fleet_lvl) await ctx.send(embed=embed) else: await ctx.send(namesub("<fleet.title> %s is empty!" % (1)))
def run(self, edit, caller=None): project_dir = self.view.window().folders()[0] ctags_file_path = os.path.join(project_dir, setting('ctags_file')) if not os.path.isfile(ctags_file_path): sublime.status_message("There's no ctags file for ClassHierarchy. Please check the settings or build the file with 'rebuild_hierarchy_ctags' command.") return global is_hierarchy_tree_in_loading if is_busy(): return is_hierarchy_tree_in_loading = True unload_hierarchy_tree(project_dir) sublime.status_message("Re/Loading hierarchy tree... Please be patient.") thread = ReloadHierarchyTreeThread(project_dir, ctags_file_path) if caller: if caller['symbol']: did_finished = lambda: self.view.run_command(to_underscore(caller['name']), {'symbol': caller['symbol'], 'window': caller['window']}) else: did_finished = lambda: self.view.run_command(to_underscore(caller['name']), {'no_symbol': True, 'window': caller['window']}) else: did_finished = lambda: sublime.status_message("Re/Loading hierarchy tree is finished!") thread.start() sublime.set_timeout(lambda: check_if_thread_finished(thread, did_finished), 500)
def bind_for_all(key, to, options='', mode=None, leader=None): if not leader: leader = setting('prefix', '-') with buffers.remain(): for b in buffers.all: b.open() bind(key, to, options, mode, leader)
def unbind_for_all(key, options='', leader=None): if not leader: leader = setting('prefix', '-') with buffers.remain(): for b in buffers.all: b.open() unbind(key, options, leader)
def run(self, edit): global is_hierarchy_ctags_in_building if is_busy(): return is_hierarchy_ctags_in_building = True project_dir = self.view.window().folders()[0] unload_hierarchy_tree(project_dir) sublime.status_message("Re/Building hierarchy ctags... Please be patient.") thread = RebuildHierarchyCtagsThread(setting('ctags_command'), setting('ctags_file'), project_dir) did_finished = lambda: self.view.run_command('reload_hierarchy_tree') thread.start() sublime.set_timeout(lambda: check_if_thread_finished(thread, did_finished), 500)
def unbind_for_all(key, options='', leader=None): if not leader: leader = setting('leader', '<localleader>') with buffers.remain(): for b in buffers.all: b.open() unbind(key, options, leader)
def bind_for_all(key, to, options='', mode=None, leader=None): if not leader: leader = setting('leader', '<localleader>') with buffers.remain(): for b in buffers.all: b.open() bind(key, to, options, mode, leader)
async def f_flag(ctx, flagship: int): """Set the flagship for the user's fleet.""" if (not setting('features.fleets_enabled')): await ctx.send("That feature is not enabled.") return did = ctx.author.id fleet = userinfo.UserFleet.instance(1, did) inv = userinfo.get_user_inventory(did) ins = [x for x in inv.inventory if x.invid == flagship] if (len(ins) > 0): ins = ins.pop() cancel = False if (len(fleet.ships) > 0): old_flag = fleet.ships.pop(0) if (not old_flag == flagship): if (flagship in fleet.ships): fleet.ships.remove(flagship) else: if (len(fleet.ships) > setting('fleets.fleet_capacity')): cancel = True await ctx.send(namesub("<fleet.title> %s is full!") % (1)) if ins.sid in map(lambda x: [y for y in inv.inventory if y.invid == x].pop().sid, fleet.ships): cancel = True await ctx.send(namesub("You already have another %s in <fleet> " "%s!") % (ins.base().name, 1)) fleet.ships.append(old_flag) else: cancel = True await ctx.send(namesub("%s is already <flagship> of <fleet> %s!") % ( ins.base().name, 1)) fleet.ships.insert(0, flagship) else: fleet.ships = [flagship, ] if (not cancel): fleet.update() await ctx.send(namesub("Set %s as the <flagship> of <fleet> %s\n\n%s: *%s*") % ( ins.base().name, 1, ins.base().name, ins.base().get_quote('fleet_join'))) else: await ctx.send(namesub("<ship.title> with ID %s not found in your inventory") % ( flagship))
async def f_clear(ctx): """Clear a user's fleet.""" if (not setting('features.fleets_enabled')): await ctx.send("That feature is not enabled.") return did = ctx.author.id fleet = userinfo.UserFleet.instance(1, did) fleet.ships = [] fleet.update() await ctx.send(namesub("Cleared <fleet> %s!") % (1))
def redraw_hud(self): with windows.remain(): windows.focus(1) vim.command('setlocal modifiable') buffers.hud.set_lines(self.hud_lines()) vim.command('setlocal nomodifiable') vim.command('set winfixheight') vim.command('resize ' + setting('hud_size', '3')) vim.command('wincmd =')
def mod_bauxite(self, delta): """Add bauxite to the user. Parameters ---------- delta : int Amount to add, can be negative. """ if (setting('features.resources_enabled')): self.bauxite += delta self.bauxite = max(0, min(RESOURCE_CAP, self.bauxite)) self.set_col("RBauxite", self.bauxite)
def run(self, edit): global is_hierarchy_ctags_in_building if is_busy(): return is_hierarchy_ctags_in_building = True project_dir = self.view.window().folders()[0] unload_hierarchy_tree(project_dir) sublime.status_message( "Re/Building hierarchy ctags... Please be patient.") thread = RebuildHierarchyCtagsThread(setting('ctags_command'), setting('ctags_file'), project_dir) did_finished = lambda: self.view.run_command('reload_hierarchy_tree') thread.start() sublime.set_timeout( lambda: check_if_thread_finished(thread, did_finished), 500)
def mod_ammo(self, delta): """Add ammo to the user. Parameters ---------- delta : int Amount to add, can be negative. """ if (setting('features.resources_enabled')): self.ammo += delta self.ammo = max(0, min(RESOURCE_CAP, self.ammo)) self.set_col("RAmmo", self.ammo)
def mod_fuel(self, delta): """Add fuel to the user. Parameters ---------- delta : int Amount to add, can be negative. """ if (setting('features.resources_enabled')): self.fuel += delta self.fuel = max(0, min(RESOURCE_CAP, self.fuel)) self.set_col("RFuel", self.fuel)
async def backup_task(): """Automatically back up the user database.""" await bot.wait_until_ready() if (not setting('backups.enabled')): logging.info("Backups not enabled, stopping task...") return DIR_PATH = os.path.dirname(os.path.realpath(__file__)) DB_PATH = os.path.join(DIR_PATH, "../usersdb.db") # hidden to git BACKUP_DIR = os.path.join(DIR_PATH, setting('backups.backup_folder_local')) await asyncio.sleep(20) while not bot.is_closed(): now = datetime.datetime.now() backup_name = "usersdb-backup-%s.db" % ( now.strftime("%y-%m-%d.%H-%M-%S")) backup_file = os.path.join(BACKUP_DIR, backup_name) backup_file = str(os.path.realpath(backup_file)).replace('\\', '\\\\') db_loc = str(os.path.realpath(DB_PATH)) logging.info("Creating backup %s..." % backup_file) subprocess.check_output( ['sqlite3', db_loc, '.backup %s' % backup_file]) await asyncio.sleep(setting('backups.backup_time'))
async def f_set(ctx, *ships): """Set the user's fleet to the given ships.""" if (not setting('features.fleets_enabled')): await ctx.send("That feature is not enabled.") return did = ctx.author.id fleet = userinfo.UserFleet.instance(1, did) inv = userinfo.get_user_inventory(did) sids_raw = map(int, ships) sids_raw = [x for x in sids_raw if x > 0 and x in map(lambda n: n.invid, inv.inventory)] # check for no dupes while still keeping order sids = [] for x in sids_raw: if x in sids: continue sid = [y for y in inv.inventory if y.invid == x].pop().sid if sid in map(lambda y: [z for z in inv.inventory if z.invid == y] .pop().sid, sids): continue sids.append(x) if (len(sids) == 0): await ctx.send(namesub("Please include at least one valid <ship.title> ID")) elif(len(sids) > setting('fleets.fleet_capacity')): await ctx.send(namesub("Too many <ship_plural> in the <fleet>!")) else: fleet.ships = sids fleet.update() strs = fleet_strings(inv, fleet) flag = strs.pop(0) line_base = [x for x in inv.inventory if x.invid == sids[0]].pop().base() if (len(strs) > 0): await ctx.send(namesub("Set <fleet> %s to: <flagship.title> %s, <ship_plural> %s\n\n%s: *%s*") % (1, flag, ", ".join(strs), line_base.name, line_base.get_quote('fleet_join'))) else: await ctx.send(namesub("Set <fleet> %s to: <flagship.title> %s\n\n%s: *%s*") % (1, flag, line_base.name, line_base.get_quote('fleet_join')))
def init(): process_result() create_hud() setlocal_buffers() bind_global_keys() vim.command('set hidden') initial_mode = setting('initial_mode', 'grid').lower() if initial_mode not in ['grid', 'loupe', 'compare', 'path']: initial_mode = 'grid' modes.current_mode = getattr(modes, initial_mode) modes.current_mode.activate()
def ocommand(message, sprefix, prefix, consol_prefix, log_prefix): # open lang file sconfig = ConfigParser() sconfig.read('../servers/' + message.server.id + '/serverconfig.ini') serverlang = sconfig.get('Config', 'lang') langfile = open("../config/lang/" + serverlang + ".lang", "r", encoding='utf-8') lang = langfile.read().split("\n") msg = "" if message.content.startswith(sprefix + "pysettings"): if message.author.server_permissions.administrator: msg = (setting(message)) else: msg = lang[8] elif message.content.startswith(sprefix + "pyhelp"): msg = pyhelp(message, sprefix, prefix) elif message.content.startswith(sprefix + "pycommandlist"): msg = (commandlist(message, sprefix)) elif message.content.startswith(sprefix + "pyclean"): if message.author.server_permissions.manage_messages: msg = "clean" else: msg = lang[8] elif message.content.startswith(sprefix + "pyaddcommand"): if message.author.server_permissions.administrator: msg = (addcommand(message)) else: msg = lang[8] elif message.content.startswith(sprefix + "pyremovecommand"): if message.author.server_permissions.administrator: msg = remove(message) else: msg = lang[8] elif message.content.startswith(sprefix + "pysetcommand"): if message.author.server_permissions.administrator: msg = set(message) else: msg = lang[8] else: msg = lang[9] return(msg)
def start_screen(): buttons = [ Button(WIDTH // 6, 2 * HEIGHT // 12, WIDTH // 3, HEIGHT // 6, 'Play', pygame.Color('black')), Button(WIDTH // 6, 5 * HEIGHT // 12, WIDTH // 3, HEIGHT // 6, 'Settings', pygame.Color('black')), Button(WIDTH // 6, 8 * HEIGHT // 12, WIDTH // 3, HEIGHT // 6, 'Exit', pygame.Color('black')) ] while True: screen.fill((255, 255, 255)) for button in buttons: button.draw(screen) for event in pygame.event.get(): if event.type == pygame.QUIT: terminate() if event.type == pygame.MOUSEMOTION: for button in buttons: if button.is_selected(event.pos): button.col = (255, 255, 0) else: button.col = pygame.Color('black') if event.type == pygame.MOUSEBUTTONUP: for button in buttons: if button.is_selected(event.pos): idx = buttons.index(button) if idx == 0: return if idx == 1: setting() if idx == 2: terminate() pygame.display.flip()
async def drop(ctx): """Drop a random ship for the user.""" did = ctx.author.id if (not setting('features.drop_enabled')): await ctx.send("That feature is not enabled.") return if (userinfo.has_space_in_inventory(did)): cd = userinfo.check_cooldown(did, 'Last_Drop', DROP_COOLDOWN) if (cd == 0): drop = drophandler.get_random_drop(did, only_droppable=True) ship_base = drop.base() ship_name = ship_base.name ship_rarity = ship_base.rarity rarity = setting('rarities') inv = userinfo.get_user_inventory(did) inv.add_to_inventory(drop) image_file = imggen.generate_ship_card(ctx.bot, drop) await ctx.send( file=discord.File( io.BytesIO(image_file.getvalue()), filename="image.png"), content="%s got %s! (%s)\n\n%s: *%s*" % ( ctx.author.display_name, ship_name, rarity[ship_rarity - 1], ship_name, ship_base.get_quote('intro'))) logging.info("[Drop] %s (%s) received %s from a drop" % (str(ctx.author), did, ship_name)) else: hrs = cd // 3600 min = cd // 60 % 60 sec = cd % 60 await ctx.send("You have %dh%02dm%02ds remaining until you can" " get your next drop" % (hrs, min, sec)) else: await ctx.send(namesub("Your inventory is full! You can scrap a <ship.title> with" " `%sscrap [<ship.title> ID]`") % COMMAND_PREFIX)
def add_exp(self, exp): """Add EXP to the local copy of the ship. Returns ------- bool Whether or not the ship levelled up in the process. """ if (not setting('features.levels_enabled')): return None req = self.exp_req() self.exp += exp lvl = False if (self.level != setting('levels.level_cap') and self.level < setting('levels.level_cap_married')): if (self.exp > req): self.level += 1 self.exp -= req lvl = True self.add_exp(0) # level up as much as possible else: self.exp = 0 userinfo.update_ship_exp(self) return lvl
def unbind(key, options='', leader=None): if not leader: leader = setting('prefix', '-') vim.command('unmap %s %s%s' % (options, leader, key))
def bind(key, to, options='', mode=None, leader=None): if not leader: leader = setting('leader', '<localleader>') vim.command('nnoremap %s %s%s %s' % (options, leader, key, to))
def unbind(key, options='', leader=None): if not leader: leader = setting('leader', '<localleader>') vim.command('unmap %s %s%s' % (options, leader, key))
def boolsetting(name): if int(setting(name, 0)): return True else: False
def bind(key, to, options='', mode=None, leader=None): if not leader: leader = setting('prefix', '-') vim.command('nnoremap %s %s%s %s' % (options, leader, key, to))
def __init__(self): #------------------------------------------ super(MainWindow, self).__init__() centralWidget = QtGui.QWidget() self.setCentralWidget(centralWidget) # gui self.frontSize=10 #-------------------------------------------------------main scene # place some public variable # load some map mainBG = QtGui.QPixmap(self) mainBG.load('UI/M_mainBG.png') menuOn = True settings.setting() # initialize widget #---main windows self.mainWidget = mainEngine.GLWidget() self.toolWidget = QtGui.QWidget() def contextMenuEvent(self, event): self.file.exec_(event.globalPos()) #---menu if menuOn == True: self.createActions() self.createMenus() # tool view Area self.toolArea = QtGui.QScrollArea() self.toolArea.setWidget(self.toolWidget) self.toolArea.setWidgetResizable(True) #self.toolArea.setMinimumSize(20,50) #self.toolArea.setMaximumSize(20, 900) # part of tool view label2 = QtGui.QLabel('xxx', self) label2.setAlignment(QtCore.Qt.AlignCenter) label3 = QtGui.QLabel('xxx', self) label3.setAlignment(QtCore.Qt.AlignCenter) label5 = QtGui.QLabel('xxx', self) label5.setAlignment(QtCore.Qt.AlignCenter) label6 = QtGui.QLabel('', self) label6.setAlignment(QtCore.Qt.AlignCenter) text1 = QtGui.QLineEdit('xxx') text2 = QtGui.QLineEdit('xxx') #file_obj = open("visual_fengx_information.txt") #file_obj_content = file_obj.read() #text3 = QtGui.QTextEdit(file_obj_content) # windows style change self.styleComboBox = QtGui.QComboBox() self.styleComboBox.addItems(QtGui.QStyleFactory.keys()) self.styleLabel = QtGui.QLabel("&Style:") self.styleLabel.setBuddy(self.styleComboBox) #dock ''' #dock1.setFeatures(QDockWidget.AllDockWidgetFeatures) # dock1.setFeatures(QDockWidget.DockWidgetMovable) # dock1.setAllowedAreas(Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea) #self.addDockWidget(Qt.RightDockWidgetArea, dock1) ''' # tool view layout self.toolLayout = QtGui.QGridLayout() self.toolLayout.addWidget(label5, 1, 0, 1, 1) self.toolLayout.addWidget(label2, 2, 0, 1, 1) self.toolLayout.addWidget(label3, 3, 0, 1, 1) self.toolLayout.addWidget(text1, 2, 1, 1, 1) self.toolLayout.addWidget(text2, 3, 1, 1, 1) #self.toolLayout.addWidget(text3, 6, 0, 1, 2) self.toolLayout.addWidget(self.styleComboBox, 1, 1, 1, 1) self.toolLayout.addWidget(label6, 5, 1, 1, 2) # main scene windows self.glWidgetArea = QtGui.QScrollArea() self.glWidgetArea.setWidget(self.mainWidget) self.glWidgetArea.setWidgetResizable(True) self.glWidgetArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.glWidgetArea.setMinimumSize(150, 150) self.glWidgetArea.setMaximumSize(1440, 900) self.setWindowIcon(QtGui.QIcon('UI/icons/Spell_Shadow_DeathCoil.png')) #-------------------------------------------------------toolbar # def toolbar1(self): self.test1 = QtGui.QAction(QtGui.QIcon('UI/icons/Spell_Shadow_DeathCoil.png'), 'xxx', self) self.frame = QtGui.QAction(QtGui.QIcon('UI/icons/1 (1)'), 'frame all', self) self.test2 = QtGui.QAction(QtGui.QIcon('UI/icons/1 (2)'), 'frame all', self) self.test3 = QtGui.QAction(QtGui.QIcon('UI/icons/1 (3)'), 'frame all', self) self.test4 = QtGui.QAction(QtGui.QIcon('UI/icons/1 (4)'), 'frame all', self) self.exit = QtGui.QAction(QtGui.QIcon('UI/icons/Spell_Shadow_DeathCoil.png'), 'Exit', self) self.exit.setShortcut('Ctrl+Q') self.connect(self.exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()')) #self.connect(self.frame, QtCore.SIGNAL('triggered()'), QtCore.SLOT('self.frame)) self.toolbar = self.addToolBar('MainToolBar') self.toolbar.setIconSize(QtCore.QSize(40, 40)) self.toolbar.addAction(self.frame) self.toolbar.addAction(self.exit) self.toolbar.addAction(self.test1) self.toolbar.addAction(self.test2) self.toolbar.addAction(self.test3) self.toolbar.addAction(self.test4) self.toolbar.setFloatable(False) self.toolbar.setOrientation(0x1) self.toolbar.setToolButtonStyle(4) #-------------------------------------------------------main layout mainLayout = QtGui.QGridLayout() mainLayout.addLayout(self.toolLayout, 1, 3, 3, 3) mainLayout.addWidget(self.glWidgetArea, 1, 0, 3, 1) centralWidget.setLayout(mainLayout) self.setWindowTitle("VisualFeng_1.0") self.setGeometry(100, 100, 900, 600) #style change combobox self.styleComboBox.activated[str].connect(self.changeStyle) #----------main window background self.palette1 = QtGui.QPalette(self) self.palette1.setBrush(self.backgroundRole(), QtGui.QBrush(mainBG)) self.setPalette(self.palette1) self.setAutoFillBackground(0)
# -*- encoding: utf-8 -*- import threading import sublime, sublime_plugin import os import re import subprocess from ClassHierarchyManager import ClassHierarchyManager, set_tab_size, NoSymbolException from helpers import hierarchy_base_decorator, to_underscore from HierarchyView import HierarchyView from settings import setting set_tab_size(setting('tab_size')) is_hierarchy_ctags_in_building = False is_hierarchy_tree_in_loading = False hierarchy_tree_pool = dict() class HierarchyTree(object): def __init__(self, tree): self.tree = tree self.view_pool = dict() def get_hierarchy_tree(project_dir): try: return hierarchy_tree_pool[project_dir] except KeyError: return None def load_hierarchy_tree(project_dir, ctags_file_path):