Commit d19a8553 authored by AL's avatar AL

huge improvements

parent 19f0684a
#include "ABox.h"
ABox::ABox(DXGraphics& gfx, const ActionBox& actBox) :
ABox::ABox(DXGraphics& gfx, const ActionBox& actBox) :
actBox(actBox),
HudElement(L"Media\\Sprites\\pm_ABox.png", gfx),
skillIconInfo(actBox.GetPickedSkillsInfo())
skillIconInfo(actBox.GetPickedSkillsInfo()),
mi(gfx, L"Media\\Sprites\\skillIcon_quick.png")
{
skills.emplace(std::make_pair(Skill0::Inactive, std::make_unique<HudElement>(L"Media//Sprites//SkillSheet.png", gfx, 0, 7, 1)));
skills.emplace(std::make_pair(Skill0::Cut, std::make_unique<HudElement>(L"Media//Sprites//SkillSheet.png", gfx, 1, 7, 1)));
......@@ -26,6 +33,12 @@ ABox::ABox(DXGraphics& gfx, const ActionBox& actBox) :
pos4.emplace_back(0.01f, -0.52f, 0.49f);
pos4.emplace_back(0.61f, -0.52f, 0.49f);
mi.AddDrawingPosition(0u, skills[Skill0::Inactive].get(), 0);
mi.AddDrawingPosition(0u, skills[Skill0::Inactive].get(), 1);
mi.AddDrawingPosition(0u, skills[Skill0::Inactive].get(), 2);
//skillMicroicons.emplace((SkillInfoMicroicons::Quick, std::make_unique<HudElement>(L"Media//Sprites//skillIcon_quick.png", gfx)));
//skillMicroicons.emplace((SkillInfoMicroicons::Rewinding, std::make_unique<HudElement>(L"Media//Sprites//skillIcon_rewinding.png", gfx)));
//skillMicroicons.emplace((SkillInfoMicroicons::TurnEnder, std::make_unique<HudElement>(L"Media//Sprites//skillIcon_turnEnder.png", gfx)));
......@@ -56,7 +69,7 @@ void ABox::SmartSubmit(FrameCommander& fc) const
//submiting skillMicroicons
mi.SmartSubmit(fc);
//for (int i = 0; i < ActionBox::GetPickedSkills().size(); i++) //drawing text over ABox skills
//{
......
......@@ -4,6 +4,7 @@
#include "Skills0.h"
#include <map>
#include "ActionBox.h"
#include "SkillMicroicons.h"
class ABox :public HudElement
{
......@@ -17,5 +18,6 @@ private:
std::unordered_map<Skill0, std::unique_ptr<HudElement>> skills;
const ActionBox& actBox;
const std::vector<std::map<SkillInfoMicroicons, bool>>& skillIconInfo; //idk why is it a vector
SkillMicroicon mi;
//std::map<SkillInfoMicroicons, std::unique_ptr<HudElement>> skillMicroicons;
};
\ No newline at end of file
......@@ -28,10 +28,10 @@ public:
passes[1].Execute( gfx );
// outline drawing pass
Stencil::Resolve( gfx,Stencil::Mode::Mask)->Bind( gfx );
struct SolidColorBuffer
{
DirectX::XMFLOAT4 color = { 0.4f,0.4f,0.4f,1.0f };
} scb;
//struct SolidColorBuffer
//{
// DirectX::XMFLOAT4 color = { 0.4f,0.4f,0.4f,1.0f };
//} scb;
//PixelConstantBuffer<SolidColorBuffer>::Resolve( gfx,scb,1u )->Bind( gfx );
passes[2].Execute( gfx );
Stencil::Resolve(gfx, Stencil::Mode::HUD)->Bind(gfx); //::HUD
......
......@@ -160,9 +160,21 @@ DirectX::XMMATRIX HudElement::GetTransformXM() const noexcept
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f };
if (!parentData.empty())
if (std::get<2>(parentData[0]) == applyParentingToAllObjects)
if (parentData.count(applyParentingToAllObjects))
{
DirectX::XMMATRIX parentTransform = std::get<0>(parentData[0])->GetTransformXMSpecific(std::get<1>(parentData[0]));
auto at = parentData.at(applyParentingToAllObjects);
DirectX::XMMATRIX parentTransform = at.first->GetTransformXMSpecific(at.second);
DirectX::XMFLOAT4X4 parentDec;
DirectX::XMStoreFloat4x4(&parentDec, parentTransform);
store._11 *= parentDec._13;//scaling position offset
store._12 *= parentDec._13;//scaling position offset
store._11 += parentDec._11;//translating
store._12 += parentDec._12;//translating
store._13 *= parentDec._13;//scaling scale
} else if (parentData.count(currentObjectBeingDrawn))
{
auto at = parentData.at(currentObjectBeingDrawn);
DirectX::XMMATRIX parentTransform = at.first->GetTransformXMSpecific(at.second);
DirectX::XMFLOAT4X4 parentDec;
DirectX::XMStoreFloat4x4(&parentDec,parentTransform);
store._11 *= parentDec._13;//scaling position offset
......@@ -175,25 +187,38 @@ DirectX::XMMATRIX HudElement::GetTransformXM() const noexcept
return std::move(encoded);
}
DirectX::XMMATRIX HudElement::GetTransformXMSpecific(size_t ans) const noexcept
DirectX::XMMATRIX HudElement::GetTransformXMSpecific(size_t ind) const noexcept
{
DirectX::XMFLOAT4X4 store{ (*posData)[ans].pos.x,(*posData)[ans].pos.y,
(*posData)[ans].rot.x,0.0f,
DirectX::XMFLOAT4X4 store{ (*posData)[ind].pos.x,(*posData)[ind].pos.y,
(*posData)[ind].rot.x,0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f };
if(!parentData.empty())
if (std::get<2>(parentData[0])== applyParentingToAllObjects)
{
DirectX::XMMATRIX parentTransform = std::get<0>(parentData[0])->GetTransformXMSpecific(std::get<1>(parentData[0]));
DirectX::XMFLOAT4X4 parentDec;
DirectX::XMStoreFloat4x4(&parentDec, parentTransform);
store._11 *= parentDec._13;//scaling position offset
store._12 *= parentDec._13;//scaling position offset
store._11 += parentDec._11;//translating
store._12 += parentDec._12;//translating
store._13 *= parentDec._13;//scaling scale
}
if (!parentData.empty())
if (parentData.count(applyParentingToAllObjects))
{
auto at = parentData.at(applyParentingToAllObjects);
DirectX::XMMATRIX parentTransform = at.first->GetTransformXMSpecific(at.second);
DirectX::XMFLOAT4X4 parentDec;
DirectX::XMStoreFloat4x4(&parentDec, parentTransform);
store._11 *= parentDec._13;//scaling position offset
store._12 *= parentDec._13;//scaling position offset
store._11 += parentDec._11;//translating
store._12 += parentDec._12;//translating
store._13 *= parentDec._13;//scaling scale
}
else if (parentData.count(currentObjectBeingDrawn))
{
auto at = parentData.at(currentObjectBeingDrawn);
DirectX::XMMATRIX parentTransform = at.first->GetTransformXMSpecific(at.second);
DirectX::XMFLOAT4X4 parentDec;
DirectX::XMStoreFloat4x4(&parentDec, parentTransform);
store._11 *= parentDec._13;//scaling position offset
store._12 *= parentDec._13;//scaling position offset
store._11 += parentDec._11;//translating
store._12 += parentDec._12;//translating
store._13 *= parentDec._13;//scaling scale
}
DirectX::XMMATRIX encoded = DirectX::XMLoadFloat4x4(&store);
return std::move(encoded);
}
......@@ -205,10 +230,10 @@ void HudElement::BindPositionData(const std::vector<PositionData>* posData)
void HudElement::AddParent(const HudElement* par, size_t parentInd, size_t objectInd)
{
parentData.push_back( std::make_tuple(par, parentInd, objectInd));
parentData.emplace(objectInd, std::make_pair(par, parentInd));
}
void HudElement::UnboundParents()
void HudElement::UnbindParents()
{
parentData.clear();
}
......
......@@ -19,16 +19,17 @@ public:
DirectX::XMMATRIX GetTransformXMSpecific(size_t ind) const noexcept; //extracts transform of specific object and does not desturb the currentObjectBeingDrawn variable
void BindPositionData(const std::vector<PositionData>* posData);
void AddParent(const HudElement* parent, size_t parentInd = 0u, size_t objectInd = applyParentingToAllObjects); //index in posData that corresponds to the needed object
void UnboundParents();
void UnbindParents();
virtual void SmartSubmit(FrameCommander& fc) const; //uses Submit with standart tecqunice for first draw call
//and consecutive for all the rest in posData
protected:
std::vector<std::tuple<const HudElement*, size_t, size_t>> parentData; //is used to offset coordinates (and scaling) for nested objects
//std::vector<std::tuple<const HudElement*, size_t, size_t>> parentData; //is used to offset coordinates (and scaling) for nested objects
//HudElement* defines the model of parent and size_t defines the
//index in parnt's posData that corresponds to the right one
//second size_t showes to what object is the parent bound
//default value applies parenting to all objects
//could not make it a const pointer for some reason
std::unordered_map<size_t, std::pair<const HudElement*, size_t>> parentData; //object index than parent object than parent object index
mutable size_t currentObjectBeingDrawn = 0;
const std::vector<PositionData>* posData; //for every object there will be one position
......
//#include "SkillMicroicons.h"
//
#include "SkillMicroicons.h"
//void SkillMicroicon::UpdateData(size_t ind, HudElement& parent, size_t parentInd)
//{
// value = val;
......@@ -53,3 +53,18 @@
//{
// if (isActive)HudElement::SmartSubmit(fc);
//}
//
void SkillMicroicon::AddDrawingPosition(size_t ind, const HudElement* parent, size_t parentInd)
{
const float y = 0.63f;
const float x = (1 + ind) * xOffset + size * ind - 1.0f;
posData.emplace_back(x, y, size);
AddParent(parent, parentInd, posData.size() - 1u);
}
void SkillMicroicon::ClearDrawingPositions()
{
UnbindParents();
posData.clear();
}
//#pragma once
//#include "Framework\HudElement.h"
//class SkillMicroicon : protected HudElement
//{
//public:
// virtual ~SkillMicroicon() = default;
// SkillMicroicon(DXGraphics& gfx, std::wstring spriteName) :
// HudElement(spriteName, gfx) {
// BindPositionData(&posData);
// }
// SkillMicroicon& operator = (SkillMicroicon&&) = delete;
// SkillMicroicon(SkillMicroicon&&) = delete;
// void SmartSubmit(FrameCommander& fc) const override;
// const std::vector<PositionData>& GetPosition() const;
// void AddDrawingPosition(size_t ind, HudElement& parent, size_t parentInd); //ind indicates the number (left-to-right) of this icon
// void ClearDrawingPositions();
//protected:
// std::vector<PositionData> posData;
// static constexpr float xOffset = 0.04f;
// static constexpr float size = 0.1f;
//};
\ No newline at end of file
#pragma once
#include "Framework\HudElement.h"
class SkillMicroicon : public HudElement
{
public:
virtual ~SkillMicroicon() = default;
SkillMicroicon(DXGraphics& gfx, std::wstring spriteName) :
HudElement(spriteName, gfx) {
BindPositionData(&posData);
}
SkillMicroicon& operator = (SkillMicroicon&&) = delete;
SkillMicroicon(SkillMicroicon&&) = delete;
//void SmartSubmit(FrameCommander& fc) const override;
//const std::vector<PositionData>& GetPosition() const;
void AddDrawingPosition(size_t ind, const HudElement* parent, size_t parentInd); //ind indicates the number (left-to-right) of this icon
void ClearDrawingPositions();
protected:
std::vector<PositionData> posData;
static constexpr float xOffset = 0.04f;
static constexpr float size = 0.25f;
};
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment