This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 374 for ps


Ignore:
Timestamp:
06/03/04 02:19:22 (21 years ago)
Author:
janwas
Message:

animation: console scrolls in from top of screen

Location:
ps/trunk/source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/main.cpp

    r369 r374  
    544544    font = font_load("fonts/verdana.fnt");
    545545
    546     g_Console = new CConsole;
     546    g_Console = new CConsole(0, g_yres-600.f, 800.f, 600.f);
    547547
    548548    // create renderer
     
    650650        mouseButtons[SDL_BUTTON_WHEELDOWN] = false;
    651651
     652        float TimeSinceLastFrame = (float)(time1-time0);
    652653        in_get_events();
    653         UpdateWorld(float(time1-time0));
    654         terr_update(float(time1-time0));
     654        UpdateWorld(TimeSinceLastFrame);
     655        terr_update(TimeSinceLastFrame);
     656        g_Console->Update(TimeSinceLastFrame);
    655657        Render();
    656658        SDL_GL_SwapBuffers();
  • ps/trunk/source/ps/CConsole.cpp

    r370 r374  
    11#include "CConsole.h"
    22
    3 CConsole::CConsole(float X, float Y, float W, float H):
    4                     m_fX(X), m_fY(Y), m_fMaxWidth(W), m_fMaxHeight(H)
    5 {
    6     m_fHeight = m_fMaxHeight;
    7     m_fWidth = m_fMaxWidth;
    8 
     3#include "prometheus.h"
     4#include "sysdep/sysdep.h"
     5
     6CConsole::CConsole(float X, float Y, float W, float H)
     7    : m_fX(X), m_fY(Y), m_fWidth(W), m_fHeight(H)
     8{
    99    m_bToggle = false;
    1010    m_bVisible = false;
     11
     12    m_VisibleFrac = 0.0f;
    1113
    1214    m_szBuffer = (char*)malloc(sizeof(char) * BUFFER_SIZE);
     
    107109void CConsole::Update(const float DeltaTime)
    108110{
    109     const float MoveSpeed = 10.0f;
    110 
    111     if (m_bToggle)
     111    if(m_bToggle)
    112112    {
    113         if (m_fHeight > m_fY)
    114             m_fHeight -= MoveSpeed * DeltaTime;
     113        const float AnimateTime = .30f;
     114        const float Delta = DeltaTime / AnimateTime;
     115        if(m_bVisible)
     116        {
     117            m_VisibleFrac += Delta;
     118            if(m_VisibleFrac > 1.0f)
     119            {
     120                m_VisibleFrac = 1.0f;
     121                m_bToggle = false;
     122            }
     123        }
    115124        else
    116             if (m_bVisible) m_bVisible = false;
    117     }
    118     else
    119     {
    120         if (!m_bVisible) m_bVisible = true;
    121 
    122         if (m_fHeight < m_fMaxHeight)
    123             m_fHeight += MoveSpeed * DeltaTime;
    124         else
    125             if (m_fHeight != m_fMaxHeight)
    126                 m_fHeight = m_fMaxHeight;
     125        {
     126            m_VisibleFrac -= Delta;
     127            if(m_VisibleFrac < 0.0f)
     128            {
     129                m_VisibleFrac = 0.0f;
     130                m_bToggle = false;
     131            }
     132        }
    127133    }
    128134}
     
    133139    if (!m_bVisible) return;
    134140
    135     glTranslatef(m_fX, m_fY, 0.0f); //Move to window position
     141    // animation: slide in from top of screen
     142    const float MaxY = m_fHeight;
     143    const float DeltaY = (1.0f - m_VisibleFrac) * MaxY;
     144
     145    glTranslatef(m_fX, m_fY + DeltaY, 0.0f); //Move to window position
    136146
    137147    DrawWindow();
     
    247257    static int iHistoryPos = -1;
    248258
    249     if (szChar == '`')
     259    if (szChar == SDLK_F1)
    250260    {
    251         m_bToggle = !m_bToggle;
     261        m_bToggle = true;
     262        m_bVisible = !m_bVisible;
    252263        return;
    253264    }
     
    418429
    419430extern CConsole* g_Console;
    420 static bool console_active = false;
    421431
    422432bool conInputHandler(const SDL_Event& ev)
     
    425435        return false;
    426436
    427     const int c = ev.key.keysym.sym;
    428     if(c == SDLK_F1)
    429     {
    430         console_active = !console_active;
    431 //      g_Console->Toggle();
    432     }
    433 
    434     if(console_active)
    435     {
    436         g_Console->InsertChar(c);
    437         return true;
    438     }
    439     else
    440         return false;
    441 }
     437    g_Console->InsertChar(ev.key.keysym.sym);
     438    return g_Console->IsActive();
     439}
  • ps/trunk/source/ps/CConsole.h

    r370 r374  
    2424    float m_fY;
    2525
    26     float m_fMaxHeight;
    27     float m_fMaxWidth;
    28 
    2926    float m_fHeight;
    3027    float m_fWidth;
     28
     29    // show / hide animation
     30    float m_VisibleFrac;
    3131
    3232    std::map<std::string, fptr> m_mapFuncList;
     
    7676
    7777    void RegisterFunc(fptr F, const char* szName);
     78
     79    bool IsActive() { return m_bVisible; }
    7880};
    7981
Note: See TracChangeset for help on using the changeset viewer.