Ejemplo n.º 1
0
void CheatDrawText() {
	
	if(sp_max_start == 0) {
		return;
	}
	
	PlatformDuration elapsed = g_platformTime.frameStart() - sp_max_start;
	
	if(elapsed < PlatformDurationMs(20000)) {
		
		float modi = (PlatformDurationMs(20000) - elapsed) / PlatformDurationMs(2000) * 0.1f;
		float sizX = 16;
		
		Vec2f p = Vec2f(g_size.center());
		p.x -= sp_max_ch.length() * 0.5f * sizX;
		
		for(size_t i = 0; i < sp_max_ch.length(); i++) {
			Vec2f d = p + Vec2f(sizX * i, sp_max_y[i]);
			
			sp_max_y[i] = std::sin(d.x + elapsed / PlatformDurationMs(100)) * 30.f * modi;
			std::string tex(1, sp_max_ch[i]);
			
			UNICODE_ARXDrawTextCenter(hFontInGame, d + Vec2f(-1, -1), tex, Color::none);
			UNICODE_ARXDrawTextCenter(hFontInGame, d + Vec2f(1, 1), tex, Color::none);
			UNICODE_ARXDrawTextCenter(hFontInGame, d, tex, sp_max_col[i]);
		}
		
	}
	
}
Ejemplo n.º 2
0
void CheatDrawText() {
	
	if(sp_max_start == PlatformInstant_ZERO)
		return;
	
	PlatformDuration elapsed = g_platformTime.frameStart() - sp_max_start;

	if(sp_max_start != PlatformInstant_ZERO && elapsed < PlatformDurationMs(20000)) {
		float modi = float(toMs(PlatformDurationMs(20000) - elapsed)) * ( 1.0f / 2000 ) * ( 1.0f / 10 );
		float sizX = 16;
		
		Vec2f p = Vec2f(g_size.center());
		p.x -= sp_max_ch.length() * ( 1.0f / 2 ) * sizX;
		
		for(size_t i = 0; i < sp_max_ch.length(); i++) {
			Vec2f d = p + Vec2f(sizX * i, sp_max_y[i]);
			
			sp_max_y[i] = std::sin(d.x + arxtime.now_f() * ( 1.0f / 100 )) * 30.f * modi;
			std::string tex(1, sp_max_ch[i]);

			UNICODE_ARXDrawTextCenter(hFontInBook, d + Vec2f(-1,-1), tex, Color::none);
			UNICODE_ARXDrawTextCenter(hFontInBook, d + Vec2f( 1, 1), tex, Color::none);
			UNICODE_ARXDrawTextCenter(hFontInBook, d, tex, sp_max_col[i]);
		}
	}
}
Ejemplo n.º 3
0
	Result execute(Context & context) {
		
		std::string inout = context.getWord();
		const PlatformDuration duration = PlatformDurationMs(context.getFloat());
		
		if(inout == "out") {
			
			Color3f color;
			color.r = context.getFloat();
			color.g = context.getFloat();
			color.b = context.getFloat();
			fadeSetColor(color);
			
			fadeRequestStart(FadeType_Out, duration);
			
			DebugScript(" out " << toMs(duration) << ' ' << color.r << ' ' << color.g << ' ' << color.b);
		} else if(inout == "in") {
			
			fadeRequestStart(FadeType_In, duration);
			
			DebugScript(" in " << toMs(duration));
		} else {
			ScriptWarning << "unexpected fade direction: " << inout;
			return Failed;
		}
		
		return Success;
	}
Ejemplo n.º 4
0
void MenuCursor::DrawCursor() {
	
	trail.draw();
	
	DrawOneCursor(GInput->getMousePosAbs());

	lFrameDiff += g_platformTime.lastFrameDuration();

	if(lFrameDiff > PlatformDurationMs(70)) {
		if(bMouseOver) {
			if(m_currentFrame < 4) {
				m_currentFrame++;
			} else {
				if(m_currentFrame > 4) {
					m_currentFrame--;
				}
			}
			bMouseOver=false;
		} else {
			if(m_currentFrame > 0) {
				m_currentFrame++;

				if(m_currentFrame > 7)
					m_currentFrame=0;
			}
		}

		lFrameDiff = PlatformDuration_ZERO;
	}

	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 5
0
void MenuCursor::DrawCursor() {
	
	trail.draw();
	
	DrawOneCursor(GInput->getMousePosition());
	
	lFrameDiff += g_platformTime.lastFrameDuration();
	
	if(lFrameDiff > PlatformDurationMs(70)) {
		if(bMouseOver) {
			if(m_currentFrame < 4) {
				m_currentFrame++;
			} else {
				if(m_currentFrame > 4) {
					m_currentFrame--;
				}
			}
			bMouseOver = false;
		} else {
			if(m_currentFrame > 0) {
				m_currentFrame++;
				if(m_currentFrame > 7) {
					m_currentFrame = 0;
				}
			}
		}
		lFrameDiff = 0;
	}
	
}
Ejemplo n.º 6
0
void CinematicBorder::update() {
	
	if(m_direction == 1) {
		CINEMA_DECAL += g_platformTime.lastFrameDuration() / PlatformDurationMs(10);

		if(CINEMA_DECAL > 100.f) {
			CINEMA_DECAL = 100.f;
			m_direction = 0;
		}
	} else if(m_direction == -1) {
		CINEMA_DECAL -= g_platformTime.lastFrameDuration() / PlatformDurationMs(10);

		if(CINEMA_DECAL < 0.f) {
			CINEMA_DECAL = 0.f;
			m_direction = 0;
		}
	}
}
Ejemplo n.º 7
0
void PurseIconGui::update(const Rectf & parent) {
	m_rect = createChild(parent, Anchor_TopRight, m_size * m_scale, Anchor_BottomRight);
	
	if(m_haloActive) {
		m_haloTime += g_platformTime.lastFrameDuration();
		if(m_haloTime >= PlatformDurationMs(1000)) {
			m_haloActive = false;
		}
	}
}
Ejemplo n.º 8
0
static void characterCreationAddDescription(const std::string & text) {
	
	const int t = 0;
	
	// TODO copy-paste
	UNICODE_ARXDrawTextCenteredScroll(hFontInGame,
		float(g_size.width()) * 0.5f,
		4,
		float(g_size.center().x) * 0.82f,
		text,
		Color(232 + t, 204 + t, 143 + t),
		PlatformDurationMs(1000),
		0.01f,
		3,
		0);
}
Ejemplo n.º 9
0
void HitStrengthGauge::update() {
	
	if(!player.isAiming()) {
		m_intensity = 0.2f;
	} else {
		float j;
		if(player.m_bowAimRatio > 0) {
			j = player.m_bowAimRatio;
		} else {
			j = player.m_aimTime / player.Full_AimTime;
		}
		m_intensity = glm::clamp(j, 0.2f, 1.f);
	}
	
	if(m_flashActive) {
		m_flashTime += g_platformTime.lastFrameDuration();
		if(m_flashTime >= PlatformDurationMs(500)) {
			m_flashActive = false;
			m_flashTime = 0;
		}
	}
}
Ejemplo n.º 10
0
	CursorAnimatedHand()
		: m_time(PlatformDuration_ZERO)
		, m_frame(0)
		, m_delay(PlatformDurationMs(70))
	{}
Ejemplo n.º 11
0
void Input::update(float time) {

	backend->update();

	bool keyJustPressed = false;
	iKeyId = -1;
	int modifier = 0;

	for(int i = 0; i < Keyboard::KeyCount; i++) {
		if(isKeyPressed(i)) {
			switch(i) {
			case Keyboard::Key_LeftShift:
			case Keyboard::Key_RightShift:
			case Keyboard::Key_LeftCtrl:
			case Keyboard::Key_RightCtrl:
			case Keyboard::Key_LeftAlt:
			case Keyboard::Key_RightAlt:
				modifier = i;
				break;
			}

			if(keysStates[i] < 2) {
				keysStates[i]++;
			}

			if(!keyJustPressed) {
				if(keysStates[i] == 1) {
					iKeyId = i;
					keyJustPressed = true;
				} else {
					iKeyId = i;
				}
			}
		} else {
			if(keysStates[i] > 0) {
				keysStates[i]--;
			}
		}
	}

	if(modifier != 0 && iKeyId != modifier) {
		iKeyId |= (modifier << 16);
	}

	if(iKeyId >= 0) {   //keys priority
		switch(iKeyId) {
			case Keyboard::Key_LeftShift:
			case Keyboard::Key_RightShift:
			case Keyboard::Key_LeftCtrl:
			case Keyboard::Key_RightCtrl:
			case Keyboard::Key_LeftAlt:
			case Keyboard::Key_RightAlt: {
				
				bool bFound = false;
				
				for(int i = 0; i < Keyboard::KeyCount; i++) {
					
					if(bFound) {
						break;
					}
					
					switch(i & 0xFFFF) {
						case Keyboard::Key_LeftShift:
						case Keyboard::Key_RightShift:
						case Keyboard::Key_LeftCtrl:
						case Keyboard::Key_RightCtrl:
						case Keyboard::Key_LeftAlt:
						case Keyboard::Key_RightAlt:
							continue;
						default: {
							if(keysStates[i]) {
								bFound = true;
								iKeyId &= ~0xFFFF;
								iKeyId |= i;
							}
							break;
						}
					}
					
				}
				
			}
		}
	}
	
	const PlatformInstant now = g_platformTime.frameStart();
	
	for(int buttonId = Mouse::ButtonBase; buttonId < Mouse::ButtonMax; buttonId++) {
		int i = buttonId - Mouse::ButtonBase;
		
		int iNumClick;
		int iNumUnClick;
		backend->getMouseButtonClickCount(buttonId, iNumClick, iNumUnClick);
		
		iOldNumClick[i] += iNumClick + iNumUnClick;
		
		if(!bMouseButton[i] && iOldNumClick[i] == iNumUnClick) {
			iOldNumClick[i] = 0;
		}
		
		bOldMouseButton[i] = bMouseButton[i];
		
		if(bMouseButton[i]) {
			if(iOldNumClick[i]) {
				bMouseButton[i] = false;
			}
		} else {
			if(iOldNumClick[i]) {
				bMouseButton[i] = true;
			}
		}
		
		if(iOldNumClick[i]) {
			iOldNumClick[i]--;
		}
		
		if(iMouseTimeSet[i] > 1 || (iMouseTimeSet[i] == 1 && now - iMouseTime[i][0] > PlatformDurationMs(300))) {
			iMouseTime[i][0] = 0;
			iMouseTime[i][1] = 0;
			iMouseTimeSet[i] = 0;
		}
		
		if(getMouseButtonNowPressed(buttonId)) {
			switch(iMouseTimeSet[i]) {
			case 0:
				iMouseTime[i][0] = now;
				iMouseTimeSet[i]++;
				break;
			case 1:
				iMouseTime[i][1] = now;
				iMouseTimeSet[i]++;
				break;
			}
		}
	}
	
	// Get the new coordinates
	int absX, absY;
	mouseInWindow = backend->getAbsoluteMouseCoords(absX, absY);
	Vec2s newMousePosition(absX, absY);
	
	Vec2i wndSize = mainApp->getWindow()->getSize();
	if(absX >= 0 && absX < wndSize.x && absY >= 0 && absY < wndSize.y) {
		
		// Use the absolute mouse position reported by the backend, as is
		if(m_mouseMode == Mouse::Absolute) {
			iMouseA = newMousePosition;
		} else {
			iMouseA = wndSize / s32(2);
		}
		
	} else {
		mouseInWindow = false;
	}
	
	int relX, relY;
	backend->getRelativeMouseCoords(relX, relY, iWheelDir);
	
	if(m_mouseMode == Mouse::Relative) {
		
		if(m_useRawMouseInput) {
			m_mouseMovement = Vec2f(relX * 2, relY * 2);
		} else {
			m_mouseMovement = Vec2f(newMousePosition - m_lastMousePosition);
			if(newMousePosition != m_lastMousePosition) {
				centerMouse();
			} else {
				m_lastMousePosition = newMousePosition;
			}
		}
		
		// Use the sensitivity config value to adjust relative mouse mouvements
		m_mouseMovement *= m_mouseSensitivity;
		
		if(m_mouseAcceleration > 0 && time > 0.0f) {
			Vec2f speed = m_mouseMovement / (time * 0.14f);
			Vec2f sign(speed.x < 0 ? -1.f : 1.f, speed.y < 0 ? -1.f : 1.f);
			float exponent = 1.f + m_mouseAcceleration * 0.05f;
			speed.x = (std::pow(speed.x * sign.x + 1.f, exponent) - 1.f) * sign.x;
			speed.y = (std::pow(speed.y * sign.y + 1.f, exponent) - 1.f) * sign.y;
			m_mouseMovement = speed * (time * 0.14f);
		}
		
		if(m_invertMouseY) {
			m_mouseMovement.y *= -1.f;
		}
		
		if(!mouseInWindow) {
			LogWarning << "Cursor escaped the window while in relative input mode";
			centerMouse();
		}
		
	} else {
		m_mouseMovement = Vec2f_ZERO;
		if(!m_useRawMouseInput) {
			m_lastMousePosition = newMousePosition;
		}
	}
	
	
}
Ejemplo n.º 12
0
void ARX_MAGICAL_FLARES_Update() {

	if(!g_magicFlaresCount)
		return;

	shinum++;
	if(shinum >= 10) {
		shinum = 1;
	}
	
	PlatformDuration diff = g_platformTime.lastFrameDuration();
	
	bool key = !GInput->actionPressed(CONTROLS_CUST_MAGICMODE);

	RenderMaterial mat;
	mat.setBlendType(RenderMaterial::Additive);
	
	EERIE_LIGHT * light = lightHandleGet(torchLightHandle);
	
	for(long j = 1; j < 5; j++) {

		TextureContainer * surf;
		switch(j) {
			case 2:  surf = g_magicFlareTextures.lumignon; break;
			case 3:  surf = g_magicFlareTextures.lumignon2; break;
			case 4:  surf = g_magicFlareTextures.plasm; break;
			default: surf = g_magicFlareTextures.shine[shinum]; break;
		}

		mat.setTexture(surf);

		for(size_t i = 0; i < g_magicFlaresMax; i++) {

			MagicFlare & flare = g_magicFlares[i];

			if(!flare.exist || flare.type != j) {
				continue;
			}
			
			flare.tolive -= diff * 2;
			if(flare.flags & 1) {
				flare.tolive -= diff * 4;
			} else if(key) {
				flare.tolive -= diff * 6;
			}
			
			float z = flare.tolive / PlatformDurationMs(4000);
			float size;
			if(flare.type == 1) {
				size = flare.size * 2 * z;
			} else if(flare.type == 4) {
				size = flare.size * 2.f * z * (4.0f / 3.0f);
			} else {
				size = flare.size;
			}

			if(flare.tolive <= 0 || flare.pos.y < -64.f || size < 3.f) {
				removeFlare(flare);
				continue;
			}

			if(flare.type == 1 && z < 0.6f)  {
				z = 0.6f;
			}

			Color3f color = flare.rgb * z;

			light->rgb = componentwise_max(light->rgb, color);
			
			EERIE_LIGHT * el = lightHandleGet(flare.dynlight);
			if(el) {
				el->pos = flare.p;
				el->rgb = color;
			}

			mat.setDepthTest(flare.io != NULL);
			
			if(flare.bDrawBitmap) {
				Vec3f pos = Vec3f(flare.p.x - size / 2.0f, flare.p.y - size / 2.0f, flare.p.z);
				EERIEAddBitmap(mat, pos, size, size, surf, Color(color));
			} else {
				EERIEAddSprite(mat, flare.p, size * 0.025f + 1.f, Color(color), 2.f);
			}

		}
	}

	light->rgb = componentwise_min(light->rgb, Color3f::white);
}
Ejemplo n.º 13
0
void BackpackIconGui::updateInput() {
	
	static PlatformInstant flDelay = 0;
	
	// Check for backpack Icon
	if(m_rect.contains(Vec2f(DANAEMouse))) {
		if(eeMouseUp1() && playerInventory.insert(DRAGINTER)) {
			ARX_SOUND_PlayInterface(SND_INVSTD);
			Set_DragInter(NULL);
		}
	}
	
	if(m_rect.contains(Vec2f(DANAEMouse)) || flDelay != 0) {
		eMouseState = MOUSE_IN_INVENTORY_ICON;
		cursorSetInteraction();
		
		
		if(eeMouseDoubleClick1()) {
			ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
			
			playerInventory.optimize();
			
			flDelay = 0;
		} else if(eeMouseDown1() || flDelay != 0) {
			if(flDelay == 0) {
				flDelay = g_platformTime.frameStart();
				return;
			} else {
				if(g_platformTime.frameStart() - flDelay < PlatformDurationMs(300)) {
					return;
				} else {
					flDelay = 0;
				}
			}
			
			if(player.Interface & INTER_INVENTORYALL) {
				ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				g_playerInventoryHud.close();
			} else {
				bInverseInventory = !bInverseInventory;
				lOldTruePlayerMouseLook = TRUE_PLAYER_MOUSELOOK_ON;
			}
		} else if(eeMouseDown2()) {
			g_playerBook.close();
			ARX_INVENTORY_OpenClose(NULL);
			
			if(player.Interface & INTER_INVENTORYALL) {
				g_playerInventoryHud.close();
			} else {
				if(player.Interface & INTER_INVENTORY) {
					ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
					g_playerInventoryHud.close();
					bInventorySwitch = true;
				} else {
					ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
					player.Interface |= INTER_INVENTORYALL;
					
					g_playerInventoryHud.resetPos();
					
					ARX_INTERFACE_NoteClose();
					
					if(TRUE_PLAYER_MOUSELOOK_ON) {
						WILLRETURNTOFREELOOK = true;
					}
				}
			}
			
			TRUE_PLAYER_MOUSELOOK_ON = false;
		}
		
		if(DRAGINTER == NULL)
			return;
	}
}