diff --git a/assets/images/teoncreative_logo.png b/assets/images/teoncreative_logo.png index dccd0e3..00e6d34 100644 Binary files a/assets/images/teoncreative_logo.png and b/assets/images/teoncreative_logo.png differ diff --git a/assets/images/teoncreative_logo_white.png b/assets/images/teoncreative_logo_white.png deleted file mode 100644 index 00e6d34..0000000 Binary files a/assets/images/teoncreative_logo_white.png and /dev/null differ diff --git a/src/app/app.cpp b/src/app/app.cpp index 68e2290..0ac3753 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -20,19 +20,41 @@ gApp::~gApp() { } void gApp::setup() { - RenderUtil::Setup(); -// auto* cnv = new GameCanvas(this, CreateRef(), nullptr); - auto* cnv = new LoadingCanvas(this); - appmanager->setCurrentCanvas(cnv); + RenderUtil::Setup(); + cursor_ = new gImage(); + cursor_->loadImage("cursor.png"); + cursor_->setFiltering(2, 2); + cursor_height_ = cursor_->getHeight(); + cursor_width_ = 16; + auto* cnv = new LoadingCanvas(this); + appmanager->setCurrentCanvas(cnv); + appmanager->getWindow()->setCursorMode(0x00034002); // GLFW_CURSOR_HIDDEN + appmanager->setTargetFramerate(1000); } void gApp::update() { } void gApp::stop() { - auto* canvas = appmanager->getCurrentCanvas(); - if (canvas != nullptr) { - canvas->hideNotify(); - delete canvas; - } + auto* canvas = appmanager->getCurrentCanvas(); + if (canvas != nullptr) { + canvas->hideNotify(); + delete canvas; + } +} + +void gApp::SetCursorPos(int x, int y) { + cursor_pos_x_ = x; + cursor_pos_y_ = y; +} + +void gApp::SetCursorType(CursorType type) { + cursor_type_ = type; +} + +void gApp::DrawCursor() { + cursor_->drawSub(cursor_pos_x_ - cursor_width_ * 2, cursor_pos_y_ - cursor_height_, + cursor_width_ * 4, cursor_height_ * 4, + cursor_type_ * 16, 0, + cursor_width_, cursor_height_); } \ No newline at end of file diff --git a/src/app/app.h b/src/app/app.h index fc378af..a4bd9cd 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -1,28 +1,44 @@ /* - * gApp.h - * - * Created on: May 6, 2020 - * Author: noyan - */ +* gApp.h +* +* Created on: May 6, 2020 +* Author: noyan +*/ #ifndef GAPP_H_ #define GAPP_H_ #include "gBaseApp.h" +enum CursorType { + kArrow, + kHand, + kHandClosed +}; class gApp : public gBaseApp { -public: - gApp(); - gApp(int argc, char **argv); - ~gApp(); + public: + gApp(); + gApp(int argc, char **argv); + ~gApp(); + + void setup(); + void update(); + + void stop(); + + void SetCursorPos(int x, int y); + void SetCursorType(CursorType type); + void DrawCursor(); - void setup(); - void update(); + bool loaded_ = false; - void stop(); + private: + gImage* cursor_; + CursorType cursor_type_ = kArrow; + int cursor_width_, cursor_height_; + int cursor_pos_x_ = -100, cursor_pos_y_ = -100; - bool loaded_ = false; }; #endif /* GAPP_H_ */ diff --git a/src/game_canvas.cpp b/src/game_canvas.cpp index 097d6b4..78162eb 100644 --- a/src/game_canvas.cpp +++ b/src/game_canvas.cpp @@ -1,7 +1,7 @@ #include "game_canvas.h" #include "message_canvas.h" -GameCanvas::GameCanvas(gApp* root, Ref connection, Ref thread) : gBaseCanvas(root), connection_(connection), thread_(thread) { +GameCanvas::GameCanvas(gApp* root, Ref connection, Ref thread) : gBaseCanvas(root), root_(root), connection_(connection), thread_(thread) { this->root_ = root; } @@ -20,10 +20,6 @@ void GameCanvas::setup() { player_color_ = kPieceColorWhite; flip_board_ = false; } - cursor_.loadImage("cursor.png"); - cursor_.setFiltering(2, 2); - cursor_height_ = cursor_.getHeight(); - cursor_width_ = 16; board_textures_[0].loadImage("boards/board_persp_01.png"); board_textures_[0].setFiltering(2, 2); board_textures_[1].loadImage("boards/board_persp_01_flipped.png"); @@ -83,9 +79,6 @@ void GameCanvas::setup() { SetInfoText("You lost!"); } }); - appmanager->getWindow()->setCursorMode(0x00034002); // GLFW_CURSOR_HIDDEN - appmanager->setTargetFramerate(120); - connection_->Ready(); } @@ -129,10 +122,7 @@ void GameCanvas::draw() { DrawBoard(); DrawInfoText(); // pos * 2 -> pos * 4 / 2 -> pos * pixelScale / 2 - cursor_.drawSub(cursor_pos_x_ - cursor_width_ * 2, cursor_pos_y_ - cursor_height_, - cursor_width_ * 4, cursor_height_ * 4, - cursor_type_ * 16, 0, - cursor_width_, cursor_height_); + root_->DrawCursor(); /*for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { RenderUtil::DrawFont(gToStr(x) + " " + gToStr(y), @@ -322,8 +312,7 @@ void GameCanvas::charPressed(unsigned int codepoint) { } void GameCanvas::mouseMoved(int x, int y) { - cursor_pos_x_ = x; - cursor_pos_y_ = y; + root_->SetCursorPos(x, y); if (input_lock_ || promoting_ || connection_->GetCurrentTurn() != player_color_) { return; } @@ -346,18 +335,17 @@ void GameCanvas::mouseMoved(int x, int y) { void GameCanvas::mouseDragged(int x, int y, int button) { // gLogi("GameCanvas") << "mouseDragged" << ", x:" << x << ", y:" << y << ", b:" << button; - cursor_pos_x_ = x; - cursor_pos_y_ = y; - cursor_type_ = CursorType::kHandClosed; + root_->SetCursorPos(x, y); + root_->SetCursorType(CursorType::kHandClosed); } void GameCanvas::mousePressed(int x, int y, int button) { // gLogi("GameCanvas") << "mousePressed" << ", x:" << x << ", y:" << y << ", b:" << button; - cursor_type_ = CursorType::kHandClosed; + root_->SetCursorType(CursorType::kHandClosed); } void GameCanvas::mouseReleased(int x, int y, int button) { - cursor_type_ = CursorType::kArrow; + root_->SetCursorType(CursorType::kArrow); if (animate_ || input_lock_ || connection_->GetCurrentTurn() != player_color_) { return; } diff --git a/src/game_canvas.h b/src/game_canvas.h index 9da5b65..fde2f66 100644 --- a/src/game_canvas.h +++ b/src/game_canvas.h @@ -8,11 +8,6 @@ #include "gImage.h" #include "net/packets.h" -enum CursorType { - kArrow, - kHand, - kHandClosed -}; class GameCanvas : public gBaseCanvas { public: @@ -50,8 +45,6 @@ class GameCanvas : public gBaseCanvas { void UpdateFallAnimation(); private: gApp* root_; - gImage cursor_; - int cursor_width_, cursor_height_; gImage board_textures_[2]; gImage outliner_; int board_pos_x, board_pos_y; @@ -84,8 +77,6 @@ class GameCanvas : public gBaseCanvas { bool ended_ = false; PieceColor winner_color_; double dance_anim_time_ = 0.0f; - int cursor_pos_x_ = -100, cursor_pos_y_ = -100; - CursorType cursor_type_ = CursorType::kArrow; private: void SetInfoText(const std::string& text); }; diff --git a/src/loading_canvas.cpp b/src/loading_canvas.cpp index a576240..5ccba5e 100644 --- a/src/loading_canvas.cpp +++ b/src/loading_canvas.cpp @@ -9,7 +9,7 @@ LoadingCanvas::~LoadingCanvas() { } void LoadingCanvas::setup() { - brand_logo_.loadImage("teoncreative_logo_white.png"); + brand_logo_.loadImage("teoncreative_logo.png"); brand_width_ = brand_logo_.getWidth() / 4; brand_height_ = brand_logo_.getHeight() / 4; brand_x_ = (getWidth() - brand_width_) / 2; diff --git a/src/menu_canvas.cpp b/src/menu_canvas.cpp index 59e9113..555505c 100644 --- a/src/menu_canvas.cpp +++ b/src/menu_canvas.cpp @@ -148,7 +148,6 @@ void MenuCanvas::setup() { loading_anim = 0; title = ""; task = nullptr; - appmanager->setTargetFramerate(120); fade_in_ = !root->loaded_; root->loaded_ = true; fade_in_timer_ = 0.0f; @@ -217,6 +216,7 @@ void MenuCanvas::draw() { } RenderUtil::DrawFont(title, getWidth() / 2, 150, {1.0f, 1.0f, 1.0f}, true); setColor(og_color); + root->DrawCursor(); return; } // buttons @@ -226,6 +226,7 @@ void MenuCanvas::draw() { // logo RenderUtil::DrawFont(&logo_font, "Chess Tacos", getWidth() / 2 - logo_font.getStringWidth("Chess Tacos") / 2, 150); setColor(og_color); + root->DrawCursor(); } void MenuCanvas::keyPressed(int key) { @@ -242,6 +243,7 @@ void MenuCanvas::charPressed(unsigned int codepoint) { void MenuCanvas::mouseMoved(int x, int y) { // gLogi("gCanvas") << "mouseMoved" << ", x:" << x << ", y:" << y; + root->SetCursorPos(x, y); if (loading) { return; } @@ -252,10 +254,13 @@ void MenuCanvas::mouseMoved(int x, int y) { void MenuCanvas::mouseDragged(int x, int y, int button) { // gLogi("gCanvas") << "mouseDragged" << ", x:" << x << ", y:" << y << ", b:" << button; + root->SetCursorPos(x, y); + root->SetCursorType(CursorType::kHandClosed); } void MenuCanvas::mousePressed(int x, int y, int button) { // gLogi("gCanvas") << "mousePressed" << ", x:" << x << ", y:" << y << ", b:" << button; + root->SetCursorType(CursorType::kHandClosed); if (loading) { return; } @@ -266,6 +271,7 @@ void MenuCanvas::mousePressed(int x, int y, int button) { void MenuCanvas::mouseReleased(int x, int y, int button) { // gLogi("gCanvas") << "mouseReleased" << ", button:" << button; + root->SetCursorType(CursorType::kArrow); if (loading) { return; } diff --git a/src/message_canvas.cpp b/src/message_canvas.cpp index 6ac934b..8b2a3f0 100644 --- a/src/message_canvas.cpp +++ b/src/message_canvas.cpp @@ -29,6 +29,7 @@ void MessageCanvas::draw() { back_button->Draw(); // logo RenderUtil::DrawFont(message, getWidth() / 2, 300); + root->DrawCursor(); } void MessageCanvas::keyPressed(int key) { diff --git a/znet b/znet index e4233d7..795c576 160000 --- a/znet +++ b/znet @@ -1 +1 @@ -Subproject commit e4233d7a628ed12452d5d8b3f88f53c1c5a3cb65 +Subproject commit 795c576ea372d8847e78ca95f4c216bcb32073de