Skip to content

Commit

Permalink
Fix warnings and update subprojects
Browse files Browse the repository at this point in the history
  • Loading branch information
pinguin999 committed Nov 8, 2024
1 parent f2e6d6a commit d19f691
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 58 deletions.
22 changes: 9 additions & 13 deletions src/background.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "background.hpp"

#include "jngl/matrix.hpp"
#include "skeleton_drawable.hpp"
#include "game.hpp"

Expand Down Expand Up @@ -67,25 +68,22 @@ bool Background::stepClickableRegions(bool force)

void Background::draw() const
{
jngl::pushMatrix();
jngl::translate(position);
jngl::rotate(getRotation());

#ifndef NDEBUG
if (auto _game = game.lock())
{
skeleton->debugdraw = _game->enableDebugDraw;
}
#endif

skeleton->draw();
auto mv = jngl::modelview().translate(position).rotate(getRotation());
skeleton->draw(mv);

#ifndef NDEBUG
if (auto _game = game.lock())
{
if (_game->enablezMapDebugDraw && sprite)
{
sprite->draw();
sprite->draw(mv);
}
}
#endif
Expand All @@ -102,7 +100,7 @@ void Background::draw() const
{
if (hasPathTo(_game->player->getPosition(), corner))
{
jngl::drawLine(_game->player->getPosition(), corner);
jngl::drawLine(mv, _game->player->getPosition(), corner);
}
}

Expand All @@ -111,7 +109,7 @@ void Background::draw() const
{
for (size_t i = 1; i < forbidden_area.size(); i++)
{
jngl::drawLine(forbidden_area.at(i), forbidden_area.at(i - 1));
jngl::drawLine(mv, forbidden_area.at(i), forbidden_area.at(i - 1));
}
}

Expand All @@ -122,7 +120,7 @@ void Background::draw() const
{
if (hasPathTo(_game->player->getPosition(), forbidden_corner))
{
jngl::drawLine(_game->player->getPosition(), forbidden_corner);
jngl::drawLine(mv, _game->player->getPosition(), forbidden_corner);
}
}
}
Expand All @@ -131,7 +129,7 @@ void Background::draw() const
auto debugPath = getPathToTarget(_game->player->getPosition(), _game->pointer->getWorldPosition());
for (size_t i = 1; i < debugPath.size(); i++)
{
jngl::drawLine(debugPath[i - 1], debugPath[i]);
jngl::drawLine(mv, debugPath[i - 1], debugPath[i]);
}
}

Expand All @@ -141,7 +139,7 @@ void Background::draw() const
auto pos = getPoint(point_name);
if (pos)
{
jngl::drawCircle(jngl::modelview().translate(jngl::Vec2(pos->x, pos->y)), 1);
jngl::drawCircle(jngl::Mat3(mv).translate(jngl::Vec2(pos->x, pos->y)), 1);
jngl::Text bbname;
bbname.setText(point_name);
bbname.setAlign(jngl::Alignment::CENTER);
Expand All @@ -152,8 +150,6 @@ void Background::draw() const
}
}
#endif

jngl::popMatrix();
}

enum class Result {
Expand Down
9 changes: 2 additions & 7 deletions src/dialog/speech_bubble.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "speech_bubble.hpp"
#include "../game.hpp"
#include "jngl/matrix.hpp"
#include <math.h>

SpeechBubble::SpeechBubble(std::shared_ptr<Game> game,
Expand Down Expand Up @@ -28,16 +29,10 @@ void SpeechBubble::draw() const
{
if (auto _game = game.lock())
{
jngl::pushMatrix();
jngl::translate(position);
jngl::rotate(getRotation());

#ifndef NDEBUG
skeleton->debugdraw = _game->enableDebugDraw;
#endif

skeleton->draw();
jngl::popMatrix();
skeleton->draw(jngl::modelview().translate(position).rotate(getRotation()));

jngl::pushMatrix();
jngl::translate(jngl::Vec2{jngl::getScreenSize().x / -2.0 + 50, jngl::getScreenSize().y / 3.5});
Expand Down
5 changes: 2 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Game::Game(const YAML::Node &config) : config(config),
#else
"."s,
#endif
[this](const TYPE &path, const filewatch::Event change_type)
[this](const TYPE &path [[maybe_unused]], const filewatch::Event change_type)
{
switch (change_type)
{
Expand Down Expand Up @@ -185,7 +185,6 @@ void Game::loadSceneWithFade(std::string level)
jngl::setWork<SceneFade>(jngl::getWork(), [this, level]() {
loadScene(level);
});
pointer->setPrimaryHandled();
}else{
loadScene(level);
}
Expand Down Expand Up @@ -420,7 +419,7 @@ void Game::debugStep()
const int target = tens.value() * 10 + x;

int i = 0;
for (const auto & entry : std::filesystem::directory_iterator(path))
for (const auto & entry [[maybe_unused]] : std::filesystem::directory_iterator(path))
{
i++;
}
Expand Down
19 changes: 9 additions & 10 deletions src/interactable_object.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "interactable_object.hpp"

#include "jngl/Mat3.hpp"
#include "skeleton_drawable.hpp"
#include "game.hpp"

Expand Down Expand Up @@ -108,20 +109,20 @@ void InteractableObject::draw() const
return;
}

jngl::pushMatrix();
auto mv = jngl::modelview();
if (abs_position)
{
jngl::reset();
mv = jngl::Mat3();
if (auto _game = game.lock())
{
jngl::scale(_game->getCameraZoom());
mv.scale(_game->getCameraZoom());
}
}
else
{
jngl::translate(position);
mv.translate(position);
}
jngl::rotate(getRotation());
mv.rotate(getRotation());

#ifndef NDEBUG
if (auto _game = game.lock())
Expand All @@ -130,26 +131,24 @@ void InteractableObject::draw() const
}
#endif

skeleton->draw();
skeleton->draw(mv);

#ifndef NDEBUG
if (auto _game = game.lock())
{
if (_game->editMode)
{
const float DEBUG_GRAP_DISTANCE = (*_game->lua_state)["config"]["debug_grap_distance"];
jngl::drawCircle(jngl::Vec2(0, 0), DEBUG_GRAP_DISTANCE);
jngl::drawCircle(mv, DEBUG_GRAP_DISTANCE);
jngl::Text pposition;
pposition.setText("x: " + std::to_string(position.x) + "\ny: " + std::to_string(position.y));
jngl::setFontColor(jngl::Rgba(1.0, 0, 0, 1.0));
pposition.setAlign(jngl::Alignment::CENTER);
pposition.setCenter(0, 0);
pposition.draw();
pposition.draw(mv);
}
}
#endif

jngl::popMatrix();
}

void InteractableObject::goToPosition(jngl::Vec2 position, const sol::function &callback)
Expand Down
9 changes: 3 additions & 6 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,10 @@ bool Player::step(bool /*force*/)

void Player::draw() const
{
jngl::pushMatrix();
jngl::translate(position);
jngl::rotate(getRotation());
auto mv = jngl::modelview().translate(position).rotate(getRotation());
if (auto _game = game.lock())
{
jngl::scale(_game->currentScene->getScale(position));
mv.scale(_game->currentScene->getScale(position));
}

#ifndef NDEBUG
Expand All @@ -299,8 +297,7 @@ void Player::draw() const
}
#endif

skeleton->draw();
jngl::popMatrix();
skeleton->draw(mv);
}

void Player::setTargentPosition(jngl::Vec2 position)
Expand Down
10 changes: 2 additions & 8 deletions src/pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "input/gamepad.hpp"
#include "input/keyboard.hpp"
#include "jngl/matrix.hpp"
#include "skeleton_drawable.hpp"
#include "game.hpp"

Expand Down Expand Up @@ -139,16 +140,11 @@ bool Pointer::step(bool)

void Pointer::draw() const
{
jngl::pushMatrix();
jngl::translate(position);
jngl::rotate(getRotation());

#ifndef NDEBUG
if (auto _game = game.lock())
{
if (_game->editMode)
{
jngl::popMatrix();
return;
}
}
Expand All @@ -161,9 +157,7 @@ void Pointer::draw() const
}
#endif

skeleton->draw();

jngl::popMatrix();
skeleton->draw(jngl::modelview().translate(position).rotate(getRotation()));
}

void Pointer::vibrate()
Expand Down
8 changes: 4 additions & 4 deletions src/skeleton_drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void SkeletonDrawable::setAlpha(float alpha) {
this->alpha = alpha;
}

void SkeletonDrawable::draw() const {
void SkeletonDrawable::draw(const jngl::Mat3& modelview) const {
unsigned short quadIndices[6] = { 0, 1, 2, 2, 3, 0 };

static auto *blancColor = new spColor();
Expand Down Expand Up @@ -177,9 +177,9 @@ void SkeletonDrawable::draw() const {
}else{
for (int i = 0; i < box->super.verticesCount - 2; i += 2)
{
jngl::drawLine(jngl::Vec2{bbvertices[i], bbvertices[i + 1]},jngl::Vec2{bbvertices[i + 2], bbvertices[i + 3]});
jngl::drawLine(modelview, {bbvertices[i], bbvertices[i + 1]}, {bbvertices[i + 2], bbvertices[i + 3]});
}
jngl::drawLine(jngl::Vec2{bbvertices[box->super.verticesCount - 2], bbvertices[box->super.verticesCount - 1]}, jngl::Vec2{bbvertices[0], bbvertices[1]});
jngl::drawLine(modelview, {bbvertices[box->super.verticesCount - 2], bbvertices[box->super.verticesCount - 1]}, {bbvertices[0], bbvertices[1]});
}
jngl::Text bbname;
bbname.setText(box->super.super.name);
Expand Down Expand Up @@ -227,7 +227,7 @@ void SkeletonDrawable::draw() const {
if (texture)
{
jngl::setSpriteColor(r, g, b, a * alpha);
texture->drawMesh(vertexArray);
texture->drawMesh(modelview, vertexArray);
jngl::setSpriteColor(255, 255, 255, 255);
}

Expand Down
8 changes: 4 additions & 4 deletions src/skeleton_drawable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ _SP_ARRAY_DECLARE_TYPE(spColorArray, spColor)

namespace spine {

class SkeletonDrawable : public jngl::Drawable {
class SkeletonDrawable {
public:
spSkeleton* skeleton;
spAnimationState* state;
float timeScale;

explicit SkeletonDrawable(spSkeletonData* skeleton, spAnimationStateData* stateData = 0);
~SkeletonDrawable() override;
~SkeletonDrawable();

void endAnimation(int trackIndex) const;

void step() override;
void step();

void draw() const override;
void draw(const jngl::Mat3& modelview = jngl::modelview()) const;

void setAlpha(float);

Expand Down
2 changes: 1 addition & 1 deletion subprojects/schnacker
Submodule schnacker updated from 28e36b to bcfa0b
2 changes: 1 addition & 1 deletion subprojects/spine-runtimes
Submodule spine-runtimes updated 214 files

0 comments on commit d19f691

Please sign in to comment.