From: <no...@so...> - 2002-01-18 07:07:20
|
Patches item #443689, was opened at 2001-07-22 20:45 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=303248&aid=443689&group_id=3248 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Brandon Hechinger (brandonh) Assigned to: Nobody/Anonymous (nobody) Summary: Message Verbosity Setting Initial Comment: Allows a setting (0-10) to adjust/limit which types of messages are displayed. Modifies: src/bzflag/ControlPanel.cxx src/bzflag/KeyMap.cxx src/bzflag/playing.cxx src/bzflag/ControlPanel.h src/bzflag/KeyMap.h include/global.h Adds two keys ([ and ]) for run-time adjustment of the message level. For example, level 4 displays MsgType's 0-4 (see global.h). Calls to addMessage() without a MsgType passed will default to MsgOther, which currently is the highest-priority (will always display). I left code in addMessage() so you can #define SHOW_MSGTYPES (at the top of ControlPanel.cxx is a good place). This makes addMessage() display the msgType (#) on each line, (in case one wishes to make adjustments). ---------------------------------------------------------------------- Comment By: Dave Brosius (dbrosius) Date: 2002-01-17 23:07 Message: Logged In: YES user_id=66596 After playing with this patch for awhile, I really would prefer if the different types of messages were bit settings, like FlagMessages = 1 KillMessages = 2 PlayerMessages = 4 etc, etc Then hitting [ or ] would cycle through 1, 2, ....7 and would show messages if the value of the variable had the appropriate bit set. When you hit [ or ] and let say the current value was 3, it would show Show Messages: (Flag)(Kill) moving to 4 would display Show Messages: (Player) moving to 5 would display Show Messages: (Flag)(Player) etc, etc Never show the actual numeric value (it means nothing to user). In this way I can get any combination of messages that I want, and I know what each setting corresponds to. The current way it is implemented, there is a hardcoded order to the importance of messages, with difficult to remember numeric values. There's no way to see the least and most important messages only, for instance. I like the general idea, though... Thanks for the patch. Just my opinion. ---------------------------------------------------------------------- Comment By: Dave Brosius (dbrosius) Date: 2002-01-03 15:51 Message: Logged In: YES user_id=66596 Hey Brandon, Just tried out your flag, works good! Couple things. 1) If you push ] when your at 10, perhaps should show setting even though hasn't changed. 2) Also, I'd like some clear way to discern what each value corresponds to... Hmmmm, ideas? But anyhooo.... Works good... BTW, when I tried to patch it to the current sources, I got merge conflicts, so I took the liberty of fixing them up ... here it is... ----------------------------------------------------------- Index: bzflag/include/global.h =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/include/global.h,v retrieving revision 1.5 diff -u -r1.5 global.h --- bzflag/include/global.h 2001/11/15 09:37:06 1.5 +++ bzflag/include/global.h 2002/01/03 23:45:39 @@ -256,4 +256,24 @@ const float MomentumAngAcc= 1.0f; // const float MagnetPower = 0.0f; // off +/* message types (for ControlPanel::addMessage()) + * Used for reducing on the scroll (with the VerboseThresh setting) + * Lower numbers = Higher priority + * The actual compare is done in the ControlPanel::addMessage() using + * MSG_MAXTYPE-msgType + */ +enum MsgType { + MsgOther = 0, // Always displays + MsgSystem, // System and Network messages + MsgTeamtalk, // Talk from teammates + MsgTalk, // Global talk + MsgMine, // My own messages (death, kills, ...) + MsgMyflags, // My own flags + MsgFlags, // Other users' flags + MsgOthermisc, // Network (problem) (like not-responding) + MsgKills, // Other user kills + MsgOtheract, // Other user activity (joins, exits, pause, ...) + MsgMaxType +}; + #endif // BZF_GLOBAL_H Index: bzflag/src/bzflag/ControlPanel.cxx =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/ControlPanel.cxx,v retrieving revision 1.10 diff -u -r1.10 ControlPanel.cxx --- bzflag/src/bzflag/ControlPanel.cxx 2001/11/30 04:36:56 1.10 +++ bzflag/src/bzflag/ControlPanel.cxx 2002/01/03 23:45:43 @@ -47,6 +47,7 @@ // ControlPanel // +int ControlPanel::msgVerbosity = MsgMaxType; const int ControlPanel::maxLines = 30; const int ControlPanel::maxScrollPages = 4; int ControlPanel::messagesOffset = 0; @@ -515,6 +516,34 @@ } } +void ControlPanel::showMsgVerbosity (void) +{ + char buf[5]; + BzfString msg; + + msg = "Message Verbosity (0-"; + sprintf(buf, "%d", MsgMaxType); + msg += buf; + msg += "): "; + sprintf(buf, "%d", msgVerbosity); + msg += buf; + addMessage(msg, MsgOther); +} + +void ControlPanel::incMsgVerbosity(int i) +{ + BzfString msg; + char show=1; + if (i>-1) { + if (msgVerbosity < (int)MsgMaxType) msgVerbosity++; + else show=0; + } else { + if (msgVerbosity) msgVerbosity--; + else show=0; + } + if (show) showMsgVerbosity(); +} + void ControlPanel::setMessagesOffset (int offset, int whence) { // offset = offset from whence (offset of 0 is the bottom/most recent) // whence = 0, 1, or 2 (akin to SEEK_SET, SEEK_CUR, SEEK_END) @@ -549,9 +578,22 @@ } void ControlPanel::addMessage(const BzfString& line, + MsgType msgType, const GLfloat* color) { +#ifdef SHOW_MSGTYPES + BzfString msg; +#endif + if ((int)msgType > msgVerbosity) return; + +#ifdef SHOW_MSGTYPES + msg = line; + msg += " "; + msg += msgType; + ControlPanelMessage item(msg, color); +#else ControlPanelMessage item(line, color); +#endif if (messages.getLength() < maxLines * maxScrollPages) { // not full yet so just append it Index: bzflag/src/bzflag/ControlPanel.h =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/ControlPanel.h,v retrieving revision 1.5 diff -u -r1.5 ControlPanel.h --- bzflag/src/bzflag/ControlPanel.h 2001/03/04 16:35:56 1.5 +++ bzflag/src/bzflag/ControlPanel.h 2002/01/03 23:45:44 @@ -43,8 +43,12 @@ void setNumberOfFrameBuffers(int); - void addMessage(const BzfString&, const GLfloat* = NULL); - void setMessagesOffset(int offset, int whence); + void showMsgVerbosity(void); + void incMsgVerbosity(int i = 1); + + void addMessage(const BzfString&, MsgType msgType = MsgOther, + const GLfloat* = NULL); + void setMessagesOffset(int offset, int whence); void setStatus(const char*); void resetTeamCounts(); void setTeamCounts(const int* counts); @@ -105,6 +109,7 @@ static int messagesOffset; static const int maxScrollPages; static const int maxLines; + static int msgVerbosity; }; #endif // BZF_CONTROL_PANEL_H Index: bzflag/src/bzflag/KeyMap.cxx =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/KeyMap.cxx,v retrieving revision 1.10 diff -u -r1.10 KeyMap.cxx --- bzflag/src/bzflag/KeyMap.cxx 2001/11/30 04:36:56 1.10 +++ bzflag/src/bzflag/KeyMap.cxx 2002/01/03 23:45:45 @@ -33,7 +33,10 @@ { 0, BzfKeyEvent::F12, 0 }, { 0, BzfKeyEvent::PageUp, 0 }, { 0, BzfKeyEvent::PageDown, 0 }, - { 'a', 0, 0 } + { 'a', 0, 0 }, + { '[', 0, 0 }, + { ']', 0, 0 } + }; const BzfKeyEvent BzfKeyMap::defaults2[] = { { '\r', 0, 0 }, @@ -78,6 +81,8 @@ "scrollBackwardKey", "scrollForwardKey", "slowKeyboardMotion", + "decVerbosityKey", + "incVerbosityKey" }; const char* BzfKeyMap::eventNames[] = { @@ -142,6 +147,8 @@ reset(ScrollBackward); reset(ScrollForward); reset(SlowKeyboardMotion); + reset(decMsgVerbosity); + reset(incMsgVerbosity); } void BzfKeyMap::reset(Key key) Index: bzflag/src/bzflag/KeyMap.h =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/KeyMap.h,v retrieving revision 1.8 diff -u -r1.8 KeyMap.h --- bzflag/src/bzflag/KeyMap.h 2001/11/30 04:36:56 1.8 +++ bzflag/src/bzflag/KeyMap.h 2002/01/03 23:45:46 @@ -44,6 +44,8 @@ ScrollBackward, ScrollForward, SlowKeyboardMotion, + decMsgVerbosity, + incMsgVerbosity, LastKey }; Index: bzflag/src/bzflag/playing.cxx =========================================================== ======== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/playing.cxx,v retrieving revision 1.59 diff -u -r1.59 playing.cxx --- bzflag/src/bzflag/playing.cxx 2001/12/06 10:26:25 1.59 +++ bzflag/src/bzflag/playing.cxx 2002/01/03 23:46:21 @@ -727,6 +727,15 @@ } } + else if (keymap.isMappedTo(BzfKeyMap::decMsgVerbosity, key)) { + // increment verbosity level + if (pressed) controlPanel->incMsgVerbosity(-1); + } + else if (keymap.isMappedTo(BzfKeyMap::incMsgVerbosity, key)) { + // increment verbosity level + if (pressed) controlPanel->incMsgVerbosity(1); + } + else if (keymap.isMappedTo(BzfKeyMap::Score, key)) { // toggle score board if (pressed) { @@ -764,7 +773,7 @@ if (myTank->isAlive()) { if (myTank->isPaused()) { myTank->setPause(False); - controlPanel->addMessage("Resumed"); + controlPanel->addMessage("Resumed", MsgMine); // restore the sound if (savedVolume != -1) { @@ -982,7 +991,7 @@ pauseCountdown = 0.0f; if (myTank && myTank->isAlive() && myTank->isPaused ()) { myTank->setPause(False); - controlPanel->addMessage("Resumed"); + controlPanel->addMessage("Resumed", MsgMine); } } @@ -1129,6 +1138,7 @@ static void addMessage(const Player* player, const BzfString& msg, + MsgType msgType = MsgOther, const GLfloat* color = NULL) { BzfString fullMessage; @@ -1150,7 +1160,7 @@ if (player && color == NULL) color = Team::getRadarColor(player->getTeam()); #endif - controlPanel->addMessage(fullMessage, color); + controlPanel->addMessage(fullMessage, msgType, color); } static void updateNumPlayers() @@ -1321,7 +1331,7 @@ name += message; message = name; } - addMessage(player[i], message); + addMessage(player[i], message, MsgOtheract); } // restore player's local score if player had been playing earlier @@ -1334,6 +1344,7 @@ uint16_t, void* msg) { boolean checkScores = False; + MsgType msgType; switch (code) { case MsgUDPLinkRequest: @@ -1435,7 +1446,7 @@ msg = id.unpack(msg); int playerIndex = lookupPlayerIndex(id); if (playerIndex >= 0) { - addMessage(player[playerIndex], "signing off"); + addMessage(player[playerIndex], "signing off", MsgOtheract); world->addDeadPlayer(player[playerIndex]); delete player[playerIndex]; player[playerIndex] = NULL; @@ -1558,22 +1569,25 @@ } } + if (killerPlayer == myTank || victimPlayer == myTank) msgType=MsgMine; + else msgType=MsgKills; + // add message if (human && victimPlayer) { if (killerPlayer == victimPlayer) - addMessage(victimPlayer, "blew myself up"); + addMessage(victimPlayer, "blew myself up", MsgMine); else if (!killerPlayer) - addMessage(victimPlayer, "destroyed by <unknown>"); + addMessage(victimPlayer, "destroyed by <unknown>", msgType); else if (killerPlayer->getTeam() == victimPlayer- >getTeam() && killerPlayer- >getTeam() != RogueTeam) { BzfString message("destroyed by teammate "); message += killerPlayer->getCallSign(); - addMessage(victimPlayer, message); + addMessage(victimPlayer, message, msgType); } else { BzfString message("destroyed by "); message += killerPlayer->getCallSign(); - addMessage(victimPlayer, message); + addMessage(victimPlayer, message, msgType); } } @@ -1640,7 +1654,7 @@ BzfString message("grabbed "); message += Flag::getName(tank->getFlag()); message += " flag"; - addMessage(tank, message); + addMessage(tank, message, (tank==myTank) ? MsgMyflags : MsgFlags); } break; } @@ -1678,13 +1692,13 @@ BzfString message("took my flag into "); message += Team::getName(TeamColor(team)); message += " territory"; - addMessage(capturer, message); + addMessage(capturer, message, MsgMyflags); } else { BzfString message("captured "); message += Team::getName(TeamColor (capturedTeam)); message += "'s flag"; - addMessage(capturer, message); + addMessage(capturer, message, MsgFlags); } } @@ -1835,7 +1849,7 @@ fullMsg += "] "; fullMsg += (const char*)msg; } - addMessage(NULL, fullMsg, Team::getRadarColor (RogueTeam)); + addMessage(NULL, fullMsg, MsgTalk, Team::getRadarColor(RogueTeam)); break; } if (!srcPlayer) { @@ -1843,7 +1857,7 @@ fullMsg = "(UNKNOWN) "; fullMsg += (const char*)msg; - addMessage(NULL, fullMsg, Team::getRadarColor (RogueTeam)); + addMessage(NULL, fullMsg, MsgTalk, Team::getRadarColor(RogueTeam)); break; } if (!strncmp((char *)msg,"CLIENTQUERY",strlen ("CLIENTQUERY"))) { @@ -1863,7 +1877,8 @@ else msgColor = Team::getRadarColor(srcPlayer- >getTeam()); - addMessage(srcPlayer,"[Sent versioninfo per request]", msgColor); + addMessage(srcPlayer,"[Sent versioninfo per request]", + MsgSystem, msgColor); break; } fullMsg += (const char*)msg; @@ -1872,7 +1887,7 @@ msgColor = Team::getRadarColor(RogueTeam); else msgColor = Team::getRadarColor(srcPlayer->getTeam ()); - addMessage(srcPlayer, fullMsg, msgColor); + addMessage(srcPlayer, fullMsg, MsgTalk, msgColor); // HUD one line display fullMsg = srcPlayer->getCallSign(); @@ -1947,7 +1962,7 @@ if ((oldStatus & short(Player::Paused)) != (newStatus & short (Player::Paused))) addMessage(tank, (tank->getStatus() & Player::Paused) ? - "Paused" : "Resumed"); + "Paused" : "Resumed", MsgOtheract); if ((oldStatus & short(Player::Exploding)) == 0 && (newStatus & short(Player::Exploding)) != 0) { // player has started exploding and we haven't gotten killed @@ -2332,7 +2347,7 @@ BzfString message("dropped "); message += Flag::getName(tank->getFlag()); message += " flag"; - addMessage(tank, message); + addMessage(tank, message, (tank == myTank) ? MsgMyflags : MsgFlags); // player no longer has flag tank->setFlag(NoFlag); @@ -2392,7 +2407,7 @@ // print reason if it's my tank if (tank == myTank && blowedUpMessage[reason]) { - controlPanel->addMessage(blowedUpMessage[reason]); + controlPanel->addMessage(blowedUpMessage[reason], MsgMine); hud->setAlert(0, blowedUpMessage[reason], 4.0f, True); } @@ -2573,11 +2588,11 @@ else { msg += ")"; } - addMessage(NULL, msg); + addMessage(NULL, msg, MsgMine); hud->setAlert(1, msg, 2.0f, 1); } else if (myTank->getFlag() == ColorblindnessFlag) { - addMessage(NULL, "Looking at a tank"); + addMessage(NULL, "Looking at a tank", MsgMine); hud->setAlert(1, "Looking at a tank", 2.0f, 0); } else { @@ -2592,7 +2607,7 @@ else { msg += ")"; } - addMessage(NULL, msg); + addMessage(NULL, msg, MsgMine); hud->setAlert(1, msg, 2.0f, 0); myTank->setNemesis(bestTarget); } @@ -3523,10 +3538,10 @@ player[i]->doDeadReckoning(); const boolean isNotResponding = player[i]- >isNotResponding(); if (!wasNotResponding && isNotResponding) { - addMessage(player[i], BzfString("not responding")); + addMessage(player[i], BzfString("not responding"), MsgOthermisc); } else if (wasNotResponding && !isNotResponding) { - addMessage(player[i], BzfString("okay")); + addMessage(player[i], BzfString("okay"), MsgOthermisc); } } @@ -3640,7 +3655,7 @@ // now actually pause myTank->setPause(True); hud->setAlert(1, NULL, 0.0f, True); - controlPanel->addMessage("Paused"); + controlPanel->addMessage("Paused", MsgMine); // turn off the sound if (savedVolume == -1) { @@ -4612,6 +4627,7 @@ controlPanel->addMessage(copyright); controlPanel->addMessage("Author: Chris Schoeneman <cr...@bi...>"); controlPanel->addMessage("Maintainer: Tim Riker <Tim@Rikers.org>"); + controlPanel->showMsgVerbosity(); // print OpenGL renderer controlPanel->addMessage((const char*)glGetString (GL_RENDERER)); ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=303248&aid=443689&group_id=3248 |