void SecondaryInventoryCloseHudIcon::updateInput() { m_isSelected = m_rect.contains(Vec2f(DANAEMouse)); if(m_isSelected) { SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1()) { Entity * io = NULL; if(SecondaryInventory) io = SecondaryInventory->io; else if(player.Interface & INTER_STEAL) io = ioSteal; if(io) { ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f)); g_secondaryInventoryHud.m_fadeDirection = SecondaryInventoryHud::Fade_left; SendIOScriptEvent(io,SM_INVENTORY2_CLOSE); TSecondaryInventory=SecondaryInventory; SecondaryInventory=NULL; } } if(DRAGINTER == NULL) return; } }
void StealIconGui::updateInput() { // steal if(player.Interface & INTER_STEAL) { if(m_rect.contains(Vec2f(DANAEMouse))) { eMouseState = MOUSE_IN_STEAL_ICON; cursorSetInteraction(); if(eeMouseDown1()) { ARX_INVENTORY_OpenClose(ioSteal); if(player.Interface & (INTER_INVENTORY | INTER_INVENTORYALL)) { ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f)); } if(SecondaryInventory) { SendIOScriptEvent(entities.player(), ioSteal, SM_STEAL); bForceEscapeFreeLook = true; lOldTruePlayerMouseLook = !TRUE_PLAYER_MOUSELOOK_ON; } } if(DRAGINTER == NULL) { return; } } } }
void ManaGauge::updateInput(const Vec2f & mousePos) { if(!(player.Interface & INTER_COMBATMODE)) { if(m_rect.contains(mousePos)) { if(eeMouseDown1()) { std::stringstream ss; ss << checked_range_cast<int>(player.manaPool.current); ARX_SPEECH_Add(ss.str()); } } } }
void BookIconGui::updateInput() { m_isSelected = m_rect.contains(Vec2f(DANAEMouse)); if(m_isSelected) { cursorSetInteraction(); if(eeMouseDown1()) { g_playerBook.toggle(); } return; } }
void LevelUpIconGui::updateInput() { if(!m_visible) return; m_isSelected = m_rect.contains(Vec2f(DANAEMouse)); if(m_isSelected) { cursorSetInteraction(); if(eeMouseDown1()) { g_playerBook.open(); } } }
void SecondaryInventoryPickAllHudIcon::updateInput() { m_isSelected = m_rect.contains(Vec2f(DANAEMouse)); if(m_isSelected) { SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1()) { // play un son que si un item est pris ARX_INVENTORY_TakeAllFromSecondaryInventory(); } if(DRAGINTER == NULL) return; } }
void PlayerInventoryHud::draw() { if(player.Interface & INTER_INVENTORY) { if(player.bag) { ARX_INTERFACE_DrawInventory(g_currentInventoryBag, Vec2i_ZERO); CalculateInventoryCoordinates(); if(g_currentInventoryBag > 0) { Rectf rect = Rectf(m_arrowsAnchor, 32.f * m_scale, 32.f * m_scale); EERIEDrawBitmap(rect, 0.001f, m_heroInventoryUp, Color::white); if(rect.contains(Vec2f(DANAEMouse))) { GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne); GRenderer->SetRenderState(Renderer::AlphaBlending, true); SpecialCursor=CURSOR_INTERACTION_ON; EERIEDrawBitmap(rect, 0.001f, m_heroInventoryUp, Color::white); GRenderer->SetRenderState(Renderer::AlphaBlending, false); SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1() || (eeMouseUp1() && DRAGINTER)) { previousBag(); } } } if(g_currentInventoryBag < player.bag-1) { Rectf rect = Rectf(m_arrowsAnchor + Vec2f(0.f, 32.f + 5.f) * m_scale, 32.f * m_scale, 32.f * m_scale); EERIEDrawBitmap(rect, 0.001f, m_heroInventoryDown, Color::white); if(rect.contains(Vec2f(DANAEMouse))) { GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne); GRenderer->SetRenderState(Renderer::AlphaBlending, true); EERIEDrawBitmap(rect, 0.001f, m_heroInventoryDown, Color::white); GRenderer->SetRenderState(Renderer::AlphaBlending, false); SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1() || (eeMouseUp1() && DRAGINTER)) { nextBag(); } } } } } else if((player.Interface & INTER_INVENTORYALL) || bInventoryClosing) { Vec2f anchorPos = anchorPosition(); //TODO see about these coords, might be calculated once only const float fBag = (player.bag-1) * (-121 * m_scale); const float fOffsetY = (121 * m_scale); int iOffsetY = checked_range_cast<int>(fBag + fOffsetY); int posx = checked_range_cast<int>(anchorPos.x); int posy = checked_range_cast<int>(anchorPos.y + ((-3.f + 25 - 32) * m_scale)); for(int i = 0; i < player.bag; i++) { Vec2f pos1 = Vec2f(posx + (45 * m_scale), static_cast<float>(posy + iOffsetY)); Vec2f pos2 = Vec2f(posx + (m_bagBackgroundSize.x * m_scale)*0.5f + (-16 * m_scale), posy+iOffsetY + (-5 * m_scale)); Vec2f pos3 = Vec2f(posx + (m_bagBackgroundSize.x * m_scale) + ((-45-32) * m_scale), posy+iOffsetY + (-15 * m_scale)); TextureContainer * tex = m_heroInventoryLink; EERIEDrawBitmap(Rectf(pos1, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white); EERIEDrawBitmap(Rectf(pos2, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white); EERIEDrawBitmap(Rectf(pos3, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white); iOffsetY += checked_range_cast<int>(fOffsetY); } iOffsetY = checked_range_cast<int>(fBag); for(short i = 0; i < player.bag; i++) { ARX_INTERFACE_DrawInventory(i, Vec2i(0, iOffsetY)); iOffsetY += checked_range_cast<int>(fOffsetY); } } }
void ARX_INTERFACE_ManageOpenedBook_Finish() { Vec3f pos = Vec3f(0.f, 0.f, 2100.f); Anglef angle = Anglef::ZERO; EERIE_LIGHT * light = lightHandleGet(torchLightHandle); EERIE_LIGHT tl = *light; light->pos = Vec3f(500.f, -1960.f, 1590.f); light->exist = 1; light->rgb = Color3f(0.6f, 0.7f, 0.9f); light->intensity = 1.8f; light->fallstart=4520.f; light->fallend = light->fallstart + 600.f; RecalcLight(light); EERIE_CAMERA * oldcam = ACTIVECAM; PDL[0] = light; TOTPDL=1; Vec2i tmpPos = Vec2i_ZERO; for(size_t i = 0; i < RUNE_COUNT; i++) { if(!gui::necklace.runes[i]) continue; EERIE_3DOBJ * rune = gui::necklace.runes[i]; bookcam.center.x = (382 + tmpPos.x * 45 + BOOKDEC.x) * g_sizeRatio.x; bookcam.center.y = (100 + tmpPos.y * 64 + BOOKDEC.y) * g_sizeRatio.y; SetActiveCamera(&bookcam); PrepareCamera(&bookcam, g_size); // First draw the lace angle.setPitch(0.f); if(player.hasRune((Rune)i)) { TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(gui::necklace.lacet, t1, NULL); if(rune->angle.getPitch() != 0.f) { if(rune->angle.getPitch() > 300.f) rune->angle.setPitch(300.f); angle.setPitch(std::sin(arxtime.get_updated() * (1.0f / 200)) * rune->angle.getPitch() * (1.0f / 40)); } rune->angle.setPitch(rune->angle.getPitch() - framedelay * 0.2f); if(rune->angle.getPitch() < 0.f) rune->angle.setPitch(0.f); GRenderer->SetRenderState(Renderer::DepthWrite, true); GRenderer->SetRenderState(Renderer::AlphaBlending, false); // Now draw the rune TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(rune, t2, NULL); EERIE_2D_BBOX runeBox; UpdateBbox2d(*rune, runeBox); PopAllTriangleList(); tmpPos.x++; if(tmpPos.x > 4) { tmpPos.x = 0; tmpPos.y++; } const Rect runeMouseTestRect( runeBox.min.x, runeBox.min.y, runeBox.max.x, runeBox.max.y ); // Checks for Mouse floating over a rune... if(runeMouseTestRect.contains(Vec2i(DANAEMouse))) { long r=0; for(size_t j = 0; j < rune->facelist.size(); j++) { float n = PtIn2DPolyProj(rune, &rune->facelist[j], (float)DANAEMouse.x, (float)DANAEMouse.y); if(n!=0.f) { r=1; break; } } if(r) { GRenderer->SetRenderState(Renderer::AlphaBlending, true); GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne); TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(rune, t, NULL); rune->angle.setPitch(rune->angle.getPitch() + framedelay*2.f); PopAllTriangleList(); GRenderer->SetRenderState(Renderer::AlphaBlending, false); SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1()) if((size_t)LastRune != i) { PlayerBookDrawRune((Rune)i); } LastRune=i; } } } } GRenderer->SetCulling(Renderer::CullCCW); LastRune=-1; *light = tl; SetActiveCamera(oldcam); PrepareCamera(oldcam, g_size); }
void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos, Rectf rect, float scale) { RenderState baseState = render3D().depthTest(false).fog(false); Vec3f pos = Vec3f(0.f, 0.f, 2100.f); EERIE_LIGHT * light = lightHandleGet(torchLightHandle); EERIE_LIGHT tl = *light; light->pos = Vec3f(500.f, -1960.f, 1590.f); light->m_exists = true; light->rgb = Color3f(0.6f, 0.7f, 0.9f); light->intensity = 1.8f; light->fallstart = 4520.f; light->fallend = light->fallstart + 600.f; RecalcLight(light); Camera * oldcam = g_camera; g_culledDynamicLights[0] = light; g_culledDynamicLightsCount = 1; Vec2i tmpPos(0); GRenderer->SetAntialiasing(true); float wave = timeWaveSin(g_platformTime.frameStart(), PlatformDurationMsf(1256.6370614f)); float ptDelta = toMs(g_platformTime.lastFrameDuration()); Camera bookcam; bookcam.angle = Anglef(); bookcam.m_pos = Vec3f(0.f); bookcam.focal = 500.f; bookcam.cdepth = 2200.f; for(size_t i = 0; i < RUNE_COUNT; i++) { if(!gui::necklace.runes[i]) continue; EERIE_3DOBJ * rune = gui::necklace.runes[i]; Vec2i projectionCenter = Vec2i(rect.topLeft() + (Vec2f(285, 36) + Vec2f(tmpPos) * Vec2f(45, 64)) * scale); PrepareCamera(&bookcam, Rect(rect), projectionCenter); if(player.hasRune((Rune)i)) { Anglef angle; if(rune->angle.getYaw() != 0.f) { if(rune->angle.getYaw() > 300.f) { rune->angle.setYaw(300.f); } angle.setYaw(wave * rune->angle.getYaw() * (1.0f / 40)); } rune->angle.setYaw(rune->angle.getYaw() - ptDelta * 0.2f); if(rune->angle.getYaw() < 0.f) rune->angle.setYaw(0.f); // Now draw the rune TransformInfo t2(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t2, NULL, false, 0.f); Rectf runeBox = UpdateBbox2d(*rune).toRect(); PopAllTriangleListOpaque(baseState); tmpPos.x++; if(tmpPos.x > 4) { tmpPos.x = 0; tmpPos.y++; } // TODO this is a workaround for vertexClipPositions being relative to viewport Vec2f mousePosInViewport = mousePos - rect.topLeft(); // Checks for Mouse floating over a rune... if(runeBox.contains(mousePosInViewport)) { bool r = false; for(size_t j = 0; j < rune->facelist.size(); j++) { float n = PtIn2DPolyProj(rune->vertexClipPositions, &rune->facelist[j], mousePosInViewport.x, mousePosInViewport.y); if(n != 0.f) { r = true; break; } } if(r) { TransformInfo t(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t, NULL, false, 0.f); rune->angle.setYaw(rune->angle.getYaw() + ptDelta * 2.f); PopAllTriangleListOpaque(baseState.blendAdditive()); cursorSetInteraction(); if(eeMouseDown1()) { PlayerBookDrawRune((Rune)i); } } } TransformInfo t1(pos, quat_identity()); DrawEERIEInter(gui::necklace.lacet, t1, NULL, false, 0.f); PopAllTriangleListOpaque(baseState); } } *light = tl; PrepareCamera(oldcam, g_size); GRenderer->SetAntialiasing(false); }
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; } }