Ожидаемый контент:

...

Карты, моды, дополнения, утилиты...

...

... и другое

В разработке... (Внимание: это меню отображается некорректно на некоторых стилях форума)

DOOM 0.9.1282

Форум Мапперов и Doom'еров

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Форум Мапперов и Doom'еров » idTech 4 » Исходный код (Source Code)


Исходный код (Source Code)

Сообщений 1 страница 2 из 2

1

Тут будет тема, в которой можно писать всю движуху по сырцам дума третьего - изменению, доработке, обсуждению и прочее прочее.

Сам исходный код движка находится тут - GitHub

+1

2

В оригинальном движке по дефолту русская буква я (маленькая) в чате сетевой игры не вводится. Чтобы это исправить, нужно поправить EditWindow.cpp, находящийся в neo\ui. Изменение вносится в .exe, не в .dll.
В idEditWindow::HandleEvent в блоке if начинающемся на 212 строке нужно добавить:
if ( key == 255 ) {
text = text + '`';
cursorPos = len + 1;
return "";
}

:

Полный код скорректированного idEditWindow::HandleEvent

/*
=============
idEditWindow::HandleEvent
=============
*/
const char *idEditWindow::HandleEvent(const sysEvent_t *event, bool *updateVisuals) {
        static char buffer[ MAX_EDITFIELD ];
        const char *ret = "";

        if ( wrap ) {
                // need to call this to allow proper focus and capturing on embedded children
                ret = idWindow::HandleEvent( event, updateVisuals );
                if ( ret && *ret ) {
                        return ret;
                }
        }

        if ( ( event->evType != SE_CHAR && event->evType != SE_KEY ) ) {
                return ret;
        }

        idStr::Copynz( buffer, text.c_str(), sizeof( buffer ) );
        int key = event->evValue;
        int len = text.Length();

        if ( event->evType == SE_CHAR ) {
                if ( event->evValue == Sys_GetConsoleKey( false ) || event->evValue == Sys_GetConsoleKey( true ) ) {
                        return "";
                }

                if ( updateVisuals ) {
                        *updateVisuals = true;
                }

                if ( maxChars && len > maxChars ) {
                        len = maxChars;
                }
       
                if ( ( key == K_ENTER || key == K_KP_ENTER ) && event->evValue2 ) {
                        RunScript( ON_ACTION );
                        RunScript( ON_ENTER );
                        return cmd;
                }

                if ( key == K_ESCAPE ) {
                        RunScript( ON_ESC );
                        return cmd;
                }

                if ( readonly ) {
                        return "";
                }

                if ( key == 255 ) {
                        text = text + '`';
                        cursorPos = len + 1;
                        return "";
                }
               
               
                if ( key == 'h' - 'a' + 1 || key == K_BACKSPACE ) {     // ctrl-h is backspace
                        if ( cursorPos > 0 ) {
                                if ( cursorPos >= len ) {
                                        buffer[len - 1] = 0;
                                        cursorPos = len - 1;
                                } else {
                                        memmove( &buffer[ cursorPos - 1 ], &buffer[ cursorPos ], len + 1 - cursorPos);
                                        cursorPos--;
                                }

                                text = buffer;
                                UpdateCvar( false );
                                RunScript( ON_ACTION );
                        }

                        return "";
                }

                //
                // ignore any non printable chars (except enter when wrap is enabled)
                //
                if ( wrap && (key == K_ENTER || key == K_KP_ENTER) ) {
                } else if ( !idStr::CharIsPrintable( key ) ) {
                        return "";
                }

                if ( numeric ) {
                        if ( ( key < '0' || key > '9' ) && key != '.' ) {
                        return "";
                        }
                }

                if ( dc->GetOverStrike() ) {
                        if ( maxChars && cursorPos >= maxChars ) {
                        return "";
                        }
                } else {
                        if ( ( len == MAX_EDITFIELD - 1 ) || ( maxChars && len >= maxChars ) ) {
                        return "";
                        }
                        memmove( &buffer[ cursorPos + 1 ], &buffer[ cursorPos ], len + 1 - cursorPos );
                }

                buffer[ cursorPos ] = key;

                text = buffer;
                UpdateCvar( false );
                RunScript( ON_ACTION );

                if ( cursorPos < len + 1 ) {
                        cursorPos++;
                }
                EnsureCursorVisible();

        } else if ( event->evType == SE_KEY && event->evValue2 ) {

                if ( updateVisuals ) {
                        *updateVisuals = true;
                }

                if ( key == K_DEL ) {
                        if ( readonly ) {
                                return ret;
                        }
                        if ( cursorPos < len ) {
                                memmove( &buffer[cursorPos], &buffer[cursorPos + 1], len - cursorPos);
                                text = buffer;
                                UpdateCvar( false );
                                RunScript( ON_ACTION );
                        }
                        return ret;
                }

                if ( key == K_RIGHTARROW )  {
                        if ( cursorPos < len ) {
                                if ( idKeyInput::IsDown( K_CTRL ) ) {
                                        // skip to next word
                                        while( ( cursorPos < len ) && ( buffer[ cursorPos ] != ' ' ) ) {
                                                cursorPos++;
                                        }

                                        while( ( cursorPos < len ) && ( buffer[ cursorPos ] == ' ' ) ) {
                                                cursorPos++;
                                        }
                                } else {
                                        if ( cursorPos < len ) {
                                                cursorPos++;
                                        }
                                }
                        }

                        EnsureCursorVisible();

                        return ret;
                }

                if ( key == K_LEFTARROW ) {
                        if ( idKeyInput::IsDown( K_CTRL ) ) {
                                // skip to previous word
                                while( ( cursorPos > 0 ) && ( buffer[ cursorPos - 1 ] == ' ' ) ) {
                                        cursorPos--;
                                }

                                while( ( cursorPos > 0 ) && ( buffer[ cursorPos - 1 ] != ' ' ) ) {
                                        cursorPos--;
                                }
                        } else {
                                if ( cursorPos > 0 ) {
                                        cursorPos--;
                                }
                        }

                        EnsureCursorVisible();

                        return ret;
                }

                if ( key == K_HOME ) {
                        if ( idKeyInput::IsDown( K_CTRL ) || cursorLine <= 0 || ( cursorLine >= breaks.Num() ) ) {
                cursorPos = 0;
                        } else {
                                cursorPos = breaks[cursorLine];
                        }
                        EnsureCursorVisible();
                        return ret;
                }

                if ( key == K_END )  {
                        if ( idKeyInput::IsDown( K_CTRL ) || (cursorLine < -1) || ( cursorLine >= breaks.Num() - 1 ) ) {
                                cursorPos = len;
                        } else {
                                cursorPos = breaks[cursorLine + 1] - 1;
                        }
                        EnsureCursorVisible();
                        return ret;
                }

                if ( key == K_INS ) {
                        if ( !readonly ) {
                                dc->SetOverStrike( !dc->GetOverStrike() );
                        }
                        return ret;
                }

                if ( key == K_DOWNARROW ) {
                        if ( idKeyInput::IsDown( K_CTRL ) ) {
                                scroller->SetValue( scroller->GetValue() + 1.0f );
                        } else {
                                if ( cursorLine < breaks.Num() - 1 ) {
                                        int offset = cursorPos - breaks[cursorLine];
                                        cursorPos = breaks[cursorLine + 1] + offset;
                                        EnsureCursorVisible();
                                }
                        }
                }

                if (key == K_UPARROW ) {
                        if ( idKeyInput::IsDown( K_CTRL ) ) {
                                scroller->SetValue( scroller->GetValue() - 1.0f );
                        } else {
                                if ( cursorLine > 0 ) {
                                        int offset = cursorPos - breaks[cursorLine];
                                        cursorPos = breaks[cursorLine - 1] + offset;
                                        EnsureCursorVisible();
                                }
                        }
                }

                if ( key == K_ENTER || key == K_KP_ENTER ) {
                        RunScript( ON_ACTION );
                        RunScript( ON_ENTER );
                        return cmd;
                }

                if ( key == K_ESCAPE ) {
                        RunScript( ON_ESC );
                        return cmd;
                }

        } else if ( event->evType == SE_KEY && !event->evValue2 ) {
                if ( key == K_ENTER || key == K_KP_ENTER ) {
                        RunScript( ON_ENTERRELEASE );
                        return cmd;
                } else {
                        RunScript( ON_ACTIONRELEASE );
                }
        }

        return ret;
}

+1


Вы здесь » Форум Мапперов и Doom'еров » idTech 4 » Исходный код (Source Code)