Ejemplo n.º 1
0
	def info_menu(self, userids = []):
		try:
			info_menu = SimpleMenu(build_callback=self.callback_info_menu)
			list = []
			if type(userids) is not list:
				player = Player.from_userid(userids)
				list = [player.index]
			else:
				for item in userids:
					player = Player.from_userid(item)
					list.append(player.index)
			info_menu.send(list)
		except:
			msg('ERROR', 'could not send info menu to one or more players')
def send_delete_popup(index):
    if index in popups:
        popups[index].close(index)

    popup = popups[index] = SimpleMenu(select_callback=select_callback_delete)
    popup.append(Text(strings['popup delete title']))
    popup.append(
        SimpleOption(choice_index=1,
                     text=strings['popup delete no'],
                     value=False))
    popup.append(
        SimpleOption(choice_index=2,
                     text=strings['popup delete yes'],
                     value=True))
    popup.send(index)
def send_highlight_popup(index, zombie_spawn):
    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_zombie_spawn'],
            value=HighlightChoice.HL_NEXT
    ))

    popup.append(SimpleOption(
        choice_index=2,
        text=strings['popup highlight prev_zombie_spawn'],
        value=HighlightChoice.HL_PREV
    ))

    if zombie_spawn is None:
        popup.append(
            Text(strings['popup highlight current_zombie_spawn none']))
    else:
        popup.append(
            Text(strings['popup highlight current_zombie_spawn'].tokenize(
                origin=vector_to_str(zombie_spawn.origin),
                angles=vector_to_str(zombie_spawn.angles),
                classname=zombie_spawn.classname
            ))
        )

        popup.append(SimpleOption(
            choice_index=3,
            text=strings['popup highlight delete'],
            value=HighlightChoice.DELETE
        ))

    popup.send(index)
Ejemplo n.º 4
0
        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')
@ClientCommand('goldadmin')
def _wcs_admin_command(command, index, team=None):
    userid = userid_from_index(index)
Ejemplo n.º 5
0
 def menu(cls):
     """Returns the menu object"""
     return SimpleMenu(build_callback=cls.build, select_callback=cls.select)
Ejemplo n.º 6
0
def doCommand(userid):
    index = index_from_userid(userid)
    userid = int(userid)
    race = wcs.wcs.wcsplayers[userid].currace
    skills = wcs.wcs.wcsplayers[userid].all_races[race]['skills'].split('|')
    names = wcs.wcs.racedb.races[race]['skillnames'].split('|')
    n = 0
    showskills = SimpleMenu(select_callback=showskills_select)
    showskills.append(Text('Your %s skills:' % race))
    showskills.append(Text('------------------------------'))
    while n < len(names):
        try:
            level = str(skills[n])
        except IndexError:
            level = 0
        name = str(names[n])
        n += 1
        showskills.append(
            SimpleOption(n,
                         '%s : %s' % (str(name), str(level)),
                         value=None,
                         highlight=True,
                         selectable=False))
    showskills.append(Text('------------------------------'))
    showskills.append(
        Text('Unused points: %s' %
             str(wcs.wcs.wcsplayers[userid].all_races[race]['unused'])))
    showskills.append(Text('------------------------------'))
    showskills.append(
        SimpleOption(8, 'Back', value='back', highlight=True, selectable=True))
    showskills.append(SimpleOption(9, 'Close', highlight=False))
    showskills.send(index)
Ejemplo n.º 7
0
 def _create_menu(self):
     self.menu = SimpleMenu(
         select_callback=self._chosen_value,
         build_callback=self._menu_build,
     )
Ejemplo n.º 8
0
def doCommand2(userid):
    player_entity = Player(index_from_userid(userid))
    available = available_races(userid)
    left = left_to_next(userid)
    all_count = all_races()
    perc = float(available) / (float(all_count) / 100.0)
    perc = Decimal(perc)
    perc = round(perc, 2)
    rank = wcs.wcs.wcsplayers[userid].get_rank()
    myinfo2_menu = SimpleMenu()
    myinfo2_menu.select_callback = myinfo2_select
    myinfo2_menu.append(Text('->1. %s' % player_entity.name))
    myinfo2_menu.append(Text('-' * 25))
    myinfo2_menu.append(
        Text('Total level: %s' % str(wcs.wcs.wcsplayers[userid].totallevel)))
    myinfo2_menu.append(Text('-' * 25))
    myinfo2_menu.append(Text('- WCS rank: %s' % rank[0]))
    myinfo2_menu.append(Text('- Levels to next race: %s' % left))
    myinfo2_menu.append(
        Text('- Races available: %s of %s' % (available, all_count)))
    myinfo2_menu.append(Text('- Percentage of races: %s' % perc))
    myinfo2_menu.append(Text('-' * 25))
    myinfo2_menu.append(SimpleOption(7, 'Back', value=8))
    myinfo2_menu.append(Text(' '))
    myinfo2_menu.append(SimpleOption(9, 'Close', highlight=False))
    myinfo2_menu.send(index_from_userid(userid))
Ejemplo n.º 9
0
from menus.radio import MAX_ITEM_COUNT

# WCS Imports
#   Menus
from .base import PagedMenu
from .base import PagedPageCountMenu

# ============================================================================
# >> ALL DECLARATION
# ============================================================================
__all__ = ()

# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
main_menu = SimpleMenu()
shopmenu_menu = PagedPageCountMenu()
shopinfo_menu = PagedPageCountMenu()
shopinfo_detail_menu = SimpleMenu()
showskills_menu = PagedMenu()
resetskills_menu = SimpleMenu()
spendskills_menu = PagedMenu()
changerace_menu = PagedPageCountMenu()
changerace_search_menu = PagedPageCountMenu()
raceinfo_menu = PagedPageCountMenu()
raceinfo_search_menu = PagedPageCountMenu()
raceinfo_detail_menu = SimpleMenu()
raceinfo_skills_menu = PagedMenu()
raceinfo_skills_detail_menu = SimpleMenu()
raceinfo_race_detail_menu = SimpleMenu()
playerinfo_menu = SimpleMenu()
Ejemplo n.º 10
0
def send_level_menu(index):
    """Send the level menu to the player."""
    menu = SimpleMenu()
    player = player_dictionary[userid_from_index(index)]
    menu.append(
        SimpleOption(
            1,
            menu_strings['Level:Title'],
            selectable=False,
        )
    )
    language = player.language
    if GunGameStatus.MATCH is not GunGameMatchStatus.ACTIVE:
        menu.append(menu_strings['Inactive'])
    elif gg_plugin_manager.is_team_game:
        if player.team not in team_levels:
            menu.append(Text(menu_strings['Level:Inactive']))
        else:
            team_level = team_levels[player.team]
            leader_level = max(team_levels.values())
            teams = [
                team_names[num] for num, level in team_levels.items()
                if level == leader_level
            ]
            menu.append(
                menu_strings['Level:Team'].get_string(
                    language=language,
                    level=team_level,
                )
            )
            if team_level < leader_level:
                menu.append(
                    menu_strings['Level:Team:Trailing'].get_string(
                        language=language,
                        levels=leader_level - team_level,
                    )
                )
            elif len(teams) == 1:
                second_place = max([
                    x for x in team_levels.values() if x != leader_level
                ])
                menu.append(
                    menu_strings['Level:Team:Leading'].get_string(
                        language=language,
                        levels=leader_level - second_place
                    )
                )
            elif len(teams) == len(team_levels):
                if len(teams) == 2:
                    menu.append(menu_strings['Level:Team:Tied'])
                else:
                    menu.append(menu_strings['Level:Team:All'])
            else:
                message = menu_strings['Level:Team:Multiple'].get_string(
                    language=language,
                )
                message += '\n\t* {teams}'.format(
                    teams=', '.join(teams)
                )
                menu.append(message)
    elif player.team < 2:
        menu.append(Text(menu_strings['Level:Inactive']))
    else:
        menu.append(
            Text(
                menu_strings['Level:Current'].get_string(
                    language,
                    level=player.level,
                )
            )
        )
        menu.append(
            Text(
                menu_strings['Level:Weapon'].get_string(
                    language,
                    kills=player.level_multi_kill - player.multi_kill,
                    weapon=player.level_weapon,
                )
            )
        )
        leaders = leader_manager.current_leaders
        if leaders is None:
            menu.append(Text(menu_strings['Leader:None']))
        elif player.userid not in leaders:
            menu.append(
                Text(
                    menu_strings['Level:Trailing'].get_string(
                        language,
                        levels=leader_manager.leader_level - player.level,
                    )
                )
            )
        elif len(leaders) > 1:
            menu.append(Text(menu_strings['Level:Tied']))
        else:
            menu.append(Text(menu_strings['Level:Leading']))
        menu.append(
            SimpleOption(
                2,
                menu_strings['Level:Wins-Title'],
                selectable=False,
            )
        )
        menu.append(
            Text(
                menu_strings['Level:Wins'].get_string(
                    language,
                    wins=player.wins,
                )
            )
        )
    menu.send(index)
Ejemplo n.º 11
0
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))
Ejemplo n.º 12
0
 def _create_menu(self):
     self.menu = SimpleMenu(
         select_callback=self._chosen_value,
         build_callback=self._menu_build,
     )
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)
Ejemplo n.º 14
0
class IntegerSetting(SettingsType):
    """Class used to store integer value settings."""

    _type = int

    def __init__(
        self, name, default, text=None, min_value=None, max_value=None
    ):
        """Store the base attributes on instantiation."""
        super().__init__(name, default, text)
        if min_value is not None and max_value is not None:
            if min_value >= max_value:
                raise ValueError(
                    'min_value ({min_value}) must be less than max_value '
                    '({max_value}).'.format(
                        min_value=min_value,
                        max_value=max_value,
                    )
                )
        self.min = self._type(min_value) if min_value is not None else None
        self.max = self._type(max_value) if max_value is not None else None
        self.current_values = {}

    def _create_menu(self):
        self.menu = SimpleMenu(
            select_callback=self._chosen_value,
            build_callback=self._menu_build,
        )

    def _menu_build(self, menu, index):
        """Build the menu."""
        self.menu.clear()
        self.menu.append(self.name if self.text is None else self.text)

        # Get the player's information
        player = Player(index)
        uniqueid = player.uniqueid
        current_value = self.get_setting(index)

        description = _settings_strings['Description'].get_string(
            language=player.language,
            value=current_value,
        )
        self.menu.append(description)
        self.menu.append('-' * len(description))
        counter = 1
        if self.min is None or self.max is None or self.max - self.min > 100:
            for value in (100, -100):
                self._add_option(choice_index=counter, value=value)
                counter += 1

        if self.min is None or self.max is None or self.max - self.min > 10:
            for value in (10, -10):
                self._add_option(choice_index=counter, value=value)
                counter += 1

        for value in (1, -1):
            self._add_option(choice_index=counter, value=value)
            counter += 1

        if uniqueid not in self.current_values:
            self.current_values[uniqueid] = current_value

        self.menu.append(
            SimpleOption(
                choice_index=counter,
                text='Save ({current_value})'.format(
                    current_value=self.current_values[uniqueid],
                ),
                value='Save',
            )
        )

    def _add_option(self, choice_index, value):
        """Add the value to the menu."""
        self.menu.append(
            SimpleOption(
                choice_index=choice_index,
                text='{:+d}'.format(value),
                value=value,
            )
        )

    def _chosen_value(self, menu, index, option):
        """Store the player's chosen value for the setting."""
        uniqueid = uniqueid_from_index(index)

        if option.value == 'Save':
            value = self.current_values[uniqueid]

            # Set the player's setting
            _player_settings_storage[uniqueid][self.convar] = value
            self._send_chosen_message(index, value)
            del self.current_values[uniqueid]
            return

        new_value = self.current_values[uniqueid] + option.value
        if self.min is not None:
            new_value = max(new_value, self.min)
        if self.max is not None:
            new_value = min(new_value, self.max)
        self.current_values[uniqueid] = new_value
        self.menu.send()

    def _is_valid_setting(self, value):
        """Return whether the given value is a valid value for the setting."""
        # Is the given value less than the setting's min value?
        if self.min is not None and value < self.min:

            # If too low, return False
            return False

        # Is the given value more than the setting's max value?
        if self.max is not None and value > self.max:

            # If too high, return False
            return False

        # Return True if the value is within the proper range
        return True
Ejemplo n.º 15
0
# Save original mp_timelimit value
mp_timelimit_old_value = 0

logger = LogManager(info.name, cvar_logging_level, cvar_logging_areas)

mapcycle_json = None

# Delays
delay_scheduled_vote = None
delay_changelevel = None
delay_end_vote = None
delay_likemap_survey = None

# Popups
nomination_popup = PagedMenu(title=popups_strings['nominate_map'])
likemap_popup = SimpleMenu()
main_popup = PagedMenu(title=popups_strings['choose_map'])

# ChangeLevel function (to hook)
engine_server_changelevel = get_virtual_function(engine_server, 'ChangeLevel')


# =============================================================================
# >> CLASSES
# =============================================================================
class CorruptJSONFile(Exception):
    """Raised when mapcycle.json doesn't contain a list."""
    pass


# =============================================================================
Ejemplo n.º 16
0
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)


def doCommand(userid):
    index = index_from_userid(userid)
    wcshelp.send(index)
Ejemplo n.º 17
0
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.')
Ejemplo n.º 18
0

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
# ======================================================================


def _admin_players_select_callback(menu, player_index, choice):
    """Admin Players menu's select_callback function."""
Ejemplo n.º 19
0
    def send_menu_stats(self, kill_type, attacker_name, attacker_headshot,
                        weapon, distance, health, distance_setting,
                        use_hitgroups):
        """Send victim stats to the player via a menu."""
        wounded_only = {
            username: values
            for username, values in self.given.items()
            if username not in self.killed
        }
        killed_only = {
            username: values
            for username, values in self.given.items()
            if username in self.killed
        }
        menu = SimpleMenu()
        for num, (string_name, group) in enumerate(iterable=[
            ('Attackers', self.taken),
            ('Wounded', wounded_only),
            ('Killed', killed_only),
        ],
                                                   start=1):
            if not group:
                continue

            menu.append(
                SimpleOption(
                    choice_index=num,
                    text=TRANSLATION_STRINGS[f'Type:{string_name}'],
                    selectable=False,
                ))
            for message in self.iter_messages(
                    string_name=string_name,
                    group=group,
                    use_hitgroups=use_hitgroups,
                    distance_setting=distance_setting,
            ):
                menu.append('  ' + message)

        kill_message = self.get_kill_message(
            kill_type=kill_type,
            attacker_name=attacker_name,
            attacker_headshot=attacker_headshot,
            weapon=weapon,
            distance=distance,
            health=health,
            distance_setting=distance_setting,
        )
        if kill_message:
            menu.append(
                SimpleOption(
                    choice_index=4,
                    text=TRANSLATION_STRINGS['Type:Killer'],
                    selectable=False,
                ))
            menu.append('   ' + kill_message)

        menu.send(self.index)
Ejemplo n.º 20
0
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):
    """Admin Players menu's select_callback function."""

    next_menu = menu.callback_menu
    next_menu.player = choice.value
Ejemplo n.º 21
0
    def send_menu_stats(
        self, kill_type, attacker_name, attacker_headshot, weapon, distance,
        health, distance_setting, use_hitgroups
    ):
        """Send victim stats to the player via a menu."""
        wounded_only = {
            username: values
            for username, values in self.given.items()
            if username not in self.killed
        }
        killed_only = {
            username: values
            for username, values in self.given.items()
            if username in self.killed
        }
        menu = SimpleMenu()
        for num, (string_name, group) in enumerate(
            iterable=[
                ('Attackers', self.taken),
                ('Wounded', wounded_only),
                ('Killed', killed_only),
            ],
            start=1
        ):
            if not group:
                continue

            menu.append(
                SimpleOption(
                    choice_index=num,
                    text=TRANSLATION_STRINGS[f'Type:{string_name}'],
                    selectable=False,
                )
            )
            for message in self.iter_messages(
                string_name=string_name,
                group=group,
                use_hitgroups=use_hitgroups,
                distance_setting=distance_setting,
            ):
                menu.append('  ' + message)

        kill_message = self.get_kill_message(
            kill_type=kill_type,
            attacker_name=attacker_name,
            attacker_headshot=attacker_headshot,
            weapon=weapon,
            distance=distance,
            health=health,
            distance_setting=distance_setting,
        )
        if kill_message:
            menu.append(
                SimpleOption(
                    choice_index=4,
                    text=TRANSLATION_STRINGS['Type:Killer'],
                    selectable=False,
                )
            )
            menu.append('   ' + kill_message)

        menu.send(self.index)
Ejemplo n.º 22
0
        menu.close(index)
    elif choice.choice_index == 9:
        menu.close(index)


def _main_menu_build(menu, index):
    menu.clear()
    menu.append(Text('WCS Menu'))
    menu.append(SimpleOption(1, 'shopmenu - buy shop items', 'shopmenu'))
    menu.append(SimpleOption(2, 'shopinfo - show item info', 'shopinfo'))
    menu.append(Text('-------------------'))
    menu.append(
        SimpleOption(3, 'showskills - show all skills levels', 'showskills'))
    menu.append(
        SimpleOption(4, 'resetskills - reset your skills', 'resetskills'))
    menu.append(
        SimpleOption(5, 'spendskills - spend skill points', 'spendskills'))
    menu.append(Text('-------------------'))
    menu.append(SimpleOption(6, 'changerace - choose your race', 'changerace'))
    menu.append(
        SimpleOption(7, 'raceinfo - show info about skills', 'raceinfo'))
    menu.append(Text('-------------------'))
    menu.append(
        SimpleOption(8, 'playerinfo - shows info about a player',
                     'playerinfo'))
    menu.append(Text('-------------------'))
    menu.append(SimpleOption(9, 'Close', highlight=False))


main_menu = SimpleMenu(select_callback=_main_menu_select,
                       build_callback=_main_menu_build)
Ejemplo n.º 23
0
        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():
    path = os.path.dirname(os.path.abspath(__file__))
    return path


@SayCommand('wcsadmin')
@ClientCommand('wcsadmin')
Ejemplo n.º 24
0
    _winner_manager.send_winner_menu(player_dictionary[game_event['winner']])


@Event('gg_team_win')
def _team_win(game_event):
    _winner_manager.send_menu_to_team_winner(game_event['winner'])


# =============================================================================
# >> LISTENERS
# =============================================================================
@OnLevelInit
def _level_init(map_name):
    _winner_manager.set_next_game_mode()


@OnLevelEnd
def _level_end():
    winner_menu.close()


# =============================================================================
# >> MENU CALLBACKS
# =============================================================================
def _chosen_game_mode(parent_menu, index, menu_choice):
    _winner_manager.set_choice(Player(index), menu_choice.value)


winner_menu = SimpleMenu(select_callback=_chosen_game_mode)
winner_menu.title = message_manager['WinnerMenu:Menu']
Ejemplo n.º 25
0
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))
Ejemplo n.º 26
0
            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))


restedexp_menu = SimpleMenu(select_callback=restedexp_menu_select,
                            build_callback=restedexp_menu_build)


@SayCommand('restedxp')
@SayCommand('restedexp')
@ClientCommand('restedxp')
@ClientCommand('restedexp')
def rested_exp_cmd(command, index, team=None):
    restedexp_menu.send(index)


@ServerCommand('saverestedxp')
@ServerCommand('saverestedexp')
def save_rested_cmd(args):
    pickle.save()
Ejemplo n.º 27
0
# WCS Imports
#   Menus
from .base import PagedMenu
from .base import PagedPageCountMenu


# ============================================================================
# >> ALL DECLARATION
# ============================================================================
__all__ = ()


# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
main_menu = SimpleMenu()
shopmenu_menu = PagedPageCountMenu()
shopinfo_menu = PagedPageCountMenu()
shopinfo_detail_menu = SimpleMenu()
showskills_menu = PagedMenu()
resetskills_menu = SimpleMenu()
spendskills_menu = PagedMenu()
changerace_menu = PagedPageCountMenu()
raceinfo_menu = PagedPageCountMenu()
raceinfo_detail_menu = SimpleMenu()
raceinfo_skills_menu = PagedMenu()
raceinfo_skills_detail_menu = SimpleMenu()
raceinfo_race_detail_menu = SimpleMenu()
playerinfo_menu = PagedPageCountMenu()
playerinfo_detail_menu = SimpleMenu()
playerinfo_detail_skills_menu = PagedMenu()
Ejemplo n.º 28
0
class IntegerSetting(SettingsType):
    """Class used to store integer value settings."""

    _type = int

    def __init__(self,
                 name,
                 default,
                 text=None,
                 min_value=None,
                 max_value=None):
        """Store the base attributes on instantiation."""
        super().__init__(name, default, text)
        if min_value is not None and max_value is not None:
            if min_value >= max_value:
                raise ValueError(
                    'min_value ({min_value}) must be less than max_value '
                    '({max_value}).'.format(
                        min_value=min_value,
                        max_value=max_value,
                    ))
        self.min = self._type(min_value) if min_value is not None else None
        self.max = self._type(max_value) if max_value is not None else None
        self.current_values = {}

    def _create_menu(self):
        self.menu = SimpleMenu(
            select_callback=self._chosen_value,
            build_callback=self._menu_build,
        )

    def _menu_build(self, menu, index):
        """Build the menu."""
        self.menu.clear()
        self.menu.append(self.name if self.text is None else self.text)

        # Get the player's information
        player = Player(index)
        uniqueid = player.uniqueid
        current_value = self.get_setting(index)

        description = _settings_strings['Description'].get_string(
            language=player.language,
            value=current_value,
        )
        self.menu.append(description)
        self.menu.append('-' * len(description))
        counter = 1
        if self.min is None or self.max is None or self.max - self.min > 100:
            for value in (100, -100):
                self._add_option(choice_index=counter, value=value)
                counter += 1

        if self.min is None or self.max is None or self.max - self.min > 10:
            for value in (10, -10):
                self._add_option(choice_index=counter, value=value)
                counter += 1

        for value in (1, -1):
            self._add_option(choice_index=counter, value=value)
            counter += 1

        if uniqueid not in self.current_values:
            self.current_values[uniqueid] = current_value

        self.menu.append(
            SimpleOption(
                choice_index=counter,
                text='Save ({current_value})'.format(
                    current_value=self.current_values[uniqueid], ),
                value='Save',
            ))

    def _add_option(self, choice_index, value):
        """Add the value to the menu."""
        self.menu.append(
            SimpleOption(
                choice_index=choice_index,
                text='{:+d}'.format(value),
                value=value,
            ))

    def _chosen_value(self, menu, index, option):
        """Store the player's chosen value for the setting."""
        uniqueid = uniqueid_from_index(index)

        if option.value == 'Save':
            value = self.current_values[uniqueid]

            # Set the player's setting
            _player_settings_storage[uniqueid][self.convar] = value
            self._send_chosen_message(index, value)
            del self.current_values[uniqueid]
            return

        new_value = self.current_values[uniqueid] + option.value
        if self.min is not None:
            new_value = max(new_value, self.min)
        if self.max is not None:
            new_value = min(new_value, self.max)
        self.current_values[uniqueid] = new_value
        self.menu.send()

    def _is_valid_setting(self, value):
        """Return whether the given value is a valid value for the setting."""
        # Is the given value less than the setting's min value?
        if self.min is not None and value < self.min:

            # If too low, return False
            return False

        # Is the given value more than the setting's max value?
        if self.max is not None and value > self.max:

            # If too high, return False
            return False

        # Return True if the value is within the proper range
        return True