示例#1
0
//-----------------------------------------------------------------------------
// ARX Menu Rendering Func
// returns false if no menu needs to be displayed
//-----------------------------------------------------------------------------
bool ARX_Menu_Render() {
	
	if(ARXmenu.currentmode == AMCM_OFF)
		return false;

	bool br = Menu2_Render();

	if(br)
		return br;

	if(ARXmenu.currentmode == AMCM_OFF)
		return false;

	if(GInput->getMouseButton(Mouse::Button_0)) {
		EERIEMouseButton = 1;
		LastMouseClick = 1;
	} else if(GInput->getMouseButton(Mouse::Button_1)) {
		EERIEMouseButton = 2;
		LastMouseClick = 2;
	} else {
		EERIEMouseButton = 0;
	}

	GRenderer->BeginScene();

	GRenderer->Clear(Renderer::ColorBuffer | Renderer::DepthBuffer);
	
	FLYING_OVER = 0;

	//-------------------------------------------------------------------------

	if(ARXmenu.currentmode == AMCM_NEWQUEST && ARXmenu.mda) {
		if(ITC.Get("questbook") == NULL) {
			ARX_Menu_Resources_Release(false);
			ARX_Menu_Resources_Create();
			
			// TODO this is also in Interface.cpp

			ITC.Set("playerbook", "graph/interface/book/character_sheet/char_sheet_book");
			ITC.Set("ic_casting", "graph/interface/book/character_sheet/buttons_carac/icone_casting");
			ITC.Set("ic_close_combat", "graph/interface/book/character_sheet/buttons_carac/icone_close_combat");
			ITC.Set("ic_constitution", "graph/interface/book/character_sheet/buttons_carac/icone_constit");
			ITC.Set("ic_defense", "graph/interface/book/character_sheet/buttons_carac/icone_defense");
			ITC.Set("ic_dexterity", "graph/interface/book/character_sheet/buttons_carac/icone_dext");
			ITC.Set("ic_etheral_link", "graph/interface/book/character_sheet/buttons_carac/icone_etheral_link");
			ITC.Set("ic_mind", "graph/interface/book/character_sheet/buttons_carac/icone_intel");
			ITC.Set("ic_intuition", "graph/interface/book/character_sheet/buttons_carac/icone_intuition");
			ITC.Set("ic_mecanism", "graph/interface/book/character_sheet/buttons_carac/icone_mecanism");
			ITC.Set("ic_object_knowledge", "graph/interface/book/character_sheet/buttons_carac/icone_obj_knowledge");
			ITC.Set("ic_projectile", "graph/interface/book/character_sheet/buttons_carac/icone_projectile");
			ITC.Set("ic_stealth", "graph/interface/book/character_sheet/buttons_carac/icone_stealth");
			ITC.Set("ic_strength", "graph/interface/book/character_sheet/buttons_carac/icone_strenght");

			ITC.Set("questbook", "graph/interface/book/questbook");
			ITC.Set("ptexspellbook", "graph/interface/book/spellbook");
			ITC.Set("bookmark_char", "graph/interface/book/bookmark_char");
			ITC.Set("bookmark_magic", "graph/interface/book/bookmark_magic");
			ITC.Set("bookmark_map", "graph/interface/book/bookmark_map");
			ITC.Set("bookmark_quest", "graph/interface/book/bookmark_quest");

			ITC.Set("accessible_1", "graph/interface/book/accessible/accessible_1");
			ITC.Set("accessible_2", "graph/interface/book/accessible/accessible_2");
			ITC.Set("accessible_3", "graph/interface/book/accessible/accessible_3");
			ITC.Set("accessible_4", "graph/interface/book/accessible/accessible_4");
			ITC.Set("accessible_5", "graph/interface/book/accessible/accessible_5");
			ITC.Set("accessible_6", "graph/interface/book/accessible/accessible_6");
			ITC.Set("accessible_7", "graph/interface/book/accessible/accessible_7");
			ITC.Set("accessible_8", "graph/interface/book/accessible/accessible_8");
			ITC.Set("accessible_9", "graph/interface/book/accessible/accessible_9");
			ITC.Set("accessible_10", "graph/interface/book/accessible/accessible_10");
			ITC.Set("current_1", "graph/interface/book/current_page/current_1");
			ITC.Set("current_2", "graph/interface/book/current_page/current_2");
			ITC.Set("current_3", "graph/interface/book/current_page/current_3");
			ITC.Set("current_4", "graph/interface/book/current_page/current_4");
			ITC.Set("current_5", "graph/interface/book/current_page/current_5");
			ITC.Set("current_6", "graph/interface/book/current_page/current_6");
			ITC.Set("current_7", "graph/interface/book/current_page/current_7");
			ITC.Set("current_8", "graph/interface/book/current_page/current_8");
			ITC.Set("current_9", "graph/interface/book/current_page/current_9");
			ITC.Set("current_10", "graph/interface/book/current_page/current_10");

			ITC.Set("ptexcursorredist", "graph/interface/cursors/add_points");

			ITC.Level = getLocalised("system_charsheet_player_lvl");
			ITC.Xp = getLocalised("system_charsheet_player_xp");

			ANIM_Set(&player.bookAnimation[0], herowaitbook);
			player.bookAnimation[0].flags |= EA_LOOP;

			ARXOldTimeMenu = ARXTimeMenu = arxtime.get_updated();
			ARXDiffTimeMenu = 0;
		}

		GRenderer->SetRenderState(Renderer::Fog, false);
		GRenderer->SetRenderState(Renderer::AlphaBlending, false);

		if(ARXmenu.mda->BookBackground != NULL) {
			GRenderer->SetRenderState(Renderer::AlphaBlending, false);
			GRenderer->SetRenderState(Renderer::Fog, false);
			GRenderer->SetRenderState(Renderer::DepthWrite, false);
			GRenderer->SetRenderState(Renderer::DepthTest, false);

			EERIEDrawBitmap2(0, 0, static_cast<float>(g_size.width()), static_cast<float>(g_size.height()), 0.9f, ARXmenu.mda->BookBackground, Color::white);
		}

		BOOKZOOM = 1;

		ARX_INTERFACE_ManageOpenedBook();


		if(ARXmenu.mda) {
			long DONE = 0;

			if(player.Skill_Redistribute == 0 && player.Attribute_Redistribute == 0)
				DONE = 1;

			float ox, oy;
			ox = Xratio;
			oy = Yratio;
			LASTBOOKBUTTON = BOOKBUTTON;
			BOOKBUTTON = EERIEMouseButton;
			Xratio = ox;
			Yratio = oy;

			if(!ARXmenu.mda->flyover[FLYING_OVER].empty() ) //=ARXmenu.mda->flyover[FLYING_OVER];
			{
				if(FLYING_OVER != OLD_FLYING_OVER) {

					float fRandom = rnd() * 2;

					int t = checked_range_cast<int>(fRandom);

					pTextManage->Clear();
					OLD_FLYING_OVER = FLYING_OVER;
					UNICODE_ARXDrawTextCenteredScroll(hFontInGame,
						(g_size.width() * 0.5f),
						12,
						(g_size.center().x) * 0.82f,
						ARXmenu.mda->flyover[FLYING_OVER],
						Color(232 + t, 204 + t, 143 + t),
						1000,
						0.01f,
						2);
				}
			} else {
				OLD_FLYING_OVER = -1;
			}
			
			float fPosX = 0;
			float fPosY = 313 * Yratio + (g_size.height() - 313 * Yratio) * 0.70f;

			float fSizeX = 100 * Xratio;
			float fSizeY = 100 * Yratio;

			Color color = Color::none;

			//---------------------------------------------------------------------
			// Button QUICK GENERATION
			fPosX = (g_size.width() - (513 * Xratio)) * 0.5f;

			if(MouseInRect(fPosX, fPosY, fPosX + fSizeX + 50, fPosY + fSizeY)) {
				SpecialCursor = CURSOR_INTERACTION_ON;
				FLYING_OVER = BUTTON_QUICK_GENERATION;

				if (EERIEMouseButton & 1) ;
				else if ((!(EERIEMouseButton & 1)) && (LastMouseClick & 1))
				{
					QUICK_MOD++;
					int iSkin = player.skin;
					ARX_MENU_CLICKSOUND();

					if(bQuickGenFirstClick) {
						ARX_PLAYER_MakeAverageHero();
						bQuickGenFirstClick = false;
					} else {
						ARX_PLAYER_QuickGeneration();
					}

					player.skin = checked_range_cast<char>(iSkin);
				}

				color = Color(255, 255, 255);
			}
			else
				color = Color(232, 204, 143);

			pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_quickgen, static_cast<long>(fPosX), static_cast<long>(fPosY), color);

			//---------------------------------------------------------------------
			// Button SKIN
			fPosX = g_size.width() * 0.5f;

			if(MouseInRect(fPosX, fPosY, fPosX + fSizeX, fPosY + fSizeY)) {
				SpecialCursor = CURSOR_INTERACTION_ON;
				FLYING_OVER = BUTTON_SKIN;

				if(!(EERIEMouseButton & 1) && (LastMouseClick & 1)) {
					SKIN_MOD++;
					BOOKZOOM = 1;
					ARX_MENU_CLICKSOUND();
					player.skin++;

					if(player.skin > 3)
						player.skin = 0;

					ARX_PLAYER_Restore_Skin();
				}

				color = Color(255, 255, 255);
			}
			else
				color = Color(232, 204, 143);

			pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_skin, static_cast<long>(fPosX), static_cast<long>(fPosY), color);

			//---------------------------------------------------------------------
			// Button DONE
			fPosX = g_size.width() - (g_size.width() - 513 * Xratio) * 0.5f - 40 * Xratio;

			if(MouseInRect(fPosX, fPosY, fPosX + fSizeX, fPosY + fSizeY)) {
				if(DONE)
					SpecialCursor = CURSOR_INTERACTION_ON;

				FLYING_OVER = BUTTON_DONE;

				if(DONE && !(EERIEMouseButton & 1) && (LastMouseClick & 1)) {
					if(SKIN_MOD == 8 && QUICK_MOD == 10) {
						SKIN_MOD = -2;
					} else if(SKIN_MOD == -1) {
						ARX_PLAYER_MakeSpHero();
						player.skin = 4;
						ARX_PLAYER_Restore_Skin();
						SKIN_MOD = 0;
						SP_HEAD = 1;
					} else {
						if(SP_HEAD) {
							player.skin = 4;
							ARX_PLAYER_Restore_Skin();
							SP_HEAD = 0;
						}

						ARX_MENU_CLICKSOUND();

						bFadeInOut = true;		//fade out
						bFade = true;			//active le fade
						iFadeAction = AMCM_OFF;
					}
				} else {
					if(DONE)
						color = Color(255, 255, 255);
					else
						color = Color(192, 192, 192);
				}
			} else {
				if(DONE)
					color = Color(232, 204, 143);
				else
					color = Color(192, 192, 192);
			}

			if(SKIN_MOD < 0)
				color = Color(255, 0, 255);

			pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_done, static_cast<long>(fPosX), static_cast<long>(fPosY), color);
		}
	}

	DynLight[0].pos.x = 0.f + GInput->getMousePosAbs().x - (g_size.width() >> 1);
	DynLight[0].pos.y = 0.f + GInput->getMousePosAbs().y - (g_size.height() >> 1);

	if(pTextManage) {
		pTextManage->Update(framedelay);
		pTextManage->Render();
	}

	if(ARXmenu.currentmode != AMCM_CREDITS)
		ARX_INTERFACE_RenderCursor(1);

	if(ARXmenu.currentmode == AMCM_NEWQUEST) {
		if(ProcessFadeInOut(bFadeInOut, 0.1f)) {
			switch(iFadeAction) {
				case AMCM_OFF:
					arxtime.resume();
					ARX_MENU_NEW_QUEST_Clicked_QUIT();
					iFadeAction = -1;
					bFade = false;
					fFadeInOut = 0.f;

					if(pTextManage)
						pTextManage->Clear();

					break;
			}
		}
	}

	GRenderer->EndScene();
	return true;
}
示例#2
0
void MiniMap::showBookEntireMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(!m_levels[showLevel].m_texContainer) {
		return;
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	float zoom = 250.f;
	float startX = 140.f;
	float startY = 120.f;
	
	Vec2f playerPos(0.f, 0.f);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		playerPos = computePlayerPos(zoom, showLevel);
		playerPos.x += startX;
		playerPos.y += startY;
	}
	
	drawBackground(showLevel, Rect(0, 0, 345, 290), startX, startY, zoom);
	
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		drawPlayer(3.f, playerPos.x, playerPos.y);
		drawDetectedEntities(showLevel, startX, startY, zoom);
	}
	
	TexturedVertex verts[4];
	for(int k = 0; k < 4; k++) {
		verts[k].color = 0xFFFFFFFF;
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float caseX = zoom / ((float)MINIMAP_MAX_X);
	float caseY = zoom / ((float)MINIMAP_MAX_Z);
	float ratio = 1.f;
	
	for(size_t i = 0; i < m_mapMarkers.size(); i++) {
		
		if(m_mapMarkers[i].m_lvl != showLevel + 1) {
			continue;
		}
		
		float pos_x = m_mapMarkers[i].m_x * 8 * ratio * m_activeBkg->Xmul * caseX + startX;
		float pos_y = m_mapMarkers[i].m_y * 8 * ratio * m_activeBkg->Zmul * caseY + startY;
		float size = 5.f * ratio;
		verts[0].color = 0xFFFF0000;
		verts[1].color = 0xFFFF0000;
		verts[2].color = 0xFFFF0000;
		verts[3].color = 0xFFFF0000;
		verts[0].p.x = (pos_x - size) * Xratio;
		verts[0].p.y = (pos_y - size) * Yratio;
		verts[1].p.x = (pos_x + size) * Xratio;
		verts[1].p.y = (pos_y - size) * Yratio;
		verts[2].p.x = (pos_x + size) * Xratio;
		verts[2].p.y = (pos_y + size) * Yratio;
		verts[3].p.x = (pos_x - size) * Xratio;
		verts[3].p.y = (pos_y + size) * Yratio;
		verts[0].uv = Vec2f::ZERO;
		verts[1].uv = Vec2f::X_AXIS;
		verts[2].uv = Vec2f::ONE;
		verts[3].uv = Vec2f::Y_AXIS;
		
		if(MouseInRect(verts[0].p.x, verts[0].p.y, verts[2].p.x, verts[2].p.y)) {
			if(!m_mapMarkers[i].m_text.empty()) {
				
				Rect bRect(140, 290, 140 + 205, 358);
				
				Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * Xratio);
				Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * Xratio);
				Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * Yratio);
				Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * Yratio);
				Rect rRect = Rect(left, top, right, bottom);
				
				long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect);
				
				DrawBookTextInRect(hFontInGameNote, float(bRect.left), float(bRect.top), float(bRect.right), m_mapMarkers[i].m_text.substr(0, lLengthDraw), Color::none);
			}
		}
		
		if(m_mapMarkerTexCont == NULL) {
			m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker");
		}
		
		GRenderer->SetTexture(0, m_mapMarkerTexCont);
		
		EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4);
	}
}
示例#3
0
//-----------------------------------------------------------------------------
void ARX_MINIMAP_Show(LPDIRECT3DDEVICE7 m_pd3dDevice, long SHOWLEVEL, long flag, long fl2)
{
	float sstartx, sstarty;

	if (!pTexDetect)
	{
		GetTextureFile("Graph\\particles\\flare.bmp");
		char temp[256];
		MakeDir(temp, "Graph\\particles\\flare.bmp");
		pTexDetect = D3DTextr_GetSurfaceContainer(temp);
	}

	//	SHOWLEVEL=8;
	// First Load Minimap TC & DATA if needed
	if (minimap[SHOWLEVEL].tc == NULL)
	{
		ARX_MINIMAP_GetData(SHOWLEVEL);
	}

	if ((minimap[SHOWLEVEL].tc) && (minimap[SHOWLEVEL].tc->m_pddsSurface))
	{
		float startx, starty, casex, casey, ratiooo;
		float mod_x = (float)MAX_BKGX / (float)MINIMAP_MAX_X;
		float mod_z = (float)MAX_BKGZ / (float)MINIMAP_MAX_Z;

		if (flag == 1)
		{


			startx = 0;
			starty = 0;
			casex = (900) / ((float)MINIMAP_MAX_X);
			casey = (900) / ((float)MINIMAP_MAX_Z);
			ratiooo = 900.f / 250.f;

			if (fl2)
			{
				casex = (600) / ((float)MINIMAP_MAX_X);
				casey = (600) / ((float)MINIMAP_MAX_Z);
				ratiooo = 600.f / 250.f;
			}

		}
		else
		{
			startx = (140); 
			starty = (120);
			casex = (250) / ((float)MINIMAP_MAX_X);
			casey = (250) / ((float)MINIMAP_MAX_Z);
			ratiooo = 1.f;
		}

		sstartx = startx;
		sstarty = starty;


		float ofx, ofx2, ofy, ofy2, px, py;
		px = py = 0.f;

		ofx		= mini_offset_x[CURRENTLEVEL];
		ofx2	= minimap[SHOWLEVEL].xratio;
		ofy		= mini_offset_y[CURRENTLEVEL];
		ofy2	= minimap[SHOWLEVEL].yratio;

		if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)) || (flag == 2))
		{
			// Computes playerpos
			ofx = mini_offset_x[CURRENTLEVEL];
			ofx2 = minimap[SHOWLEVEL].xratio;
			ofy = mini_offset_y[CURRENTLEVEL];
			ofy2 = minimap[SHOWLEVEL].yratio;
		
			px = startx + ((player.pos.x + ofx - ofx2) * DIV100 * casex
			               + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x ; //DIV100*2;
			py = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
			               - (player.pos.z + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z ;    //DIV100*2;

			if (flag == 1)
			{
				sstartx = startx;
				sstarty = starty;

				startx = 490.f - px;
				starty = 220.f - py;
				px += startx;
				py += starty;
			}
		}


		D3DTLVERTEX verts[4];
		SETTC(m_pd3dDevice, minimap[SHOWLEVEL].tc);

		for (long k = 0; k < 4; k++)
		{
			verts[k].color = 0xFFFFFFFF;
			verts[k].rhw = 1;
			verts[k].sz = 0.00001f;
		}

		float div = DIV25;
		TextureContainer * tc = minimap[SHOWLEVEL].tc;
		float dw = 1.f / (float)max(tc->m_dwDeviceWidth, tc->m_dwOriginalWidth); 
		float dh = 1.f / (float)max(tc->m_dwDeviceHeight, tc->m_dwOriginalHeight);
		
		float vx2 = 4.f * dw * mod_x;
		float vy2 = 4.f * dh * mod_z;

		float _px;
		RECT boundaries;
		float MOD20, MOD20DIV, divXratio, divYratio;

		boundaries.bottom = boundaries.left = boundaries.right = boundaries.top = 0;
		MOD20 = MOD20DIV = divXratio = divYratio = 0.f;

		if (flag != 2)
		{

			if (flag == 1)
			{
				MOD20 = 20.f * Xratio;
				MOD20DIV = 1.f / (MOD20);
				//@PERF do if(fl2){}else{} to make 4 and not 8 flot op if fl2.

				ARX_CHECK_LONG((360 + MOD20)*Xratio);
				ARX_CHECK_LONG((555 - MOD20)*Xratio);
				ARX_CHECK_LONG((85 + MOD20)*Yratio);
				ARX_CHECK_LONG((355 - MOD20)*Yratio);

				//CAST
				boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((360 + MOD20) * Xratio);
				boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((555 - MOD20) * Xratio);
				boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((85 + MOD20) * Yratio);
				boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((355 - MOD20) * Yratio);

				if (fl2)
				{
					//CHECK (DEBUG)
					ARX_CHECK_LONG((390 + MOD20)*Xratio);
					ARX_CHECK_LONG((590 - MOD20)*Xratio);
					ARX_CHECK_LONG((135 + MOD20)*Yratio);
					ARX_CHECK_LONG((295 - MOD20)*Yratio);

					//CAST
					boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((390 + MOD20) * Xratio);
					boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((590 - MOD20) * Xratio);
					boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((135 + MOD20) * Yratio);
					boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((295 - MOD20) * Yratio);
				}
			}

			SETALPHABLEND(m_pd3dDevice, TRUE);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ZERO);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS);
			SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_CLAMP);

			if (fl2)
			{
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			}
		}
		else
		{
			divXratio = 1.f / Xratio;
			divYratio = 1.f / Yratio;
		}

		for (long j = -2; j < MINIMAP_MAX_Z + 2; j++)
		{
			for (long i = -2; i < MINIMAP_MAX_X + 2; i++)
			{
				float vx, vy, vxx, vyy;
				vxx = ((float)i * (float)ACTIVEBKG->Xdiv * mod_x);
				vyy = ((float)j * (float)ACTIVEBKG->Zdiv * mod_z);
				vx = (vxx * div) * dw;
				vy = (vyy * div) * dh;

				long okay = 1;
				float posx = (startx + i * casex) * Xratio;
				float posy = (starty + j * casey) * Yratio;

				if (flag == 1)
				{

					if	((posx < 360 * Xratio)
					        ||	(posx > 555 * Xratio)
					        ||	(posy < 85 * Yratio)
					        ||	(posy > 355 * Yratio))
						okay = 0;

					if (fl2)
					{
						okay = 1;

						if	((posx < 390 * Xratio)
						        ||	(posx > 590 * Xratio)
						        ||	(posy < 135 * Yratio)
						        ||	(posy > 295 * Yratio))
							okay = 0;
					}

				}
				else
				{
					if ((posx > 345 * Xratio)
					        ||	(posy > 290 * Yratio))
						okay = 0;
				}

				if (okay)
				{
					if ((flag == 2)
					        && (i >= 0) && (i < MINIMAP_MAX_X)
					        && (j >= 0) && (j < MINIMAP_MAX_Z))
					{
						float d = Distance2D(posx * divXratio + casex * DIV2, posy * divYratio /*-casey * 2 * Yratio*/, px, py);

						if (d <= 6.f)
						{
							long r;
							float vv = (6 - d) * DIV6;

							if (vv >= 0.5f)
								vv = 1.f;
							else if (vv > 0.f)
								vv = vv * 2.f;
							else
								vv = 0.f;

							F2L((float)(vv * 255.f), &r);


							long ucLevel =  __max(r, minimap[SHOWLEVEL].revealed[i][j]);
							ARX_CHECK_UCHAR(ucLevel);

							minimap[SHOWLEVEL].revealed[i][j] = ARX_CLEAN_WARN_CAST_UCHAR(ucLevel);


						}
					}

					if (!FOR_EXTERNAL_PEOPLE)
					{
						if ((i >= 0) && (i < MINIMAP_MAX_X)
						        &&	(j >= 0) && (j < MINIMAP_MAX_Z))
						{
							minimap[SHOWLEVEL].revealed[i][j] = 255;
						}
					}

					verts[3].sx = verts[0].sx = (posx);
					verts[1].sy = verts[0].sy = (posy);
					verts[2].sx = verts[1].sx = posx + (casex * Xratio);
					verts[3].sy = verts[2].sy = posy + (casey * Yratio);

					verts[3].tu = verts[0].tu = vx;
					verts[1].tv = verts[0].tv = vy;
					verts[2].tu = verts[1].tu = vx + vx2;
					verts[3].tv = verts[2].tv = vy + vy2;

					if (flag != 2)
					{
						float v;
						float oo = 0.f;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 0;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[0].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[0].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 1;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[1].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[1].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 2;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}
						

						if (fl2) verts[2].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[2].color = D3DRGB(v, v, v);

						oo += v;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 3;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[3].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[3].color = D3DRGB(v, v, v);

						oo += v;

						if (oo > 0.f)
						{
							if (fl2)
							{
								verts[0].sx += DECALX * Xratio;
								verts[0].sy += DECALY * Yratio;
								verts[1].sx += DECALX * Xratio;
								verts[1].sy += DECALY * Yratio;
								verts[2].sx += DECALX * Xratio;
								verts[2].sy += DECALY * Yratio;
								verts[3].sx += DECALX * Xratio;
								verts[3].sy += DECALY * Yratio;
							}

							EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
						}
					}
				}
			}
		}

		if (flag != 2)
		{
			m_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESS , D3DTADDRESS_WRAP);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);

			SETALPHABLEND(m_pd3dDevice, FALSE);

			if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)))
			{
				// Now Draws Playerpos/angle
				verts[0].color = 0xFFFF0000;
				verts[1].color = 0xFFFF0000;
				verts[2].color = 0xFFFF0000;
				float val;

				if (flag == 1) val = 6.f;
				else val = 3.f;

				float rx = 0.f;
				float ry = -val * 1.8f;
				float rx2 = -val * DIV2;
				float ry2 = val;
				float rx3 = val * DIV2;
				float ry3 = val;

				float angle = DEG2RAD(player.angle.b);
				float ca = EEcos(angle);
				float sa = EEsin(angle);

				verts[0].sx = (px + rx2 * ca + ry2 * sa) * Xratio;
				verts[0].sy = (py + ry2 * ca - rx2 * sa) * Yratio;
				verts[1].sx = (px + rx * ca + ry * sa) * Xratio;
				verts[1].sy = (py + ry * ca - rx * sa) * Yratio;
				verts[2].sx = (px + rx3 * ca + ry3 * sa) * Xratio;
				verts[2].sy = (py + ry3 * ca - rx3 * sa) * Yratio;

				SETTC(GDevice, NULL);

				if (fl2)
				{
					SETALPHABLEND(m_pd3dDevice, TRUE);
					verts[0].sx += DECALX * Xratio;
					verts[0].sy += DECALY * Yratio;
					verts[1].sx += DECALX * Xratio;
					verts[1].sy += DECALY * Yratio;
					verts[2].sx += DECALX * Xratio;
					verts[2].sy += DECALY * Yratio;
				}

				EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 3, 0);

				if (fl2) SETALPHABLEND(m_pd3dDevice, FALSE);
			}
		}

		// tsu
		for (long lnpc = 1; lnpc < inter.nbmax; lnpc++)
		{
			if ((inter.iobj[lnpc] != NULL) && (inter.iobj[lnpc]->ioflags & IO_NPC))
			{
				if (inter.iobj[lnpc]->_npcdata->life > 0.f)
					if (!((inter.iobj[lnpc]->GameFlags & GFLAG_MEGAHIDE) ||
					        (inter.iobj[lnpc]->show == SHOW_FLAG_MEGAHIDE))
					        && (inter.iobj[lnpc]->show == SHOW_FLAG_IN_SCENE))
						if (!(inter.iobj[lnpc]->show == SHOW_FLAG_HIDDEN))
							if (inter.iobj[lnpc]->_npcdata->fDetect >= 0)
							{
								if (player.Full_Skill_Etheral_Link >= inter.iobj[lnpc]->_npcdata->fDetect)
								{
									float fpx;
									float fpy;
								
									fpx = sstartx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
									                 + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
									fpy = sstarty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
									                 - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 

									if (flag == 1)
									{

										fpx = startx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
										                + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
										fpy = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
										                - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 


									}

									float d = Distance2D(player.pos.x, player.pos.z, inter.iobj[lnpc]->pos.x, inter.iobj[lnpc]->pos.z);

		
									if ((d <= 800) && (fabs(inter.iobj[0]->pos.y - inter.iobj[lnpc]->pos.y) < 250.f))
									{
										float col = 1.f;

										if (d > 600.f)
										{
											col = 1.f - (d - 600.f) * DIV200;
										}

										if (!fl2)
										{
											SETALPHABLEND(m_pd3dDevice, true);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
										}
										else
											SETALPHABLEND(m_pd3dDevice, true);

										if (fl2)
										{
											fpx += DECALX * Xratio;
											fpy += (DECALY + 15) * Yratio;
										}

										fpx *= Xratio;
										fpy *= Yratio;
										EERIEDrawBitmap(GDevice, fpx, fpy,
										                5.f * ratiooo, 5.f * ratiooo, 0, pTexDetect, D3DRGB(col, 0, 0));

										if (!fl2)
											SETALPHABLEND(m_pd3dDevice, false);
									}
								}
							}
			}
		}

		if (flag == 0)
			for (long i = 0; i < Nb_Mapmarkers; i++)
			{
				if (Mapmarkers[i].lvl == SHOWLEVEL + 1)
				{
					float pos_x = Mapmarkers[i].x * 8 * ratiooo * ACTIVEBKG->Xmul * casex + startx;
					float pos_y = Mapmarkers[i].y * 8 * ratiooo * ACTIVEBKG->Zmul * casey + starty;
					float size = 5.f * ratiooo;
					verts[0].color = 0xFFFF0000;
					verts[1].color = 0xFFFF0000;
					verts[2].color = 0xFFFF0000;
					verts[3].color = 0xFFFF0000;
					verts[0].sx = (pos_x - size) * Xratio;
					verts[0].sy = (pos_y - size) * Yratio;
					verts[1].sx = (pos_x + size) * Xratio;
					verts[1].sy = (pos_y - size) * Yratio;
					verts[2].sx = (pos_x + size) * Xratio;
					verts[2].sy = (pos_y + size) * Yratio;
					verts[3].sx = (pos_x - size) * Xratio;
					verts[3].sy = (pos_y + size) * Yratio;
					verts[0].tu = 0.f;
					verts[0].tv = 0.f;
					verts[1].tu = 1.f;
					verts[1].tv = 0.f;
					verts[2].tu = 1.f;
					verts[2].tv = 1.f;
					verts[3].tu = 0.f;
					verts[3].tv = 1.f;

					if ((!fl2)
					        && (MouseInRect(verts[0].sx, verts[0].sy, verts[2].sx, verts[2].sy)))
					{
						if (!Mapmarkers[i].tstring)
						{
							_TCHAR output[4096];
							MakeLocalised(Mapmarkers[i].string, output, 4096, 0);
							Mapmarkers[i].tstring = (_TCHAR *)malloc((_tcslen(output) + 1) * sizeof(_TCHAR));
							ZeroMemory(Mapmarkers[i].tstring, (_tcslen(output) + 1)*sizeof(_TCHAR));
							_tcscpy(Mapmarkers[i].tstring, output);
						}

						if (Mapmarkers[i].tstring)
						{
							RECT rRect, bRect;
							SetRect(&bRect	, (140),	(290)
							        , (140 + 205),	(358));

							float fLeft		= (bRect.left) * Xratio ;
							float fRight	= (bRect.right) * Xratio ;
							float fTop		= (bRect.top) * Yratio ;
							float fBottom	= (bRect.bottom) * Yratio ;
							ARX_CHECK_INT(fLeft);
							ARX_CHECK_INT(fRight);
							ARX_CHECK_INT(fTop);
							ARX_CHECK_INT(fBottom);

							SetRect(&rRect
							        , ARX_CLEAN_WARN_CAST_INT(fLeft)
							        , ARX_CLEAN_WARN_CAST_INT(fTop)
							        , ARX_CLEAN_WARN_CAST_INT(fRight)
							        , ARX_CLEAN_WARN_CAST_INT(fBottom));


							long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(
							                       hFontInGameNote, Mapmarkers[i].tstring, 0, rRect);

							danaeApp.DANAEEndRender();
							_TCHAR	Page_Buffer[256];
							_tcsncpy(Page_Buffer, Mapmarkers[i].tstring, lLengthDraw);
							Page_Buffer[lLengthDraw] = _T('\0');

							DrawBookTextInRect(ARX_CLEAN_WARN_CAST_FLOAT(bRect.left), ARX_CLEAN_WARN_CAST_FLOAT(bRect.top),
							                   ARX_CLEAN_WARN_CAST_FLOAT(bRect.right), ARX_CLEAN_WARN_CAST_FLOAT(bRect.bottom),
							                   Page_Buffer, 0, 0x00FF00FF,
							                   hFontInGameNote);


							danaeApp.DANAEStartRender();
						}
					}

					if (MapMarkerTc == NULL)
					{
						MapMarkerTc = MakeTCFromFile("Graph\\interface\\icons\\mapmarker.bmp");
					}

					SETTC(GDevice, MapMarkerTc);

					if (fl2)
					{
						verts[0].sx += DECALX * Xratio;
						verts[0].sy += DECALY * Yratio;
						verts[1].sx += DECALX * Xratio;
						verts[1].sy += DECALY * Yratio;
						verts[2].sx += DECALX * Xratio;
						verts[2].sy += DECALY * Yratio;
						verts[3].sx += DECALX * Xratio;
						verts[3].sy += DECALY * Yratio;
					}

					EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
				}
			}

	}
}