puzzle ui
This commit is contained in:
@@ -322,6 +322,7 @@ namespace Game
|
||||
Level& level = GetInstance().GameLevel;
|
||||
auto& window = GetShared().Window;
|
||||
auto& staticCards = Puzzle::GetStaticPuzzleData().Cards;
|
||||
auto& visuals = Puzzle::GetStaticPuzzleData().Visuals;
|
||||
|
||||
Transform& camTransform = GetInstance().Player.PlayerCamTransform;
|
||||
camTransform.UpdateMatrix();
|
||||
@@ -360,8 +361,11 @@ namespace Game
|
||||
|
||||
bool isValid = Puzzle::IsValid(card.RefCard);
|
||||
|
||||
// Tile
|
||||
tile.EData.Visible = true;
|
||||
tile.EData.ModelH = isValid ? staticCards[card.RefCard.Idx].ModelHandle : staticCards[0].ModelHandle;
|
||||
tile.EData.DotColor = visuals.TileDotColor;
|
||||
tile.EData.BaseColor = visuals.TileBaseColor;
|
||||
|
||||
Vec3 cardPos = {
|
||||
(float)card.Position.X * Puzzle::Config::CardScaleWorld,
|
||||
@@ -375,10 +379,12 @@ namespace Game
|
||||
tile.EData.Transform.SetPosition(cardPos);
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||
|
||||
// Quad
|
||||
quad.EData.Visible = isValid;
|
||||
quad.EData.TextureHandle =
|
||||
isValid ? staticCards[card.RefCard.Idx].BoardTextureHandle : Gen::TextureHandle{};
|
||||
quad.EData.DotColor = card.IsLocked ? Vec4{0.0f, 0.0f, 0.0f, 0.0f} : Vec4{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
quad.EData.DotColor = card.IsLocked ? Puzzle::GetStaticPuzzleData().Visuals.DisabledCardTint
|
||||
: Vec4{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
quad.EData.Transform = boardTransform;
|
||||
quad.EData.Transform.TranslateLocal(Vec3{(float)card.Position.X, (float)card.Position.Y, 0.0f} *
|
||||
@@ -394,14 +400,20 @@ namespace Game
|
||||
camTransform.GetPosition(), mousePosWorld, quadPosWorld, quadXWorld, quadZWorld, intersectPos))
|
||||
{
|
||||
Vec3 quadSpaceIntersect = quad.EData.Transform.GlobalToLocalPoint(intersectPos);
|
||||
if (quadSpaceIntersect.x >= -1.0f && quadSpaceIntersect.x <= 1.0f &&
|
||||
if (isValid && quadSpaceIntersect.x >= -1.0f && quadSpaceIntersect.x <= 1.0f &&
|
||||
quadSpaceIntersect.z >= -1.0f && quadSpaceIntersect.z <= 1.0f)
|
||||
{
|
||||
if (isValid && !card.IsLocked && DraggedCard.X == -1 &&
|
||||
GetMouseButtonPressedNow(MouseButton::Left))
|
||||
if (!card.IsLocked && DraggedCard.X == -1)
|
||||
{
|
||||
DraggedCard.X = x;
|
||||
DraggedCard.Y = y;
|
||||
if (GetMouseButtonPressedNow(MouseButton::Left))
|
||||
{
|
||||
DraggedCard.X = x;
|
||||
DraggedCard.Y = y;
|
||||
}
|
||||
if (GetMouseButtonPressedNow(MouseButton::Right))
|
||||
{
|
||||
Puzzle::RotateCard(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,8 +433,7 @@ namespace Game
|
||||
|
||||
if (GetMouseButtonPressedNow(MouseButton::Right))
|
||||
{
|
||||
srcCard.Rotation += 1;
|
||||
if (srcCard.Rotation >= 4) srcCard.Rotation = 0;
|
||||
Puzzle::RotateCard(srcCard);
|
||||
}
|
||||
|
||||
if (!GetMouseButton(MouseButton::Left))
|
||||
|
||||
@@ -271,6 +271,11 @@ namespace Puzzle
|
||||
ImGui::InvisibleButton("cardbn",
|
||||
{Puzzle::Config::CardSize * UIPuzBoxSize, Puzzle::Config::CardSize * UIPuzBoxSize});
|
||||
}
|
||||
void RotateCard(PlacedPuzzleCard& card)
|
||||
{
|
||||
card.Rotation += 1;
|
||||
if (card.Rotation >= 4) card.Rotation = 0;
|
||||
}
|
||||
|
||||
void WritePuzzleFilePath(char* buf, int32_t bufSize, uint16_t puzID)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Puzzle
|
||||
PuzzleElementType::Enum GetCardNodeAt(const StaticPuzzleCard& card, uint8_t rotation, int8_t x, int8_t y);
|
||||
PuzzleElementType::Enum& EditCardNodeAt(StaticPuzzleCard& card, uint8_t rotation, int8_t x, int8_t y);
|
||||
void DrawCard(const StaticPuzzleCard& card, uint8_t rotation, ImVec2 pos);
|
||||
void RotateCard(PlacedPuzzleCard& card);
|
||||
|
||||
// TODO: targetPos is of type CardPos
|
||||
bool ReturnPlacedCard(PuzzleData& obj, PuzPos targetPos);
|
||||
|
||||
@@ -197,24 +197,6 @@ namespace Tools
|
||||
Vec3 quadPos = level.UIQuads.Get({0}).EData.Transform.GetPosition();
|
||||
ImGui::Text("%f %f %f", quadPos.x, quadPos.y, quadPos.z);
|
||||
|
||||
auto& puzzleVisuals = Puzzle::GetStaticPuzzleData().Visuals;
|
||||
if (ImGui::ColorEdit3("Tile Base Color", &puzzleVisuals.TileBaseColor.x))
|
||||
{
|
||||
auto& tiles = level.PuzzleTiles;
|
||||
for (int32_t i = 0; i < tiles.Count; ++i)
|
||||
{
|
||||
tiles.Data[i].EData.BaseColor = puzzleVisuals.TileBaseColor;
|
||||
}
|
||||
}
|
||||
if (ImGui::ColorEdit3("Tile Dot Color", &puzzleVisuals.TileDotColor.x))
|
||||
{
|
||||
auto& tiles = level.PuzzleTiles;
|
||||
for (int32_t i = 0; i < tiles.Count; ++i)
|
||||
{
|
||||
tiles.Data[i].EData.DotColor = puzzleVisuals.TileDotColor;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Shader log:");
|
||||
ImGui::TextWrapped("%s", Game::GetShared().Dev.ShaderLog);
|
||||
}
|
||||
@@ -282,6 +264,7 @@ namespace Tools
|
||||
if (ImGui::Begin("Cards"))
|
||||
{
|
||||
Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
|
||||
|
||||
if (ImGui::Button("Save"))
|
||||
{
|
||||
Puzzle::SaveStaticPuzzleData();
|
||||
@@ -292,6 +275,12 @@ namespace Tools
|
||||
Puzzle::LoadStaticPuzzleData();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::ColorEdit3("Disabled Tint", &staticData.Visuals.DisabledCardTint.x);
|
||||
ImGui::ColorEdit3("Tile Base Color", &staticData.Visuals.TileBaseColor.x);
|
||||
ImGui::ColorEdit3("Tile Dot Color", &staticData.Visuals.TileDotColor.x);
|
||||
|
||||
for (int32_t i = 0; i < BX_COUNTOF(staticData.Cards); ++i)
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user