mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Style tweaks: preface privates with underscore, capitalize enum members.
This commit is contained in:
parent
c6661e8b8e
commit
46041b2ed9
6 changed files with 32 additions and 28 deletions
|
@ -654,7 +654,7 @@ void Avatar::render(bool lookingInMirror) {
|
|||
glTranslatef(width * 0.5, 0, 0);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
if (_keyState == NoKeyDown) {
|
||||
if (_keyState == NO_KEY_DOWN) {
|
||||
drawtext(0, 0, chatMessageScale, 180, 1.0, 0, _chatMessage.c_str(), 0, 1, 0);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -15,8 +15,8 @@ using namespace std;
|
|||
const int MAX_CONTENT_LENGTH = 140;
|
||||
|
||||
void ChatEntry::clear () {
|
||||
contents.clear();
|
||||
cursorPos = 0;
|
||||
_contents.clear();
|
||||
_cursorPos = 0;
|
||||
}
|
||||
|
||||
bool ChatEntry::key(unsigned char k) {
|
||||
|
@ -25,22 +25,22 @@ bool ChatEntry::key(unsigned char k) {
|
|||
return false;
|
||||
|
||||
case '\b':
|
||||
if (cursorPos != 0) {
|
||||
contents.erase(cursorPos - 1, 1);
|
||||
cursorPos--;
|
||||
if (_cursorPos != 0) {
|
||||
_contents.erase(_cursorPos - 1, 1);
|
||||
_cursorPos--;
|
||||
}
|
||||
return true;
|
||||
|
||||
case 127: // delete
|
||||
if (cursorPos < contents.size()) {
|
||||
contents.erase(cursorPos, 1);
|
||||
if (_cursorPos < _contents.size()) {
|
||||
_contents.erase(_cursorPos, 1);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (contents.size() != MAX_CONTENT_LENGTH) {
|
||||
contents.insert(cursorPos, 1, k);
|
||||
cursorPos++;
|
||||
if (_contents.size() != MAX_CONTENT_LENGTH) {
|
||||
_contents.insert(_cursorPos, 1, k);
|
||||
_cursorPos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -49,24 +49,24 @@ bool ChatEntry::key(unsigned char k) {
|
|||
void ChatEntry::specialKey(unsigned char k) {
|
||||
switch (k) {
|
||||
case GLUT_KEY_LEFT:
|
||||
if (cursorPos != 0) {
|
||||
cursorPos--;
|
||||
if (_cursorPos != 0) {
|
||||
_cursorPos--;
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_KEY_RIGHT:
|
||||
if (cursorPos != contents.size()) {
|
||||
cursorPos++;
|
||||
if (_cursorPos != _contents.size()) {
|
||||
_cursorPos++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatEntry::render(int screenWidth, int screenHeight) {
|
||||
drawtext(20, screenHeight - 150, 0.10, 0, 1.0, 0, contents.c_str(), 1, 1, 1);
|
||||
drawtext(20, screenHeight - 150, 0.10, 0, 1.0, 0, _contents.c_str(), 1, 1, 1);
|
||||
|
||||
float width = 0;
|
||||
for (string::iterator it = contents.begin(), end = it + cursorPos; it != end; it++) {
|
||||
for (string::iterator it = _contents.begin(), end = it + _cursorPos; it != end; it++) {
|
||||
width += glutStrokeWidth(GLUT_STROKE_ROMAN, *it)*0.10;
|
||||
}
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
class ChatEntry {
|
||||
public:
|
||||
|
||||
const std::string& getContents () const { return contents; }
|
||||
const std::string& getContents () const { return _contents; }
|
||||
|
||||
void clear ();
|
||||
|
||||
|
@ -25,9 +25,8 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
std::string contents;
|
||||
|
||||
int cursorPos;
|
||||
std::string _contents;
|
||||
int _cursorPos;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__ChatEntry__) */
|
||||
|
|
|
@ -1389,7 +1389,7 @@ void specialkey(int k, int x, int y)
|
|||
|
||||
void keyUp(unsigned char k, int x, int y) {
|
||||
if (::chatEntryOn) {
|
||||
myAvatar.setKeyState(AvatarData::NoKeyDown);
|
||||
myAvatar.setKeyState(NO_KEY_DOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1407,7 @@ void key(unsigned char k, int x, int y)
|
|||
if (::chatEntryOn) {
|
||||
if (chatEntry.key(k)) {
|
||||
myAvatar.setKeyState(k == '\b' || k == 127 ? // backspace or delete
|
||||
AvatarData::DeleteKeyDown : AvatarData::InsertKeyDown);
|
||||
DELETE_KEY_DOWN : INSERT_KEY_DOWN);
|
||||
myAvatar.setChatMessage(string(chatEntry.getContents().size(), 'X'));
|
||||
|
||||
} else {
|
||||
|
@ -1486,7 +1486,7 @@ void key(unsigned char k, int x, int y)
|
|||
|
||||
if (k == '\r') {
|
||||
::chatEntryOn = true;
|
||||
myAvatar.setKeyState(AvatarData::NoKeyDown);
|
||||
myAvatar.setKeyState(NO_KEY_DOWN);
|
||||
myAvatar.setChatMessage(string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ AvatarData::AvatarData() :
|
|||
_cameraAspectRatio(0.0f),
|
||||
_cameraNearClip(0.0f),
|
||||
_cameraFarClip(0.0f),
|
||||
_keyState(NoKeyDown) {
|
||||
_keyState(NO_KEY_DOWN) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
|
||||
#include <AgentData.h>
|
||||
|
||||
enum KeyState
|
||||
{
|
||||
NO_KEY_DOWN,
|
||||
INSERT_KEY_DOWN,
|
||||
DELETE_KEY_DOWN
|
||||
};
|
||||
|
||||
class AvatarData : public AgentData {
|
||||
public:
|
||||
AvatarData();
|
||||
|
@ -76,8 +83,6 @@ public:
|
|||
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
|
||||
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||
|
||||
enum KeyState { NoKeyDown, InsertKeyDown, DeleteKeyDown };
|
||||
|
||||
// key state
|
||||
void setKeyState(KeyState s) { _keyState = s; }
|
||||
KeyState keyState() const { return _keyState; }
|
||||
|
@ -118,7 +123,7 @@ protected:
|
|||
float _cameraNearClip;
|
||||
float _cameraFarClip;
|
||||
|
||||
// key state (nothing, down, up, backspace)
|
||||
// key state
|
||||
KeyState _keyState;
|
||||
|
||||
// chat message
|
||||
|
|
Loading…
Reference in a new issue