Ejemplo n.º 1
0
void BroadcastConsole::OnMsgRecv(const std::string& str)
{
  // Discard if same as last msg
  if (!m_texts.empty())
  {
    if (m_texts[0]->GetText() == str)
    {
      std::cout << "Discarding duplicate msg\n";
      return;
    }
  }

  GuiText* text = new GuiText;
  text->SetIsMulti(true);
  text->SetTextSize(1.0f); // TODO CONFIG
  text->SetSize(Vec2f(2.0f, 0.1f)); // assume single line
  text->SetText(str);
  text->SizeToText();
  text->SetFgCol(Colour(1, 1, 0, 1));

  m_texts.push_front(text);

  static const unsigned int NUM_LINES = ROConfig()->GetInt("chat-max-lines", 10);
  if (m_texts.size() > NUM_LINES) 
  {
    m_texts.pop_back();
  }
  ReposText();
}
Ejemplo n.º 2
0
  virtual void Draw()
  {
    // Don't draw name of local player ?
    if (IsVisible() && m_player->GetId() != GetLocalPlayerId())
    {
      //Assert(m_player->GetAABB());
      //DrawAABB(*(m_player->GetAABB()));
 
      // Print name 
      // TODO Do all these in one go, to minimise state changes
      AmjuGL::PushAttrib(AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ);
      AmjuGL::Enable(AmjuGL::AMJU_BLEND);
      AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);

      GuiText text;
      text.SetTextSize(5.0f); // TODO CONFIG
      text.SetText(m_player->GetName());
    
      static const float MAX_NAME_WIDTH = 4.0f; // minimise this to reduce overdraw - calc from text
      text.SetSize(Vec2f(MAX_NAME_WIDTH, 1.0f));
      text.SetJust(GuiText::AMJU_JUST_CENTRE);
      //text.SetInverse(true);
      //text.SetDrawBg(true);
      text.SetFgCol(Colour(1, 1, 1, 1));

      AmjuGL::PushMatrix();
    
      Matrix m;
      m.SetIdentity();

      // Reverse modelview rotation
      Matrix r;
      r.ModelView();
      m = TransposeRot(r);

      Vec3f tr(m_combined[12], m_combined[13], m_combined[14]);
      m.TranslateKeepRotation(tr);
      AmjuGL::MultMatrix(m);
      static const float SCALE_FACTOR = 20.0f;
      float x = MAX_NAME_WIDTH * SCALE_FACTOR * -0.5f;
      AmjuGL::Translate(x, 60.0f, 0); // TODO CONFIG
    
      AmjuGL::Scale(SCALE_FACTOR, SCALE_FACTOR, 10);  

      text.Draw();
      AmjuGL::PopMatrix();
      AmjuGL::PopAttrib();
    }
  }
Ejemplo n.º 3
0
void LurkMsg::Set(const std::string& str, const Colour& fgCol, const Colour& bgCol, LurkPos lp,
  CommandFunc onFinished)
{
  GuiText* text = new GuiText;
  if (lp == AMJU_CENTRE)
  {
    text->SetIsMulti(true);
  }
  text->SetTextSize(1.5f); // TODO CONFIG
  text->SetSize(Vec2f(1.6f, 0.1f)); // assume single line
  text->SetText(str);
  text->SizeToText();
  text->SetFgCol(fgCol);

  Set(text, fgCol, bgCol, lp, onFinished);
}
Ejemplo n.º 4
0
void Ve1NameNode::Draw()
{
  // Print name 
  // TODO Do all these in one go, to minimise state changes
  AmjuGL::PushAttrib(AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ);
  AmjuGL::Enable(AmjuGL::AMJU_BLEND);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);

  GuiText text;
  text.SetTextSize(5.0f); // TODO CONFIG
  text.SetText(ToString(*m_obj));
    
  static const float MAX_NAME_WIDTH = 4.0f; // minimise this to reduce overdraw - calc from text
  text.SetSize(Vec2f(MAX_NAME_WIDTH, 1.0f));
  text.SetJust(GuiText::AMJU_JUST_CENTRE);
  //text.SetInverse(true);
  //text.SetDrawBg(true);

  AmjuGL::PushMatrix();
    
  Matrix m;
  m.SetIdentity();
  //Vec3f tr(m_local[12], m_local[13], m_local[14]);
  Vec3f tr(m_combined[12], m_combined[13], m_combined[14]);
  m.Translate(tr);
  AmjuGL::MultMatrix(m);
  static const float SCALE_FACTOR = 20.0f;
  float x = MAX_NAME_WIDTH * SCALE_FACTOR * -0.5f;
  AmjuGL::Translate(x, 60.0f, 0); // TODO CONFIG
    
  AmjuGL::Scale(SCALE_FACTOR, SCALE_FACTOR, 10);  

  text.Draw();
  AmjuGL::PopMatrix();
  AmjuGL::PopAttrib();

  /*
  AmjuGL::PushAttrib(
    AmjuGL::AMJU_TEXTURE_2D | AmjuGL:: AMJU_LIGHTING | AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ | AmjuGL::AMJU_DEPTH_WRITE);

  AmjuGL::Enable(AmjuGL::AMJU_TEXTURE_2D);
  AmjuGL::Disable(AmjuGL::AMJU_LIGHTING);
  AmjuGL::Enable(AmjuGL::AMJU_BLEND);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_WRITE);

  AmjuGL::PushMatrix();
  AmjuGL::SetIdentity();

  AmjuGL::SetMatrixMode(AmjuGL::AMJU_PROJECTION_MATRIX);
  AmjuGL::PushMatrix();
  AmjuGL::SetIdentity();

  MultColour(Colour(0, 0, 1, 1));
  GuiText text;
  text.SetTextSize(0.5f);
  std::string s = "Object " + ToString(m_obj->GetId()) + " " + m_obj->GetTypeName();
  text.SetText(s);
  text.SizeToText();
  text.SetJust(GuiText::AMJU_JUST_LEFT);
  text.SetLocalPos(screenpos);
  text.Draw();


  AmjuGL::PopMatrix();
  AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
  AmjuGL::PopMatrix();

  AmjuGL::PopAttrib();
  */
}