...
 
Commits (3)
......@@ -82,10 +82,12 @@ const std::vector<std::map<SkillInfoMicroicons, bool>>& ActionBox::GetPickedSkil
bool ActionBox::ProcessInput(const char input)
{
bool ending = false;
for (int i = 0; i < keyToSkill.size(); i++)
{
if (input == keyToSkill[i])
{
bool blocked = false;
switch (pickedSkills[i]->get()->ProcessPress())
{
case finish:
......@@ -95,7 +97,7 @@ bool ActionBox::ProcessInput(const char input)
}
pickedSkills[i]->get()->Activate();
SPI::Play(Sounds::ABoxSkillPress);
return true;
ending = true;
break;
case normalContinue: //can only be returned by quick, non-rewind skills
pickedSkills[i]->get()->SetAvalibility(false);
......@@ -116,13 +118,30 @@ bool ActionBox::ProcessInput(const char input)
break;
case blockedIgnore:
SPI::Play(Sounds::ABoxBlockedPress);
blocked = true;
break;
default:
break;
}
if (!blocked)
switch (i)
{
case 0:
SetPressedKey(Key::W);
break;
case 1:
SetPressedKey(Key::A);
break;
case 2:
SetPressedKey(Key::S);
break;
case 3:
SetPressedKey(Key::D);
break;
}
}
}
return false;
return ending;
}
bool ActionBox::UpdateTurnState() //not intuitive
......
......@@ -3,6 +3,7 @@
#include <vector>
#include "./Framework/Vec2.h"
#include "Skills0.h"
#include "PressableMenu.h"
struct ABoxDrawingInfo
{
......@@ -17,7 +18,7 @@ enum class SkillInfoMicroicons
Upgraded
};
class ActionBox
class ActionBox : public PressableMenu
{
public:
ActionBox(std::vector<std::unique_ptr<class Skill>>& skillPool);
......
#include "EffectHandler.h"
#include "Framework/BindableCommon.h"
#include "Framework/TransformCbuf2D.h"
Effect2DData EffectDataInterpolate(Effect2DData e1, Effect2DData e2, float progress)
{
return Effect2DData(e1*(1.0f-progress)+e2*progress);
}
HudEffect::HudEffect(DXGraphics& gfx, Effect2DSequence data, std::wstring spriteName) :effectSequence(data), gfx(gfx)
{
using namespace Bind;
namespace dx = DirectX;
using Dvtx::VertexLayout;
Technique standard;
{
Step only(3);
std::shared_ptr<Texture> tex = Texture::Resolve(gfx, spriteName);
float aspectRatio = (float)tex->GetWidth() / (float)tex->GetHeight();
float screenAspecrRatio = (float)gfx.GetScreenWidth() / (float)gfx.GetScreenHeight();
float totalAR = aspectRatio / screenAspecrRatio;
only.AddBindable(std::move(tex));
only.AddBindable(Bind::Sampler::Resolve(gfx)); //for filtering
Dvtx::VertexBuffer vbuf(std::move(
VertexLayout{}
.Append(VertexLayout::Position2D)
.Append(VertexLayout::Texture2D)
));
if (aspectRatio <= 1.0f) //streching in right direction
{
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * -1.0f, 1.0f }, dx::XMFLOAT2{ 0.0f, 0.0f }); //assembling a rectangle of 2 triangles
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * 1.0f, -1.0f }, dx::XMFLOAT2{ 1.0f, 1.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * -1.0f, -1.0f }, dx::XMFLOAT2{ 0.0f, 1.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * -1.0f, 1.0f }, dx::XMFLOAT2{ 0.0f, 0.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * 1.0f, 1.0f }, dx::XMFLOAT2{ 1.0f, 0.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ totalAR * 1.0f, -1.0f }, dx::XMFLOAT2{ 1.0f, 1.0f });
}
else
{
totalAR = 1.0f / totalAR;
vbuf.EmplaceBack(dx::XMFLOAT2{ -1.0f,totalAR * 1.0f }, dx::XMFLOAT2{ 0.0f, 0.0f }); //assembling a rectangle of 2 triangles
vbuf.EmplaceBack(dx::XMFLOAT2{ 1.0f, totalAR * -1.0f }, dx::XMFLOAT2{ 1.0f, 1.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ -1.0f,totalAR * -1.0f }, dx::XMFLOAT2{ 0.0f, 1.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ -1.0f,totalAR * 1.0f }, dx::XMFLOAT2{ 0.0f, 0.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ 1.0f,totalAR * 1.0f }, dx::XMFLOAT2{ 1.0f, 0.0f });
vbuf.EmplaceBack(dx::XMFLOAT2{ 1.0f, totalAR * -1.0f }, dx::XMFLOAT2{ 1.0f, 1.0f });
}
std::vector<unsigned short> indices{ 0,1,2,3,4,5 };
only.AddBindable(PixelShader::Resolve(gfx, L"HUDEffectPS.cso"));
auto pvs = VertexShader::Resolve(gfx, L"HudVS.cso");
auto pvsbc = pvs->GetBytecode();
only.AddBindable(InputLayout::Resolve(gfx, vbuf.GetLayout(), pvsbc));
only.AddBindable(std::move(pvs));
const auto meshTag = L"HUDEffect" + spriteName;
pVertices = VertexBuffer::Resolve(gfx, meshTag, vbuf);
pIndices = IndexBuffer::Resolve(gfx, meshTag, indices);
pTopology = Topology::Resolve(gfx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
only.AddBindable(Blender::Resolve(gfx, true));
only.AddBindable(std::make_shared<TransformCbuf2D>(gfx));
auto pcb = std::make_shared<PixelConstantBuffer<EffectCBuff>>(gfx, 3);
cbuf = pcb;
only.AddBindable(pcb);
standard.AddStep(only); //is not moved to preserve the object
}
AddTechnique(std::move(standard));
BindPositionData(&refPosData);
refPosData.emplace_back();
}
HudEffect::HudEffect(HudEffect&& mvFrom):
HudElement(std::move(mvFrom)),
cbData (std::move(mvFrom.cbData)),
refPosData (std::move(mvFrom.refPosData)),
cbuf (std::move(mvFrom.cbuf )),
effectSequence (std::move(mvFrom.effectSequence)),
gfx (std::move(mvFrom.gfx)){}
bool HudEffect::UpdateData(float dt)
{
auto nd = effectSequence.Update(dt);
if (nd.has_value())
{
refPosData[0].pos.x = nd->posX;
refPosData[0].pos.y = nd->posY;
refPosData[0].rot.x = nd->scale;
cbData.fillness = nd->opacity;
cbuf->Update(gfx, cbData);
return 0;
}
else return 1;
}
EffectHandler::EffectHandler(DXGraphics& gfx)
{
EffectHandler::gfx = &gfx;
}
void EffectHandler::AddEffect2D(Effect2DSequence data, std::wstring spriteName)
{
e2d.push_back(std::make_unique<HudEffect>(*gfx, data, spriteName));
}
void EffectHandler::AddEffect2D(PositionData posData,Effect e)
{
switch (e)
{
case Effect::Shine:
{
Effect2DSequence e2ds;
e2ds.AddStage({ posData.pos.x,posData.pos.y,0.0f,0.0f }, 0.1f);
e2ds.AddStage({ posData.pos.x,posData.pos.y,posData.rot.x,0.9f }, 0.3f);
e2ds.AddStage({ posData.pos.x,posData.pos.y,posData.rot.x,0.0f }, 0.0f);
EffectHandler::AddEffect2D(e2ds, L"Media\\Sprites\\effect_shine.png");
break;
}
case Effect::Sparks:
{
e2df.push_back(std::make_unique<Effect2DPhysics>(30u, posData, 1.0f, 10.0f, 1.5f, 0.95f, L"Media\\Sprites\\effect_particle1.png", *gfx));
break;
}
default:
break;
}
}
void EffectHandler::SubmitAndUpdate(FrameCommander& fc, float dt)
{
e2d.erase(std::remove_if(e2d.begin(), e2d.end(), [dt](std::unique_ptr<HudEffect>& o) {return o->UpdateData(dt); }),e2d.end());
for (const auto& e : e2d)e->SmartSubmit(fc);
for (auto& e : e2df)
{
e->SubmitAndUpdateParticles(fc, dt);
}
e2df.erase(std::remove_if(e2df.begin(), e2df.end(), [](std::unique_ptr <Effect2DPhysics>& o) {return o->isDead; }), e2df.end());
}
std::optional<Effect2DData> Effect2DSequence::Update(float dt) //make friend of handler
{
currentStageTime += dt;
for (;;)
{
if (currentStageTime < stageTimes[0u])
{
return std::optional<Effect2DData>(EffectDataInterpolate(stages[0u], stages[1u], currentStageTime / stageTimes[0u]));
}
else
{
currentStageTime -= stageTimes[0u];
stages.erase(stages.begin());
stageTimes.erase(stageTimes.begin());
if (stageTimes.size() == 1u) return std::optional<Effect2DData>(); //no more data to interpolate, the effect has done its job
}
}
}
Effect2DPhysics::Effect2DPhysics(size_t particleCount, PositionData particleOrigin, float speedMin, float speedMax, float lifeTime, float friction, std::wstring sprite, DXGraphics& gfx):
lifeTime(lifeTime),
particleSprite(sprite, gfx)
{
PositionData po = particleOrigin;
po.rot.x *= partScale; //scaling down
for (size_t i = 0; i < particleCount; i++)
{
partPos.push_back(po);
auto speed = RU.GetFloat(speedMin, speedMax);
auto speedDist = RU.GetFloat0to1();
partVel.emplace_back(RU.GetBool()?speed * speedDist : -speed * speedDist, RU.GetBool() ? speed * (1.0f - speedDist): -speed * (1.0f - speedDist), friction);
}
particleSprite.BindPositionData(&partPos);
}
void Effect2DPhysics::SubmitAndUpdateParticles(FrameCommander& fc, float dt)
{
curTime += dt;
if (curTime <= lifeTime)
{
for (size_t i = 0; i < partPos.size(); i++)
{
partPos[i].pos.x += (partVel[i].pos.x * dt);
partPos[i].pos.y += (partVel[i].pos.y * dt);
partVel[i].pos.x *= (partVel[i].rot.x);
partVel[i].pos.y *= (partVel[i].rot.x);
}
}
else
{
isDead = true;
partPos.clear();
partVel.clear();
}
if (partPos.size())
{
particleSprite.SmartSubmit(fc);
}
}
std::vector<std::unique_ptr<HudEffect>> EffectHandler::e2d;
std::vector<std::unique_ptr<Effect2DPhysics>> EffectHandler::e2df;
DXGraphics* EffectHandler::gfx;
\ No newline at end of file
#pragma once
#include "Framework\Vec3.h"
#include "Framework\HudElement.h"
#include "Framework\FrameCommander.h"
#include "RandomUnit.h"
struct Effect2DData
{
Effect2DData(float pX, float pY, float scale, float opacity) : posX(pX), posY(pY), scale(scale), opacity(opacity) {}
Effect2DData operator*(float f)
{
Effect2DData e2d(posX * f, posY * f, scale * f, opacity * f);
return e2d;
}
Effect2DData operator+(Effect2DData in)
{
Effect2DData e2d(posX + in.posX, posY + in.posY, scale + in.scale, opacity + in.opacity);
return e2d;
}
float posX;
float posY;
float scale;
float opacity;
};
#ifndef EFFECT2DDATAINTERPOL
#define EFFECT2DDATAINTERPOL
Effect2DData EffectDataInterpolate(Effect2DData e1, Effect2DData e2, float progress);
#endif
class Effect2DSequence //sequence of Effect2DData
{
public:
Effect2DSequence() = default; //thisobject must be constructed manually due to undefined number of arguments (and my incompetence in handling such things with template metagrogramming)
void AddStage(Effect2DData e2d, float time) //time is the time of iterplation from this stage to the next one. for last stage time is supposed to be 0;
{ stages.push_back(e2d); stageTimes.push_back(time); }
std::optional<Effect2DData> Update(float dt);
private:
std::vector<Effect2DData> stages;
std::vector<float>stageTimes;
float currentStageTime = 0.0f;
};
class Effect2DPhysics //Effect2DData, transformed according gravity
{
public:
Effect2DPhysics(size_t particleCount, PositionData particleOrigin, float speedMin, float speedMax, float lifeTime, float friction, std::wstring sprite, DXGraphics& gfx);
Effect2DPhysics(Effect2DPhysics&&) = default;
Effect2DPhysics& operator=(Effect2DPhysics&&) = default;
void SubmitAndUpdateParticles(FrameCommander& fc, float dt); //make friend of handler
bool isDead = false;
private:
std::vector<PositionData> partPos;
std::vector<PositionData> partVel; //here PositionData.pos represents velocities and .rot - acceleration
HudElement particleSprite;
float curTime = 0.0f;
const float lifeTime;
static constexpr float partScale = 0.025f;
};
class HudEffect : public HudElement
{
public:
HudEffect(DXGraphics& gfx, Effect2DSequence data, std::wstring spriteName);
HudEffect(HudEffect&&);
HudEffect(const HudEffect&) = delete;
HudEffect& operator = (HudEffect&&) = default;
HudEffect& operator = (const HudEffect&) = delete;
bool UpdateData(float dt); //returns 1 if object is dead
private:
struct EffectCBuff
{
float fillness;
float pad1;
float pad2;
float pad3;
};
EffectCBuff cbData;
std::vector<PositionData> refPosData;
std::shared_ptr <Bind::PixelConstantBuffer<EffectCBuff>> cbuf;
Effect2DSequence effectSequence;
DXGraphics& gfx;
};
class EffectHandler
{
public:
enum class Effect
{
Shine,
Sparks
};
EffectHandler(DXGraphics& gfx);
static void AddEffect2D(Effect2DSequence data, std::wstring spriteName);
static void AddEffect2D(PositionData posData, Effect e);
void SubmitAndUpdate(FrameCommander& fc, float dt); //can be made a friend
private:
static std::vector<std::unique_ptr<HudEffect>> e2d; //uses pointers because HudElement cant be copied
static std::vector<std::unique_ptr<Effect2DPhysics>> e2df;
static DXGraphics* gfx;
};
......@@ -176,10 +176,11 @@
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ArmorBar.h" />
<ClInclude Include="HPBar.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="ChiliXM.h" />
<ClInclude Include="DynamicConstant.h" />
<ClInclude Include="EffectHandler.h" />
<ClInclude Include="Framework\Bindable.h" />
<ClInclude Include="Framework\BindableCodex.h" />
<ClInclude Include="Framework\BindableCommon.h" />
......@@ -234,7 +235,6 @@
<ClInclude Include="Framework\VertexBuffer.h" />
<ClInclude Include="Framework\VertexShader.h" />
<ClInclude Include="Framework\WindowsThrowMacros.h" />
<ClInclude Include="HealthBar.h" />
<ClInclude Include="imgui\imconfig.h" />
<ClInclude Include="imgui\imgui.h" />
<ClInclude Include="imgui\ImguiManager.h" />
......@@ -247,14 +247,11 @@
<ClInclude Include="InitiativeBar.h" />
<ClInclude Include="IntentIcons.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="RewardMenu.h" />
<ClInclude Include="PressableMenu.h" />
<ClInclude Include="SideButtons.h" />
<ClInclude Include="LevelMap.h" />
<ClInclude Include="MainMenuHolder.h" />
<ClInclude Include="Menu.h" />
<ClInclude Include="Scenario3D.h" />
<ClInclude Include="ABox.h" />
<ClInclude Include="ABoxSupporter.h" />
<ClInclude Include="ActionBoxConstructor.h" />
<ClInclude Include="ChanceOnlyRBox.h" />
<ClInclude Include="Char0ActionBox.h" />
......@@ -340,9 +337,7 @@
<ClInclude Include="StatusBar.h" />
<ClInclude Include="StatusIcons.h" />
<ClInclude Include="TextDrawingUnit.h" />
<ClInclude Include="TopPanel.h" />
<ClInclude Include="TurnAnnouncer.h" />
<ClInclude Include="TutorialHolder.h" />
<ClInclude Include="TutorialSlide.h" />
<ClInclude Include="VirtualRBox.h" />
<ClInclude Include="WallsETC.h" />
......@@ -352,7 +347,9 @@
<ClCompile Include="ABox.cpp" />
<ClCompile Include="ABoxSupporter.cpp" />
<ClCompile Include="ActionBox.cpp" />
<ClCompile Include="ArmorBar.cpp" />
<ClCompile Include="EffectHandler.cpp" />
<ClCompile Include="Framework\FrameCommander.cpp" />
<ClCompile Include="HPBar.cpp" />
<ClCompile Include="Camera.cpp" />
<ClCompile Include="ChiliXM.cpp" />
<ClCompile Include="CombatEntity.cpp" />
......@@ -436,7 +433,6 @@
<ClCompile Include="Framework\VertexShader.cpp" />
<ClCompile Include="Game.cpp" />
<ClCompile Include="Ghoul.cpp" />
<ClCompile Include="HealthBar.cpp" />
<ClCompile Include="HUD.cpp" />
<ClCompile Include="imgui\imgui.cpp" />
<ClCompile Include="imgui\ImguiManager.cpp" />
......@@ -552,6 +548,14 @@
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="HUDEffectPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
</FxCompile>
<FxCompile Include="HudPS.hlsl">
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
......
......@@ -61,6 +61,9 @@
<Filter Include="Header Files\commentedOut\SkillTypes">
<UniqueIdentifier>{ef7df50d-1335-4b95-a59d-8b22319adaf9}</UniqueIdentifier>
</Filter>
<Filter Include="Shaders\old%3f">
<UniqueIdentifier>{cfb9c46f-01e4-447d-a79a-57f68129f11e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Resource.h">
......@@ -165,9 +168,6 @@
<ClInclude Include="SkillStuff\DustThrow.h">
<Filter>Header Files\commentedOut\0Skills</Filter>
</ClInclude>
<ClInclude Include="SkillStuff\SkillConstructor.h">
<Filter>Header Files\Skills</Filter>
</ClInclude>
<ClInclude Include="SkillStuff\AbilityGeneralTypes.h">
<Filter>Header Files\Skills</Filter>
</ClInclude>
......@@ -240,15 +240,6 @@
<ClInclude Include="HUD.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="ABoxSupporter.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="TopPanel.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="ABox.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="DummySkill.h">
<Filter>Header Files\commentedOut\0Skills</Filter>
</ClInclude>
......@@ -261,9 +252,6 @@
<ClInclude Include="Menu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MainMenuHolder.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="TutorialSlide.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
......@@ -537,9 +525,6 @@
<ClInclude Include="Scenarios.h">
<Filter>Header Files\commentedOut</Filter>
</ClInclude>
<ClInclude Include="TutorialHolder.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="CombatEntity.h">
<Filter>Header Files</Filter>
</ClInclude>
......@@ -549,18 +534,12 @@
<ClInclude Include="SkillStuff\0SkillList.h">
<Filter>Header Files\commentedOut</Filter>
</ClInclude>
<ClInclude Include="HealthBar.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="StatusBar.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="StatusIcons.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="ArmorBar.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="SkillStuff\StandartSkill.h">
<Filter>Header Files\Skills</Filter>
</ClInclude>
......@@ -573,10 +552,19 @@
<ClInclude Include="SkillMicroicons.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="RewardMenu.h">
<ClInclude Include="WASDPanels.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="EffectHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HPBar.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
<ClInclude Include="WASDPanels.h">
<ClInclude Include="SkillStuff\SkillConstructor.h">
<Filter>Header Files\commentedOut</Filter>
</ClInclude>
<ClInclude Include="PressableMenu.h">
<Filter>Header Files\HUDs</Filter>
</ClInclude>
</ItemGroup>
......@@ -839,18 +827,12 @@
<ClCompile Include="CombatEntity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HealthBar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StatusBar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StatusIcons.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ArmorBar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="IntentIcons.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -869,56 +851,29 @@
<ClCompile Include="WASDPanels.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HPBar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EffectHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Framework\FrameCommander.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="FramebufferPS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="FramebufferVS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PixelShader.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="SolidVS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="SolidPS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="VertexShader.hlsl">
<Filter>Source Files</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpec.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpecNormalMap.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpecNormMask.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongVS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongVSNormalMap.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongVSNotex.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPSNormalMap.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPSNormalMapObject.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongPSNotex.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="ShaderOps.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
......@@ -955,6 +910,45 @@
<FxCompile Include="InitBarPS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="FramebufferVS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="FramebufferPS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongPS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongPSNotex.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpec.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpecNormalMap.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongPSSpecNormMask.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongVS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PhongVSNotex.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="PixelShader.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="SolidPS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="SolidVS.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="HUDEffectPS.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
......
......@@ -28,8 +28,8 @@ struct PositionData
~PositionData() = default;
PositionData& operator=(PositionData pd);
PositionData& operator=(PositionData&& pd);
DirectX::XMFLOAT3 pos = { 0.0f,0.0f,0.0f };
DirectX::XMFLOAT3 rot = { 0.0f,0.0f,0.0f };
DirectX::XMFLOAT3 pos = { 0.0f,0.0f,0.0f }; //for 2d objects first 2 coordinates mean x and y
DirectX::XMFLOAT3 rot = { 0.0f,0.0f,0.0f }; //and first coordinate here means scale
};
struct LetterData
{
......
#include "FrameCommander.h"
void FrameCommander::Execute(DXGraphics& gfx, float dt) const noxnd
{
using namespace Bind;
// main phong lighting pass
Stencil::Resolve(gfx, Stencil::Mode::Off)->Bind(gfx);
passes[0].Execute(gfx);
// outline masking pass
//Stencil::Resolve(gfx, Stencil::Mode::Write)->Bind(gfx);
//NullPixelShader::Resolve(gfx)->Bind(gfx);
//passes[1].Execute(gfx);
//// outline drawing pass
//Stencil::Resolve(gfx, Stencil::Mode::Mask)->Bind(gfx);
//passes[2].Execute(gfx);
Stencil::Resolve(gfx, Stencil::Mode::HUD)->Bind(gfx); //::HUD
passes[3].Execute(gfx);
passes[4].Execute(gfx); //text
} //if the passes need to be rearranged in some way
//than all darwables that depend on them should be ajusted accordingly
void FrameCommander::Reset() noexcept
{
for (auto& p : passes)
{
p.Reset();
}
}
\ No newline at end of file
......@@ -5,47 +5,15 @@
#include "Job.h"
#include "Pass.h"
class FrameCommander
class FrameCommander //submits drawables
{
public:
void Accept( Job job,size_t target ) noexcept
{
passes[target].Accept( job );
}
void Execute( DXGraphics& gfx ) const noxnd
{
using namespace Bind;
// normally this would be a loop with each pass defining it setup / etc.
// and later on it would be a complex graph with parallel execution contingent
// on input / output requirements
// main phong lighting pass
Stencil::Resolve( gfx,Stencil::Mode::Off )->Bind( gfx );
passes[0].Execute( gfx );
// outline masking pass
Stencil::Resolve( gfx,Stencil::Mode::Write)->Bind( gfx );
NullPixelShader::Resolve( gfx )->Bind( gfx );
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;
//PixelConstantBuffer<SolidColorBuffer>::Resolve( gfx,scb,1u )->Bind( gfx );
passes[2].Execute( gfx );
Stencil::Resolve(gfx, Stencil::Mode::HUD)->Bind(gfx); //::HUD
passes[3].Execute(gfx);
passes[4].Execute(gfx); //text
} //if the passes need to be rearranged in some way
//than all darwables that depend on them should be ajusted accordingly
void Reset() noexcept
{
for( auto& p : passes )
{
p.Reset();
}
}
private:
void Execute(DXGraphics& gfx, float dt) const noxnd;
void Reset() noexcept;
private:
std::array<Pass, 5> passes;
};
\ No newline at end of file
......@@ -223,6 +223,14 @@ DirectX::XMMATRIX HudElement::GetTransformXMSpecific(size_t ind) const noexcept
return std::move(encoded);
}
PositionData HudElement::GetCumulatedPosData(size_t ind) const noexcept
{
auto trans = GetTransformXMSpecific(ind);
DirectX::XMFLOAT4X4 dec;
DirectX::XMStoreFloat4x4(&dec, trans);
return PositionData(dec._11, dec._12, dec._13);
}
void HudElement::BindPositionData(const std::vector<PositionData>* posData)
{
this->posData = posData;
......
......@@ -17,6 +17,7 @@ public:
virtual ~HudElement() = default;
DirectX::XMMATRIX GetTransformXM() const noexcept override;
DirectX::XMMATRIX GetTransformXMSpecific(size_t ind) const noexcept; //extracts transform of specific object and does not desturb the currentObjectBeingDrawn variable
PositionData GetCumulatedPosData(size_t ind = 0u) const noexcept; //extracts pos data according to parent's transforms
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 UnbindParents();
......
......@@ -10,8 +10,6 @@
using namespace std::string_literals;
namespace dx = DirectX;
......@@ -22,7 +20,8 @@ Game::Game()
ll(wnd.DXGfx(),fc,cm),
td(wnd.DXGfx(),fc),
hud(menu,fc, wnd.DXGfx(),cm.GetPlayerManager().GetActionBox(),cm),
menu(cm)
menu(cm),
eh(wnd.DXGfx())
//gfx( wnd.GetHWND() ),
//scene(gfx,map,menu)
{
......@@ -39,6 +38,11 @@ Game::Game()
int Game::Go()
{
while(true)
{
if (isExiting)break;
......@@ -87,39 +91,37 @@ int Game::Go()
//planeTN.Submit(fc);
ll.SubmitDrawables();
cm.Draw(wnd.DXGfx());
eh.SubmitAndUpdate(fc, dt);
td.SubmitText(dt);
fc.Execute(wnd.DXGfx());
//if (!wnd.CursorEnabled())
//{
// if (wnd.kbd.KeyIsPressed('W'))
// {
// cam.Translate({ 0.0f,0.0f,dt });
// }
// if (wnd.kbd.KeyIsPressed('A'))
// {
// cam.Translate({ -dt,0.0f,0.0f });
// }
// if (wnd.kbd.KeyIsPressed('S'))
// {
// cam.Translate({ 0.0f,0.0f,-dt });
// }
// if (wnd.kbd.KeyIsPressed('D'))
// {
// cam.Translate({ dt,0.0f,0.0f });
// }
// if (wnd.kbd.KeyIsPressed('R'))
// {
// cam.Translate({ 0.0f,dt,0.0f });
// }
// if (wnd.kbd.KeyIsPressed('F'))
// {
// cam.Translate({ 0.0f,-dt,0.0f });
// }
//}
fc.Execute(wnd.DXGfx(),dt);
/*if (!wnd.CursorEnabled())
{
if (wnd.kbd.KeyIsPressed('W'))
{
cam.Translate({ 0.0f,0.0f,dt });
}
if (wnd.kbd.KeyIsPressed('A'))
{
cam.Translate({ -dt,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed('S'))
{
cam.Translate({ 0.0f,0.0f,-dt });
}
if (wnd.kbd.KeyIsPressed('D'))
{
cam.Translate({ dt,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed('R'))
{
cam.Translate({ 0.0f,dt,0.0f });
}
if (wnd.kbd.KeyIsPressed('F'))
{
cam.Translate({ 0.0f,-dt,0.0f });
}
}*/
while (const auto delta = wnd.mouse.ReadRawDelta())
{
......
......@@ -24,6 +24,10 @@
#include "./Framework/LevelLayout.h"
#include"./Framework/TextDrawer.h"
#include "EffectHandler.h"
class Game
{
public:
......@@ -34,7 +38,6 @@ public:
private:
void ComposeFrame();
void UpdateModel();
void ProcessInput();
private:
ImguiManager imgui;
......@@ -43,7 +46,6 @@ private:
SoundPlayer snd;
FrameTimer timer;
float speed_factor = 1.0f;
//LevelMap map;
Camera cam;
PointLight light;
float dt=0.0f;
......@@ -56,4 +58,7 @@ private:
TextDrawer td;
Menu menu;//menu before HUD
HUD hud;
EffectHandler eh;
};
\ No newline at end of file
......@@ -9,12 +9,12 @@
#include "InitiativeBar.h"
#include "WASDPanels.h"
HUD::HUD(Menu& menu, FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox, const CombatManager& cm) : //will require a rework to support any number of skills other than 4
HUD::HUD(const Menu& menu, FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox, const CombatManager& cm) : //will require a rework to support any number of skills other than 4
menu(menu), fc(fc), gfx(gfx), cd(cm.GetCombatDataReference())
{
elements.emplace(std::make_pair(Element::ActionBox, std::make_unique<ABox>(gfx, abox)));
elements.emplace(std::make_pair(Element::MainMenuHolder,std::make_unique<MainMenuHolder>(gfx)));
elements.emplace(std::make_pair(Element::TutorialHolder,std::make_unique<TutorialHolder>(gfx)));
elements.emplace(std::make_pair(Element::MainMenuHolder,std::make_unique<MainMenuHolder>(gfx,menu)));
elements.emplace(std::make_pair(Element::TutorialHolder,std::make_unique<TutorialHolder>(gfx,menu)));
elements.emplace(std::make_pair(Element::RightButton, std::make_unique<SideButton>(gfx, SideButton::Side::Right)));
elements.emplace(std::make_pair(Element::LeftButton, std::make_unique<SideButton>(gfx, SideButton::Side::Left)));
elements.emplace(std::make_pair(Element::TutorialSlide1,std::make_unique<TutorialSlide>(L"Media\\Sprites\\tut1.png", gfx)));
......@@ -26,13 +26,13 @@ HUD::HUD(Menu& menu, FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox,
elements.emplace(std::make_pair(Element::EnemyStatusBar,std::make_unique<EnemyStatusBar>(cm.GetCombatDataReference(), gfx)));
elements.emplace(std::make_pair(Element::IntentIcon, std::make_unique<IntentIconManager>(cm.GetCombatDataReference(), gfx)));
elements.emplace(std::make_pair(Element::InitiativeBar, std::make_unique<InitiativeBar>(gfx, cm.GetCombatDataReference())));
elements.emplace(std::make_pair(Element::RewardMenu, std::make_unique<RewardMenu>(gfx, cm)));
elements.emplace(std::make_pair(Element::RewardMenu, std::make_unique<RewardMenu>(gfx, cm, menu)));
}
void HUD::Submit() const
{
auto ms = menu.GetMenuState();
prevState = ms;
ms = menu.GetMenuState();
switch (ms)
{
case Menu::MenuState::Main:
......@@ -92,9 +92,16 @@ void HUD::Submit() const
elements.at(Element::InitiativeBar)->SmartSubmit(fc);
elements.at(Element::RewardMenu)->SmartSubmit(fc);
break;
case Menu::MenuState::None:
break;
default:
assert(false && "MissedMenuState");
break;
}
//help effect work properly
if (ms!=prevState)
if(prevState== Menu::MenuState::Main)elements.at(Element::MainMenuHolder)->SmartSubmit(fc);
else if (prevState == Menu::MenuState::Tutorial_Selection)elements.at(Element::TutorialHolder)->SmartSubmit(fc);
else if (prevState == Menu::MenuState::ChoosingReward)elements.at(Element::RewardMenu)->SmartSubmit(fc);
}
......@@ -26,10 +26,12 @@ class HUD //responsible for drawing hud
InitiativeBar
};
public:
HUD(Menu& menu,FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox,const CombatManager& cm);
HUD(const Menu& menu,FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox,const CombatManager& cm);
void Submit()const;
private:
Menu& menu; //const?
const Menu& menu;
mutable Menu::MenuState ms = Menu::MenuState::None;
mutable Menu::MenuState prevState = Menu::MenuState::None; //helps execute some effects correctly
FrameCommander& fc;
DXGraphics& gfx;
const CombatData& cd;
......
cbuffer TransformCBuf : register(b3)
{
float opacity;
float3 padding;
};
Texture2D tex;
SamplerState splr;
float4 main(float2 pos : Position, float2 tc : Texcoord) : SV_Target
{
float4 dtex;
dtex = tex.Sample(splr, tc);
return float4((opacity * dtex).rgba);
}
......@@ -5,6 +5,7 @@ bool Menu::Update(Keyboard::Event in_event)
{
if (in_event.IsPress())
{
SetPressedKey(Key::None);
if (cm.IsReturningToMenu())mState = Menu::MenuState::Main;
if(cm.GetRewardMenuActiveness())mState = Menu::MenuState::ChoosingReward;
auto code = in_event.GetCode();
......@@ -15,17 +16,21 @@ bool Menu::Update(Keyboard::Event in_event)
{
mState = MenuState::Inactive;
cm.StartBattle(0);
SetPressedKey(Key::W);
}
else if (code == 'D')
{
SetPressedKey(Key::D);
return 1;
}
else if (code == 'A')
{
SetPressedKey(Key::A);
mState = MenuState::Achivements;
}
else if (code == 'S')
{
SetPressedKey(Key::S);
mState = MenuState::Tutorial_Selection;
}
break;
......@@ -38,18 +43,22 @@ bool Menu::Update(Keyboard::Event in_event)
case Menu::MenuState::Tutorial_Selection:
if (code == 'W')
{
SetPressedKey(Key::W);
mState = MenuState::Tutorial1;
}
else if (code == 'A')
{
SetPressedKey(Key::A);
mState = MenuState::SkillInfo;
}
else if (code == 'S')
{
SetPressedKey(Key::S);
mState = MenuState::OtherInfo;
}
else if (code == 'D')
{
SetPressedKey(Key::D);
mState = MenuState::Main;
}
break;
......@@ -120,22 +129,26 @@ bool Menu::Update(Keyboard::Event in_event)
case Menu::MenuState::ChoosingReward:
if (code == 'W')
{
SetPressedKey(Key::W);
cm.ChoseBandage();
mState = MenuState::Inactive;
}
if (code == 'A')
{
cm.ChoseCrit();
SetPressedKey(Key::A);
cm.ChoseDodge();
mState = MenuState::Inactive;
}
if (code == 'S')
{
SetPressedKey(Key::S);
cm.ChoseUpgrade();
mState = MenuState::Inactive;
}
if (code == 'D')
{
cm.ChoseDodge();
SetPressedKey(Key::D);
cm.ChoseCrit();
mState = MenuState::Inactive;
}
break;
......
#pragma once
#include "Framework/Keyboard.h"
#include "CombatManager.h"
class Menu //handles main menu logic
#include "PressableMenu.h"
class Menu : public PressableMenu //handles main menu logic
{
public:
Menu(CombatManager& cm) :cm(cm) {};
......@@ -18,9 +19,10 @@ public:
Tutorial4,
Tutorial5,
ChoosingReward,
Inactive
Inactive,
None
};
MenuState GetMenuState()
MenuState GetMenuState() const
{
return mState;
}
......
#pragma once
class PressableMenu
{
public:
enum class Key
{
W, A, S, D, None
};
Key GetPressedKey() const {return pressedKey; };
void KeyAcquired() const { pressedKey = Key::None; };
protected:
void SetPressedKey(Key in) { pressedKey = in; }
private:
mutable Key pressedKey = Key::None;
};
\ No newline at end of file
......@@ -18,3 +18,9 @@ float RandomUnit::GetFloat0to1()
return dist(rng);
}
bool RandomUnit::GetBool()
{
static std::uniform_int_distribution<size_t> dist(0u,1u);
return static_cast<bool>(dist(rng));
}
......@@ -10,6 +10,7 @@ public:
size_t GetUInt(size_t low, size_t high) ;
float GetFloat(float low, float high) ;
float GetFloat0to1() ;
bool GetBool();
private:
std::random_device rd;
std::mt19937 rng;
......
#include "WASDPanels.h"
#include "EffectHandler.h"
WASDPanel::WASDPanel(DXGraphics& gfx):
HudElement(L"Media\\Sprites\\WASDPanel.png", gfx)
......@@ -17,35 +18,81 @@ void WASDPanel::SmartSubmit(FrameCommander& fc) const
this->Submit(fc, Techniques::Standart);
}
MainMenuHolder::MainMenuHolder(DXGraphics& gfx) :WASDPanel(gfx)
MainMenuHolder::MainMenuHolder(DXGraphics& gfx, const Menu& menu):
WASDPanel(gfx),
menu(menu)
{
myPosData.emplace_back(0.0f, 0.0f, BigScale);
panels.emplace(std::make_pair(Position::W, std::make_unique<HudElement>(L"Media\\Sprites\\menu_play.png", gfx)));
panels.emplace(std::make_pair(Position::A, std::make_unique<HudElement>(L"Media\\Sprites\\menu_achievements.png", gfx)));
panels.emplace(std::make_pair(Position::S, std::make_unique<HudElement>(L"Media\\Sprites\\menu_tutorial.png", gfx)));
panels.emplace(std::make_pair(Position::D, std::make_unique<HudElement>(L"Media\\Sprites\\menu_quit.png", gfx)));
panels.at(Position::W)->BindPositionData(&panelPositions[0]);
panels.at(Position::A)->BindPositionData(&panelPositions[1]);
panels.at(Position::S)->BindPositionData(&panelPositions[2]);
panels.at(Position::D)->BindPositionData(&panelPositions[3]);
panels.emplace(std::make_pair(PressableMenu::Key::W, std::make_unique<HudElement>(L"Media\\Sprites\\menu_play.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::A, std::make_unique<HudElement>(L"Media\\Sprites\\menu_achievements.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::S, std::make_unique<HudElement>(L"Media\\Sprites\\menu_tutorial.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::D, std::make_unique<HudElement>(L"Media\\Sprites\\menu_quit.png", gfx)));
panels.at(PressableMenu::Key::W)->BindPositionData(&panelPositions[0]);
panels.at(PressableMenu::Key::A)->BindPositionData(&panelPositions[1]);
panels.at(PressableMenu::Key::S)->BindPositionData(&panelPositions[2]);
panels.at(PressableMenu::Key::D)->BindPositionData(&panelPositions[3]);
for (auto& pan : panels) pan.second->AddParent(this, 0u);
}
RewardMenu::RewardMenu(DXGraphics& gfx, const CombatManager& cm) :
void MainMenuHolder::SmartSubmit(FrameCommander& fc) const
{
for (auto& s : panels) s.second->SmartSubmit(fc);
this->Submit(fc, Techniques::Standart);
const auto key = menu.GetPressedKey();
if (key != PressableMenu::Key::None)
{
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Shine);
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Sparks);
menu.KeyAcquired();
}
}
TutorialHolder::TutorialHolder(DXGraphics& gfx, const Menu& menu):
WASDPanel(gfx),
cm(cm)
menu(menu)
{
myPosData.emplace_back(0.0f, 0.0f, BigScale);
panels.emplace(std::make_pair(PressableMenu::Key::W, std::make_unique<HudElement>(L"Media\\Sprites\\menu_howToPlay.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::A, std::make_unique<HudElement>(L"Media\\Sprites\\menu_skills.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::S, std::make_unique<HudElement>(L"Media\\Sprites\\menu_other.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::D, std::make_unique<HudElement>(L"Media\\Sprites\\menu_back.png", gfx)));
panels.at(PressableMenu::Key::W)->BindPositionData(&panelPositions[0]);
panels.at(PressableMenu::Key::A)->BindPositionData(&panelPositions[1]);
panels.at(PressableMenu::Key::S)->BindPositionData(&panelPositions[2]);
panels.at(PressableMenu::Key::D)->BindPositionData(&panelPositions[3]);
for (auto& pan : panels) pan.second->AddParent(this, 0u);
}
void TutorialHolder::SmartSubmit(FrameCommander& fc) const
{
for (auto& s : panels) s.second->SmartSubmit(fc);
this->Submit(fc, Techniques::Standart);
const auto key = menu.GetPressedKey();
if (key != PressableMenu::Key::None)
{
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Shine);
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Sparks);
menu.KeyAcquired();
}
}
RewardMenu::RewardMenu(DXGraphics& gfx, const CombatManager& cm, const Menu& menu) :
WASDPanel(gfx),
cm(cm),
menu(menu)
{
myPosData.emplace_back(0.0f, 0.0f, MediumScale);
panels.emplace(std::make_pair(Position::W, std::make_unique<HudElement>(L"Media\\Sprites\\RewardBandage.png", gfx)));
panels.emplace(std::make_pair(Position::A, std::make_unique<HudElement>(L"Media\\Sprites\\RewardDodge.png", gfx)));
panels.emplace(std::make_pair(Position::S, std::make_unique<HudElement>(L"Media\\Sprites\\RewardUpgrade.png", gfx)));
panels.emplace(std::make_pair(Position::D, std::make_unique<HudElement>(L"Media\\Sprites\\RewardCrit.png", gfx)));
panels.at(Position::W)->BindPositionData(&panelPositions[0]);
panels.at(Position::A)->BindPositionData(&panelPositions[1]);
panels.at(Position::S)->BindPositionData(&panelPositions[2]);
panels.at(Position::D)->BindPositionData(&panelPositions[3]);
panels.emplace(std::make_pair(PressableMenu::Key::W, std::make_unique<HudElement>(L"Media\\Sprites\\RewardBandage.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::A, std::make_unique<HudElement>(L"Media\\Sprites\\RewardDodge.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::S, std::make_unique<HudElement>(L"Media\\Sprites\\RewardUpgrade.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::D, std::make_unique<HudElement>(L"Media\\Sprites\\RewardCrit.png", gfx)));
panels.at(PressableMenu::Key::W)->BindPositionData(&panelPositions[0]);
panels.at(PressableMenu::Key::A)->BindPositionData(&panelPositions[1]);
panels.at(PressableMenu::Key::S)->BindPositionData(&panelPositions[2]);
panels.at(PressableMenu::Key::D)->BindPositionData(&panelPositions[3]);
for (auto& pan : panels) pan.second->AddParent(this, 0u);
}
......@@ -56,22 +103,13 @@ void RewardMenu::SmartSubmit(FrameCommander& fc) const
for (auto& s : panels) s.second->SmartSubmit(fc);
this->Submit(fc, Techniques::Standart);
}
}
TutorialHolder::TutorialHolder(DXGraphics& gfx) :
WASDPanel(gfx)
{
myPosData.emplace_back(0.0f, 0.0f, BigScale);
panels.emplace(std::make_pair(Position::W, std::make_unique<HudElement>(L"Media\\Sprites\\menu_howToPlay.png", gfx)));
panels.emplace(std::make_pair(Position::A, std::make_unique<HudElement>(L"Media\\Sprites\\menu_skills.png", gfx)));
panels.emplace(std::make_pair(Position::S, std::make_unique<HudElement>(L"Media\\Sprites\\menu_other.png", gfx)));
panels.emplace(std::make_pair(Position::D, std::make_unique<HudElement>(L"Media\\Sprites\\menu_back.png", gfx)));
panels.at(Position::W)->BindPositionData(&panelPositions[0]);
panels.at(Position::A)->BindPositionData(&panelPositions[1]);
panels.at(Position::S)->BindPositionData(&panelPositions[2]);
panels.at(Position::D)->BindPositionData(&panelPositions[3]);
for (auto& pan : panels) pan.second->AddParent(this, 0u);
const auto key = menu.GetPressedKey();
if (key != PressableMenu::Key::None)
{
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Shine);
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Sparks);
menu.KeyAcquired();
}
}
ABox::ABox(DXGraphics& gfx, const ActionBox& actBox) :
......@@ -107,6 +145,18 @@ ABox::ABox(DXGraphics& gfx, const ActionBox& actBox) :
skillMicroicons.emplace(std::make_pair(SkillInfoMicroicons::Rewinding, std::make_unique<SkillMicroicon>(gfx, L"Media//Sprites//skillIcon_rewinding.png")));
skillMicroicons.emplace(std::make_pair(SkillInfoMicroicons::TurnEnder, std::make_unique<SkillMicroicon>(gfx, L"Media//Sprites//skillIcon_turnEnder.png")));
skillMicroicons.emplace(std::make_pair(SkillInfoMicroicons::Upgraded, std::make_unique<SkillMicroicon>(gfx, L"Media//Sprites//skillIcon_upgraded.png")));
//adding reference panels for effects
panels.emplace(std::make_pair(PressableMenu::Key::W, std::make_unique<HudElement>(L"Media\\Sprites\\blank.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::A, std::make_unique<HudElement>(L"Media\\Sprites\\blank.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::S, std::make_unique<HudElement>(L"Media\\Sprites\\blank.png", gfx)));
panels.emplace(std::make_pair(PressableMenu::Key::D, std::make_unique<HudElement>(L"Media\\Sprites\\blank.png", gfx)));
panels.at(PressableMenu::Key::W)->BindPositionData(&panelPositions[0]);
panels.at(PressableMenu::Key::A)->BindPositionData(&panelPositions[1]);
panels.at(PressableMenu::Key::S)->BindPositionData(&panelPositions[2]);
panels.at(PressableMenu::Key::D)->BindPositionData(&panelPositions[3]);
for (auto& pan : panels) pan.second->AddParent(this, 0u);
}
void ABox::SmartSubmit(FrameCommander& fc) const
......@@ -159,6 +209,14 @@ void ABox::SmartSubmit(FrameCommander& fc) const
}
for (auto& s : skillMicroicons) s.second->SmartSubmit(fc);
this->Submit(fc, Techniques::Standart);
//submiting effects
const auto key = actBox.GetPressedKey();
if (actBox.GetPressedKey() != PressableMenu::Key::None)
{
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Shine);
EffectHandler::AddEffect2D(panels.at(key)->GetCumulatedPosData(), EffectHandler::Effect::Sparks);
actBox.KeyAcquired();
}
}
std::vector<std::vector<PositionData>> ABox::posSkill;
\ No newline at end of file
#pragma once
#include "Framework\HudElement.h"
#include "CombatManager.h"
#include "Menu.h"
class WASDPanel :public HudElement //derived classes are to bind panels position data(&panelPositions[i]);
// and set this object as their parent. panels -> AddParent(this);
......@@ -9,17 +10,11 @@ class WASDPanel :public HudElement //derived classes are to bind panels positio
public:
WASDPanel(DXGraphics& gfx);
void SmartSubmit(FrameCommander& fc) const override;
protected:
enum class Position
{
W,
A,
S,
D
};
std::vector<PositionData> myPosData;
std::vector<std::vector<PositionData>> panelPositions;
std::unordered_map<Position, std::unique_ptr<HudElement>> panels;
std::unordered_map<PressableMenu::Key, std::unique_ptr<HudElement>> panels;
static constexpr float BigScale = 0.625f;
static constexpr float MediumScale = 0.325f;
static constexpr float SmallScale = 0.125f;
......@@ -28,23 +23,27 @@ protected:
class MainMenuHolder :public WASDPanel
{
public:
MainMenuHolder(DXGraphics& gfx);
MainMenuHolder(DXGraphics& gfx,const Menu& menu);
void SmartSubmit(FrameCommander& fc) const override;
const Menu& menu;
};
class TutorialHolder :public WASDPanel
{
public:
TutorialHolder(DXGraphics& gfx, const Menu& menu);
void SmartSubmit(FrameCommander& fc) const override;
const Menu& menu;
};
class RewardMenu :public WASDPanel
{
public:
RewardMenu(DXGraphics& gfx, const CombatManager& cm);
RewardMenu(DXGraphics& gfx, const CombatManager& cm, const Menu& menu);
void SmartSubmit(FrameCommander& fc)const override;
private:
const CombatManager& cm;
};
class TutorialHolder :public WASDPanel
{
public:
TutorialHolder(DXGraphics& gfx);
const Menu& menu;
};
#pragma once
......