Ejemplo n.º 1
1
//-----------------------------------------------------------------------------
//                       _ u p d a t e D e b u g T e x t
//-----------------------------------------------------------------------------
void _updateDebugText(u32 idx, core::stringc text)
{
    u32 cidx;
    if(idx >= m_textItems.size())
    {
        core::recti apos = m_debugPanel->getAbsolutePosition();
        rectd tdim(0,0,apos.getWidth(),m_charHeight);

        cidx = m_textItems.size();
        while(cidx <= idx)
        {
            IGUIStaticText* textArea = m_gui->addStaticText(L" ",tdim,false,false,0);
            textArea->move(position2di(5,m_charHeight*cidx));
            textArea->setOverrideColor(SColor(255,255,255,255));

            textArea->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);

            m_debugPanel->addChild(textArea);
            m_textItems.push_back(textArea);
            ++cidx;
        }

        core::recti r = m_debugPanel->getRelativePosition();
        r.LowerRightCorner.Y = m_textItems.size() * m_charHeight;
        m_debugPanel->setRelativePosition(r);
    }

    m_textItems[idx]->setVisible(true); // only display updated items
    core::stringw wtext = text;
    m_textItems[idx]->setText(wtext.c_str());
}
Ejemplo n.º 2
0
//! Draws the outline of a 2d rectangle
void CNullDriver::draw2DRectangleOutline(const rectanglei& pos, SColor color)
{
	draw2DLine(pos.UpperLeftCorner, position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), color);
	draw2DLine(position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), pos.LowerRightCorner, color);
	draw2DLine(pos.LowerRightCorner, position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), color);
	draw2DLine(position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), pos.UpperLeftCorner, color);
}
Ejemplo n.º 3
0
void CCursorController::render()
{
   updateMousePos();

   if(isVisible() && used)
   {
      _IRR_DEBUG_BREAK_IF(!m_pMouseCursor); // There isn't any cursor texture loaded
      if(m_pMouseCursor)
      {
         videoDriver->draw2DImage(m_pMouseCursor,
            topleft ? position2di(m_MousePos.X,m_MousePos.Y) : position2di(m_MousePos.X - m_pMouseCursor->getSize().Width/2+1,
            m_MousePos.Y - m_pMouseCursor->getSize().Height/2+2),
            rect<s32>(position2di(0,0),m_pMouseCursor->getSize()),
            0, SColor(140,255,255,255), true);
      }
   }

   if(isOSCursorVisible())
   {
      irrCursorControl->setVisible(true);
//       irrCursorControl->setPosition(irrCursorControl->getPosition());
   }
   else
   {
      irrCursorControl->setVisible(false);
//       irrCursorControl->setPosition(irrCursorControl->getPosition());
   }
}
Ejemplo n.º 4
0
// ----------------------------------------------------------------------------
void TerrPanel::btnDown(int btn)
{
    switch (btn)
    {
    case EDGE_1:
        m_tmod.edge_type = 1;
        m_active_edge_frame->setRelativePosition(position2di(100, 95));
        break;
    case EDGE_2:
        m_tmod.edge_type = 2;
        m_active_edge_frame->setRelativePosition(position2di(150, 95));
        break;
    case EDGE_3:
        m_tmod.edge_type = 3;
        m_active_edge_frame->setRelativePosition(position2di(200, 95));
        break;
    case M_T1:
        m_tmod.col_mask = SColor(255, 0, 0, 0);
        break;
    case M_T2:
        m_tmod.col_mask = SColor(0, 255, 0, 0);
        break;
    case M_T3:
        m_tmod.col_mask = SColor(0, 0, 255, 0);
        break;
    case M_T4:
        m_tmod.col_mask = SColor(0, 0, 0, 255);
        break;
    case M_TC1:
    case M_TC2:
    case M_TC3:
    case M_TC4:
        terrChange(btn);
        break;
    case TerrPanel::H_BTN:
        m_tmod.type = HEIGHT_MOD;
        break;
    case TerrPanel::T_SOFT_BTN:
        m_tmod.type = SOFT_BRUSH;
        break;
    case TerrPanel::T_HARD_BTN:
        m_tmod.type = HARD_BRUSH;
        break;
    case TerrPanel::T_BRIGHTNESS_BTN:
        m_tmod.type = BRIGHTNESS_MOD;
        break;
    case S_T1:
    case S_T2:
    case S_T3:
    case S_T4:
    case S_T5:
    case S_T6:
        skyChange(btn);
        break;
    default:
        break;
    }
} // btnDown
Ejemplo n.º 5
0
void EspadachinIA::Pintar(IVideoDriver* driver,int TPositionX,int TPositionY)
{
	ITexture *TTexture_Suelo = getTextura();
	
	int pos_sprite = current_sprite * sprite_Width;

	driver->draw2DImage(TTexture_Suelo, position2di(TPositionX, TPositionY), rect<s32>(0, 0, TTexture_Suelo->getSize().Width, TTexture_Suelo->getSize().Height), 0, SColor((u32)((1.0f - 0.0f) * 255), 255, 255, 255), true);
	driver->draw2DImage(TTexture, position2di(TPositionX + 2, TPositionY - 20), rect<s32>(pos_sprite, 0, pos_sprite + sprite_Width, sprite_Height), 0, SColor((u32)((1.0f - 0.0f) * 255), 255, 255, 255), true);
	nextSprite();
}
Ejemplo n.º 6
0
    //-----------------------------------------------------------------------
    //                              a d d I t e m
    //-----------------------------------------------------------------------
    u32 TTextOverlay::addItem(const TString& text,TTextAlignment a, TColor color,
        TColor bgColor)
    {

        s32 offset = 0;
        int idx;
        IGUIEnvironment* mgr = getApplication()->getGUIManager();
        IGUIFont* font=m_panel->getOverrideFont();
        if(!font)
            font = mgr->getSkin()->getFont();

        TRecti apos = m_panel->getAbsolutePosition();

        idx = (int)m_textItems.size();
        TStrStream name;		
        name << m_name.c_str() << "-item" << idx+1;

        TStringW wstr = text.c_str();

        s32 cheight = font->getDimension(L"Ay").Height;
        cheight += font->getKerningHeight();

        TRecti tdim(0,0,apos.getWidth(),cheight);
        
        TTextElement* textArea = mgr->addStaticText(wstr.c_str(),tdim,false,false,m_panel);
        textArea->move(position2di(0,cheight*idx));
        textArea->setOverrideFont(font);
        textArea->setOverrideColor(color);
        textArea->setBackgroundColor(bgColor);

        offset = idx * (cheight);
        s32 theight = ((idx+1) * cheight) + (m_margins.Height * 2);

        EGUI_ALIGNMENT oa=EGUIA_UPPERLEFT;

        switch(a)
        {
        case taLeft:
            oa = EGUIA_UPPERLEFT;
            break;
        case taCenter:
            oa = EGUIA_CENTER;
            break;
        case taRight:
            oa = EGUIA_LOWERRIGHT;
            break;
        };

        textArea->setTextAlignment(oa,EGUIA_UPPERLEFT);

        m_panel->addChild(textArea);
        m_textItems.push_back(textArea);

        if(apos.getHeight() < theight)     
        {
            m_panel->setMinSize(TDimensionu(0,theight));
        }

        return m_textItems.size()-1;
    }
Ejemplo n.º 7
0
//! Creates a software image from part of another image.
IImage* CNullDriver::createImage(IImage* imageToCopy, const position2d<s32>& pos, const dimension2d<u32>& size)
{
	Printer::log("Deprecated method, please create an empty image instead and use copyTo().", ELL_WARNING);
	CImage* tmp = new CImage(imageToCopy->getColorFormat(), imageToCopy->getDimension());
	imageToCopy->copyTo(tmp, position2di(0,0), rectanglei(pos,size));
	return tmp;
}
Ejemplo n.º 8
0
// ----------------------------------------------------------------------------
CMeshBuffer<S3DVertex2TCoords>* Terrain::build(path p)
{
    IrrlichtDevice* device = Editor::getEditor()->getDevice();

    CMeshBuffer<S3DVertex2TCoords>* mb = new CMeshBuffer<S3DVertex2TCoords>();

    mb->Vertices.reallocate(m_mesh.vertex_count);
    mb->Indices.reallocate(m_mesh.quad_count * 6);

    for (u32 i = 0; i < m_mesh.vertex_count; i++)
        mb->Vertices.push_back(m_mesh.vertices[i]);
    for (u32 i = 0; i < m_mesh.quad_count * 6; i++)
        mb->Indices.push_back(m_mesh.indices[i]);

    mb->recalculateBoundingBox();
    mb->Material = m_material;

    ITexture* texture = m_material.getTexture(1);
    IImage* image = device->getVideoDriver()->createImage(texture, position2di(0, 0),
        texture->getSize());
    stringc name = p + "/splatt.png";
    device->getVideoDriver()->writeImageToFile(image, name.c_str());
    image->drop();

    return mb;

} // build
Ejemplo n.º 9
0
CTournamentBase::CTournamentRaceGUI::CTournamentRaceGUI(IrrlichtDevice *pDevice, u32 iId, IGUIElement *pParent, bool bCanRemoveRace) {
  IGUIEnvironment *pGuienv=pDevice->getGUIEnvironment();
  m_pTab=pGuienv->addTab(rect<s32>(position2di(5,5+iId*25),dimension2di(520,20)),pParent);
  m_pTab->setBackgroundColor(SColor(128,128,128,128));
  m_pTab->setDrawBackground(true);

  wchar_t s[0xFF];
  swprintf(s,0xFF,L"%i | Track",iId+1);
  m_pNum=pGuienv->addStaticText(s,rect<s32>(1,1,80,18),false,true,m_pTab);
  m_pNum->setTextAlignment(EGUIA_CENTER,EGUIA_CENTER);
  m_iId=iId;

  m_pTrack=pGuienv->addComboBox(rect<s32>(85,1,390,18),m_pTab,100+iId);

  CLevelList *pLevelList=new CLevelList(pDevice);
  for (u32 i=0; i<pLevelList->m_aLevels.size(); i++) m_pTrack->addItem(pLevelList->m_aLevels[i]->m_sName.c_str());
  delete pLevelList;

  pGuienv->addStaticText(L"Laps",rect<s32>(395,1,430,18),false,true,m_pTab);

  m_pLaps=pGuienv->addComboBox(rect<s32>(435,1,475,18),m_pTab,150+iId);
  for (u32 i=2; i<=15; i++) {
    swprintf(s,0xFF,L"%i",i);
    m_pLaps->addItem(s);
  }

  m_pDel=pGuienv->addButton(rect<s32>(480,1,515,18),m_pTab,23+iId,L"Del");
  if (!bCanRemoveRace) {
    m_pDel->setVisible(false);
    m_pTrack->setEnabled(false);
    m_pLaps->setEnabled(false);
  }
}
Ejemplo n.º 10
0
void CTournamentRace::deactivate(IState *pNext) {
  for (u32 i=0; i<m_aRaces.size(); i++) delete m_aRaces[i];

  IImage *pLoading=m_pDriver->createImageFromFile("data/loading.png");

  if (pLoading) {
    ITexture *pLoadingTexture=m_pDriver->addTexture("loading",pLoading);
    if (pLoadingTexture) {
      dimension2du screenSize=m_pDriver->getScreenSize();
      position2di pos=position2di(screenSize.Width/2-115,screenSize.Height/2-32);
      m_pGuienv->addImage(pLoadingTexture,pos);
      m_pDriver->beginScene();
      m_pSmgr->drawAll();
      m_pGuienv->drawAll();
      m_pDriver->endScene();
    }
    pLoading->drop();
  }

  if (m_pNetAdapter) m_pNetAdapter->removeConnectionHandler(this);
  irr::ode::CIrrOdeManager::getSharedInstance()->getQueue()->removeEventListener(this);
  m_aRaces.clear();
  m_pGuienv->clear();
  m_pSmgr->clear();
}
Ejemplo n.º 11
0
vector<StateCost>* Grid::getNeighbors(position2di position) const {
    vector<StateCost>* result = new vector<StateCost>();

    for (int i = -1; i < 2; i++)
        for (int j = -1; j < 2; j++)
            if ( limitOk(position2di(i,j) + position) && !(i == 0 && j == 0) ) {
                struct StateCost bla;
                bla.cost = 1;
                bla.state = (void*) getCell(position2di(i, j));
                result->push_back(bla);
            }

        //cout<<"Neigh size: " << result->size() << endl;

    return result;
}
Ejemplo n.º 12
0
// ----------------------------------------------------------------------------
void Editor::dataDirLocDlg()
{
    IGUIFileOpenDialog* ofd = m_gui_env->addFileOpenDialog(
        L"Pls. select data directory (folder containing textures, tracks, etc.):",
        true, 0, -1, true);
    ofd->setMinSize(dimension2du(600, 512));
    ofd->setRelativePosition(position2di(m_screen_size.Width / 2 - 300, 100));
} // dataDirLocDlg
Ejemplo n.º 13
0
void CTournamentBase::CTournamentRaceGUI::setId(u32 iId) {
  wchar_t s[0xFF];
  swprintf(s,0xFF,L"%i | Track",iId+1);
  m_pNum->setText(s);
  m_iId=iId;
  m_pTab->setRelativePosition(position2di(5,5+iId*25));
  m_pDel->setID(23+iId);
}
Ejemplo n.º 14
0
void Grid::mapTerrain(Level* level) {
    sizeY_ = level->getSize().Height;
    sizeX_ = level->getSize().Width;

    grid_ = new Cell*[sizeY_];
    for (int i = 0; i < sizeY_; i++)
        grid_[i] = new Cell[sizeX_];

    for (int i = 0; i < sizeX_; i++)
        for (int j = 0; j < sizeY_; j++)
            grid_[i][j].setPosition(position2di(i,j));
}
Ejemplo n.º 15
0
// ----------------------------------------------------------------------------
void ToolBar::reallocate()
{
    unsigned int screen_x = Editor::getEditor()->getScreenSize().Width;
    int max_dist_between_blocks = 50;

    int space_between_blocks = min((screen_x - 18 * 50) / 6, max_dist_between_blocks);

    // first 4 icon - new, open, save, save as
    int block_begin = 5;
    for (int i = 0; i < 4; i++)
        m_buttons[i]->setRelativePosition(position2di(block_begin + i * 50, 5));

    // second block: 2 icon - undo, redo
    block_begin += space_between_blocks;
    for (int i = 4; i < 6; i++)
        m_buttons[i]->setRelativePosition(position2di(block_begin + i * 50, 5));

    // fourth block: 5 icon - select, move, rotate, scale, delete
    block_begin += space_between_blocks;
    for (int i = 6; i < 11; i++)
        m_buttons[i]->setRelativePosition(position2di(block_begin + i * 50, 5));

    // fifth block: switch camera, restore def camera pos,rot
    block_begin += space_between_blocks;
    m_buttons[11]->setRelativePosition(position2di(block_begin + 11 * 50, 5));
    m_buttons[12]->setRelativePosition(position2di(block_begin + 12 * 50, 5));

    // Sixth block: driveline,hide terrain, music
    block_begin += space_between_blocks;
    m_buttons[13]->setRelativePosition(position2di(block_begin + 13 * 50, 5));
    m_buttons[14]->setRelativePosition(position2di(block_begin + 14 * 50, 5));
    m_buttons[15]->setRelativePosition(position2di(block_begin + 15 * 50, 5));

    // test
    block_begin += space_between_blocks;
    m_buttons[16]->setRelativePosition(position2di(block_begin + 16 * 50, 5));

    // last block - quit
    m_buttons[17]->setRelativePosition(position2di(screen_x - 50, 5));
} // reallocate
// ----------------------------------------------------------------------------
void RoadCrossSectionWndw::reallocate()
{
    dimension2du ss = Editor::getEditor()->getScreenSize();
    f32          dx = (ss.Width - 300 - 8 * 50) / 9.0f;
    f32          x  = 25 + dx;
    s32          h  = ss.Height;

    m_gof    ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_gp     ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_gm     ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_pp     ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_pm     ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_sym    ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_ok     ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
    m_cancel ->setRelativePosition(position2di((s32)x,h - 100)); x += dx + 50;
} // reallocate
Ejemplo n.º 17
0
//-----------------------------------------------------------------------------
//                           _ a d d H e l p T e x t
//-----------------------------------------------------------------------------
void _addHelpText(core::stringc text)
{
    core::recti apos = m_helpPanel->getAbsolutePosition();
    rectd tdim(0,0,apos.getWidth(),m_charHeight);

    core::stringw wtext = text;
    IGUIStaticText* textArea = m_gui->addStaticText(wtext.c_str(),tdim,false,false,0);
    textArea->move(position2di(5,m_charHeight*m_helpItems.size()));
    textArea->setOverrideColor(SColor(255,255,255,255));

    textArea->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);

    m_helpPanel->addChild(textArea);
    m_helpItems.push_back(textArea);
}
Ejemplo n.º 18
0
bool GraphicsEngine::DrawImage(TextureObject* iTex, int x, int y,
        DWORD color)
{
    if (!m_Driver_ptr)
    {
        return false;
    }
    if (!iTex)
    {
        return false;
    }
    m_Driver_ptr->draw2DImage(iTex, position2di(x, y),
        rect<s32>(0, 0, iTex->getSize().Width, iTex->getSize().Height),
        0, color, true);
    return true;
}
Ejemplo n.º 19
0
void Scrollbar::UpdateScrollerPos(Window &_win)
{
	double DELTA = this->getScrollerRatio();
	
	// determine new scroller position
	if (btnUp->isPressed())
	{
		scrollPos -= DELTA;
	}
	else if (btnDown->isPressed())
	{
		scrollPos += DELTA;
	}
	else if(scroller->isPressed()) // we are dragging scroller
	{
		position2di pos = _win.reciever.GetMouseState().positionCurr - position2di(absXpos, absYpos);

		switch (scrollBarOrientation)
		{
			case HORIZANTAL:
				scrollPos = pos.X;
				break;
			case VERTICAL:
				scrollPos = pos.Y;
				break;
			default:
				// ;-;
				break;
		};
	}

	// Update scroller position
	switch (scrollBarOrientation)
	{
		case HORIZANTAL:
			this->scrollPos = BOUND(this->getScrollerLength() / 2 + WIDTH, scrollPos, -this->getScrollerLength() / 2 + pxLength - WIDTH);
			scroller->setPos(scrollPos - this->getScrollerLength() / 2, 0);
			break;
		case VERTICAL:
			this->scrollPos = BOUND(this->getScrollerLength() / 2 + WIDTH, scrollPos, -this->getScrollerLength() / 2 + pxLength - WIDTH);
			scroller->setPos(0, scrollPos - getScrollerLength() / 2);
			break;
		default:
			// ;-;
			break;
	};
}
Ejemplo n.º 20
0
/**
 * This function is used to show the highscore table
 * @param a new time value to be entered to the list. If this param is 0 the highscore list will just be shown, no entry will be added
 */
void CHiScoreList::show(IGUIStaticText *pListField, IGUIEnvironment *pGuiEnv,const wchar_t *sLevelName) {
  dimension2du screenSize=m_pDevice->getVideoDriver()->getScreenSize();
  m_iRet=0;
  u32 iPos=0;
  list<CHiScoreEntry *>::Iterator i;
  //create a window to display the table
  rect<s32> winRect(screenSize.Width/2-249,130,screenSize.Width/2+248,screenSize.Height-25);

  iPos=1;
  position2di pos=position2di(10,10);
  wchar_t s[0xFFFF];
  swprintf(s,0xFFFF,L"\"%s\"\n\n",sLevelName);
  for (i=m_lList.begin(); i!=m_lList.end() && iPos<=10; i++) {
    swprintf(s,0xFFFF,L"%s%2i: %s (%.2f)\n",s,iPos++,(*i)->sName,((f32)(*i)->iTime)/1000.0f);
  }
  pListField->setText(s);
}
Ejemplo n.º 21
0
bool GraphicsEngine::DrawImage(const std::string& strId, int x, int y,
    DWORD color)
{
    if (!m_Driver_ptr)
    {
        return false;
    }
    ///> ÔÝÎÞ×ÊÔ´³Ø
    const video::ITexture* texture = NULL;
    if (!texture)
    {
        return false;
    }
    m_Driver_ptr->draw2DImage(texture, position2di(x, y),
        rect<s32>(0, 0, texture->getSize().Width, texture->getSize().Height),
        0, color, true);
    return true;
}
Ejemplo n.º 22
0
void CTournamentBase::fillTournamentGUI() {
  if (m_bNetClient) return;

  m_pName->setText(m_pTournament?m_pTournament->getName():L"new tournament");

  if (m_pTournament)
    for (u32 i=0; i<m_pTournament->getRaceCount(); i++) {
      CTournamentRaceGUI *pRace=new CTournamentRaceGUI(m_pDevice,m_lRaces.getSize(),m_pRaceTab,!m_bNetClient);
      pRace->setTrack(m_pTournament->getRace(i)->getTrack());
      pRace->setLaps(m_pTournament->getRace(i)->getLaps());
      m_lRaces.push_back(pRace);

      addTrack(i);
      trackChanged(i,stringc(m_pTournament->getRace(i)->getTrack()).c_str());
      lapsChanged(i,m_pTournament->getRace(i)->getLaps());
    }

  m_pRaceListButtons->setRelativePosition(position2di(5,5+m_lRaces.getSize()*25));
  if (m_lRaces.getSize()>=20) m_pRaceListButtons->setVisible(false);
}
InterfazPathfinding::InterfazPathfinding(IrrlichtDevice * IrrDevice,shared_ptr<mapa2D> map){
	device = IrrDevice;
    env = IrrDevice->getGUIEnvironment();
    driver = IrrDevice->getVideoDriver();
    font = env->getFont("../media/fonthaettenschweiler.bmp");
    env->clear();
    init();

    mapa = map;
    caminoFinal = NULL;
	
	drawRegiones = false;
	drawEnlaces = false;
	drawCaminosInternos = false;
	drawCaminoFinal = false;
	estado = ESTADO_CAMINO;
	origen = destino = position2di(-1,-1);

	enlaces_textura = driver->getTexture("../media/Texturas/debug_pathfinding/enlaces.png");
	caminos_internos_textura = driver->getTexture("../media/Texturas/debug_pathfinding/caminos_internos.png");
	caminos_textura = driver->getTexture("../media/Texturas/debug_pathfinding/caminos.png");
}
Ejemplo n.º 24
0
//! Creates a software image from part of a texture.
IImage* CNullDriver::createImage(ITexture* texture, const position2d<s32>& pos, const dimension2d<u32>& size)
{
	if ((pos==position2di(0,0)) && (size == texture->getSize()))
	{
		IImage* image = new CImage(texture->getColorFormat(), size, texture->lock(ETLM_READ_ONLY), false);
		texture->unlock();
		return image;
	}
	else
	{
		// make sure to avoid buffer overruns
		// make the vector a separate variable for g++ 3.x
		const vector2d<u32> leftUpper(clamp(static_cast<u32>(pos.X), 0u, texture->getSize().Width),
					clamp(static_cast<u32>(pos.Y), 0u, texture->getSize().Height));
		const rectangle<u32> clamped(leftUpper,
					dimension2du(clamp(static_cast<u32>(size.Width), 0u, texture->getSize().Width),
					clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height)));
		if (!clamped.isValid())
			return 0;
		u8* src = static_cast<u8*>(texture->lock(ETLM_READ_ONLY));
		if (!src)
			return 0;
		IImage* image = new CImage(texture->getColorFormat(), clamped.getSize());
		u8* dst = static_cast<u8*>(image->lock());
		src += clamped.UpperLeftCorner.Y * texture->getPitch() + image->getBytesPerPixel() * clamped.UpperLeftCorner.X;
		for (u32 i=0; i<clamped.getHeight(); ++i)
		{
			CColorConverter::convert_viaFormat(src, texture->getColorFormat(), clamped.getWidth(), dst, image->getColorFormat());
			src += texture->getPitch();
			dst += image->getPitch();
		}
		image->unlock();
		texture->unlock();
		return image;
	}
}
Ejemplo n.º 25
0
//Need to be reworked: BAD. Render loop is done here!
stringc GUIGame::showInputQuestion(stringw text)
{
    std::string newtxt = "";

    bool mouseExit = false;

	
    while(!App::getInstance()->isKeyPressed(KEY_RETURN) && mouseExit==false && App::getInstance()->getDevice()->run())
    {
		u32 timercheck = App::getInstance()->getDevice()->getTimer()->getRealTime();
        App::getInstance()->getDevice()->getVideoDriver()->beginScene(true, true, SColor(0,200,200,200));
        App::getInstance()->getDevice()->getSceneManager()->drawAll();
        //guienv->drawAll();

        App::getInstance()->getDevice()->getVideoDriver()->draw2DRectangle(SColor(150,0,0,0), rect<s32>(10,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 200,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 10,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 10));

        rect<s32> textRect = rect<s32>(10,  App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 180,
                                            App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 10,
                                            App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 10);

        stringw realTxt = stringw(text.c_str());
        realTxt += stringw(newtxt.c_str());
		// Flashing cursor, flash at 1/4 second interval (based on realtime)
	    if((timercheck-timer2>250))
		{
			realTxt += L'_';
			if (timercheck-timer2>500)
				timer2=timercheck;
		}

		GUIManager::getInstance()->guiFontDialog->draw(realTxt.c_str(),textRect,SColor(255,255,255,255),false,false,&textRect);


        //draw YES GREEN button
        position2di buttonYesPosition = position2di(App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 58,
                    App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 58);

        App::getInstance()->getDevice()->getVideoDriver()->draw2DImage(guiDialogImgYes,buttonYesPosition,
                                                                   rect<s32>(0,0,48,48),0,SColor(255,255,255,255),true);

        //check mouse click on OK button
        position2di mousePos = App::getInstance()->getDevice()->getCursorControl()->getPosition();
		if(mousePos.getDistanceFrom(buttonYesPosition+position2di(16,16)) < 16 && App::getInstance()->isMousePressed(0)) mouseExit = true;


        //verify pressed chars and add it to the string

        if(timercheck-timer > 160)
        {
            //process all keycodes [0-9] and [A-Z]
            for(int i=0x30;i<0x5B;i++)
            {
				if(App::getInstance()->isKeyPressed(i))
                {
                    newtxt += i;
                    timer = timercheck;
                }
            }

            //process delete and backspace (same behavior for both of them -> remove the last char)
            if(App::getInstance()->isKeyPressed(KEY_BACK) || App::getInstance()->isKeyPressed(KEY_DELETE))
            {
                newtxt = newtxt.substr(0,newtxt.size()-1);
				timer = timercheck;
            }
        }
        App::getInstance()->getDevice()->getVideoDriver()->endScene();
    }

    //EventReceiver::getInstance()->flushKeys();
    //EventReceiver::getInstance()->flushMouse();
	GUIManager::getInstance()->flush();

    return stringc(newtxt.c_str());
}
Ejemplo n.º 26
0
// Set up the gameplay interface GUI
void GUIGame::setupGameplayGUI()
{

	driver=App::getInstance()->getDevice()->getVideoDriver();
	guienv=App::getInstance()->getDevice()->getGUIEnvironment();

	GUIManager::getInstance()->createConsole();

	IGUIInOutFader* fader=guienv->addInOutFader();
	fader->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT);
    fader->setVisible(false);
	fader->setID(GUIManager::ID_FADER);

	// NEW Create display size since IRRlicht return wrong values
	// Check the current screen size
	displayheight=screensize.Height;
	displaywidth=screensize.Width;

	// Create a cutscene text
	IGUIStaticText* guiCutsceneText = guienv->addStaticText(L"This is a standard cutscene text",core::rect<s32>(100,displayheight/2+(displayheight/4),displaywidth-10,displayheight-100),false,true,0,-1,false);
	guiCutsceneText->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiCutsceneText->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guiCutsceneText->setVisible(false);
	guiCutsceneText->setID(GUIManager::ST_ID_CUTSCENE_TEXT);

	// This is called only in the PLAYER application
	#ifndef EDITOR
	// ----------------------------------------
	guienv->getSkin()->setFont(GUIManager::getInstance()->guiFontC12);
	//guienv->getSkin()->setFont(guiFontCourier12);
	// Load textures
	ITexture* imgLogo = driver->getTexture(App::getInstance()->logoimage.c_str());
	printf("Here is the logo: %s\n",App::getInstance()->logoimage.c_str());

	//LOADER WINDOW
	IGUIWindow* guiLoaderWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2-300, driver->getScreenSize().Height/2-200,600,400),false,L"Loading...",0,GUIManager::WIN_LOADER);
	guiLoaderWindow->setDrawTitlebar(false);
	guiLoaderWindow->getCloseButton()->setVisible(false);

	guienv->addImage(imgLogo,vector2d<s32>(5,5),true,guiLoaderWindow);
    IGUIStaticText* guiLoaderDescription = guienv->addStaticText(L"Loading fonts...",
		GUIManager::getInstance()->myRect(10,350,580,40),
		true,true,guiLoaderWindow,
		GUIManager::TXT_ID_LOADER,false);

	//Define 2 buttons to place in the loader windows (player only)
	IGUIButton* guiBtGamePlay = guienv->addButton(core::rect<s32>(400,360,580,380),guiLoaderWindow, GUIManager::BT_PLAYER_START, L"PLAY GAME NOW!");
	guiBtGamePlay->setVisible(false);

	IGUIButton* guiBtGameConfig = guienv->addButton(core::rect<s32>(20,360,200,380),guiLoaderWindow, GUIManager::BT_PLAYER_CONFIG, L"EDIT CONFIGURATION");
	guiBtGameConfig->setVisible(false);

	App::getInstance()->quickUpdate();

	GUIManager::getInstance()->loadFonts();
	guiLoaderDescription->setText(L"Loading interface graphics...");
	//printf("The GUI should display from here...\n");
	// quick update
	App::getInstance()->quickUpdate();

	// Buttons
	ITexture* imgCloseProgram = driver->getTexture("../media/art/bt_close_program.png");
	ITexture* imgAbout = driver->getTexture("../media/art/bt_about.png");
	ITexture* imgAbout1 = driver->getTexture("../media/art/bt_about_ghost.png");
	ITexture* imgHelp = driver->getTexture("../media/art/bt_help.png");
	ITexture* imgHelp1 = driver->getTexture("../media/art/bt_help_ghost.png");
	ITexture* imgConfig = driver->getTexture("../media/art/bt_config.png");
	ITexture* imgConfig1 = driver->getTexture("../media/art/bt_config_ghost.png");

	IGUIWindow* guiMainToolWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width-170,0,170,46),false,0,0,GUIManager::WIN_GAMEPLAY);
	guiMainToolWindow->setDraggable(false);
	guiMainToolWindow->setDrawTitlebar(false);
	guiMainToolWindow->getCloseButton()->setVisible(false);
	guiMainToolWindow->setVisible(false);


	//Play Game
	int x = 0;
	mainToolbarPos.Y=5;
	IGUIButton* guiPlayGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_PLAY_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_play_game")).c_str());

    guiPlayGame->setImage(driver->getTexture("../media/art/bt_play_game.png"));


    //Stop Game
    IGUIButton* guiStopGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_STOP_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_stop_game")).c_str());

    guiStopGame->setImage(driver->getTexture("../media/art/bt_stop_game.png"));
    guiStopGame->setVisible(false);



    //ABOUT BUTTON
	x += 42;
    IGUIButton* guiAbout = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_ABOUT,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_about")).c_str() );

    guiAbout->setImage(imgAbout);
	guiAbout->setPressedImage(imgAbout1);

	// Help Button
	x += 42;
    IGUIButton* guiHelpButton = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_HELP,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_help")).c_str() );

    guiHelpButton->setImage(imgHelp);
    guiHelpButton->setPressedImage(imgHelp1);

	// Close program
	x += 42;
	IGUIButton* guiCloseProgram = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_CLOSE_PROGRAM,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_close_program")).c_str() );

    guiCloseProgram->setImage(imgCloseProgram);

	//ABOUT WINDOW
	IGUIWindow* guiAboutWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2 - 300,driver->getScreenSize().Height/2 - 200,600,400),false);
    guiAboutWindow->setDraggable(false);
    guiAboutWindow->setDrawTitlebar(false);
    guiAboutWindow->getCloseButton()->setVisible(false);
    guiAboutWindow->setVisible(false);

    guienv->addImage(driver->getTexture("../media/art/logo1.png"),position2di(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-100,10),true,guiAboutWindow);

	IGUIButton* guiAboutClose = guienv->addButton(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth() - 37,guiAboutWindow->getAbsoluteClippingRect().getHeight() - 37,32,32),guiAboutWindow,GUIManager::BT_ID_ABOUT_WINDOW_CLOSE);

    guiAboutClose->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

	IGUIListBox* guiAboutText = guienv ->addListBox(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-250,160,500,200),guiAboutWindow);

	// Ask the LANGManager to fill the box with the proper Language of the about text.
	LANGManager::getInstance()->setAboutText(guiAboutText);

	// Create the Configuration window (Need to be updated)
#ifndef EDITOR
	configWindow = new GUIConfigWindow(App::getInstance()->getDevice());
	configWindow->setID(GUIManager::GCW_CONFIG_WINDOW);
	// Give back to the GUI Manager since it's needed for both applications
	GUIManager::getInstance()->setConfigWindow(configWindow);
#endif

	// ---------------------------------------
	#endif

	// --- Active game menu during play

	ITexture* gameplay_bar = driver->getTexture("../media/art/gameplay_bar.png");
	ITexture* circle = driver->getTexture("../media/art/circle.png");
	ITexture* circleMana = driver->getTexture("../media/art/circlemana.png");
	ITexture* topCircle = driver->getTexture("../media/art/circle_top.png");
	IGUIImage* gameplay_bar_image = NULL;
	
	if (gameplay_bar)
	{
		gameplay_bar_image = guienv->addImage(gameplay_bar,vector2d<s32>((displaywidth/2)-(gameplay_bar->getSize().Width/2),displayheight-gameplay_bar->getSize().Height),true);
		gameplay_bar_image->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
		gameplay_bar_image->setID(GUIManager::IMG_BAR);

		// The life gauge
		CGUIGfxStatus* lifegauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		lifegauge->setImage(circle);
		lifegauge->ViewHalfLeft();
		lifegauge->setID(GUIManager::IMG_LIFEGAUGE);

		// The mana gauge
		CGUIGfxStatus* managauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		managauge->setImage(circleMana);
		managauge->ViewHalfRight();
		managauge->setID(GUIManager::IMG_MANAGAUGE);

		// The image over the circle
		IGUIImage* circle_overlay =	guienv->addImage(topCircle,vector2d<s32>((gameplay_bar->getSize().Width/2)-64,gameplay_bar->getSize().Height-128),true,gameplay_bar_image);
	}	

	gameplay_bar_image->setVisible(false);

    ///DIALOG
	guiDialogImgYes = driver->getTexture("../media/art/img_yes.png");
    guiDialogImgYes_s = driver->getTexture("../media/art/img_yes_s.png");
    guiDialogImgNo = driver->getTexture("../media/art/img_no.png");
    guiDialogImgNo_s = driver->getTexture("../media/art/img_no_s.png");


    //view items
	if (gameplay_bar_image)
	{
		core::stringw text=LANGManager::getInstance()->getText("bt_view_items");
		IGUIButton* guiBtViewItems = guienv->addButton(GUIManager::getInstance()->myRect(465,85,48,48),
		//displaywidth/2 + 80,displayheight - 57,48,48),
                                     gameplay_bar_image,
									 GUIManager::BT_ID_VIEW_ITEMS,L"",
									 text.c_str());

		guiBtViewItems->setImage(driver->getTexture("../media/art/bt_view_items.png"));
		guiBtViewItems->setVisible(true);
		
	}

	

    //Items window

	IGUIWindow* guiWindowItems = guienv->addWindow(GUIManager::getInstance()->myRect(100,100,displaywidth-200,displayheight-150),false,L"",0,GUIManager::GCW_GAMEPLAY_ITEMS);
    guiWindowItems->getCloseButton()->setVisible(false);
    guiWindowItems->setDrawTitlebar(false);
    guiWindowItems->setDraggable(false);
	guiWindowItems->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER);
    IGUITabControl * gameTabCtrl = guienv->addTabControl(core::rect<s32>(10,30,displaywidth-240,displayheight-200),guiWindowItems,false,true,-1);
	IGUITab * tab1 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_stats_title").c_str());
	IGUITab * tab2 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_inventory_title").c_str());
	IGUITab * tab3 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_skills_title").c_str());
	IGUITab * tab4 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_quests_title").c_str());


	nodepreview = new NodePreview(guienv,tab1,rect<s32>(440,40,740,370),-1);
	nodepreview->drawBackground(false);

	//DynamicObjectsManager::getInstance()->setActiveObject("player_template");

	//guiPlayerNodePreview->setNode(DynamicObjectsManager::getInstance()->getActiveObject()->getNode());
	//guiPlayerNodePreview->setNode(Player::getInstance()->getNodeRef());
	//DynamicObjectsManager::getInstance()->setActiveObject("Archer");
	//printf("This is the node name: %s\n",DynamicObjectsManager::getInstance()->getActiveObject()->getName());
	nodepreview->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);

	IGUIListBox* guiPlayerItems = guienv->addListBox(GUIManager::getInstance()->myRect(10,30,200,displayheight-340),tab2,GUIManager::LB_ID_PLAYER_ITEMS,true);

	ITexture* info_none = driver->getTexture("../media/editor/info_none.jpg");

	IGUIImage* guiPlayerLootImage = NULL;

	if (info_none)
		guiPlayerLootImage = guienv->addImage(info_none,vector2d<s32>(220,30),true,tab2,GUIManager::IMG_LOOT);

	guienv->addStaticText(L"",core::rect<s32>(220,250,520,410),true,true,tab2,GUIManager::TXT_ID_LOOT_DESCRIPTION,true);

	//guienv->addImage(info_none,vector2d<s32>(5,5),true,tab2);
	core::stringc filename = "../media/dynamic_objects/";

	IGUIButton* guiBtUseItem = guienv->addButton(GUIManager::getInstance()->myRect(10,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_USE_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_use_item")).c_str());
    guiBtUseItem->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

    IGUIButton* guiBtDropItem = guienv->addButton(GUIManager::getInstance()->myRect(52,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_DROP_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_drop_item")).c_str());
    guiBtDropItem->setImage(driver->getTexture("../media/art/bt_no_32.png"));


    IGUIButton* guiBtCloseItemsWindow = guienv->addButton(GUIManager::getInstance()->myRect(displaywidth-210-32,displayheight-160 - 32,32,32),
                                         guiWindowItems,
										 GUIManager::BT_ID_CLOSE_ITEMS_WINDOW,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_close_items_window")).c_str());
    guiBtCloseItemsWindow->setImage(driver->getTexture("../media/art/bt_arrow_32.png"));
	guiWindowItems->setVisible(false);



	// TExt GUI for player stats

	IGUIStaticText* guiPlayerMoney = guienv->addStaticText(L"GOLD:129",GUIManager::getInstance()->myRect(15,displayheight-300,300,32),false,false,tab1, GUIManager::ST_ID_PLAYER_MONEY);
	guiPlayerMoney->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
    guiPlayerMoney->setOverrideColor(SColor(255,255,255,255));

	stringc playerLifeText = LANGManager::getInstance()->getText("txt_player_life");


	IGUIStaticText* guiPlayerLife=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(15,6,600,30),false,false,tab1,-1,false);
    guiPlayerLife->setOverrideColor(SColor(255,255,255,100));
    guiPlayerLife->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife->setID(GUIManager::ST_ID_PLAYER_LIFE);

	//Have to rework this. Currently hidden.
	IGUIStaticText* guiPlayerLife_Shadow=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(14,5,600,30),false,false,tab1,-1,false);
    guiPlayerLife_Shadow->setOverrideColor(SColor(255,30,30,30));
	guiPlayerLife_Shadow->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife_Shadow->setVisible(false);
	
	GUIManager::getInstance()->setElementVisible(GUIManager::ST_ID_PLAYER_LIFE, false);


	////// --------------------------------
	///    Define the Dialogs used in the game
	//////

	IGUIWindow* guidialog = guienv->addWindow(GUIManager::getInstance()->myRect(10,displayheight-200,displaywidth-20,190),true,L"",0,GUIManager::GCW_DIALOG);
	guidialog->getCloseButton()->setVisible(false);
	guidialog->setDrawTitlebar(false);
	guidialog->setDraggable(false);
	guidialog->setDrawBackground(false);
	guidialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Panel background is done with pictures
	IGUIImage* img1 = guienv->addImage(driver->getTexture("../media/art/panel_left.png"),vector2d<s32>(0,0),true,guidialog);
	IGUIImage* img2 = guienv->addImage(driver->getTexture("../media/art/panel_middle.png"),vector2d<s32>(51,0),true,guidialog);
	IGUIImage* img3 = guienv->addImage(driver->getTexture("../media/art/panel_right.png"),vector2d<s32>(581,0),true,guidialog);
	img2->setScaleImage(true);
	img2->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	img3->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Text display of the panel
	rect<s32> textRect = rect<s32>(30,25,600,170);
	IGUIStaticText* txt_dialog = guienv->addStaticText(L"Hello! This is a simple test to see how the text is flowing inside the box. There is a test, test, and test of text we need to make to be sure the flowing is ok",textRect,false,false,guidialog,GUIManager::TXT_ID_DIALOG,false);
	txt_dialog->setOverrideFont(GUIManager::getInstance()->guiFontDialog);
	txt_dialog->setOverrideColor(SColor(255,255,255,255));
	txt_dialog->setWordWrap(true);
	txt_dialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	IGUIButton* guiBtDialogYes = guienv->addButton(GUIManager::getInstance()->myRect(640,30,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_YES,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_yes")).c_str());
    guiBtDialogYes->setImage(guiDialogImgYes);
	guiBtDialogYes->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	IGUIButton* guiBtDialogCancel = guienv->addButton(GUIManager::getInstance()->myRect(640,110,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_CANCEL,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_no")).c_str());
    guiBtDialogCancel->setImage(guiDialogImgNo);
	guiBtDialogCancel->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guidialog->setVisible(false);

}
Ejemplo n.º 27
0
void cEditor::updatePoint(int start, int count){
	for (int id=start;id<count;id++){
		if (!points[id])
			continue;

		points[id] -> image -> setVisible (nodes[curId] && nodes[curId]->getCurrentNodeBox()!=NULL);

		if (nodes[curId]==NULL || nodes[curId]->getCurrentNodeBox()==NULL)
			continue;

		if (point_on == id){
			// get mouse position
			position2di target = mouse_position;
			target.X -= 5;
			target.Y -= 5;

			// correct out of bounds
			if (target.X < driver->getViewPort().UpperLeftCorner.X){
				target.X = driver->getViewPort().UpperLeftCorner.X-5;
			}else if (target.X > driver->getViewPort().LowerRightCorner.X){
				target.X = driver->getViewPort().LowerRightCorner.X-5;
			}
				
			if (target.Y < driver->getViewPort().UpperLeftCorner.Y){
				target.Y = driver->getViewPort().UpperLeftCorner.Y-5;	
			}else if (target.Y > driver->getViewPort().LowerRightCorner.Y){
				target.Y = driver->getViewPort().LowerRightCorner.Y-5;
			}

			// set image location
			points[id] -> image -> setRelativePosition(target);

			position2di tar2 = target;
			tar2.X -= driver->getViewPort().UpperLeftCorner.X - 5;
			tar2.Y -= driver->getViewPort().UpperLeftCorner.Y - 5;

			// get the ray
			line3d<irr::f32> ray = coli -> getRayFromScreenCoordinates(tar2,smgr->getActiveCamera());
			
			// contains the output values
			vector3df wpos = vector3df(0,0,0); // the collision position
			#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
				const ISceneNode* tmpNode; // not needed, but required for function
			#else
				ISceneNode* tmpNode; // not needed, but required for function
			#endif
			triangle3df tmpTri; // not needed, but required for function

			// Execute function
			coli->getCollisionPoint(ray,plane_tri,wpos,tmpTri,tmpNode);

			// Resize node box face
			nodes[curId]->resizeNodeBoxFace(nodes[curId]->getCurrentNodeBox(),points[id]->type,wpos);
		}else{
			vector3df position = vector3df(0,0,0);

			switch (points[id]->type){
			case CDR_X_P:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X + ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2);
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
				break;
			case CDR_X_N:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X - ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2);
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
				break;
			case CDR_Y_P:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X;
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y + ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2);
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
				break;
			case CDR_Y_N:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X;
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y - ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2);
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z;
				break;
			case CDR_Z_P:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X;
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z + ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2);
				break;
			case CDR_Z_N:
				position.X = nodes[curId]->getCurrentNodeBox()->position.X;
				position.Y = nodes[curId]->getCurrentNodeBox()->position.Y;
				position.Z = nodes[curId]->getCurrentNodeBox()->position.Z - ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2);
				break;
			}
			#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
				vector2d<irr::s32> cpos = coli -> getScreenCoordinatesFrom3DPosition(position,smgr->getActiveCamera());
			#else
				vector2d<irr::s32> cpos = coli -> getScreenCoordinatesFrom3DPosition(position,smgr->getActiveCamera(),true);
			#endif
			points[id] -> image -> setRelativePosition(position2di(driver->getViewPort().UpperLeftCorner.X+cpos.X-5, driver->getViewPort().UpperLeftCorner.Y+cpos.Y-5));
		}
	}
}
Ejemplo n.º 28
0
EditorEventReceiver::EditorEventReceiver(Editor* editor)
{
	this->editor = editor;
	setActiveCamera( camera[0] );
	this->oldMousePos = position2di(0,0);
}
Ejemplo n.º 29
0
// ----------------------------------------------------------------------------
void RoadPanel::init()
{
    m_next_road_mesh_ID = 1;

    Editor* editor = Editor::getEditor();
    path icons     = editor->getIconsLoc();

    IGUIEnvironment* gui_env = editor->getGUIEnv();
    IGUIFont* font = editor->getFont();
    m_wndw->setRelativePosition(position2di(0, 50));
    gui_env->addStaticText(_(L"Selected Road:"), rect<s32>(10, 10, 200, 30),
        false, false, m_wndw, -1, false)->setOverrideFont(font);

    m_cb = gui_env->addComboBox(rect<s32>(30, 45, 210, 65), m_wndw, SELECT);
    m_cb->addItem(L"DriveLine", 0);

    gui_env->addStaticText(_(L"Width:"), rect<s32>(30, 77, 90, 92), false, false, m_wndw);
    m_width_sb = gui_env->addScrollBar(true, rect<s32>(100, 80, 210, 90), m_wndw, WIDTH);
    m_width_sb->setMin(1);
    m_width_sb->setMax(400);
    m_width_sb->setPos(80);

    gui_env->addStaticText(_(L"Detail:"), rect<s32>(30, 92, 90, 117), false, false, m_wndw);
    m_detail_sb = gui_env->addScrollBar(true, rect<s32>(100, 95, 210, 105), m_wndw, DETAIL);
    m_detail_sb->setMin(1);
    m_detail_sb->setMax(100);
    m_detail_sb->setPos(25);

    gui_env->addButton(rect<s32>(30, 123, 90, 143), m_wndw, TEXTURE, _(L"Texture"));

    // SCROLLBAR - WRAP U
    m_u_sb = gui_env->addScrollBar(true, rect<s32>(100, 128, 210, 138), m_wndw, WRAP_U);
    m_u_sb->setMin(1);
    m_u_sb->setMax(15);
    m_u_sb->setPos(1);
    m_u_sb->setLargeStep(2);
    m_u_sb->setSmallStep(1);

    // SCROLLBAR - WRAP V
    m_v_sb = gui_env->addScrollBar(true, rect<s32>(100, 148, 210, 158), m_wndw, WRAP_V);
    m_v_sb->setMin(1);
    m_v_sb->setMax(100);
    m_v_sb->setPos(25);

    // SCROLLBAR - OFFSET U
    m_u_offset_sb = gui_env->addScrollBar(true, rect<s32>(100, 168, 210, 178), m_wndw, OFFSET_U);
    m_u_offset_sb->setMin(0);
    m_u_offset_sb->setMax(20);
    m_u_offset_sb->setPos(0);
    m_u_offset_sb->setLargeStep(4);
    m_u_offset_sb->setSmallStep(1);

    // SCROLLBAR - OFFSET V
    m_v_offset_sb = gui_env->addScrollBar(true, rect<s32>(100, 188, 210, 198), m_wndw, OFFSET_V);
    m_v_offset_sb->setMin(0);
    m_v_offset_sb->setMax(20);
    m_v_offset_sb->setPos(0);
    m_v_offset_sb->setLargeStep(4);
    m_v_offset_sb->setSmallStep(1);

    // CHECKBOX 
    m_swap_uv        = gui_env->addCheckBox(false, rect<s32>(30,255,210,285),
                                            m_wndw, SWAP_UV, L"Swap UV");

    m_closed_road_cb = gui_env->addCheckBox(false, rect<s32>(30, 290, 210, 320),
                                            m_wndw, CLOSED_ROAD, L"Closed Road");

    gui_env->addButton(rect<s32>(30, 330, 80, 380), m_wndw, ADD, L"", _(L"Add ControlPoint"))
        ->setImage(Editor::loadImg(icons + "dl_add.png"));
    gui_env->addButton(rect<s32>(95, 330, 145, 380), m_wndw, INSERT, L"", _(L"Insert ControlPoint"))
        ->setImage(Editor::loadImg(icons + "dl_insert.png"));
    gui_env->addButton(rect<s32>(160, 330, 210, 380), m_wndw, EXIT, L"", _(L"Finish Point Placing"))
        ->setImage(Editor::loadImg(icons + "dl_ready.png"));

    gui_env->addButton(rect<s32>(60, 395, 110, 445), m_wndw, CROSS_SECTION, L"", _(L"Editor road cross section"))
        ->setImage(Editor::loadImg(icons + "edit_crossroads_section.png"));
    gui_env->addButton(rect<s32>(130, 395, 180, 445), m_wndw, ATTACH_TO_DL, L"", _(L"Attach to DriveLine"))
        ->setImage(Editor::loadImg(icons + "create-quads.png"));

    m_spline_type_cb = gui_env->addComboBox(rect<s32>(30, 470, 150, 490), m_wndw);
    m_spline_type_cb->addItem(L"Bezier", 0);
    m_spline_type_cb->addItem(L"Catmull-Rom", 1);

    m_text_field = gui_env->addEditBox(L"RoadMesh_1",rect<s32>(30, 495, 150, 515),true,m_wndw,NAMEBOX);

    gui_env->addButton(rect<s32>(160, 470, 210, 515), m_wndw, CREATE, L"", _(L"Create New Road Mesh"))
        ->setImage(Editor::loadImg(icons + "road_create.png"));
        
    gui_env->addButton(rect<s32>(30, 530, 210, 580), m_wndw, CHECKLINE, L"CHECKLINE");

    m_insert = false;

} // init
Ejemplo n.º 30
0
void CPlayer::createPlayerGUI(bool bHSplit, const wchar_t *sName, u32 iCheckpoints) {
	dimension2du cScreenSize=m_pDevice->getVideoDriver()->getScreenSize();
	position2di pos;

	IVideoDriver *pDriver=m_pDevice->getVideoDriver();
	IGUIEnvironment *pGuienv=m_pDevice->getGUIEnvironment();

	if (m_iNum==1 || m_bNetClient) {
		pos.X=37;
		pos.Y=(bHSplit || m_bNetClient)?cScreenSize.Height-42:cScreenSize.Height/2-42;
	}
	else {
		//m_kinectJoystick->setVisible(false); //if two players don't show joystick
		pos.X=bHSplit?cScreenSize.Width-237:37;
		pos.Y=cScreenSize.Height-42;
		m_kinectJoystick->plyerNo=2; //HACK
	}

	m_pName=pGuienv->addStaticText(sName,rect<s32>(pos.X,pos.Y,pos.X+200,pos.Y+32));
	m_pName->setDrawBackground(true);
	m_pName->setOverrideColor(SColor(255,255,118,70));
	m_pName->setOverrideFont(m_pBigFont);
	m_pName->setBackgroundColor(SColor(128,16,16,16));
	m_pName->setTextAlignment(EGUIA_CENTER,EGUIA_CENTER);

	if (bHSplit)
		pos=position2di(m_iNum==1 || m_bNetClient?5:cScreenSize.Width-37,cScreenSize.Height-42);
	else
		pos=position2di(5,m_iNum==1 && !m_bNetClient?cScreenSize.Height/2-42:cScreenSize.Height-42);

	m_pCamMode=pGuienv->addImage(pDriver->getTexture("data/freecam.png"),pos);
	m_pCamFree=pDriver->getTexture("data/freecam.png");
	m_pCamRace=pDriver->getTexture("data/racecam.png");
	m_pCpOk =pDriver->getTexture("data/checkpoint_ok.png" );
	m_pCpNok=pDriver->getTexture("data/checkpoint_nok.png");

	if (bHSplit || m_bNetClient)
		pos=position2di(m_iNum==1 || m_bNetClient?5:cScreenSize.Width-265,12);
	else
		pos=position2di(5,m_iNum==1 || m_bNetClient?12:cScreenSize.Height/2+17);

	ITexture *img=pDriver->getTexture("data/checkpoint.png");
	m_pSpeed=pGuienv->addImage(img,pos);

	m_pInfo=pGuienv->addStaticText(L"Hello World!",rect<s32>(pos.X+15,pos.Y+7,pos.X+245,pos.Y+30));

	pos=position2di(m_iNum==1 || m_bNetClient?5:bHSplit?cScreenSize.Width-22:5,bHSplit?56:m_iNum==1 || m_bNetClient?56:cScreenSize.Height/2+61);
	for (u32 i=0; i<iCheckpoints; i++) {
		IGUIImage *pCp=pGuienv->addImage(m_pCpNok,pos);
		pos.Y+=22;
		m_aCpState.push_back(pCp);
	}

	if (bHSplit || m_bNetClient)
		pos=position2di(m_iNum==1 || m_bNetClient?39:cScreenSize.Width-255,56);
	else
		pos=position2di(35,m_iNum==1 || m_bNetClient?56:cScreenSize.Height/2+61);

	m_pCpInfo=pGuienv->addTab(rect<s32>(pos.X,pos.Y,pos.X+215,pos.Y+60));
	m_pCpInfo->setBackgroundColor(SColor(128,192,192,192));
	m_pCpInfo->setDrawBackground(true);
	m_pCpInfo->setToolTipText(L"Checkpoint Info");
	pGuienv->addImage(pDriver->getTexture("data/cp_done.png"),position2di(5,5),true,m_pCpInfo);
	m_pCpTime=pGuienv->addStaticText(L"Cp_time",rect<s32>(5,40,205,60),false,true,m_pCpInfo);
	m_pCpInfo->setVisible(false);

	pos.Y+=10;
	if (m_iNum!=1 && !m_bNetClient && bHSplit) {
		pos.X=cScreenSize.Width-190;
	}

	pos=position2di(m_iNum==1 || m_bNetClient?30:bHSplit?cScreenSize.Width-240:50,bHSplit?56:m_iNum==1 || m_bNetClient?56:cScreenSize.Height/2+61);

	m_pLapTab=pGuienv->addTab(rect<s32>(pos.X,pos.Y,pos.X+200,pos.Y+55));
	m_pLapTab->setVisible(false);
	m_pLapTab->setToolTipText(L"Lap Info");
	pos=position2di(5,5);
	ITexture *tex=pDriver->getTexture("data/lap.png");
	m_pLap=pGuienv->addImage(pDriver->getTexture("data/lap.png"),pos,true,m_pLapTab);
	pos.X+=tex->getSize().Width+5;

	for (u32 j=0; j<5; j++) {
		IGUIImage *pImg=pGuienv->addImage(m_aNumbers[11],pos,true,m_pLapTab);
		m_aLapNo.push_back(pImg);
		pos.X+=26;
	}

	pos.X=(!bHSplit || m_iNum==1 || m_bNetClient)? 30:cScreenSize.Width   -136;
	pos.Y=( bHSplit || m_iNum==1 || m_bNetClient)?130:cScreenSize.Height/2+140;

	m_pFinished=pGuienv->addImage(pDriver->getTexture("data/finished.png"),pos);
	m_pFinished->setVisible(false);
	m_pFinished->setToolTipText(L"Finished");
}