diff --git a/src/Layers/xrRender/FSkinned.cpp b/src/Layers/xrRender/FSkinned.cpp index 554dc294556..42c6828fb95 100644 --- a/src/Layers/xrRender/FSkinned.cpp +++ b/src/Layers/xrRender/FSkinned.cpp @@ -1142,111 +1142,239 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w #else // USE_DX10 - void CSkeletonX_ext::_FillVerticesHW1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, - float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) +void CSkeletonX_ext::_FillVerticesHW1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, + float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) +{ + vertHW_1W* vertices; + CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); + for (auto it = faces.begin(); it != faces.end(); ++it) { - vertHW_1W* vertices; - CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); - for (auto it = faces.begin(); it != faces.end(); it++) + Fvector p[3]; + u32 idx = *it * 3; + CSkeletonWallmark::WMFace F; + + for (u32 k = 0; k < 3; k++) + { + vertHW_1W& vert = vertices[indices[idx + k]]; + F.bone_id[k][0] = vert.get_bone(); + F.bone_id[k][1] = F.bone_id[k][0]; + F.bone_id[k][2] = F.bone_id[k][0]; + F.bone_id[k][3] = F.bone_id[k][0]; + F.weight[k][0] = 0.f; + F.weight[k][1] = 0.f; + F.weight[k][2] = 0.f; + + const Fmatrix& xform = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; + vert.get_pos(F.vert[k]); + xform.transform_tiny(p[k], F.vert[k]); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) + continue; + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) { - Fvector p[3]; - u32 idx = (*it) * 3; - CSkeletonWallmark::WMFace F; + Fvector UV; for (u32 k = 0; k < 3; k++) { - vertHW_1W& vert = vertices[indices[idx + k]]; - F.bone_id[k][0] = vert.get_bone(); - F.bone_id[k][1] = F.bone_id[k][0]; - F.weight[k] = 0.f; - const Fmatrix& xform = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; - vert.get_pos(F.vert[k]); - xform.transform_tiny(p[k], F.vert[k]); - } - Fvector test_normal; - test_normal.mknormal(p[0], p[1], p[2]); - float cosa = test_normal.dotproduct(normal); - if (cosa < EPS) - continue; - if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) - { - Fvector UV; - for (u32 k = 0; k < 3; k++) - { - Fvector2& uv = F.uv[k]; - view.transform_tiny(UV, p[k]); - uv.x = (1 + UV.x) * .5f; - uv.y = (1 - UV.y) * .5f; - } - wm.m_Faces.push_back(F); + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; } + wm.m_Faces.push_back(F); } - CHK_DX(V->p_rm_Vertices->Unlock()); } - void CSkeletonX_ext::_FillVerticesHW2W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, - float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) + CHK_DX(V->p_rm_Vertices->Unlock()); +} + +void CSkeletonX_ext::_FillVerticesHW2W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, + float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) +{ + vertHW_2W* vertices; + CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); + + for (auto it = faces.begin(); it != faces.end(); ++it) { - vertHW_2W* vertices; - CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); + Fvector p[3]; + u32 idx = *it * 3; + CSkeletonWallmark::WMFace F; - for (auto it = faces.begin(); it != faces.end(); ++it) + for (u32 k = 0; k < 3; k++) { - Fvector p[3]; - u32 idx = (*it) * 3; - CSkeletonWallmark::WMFace F; + Fvector P0, P1; + vertHW_2W& vert = vertices[indices[idx + k]]; + F.bone_id[k][0] = vert.get_bone(0); + F.bone_id[k][1] = vert.get_bone(1); + F.bone_id[k][2] = F.bone_id[k][1]; + F.bone_id[k][3] = F.bone_id[k][1]; + F.weight[k][0] = vert.get_weight(); + F.weight[k][1] = 0.f; + F.weight[k][2] = 0.f; + + Fmatrix& xform0 = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; + Fmatrix& xform1 = Parent->LL_GetBoneInstance(F.bone_id[k][1]).mRenderTransform; + vert.get_pos(F.vert[k]); + xform0.transform_tiny(P0, F.vert[k]); + xform1.transform_tiny(P1, F.vert[k]); + p[k].lerp(P0, P1, F.weight[k][0]); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) continue; + + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + { + Fvector UV; for (u32 k = 0; k < 3; k++) { - Fvector P0, P1; - vertHW_2W& vert = vertices[indices[idx + k]]; - F.bone_id[k][0] = vert.get_bone(0); - F.bone_id[k][1] = vert.get_bone(1); - F.weight[k] = vert.get_weight(); - Fmatrix& xform0 = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; - Fmatrix& xform1 = Parent->LL_GetBoneInstance(F.bone_id[k][1]).mRenderTransform; - vert.get_pos(F.vert[k]); - xform0.transform_tiny(P0, F.vert[k]); - xform1.transform_tiny(P1, F.vert[k]); - p[k].lerp(P0, P1, F.weight[k]); + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; } - Fvector test_normal; - test_normal.mknormal(p[0], p[1], p[2]); - float cosa = test_normal.dotproduct(normal); - if (cosa < EPS) - continue; + wm.m_Faces.push_back(F); + } + } + CHK_DX(V->p_rm_Vertices->Unlock()); +} + +void CSkeletonX_ext::_FillVerticesHW3W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, + float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) +{ + vertHW_3W* vertices; + CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); + + for (auto it = faces.begin(); it != faces.end(); ++it) + { + Fvector p[3]; + u32 idx = (*it) * 3; + CSkeletonWallmark::WMFace F; - if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + for (u32 k = 0; k < 3; k++) + { + vertHW_3W& vert = vertices[indices[idx + k]]; + F.bone_id[k][0] = vert.get_bone(0); + F.bone_id[k][1] = vert.get_bone(1); + F.bone_id[k][2] = vert.get_bone(2); + F.bone_id[k][3] = F.bone_id[k][2]; + F.weight[k][0] = vert.get_weight0(); + F.weight[k][1] = vert.get_weight1(); + F.weight[k][2] = 0.f; + vert.get_pos(F.vert[k]); + vert.get_pos_bones(p[k], Parent); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) + continue; + + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + { + Fvector UV; + for (u32 k = 0; k < 3; k++) { - Fvector UV; - for (u32 k = 0; k < 3; k++) - { - Fvector2& uv = F.uv[k]; - view.transform_tiny(UV, p[k]); - uv.x = (1 + UV.x) * .5f; - uv.y = (1 - UV.y) * .5f; - } - wm.m_Faces.push_back(F); + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; } + wm.m_Faces.push_back(F); } - CHK_DX(V->p_rm_Vertices->Unlock()); } + CHK_DX(V->p_rm_Vertices->Unlock()); +} - void CSkeletonX_ext::_FillVerticesHW3W(const Fmatrix& /*view*/, CSkeletonWallmark& /*wm*/, const Fvector& /*normal*/, - float /*size*/, Fvisual* /*V*/, u16* /*indices*/, CBoneData::FacesVec& /*faces*/) - { - R_ASSERT2(0, "CSkeletonX_ext::_FillVerticesHW3W not implemented"); - } +void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, + float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) +{ + vertHW_4W* vertices; + CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY)); - void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& /*view*/, CSkeletonWallmark& /*wm*/, const Fvector& /*normal*/, - float /*size*/, Fvisual* /*V*/, u16* /*indices*/, CBoneData::FacesVec& /*faces*/) + for (auto it = faces.begin(); it != faces.end(); ++it) { - R_ASSERT2(0, "CSkeletonX_ext::_FillVerticesHW4W not implemented"); + Fvector p[3]; + u32 idx = (*it) * 3; + CSkeletonWallmark::WMFace F; + + for (u32 k = 0; k < 3; k++) + { + vertHW_4W& vert = vertices[indices[idx + k]]; + F.bone_id[k][0] = vert.get_bone(0); + F.bone_id[k][1] = vert.get_bone(1); + F.bone_id[k][2] = vert.get_bone(2); + F.bone_id[k][3] = vert.get_bone(3); + F.weight[k][0] = vert.get_weight0(); + F.weight[k][1] = vert.get_weight1(); + F.weight[k][2] = vert.get_weight2(); + vert.get_pos(F.vert[k]); + vert.get_pos_bones(p[k], Parent); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) + continue; + + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + { + Fvector UV; + for (u32 k = 0; k < 3; k++) + { + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; + } + wm.m_Faces.push_back(F); + } } + CHK_DX(V->p_rm_Vertices->Unlock()); +} #endif // USE_DX10 -void CSkeletonX_ext::_FillVertices(const Fmatrix& /*view*/, CSkeletonWallmark& /*wm*/, const Fvector& /*normal*/, - float /*size*/, Fvisual* /*V*/, u16 /*bone_id*/, u32 /*iBase*/, u32 /*iCount*/) +void CSkeletonX_ext::_FillVertices(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, + float size, Fvisual* V, u16 bone_id, u32 iBase, u32 /*iCount*/) { - R_ASSERT2(0, "CSkeletonX_ext::_FillVertices not implemented"); + VERIFY(Parent && ChildIDX != u16(-1)); + CBoneData& BD = Parent->LL_GetData(bone_id); + CBoneData::FacesVec* faces = &BD.child_faces[ChildIDX]; + u16* indices = nullptr; +#if defined(USE_DX10) || defined(USE_DX11) + indices = *m_Indices; +#else // USE_DX10 + CHK_DX(V->p_rm_Indices->Lock(0, V->dwPrimitives * 3, (void**)&indices, D3DLOCK_READONLY)); + // fill vertices + switch (RenderMode) + { + case RM_SKINNING_SOFT: +#endif // USE_DX10 + if (*Vertices1W) _FillVerticesSoft1W(view, wm, normal, size, indices + iBase, *faces); + else if (*Vertices2W) _FillVerticesSoft2W(view, wm, normal, size, indices + iBase, *faces); + else if (*Vertices3W) _FillVerticesSoft3W(view, wm, normal, size, indices + iBase, *faces); + else + { + VERIFY(!!*Vertices4W); + _FillVerticesSoft4W(view, wm, normal, size, indices + iBase, *faces); + } +#if !defined(USE_DX10) && !defined(USE_DX11) + break; + case RM_SINGLE: + case RM_SKINNING_1B: _FillVerticesHW1W(view, wm, normal, size, V, indices + iBase, *faces); + break; + case RM_SKINNING_2B: _FillVerticesHW2W(view, wm, normal, size, V, indices + iBase, *faces); + break; + case RM_SKINNING_3B: _FillVerticesHW3W(view, wm, normal, size, V, indices + iBase, *faces); + break; + case RM_SKINNING_4B: _FillVerticesHW4W(view, wm, normal, size, V, indices + iBase, *faces); + break; + } + CHK_DX(V->p_rm_Indices->Unlock()); +#endif // USE_DX10 } /* void CSkeletonX_ext::_FillVertices(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, diff --git a/src/Layers/xrRender/SkeletonCustom.cpp b/src/Layers/xrRender/SkeletonCustom.cpp index a033bfdc039..6e5f10129fc 100644 --- a/src/Layers/xrRender/SkeletonCustom.cpp +++ b/src/Layers/xrRender/SkeletonCustom.cpp @@ -703,7 +703,7 @@ void CKinematics::AddWallmark( intrusive_ptr wm = new CSkeletonWallmark(this, parent_xform, shader, cp, RDEVICE.fTimeGlobal); wm->m_LocalBounds.set(cp, size * 2.f); wm->XFORM()->transform_tiny(wm->m_Bounds.P, cp); - wm->m_Bounds.R = wm->m_Bounds.R; + wm->m_Bounds.R = wm->m_LocalBounds.R; Fvector tmp; tmp.invert(D); @@ -786,7 +786,7 @@ void CKinematics::RenderWallmark(intrusive_ptr wm, FVF::LIT*& Fmatrix& xform0 = LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; xform0.transform_tiny(P, F.vert[k]); } - else + else if (F.bone_id[k][1] == F.bone_id[k][2]) { // 2-link Fvector P0, P1; @@ -794,7 +794,48 @@ void CKinematics::RenderWallmark(intrusive_ptr wm, FVF::LIT*& Fmatrix& xform1 = LL_GetBoneInstance(F.bone_id[k][1]).mRenderTransform; xform0.transform_tiny(P0, F.vert[k]); xform1.transform_tiny(P1, F.vert[k]); - P.lerp(P0, P1, F.weight[k]); + P.lerp(P0, P1, F.weight[k][0]); + } + else if (F.bone_id[k][2] == F.bone_id[k][3]) + { + // 3-link + Fvector P0, P1, P2; + Fmatrix& xform0 = LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; + Fmatrix& xform1 = LL_GetBoneInstance(F.bone_id[k][1]).mRenderTransform; + Fmatrix& xform2 = LL_GetBoneInstance(F.bone_id[k][2]).mRenderTransform; + xform0.transform_tiny(P0, F.vert[k]); + xform1.transform_tiny(P1, F.vert[k]); + xform2.transform_tiny(P2, F.vert[k]); + float w0 = F.weight[k][0]; + float w1 = F.weight[k][1]; + P0.mul(w0); + P1.mul(w1); + P2.mul(1 - w0 - w1); + P = P0; + P.add(P1); + P.add(P2); + } + else + { + // 4-link + Fvector PB[4]; + for (int i = 0; i < 4; ++i) + { + Fmatrix& xform = LL_GetBoneInstance(F.bone_id[k][i]).mRenderTransform; + xform.transform_tiny(PB[i], F.vert[k]); + } + + float s = 0.f; + for (int i = 0; i < 3; ++i) + { + PB[i].mul(F.weight[k][i]); + s += F.weight[k][i]; + } + PB[3].mul(1 - s); + + P = PB[0]; + for (int i = 1; i < 4; ++i) + P.add(PB[i]); } wm->XFORM()->transform_tiny(V->p, P); V->t.set(F.uv[k]); diff --git a/src/Layers/xrRender/SkeletonCustom.h b/src/Layers/xrRender/SkeletonCustom.h index 59532c8b140..4f22c80d219 100644 --- a/src/Layers/xrRender/SkeletonCustom.h +++ b/src/Layers/xrRender/SkeletonCustom.h @@ -41,8 +41,8 @@ class CSkeletonWallmark : public intrusive_base // 4+4+4+12+4+16+16 = 60 + 4 = 6 { Fvector3 vert[3]; Fvector2 uv[3]; - u16 bone_id[3][2]; - float weight[3]; + u16 bone_id[3][4]; + float weight[3][3]; }; using WMFacesVec = xr_vector; WMFacesVec m_Faces; // 16 diff --git a/src/Layers/xrRender/SkeletonX.cpp b/src/Layers/xrRender/SkeletonX.cpp index 08091c23853..f94433d35db 100644 --- a/src/Layers/xrRender/SkeletonX.cpp +++ b/src/Layers/xrRender/SkeletonX.cpp @@ -498,7 +498,7 @@ CBoneData::FacesVec& faces) */ // Fill Vertices void CSkeletonX::_FillVerticesSoft1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, - u16* indices, CBoneData::FacesVec& faces) + u16* indices, CBoneData::FacesVec& faces) { VERIFY(*Vertices1W); for (auto it = faces.begin(); it != faces.end(); it++) @@ -511,7 +511,12 @@ void CSkeletonX::_FillVerticesSoft1W(const Fmatrix& view, CSkeletonWallmark& wm, vertBoned1W& vert = Vertices1W[indices[idx + k]]; F.bone_id[k][0] = (u16)vert.matrix; F.bone_id[k][1] = F.bone_id[k][0]; - F.weight[k] = 0.f; + F.bone_id[k][2] = F.bone_id[k][0]; + F.bone_id[k][3] = F.bone_id[k][0]; + F.weight[k][0] = 0.f; + F.weight[k][1] = 0.f; + F.weight[k][2] = 0.f; + const Fmatrix& xform = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; F.vert[k].set(vert.P); xform.transform_tiny(p[k], F.vert[k]); @@ -535,8 +540,9 @@ void CSkeletonX::_FillVerticesSoft1W(const Fmatrix& view, CSkeletonWallmark& wm, } } } + void CSkeletonX::_FillVerticesSoft2W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, - u16* indices, CBoneData::FacesVec& faces) + u16* indices, CBoneData::FacesVec& faces) { VERIFY(*Vertices2W); for (auto it = faces.begin(); it != faces.end(); it++) @@ -547,22 +553,116 @@ void CSkeletonX::_FillVerticesSoft2W(const Fmatrix& view, CSkeletonWallmark& wm, for (u32 k = 0; k < 3; k++) { Fvector P0, P1; + vertBoned2W& vert = Vertices2W[indices[idx + k]]; F.bone_id[k][0] = vert.matrix0; F.bone_id[k][1] = vert.matrix1; - F.weight[k] = vert.w; + F.bone_id[k][2] = F.bone_id[k][1]; + F.bone_id[k][3] = F.bone_id[k][1]; + F.weight[k][0] = vert.w; + F.weight[k][1] = 0.f; + F.weight[k][2] = 0.f; + Fmatrix& xform0 = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform; Fmatrix& xform1 = Parent->LL_GetBoneInstance(F.bone_id[k][1]).mRenderTransform; F.vert[k].set(vert.P); xform0.transform_tiny(P0, F.vert[k]); xform1.transform_tiny(P1, F.vert[k]); - p[k].lerp(P0, P1, F.weight[k]); + p[k].lerp(P0, P1, F.weight[k][0]); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) + continue; + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + { + Fvector UV; + for (u32 k = 0; k < 3; k++) + { + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; + } + wm.m_Faces.push_back(F); + } + } +} + +void CSkeletonX::_FillVerticesSoft3W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, + u16* indices, CBoneData::FacesVec& faces) +{ + VERIFY(*Vertices3W); + for (auto it = faces.begin(); it != faces.end(); ++it) + { + Fvector p[3]; + u32 idx = *it * 3; + CSkeletonWallmark::WMFace F; + + for (u32 k = 0; k < 3; k++) + { + const vertBoned3W& vert = Vertices3W[indices[idx + k]]; + F.bone_id[k][0] = vert.m[0]; + F.bone_id[k][1] = vert.m[1]; + F.bone_id[k][2] = vert.m[2]; + F.bone_id[k][3] = F.bone_id[k][2]; + F.weight[k][0] = vert.w[0]; + F.weight[k][1] = vert.w[1]; + F.weight[k][2] = 0.f; + vert.get_pos(F.vert[k]); + get_pos_bones(vert, p[k], Parent); } Fvector test_normal; test_normal.mknormal(p[0], p[1], p[2]); float cosa = test_normal.dotproduct(normal); if (cosa < EPS) continue; + + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) + { + Fvector UV; + for (u32 k = 0; k < 3; k++) + { + Fvector2& uv = F.uv[k]; + view.transform_tiny(UV, p[k]); + uv.x = (1 + UV.x) * .5f; + uv.y = (1 - UV.y) * .5f; + } + wm.m_Faces.push_back(F); + } + } +} + +void CSkeletonX::_FillVerticesSoft4W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, + u16* indices, CBoneData::FacesVec& faces) +{ + VERIFY(*Vertices4W); + for (auto it = faces.begin(); it != faces.end(); ++it) + { + Fvector p[3]; + u32 idx = *it * 3; + CSkeletonWallmark::WMFace F; + + for (u32 k = 0; k < 3; k++) + { + const vertBoned4W& vert = Vertices4W[indices[idx + k]]; + F.bone_id[k][0] = vert.m[0]; + F.bone_id[k][1] = vert.m[1]; + F.bone_id[k][2] = vert.m[2]; + F.bone_id[k][3] = vert.m[3]; + F.weight[k][0] = vert.w[0]; + F.weight[k][1] = vert.w[1]; + F.weight[k][2] = vert.w[2]; + vert.get_pos(F.vert[k]); + get_pos_bones(vert, p[k], Parent); + } + Fvector test_normal; + test_normal.mknormal(p[0], p[1], p[2]); + float cosa = test_normal.dotproduct(normal); + if (cosa < EPS) + continue; + if (CDB::TestSphereTri(wm.ContactPoint(), size, p)) { Fvector UV; diff --git a/src/Layers/xrRender/SkeletonX.h b/src/Layers/xrRender/SkeletonX.h index 4820b3eb3a6..7d2ed1f715f 100644 --- a/src/Layers/xrRender/SkeletonX.h +++ b/src/Layers/xrRender/SkeletonX.h @@ -65,9 +65,17 @@ class CSkeletonX virtual void _CollectBoneFaces(Fvisual* V, u32 iBase, u32 iCount) = 0; void _FillVerticesSoft1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, - u16* indices, CBoneData::FacesVec& faces); + u16* indices, CBoneData::FacesVec& faces); + void _FillVerticesSoft2W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, - u16* indices, CBoneData::FacesVec& faces); + u16* indices, CBoneData::FacesVec& faces); + + void _FillVerticesSoft3W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, + u16* indices, CBoneData::FacesVec& faces); + + void _FillVerticesSoft4W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, + u16* indices, CBoneData::FacesVec& faces); + virtual void _FillVerticesHW1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, Fvisual* V, u16* indices, CBoneData::FacesVec& faces) = 0; virtual void _FillVerticesHW2W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, diff --git a/src/Layers/xrRender/WallmarksEngine.cpp b/src/Layers/xrRender/WallmarksEngine.cpp index d09cfc190cb..7ed26281cb0 100644 --- a/src/Layers/xrRender/WallmarksEngine.cpp +++ b/src/Layers/xrRender/WallmarksEngine.cpp @@ -307,8 +307,9 @@ void CWallmarksEngine::AddStaticWallmark( void CWallmarksEngine::AddSkeletonWallmark( const Fmatrix* xf, CKinematics* obj, ref_shader& sh, const Fvector& start, const Fvector& dir, float size) { - if (0 == g_r || ::RImplementation.phase != CRender::PHASE_NORMAL) + if (::RImplementation.phase != CRender::PHASE_NORMAL) return; + // optimization cheat: don't allow wallmarks more than 50 m from viewer/actor // XXX: Make console command for this if (xf->c.distance_to_sqr(Device.vCameraPosition) > _sqr(50.f)) @@ -322,7 +323,7 @@ void CWallmarksEngine::AddSkeletonWallmark( void CWallmarksEngine::AddSkeletonWallmark(intrusive_ptr wm) { - if (0 == g_r || ::RImplementation.phase != CRender::PHASE_NORMAL) + if (::RImplementation.phase != CRender::PHASE_NORMAL) return; if (!::RImplementation.val_bHUD) diff --git a/src/xrCore/Animation/Bone.hpp b/src/xrCore/Animation/Bone.hpp index 41969e666ca..b3f24118793 100644 --- a/src/xrCore/Animation/Bone.hpp +++ b/src/xrCore/Animation/Bone.hpp @@ -101,7 +101,7 @@ struct XRCORE_API vertBoned2W // (1+3+3 + 1+3+3 + 2)*4 = 16*4 = 64 bytes Fvector B; float w; float u, v; - void get_pos(Fvector& p) { p.set(P); } + void get_pos(Fvector& p) const { p.set(P); } #ifdef DEBUG static const u8 bones_count = 2; u16 get_bone_id(u8 bone) const @@ -120,7 +120,7 @@ struct XRCORE_API vertBoned3W // 70 bytes Fvector B; float w[2]; float u, v; - void get_pos(Fvector& p) { p.set(P); } + void get_pos(Fvector& p) const { p.set(P); } #ifdef DEBUG static const u8 bones_count = 3; u16 get_bone_id(u8 bone) const @@ -139,7 +139,7 @@ struct XRCORE_API vertBoned4W // 76 bytes Fvector B; float w[3]; float u, v; - void get_pos(Fvector& p) { p.set(P); } + void get_pos(Fvector& p) const { p.set(P); } #ifdef DEBUG static const u8 bones_count = 4; u16 get_bone_id(u8 bone) const diff --git a/src/xrCore/Debug/dxerr.cpp b/src/xrCore/Debug/dxerr.cpp index 738f01aaa3d..8bb164d6436 100644 --- a/src/xrCore/Debug/dxerr.cpp +++ b/src/xrCore/Debug/dxerr.cpp @@ -28,15 +28,6 @@ #include #endif -#include -#include - -#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP -#include -#include -#include -#endif - #define XAUDIO2_E_INVALID_CALL 0x88960001 #define XAUDIO2_E_XMA_DECODER_ERROR 0x88960002 #define XAUDIO2_E_XAPO_CREATION_FAILED 0x88960003 diff --git a/src/xrGame/ActorEffector_script.cpp b/src/xrGame/ActorEffector_script.cpp index f0617d5d7ce..d6eb07273d2 100644 --- a/src/xrGame/ActorEffector_script.cpp +++ b/src/xrGame/ActorEffector_script.cpp @@ -23,7 +23,7 @@ BOOL CAnimatorCamEffectorScriptCB::Valid() if (!res && cb_name.size()) { luabind::functor fl; - R_ASSERT(GEnv.ScriptEngine->functor(*cb_name, fl)); + R_ASSERT(GEnv.ScriptEngine->functor(cb_name.c_str(), fl)); fl(); cb_name = ""; } diff --git a/src/xrGame/Level_bullet_manager_firetrace.cpp b/src/xrGame/Level_bullet_manager_firetrace.cpp index 722e7d450a2..2770eafd6fd 100644 --- a/src/xrGame/Level_bullet_manager_firetrace.cpp +++ b/src/xrGame/Level_bullet_manager_firetrace.cpp @@ -174,27 +174,26 @@ void CBulletManager::FireShotmark(SBullet* bullet, const Fvector& vDir, const Fv if (R.O) { - /* add_SkeletonWallmark not implemented now... - particle_dir = vDir; - particle_dir.invert (); + //add_SkeletonWallmark not implemented now... + particle_dir = vDir; + particle_dir.invert(); - //на текущем актере отметок не ставим - if(Level().CurrentEntity() && Level().CurrentEntity()->ID() == R.O->ID()) return; + //на текущем актере отметок не ставим + if (Level().CurrentEntity() && Level().CurrentEntity()->ID() == R.O->ID()) return; - if (mtl_pair && !mtl_pair->CollideMarks->empty() && ShowMark) - { - //добавить отметку на материале - Fvector p; - p.mad(bullet->bullet_pos,bullet->dir,R.range-0.01f); - if(!GEnv.isDedicatedServer) - GlobalEnv.Render->add_SkeletonWallmark ( &R.O->renderable.xform, - PKinematics(R.O->Visual()), - &*mtl_pair->CollideMarks, - p, - bullet->dir, - bullet->wallmark_size); - } - */ + if (mtl_pair && !mtl_pair->CollideMarks->empty() && ShowMark) + { + //добавить отметку на материале + Fvector p; + p.mad(bullet->bullet_pos, bullet->dir, R.range - 0.01f); + if (!GEnv.isDedicatedServer) + GEnv.Render->add_SkeletonWallmark(&R.O->XFORM(), + PKinematics(R.O->Visual()), + &*mtl_pair->CollideMarks, + p, + bullet->dir, + bullet->wallmark_size); + } } else { diff --git a/src/xrGame/UIGameSP.cpp b/src/xrGame/UIGameSP.cpp index 4b96b32b790..1f7002309fa 100644 --- a/src/xrGame/UIGameSP.cpp +++ b/src/xrGame/UIGameSP.cpp @@ -285,24 +285,38 @@ bool CChangeLevelWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) return inherited::OnKeyboardAction(dik, keyboard_action); } +// Не инициализировалась форма, поскольку виртуальная функция отличалась набором аргуметов +//morrey bool g_block_pause = false; -void CChangeLevelWnd::Show() + +void CChangeLevelWnd::Show(bool status) { - m_messageBox->InitMessageBox( - m_b_allow_change_level ? "message_box_change_level" : "message_box_change_level_disabled"); - SetWndPos(m_messageBox->GetWndPos()); - m_messageBox->SetWndPos(Fvector2().set(0.0f, 0.0f)); - SetWndSize(m_messageBox->GetWndSize()); + inherited::Show(status); + if (status) + { + m_messageBox->InitMessageBox( + m_b_allow_change_level ? "message_box_change_level" : "message_box_change_level_disabled"); + SetWndPos(m_messageBox->GetWndPos()); + m_messageBox->SetWndPos(Fvector2().set(0.0f, 0.0f)); + SetWndSize(m_messageBox->GetWndSize()); - m_messageBox->SetText(m_message_str.c_str()); + m_messageBox->SetText(m_message_str.c_str()); - g_block_pause = true; - Device.Pause(TRUE, TRUE, TRUE, "CChangeLevelWnd_show"); - bShowPauseString = FALSE; + g_block_pause = true; + Device.Pause(TRUE, TRUE, TRUE, "CChangeLevelWnd_show"); + bShowPauseString = FALSE; + } + else + { + g_block_pause = false; + Device.Pause(FALSE, TRUE, TRUE, "CChangeLevelWnd_hide"); + } } +//old void CChangeLevelWnd::Hide() { g_block_pause = false; Device.Pause(FALSE, TRUE, TRUE, "CChangeLevelWnd_hide"); } +//morrey diff --git a/src/xrGame/UIGameSP.h b/src/xrGame/UIGameSP.h index 491d79939b2..c9e98cf651f 100644 --- a/src/xrGame/UIGameSP.h +++ b/src/xrGame/UIGameSP.h @@ -67,7 +67,7 @@ class CChangeLevelWnd : public CUIDialogWnd virtual ~CChangeLevelWnd(){}; virtual void SendMessage(CUIWindow* pWnd, s16 msg, void* pData); virtual bool WorkInPause() const { return true; } - virtual void Show(); + virtual void Show(bool status); virtual void Hide(); virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action); }; diff --git a/src/xrGame/ai/monsters/ai_monster_utils.cpp b/src/xrGame/ai/monsters/ai_monster_utils.cpp index fa42b416eef..2d3bcd14585 100644 --- a/src/xrGame/ai/monsters/ai_monster_utils.cpp +++ b/src/xrGame/ai/monsters/ai_monster_utils.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "ai_monster_utils.h" #include "Entity.h" -#include "xrAICore/Navigation/ai_object_location.h" +#include "xrAICore/Navigation/ai_object_location_impl.h" #include "ai_space.h" #include "xrAICore/Navigation/level_graph.h" #include "Include/xrRender/Kinematics.h" diff --git a/src/xrGame/ai/monsters/rats/ai_rat_templates.cpp b/src/xrGame/ai/monsters/rats/ai_rat_templates.cpp index 2772e86385a..15b84026bdc 100644 --- a/src/xrGame/ai/monsters/rats/ai_rat_templates.cpp +++ b/src/xrGame/ai/monsters/rats/ai_rat_templates.cpp @@ -12,7 +12,7 @@ #include "xrAICore/Navigation/game_graph.h" #include "magic_box3.h" #include "Include/xrRender/RenderVisual.h" -#include "xrAICore/Navigation/ai_object_location.h" +#include "xrAICore/Navigation/ai_object_location_impl.h" #include "xrAICore/Navigation/level_graph.h" #include "movement_manager.h" #include "location_manager.h" diff --git a/src/xrGame/ai/trader/trader_animation.cpp b/src/xrGame/ai/trader/trader_animation.cpp index 74ea7ae409b..16c00ac381a 100644 --- a/src/xrGame/ai/trader/trader_animation.cpp +++ b/src/xrGame/ai/trader/trader_animation.cpp @@ -68,7 +68,8 @@ void CTraderAnimation::set_sound(LPCSTR sound, LPCSTR anim) m_sound = new ref_sound(); m_sound->create(sound, st_Effect, SOUND_TYPE_WORLD); - m_sound->play(NULL, sm_2D); + //m_sound->play(NULL, sm_2D); + m_sound->play(m_trader); } void CTraderAnimation::remove_sound() @@ -87,10 +88,15 @@ void CTraderAnimation::remove_sound() ////////////////////////////////////////////////////////////////////////// void CTraderAnimation::update_frame() { - if (m_sound && !m_sound->_feedback()) + if (m_sound) { - m_trader->callback(GameObject::eTraderSoundEnd)(); - remove_sound(); + if (m_sound->_feedback()) + m_sound->set_position(m_trader->Position()); + else + { + m_trader->callback(GameObject::eTraderSoundEnd)(); + remove_sound(); + } } if (!m_motion_global) diff --git a/src/xrGame/alife_monster_movement_manager.h b/src/xrGame/alife_monster_movement_manager.h index f3333c8b80f..cd22249de89 100644 --- a/src/xrGame/alife_monster_movement_manager.h +++ b/src/xrGame/alife_monster_movement_manager.h @@ -8,14 +8,16 @@ #pragma once +#include "movement_manager_space.h" + class CMovementManagerHolder; class CALifeMonsterDetailPathManager; class CALifeMonsterPatrolPathManager; -namespace MovementManager -{ -enum EPathType; -}; +//namespace MovementManager +//{ +//enum EPathType; +//}; class CALifeMonsterMovementManager { diff --git a/src/xrGame/alife_monster_patrol_path_manager.h b/src/xrGame/alife_monster_patrol_path_manager.h index 94412812c55..3a1e2a3f0ce 100644 --- a/src/xrGame/alife_monster_patrol_path_manager.h +++ b/src/xrGame/alife_monster_patrol_path_manager.h @@ -9,12 +9,13 @@ #pragma once #include "xrAICore/Navigation/game_graph_space.h" +#include "xrAICore/Navigation/PatrolPath/patrol_path.h" class CMovementManagerHolder; class CPatrolPath; -enum EPatrolStartType; -enum EPatrolRouteType; +//enum EPatrolStartType; +//enum EPatrolRouteType; class CALifeMonsterPatrolPathManager { diff --git a/src/xrGame/alife_simulator_script.cpp b/src/xrGame/alife_simulator_script.cpp index 8c69bdc4098..f0510f3a1c9 100644 --- a/src/xrGame/alife_simulator_script.cpp +++ b/src/xrGame/alife_simulator_script.cpp @@ -43,7 +43,6 @@ bool valid_object_id(const CALifeSimulator* self, ALife::_OBJECT_ID object_id) return (object_id != 0xffff); } -#ifdef DEBUG CSE_ALifeDynamicObject* alife_object(const CALifeSimulator* self, LPCSTR name) { VERIFY(self); @@ -58,7 +57,6 @@ CSE_ALifeDynamicObject* alife_object(const CALifeSimulator* self, LPCSTR name) return (0); } -#endif // #ifdef DEBUG CSE_ALifeDynamicObject* alife_object(const CALifeSimulator* self, ALife::_OBJECT_ID id, bool no_assert) { @@ -322,6 +320,7 @@ SCRIPT_EXPORT(CALifeSimulator, (), { (CSE_ALifeDynamicObject * (*)(const CALifeSimulator*, ALife::_OBJECT_ID))(alife_object)) .def("object", (CSE_ALifeDynamicObject * (*)(const CALifeSimulator*, ALife::_OBJECT_ID, bool))( alife_object)) + .def("object", (CSE_ALifeDynamicObject *(*) (const CALifeSimulator*, LPCSTR))(alife_object)) .def("story_object", (CSE_ALifeDynamicObject * (*)(const CALifeSimulator*, ALife::_STORY_ID))( alife_story_object)) .def("set_switch_online", diff --git a/src/xrGame/script_game_object3.cpp b/src/xrGame/script_game_object3.cpp index b3f15cb352d..622951b2e88 100644 --- a/src/xrGame/script_game_object3.cpp +++ b/src/xrGame/script_game_object3.cpp @@ -766,15 +766,21 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, bool tors void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector& vector3d, bool torso_look = false) { CAI_Stalker* stalker = smart_cast(&object()); + if (!stalker) GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CSightManager : cannot access class member set_sight!"); else { + //morrey + // не работала чн-кая анимация if ((sight_type == SightManager::eSightTypeDirection) && (_abs(vector3d.magnitude() - 1.f) > .01f)) { - VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d))); - vector3d.normalize(); + // Xottab_DUTY to Xottab_DUTY: здесь закомментировано две строчки. + //VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d))); + Msg("- non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d)); + //vector3d.normalize(); } + //-morrey stalker->sight().setup(sight_type, vector3d, torso_look); } diff --git a/src/xrGame/script_movement_action.h b/src/xrGame/script_movement_action.h index 68615b881db..974dec797cf 100644 --- a/src/xrGame/script_movement_action.h +++ b/src/xrGame/script_movement_action.h @@ -9,11 +9,12 @@ #pragma once #include "script_abstract_action.h" +#include "detail_path_manager_space.h" -namespace DetailPathManager -{ -enum EDetailPathType; -}; +//namespace DetailPathManager +//{ +//enum EDetailPathType; +//}; namespace MonsterSpace { diff --git a/src/xrGame/script_watch_action.h b/src/xrGame/script_watch_action.h index f5a4984aac9..290e06c72e8 100644 --- a/src/xrGame/script_watch_action.h +++ b/src/xrGame/script_watch_action.h @@ -9,11 +9,12 @@ #pragma once #include "script_abstract_action.h" - +#include "sight_manager_space.h" +/* namespace SightManager { enum ESightType; -}; +};*/ class CScriptGameObject; diff --git a/src/xrGame/sight_action.cpp b/src/xrGame/sight_action.cpp index 84a59e5cc29..54f81221d08 100644 --- a/src/xrGame/sight_action.cpp +++ b/src/xrGame/sight_action.cpp @@ -10,7 +10,7 @@ #include "sight_action.h" #include "ai/stalker/ai_stalker.h" #include "sight_manager.h" -#include "xrAICore/Navigation/ai_object_location.h" +#include "xrAICore/Navigation/ai_object_location_impl.h" #include "stalker_movement_manager_smart_cover.h" #include "inventory.h" diff --git a/src/xrGame/smart_cover.cpp b/src/xrGame/smart_cover.cpp index 29d3ad20942..9166c140474 100644 --- a/src/xrGame/smart_cover.cpp +++ b/src/xrGame/smart_cover.cpp @@ -41,24 +41,32 @@ cover::cover(smart_cover::object const& object, DescriptionPtr description, bool { m_is_smart_cover = 1; - m_loopholes.reserve(m_description->loopholes().size()); - Loopholes::const_iterator I = m_description->loopholes().begin(); - Loopholes::const_iterator E = m_description->loopholes().end(); - for (; I != E; ++I) + if (loopholes_availability) { - for (luabind::iterator i(loopholes_availability), e; i != e; ++i) + m_loopholes.reserve(m_description->loopholes().size()); + for (const auto& it : m_description->loopholes()) { - LPCSTR const loophole_id = luabind::object_cast(i.key()); - if (xr_strcmp(loophole_id, (*I)->id())) - continue; + for (luabind::iterator i(loopholes_availability), e; i != e; ++i) + { + pcstr const loophole_id = luabind::object_cast(i.key()); + if (xr_strcmp(loophole_id, it->id())) + continue; - if (!luabind::object_cast(*i)) - break; + if (!luabind::object_cast(*i)) + break; - m_loopholes.push_back(*I); - break; + m_loopholes.push_back(it); + break; + } } } + else + { + m_loopholes.reserve(m_description->loopholes().size()); + + for (const auto& it : m_description->loopholes()) + m_loopholes.push_back(it); + } CLevelGraph const& graph = ai().level_graph(); m_vertices.resize(loopholes().size()); diff --git a/src/xrGame/stalker_movement_manager_smart_cover.cpp b/src/xrGame/stalker_movement_manager_smart_cover.cpp index 90f0f2383b6..2cd9de4cae2 100644 --- a/src/xrGame/stalker_movement_manager_smart_cover.cpp +++ b/src/xrGame/stalker_movement_manager_smart_cover.cpp @@ -244,7 +244,11 @@ void stalker_movement_manager_smart_cover::reach_enter_location(u32 const& time_ if (!object().sight().current_action().target_reached()) return; - if (target_params().cover()->can_fire()) + // morrey + // смарткаверы чн-ные не работали. заюзал из чн алгоритм + //if (target_params().cover()->can_fire()) // ЗП + //if (target_params().cover()->is_combat_cover()) // ЧН + if (target_params().cover()->can_fire() || target_params().cover()->is_combat_cover()) // Xottab_DUTY to morrey: а если так попробовать? { CInventoryItem const* const inventory_item = object().inventory().ActiveItem(); if (!inventory_item) diff --git a/src/xrGame/ui/FactionState.cpp b/src/xrGame/ui/FactionState.cpp new file mode 100644 index 00000000000..341149b83e2 --- /dev/null +++ b/src/xrGame/ui/FactionState.cpp @@ -0,0 +1,114 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FactionState.cpp +// Created : 22.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Faction War state class implementation +//////////////////////////////////////////////////////////////////////////// + +#include "pch_script.h" +#include "StdAfx.h" +#include "FactionState.h" +#include "Actor.h" +#include "character_community.h" +#include "character_reputation.h" +#include "relation_registry.h" +#include "ai_space.h" +#include "xrScriptEngine/script_engine.hpp" + +using namespace luabind; + +FactionState::FactionState(): + member_count(0), + resource(0.0f), + power(0.0f), + m_actor_goodwill(0) +{ + m_id._set ( NULL ); + m_name._set ( NULL ); + m_icon._set ( NULL ); + m_icon_big._set ( NULL ); + m_target._set ( NULL ); + m_target_desc._set( NULL ); + m_location._set ( NULL ); + + ResetStates(); +} + +FactionState::FactionState( shared_str const& id ) +{ + FactionState(); + set_faction_id2( id ); +} + +FactionState::~FactionState() +{ +} + +void FactionState::ResetStates() +{ + for ( int i = 0; i < war_state_count ; ++i ) + { + m_war_state_str[i]._set( NULL ); + m_war_state_hint_str[i]._set( NULL ); + } + /*for ( int i = 0; i < bonuses_count ; ++i ) + { + bonuses_vs[i]._set( NULL ); + }*/ +} + +SCRIPT_EXPORT(FactionState, (), +{ + module(luaState) + [ + class_("FactionState") + .def_readwrite("member_count", &FactionState::member_count) + .def_readwrite("resource", &FactionState::resource) + .def_readwrite("power", &FactionState::power) + .def_readwrite("bonus", &FactionState::bonus) + + .property("faction_id", &FactionState::get_faction_id, &FactionState::set_faction_id) + .property("actor_goodwill", &FactionState::get_actor_goodwill,&FactionState::set_actor_goodwill) + + .property("name", &FactionState::get_name, &FactionState::set_name) + .property("icon", &FactionState::get_icon, &FactionState::set_icon) + .property("icon_big", &FactionState::get_icon_big, &FactionState::set_icon_big) + .property("target", &FactionState::get_target, &FactionState::set_target) + .property("target_desc", &FactionState::get_target_desc, &FactionState::set_target_desc) + .property("location", &FactionState::get_location, &FactionState::set_location) + + .property("war_state1", &FactionState::get_war_state1, &FactionState::set_war_state1) + .property("war_state2", &FactionState::get_war_state2, &FactionState::set_war_state2) + .property("war_state3", &FactionState::get_war_state3, &FactionState::set_war_state3) + .property("war_state4", &FactionState::get_war_state4, &FactionState::set_war_state4) + .property("war_state5", &FactionState::get_war_state5, &FactionState::set_war_state5) + + .property("war_state_hint1", &FactionState::get_war_state_hint1, &FactionState::set_war_state_hint1) + .property("war_state_hint2", &FactionState::get_war_state_hint2, &FactionState::set_war_state_hint2) + .property("war_state_hint3", &FactionState::get_war_state_hint3, &FactionState::set_war_state_hint3) + .property("war_state_hint4", &FactionState::get_war_state_hint4, &FactionState::set_war_state_hint4) + .property("war_state_hint5", &FactionState::get_war_state_hint5, &FactionState::set_war_state_hint5) + ]; +}) + +void FactionState::update_info() +{ + if ( m_id.size() == 0 ) + { + return; + } + m_actor_goodwill = 0; + CActor* pActor = smart_cast( Level().CurrentEntity() ); + if ( pActor ) + { + CHARACTER_COMMUNITY char_comm; + char_comm.set( m_id ); + m_actor_goodwill = RELATION_REGISTRY().GetCommunityGoodwill( char_comm.index(), pActor->object_id() ); + } + ResetStates(); + + luabind::functor m_functor; + R_ASSERT(GEnv.ScriptEngine->functor( "pda.fill_faction_state", m_functor)); + m_functor(this); +} + diff --git a/src/xrGame/ui/FactionState.h b/src/xrGame/ui/FactionState.h new file mode 100644 index 00000000000..7d17be53f16 --- /dev/null +++ b/src/xrGame/ui/FactionState.h @@ -0,0 +1,100 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FactionState.h +// Created : 22.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Faction War state class +//////////////////////////////////////////////////////////////////////////// + +#pragma once +#include "UIWindow.h" + +class FactionState +{ +public: + FactionState (); + FactionState ( shared_str const& id ); + ~FactionState (); + + IC int get_actor_goodwill ()const; + IC void set_actor_goodwill ( int gw ); + + IC LPCSTR get_faction_id () const; + IC shared_str const& get_faction_id2() const; + IC void set_faction_id ( LPCSTR id ); + IC void set_faction_id2 ( shared_str const& id ); + + IC LPCSTR get_name () const; + IC void set_name ( LPCSTR name ); + + IC LPCSTR get_icon () const; + IC void set_icon ( LPCSTR icon ); + + IC LPCSTR get_icon_big () const; + IC void set_icon_big ( LPCSTR icon_big ); + + IC LPCSTR get_target () const; + IC void set_target ( LPCSTR target ); + + IC LPCSTR get_target_desc () const; + IC void set_target_desc ( LPCSTR target_desc ); + + IC LPCSTR get_location () const; + IC void set_location ( LPCSTR location ); + + IC LPCSTR get_war_state ( u8 index ) const; + IC LPCSTR get_war_state_hint ( u8 index ) const; + + IC LPCSTR get_war_state1 () const; + IC void set_war_state1 ( LPCSTR icon ); + IC LPCSTR get_war_state2 () const; + IC void set_war_state2 ( LPCSTR icon ); + IC LPCSTR get_war_state3 () const; + IC void set_war_state3 ( LPCSTR icon ); + IC LPCSTR get_war_state4 () const; + IC void set_war_state4 ( LPCSTR icon ); + IC LPCSTR get_war_state5 () const; + IC void set_war_state5 ( LPCSTR icon ); + + IC LPCSTR get_war_state_hint1 () const; + IC void set_war_state_hint1 ( LPCSTR icon ); + IC LPCSTR get_war_state_hint2 () const; + IC void set_war_state_hint2 ( LPCSTR icon ); + IC LPCSTR get_war_state_hint3 () const; + IC void set_war_state_hint3 ( LPCSTR icon ); + IC LPCSTR get_war_state_hint4 () const; + IC void set_war_state_hint4 ( LPCSTR icon ); + IC LPCSTR get_war_state_hint5 () const; + IC void set_war_state_hint5 ( LPCSTR icon ); + + void update_info (); + void ResetStates (); + +public: + enum { war_state_count = 5 }; + enum { bonuses_count = 6 }; + + int member_count; + float resource; + float power; + + int bonus; + //shared_str bonuses[6]; + +private: + int m_actor_goodwill; + + shared_str m_id; + shared_str m_name; + shared_str m_icon; + shared_str m_icon_big; + shared_str m_target; + shared_str m_target_desc; + shared_str m_location; + + // int state_vs; + shared_str m_war_state_str[war_state_count]; + shared_str m_war_state_hint_str[war_state_count]; + +}; // struct FactionState + +#include "FactionState_inline.h" diff --git a/src/xrGame/ui/FactionState_inline.h b/src/xrGame/ui/FactionState_inline.h new file mode 100644 index 00000000000..8586f1674aa --- /dev/null +++ b/src/xrGame/ui/FactionState_inline.h @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FactionState_inline.h +// Created : 23.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Faction War state class +//////////////////////////////////////////////////////////////////////////// + +#pragma once + +int FactionState::get_actor_goodwill() const +{ + return m_actor_goodwill; +} +void FactionState::set_actor_goodwill( int gw ) +{ + m_actor_goodwill = gw; +} +LPCSTR FactionState::get_faction_id() const +{ + return m_id.c_str(); +} +shared_str const& FactionState::get_faction_id2() const +{ + return m_id; +} +void FactionState::set_faction_id( LPCSTR id ) +{ + m_id._set( id ); +} +void FactionState::set_faction_id2( shared_str const& id ) +{ + m_id._set( id ); +} +LPCSTR FactionState::get_name() const +{ + return m_name.c_str(); +} +void FactionState::set_name( LPCSTR name ) +{ + m_name._set( name ); +} +LPCSTR FactionState::get_icon() const +{ + return m_icon.c_str(); +} +void FactionState::set_icon( LPCSTR icon ) +{ + m_icon._set( icon ); +} + +LPCSTR FactionState::get_icon_big() const +{ + return m_icon_big.c_str(); +} +void FactionState::set_icon_big( LPCSTR icon_b ) +{ m_icon_big._set( icon_b ); +} + +LPCSTR FactionState::get_target() const +{ + return m_target.c_str(); +} +void FactionState::set_target( LPCSTR target ) +{ + m_target._set( target ); +} + +LPCSTR FactionState::get_target_desc() const +{ + return m_target_desc.c_str(); +} +void FactionState::set_target_desc( LPCSTR target_desc ) +{ + m_target_desc._set( target_desc ); +} + +LPCSTR FactionState::get_location() const +{ + return m_location.c_str(); +} +void FactionState::set_location( LPCSTR location ) +{ + m_location._set( location ); +} + +LPCSTR FactionState::get_war_state( u8 index ) const +{ + VERIFY( 0 <= index && index < war_state_count ); + return m_war_state_str[index].c_str(); +} + +LPCSTR FactionState::get_war_state_hint( u8 index ) const +{ + VERIFY( 0 <= index && index < war_state_count ); + return m_war_state_hint_str[index].c_str(); +} + +LPCSTR FactionState::get_war_state1() const { return m_war_state_str[0].c_str(); } +void FactionState::set_war_state1( LPCSTR icon ) { m_war_state_str[0]._set( icon );} +LPCSTR FactionState::get_war_state2() const { return m_war_state_str[1].c_str(); } +void FactionState::set_war_state2( LPCSTR icon ) { m_war_state_str[1]._set( icon );} +LPCSTR FactionState::get_war_state3() const { return m_war_state_str[2].c_str(); } +void FactionState::set_war_state3( LPCSTR icon ) { m_war_state_str[2]._set( icon );} +LPCSTR FactionState::get_war_state4() const { return m_war_state_str[3].c_str(); } +void FactionState::set_war_state4( LPCSTR icon ) { m_war_state_str[3]._set( icon );} +LPCSTR FactionState::get_war_state5() const { return m_war_state_str[4].c_str(); } +void FactionState::set_war_state5( LPCSTR icon ) { m_war_state_str[4]._set( icon );} + +LPCSTR FactionState::get_war_state_hint1() const { return m_war_state_hint_str[0].c_str(); } +void FactionState::set_war_state_hint1( LPCSTR text ) { m_war_state_hint_str[0]._set( text );} +LPCSTR FactionState::get_war_state_hint2() const { return m_war_state_hint_str[1].c_str(); } +void FactionState::set_war_state_hint2( LPCSTR text ) { m_war_state_hint_str[1]._set( text );} +LPCSTR FactionState::get_war_state_hint3() const { return m_war_state_hint_str[2].c_str(); } +void FactionState::set_war_state_hint3( LPCSTR text ) { m_war_state_hint_str[2]._set( text );} +LPCSTR FactionState::get_war_state_hint4() const { return m_war_state_hint_str[3].c_str(); } +void FactionState::set_war_state_hint4( LPCSTR text ) { m_war_state_hint_str[3]._set( text );} +LPCSTR FactionState::get_war_state_hint5() const { return m_war_state_hint_str[4].c_str(); } +void FactionState::set_war_state_hint5( LPCSTR text ) { m_war_state_hint_str[4]._set( text );} diff --git a/src/xrGame/ui/FractionState.cpp b/src/xrGame/ui/FractionState.cpp new file mode 100644 index 00000000000..c34cdbbbb45 --- /dev/null +++ b/src/xrGame/ui/FractionState.cpp @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FractionState.cpp +// Created : 22.01.2008 +// Modified : 23.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Fraction War state class implementation +//////////////////////////////////////////////////////////////////////////// + +#include "pch_script.h" +#include "StdAfx.h" +#include "FractionState.h" + +#include "../actor.h" +#include "../character_community.h" +#include "../character_reputation.h" +#include "../relation_registry.h" +#include "../ai_space.h" +#include "xrScriptEngine/script_engine.hpp" + +using namespace luabind; + +FractionState::FractionState(): + member_count(0), + resource(0.0f), + power(0.0f), + state_vs(0), + m_actor_goodwill(0) +{ + m_id._set ( NULL ); + m_name._set ( NULL ); + m_icon._set ( NULL ); + m_icon_big._set ( NULL ); + m_target._set ( NULL ); + m_target_desc._set( NULL ); + m_location._set ( NULL ); +} + +FractionState::FractionState( shared_str const& id ) +{ + FractionState(); + set_fraction_id2( id ); +} + +FractionState::~FractionState() +{ +} + +SCRIPT_EXPORT(FractionState, (), +{ + module(luaState) + [ + class_("FractionState") + .def_readwrite("member_count", &FractionState::member_count) + .def_readwrite("resource", &FractionState::resource) + .def_readwrite("power", &FractionState::power) + .def_readwrite("state_vs", &FractionState::state_vs) + .def_readwrite("bonus", &FractionState::bonus) + + .property("fraction_id", &FractionState::get_fraction_id, &FractionState::set_fraction_id) + .property("actor_goodwill", &FractionState::get_actor_goodwill,&FractionState::set_actor_goodwill) + + .property("name", &FractionState::get_name, &FractionState::set_name) + .property("icon", &FractionState::get_icon, &FractionState::set_icon) + .property("icon_big", &FractionState::get_icon_big, &FractionState::set_icon_big) + .property("target", &FractionState::get_target, &FractionState::set_target) + .property("target_desc", &FractionState::get_target_desc, &FractionState::set_target_desc) + .property("location", &FractionState::get_location, &FractionState::set_location) + ]; +}) + +void FractionState::update_info() +{ + if ( m_id.size() == 0 ) + { + return; + } + m_actor_goodwill = 0; + CActor* pActor = smart_cast( Level().CurrentEntity() ); + if ( pActor ) + { + CHARACTER_COMMUNITY char_cmm; + char_cmm.set( m_id ); + m_actor_goodwill = RELATION_REGISTRY().GetCommunityGoodwill( char_cmm.index(), pActor->object_id() ); + } + + luabind::functor m_functor; + R_ASSERT(GEnv.ScriptEngine->functor("pda.fill_fraction_state", m_functor)); + m_functor(this); +} diff --git a/src/xrGame/ui/FractionState.h b/src/xrGame/ui/FractionState.h new file mode 100644 index 00000000000..3f8b3b0fd3a --- /dev/null +++ b/src/xrGame/ui/FractionState.h @@ -0,0 +1,68 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FractionState.h +// Created : 22.01.2008 +// Modified : 22.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Fraction War state class +//////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "UIWindow.h" + +class FractionState +{ +public: + FractionState (); + FractionState ( shared_str const& id ); + ~FractionState (); + + IC int get_actor_goodwill ()const; + IC void set_actor_goodwill ( int gw ); + + IC LPCSTR get_fraction_id () const; + IC void set_fraction_id ( LPCSTR id ); + IC void set_fraction_id2 ( shared_str const& id ); + + IC LPCSTR get_name () const; + IC void set_name ( LPCSTR name ); + + IC LPCSTR get_icon () const; + IC void set_icon ( LPCSTR icon ); + + IC LPCSTR get_icon_big () const; + IC void set_icon_big ( LPCSTR icon_big ); + + IC LPCSTR get_target () const; + IC void set_target ( LPCSTR target ); + + IC LPCSTR get_target_desc () const; + IC void set_target_desc ( LPCSTR target_desc ); + + IC LPCSTR get_location () const; + IC void set_location ( LPCSTR location ); + + void update_info (); + +public: + int member_count; + float resource; + float power; + int state_vs; + int bonus; + //shared_str bonuses[6]; //int[6] + +private: + int m_actor_goodwill; + + shared_str m_id; + shared_str m_name; + shared_str m_icon; + shared_str m_icon_big; + shared_str m_target; + shared_str m_target_desc; + shared_str m_location; + +}; // struct FractionState + + +#include "FractionState_inline.h" diff --git a/src/xrGame/ui/FractionState_inline.h b/src/xrGame/ui/FractionState_inline.h new file mode 100644 index 00000000000..2b735cfb91e --- /dev/null +++ b/src/xrGame/ui/FractionState_inline.h @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : FractionState_inline.h +// Created : 23.01.2008 +// Modified : 23.01.2008 +// Author : Evgeniy Sokolov +// Description : UI Fraction War state class +//////////////////////////////////////////////////////////////////////////// + +#pragma once + +int FractionState::get_actor_goodwill() const +{ + return m_actor_goodwill; +} +void FractionState::set_actor_goodwill( int gw ) +{ + m_actor_goodwill = gw; +} +LPCSTR FractionState::get_fraction_id() const +{ + return m_id.c_str(); +} +void FractionState::set_fraction_id( LPCSTR id ) +{ + m_id._set( id ); +} +void FractionState::set_fraction_id2( shared_str const& id ) +{ + m_id._set( id ); +} +LPCSTR FractionState::get_name() const +{ + return m_name.c_str(); +} +void FractionState::set_name( LPCSTR name ) +{ + m_name._set( name ); +} +LPCSTR FractionState::get_icon() const +{ + return m_icon.c_str(); +} +void FractionState::set_icon( LPCSTR icon ) +{ + m_icon._set( icon ); +} + +LPCSTR FractionState::get_icon_big() const +{ + return m_icon_big.c_str(); +} +void FractionState::set_icon_big( LPCSTR icon_b ) +{ m_icon_big._set( icon_b ); +} + +LPCSTR FractionState::get_target() const +{ + return m_target.c_str(); +} +void FractionState::set_target( LPCSTR target ) +{ + m_target._set( target ); +} + +LPCSTR FractionState::get_target_desc() const +{ + return m_target_desc.c_str(); +} +void FractionState::set_target_desc( LPCSTR target_desc ) +{ + m_target_desc._set( target_desc ); +} + +LPCSTR FractionState::get_location() const +{ + return m_location.c_str(); +} +void FractionState::set_location( LPCSTR location ) +{ + m_location._set( location ); +} diff --git a/src/xrGame/ui/UIFactionWarWnd.cpp b/src/xrGame/ui/UIFactionWarWnd.cpp new file mode 100644 index 00000000000..698eb19f8ff --- /dev/null +++ b/src/xrGame/ui/UIFactionWarWnd.cpp @@ -0,0 +1,403 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : UIFactionWarWnd.cpp +// Created : 26.12.2007 +// Author : Evgeniy Sokolov +// Description : UI Faction War window class implementation +//////////////////////////////////////////////////////////////////////////// + +#include "pch_script.h" +#include "StdAfx.h" +#include "UIFactionWarWnd.h" + +#include "UIXmlInit.h" +#include "UIProgressBar.h" +#include "UIFrameLineWnd.h" +#include "UIHelper.h" + +#include "FactionState.h" +#include "UIPdaWnd.h" +#include "UICharacterInfo.h" + +#include "Actor.h" +#include "Pda.h" +#include "ai_space.h" +#include "xrScriptEngine/script_engine.hpp" + +#define PDA_FACTION_WAR_XML "pda_fraction_war.xml" + +CUIFactionWarWnd::CUIFactionWarWnd() +{ + Reset(); +} + +CUIFactionWarWnd::~CUIFactionWarWnd() +{ +} + +void CUIFactionWarWnd::Reset() +{ + m_previous_time = Device.dwTimeGlobal; + m_update_delay = 3000; + m_max_member_count = 100; + m_max_resource = 100; + m_max_power = 100; + m_war_states_dx = 0.0f; + hint_wnd = NULL; + m_tc_pos.set ( 0.0f, 0.0f ); + m_td_pos.set ( 0.0f, 0.0f ); +} + +void CUIFactionWarWnd::Init() +{ + CUIXml xml; + xml.Load( CONFIG_PATH, UI_PATH, PDA_FACTION_WAR_XML ); + + CUIXmlInit::InitWindow( xml, "main_wnd", 0, this ); + + m_background = UIHelper::CreateFrameWindow( xml, "background", this ); + + m_center_background = UIHelper::CreateFrameWindow( xml, "center_background", this ); + + m_target_static = UIHelper::CreateTextWnd( xml, "target_static", this ); + m_target_caption = UIHelper::CreateTextWnd( xml, "target_caption", this ); + //m_target_caption->SetElipsis( 1, 0 ); + m_tc_pos = m_target_caption->GetWndPos(); + + m_target_desc = UIHelper::CreateTextWnd( xml, "target_decs", this ); + m_td_pos = m_target_desc->GetWndPos(); + + m_state_static = UIHelper::CreateStatic( xml, "state_static", this ); + + m_our_icon = UIHelper::CreateStatic( xml, "static_our_icon", this ); + m_our_icon_over = UIHelper::CreateStatic( xml, "static_our_icon_over", this ); + m_our_name = UIHelper::CreateTextWnd( xml, "static_our_name", this ); + m_st_our_frac_info = UIHelper::CreateStatic( xml, "static_our_frac_info", this ); + m_st_our_mem_count = UIHelper::CreateStatic( xml, "static_our_mem_count", this ); + m_st_our_resource = UIHelper::CreateStatic( xml, "static_our_resource", this ); + + m_pb_our_state = UIHelper::CreateProgressBar( xml, "progress_our_state", this ); + m_pb_our_mem_count = UIHelper::CreateProgressBar( xml, "progress_our_mem_count", this ); + m_pb_our_resource = UIHelper::CreateProgressBar( xml, "progress_our_resource", this ); + + m_enemy_icon = UIHelper::CreateStatic( xml, "static_enemy_icon", this ); + m_enemy_icon_over = UIHelper::CreateStatic( xml, "static_enemy_icon_over", this ); + m_enemy_name = UIHelper::CreateTextWnd( xml, "static_enemy_name", this ); + m_st_enemy_frac_info = UIHelper::CreateStatic( xml, "static_enemy_frac_info", this ); + m_st_enemy_mem_count = UIHelper::CreateStatic( xml, "static_enemy_mem_count", this ); + m_st_enemy_resource = UIHelper::CreateStatic( xml, "static_enemy_resource", this ); + + m_pb_enemy_state = UIHelper::CreateProgressBar( xml, "progress_enemy_state", this ); + m_pb_enemy_mem_count = UIHelper::CreateProgressBar( xml, "progress_enemy_mem_count", this ); + m_pb_enemy_resource = UIHelper::CreateProgressBar( xml, "progress_enemy_resource", this ); + + m_static_line1 = UIHelper::CreateFrameLine( xml, "static_line1", this ); + m_static_line2 = UIHelper::CreateFrameLine( xml, "static_line2", this ); + m_static_line3 = UIHelper::CreateFrameLine( xml, "static_line3", this ); + m_static_line4 = UIHelper::CreateFrameLine( xml, "static_line4", this ); + m_static_line_left = UIHelper::CreateFrameLine( xml, "static_line_left", this ); + m_static_line_right = UIHelper::CreateFrameLine( xml, "static_line_right", this ); + + VERIFY( hint_wnd ); + m_war_states_parent = new CUIWindow(); + m_war_states_parent->SetAutoDelete( true ); + AttachChild( m_war_states_parent ); + Fvector2 pos; + pos.x = xml.ReadAttribFlt( "static_vs_state", 0, "x" ); + pos.y = xml.ReadAttribFlt( "static_vs_state", 0, "y" ); + m_war_states_parent->SetWndPos( pos ); + + for ( u8 i = 0; i < max_war_state; ++i ) + { + m_war_state[i] = new UIWarState(); + m_war_state[i]->InitXML( xml, "static_vs_state", m_war_states_parent ); + m_war_state[i]->set_hint_wnd( hint_wnd ); + } + + float dx = xml.ReadAttribFlt( "static_vs_state", 0, "dx" ); + m_war_states_dx = dx; + m_war_states_xcenter = xml.ReadAttribFlt( "static_vs_state", 0, "xcenter", 511.0f ); + + pos.set( 0.0f, 0.0f ); + m_war_state[0]->SetWndPos( pos ); + for ( u8 i = 1; i < max_war_state; ++i ) + { + pos.x += m_war_state[i-1]->GetWndSize().x + dx; + m_war_state[i]->SetWndPos( pos ); + } + + for ( u8 i = 0; i < max_bonuce; ++i ) + { + m_our_bonuces[i] = UIHelper::CreateStatic( xml, "static_our_bonuce", this ); + } + dx = xml.ReadAttribFlt( "static_our_bonuce", 0, "dx" ); + pos = m_our_bonuces[0]->GetWndPos(); + for ( u8 i = 1; i < max_bonuce; ++i ) + { + pos.x += m_our_bonuces[i-1]->GetWndSize().x + dx; + m_our_bonuces[i]->SetWndPos( pos ); + } + + for ( u8 i = 0; i < max_bonuce; ++i ) + { + m_enemy_bonuces[i] = UIHelper::CreateStatic( xml, "static_enemy_bonuce", this ); + } + dx = xml.ReadAttribFlt( "static_enemy_bonuce", 0, "dx" ); + pos = m_enemy_bonuces[0]->GetWndPos(); + for ( u8 i = 1; i < max_bonuce; ++i ) + { + pos.x += m_enemy_bonuces[i-1]->GetWndSize().x + dx; + m_enemy_bonuces[i]->SetWndPos( pos ); + } + int delay = xml.ReadAttribInt( "main_wnd", 0, "update_delay", 3000 ); + m_update_delay = (0 < delay)? (u32)delay : 0; +} + +void CUIFactionWarWnd::ShowInfo( bool status ) +{ +// m_target_static->Show( status ); +// m_target_caption->Show( status ); +// m_target_desc->Show( status ); + m_state_static->Show( status ); + +// m_static_line1->Show( status ); + m_static_line2->Show( status ); + m_static_line3->Show( status ); + m_static_line4->Show( status ); + m_static_line_left->Show( status ); + m_static_line_right->Show( status ); + + m_our_icon->Show( status ); + m_our_icon_over->Show( status ); + m_our_name->Show( status ); + m_st_our_frac_info->Show( status ); + m_st_our_mem_count->Show( status ); + m_st_our_resource->Show( status ); + + m_pb_our_state->Show( status ); + m_pb_our_mem_count->Show( status ); + m_pb_our_resource->Show( status ); + + m_enemy_icon->Show( status ); + m_enemy_icon_over->Show( status ); + m_enemy_name->Show( status ); + m_st_enemy_frac_info->Show( status ); + m_st_enemy_mem_count->Show( status ); + m_st_enemy_resource->Show( status ); + + m_pb_enemy_state->Show( status ); + m_pb_enemy_mem_count->Show( status ); + m_pb_enemy_resource->Show( status ); + + m_war_states_parent->Show( status ); + + for ( u8 i = 0; i < max_bonuce; ++i ) + { + m_our_bonuces[i]->Show( status ); + m_enemy_bonuces[i]->Show( status ); + } +} + +void CUIFactionWarWnd::SendMessage( CUIWindow* pWnd, s16 msg, void* pData ) +{ + CUIWndCallback::OnEvent( pWnd, msg, pData ); +} + +void CUIFactionWarWnd::Show( bool status ) +{ + if ( status ) + { + InitFactions(); + } + for ( u8 i = 0; i < max_war_state; ++i ) + { + m_war_state[i]->ClearInfo(); + } + inherited::Show( status ); +} + +void CUIFactionWarWnd::Update() +{ + inherited::Update(); + if ( !IsShown() ) + { + Reset(); + } + if ( Device.dwTimeGlobal - m_previous_time > m_update_delay ) + { + m_previous_time = Device.dwTimeGlobal; + UpdateInfo(); + } +} + +bool CUIFactionWarWnd::InitFactions() +{ + shared_str our, enemy; + if ( !CUICharacterInfo::get_actor_community( &our, &enemy ) ) + { + return false; + } + + + /* + shared_str const& actor_team = Actor()->CharacterInfo().Community().id(); + + LPCSTR vs_teams = pSettings->r_string( "actor_communities", actor_team.c_str() ); + if ( _GetItemCount( vs_teams ) != 2 ) + { + return false; + } + u32 size_temp = (xr_strlen(vs_teams) + 1) * sizeof(char); + PSTR our_fract = (PSTR)_alloca( size_temp ); + PSTR enemy_fract = (PSTR)_alloca( size_temp ); + _GetItem( vs_teams, 0, our_fract ); + _GetItem( vs_teams, 1, enemy_fract ); + + if ( xr_strlen(our_fract) == 0 || xr_strlen(enemy_fract) == 0 ) + { + return false; + }*/ + m_our_faction.set_faction_id2( our ); + m_enemy_faction.set_faction_id2( enemy ); + + UpdateInfo(); + return true; +} + +void CUIFactionWarWnd::UpdateInfo() +{ + if ( m_our_faction.get_faction_id2().size() == 0 ) + { + if ( !InitFactions() ) + { + R_ASSERT2( 0, "Actor`s faction is unknown!" ); + } + } + m_max_member_count = get_max_member_count(); + m_max_resource = get_max_resource(); + m_max_power = get_max_power(); + + m_our_faction.update_info(); + + m_target_caption->SetText( m_our_faction.get_target() ); + m_target_caption->AdjustHeightToText(); + + Fvector2 pos = m_td_pos; + pos.y = m_target_caption->GetWndPos().y + m_target_caption->GetHeight() + 8.0f; + m_target_desc->SetWndPos( pos ); + m_target_desc->SetText( m_our_faction.get_target_desc() ); + + if ( m_enemy_faction.get_faction_id2().size() == 0 || m_our_faction.member_count == 0 || xr_strlen( m_our_faction.get_name() )==0 ) + { + ShowInfo( false ); + return; + } + m_enemy_faction.update_info(); + ShowInfo( true ); + + UpdateWarStates( m_our_faction ); + + //our + m_our_name->SetTextST( m_our_faction.get_name() ); + m_our_icon->InitTexture( m_our_faction.get_icon_big() ); + + + m_pb_our_state->SetRange( 0.0f, m_max_power ); + m_pb_our_state->SetProgressPos( m_our_faction.power ); + + m_pb_our_mem_count->SetRange( 0.0f, (float)m_max_member_count ); + m_pb_our_mem_count->SetProgressPos( (float)m_our_faction.member_count ); + + m_pb_our_resource->SetRange( 0.0f, m_max_resource ); + m_pb_our_resource->SetProgressPos( m_our_faction.resource ); + set_amount_our_bonus( m_our_faction.bonus ); + + //enemy + m_enemy_name->SetTextST( m_enemy_faction.get_name() ); + m_enemy_icon->InitTexture( m_enemy_faction.get_icon_big() ); + + m_pb_enemy_state->SetRange( 0.0f, m_max_power ); + m_pb_enemy_state->SetProgressPos( m_enemy_faction.power ); + + m_pb_enemy_mem_count->SetRange( 0.0f, (float)m_max_member_count ); + m_pb_enemy_mem_count->SetProgressPos( (float)m_enemy_faction.member_count ); + + m_pb_enemy_resource->SetRange( 0.0f, m_max_resource ); + m_pb_enemy_resource->SetProgressPos( m_enemy_faction.resource ); + + set_amount_enemy_bonus( m_enemy_faction.bonus ); +} + +void CUIFactionWarWnd::UpdateWarStates( FactionState const& faction ) +{ + Fvector2 pos; + pos = m_war_states_parent->GetWndPos(); + + float sx = 0.0f; + u8 cnt = 0; + for ( u8 i = 0; i < max_war_state; ++i ) + { + if ( !m_war_state[i]->UpdateInfo( faction.get_war_state(i), faction.get_war_state_hint(i) ) ) + { + break; // for i + } + ++cnt; + sx += m_war_state[i]->GetWndSize().x + m_war_states_dx; + } + if ( cnt == 0 ) + { + m_war_states_parent->SetWndPos( pos ); + return; + } + sx -= m_war_states_dx; + + pos.x = m_war_states_xcenter - sx * 0.5f; + m_war_states_parent->SetWndPos( pos ); +} + +void CUIFactionWarWnd::set_amount_our_bonus( int value ) +{ + for ( u32 i = 0; i < max_bonuce; ++i ) + { + m_our_bonuces[i]->SetTextureColor( color_rgba( 255, 255, 255, 70) ); + } + u32 cr = color_rgba( 0, 255, 0, 255); + for ( int i = 0; i < value; ++i ) + { + m_our_bonuces[i]->SetTextureColor( cr ); + } +} + +void CUIFactionWarWnd::set_amount_enemy_bonus( int value ) +{ + for ( u32 i = 0; i < max_bonuce; ++i ) + { + m_enemy_bonuces[i]->SetTextureColor( color_rgba( 255, 255, 255, 70) ); + } + u32 cr = color_rgba( 0, 255, 0, 255); + for ( int i = 0; i < value; ++i ) + { + m_enemy_bonuces[i]->SetTextureColor( cr ); + } +} + +// ------------------------------------------------------------------------------------------------- +int CUIFactionWarWnd::get_max_member_count() +{ + luabind::functor funct; + R_ASSERT(GEnv.ScriptEngine->functor("pda.get_max_member_count", funct)); + return funct(); +} + +float CUIFactionWarWnd::get_max_resource() +{ + luabind::functor funct; + R_ASSERT(GEnv.ScriptEngine->functor("pda.get_max_resource", funct)); + return funct(); +} + +float CUIFactionWarWnd::get_max_power() +{ + luabind::functor funct; + R_ASSERT(GEnv.ScriptEngine->functor("pda.get_max_power", funct)); + return funct(); +} diff --git a/src/xrGame/ui/UIFactionWarWnd.h b/src/xrGame/ui/UIFactionWarWnd.h new file mode 100644 index 00000000000..f6df7c59c07 --- /dev/null +++ b/src/xrGame/ui/UIFactionWarWnd.h @@ -0,0 +1,112 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : UIFactionWarWnd.h +// Created : 26.12.2007 +// Author : Evgeniy Sokolov +// Description : UI Faction War window class +//////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "UIWindow.h" +#include "UIWndCallback.h" +#include "FactionState.h" +#include "UIWarState.h" + +class CUIStatic; +class CGameTask; +class CUIXml; +class CUIProgressBar; +class CUIFrameLineWnd; + +class CUIFactionWarWnd : public CUIWindow, public CUIWndCallback +{ + using inherited = CUIWindow; + + CUIFrameWindow* m_background; + CUIFrameWindow* m_center_background; + + CUITextWnd* m_target_static; + CUITextWnd* m_target_caption; // our + Fvector2 m_tc_pos; + CUITextWnd* m_target_desc; + Fvector2 m_td_pos; + CUIStatic* m_state_static; + + CUIFrameLineWnd* m_static_line1; + CUIFrameLineWnd* m_static_line2; + CUIFrameLineWnd* m_static_line3; + CUIFrameLineWnd* m_static_line4; + CUIFrameLineWnd* m_static_line_left; + CUIFrameLineWnd* m_static_line_right; + + CUIStatic* m_our_icon; + CUIStatic* m_our_icon_over; + CUITextWnd* m_our_name; + CUIStatic* m_st_our_frac_info; + CUIStatic* m_st_our_mem_count; + CUIStatic* m_st_our_resource; + + CUIProgressBar* m_pb_our_state; + CUIProgressBar* m_pb_our_mem_count; + CUIProgressBar* m_pb_our_resource; + + CUIStatic* m_enemy_icon; + CUIStatic* m_enemy_icon_over; + CUITextWnd* m_enemy_name; + CUIStatic* m_st_enemy_frac_info; + CUIStatic* m_st_enemy_mem_count; + CUIStatic* m_st_enemy_resource; + + CUIProgressBar* m_pb_enemy_state; + CUIProgressBar* m_pb_enemy_mem_count; + CUIProgressBar* m_pb_enemy_resource; + + CUIWindow* m_war_states_parent; + float m_war_states_dx; + float m_war_states_xcenter; + enum { max_war_state = FactionState::war_state_count }; + UIWarState* m_war_state[max_war_state]; + + enum { max_bonuce = 6 }; + CUIStatic* m_our_bonuces[max_bonuce]; + CUIStatic* m_enemy_bonuces[max_bonuce]; + + // ---------------------------------------- + //shared_str m_our_faction_id; + //shared_str m_enemy_faction_id; + u32 m_update_delay; + u32 m_previous_time; + + FactionState m_our_faction; + FactionState m_enemy_faction; + + int m_max_member_count; + float m_max_resource; + float m_max_power; + +public: + CUIFactionWarWnd (); + virtual ~CUIFactionWarWnd (); + + virtual void SendMessage ( CUIWindow* pWnd, s16 msg, void* pData ); + virtual void Show ( bool status ); + virtual void Update (); + + void ShowInfo ( bool status ); + + void Reset (); + void Init (); + + bool InitFactions (); + void UpdateInfo (); + void UpdateWarStates ( FactionState const& faction ); +// void set_amount_state_vs ( int value ); + void set_amount_our_bonus ( int value ); + void set_amount_enemy_bonus ( int value ); + + UIHint* hint_wnd; +protected: + int get_max_member_count (); + float get_max_resource (); + float get_max_power (); + +}; // class CUIFactionWarWnd diff --git a/src/xrGame/ui/UIPdaWnd.cpp b/src/xrGame/ui/UIPdaWnd.cpp index 1c68beb41e4..c20b9450832 100644 --- a/src/xrGame/ui/UIPdaWnd.cpp +++ b/src/xrGame/ui/UIPdaWnd.cpp @@ -24,6 +24,7 @@ #include "UIHint.h" #include "UIBtnHint.h" #include "UITaskWnd.h" +#include "UIFactionWarWnd.h" #include "UIRankingWnd.h" #include "UILogsWnd.h" @@ -36,7 +37,7 @@ void RearrangeTabButtons(CUITabControl* pTab); CUIPdaWnd::CUIPdaWnd() { pUITaskWnd = NULL; - //- pUIFactionWarWnd = NULL; + pUIFactionWarWnd = NULL; pUIRankingWnd = NULL; pUILogsWnd = NULL; m_hint_wnd = NULL; @@ -46,7 +47,7 @@ CUIPdaWnd::CUIPdaWnd() CUIPdaWnd::~CUIPdaWnd() { delete_data(pUITaskWnd); - //- delete_data( pUIFactionWarWnd ); + delete_data(pUIFactionWarWnd); delete_data(pUIRankingWnd); delete_data(pUILogsWnd); delete_data(m_hint_wnd); @@ -82,9 +83,9 @@ void CUIPdaWnd::Init() pUITaskWnd->hint_wnd = m_hint_wnd; pUITaskWnd->Init(); - //- pUIFactionWarWnd = new CUIFactionWarWnd(); - //- pUIFactionWarWnd->hint_wnd = m_hint_wnd; - //- pUIFactionWarWnd->Init (); + pUIFactionWarWnd = new CUIFactionWarWnd(); + pUIFactionWarWnd->hint_wnd = m_hint_wnd; + pUIFactionWarWnd->Init(); pUIRankingWnd = new CUIRankingWnd(); pUIRankingWnd->Init(); @@ -182,10 +183,10 @@ void CUIPdaWnd::SetActiveSubdialog(const shared_str& section) { m_pActiveDialog = pUITaskWnd; } - //- else if ( section == "eptFractionWar" ) - //- { - //- m_pActiveDialog = pUIFactionWarWnd; - //- } + else if ( section == "eptFractionWar" ) + { + m_pActiveDialog = pUIFactionWarWnd; + } else if (section == "eptRanking") { m_pActiveDialog = pUIRankingWnd; @@ -257,10 +258,10 @@ void CUIPdaWnd::DrawHint() { pUITaskWnd->DrawHint(); } - //- else if ( m_pActiveDialog == pUIFactionWarWnd ) - //- { - // m_hint_wnd->Draw(); - //- } + else if ( m_pActiveDialog == pUIFactionWarWnd ) + { + m_hint_wnd->Draw(); + } else if (m_pActiveDialog == pUIRankingWnd) { pUIRankingWnd->DrawHint(); @@ -288,7 +289,8 @@ void CUIPdaWnd::Reset() if (pUITaskWnd) pUITaskWnd->ResetAll(); - //- if ( pUIFactionWarWnd ) pUITaskWnd->ResetAll(); + if (pUIFactionWarWnd) + pUITaskWnd->ResetAll(); if (pUIRankingWnd) pUIRankingWnd->ResetAll(); if (pUILogsWnd) diff --git a/src/xrGame/ui/UIPdaWnd.h b/src/xrGame/ui/UIPdaWnd.h index 528dd187186..7b2e03ee7c2 100644 --- a/src/xrGame/ui/UIPdaWnd.h +++ b/src/xrGame/ui/UIPdaWnd.h @@ -13,7 +13,7 @@ class CUIFrameWindow; class UIHint; class CUITaskWnd; -//-class CUIFactionWarWnd; +class CUIFactionWarWnd; class CUIRankingWnd; class CUILogsWnd; class CUIAnimatedStatic; @@ -43,7 +43,7 @@ class CUIPdaWnd : public CUIDialogWnd public: CUITaskWnd* pUITaskWnd; - //- CUIFactionWarWnd* pUIFactionWarWnd; + CUIFactionWarWnd* pUIFactionWarWnd; CUIRankingWnd* pUIRankingWnd; CUILogsWnd* pUILogsWnd; diff --git a/src/xrGame/ui/UIWarState.cpp b/src/xrGame/ui/UIWarState.cpp new file mode 100644 index 00000000000..19ef18cb6ea --- /dev/null +++ b/src/xrGame/ui/UIWarState.cpp @@ -0,0 +1,94 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : UIWarState.cpp +// Created : 15.04.2008 +// Author : Evgeniy Sokolov +// Description : UI war state (PDA) window class implementation +//////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "UIWarState.h" +#include "UIStatic.h" +#include "UIXmlInit.h" +#include "UIHelper.h" + +UIWarState::UIWarState() +{ + //m_installed = false; + //m_def_texture._set( NULL ); +} + +void UIWarState::InitXML(CUIXml& xml, LPCSTR att_name, CUIWindow* parent) +{ + VERIFY( parent ); + parent->AttachChild(this); + SetAutoDelete(true); + string256 buf; + + CUIXmlInit::InitWindow(xml, att_name, 0, this); + + strconcat(sizeof buf, buf, att_name, ":img"); + m_static = UIHelper::CreateStatic(xml, buf, this); + + /* strconcat( sizeof(buf), buf, att_name, ":img:texture" ); + m_def_texture._set( xml.Read( buf, 0, NULL ) ); + VERIFY( m_def_texture.size() ); + */ + set_hint_delay((u32)xml.ReadAttribInt(att_name, 0, "delay", 0)); + + // ui_war_state_no_hint = xml.ReadAttrib( att_name, 0, "hint_disable" ); +} + +void UIWarState::ClearInfo() +{ + //m_installed = false; + // m_static->SetVisible( false ); + SetVisible(false); + set_hint_text_ST(""); + + //m_static->InitTexture( m_def_texture.c_str() ); +} + +bool UIWarState::UpdateInfo(LPCSTR icon, LPCSTR hint_text) +{ + if (!icon || !xr_strlen(icon)) + { + return false; + } + + // m_installed = true; + // m_static->SetVisible( true ); + SetVisible(true); + m_static->InitTexture(icon); + + if (!hint_text || !xr_strlen(hint_text)) + { + set_hint_text_ST(""); + } + else + { + set_hint_text_ST(hint_text); + } + return true; +} + +void UIWarState::Draw() +{ + /* u32 cr = color_rgba( 200, 200, 200, 100 ); + if ( m_installed ) + { + cr = color_rgba( 255, 255, 255, 250 ); + } + m_static->SetColor( cr ); + */ + + if (IsShown()) + { + inherited::Draw(); + } + + // if ( GetVisible() ) + // { + // inherited::Draw(); + // m_static->Draw(); + // } +} diff --git a/src/xrGame/ui/UIWarState.h b/src/xrGame/ui/UIWarState.h new file mode 100644 index 00000000000..0107dfe67be --- /dev/null +++ b/src/xrGame/ui/UIWarState.h @@ -0,0 +1,30 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : UIWarState.h +// Created : 15.04.2008 +// Author : Evgeniy Sokolov +// Description : UI war state (PDA) window class +//////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "UIHint.h" + +class CUIXml; +class CUIStatic; + +class UIWarState : public UIHintWindow +{ + using inherited = UIHintWindow; + + CUIStatic* m_static; + // shared_str m_def_texture; + // bool m_installed; + +public: + UIWarState(); + virtual ~UIWarState() {}; + + void InitXML(CUIXml& xml, LPCSTR att_name, CUIWindow* parent); + void ClearInfo(); + bool UpdateInfo(LPCSTR icon, LPCSTR hint_text); + void Draw() override; +}; // class UIWarState diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj index 8de269893d4..db59e1aba70 100644 --- a/src/xrGame/xrGame.vcxproj +++ b/src/xrGame/xrGame.vcxproj @@ -1403,6 +1403,8 @@ + + @@ -1443,6 +1445,7 @@ + @@ -1537,6 +1540,7 @@ + @@ -3348,6 +3352,8 @@ + + @@ -3420,6 +3426,7 @@ $(IntDir)$(ProjectName)_script.pch + @@ -3593,6 +3600,7 @@ + pch_script.h diff --git a/src/xrGame/xrGame.vcxproj.filters b/src/xrGame/xrGame.vcxproj.filters index 4268a10f3a5..3cb82580b09 100644 --- a/src/xrGame/xrGame.vcxproj.filters +++ b/src/xrGame/xrGame.vcxproj.filters @@ -2293,6 +2293,9 @@ {0ca5d322-0181-4fae-9706-95107e18fdc5} + + {49c6af0a-ea09-4212-bc7f-7cbcca7c5810} + @@ -6664,6 +6667,18 @@ Core\Client\Objects\zones\Ameba + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + @@ -10183,6 +10198,18 @@ Core\Client\Objects\zones\Ameba + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + + + UI\Common\PDA\FractionWar + diff --git a/src/xrScriptEngine/script_engine.cpp b/src/xrScriptEngine/script_engine.cpp index a2a24f3d34b..ae2800653cd 100644 --- a/src/xrScriptEngine/script_engine.cpp +++ b/src/xrScriptEngine/script_engine.cpp @@ -1260,7 +1260,9 @@ void CScriptEngine::on_error(lua_State* state) } CScriptProcess* CScriptEngine::CreateScriptProcess(shared_str name, shared_str scripts) -{ return new CScriptProcess(this, name, scripts); } +{ + return new CScriptProcess(this, name, scripts); +} CScriptThread* CScriptEngine::CreateScriptThread(LPCSTR caNamespaceName, bool do_string, bool reload) { diff --git a/src/xrServerEntities/script_net_packet_script.cpp b/src/xrServerEntities/script_net_packet_script.cpp index fb978ff8757..e70e030864e 100644 --- a/src/xrServerEntities/script_net_packet_script.cpp +++ b/src/xrServerEntities/script_net_packet_script.cpp @@ -7,6 +7,7 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrServer_Object_Base.h" #include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; @@ -29,7 +30,7 @@ ClientID r_clientID(NET_Packet* self) return clientID; } -extern u16 script_server_object_version(); +//extern u16 script_server_object_version(); SCRIPT_EXPORT(ClientID, (), { module(luaState)[class_("ClientID") diff --git a/src/xrServerEntities/xrServer_Object_Base.h b/src/xrServerEntities/xrServer_Object_Base.h index e20183dd0d1..93d1ed5e265 100644 --- a/src/xrServerEntities/xrServer_Object_Base.h +++ b/src/xrServerEntities/xrServer_Object_Base.h @@ -181,4 +181,6 @@ class CSE_Abstract : public IServerEntity, public CPureServerObject, public CScr virtual CSE_ALifeItemPDA* cast_item_pda() { return nullptr; }; }; +extern u16 script_server_object_version(); + #pragma warning(pop)