Example #1
0
void CUIArtefactDetectorElite::Draw()
{

	Fmatrix						LM;
	GetUILocatorMatrix			(LM);

	IUIRender::ePointType bk	= UI().m_currentPointType;

	UI().m_currentPointType	= IUIRender::pttLIT;

	UIRender->CacheSetXformWorld(LM);
	UIRender->CacheSetCullMode	(IUIRender::cmNONE);

	CUIWindow::Draw				();

//.	Frect r						= m_wrk_area->GetWndRect();
	Fvector2 wrk_sz				= m_wrk_area->GetWndSize();
	Fvector2					rp; 
	m_wrk_area->GetAbsolutePos	(rp);

	Fmatrix						M, Mc;
	float h,p;
	Device.vCameraDirection.getHP(h,p);
	Mc.setHPB					(h,0,0);
	Mc.c.set					(Device.vCameraPosition);
	M.invert					(Mc);

	UI().ScreenFrustumLIT().CreateFromRect(Frect().set(	rp.x,
													rp.y,
													wrk_sz.x,
													wrk_sz.y ));

	xr_vector<SDrawOneItem>::const_iterator it	 = m_items_to_draw.begin();
	xr_vector<SDrawOneItem>::const_iterator it_e = m_items_to_draw.end();
	for(;it!=it_e;++it)
	{
		Fvector					p = (*it).pos;
		Fvector					pt3d;
		M.transform_tiny		(pt3d,p);
		float kz				= wrk_sz.y / m_parent->m_fAfDetectRadius;
		pt3d.x					*= kz;
		pt3d.z					*= kz;

		pt3d.x					+= wrk_sz.x/2.0f;	
		pt3d.z					-= wrk_sz.y;

		Fvector2				pos;
		pos.set					(pt3d.x, -pt3d.z);
		pos.sub					(rp);
		if(1 /* r.in(pos)*/ )
		{
			(*it).pStatic->SetWndPos	(pos);
			(*it).pStatic->Draw			();
		}
	}

	UI().m_currentPointType		= bk;
}
Example #2
0
Frect CUITextureMaster::GetTextureRect(const char* texture_name){
	xr_map<shared_str, TEX_INFO>::iterator	it;
	it = m_textures.find(texture_name);
	if (it != m_textures.end())
		return (*it).second.rect;

	R_ASSERT3(false,"CUITextureMaster::GetTextureHeight Can't find texture", texture_name);
	return Frect();
}
Example #3
0
void CUITalkWnd::InitTalkWnd()
{
	inherited::SetWndRect(Frect().set(0, 0, UI_BASE_WIDTH, UI_BASE_HEIGHT));

	UITalkDialogWnd = new CUITalkDialogWnd();UITalkDialogWnd->SetAutoDelete(true);
	AttachChild(UITalkDialogWnd);
	UITalkDialogWnd->m_pParent = this;
	UITalkDialogWnd->InitTalkDialogWnd();
}
Example #4
0
void ui_core::OnDeviceReset()
{
	m_scale_.set		( float(Device.dwWidth)/UI_BASE_WIDTH, float(Device.dwHeight)/UI_BASE_HEIGHT );

	m_2DFrustum.CreateFromRect	(Frect().set(	0.0f,
												0.0f,
												float(Device.dwWidth),
												float(Device.dwHeight)
												));
}
Example #5
0
Frect CInventoryItem::GetKillMsgRect() const
{
	float x,y,w,h;

	x = READ_IF_EXISTS(pSettings,r_float,m_object->cNameSect(),"kill_msg_x", 0.0f);
	y = READ_IF_EXISTS(pSettings,r_float,m_object->cNameSect(),"kill_msg_y", 0.0f);
	w = READ_IF_EXISTS(pSettings,r_float,m_object->cNameSect(),"kill_msg_width", 0.0f);
	h = READ_IF_EXISTS(pSettings,r_float,m_object->cNameSect(),"kill_msg_height", 0.0f);

	return Frect().set(x,y,w,h);
}
Example #6
0
void ui_core::pp_start()
{
	m_bPostprocess		= true;

	m_pp_scale_.set	( float(::Render->getTarget()->get_width())/float(UI_BASE_WIDTH),	float(::Render->getTarget()->get_height())/float(UI_BASE_HEIGHT) );
	m_2DFrustumPP.CreateFromRect(Frect().set(	0.0f,
												0.0f,
												float(::Render->getTarget()->get_width()),
												float(::Render->getTarget()->get_height())
												));

	m_current_scale			= &m_pp_scale_;
//.	g_current_font_scale	= m_pp_scale_;
	
	g_current_font_scale.set(	float(::Render->getTarget()->get_width())/float(Device.dwWidth),	
								float(::Render->getTarget()->get_height())/float(Device.dwHeight) );

}
void CUIActorMenu::InfoCurItem( CUICellItem* cell_item )
{
	if ( !cell_item )
	{
		m_ItemInfo->InitItem( NULL );
		return;
	}
	PIItem current_item = (PIItem)cell_item->m_pData;

	PIItem compare_item = NULL;
	u32    compare_slot = current_item->GetSlot();
	if ( compare_slot != NO_ACTIVE_SLOT )
	{
		compare_item = m_pActorInvOwner->inventory().m_slots[compare_slot].m_pIItem;
	}

#ifdef TRADE_TIP
	m_ItemInfo->m_TradeTip = "";
	if (m_currMenuMode == mmTrade)
	{
		// calculation tips
		CInventoryOwner* item_owner = smart_cast<CInventoryOwner*>(current_item->m_pInventory->GetOwner());
		if (!current_item->CanTrade() ||
			(
			item_owner && item_owner == m_pActorInvOwner &&
			!m_pPartnerInvOwner->trade_parameters().enabled(CTradeParameters::action_buy(0), current_item->object().cNameSect())
			)
			)
			m_ItemInfo->m_TradeTip = "st_no_trade_tip_1";
		else if (current_item->GetCondition() < m_pPartnerInvOwner->trade_parameters().buy_item_condition_factor)
			m_ItemInfo->m_TradeTip = "st_no_trade_tip_2";
	}
#endif

	m_ItemInfo->InitItem	( current_item, compare_item );
	float dx_pos = GetWndRect().left;
	m_ItemInfo->AlignHintWndPos( Frect().set( 0.0f, 0.0f, 1024.0f - dx_pos, 768.0f ), 10.0f, dx_pos );
}
Example #8
0
void Openchunk::run()
{
		png_structp png_ptr_read;
    png_infop info_ptr_read;
    png_structp png_ptr_write;
    png_infop info_ptr_write;
	
    png_uint_32 next_frame_width;
    png_uint_32 next_frame_height;
    png_uint_32 next_frame_x_offset;
    png_uint_32 next_frame_y_offset;
    png_uint_16 next_frame_delay_num;
    png_uint_16 next_frame_delay_den;
    png_byte next_frame_dispose_op;
    png_byte next_frame_blend_op;
    png_color_16p Framebg;
	  framlist.clear();
	
  buffer = new StreamFile();
  buffer->LoadFile(subfile);
	qDebug() << "### start read ->" << subfile;
	if (!buffer->isValid()) {
		alert("unvalid buffer fill",__LINE__);
		exit(0);
	}
	validpng = buffer->device()->peek(4).contains("PNG");
	qDebug() << "### ahed  ->" << validpng;
	frame1.loadFromData(buffer->stream()); /* load first frame */
	if (frame1.isNull()) {
		alert("unable find a valid image",__LINE__);
		return;
	}
	png_ptr_read = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if(png_ptr_read == NULL) {
		alert("unable to create read struct",__LINE__);
		return;
	}
	info_ptr_read = png_create_info_struct(png_ptr_read);
	if(info_ptr_read == NULL) {
     alert("unable to create info struct",__LINE__);
		 return;
	}

	png_set_read_fn(png_ptr_read,buffer,EncoderReaderCallback);
	
	if(setjmp(png_ptr_read->jmpbuf)) {
        alert("something didn't work, jump 1",__LINE__);
		    return;
	}
	
	png_read_info(png_ptr_read, info_ptr_read);
	
	if(!png_get_valid(png_ptr_read, info_ptr_read, PNG_INFO_acTL)) {
			alert("source image must be animated",__LINE__);
		  return;
	}
	
	  QRect Frect(0,0,info_ptr_read->width,info_ptr_read->height);
    ////////////qDebug() << "### Frame rect from head ->" << Frect;
    QImage master(Frect.width(),Frect.height(),QImage::Format_ARGB32);
    const uint height = master.height();
    png_bytep *row_pointers = new png_bytep[height];
                        for (uint i = 0; i < height; ++i)  {
                          row_pointers[i] = (png_bytep)master.scanLine(i);
                        }
    int validloop = -1;
    for(int i = 0; i < png_get_num_frames(png_ptr_read, info_ptr_read); i++)
    {
        /////////qDebug() << "### frame read  ------------- " << i;
				png_ptr_write = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
        if(png_ptr_write == NULL)  {
        alert("unable to create write struct");
        return;
        }
        StreamFile *framer = new StreamFile();
        png_set_write_fn(png_ptr_write,framer,EncoderWriteCallback, NULL);
        info_ptr_write = png_create_info_struct(png_ptr_write);
        if(info_ptr_write == NULL)  {
        alert("unable to create write struct");
        return;
        }
        if(setjmp(png_ptr_write->jmpbuf))  {
            alert("something didn't work, jump 2");
            return;
        }
				png_read_frame_head(png_ptr_read, info_ptr_read);
				if(png_get_valid(png_ptr_read, info_ptr_read, PNG_INFO_fcTL))
        {
            png_get_next_frame_fcTL(png_ptr_read, info_ptr_read,
                                    &next_frame_width, &next_frame_height,
                                    &next_frame_x_offset, &next_frame_y_offset,
                                    &next_frame_delay_num, &next_frame_delay_den,
                                    &next_frame_dispose_op, &next_frame_blend_op);
        }
        else
        {
            /* the first frame doesn't have an fcTL so it's expected to be hidden, 
            * but we'll extract it anyway  next_frame_x_offset , next_frame_y_offset */ 
            next_frame_width = png_get_image_width(png_ptr_read, info_ptr_read);
            next_frame_height = png_get_image_height(png_ptr_read, info_ptr_read);
        }
				QRect C_frame_rect(0,0,next_frame_width,next_frame_height);
				
				
				AFRAMES FrameInfo = OneFrameReader(png_ptr_read, info_ptr_read, png_ptr_write, info_ptr_write,
        next_frame_width, next_frame_height);
				png_write_info(png_ptr_write, info_ptr_write);
				png_read_image(png_ptr_read, row_pointers);
        png_write_image(png_ptr_write, row_pointers);
        png_write_end(png_ptr_write, NULL);
				
				            float Fraction = (float)next_frame_delay_num /  (float)next_frame_delay_den + 0.00;
                    ////////qDebug() << "### Fraction  " << Fraction;
                    int PlayGo;
                    if (Fraction < 0.001 ) {
                        PlayGo = 100;
                    } else if (Fraction < 1.010 && Fraction > 0.9) {
                        PlayGo = 1000;
                    } else {
                        PlayGo = Fraction * 1000;
                    }
										
				/* extract frames */
				if ( framer->isValid() && Frect.contains(C_frame_rect) ) {
					 validloop++;
					 int Coalpha = 255;
					 /* prepare image if no background find grab a pixel color! */
					 QImage tmpgd(C_frame_rect.width(),C_frame_rect.height(),QImage::Format_ARGB32);
					 /* compose it files */
					 APNGFRAME one;
					 one.dimg = framer->stream();
					 one.maxframe = Frect;
					 one.pos = validloop;
					 one.point = QPoint(next_frame_x_offset,next_frame_y_offset);
					 one.play = PlayGo;
					 if (!(png_get_valid(png_ptr_read, info_ptr_read, PNG_INFO_bKGD))) {
					 tmpgd.loadFromData(one.dimg);
					 QRgb GrepColor = tmpgd.pixel(QPoint(2,2));
					 one.bg = QColor(GrepColor);
					 one.bg.setAlpha(qAlpha(GrepColor));
					 Coalpha = qAlpha(GrepColor);
					 } else {
					 one.bg = FrameInfo.bg; 
					 }
					 
					       QImage tmpe;
					       QImage Pvidi(one.maxframe.width(),one.maxframe.height(),QImage::Format_ARGB32);
					       if (tmpe.loadFromData(one.dimg)) {
								 QPainter p(&Pvidi);
								 p.setRenderHint(QPainter::Antialiasing, true);
								 p.setBrush(one.bg);
								 p.drawRect(Pvidi.rect());
								 p.drawImage(one.point,tmpe);
								 p.end();
								 one.item = Pvidi; 
                 ////qDebug() << "### isNull() in theard .." << one.item.isNull();									 
								 }
					 
					 
					 //////item tmpe
					 //////qDebug() << "### Frame rect ->" << one.point << ",nr." << validloop << "C." << one.bg.name() << "Al." << Coalpha;
					 framlist.insert(validloop,one);
				}
				framer->~StreamFile();
				png_ptr_write = 0;
        info_ptr_write = 0;
		}
	
	
	qDebug() << "### Frame size() ->" << framlist.size();
	//////alert("end of chunks",__LINE__);
	validpng = true;
	buffer->~StreamFile();
	exit(0);
}
Example #9
0
void CUIActorMenu::InfoCurItem( CUICellItem* cell_item )
{
	if ( !cell_item )
	{
		m_ItemInfo->InitItem( NULL );
		return;
	}
	PIItem current_item = (PIItem)cell_item->m_pData;

	PIItem compare_item = NULL;
	u16    compare_slot = current_item->BaseSlot();
	if ( compare_slot != NO_ACTIVE_SLOT )
	{
		compare_item = m_pActorInvOwner->inventory().ItemFromSlot(compare_slot);
	}

	if(GetMenuMode()==mmTrade)
	{
		CInventoryOwner* item_owner = smart_cast<CInventoryOwner*>(current_item->m_pInventory->GetOwner());
		u32 item_price = u32(-1);
		if(item_owner && item_owner==m_pActorInvOwner)
			item_price = m_partner_trade->GetItemPrice(current_item, true);
		else
			item_price = m_partner_trade->GetItemPrice(current_item, false);

		//if(item_price>500)
		//	item_price = iFloor(item_price/10+0.5f)*10;

		CWeaponAmmo* ammo = smart_cast<CWeaponAmmo*>(current_item);
		if(ammo)
		{
			for( u32 j = 0; j < cell_item->ChildsCount(); ++j )
			{
				u32 tmp_price	= 0;
				PIItem jitem	= (PIItem)cell_item->Child(j)->m_pData;
				CInventoryOwner* ammo_owner = smart_cast<CInventoryOwner*>(jitem->m_pInventory->GetOwner());
				if(ammo_owner && ammo_owner==m_pActorInvOwner)
					tmp_price = m_partner_trade->GetItemPrice(jitem, true);
				else
					tmp_price = m_partner_trade->GetItemPrice(jitem, false);

				//if(tmp_price>500)
				//	tmp_price = iFloor(tmp_price/10+0.5f)*10;

				item_price		+= tmp_price;
			}
		}

		if(	!current_item->CanTrade() || 
			(!m_pPartnerInvOwner->trade_parameters().enabled(CTradeParameters::action_buy(0), 
															current_item->object().cNameSect()) &&
			item_owner && item_owner==m_pActorInvOwner)
		)
			m_ItemInfo->InitItem	( cell_item, compare_item, u32(-1), "st_no_trade_tip_1" );
		else if(current_item->GetCondition()<m_pPartnerInvOwner->trade_parameters().buy_item_condition_factor)
			m_ItemInfo->InitItem	( cell_item, compare_item, u32(-1), "st_no_trade_tip_2" );
		else
			m_ItemInfo->InitItem	( cell_item, compare_item, item_price );
	}
	else
		m_ItemInfo->InitItem	( cell_item, compare_item, u32(-1));

//	m_ItemInfo->InitItem	( current_item, compare_item );
	float dx_pos = GetWndRect().left;
	fit_in_rect(m_ItemInfo, Frect().set( 0.0f, 0.0f, UI_BASE_WIDTH - dx_pos, UI_BASE_HEIGHT ), 10.0f, dx_pos );
}