Changeset 2349 for code/branches/questsystem3/src/orxonox/overlays
- Timestamp:
- Dec 6, 2008, 9:46:11 PM (16 years ago)
- Location:
- code/branches/questsystem3/src/orxonox/overlays/notifications
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.cc
r2346 r2349 104 104 continue; 105 105 106 text = text + "\n\n\n------------\n\n" + c ontainer->notification->getTitle() + "\n\n" + container->notification->getMessage();106 text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage()); 107 107 } 108 108 … … 110 110 } 111 111 112 const std::string & NotificationManager::clipMessage(const std::string & message)112 const std::string NotificationManager::clipMessage(const std::string & str) 113 113 { 114 std::string* clippedMessageP = new std::string(); 115 std::string clippedMessage = *clippedMessageP; 116 clippedMessage = ""; 117 std::string tempWord = ""; 114 115 std::string message = str; 116 unsigned int i = 0; 117 118 unsigned int found = message.find("\\n", i); 119 while(found != std::string::npos) 120 { 121 message.replace(found, 2, "\n"); 122 i = found+2; 123 found = message.find("\\n", i); 124 } 125 126 std::string clippedMessage = ""; 118 127 int wordLength = 0; 119 signed inti = 0;128 i = 0; 120 129 int widthLeft = NotificationQueue::queue_s->getWidth(); 121 130 while(i < message.length()) … … 123 132 while(i < message.length() && message[i] != ' ' && message[i] != '\n') 124 133 { 125 tempWord = tempWord + message[i];126 134 i++; 127 135 wordLength++; … … 130 138 if(wordLength <= widthLeft) 131 139 { 132 clippedMessage = clippedMessage + tempWord + message[i]; 140 clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength); 141 if(i < message.length()) 142 { 143 clippedMessage = clippedMessage + message.substr(i,1); 144 } 133 145 widthLeft -= (wordLength+1); 146 if(message[i] == '\n') 147 { 148 widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1); 149 } 134 150 wordLength = 0; 135 tempWord = "";136 151 i++; 137 152 } 138 153 else 139 154 { 140 clippedMessage = clippedMessage + '\n' + tempWord + message[i]; 155 clippedMessage.push_back('\n'); 156 clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength); 157 if(i < message.length()) 158 { 159 clippedMessage = clippedMessage + message.substr(i,1); 160 } 141 161 widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1); 142 162 i++; 143 163 wordLength = 0; 144 tempWord = "";145 164 } 146 165 } -
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.h
r2346 r2349 66 66 67 67 static void updateQueue(void); 68 static const std::string &clipMessage(const std::string & message);68 static const std::string clipMessage(const std::string & message); 69 69 70 70 };
Note: See TracChangeset
for help on using the changeset viewer.