- Timestamp:
- 06/03/04 02:19:22 (21 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 3 edited
-
main.cpp (modified) (2 diffs)
-
ps/CConsole.cpp (modified) (6 diffs)
-
ps/CConsole.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/main.cpp
r369 r374 544 544 font = font_load("fonts/verdana.fnt"); 545 545 546 g_Console = new CConsole ;546 g_Console = new CConsole(0, g_yres-600.f, 800.f, 600.f); 547 547 548 548 // create renderer … … 650 650 mouseButtons[SDL_BUTTON_WHEELDOWN] = false; 651 651 652 float TimeSinceLastFrame = (float)(time1-time0); 652 653 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); 655 657 Render(); 656 658 SDL_GL_SwapBuffers(); -
ps/trunk/source/ps/CConsole.cpp
r370 r374 1 1 #include "CConsole.h" 2 2 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 6 CConsole::CConsole(float X, float Y, float W, float H) 7 : m_fX(X), m_fY(Y), m_fWidth(W), m_fHeight(H) 8 { 9 9 m_bToggle = false; 10 10 m_bVisible = false; 11 12 m_VisibleFrac = 0.0f; 11 13 12 14 m_szBuffer = (char*)malloc(sizeof(char) * BUFFER_SIZE); … … 107 109 void CConsole::Update(const float DeltaTime) 108 110 { 109 const float MoveSpeed = 10.0f; 110 111 if (m_bToggle) 111 if(m_bToggle) 112 112 { 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 } 115 124 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 } 127 133 } 128 134 } … … 133 139 if (!m_bVisible) return; 134 140 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 136 146 137 147 DrawWindow(); … … 247 257 static int iHistoryPos = -1; 248 258 249 if (szChar == '`')259 if (szChar == SDLK_F1) 250 260 { 251 m_bToggle = !m_bToggle; 261 m_bToggle = true; 262 m_bVisible = !m_bVisible; 252 263 return; 253 264 } … … 418 429 419 430 extern CConsole* g_Console; 420 static bool console_active = false;421 431 422 432 bool conInputHandler(const SDL_Event& ev) … … 425 435 return false; 426 436 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 24 24 float m_fY; 25 25 26 float m_fMaxHeight;27 float m_fMaxWidth;28 29 26 float m_fHeight; 30 27 float m_fWidth; 28 29 // show / hide animation 30 float m_VisibleFrac; 31 31 32 32 std::map<std::string, fptr> m_mapFuncList; … … 76 76 77 77 void RegisterFunc(fptr F, const char* szName); 78 79 bool IsActive() { return m_bVisible; } 78 80 }; 79 81
Note:
See TracChangeset
for help on using the changeset viewer.
