mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
Delete support (though the one on my numeric keypad doesn't work?),
sending key states.
This commit is contained in:
parent
675d06e4b9
commit
d041072d40
5 changed files with 21 additions and 5 deletions
|
@ -657,7 +657,7 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
if (!_chatMessage.empty()) {
|
if (!_chatMessage.empty()) {
|
||||||
float width = 0;
|
float width = 0;
|
||||||
for (string::iterator it = _chatMessage.begin(); it != _chatMessage.end(); it++) {
|
for (string::iterator it = _chatMessage.begin(); it != _chatMessage.end(); it++) {
|
||||||
width += glutStrokeWidth(GLUT_STROKE_ROMAN, *it)*0.0005;
|
width += glutStrokeWidth(GLUT_STROKE_ROMAN, *it)*0.00025;
|
||||||
}
|
}
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
glVertex2f(0, 0);
|
glVertex2f(0, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
drawtext(0, 0, 0.0005, 180, 1.0, 0, _chatMessage.c_str(), 1, 1, 1);
|
drawtext(0, 0, 0.00025, 180, 1.0, 0, _chatMessage.c_str(), 0, 1, 0);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,12 @@ bool ChatEntry::key(unsigned char k) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case 127: // delete
|
||||||
|
if (cursorPos < contents.size()) {
|
||||||
|
contents.erase(cursorPos, 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (contents.size() != MAX_CONTENT_LENGTH) {
|
if (contents.size() != MAX_CONTENT_LENGTH) {
|
||||||
contents.insert(cursorPos, 1, k);
|
contents.insert(cursorPos, 1, k);
|
||||||
|
|
|
@ -1361,6 +1361,11 @@ void specialkey(int k, int x, int y)
|
||||||
|
|
||||||
|
|
||||||
void keyUp(unsigned char k, int x, int y) {
|
void keyUp(unsigned char k, int x, int y) {
|
||||||
|
if (::chatEntryOn) {
|
||||||
|
myAvatar.setKeyState(AvatarData::NoKeyDown);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (k == 'e') myAvatar.setDriveKeys(UP, 0);
|
if (k == 'e') myAvatar.setDriveKeys(UP, 0);
|
||||||
if (k == 'c') myAvatar.setDriveKeys(DOWN, 0);
|
if (k == 'c') myAvatar.setDriveKeys(DOWN, 0);
|
||||||
if (k == 'w') myAvatar.setDriveKeys(FWD, 0);
|
if (k == 'w') myAvatar.setDriveKeys(FWD, 0);
|
||||||
|
@ -1373,7 +1378,11 @@ void keyUp(unsigned char k, int x, int y) {
|
||||||
void key(unsigned char k, int x, int y)
|
void key(unsigned char k, int x, int y)
|
||||||
{
|
{
|
||||||
if (::chatEntryOn) {
|
if (::chatEntryOn) {
|
||||||
if (!chatEntry.key(k)) {
|
if (chatEntry.key(k)) {
|
||||||
|
myAvatar.setKeyState(k == '\b' || k == 127 ? // backspace or delete
|
||||||
|
AvatarData::DeleteKeyDown : AvatarData::InsertKeyDown);
|
||||||
|
|
||||||
|
} else {
|
||||||
myAvatar.setChatMessage(chatEntry.getContents());
|
myAvatar.setChatMessage(chatEntry.getContents());
|
||||||
chatEntry.clear();
|
chatEntry.clear();
|
||||||
::chatEntryOn = false;
|
::chatEntryOn = false;
|
||||||
|
|
|
@ -50,7 +50,8 @@ AvatarData::AvatarData() :
|
||||||
_cameraFov(0.0f),
|
_cameraFov(0.0f),
|
||||||
_cameraAspectRatio(0.0f),
|
_cameraAspectRatio(0.0f),
|
||||||
_cameraNearClip(0.0f),
|
_cameraNearClip(0.0f),
|
||||||
_cameraFarClip(0.0f) {
|
_cameraFarClip(0.0f),
|
||||||
|
_keyState(NoKeyDown) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
|
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
|
||||||
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||||
|
|
||||||
enum KeyState { NoKey, KeyDown, KeyUp, DeleteKey };
|
enum KeyState { NoKeyDown, InsertKeyDown, DeleteKeyDown };
|
||||||
|
|
||||||
// key state
|
// key state
|
||||||
void setKeyState(KeyState s) { _keyState = s; }
|
void setKeyState(KeyState s) { _keyState = s; }
|
||||||
|
|
Loading…
Reference in a new issue