bool CDisplayText::EventProcess(const Event &event) { if (m_engine->GetPause()) return true; if (event.type == EVENT_FRAME) { for (auto& line : m_textLines) { if (! line.exist) break; line.time -= event.rTime; } while (true) { if (!m_textLines.front().exist || m_textLines.front().time > 0.0f) { break; } if (!ClearLastText()) break; } } return true; }
bool CDisplayText::EventProcess(const Event &event) { int i; if ( m_engine->GetPause() ) return true; if ( event.type == EVENT_FRAME ) { for ( i=0 ; i<MAXDTLINE ; i++ ) { if ( !m_bExist[i] ) break; m_time[i] -= event.rTime; } while ( true ) { if ( !m_bExist[0] || m_time[0] > 0.0f ) break; if ( !ClearLastText() ) break; } } return true; }
void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height, float dist, float time, TextType type) { CObject* toto; CMotion* motion; Ui::CWindow* pw; Ui::CButton* button; Ui::CGroup* group; Ui::CLabel* label; Math::Point pos, ppos, dim; Sound sound; float hLine, hBox; int nLine, icon, i; if ( !m_bEnable ) return; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) { pos.x = 0.0f; pos.y = 0.0f; dim.x = 0.0f; dim.y = 0.0f; pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW2); } hBox = 0.045f; hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE); nLine = 0; for ( i=0 ; i<MAXDTLINE ; i++ ) { group = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i))); if ( group == 0 ) break; nLine ++; } if ( nLine == MAXDTLINE ) { ClearLastText(); nLine --; } pos.x = 0.10f; pos.y = 0.92f-hBox-hBox*nLine; dim.x = 0.80f; dim.y = hBox; icon = 1; // yellow if ( type == TT_ERROR ) icon = 9; // red if ( type == TT_WARNING ) icon = 10; // blue if ( type == TT_INFO ) icon = 8; // green if ( type == TT_MESSAGE ) icon = 11; // yellow pw->CreateGroup(pos, dim, icon, EventType(EVENT_DT_GROUP0+nLine)); pw->SetTrashEvent(false); ppos = pos; ppos.y -= hLine/2.0f; label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text); if ( label != 0 ) { label->SetFontSize(FONTSIZE); } dim.x = dim.y*0.75f; pos.x -= dim.x; button = pw->CreateButton(pos, dim, 14, EventType(EVENT_DT_VISIT0+nLine)); if ( goal.x == 0.0f && goal.y == 0.0f && goal.z == 0.0f ) { button->ClearState(STATE_ENABLE); } m_bExist[nLine] = true; m_visitGoal[nLine] = goal; m_visitDist[nLine] = dist; m_visitHeight[nLine] = height; m_time[nLine] = time*m_delayFactor; toto = SearchToto(); if ( toto != 0 ) { motion = toto->GetMotion(); if ( motion != 0 ) { if ( type == TT_ERROR ) { motion->SetAction(MT_ERROR, 4.0f); } if ( type == TT_WARNING ) { motion->SetAction(MT_WARNING, 4.0f); } if ( type == TT_INFO ) { motion->SetAction(MT_INFO, 4.0f); } if ( type == TT_MESSAGE ) { motion->SetAction(MT_MESSAGE, 4.0f); } } } if ( m_bHide ) { HideText(m_bHide); // hide all } else { sound = SOUND_CLICK; if ( type == TT_ERROR ) sound = SOUND_ERROR; if ( type == TT_WARNING ) sound = SOUND_WARNING; if ( type == TT_INFO ) sound = SOUND_INFO; if ( type == TT_MESSAGE ) sound = SOUND_MESSAGE; if ( sound != SOUND_CLICK ) { m_sound->Play(sound); } } }