From: <wrt...@us...> - 2008-03-18 14:21:51
|
Revision: 8333 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8333&view=rev Author: wrtlprnft Date: 2008-03-18 07:21:36 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Primitive help system. See settings_dedicated.cfg:339 for a description of the new commands Modified Paths: -------------- armagetronad/branches/0.2.8/armagetronad/NEWS armagetronad/branches/0.2.8/armagetronad/config/settings_dedicated.cfg armagetronad/branches/0.2.8/armagetronad/language/english_base.txt armagetronad/branches/0.2.8/armagetronad/src/engine/ePlayer.cpp Modified: armagetronad/branches/0.2.8/armagetronad/NEWS =================================================================== --- armagetronad/branches/0.2.8/armagetronad/NEWS 2008-03-17 20:47:10 UTC (rev 8332) +++ armagetronad/branches/0.2.8/armagetronad/NEWS 2008-03-18 14:21:36 UTC (rev 8333) @@ -153,8 +153,10 @@ enabled. In this case the server will delay the start of the next round until WAIT_FOR_EXTENAL_SCRIPT_TIMEOUT is reached or the setting is disabled. -- Wrapped console lines are indented by an amount of spaces that can be +- Wrapped console lines are indented by an amount of spaces that can be specified using the setting CONSOLE_INDENT. +- /help command that supports multiple help topics. Use + HELP_INTRODUCTORY_BLURB and ADD_HELP_TOPIC to control its contents Bugfixes: - Text input fields now let the text wrap correctly and make use of the space allocated Modified: armagetronad/branches/0.2.8/armagetronad/config/settings_dedicated.cfg =================================================================== --- armagetronad/branches/0.2.8/armagetronad/config/settings_dedicated.cfg 2008-03-17 20:47:10 UTC (rev 8332) +++ armagetronad/branches/0.2.8/armagetronad/config/settings_dedicated.cfg 2008-03-18 14:21:36 UTC (rev 8333) @@ -336,6 +336,30 @@ TEAM_BLUE_7 15 # blue portion of team 7's color TEAM_BLUE_8 7 # blue portion of team 8's color +# Help stuff + +# This is a message that will be displayed if someone uses the /help chat +# command without arguments: + +HELP_INTRODUCTORY_BLURB + +# to add your own help topics you can use the following command: + +# ADD_HELP_TOPIC <identifier> "short description" "help\ntext\nthat\ncan\nspan\nmany\nlines" + +# the quotes are required if you want to use spaces. +# if the identifier contains underscores (_) it will be treated as a +# sub-identifier. For example, if you have an identifier "rules" and an +# identifier "rules_swearing", the last one will not appear on the listing +# you get with a plain "/help", but it will be at the bottom of the text +# you get with /help rules. You can nest them as deeply as you want, but +# remember that the player who seeks help has to type your identifiers... + +# to get rid of a help command (either in scripts of if it was added by +# accident you can use + +# REMOVE_HELP_TOPIC <identifier> + #TEAM_ALLOW_SHUFFLE_UP 0 # if set to 1, players are allowed to change their position in the team as they wish. If 0, they only can drop in rank. TEAM_CENTER_IS_BOSS 1 # if set to 1, the center player is the team's boss. If at 0, it's the player who is on that team longest. Modified: armagetronad/branches/0.2.8/armagetronad/language/english_base.txt =================================================================== --- armagetronad/branches/0.2.8/armagetronad/language/english_base.txt 2008-03-17 20:47:10 UTC (rev 8332) +++ armagetronad/branches/0.2.8/armagetronad/language/english_base.txt 2008-03-18 14:21:36 UTC (rev 8333) @@ -2205,6 +2205,45 @@ player_noshuffle Your shuffling wish has no effect.\n player_shuffle_error /shuffle expects a number as argument; an explicit sign (+/-) will change your position by the indicated number of steps, no sign will shuffle you to the given position.\n +add_help_topic_help Add a new help topic to be used with /help. Usage: ADD_HELP_TOPIC <topic> <short description> <text> +add_help_topic_usage Usage: ADD_HELP_TOPIC <topic> <short description> <text>\n +add_help_topic_success Added help topic "\1".\n +remove_help_topic_help Remove a help topic. +remove_help_topic_success Removed help topic "\1".\n +remove_help_topic_notfound Help topic "\1" doesn't exist.\n + +help_introductory_blurb_help Message that is displayed before the list of help topics if someone uses /help without arguments + +help_topics_list_start Say /help TOPIC to get help on the following topics.\n +help_topic_not_found Help topic \1 not found. Try /help with no arguments to see a list of available topics.\n + +help_commands_shortdesc List of all chat commands +help_commands_text This help topic is empty. Use one of the following sub-topics instead: + +help_commands_chat_shortdesc Basic chat commands +help_commands_chat_text 0x88ff88/me <message>0xffff88: Transmit an action, as in "/me is a noob."\n0x88ff88/msg <part of a nickname> <message>0xffff88: Send a private message that only a specific player can see\n0x88ff88/team <message>0xffff88: Send a message to your teammates, or to all spectators if you're not on a team + +help_commands_team_shortdesc Basic team management commands +help_commands_team_text 0x88ff88/teamshuffle0xffff88: Shuffle yourself to be at the outside of your team's wingmen formation\n0x88ff88/teamshuffle <position>0xffff88: Shuffle yourself to be at a specific position\n0x88ff88/teamshuffle [+|-]<offset>0xffff88: Shuffle yourself up/down by a certain number of ranks\n0x88ff88/teamleave0xffff88: Leave your current team. Only works on some servers\n0x88ff88/teams0xffff88: Get a list of all teams with a somewhat graphic representation of their formation + +help_commands_pp_shortdesc Player police commands +help_commands_pp_text 0x88ff88/players0xffff88: Get a list of all players, along with some other information\n0x88ff88/vote kick|suspend <player>0xffff88: Start a poll to kick or suspend a player + +help_commands_auth_shortdesc Authentication related commands +help_commands_auth_text 0x88ff88/login @<authority>0xffff88: Authenticate yourself using a given authority. Try @forums if you have an account at http://forums.armagetronad.net\n0x88ff88/logout0xffff88: Log out so you can log back in as another player\n0x88ff88/vote include <file>0xffff88: Start a poll to include a given file\n0x88ff88/vote command <command>0xffff88: Start a poll to execute an admin command\n0x88ff88/admin <command>0xffff88: Execute a console command on the server if you have sufficient access rights\n0x88ff88/op <player> <optional access level>0xffff88: Gives another player a higher access level; the level defaults to the level one lower than you access level, which is also the maximal possible level\n0x88ff88/deop <player>0xffff88: Reverses /op; it takes away a player's access level, effectively making him unauthenticated again. Only works on players of lower access level than yours, of course.\n0x88ff88/promote <player> <optional steps>0xffff88: elevates a player's access level the given number of steps (default: one)\n0x88ff88/demote <player> <optional steps>0xffff88: lowers a player's access level the given number of steps (default: one) + +help_commands_auth_levels_shortdesc List of all access levels +help_commands_auth_levels_text 0x88ff880 (Owner)0xffff88: The owner of the server. Commands entered on the server console are executed with these rights.\n0x88ff881 (Admin)0xffff88: A server administrator. By default, almost as powerful as the owner himself.\n0x88ff882 (Moderator)0xffff88: A server moderator. Is still allowed to use /admin, but is restricted to player management commands.\n0x88ff887 (Team Leader)0xffff88: Leader of a team. By default, no admin rights at all.\n0x88ff888 (Team Member)0xffff88: Member of a team. Local team accounts get this level.\n0x88ff8812 (Local User)0xffff88: Players with local accounts get this level.\n0x88ff8815 (Remote User)0xffff88: Players with remote accounts get this level by default.\n0x88ff8816 (Fallen from Grace)0xffff88: Authenticated players who abused default rights given to them.\n0x88ff8817 (Shunned)0xffff88: Same, only worse :)\n0x88ff8819 (Authenticated)0xffff88: Minimal level authenticated players can get.\n0x88ff8820 (Program)0xffff88: Unauthenticated players. + +help_commands_ra_shortdesc Remote admin commands +help_commands_ra_text 0x88ff88/login <password>0xffff88: Log in as the server administrator using the server-specific password\n0x88ff88/logout0xffff88: Drop your logged in status so that other players can't see that you're an administrator\n0x88ff88/admin <command>0xffff88: Execute a console command as if it were entered on the server + +help_commands_misc_shortdesc Miscellaneous commands +help_commands_misc_text 0x88ff88/help0xffff88: You just found out about this one :-)\n0x88ff88/command <command>0xffff88: Execute a command on your own client. Useful for instant chats + +help_commands_tourney_shortdesc Tourney related commands +help_commands_tourney_text 0x88ff88/lock0xffff88: Locks your current team. Nobody can join it any more on their own. To let someone in, you need to invoke\n0x88ff88/invite <player>0xffff88: From that moment on, the player is allowed to join you. Another effect of /invite, even if your team is not locked, is that the invited player can read all of your team's /team messages. Invitations are permanent until revoked. That means a player who is invited into your team can join and leave it freely without further need to /invite him again. Players who were on the team when you /locked it are not automatically invited when they leave on their own account.\n0x88ff88/uninvite <player>0xffff88: reverses /invite. The invitation is revoked, the player can no longer join you, and if he currently is on your team, he will be thrown out.\n0x88ff88/unlock0xffff88: makes your team available for everyone to join again. + invite_no_team Can't use \1 if you're not on a team.\n invite_team_locked \1 locked, you'll need an invitation from a team leader via the /invite command to join from now on.\n invite_team_unlocked \1 unlocked, you can join it freely again.\n Modified: armagetronad/branches/0.2.8/armagetronad/src/engine/ePlayer.cpp =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/engine/ePlayer.cpp 2008-03-17 20:47:10 UTC (rev 8332) +++ armagetronad/branches/0.2.8/armagetronad/src/engine/ePlayer.cpp 2008-03-18 14:21:36 UTC (rev 8333) @@ -2948,6 +2948,127 @@ se_ListTeam( p, p->CurrentTeam() ); } +class eHelpTopic { + tString m_shortdesc, m_text; + static std::map<tString, eHelpTopic> s_helpTopics; +public: + eHelpTopic() {}; + eHelpTopic(tString const &shortdesc, tString const &text) : m_shortdesc(shortdesc), m_text(text) { + } + + void write(tColoredString &s) const { + s << tColoredString::ColorString(.5,.5,1.) << tOutput(&m_shortdesc[0]) << ":\n" << tOutput(&m_text[0]) << '\n'; + } + + static void addHelpTopic(std::istream &s) { + tString name, shortdesc, text; + s >> name >> shortdesc; + if(s.fail()) { + if(tConfItemBase::printErrors) { + con << tOutput("$add_help_topic_usage"); + } + return; + } + s >> text; + s_helpTopics[name] = eHelpTopic(shortdesc, text); + if(tConfItemBase::printChange) { + con << tOutput("$add_help_topic_success", name); + } + } + + static void removeHelpTopic(std::istream &s) { + tString name; + s >> name; + if(s_helpTopics.erase(name)) { + if(tConfItemBase::printChange) { + con << tOutput("$remove_help_topic_success", name); + } + } else { + if(tConfItemBase::printErrors) { + con << tOutput("$remove_help_topic_notfound", name); + } + } + } + +private: + + static void listTopics(tColoredString &s, tString const &base, std::map<tString, eHelpTopic>::const_iterator begin, std::map<tString, eHelpTopic>::const_iterator const &end) { + bool printed_start = false; + for(;begin != end; ++begin) { + if(!begin->first.StartsWith(base)) { + continue; + } + // would be easier with std::string... + if(begin->first.SubStr(base.Len() - 1).StrPos("_") >= 0) { + // don't print subcommands + continue; + } + if(!printed_start) { + printed_start = true; + s << tOutput("$help_topics_list_start"); + } + s << tColoredString::ColorString(.5,.5,1.) << begin->first << tColoredString::ColorString(1.,1.,.5) << ": " << tOutput(&begin->second.m_shortdesc[0]) << "\n"; + } + } + +public: + + static void listTopics(tColoredString &s, tString const &base=tString()) { + listTopics(s, base, s_helpTopics.begin(), s_helpTopics.end()); + } + + static void printTopic(tColoredString &s, tString const &name) { + std::map<tString, eHelpTopic>::const_iterator iter = s_helpTopics.find(name); + if(iter != s_helpTopics.end()) { + iter->second.write(s); + listTopics(s, name + "_"); + } else { + s << tOutput("$help_topic_not_found", name); + } + } +}; +static std::pair<tString, eHelpTopic> se_makeDefaultHelpTopic(char const *topic) { + tString topicStr(topic); + tString helpTopic(tString("$help_") + topicStr); + return std::pair<tString, eHelpTopic>(topicStr, eHelpTopic(helpTopic + "_shortdesc", helpTopic + "_text")); +} +static std::pair<tString, eHelpTopic> se_defaultHelpTopics[] = { + se_makeDefaultHelpTopic("commands"), + se_makeDefaultHelpTopic("commands_chat"), + se_makeDefaultHelpTopic("commands_team"), +#ifdef KRAWALL_SERVER + se_makeDefaultHelpTopic("commands_auth"), + se_makeDefaultHelpTopic("commands_auth_levels"), + se_makeDefaultHelpTopic("commands_tourney"), +#else + se_makeDefaultHelpTopic("commands_ra"), +#endif + se_makeDefaultHelpTopic("commands_misc"), + se_makeDefaultHelpTopic("commands_pp") +}; +std::map<tString, eHelpTopic> eHelpTopic::s_helpTopics(se_defaultHelpTopics, se_defaultHelpTopics + sizeof(se_defaultHelpTopics)/sizeof(eHelpTopic)); + +static tConfItemFunc add_help_topic_conf("ADD_HELP_TOPIC",&eHelpTopic::addHelpTopic); +static tConfItemFunc remove_help_topic_conf("REMOVE_HELP_TOPIC",&eHelpTopic::removeHelpTopic); +static tString se_helpIntroductoryBlurb; +static tConfItemLine se_helpIntroductoryBlurbConf("HELP_INTRODUCTORY_BLURB",se_helpIntroductoryBlurb); + +static void se_Help( ePlayerNetID * p, std::istream & s ) { + std::ws(s); + tColoredString reply; + if(s.eof() || s.fail()) { + if(se_helpIntroductoryBlurb.Len() > 1) { + reply << se_helpIntroductoryBlurb << "\n\n"; + } + eHelpTopic::listTopics(reply); + } else { + tString name; + s >> name; + eHelpTopic::printTopic(reply, name); + } + sn_ConsoleOut(reply, p->Owner()); +} + void handle_chat( nMessage &m ) { nTimeRolling currentTime = tSysTimeFloat(); @@ -3032,6 +3153,10 @@ se_ChatTeams( p ); return; } + else if (command == "/help") { + se_Help( p, s ); + return; + } #ifdef DEDICATED else { handle_chat_admin_commands( p, command, say, s ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |