mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +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()) {
|
||||
float width = 0;
|
||||
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();
|
||||
|
||||
|
@ -678,7 +678,7 @@ void Avatar::render(bool lookingInMirror) {
|
|||
glVertex2f(0, 0);
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ bool ChatEntry::key(unsigned char k) {
|
|||
cursorPos--;
|
||||
}
|
||||
return true;
|
||||
|
||||
case 127: // delete
|
||||
if (cursorPos < contents.size()) {
|
||||
contents.erase(cursorPos, 1);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (contents.size() != MAX_CONTENT_LENGTH) {
|
||||
|
|
|
@ -1361,6 +1361,11 @@ void specialkey(int 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 == 'c') myAvatar.setDriveKeys(DOWN, 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)
|
||||
{
|
||||
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());
|
||||
chatEntry.clear();
|
||||
::chatEntryOn = false;
|
||||
|
|
|
@ -50,7 +50,8 @@ AvatarData::AvatarData() :
|
|||
_cameraFov(0.0f),
|
||||
_cameraAspectRatio(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 setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||
|
||||
enum KeyState { NoKey, KeyDown, KeyUp, DeleteKey };
|
||||
enum KeyState { NoKeyDown, InsertKeyDown, DeleteKeyDown };
|
||||
|
||||
// key state
|
||||
void setKeyState(KeyState s) { _keyState = s; }
|
||||
|
|
Loading…
Reference in a new issue