def wcsadmin_github_info_confirm_menu_select(menu, client, option): if option.choice_index == 1: wcsadmin_github_info_menu.send([*menu._player_pages]) menu.close([*menu._player_pages]) wcsadmin_github_info_menu[3].selectable = wcsadmin_github_info_menu[ 3].highlight = False wcsadmin_github_info_menu[4] = Text( menu_strings['wcsadmin_github_info_menu updating']) wcsadmin_github_info_menu._installing_cycle = 0 github_manager.refresh_commits() github_manager.install_new_version() return return option.value
def init_popups(): @nomination_popup.register_select_callback def select_callback(popup, index, option): mcplayers[index].nominate_callback(option.value) @likemap_popup.register_select_callback def select_callback(popup, index, option): mcplayers[index].likemap_callback(option.value) @main_popup.register_select_callback def select_callback(popup, index, option): option.value.votes += 1 vote_progress_bar.count_vote(option.value) mcplayers[index].vote_callback(option.value) likemap_popup.append(Text(popups_strings['rate_map'])) choice_index = 1 # First of all, add "I Don't Care" option if it's enabled if config_manager['likemap_whatever_option']: # Add to the list likemap_popup.append(SimpleOption( choice_index=choice_index, text=popups_strings['whatever'], value=0, )) choice_index += 1 likemap_popup.append(SimpleOption( choice_index=choice_index, text=popups_strings['likemap_like'], value=1, )) choice_index += 1 likemap_popup.append(SimpleOption( choice_index=choice_index, text=popups_strings['likemap_dislike'], value=-1, ))
def playerinfo_detail_skills_menu_build(menu, client): menu.clear() wcsplayer = Player(client) wcstarget = Player.from_uniqueid(wcsplayer.data['_internal_playerinfo']) if wcstarget.ready: menu.title.tokens['name'] = wcstarget.name active_race = wcstarget.active_race for name, skill in active_race.skills.items(): option = Text(deepcopy(menu_strings['playerinfo_detail_skills_menu line'])) option.text.tokens['name'] = active_race.settings.strings[name] option.text.tokens['level'] = skill.level option.text.tokens['maximum'] = skill.config['maximum'] menu.append(option) else: menu.title.tokens['name'] = wcsplayer.data['_internal_playerinfo_name']
def raceinfo_race_detail_menu_build(menu, client): del menu[2:-3] wcsplayer = Player.from_index(client) race_name = wcsplayer.data['_internal_raceinfo'] settings = race_manager[race_name] menu[0].text.tokens['name'] = settings.strings['name'] kwargs = {} settings.execute('on_race_desc', wcsplayer, kwargs) info = settings.strings['description'] info = info.get_string(get_client_language(client), **kwargs) for i, text in enumerate(wrap(info, 30), 2): menu.insert(i, text) for i in range(i + 1, MAX_ITEM_COUNT + 2): menu.insert(i, Text(' '))
def wcs_bank_command(command, index, team=None): userid = userid_from_index(index) if bank_player_loaded[userid] == True: if int(bankplayer[userid].levels) > 0: amount_menu.clear() amount_menu.append( Text('You have %s Levels in your bank' % bankplayer[userid].levels)) amount_menu.append(PagedOption('1', 'spendlevels')) amount_menu.append(PagedOption('5', 'spendlevels')) amount_menu.append(PagedOption('10', 'spendlevels')) amount_menu.append(PagedOption('25', 'spendlevels')) amount_menu.append(PagedOption('100', 'spendlevels')) amount_menu.append(PagedOption('250', 'spendlevels')) amount_menu.append(PagedOption('1000', 'spendlevels')) amount_menu.append(PagedOption('2500', 'spendlevels')) amount_menu.send(index) else: wcs.wcs.tell( userid, '\x04[WCS] \x05You do not have \x04any \x05levels in your \x04Levelbank' )
def rules(userid): menu = SimpleMenu() menu.append(Text('The Rules')) menu.append(Text(' ')) for i in get_rules: menu.append(Text('%s' % (i))) menu.append(Text(' ')) menu.append(Text('Do you accept the rules?')) menu.append(Text(' ')) menu.append(SimpleOption(no_button, 'No', 'No')) menu.append(SimpleOption(yes_button, 'Yes', 'Yes')) menu.append(SimpleOption(close_button, 'Close', 0)) @menu.register_close_callback def on_close_checkpoints_menu(menu, index): queue_command_string('kickid %s You have to accept the rules!' % (userid)) menu.select_callback = rule_menu_callback menu.send(index_from_userid(userid))
def wcsadmin_players_sub_menu_build(menu, client): wcsplayer = Player(client) uniqueid = wcsplayer.data['_internal_wcsadmin_player'] if uniqueid is None: menu[0].text.tokens['name'] = menu_strings['wcsadmin_players_menu all'] menu[2].selectable = menu[2].highlight = True menu[3].selectable = menu[3].highlight = True menu[4] = Text(' ') else: wcstarget = Player.from_uniqueid(uniqueid) if wcstarget.ready: menu[0].text.tokens['name'] = wcstarget.name else: menu[0].text.tokens['name'] = wcsplayer.data['_internal_wcsadmin_player_name'] menu[2].selectable = menu[2].highlight = wcstarget.ready menu[3].selectable = menu[3].highlight = wcstarget.ready menu[4].selectable = menu[4].highlight = wcstarget.ready menu[4] = SimpleOption(3, menu_strings['wcsadmin_players_sub_menu line 3'], selectable=False, highlight=False)
def _on_spend_skills_build(menu, index): player = player_dict[index] menu.clear() menu.description = spendskills_menu_strings['description'].get_string( amount=player.race.unused_points) for skill in player.race.skills: selectable = (skill.level < skill.max_level) and skill.is_available(player) menu.append( PagedOption( spendskills_menu_strings['skill'].get_string(name=skill.name, level=skill.level, max_level=skill.max_level), skill, highlight=selectable, selectable=selectable ) ) menu.append(Text(' ')) menu.append( PagedOption( spendskills_menu_strings['reset'].get_string(), None, selectable=True ) )
def doCommand(userid): player_entity = Player(index_from_userid(userid)) racel = wcs.wcs.wcsplayers[userid].currace race = wcs.wcs.racedb.getRace(racel) name = race['skillnames'].split('|') skills = wcs.wcs.wcsplayers[userid].skills.split('|') levels = int(race['numberoflevels']) myinfo_menu = SimpleMenu() myinfo_menu.select_callback = myinfo_select myinfo_menu.append(Text('->1. %s' % player_entity.name)) myinfo_menu.append(Text('-' * 25)) myinfo_menu.append( Text('o Total level %s' % str(wcs.wcs.wcsplayers[userid].totallevel))) myinfo_menu.append(Text('-' * 25)) myinfo_menu.append( Text('o %s: Level %s' % (str(wcs.wcs.wcsplayers[userid].currace), str(wcs.wcs.wcsplayers[userid].level)))) for skill, level in enumerate(skills): myinfo_menu.append( Text(' - %s: [%s/%s]' % (name[skill], str(level), str(levels)))) myinfo_menu.append(Text('-' * 25)) myinfo_menu.append(Text('Health : %s HP' % player_entity.health)) myinfo_menu.append( Text('Speed : %s%%' % str(round(player_entity.speed * 100)))) myinfo_menu.append( Text('Gravity : %s%%' % str(round(player_entity.gravity * 100)))) myinfo_menu.append(Text(' ')) myinfo_menu.append(SimpleOption(8, 'Next', value=7)) myinfo_menu.append(SimpleOption(9, 'Close', highlight=False)) myinfo_menu.send(index_from_userid(userid))
"""Main menu's select_callback function.""" choice.value.previous_menu = menu return choice.value def _main_build_callback(menu, player_index): """Main menu's build_callback function.""" player = get_player(player_index, key='index') menu[1].text.get_string(gold=player.gold) menus['Main'] = SimpleMenu( data=[ Text('Hero-Wars'), Text(_TR['Gold']), SimpleOption(1, _TR['Current Hero'], menus['Current Hero']), SimpleOption(2, _TR['Owned Heroes'], menus['Owned Heroes']), SimpleOption(3, _TR['Buy Heroes'], menus['Hero Buy Categories']), SimpleOption(4, _TR['Sell Items'], menus['Sell Items']), SimpleOption(5, _TR['Buy Items'], menus['Item Buy Categories']), SimpleOption(0, _TR['Close']) ], select_callback=_main_select_callback, build_callback=_main_build_callback ) # ====================================================================== # >> PLAYERS MENU # ======================================================================
wcs_admin_menu.send(index) if choice.choice_index == 7: if has_flag(userid, 'wcsadmin_bank'): levelbank.wcsadmin_bank_menu.parent_menu = menu levelbank.doCommand(userid) else: wcs.wcs.tell( userid, '\x04[WCS] \x05You do not have \x04access \x05this menu!') wcs_admin_menu.send(index) if choice.choice_index == 9: menu.close(index) wcs_admin_menu = SimpleMenu([ Text('WCS Admin Menu'), Text('-------------------'), SimpleOption(1, 'Settings', value_1), SimpleOption(2, 'Give XP', value_2), SimpleOption(3, 'Give Levels', value_1), SimpleOption(4, 'Change Race', value_2), SimpleOption(5, 'Reset Race', value_2), SimpleOption(6, 'Reset Player', value_1), SimpleOption(7, 'Level Bank', value_2), Text('-------------------'), SimpleOption(9, 'Close', highlight=False), ], select_callback=_wcs_admin_menu_select) def get_addon_path():
# CHANGE EXP MENU # ====================================================================== def _exp_select_callback(menu, player_index, choice): multiplier = choice.value cfg.exp_multiplier = multiplier for player in PlayerIter(): message( player.index, '\x02Experience Values \x01changed to \x04{}x\x01, ready Next Round!' .format(multiplier)) menus['Change Exp'] = SimpleMenu(data=[ Text('Change EXP Rate'), Text(' '), SimpleOption(1, '1x', 1), SimpleOption(2, '2x', 2), SimpleOption(3, '3x', 3), Text(' '), SimpleOption(9, _TR['Close'], 0, highlight=False) ], select_callback=_exp_select_callback) # ====================================================================== # >> PLAYERS MENU # ====================================================================== def _players_select_callback(menu, player_index, choice):
def doCommand(userid): race = wcs.wcs.wcsplayers[userid].currace unused = wcs.wcs.wcsplayers[userid].all_races[race]['unused'] index = index_from_userid(userid) if unused: skills = wcs.wcs.wcsplayers[userid].all_races[race]['skills'].split( '|') db = wcs.wcs.racedb.getRace(race) nol = db['numberoflevels'] if '|' in nol: nol = nol.split('|') nol = [int(x) for x in nol] else: nos = int(db['numberofskills']) nol_tmp = int(db['numberoflevels']) nol = [] x = 0 while x < nos: nol.append(nol_tmp) x += 1 current_level = 0 for x in skills: current_level += int(x) max_level = 0 for x in nol: max_level += int(x) if current_level < max_level: spendskills = SimpleMenu() spendskills.append(Text('Available ' + race + ' skills:')) spendskills.append(Text('------------------------------')) skillnames = db['skillnames'].split('|') skillneeded = db['skillneeded'].split('|') added = 0 for number, skill in enumerate(skills): added += 1 if int(skill) >= nol[number]: spendskills.append( SimpleOption(number + 1, '' + str(skillnames[number]) + ' (maxed)', number + 1, highlight=False)) else: if int( skillneeded[number] ) > wcs.wcs.wcsplayers[userid].all_races[race]['level']: spendskills.append( SimpleOption(number + 1, '' + str(skillnames[number]) + ' (need level ' + skillneeded[number] + ')', number + 1, highlight=False)) else: spendskills.append( SimpleOption(number + 1, '' + str(skillnames[number]) + ': ' + str(skills[number]) + ' > ' + str(int(skills[number]) + 1), number + 1, highlight=True)) spendskills.append(Text('------------------------------')) spendskills.append(Text('Unused Points: ' + str(unused))) spendskills.append(Text('------------------------------')) spendskills.append( SimpleOption(8, 'Back', highlight=True, selectable=True)) spendskills.append(SimpleOption(9, 'Close', highlight=False)) spendskills.send(index) spendskills.select_callback = popupHandler else: wcs.wcs.tell( userid, '\x04[WCS] \x05You have reached the \x04maximum level \x05for this race.' ) else: wcs.wcs.tell(userid, '\x04[WCS] \x05No unused points.')
wcsadmin_management_items_menu.title = menu_strings[ 'wcsadmin_management_items_menu title'] wcsadmin_management_races_add_menu.title = menu_strings[ 'wcsadmin_management_races_add_menu title'] wcsadmin_management_items_add_menu.title = menu_strings[ 'wcsadmin_management_items_add_menu title'] wcsadmin_github_races_menu.title = menu_strings[ 'wcsadmin_github_races_menu title'] wcsadmin_github_items_menu.title = menu_strings[ 'wcsadmin_github_items_menu title'] # ============================================================================ # >> MENU FILLER # ============================================================================ main_menu.extend([ Text(menu_strings['main_menu title']), SimpleOption(1, menu_strings['main_menu line 1'], shopmenu_menu), SimpleOption(2, menu_strings['main_menu line 2'], shopinfo_menu), Text('-------------------'), SimpleOption(3, menu_strings['main_menu line 3'], showskills_menu), SimpleOption(4, menu_strings['main_menu line 4'], resetskills_menu), SimpleOption(5, menu_strings['main_menu line 5'], spendskills_menu), Text('-------------------'), SimpleOption(6, menu_strings['main_menu line 6'], changerace_menu), SimpleOption(7, menu_strings['main_menu line 7'], raceinfo_menu), Text('-------------------'), SimpleOption(8, menu_strings['main_menu line 8'], playerinfo_menu), Text('-------------------'), SimpleOption(BUTTON_CLOSE_SLOT, menu_strings['close'], highlight=False) ])
def send_highlight_popup(index, zone): if index in popups: popups[index].close(index) popup = popups[index] = SimpleMenu( select_callback=select_callback_highlight) popup.append( SimpleOption(choice_index=1, text=strings['popup highlight next_zone'], value=HighlightChoice.HL_NEXT)) popup.append( SimpleOption(choice_index=2, text=strings['popup highlight prev_zone'], value=HighlightChoice.HL_PREV)) if zone is None: popup.append(Text(strings['popup highlight current_zone none'])) else: if zone.teleport['origin'] is None: teleport_origin = "- - -" else: teleport_origin = vector_to_str(zone.teleport['origin']) if zone.teleport['angles'] is None: teleport_angles = "- - -" else: teleport_angles = vector_to_str(zone.teleport['angles']) if zone.boost is None: boost = "- - -" else: boost = vector_to_str(zone.boost) popup.append( Text(strings['popup highlight current_zone'].tokenize( nojump=zone.nojump, noduck=zone.noduck, speed_cap=zone.speed_cap, teleport_origin=teleport_origin, teleport_angles=teleport_angles, boost=boost, ))) popup.append( SimpleOption(choice_index=3, text=strings['popup highlight delete'], value=HighlightChoice.DELETE)) popup.append( SimpleOption(choice_index=4, text=strings['popup highlight toggle_nojump'], value=HighlightChoice.TOGGLE_NOJUMP)) popup.append( SimpleOption(choice_index=5, text=strings['popup highlight toggle_noduck'], value=HighlightChoice.TOGGLE_NODUCK)) popup.send(index)
from players.entity import Player from players.helpers import index_from_userid, playerinfo_from_userid, index_from_playerinfo, userid_from_index from menus import SimpleMenu from menus import SimpleOption from menus import Text import wcs def wcshelp_select(menu, index, choice): return wcshelp = SimpleMenu([ Text('Chat Commands:'), Text('wcshelp - This help'), Text('changerace - Choose your race'), Text('raceinfo - Show info about skills'), Text('shopmenu - Buy shopitems'), Text('shopinfo - Show item info'), Text('showxp - Race, level and XP'), Text('showskills - Show all skills levels'), Text('resetskills - Reset your skills'), Text('spendskills - Spend skill points'), Text('playerinfo - Shows info about a player'), Text('wcsadmin - Admin menu'), Text('wcstop - WCS top'), Text('wcsrank - WCS rank'), SimpleOption(9, 'Close', highlight=False) ], select_callback=wcshelp_select)
'wcsadmin_github_items_repository_menu title'] wcsadmin_github_info_confirm_commits_menu.title = menu_strings[ 'wcsadmin_github_info_confirm_commits_menu title'] wcsadmin_github_info_commits_menu.title = menu_strings[ 'wcsadmin_github_info_commits_menu title'] wcsadmin_github_races_menu._cycle = None wcsadmin_github_items_menu._cycle = None wcsadmin_github_info_menu._checking_cycle = None wcsadmin_github_info_menu._installing_cycle = None # ============================================================================ # >> MENU FILLER # ============================================================================ main_menu.extend([ Text(menu_strings['main_menu title']), SimpleOption(1, menu_strings['main_menu line 1'], shopmenu_menu), SimpleOption(2, menu_strings['main_menu line 2'], shopinfo_menu), Text('-------------------'), SimpleOption(3, menu_strings['main_menu line 3'], showskills_menu), SimpleOption(4, menu_strings['main_menu line 4'], resetskills_menu), SimpleOption(5, menu_strings['main_menu line 5'], spendskills_menu), Text('-------------------'), SimpleOption(6, menu_strings['main_menu line 6'], changerace_menu), SimpleOption(7, menu_strings['main_menu line 7'], raceinfo_menu), Text('-------------------'), SimpleOption(8, menu_strings['main_menu line 8'], playerinfo_menu), Text('-------------------'), SimpleOption(BUTTON_CLOSE_SLOT, menu_strings['close'], highlight=False) ])
def restedexp_menu_build(menu, index): player = Player(index) steamid = player.steamid menu.clear() menu.append(Text('Rested Experience - Main Menu')) menu.append(Text('-----------------------------')) menu.append(Text('Current Rested Experience: %s' % int(db[steamid]["exp"]))) if db[steamid]["gaintrig"] and int(toggle.get_int()): menu.append(Text("Collect Per Kill: On")) else: if not db[steamid]["gaintrig"] and int(toggle.get_int()): menu.append(Text("Collect Per Kill: Off")) else: menu.append(Text("Collect Per Kill: Off (Server Setting)")) menu.append( Text("Collected Per Kill: %s (Server Setting)" % gainxp.get_int())) menu.append(Text("-----------------------------")) menu.append(Text("Gain Amount (Online): %s" % tickoxp.get_int())) menu.append(Text("Gain Amount (Offline): %s" % tickaxp.get_int())) menu.append(Text("Gain Tick Rate: %s" % timer.get_int())) menu.append(Text("-----------------------------")) menu.append(SimpleOption(1, 'Toggle Collect Per Kill', 'toggle')) menu.append( SimpleOption(2, "Check Other Player's Rested Experience", 'check')) menu.append(Text("-----------------------------")) menu.append(SimpleOption(9, 'Close', highlight=False))
def on_github_new_version_installed(): wcsadmin_github_info_menu._installing_cycle = None wcsadmin_github_info_menu[3] = SimpleOption( 1, menu_strings['wcsadmin_github_info_menu check']) wcsadmin_github_info_menu[4] = Text(' ')
).send(index) gold_admin_menu.send(index) if choice.choice_index == 2: if has_flag(userid, 'goldadmin_removegold'): takeGolddoCommand(userid) else: SayText2('\x04[WCS] \x05You do not have \x04access \x05this menu!' ).send(index) gold_admin_menu.send(index) if choice.choice_index == 9: menu.close(index) gold_admin_menu = SimpleMenu([ Text('Gold Admin Menu'), Text('-------------------'), SimpleOption(1, 'Give Gold', value_1), SimpleOption(2, 'Remove Gold', value_2), Text('-------------------'), SimpleOption(9, 'Close', highlight=False), ], select_callback=_gold_admin_menu_select) def get_addon_path(): path = os.path.dirname(os.path.abspath(__file__)) return path @SayCommand('goldadmin')