Skip to content

Commit

Permalink
Updated obsolete codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
maroctamorg committed Oct 23, 2021
1 parent 7010114 commit 67910bc
Show file tree
Hide file tree
Showing 52 changed files with 112 additions and 189 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
# platform-specific files
Makefile

# build
build/Tsukuyomi.a

# escaped build files
*.o
14 changes: 7 additions & 7 deletions Makefiles/Makefile_linux
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ CC = g++
CFLAGS = -std=c++17
INCLUDE = `sdl2-config --cflags --libs`
LINKER_FLAGS = -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf -pthread
LIB_GRAPH_SOURCES = $(patsubst %, engine/graphics/%, graphics_context.cpp image.cpp rectangles.cpp text.cpp)
LIB_GRAPH_SOURCES = $(patsubst %, graphics/%, graphics_context.cpp image.cpp rectangles.cpp text.cpp)
LIB_GRAPH_OBJECT_FILES = $(shell basename -a ${LIB_GRAPH_SOURCES:.cpp=.o})
LIB_UI_SOURCES = $(patsubst %, engine/ui/%, text.cpp event.cpp button.cpp input.cpp layout.cpp menu.cpp pannel.cpp ui_element.cpp)
LIB_UI_SOURCES = $(patsubst %, ui/%, text.cpp event.cpp button.cpp input.cpp layout.cpp menu.cpp pannel.cpp ui_element.cpp)
LIB_UI_OBJECT_FILES = $(shell basename -a ${LIB_UI_SOURCES:.cpp=.o})
TARGET = Tsukuyomi
TARGET = Tsukuyomi.a

all: build_all run
all: build link

build_all: build_lib_graph build_lib_ui link
build: build_lib_graph build_lib_ui link

build_lib_graph:
@echo "\nBuilding GRAPHICS library..."
Expand All @@ -24,9 +24,9 @@ build_lib_ui:

link:
@echo "\nLinking App..."
${CC} -o ${TARGET} $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES}) ${LINKER_FLAGS}
ar rs ${TARGET} $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES})
mv ${TARGET} build/

cleanup:
@echo "\nCleaning up..."
rm $(patsubst %, build/%, ${LIB_GRAPH_OBJECT_FILES} ${LIB_UI_OBJECT_FILES})
rm $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES})
15 changes: 7 additions & 8 deletions Makefiles/Makefile_macOS
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ CC = g++
CFLAGS = -std=c++17
FRAMEWORKS = -F/Library/Frameworks
LINKER_FLAGS = -F/Library/Frameworks/ -framework SDL2 -framework SDL2_image -framework SDL2_ttf -framework SDL2_mixer
LIB_GRAPH_SOURCES = $(patsubst %, engine/graphics/%, graphics_context.cpp image.cpp rectangles.cpp text.cpp)
LIB_GRAPH_SOURCES = $(patsubst %, graphics/%, graphics_context.cpp image.cpp rectangles.cpp text.cpp)
LIB_GRAPH_OBJECT_FILES = $(shell basename -a ${LIB_GRAPH_SOURCES:.cpp=.o})
LIB_UI_SOURCES = $(patsubst %, engine/ui/%, text.cpp event.cpp button.cpp input.cpp layout.cpp menu.cpp pannel.cpp ui_element.cpp)
LIB_UI_SOURCES = $(patsubst %, ui/%, text.cpp event.cpp button.cpp input.cpp layout.cpp menu.cpp pannel.cpp ui_element.cpp)
LIB_UI_OBJECT_FILES = $(shell basename -a ${LIB_UI_SOURCES:.cpp=.o})
TARGET = Tsukuyomi
TARGET = Tsukuyomi.a

all: build_all run
all: build link

build_all: build_lib_graph build_lib_ui link
build: build_lib_graph build_lib_ui link

build_lib_graph:
@echo "\nBuilding GRAPHICS library..."
Expand All @@ -24,10 +24,9 @@ build_lib_ui:

link:
@echo "\nLinking App..."
${CC} -o ${TARGET} $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES}) ${LINKER_FLAGS}
ar rs ${TARGET} $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES})
mv ${TARGET} build/

cleanup:
@echo "\nCleaning up..."
rm $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES})
rm $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES})
rm $(patsubst %, build/graph/%, ${LIB_GRAPH_OBJECT_FILES}) $(patsubst %, build/ui/%, ${LIB_UI_OBJECT_FILES})
File renamed without changes.
3 changes: 3 additions & 0 deletions build/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
*/
!.gitignore
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions src/graphics/rectangles.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "rectangles.hpp"
#include <iostream>

void drawBaseRects (SDL_Renderer* renderer, const SDL_Rect& rect, const SDL_Color& color, const SDL_Color& border_color, int r) {
SDL_Rect core { rect.x + r, rect.y + r, rect.w - 2*r, rect.h - 2*r };
SDL_Rect left { rect.x, rect.y + r, r, rect.h - 2*r };
SDL_Rect right { rect.x + rect.w - r, rect.y + r, r, rect.h - 2*r };
SDL_Rect top { rect.x + r, rect.y, rect.w - 2*r, r };
SDL_Rect bottom { rect.x + r, rect.y + rect.h - r, rect.w - 2*r, r };

SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
SDL_RenderFillRect(renderer, &core);
SDL_RenderFillRect(renderer, &left);
SDL_RenderFillRect(renderer, &right);
SDL_RenderFillRect(renderer, &top);
SDL_RenderFillRect(renderer, &bottom);

if(border_color.a != 0) {
// DRAW BORDER
SDL_SetRenderDrawColor(renderer, border_color.r, border_color.g, border_color.b, border_color.a);
SDL_RenderDrawLine(renderer, left.x, left.y, left.x, left.y + left.h);
SDL_RenderDrawLine(renderer, right.x + right.w, right.y, right.x + right.w, right.y + right.h);
SDL_RenderDrawLine(renderer, top.x, top.y, top.x + top.w, top.y);
SDL_RenderDrawLine(renderer, bottom.x, bottom.y + bottom.h, bottom.x + bottom.w, bottom.y + bottom.h);
}
}

void drawRoundedRect(SDL_Renderer* renderer, const SDL_Rect& rect, const SDL_Color& color, const SDL_Color& border_color, int r, bool shadow) {
if(r > 8)
r = 8;
if(shadow) {
// drawRoundedRect(renderer, {rect.x - static_cast<int>(rect.w/10), rect.y - static_cast<int>(rect.h/20), rect.w, rect.h}, {0, 0, 0, 200}, {0, 0, 0, 0}, r, false);
drawRoundedRect(renderer, {rect.x - 10, rect.y + 10, rect.w, rect.h}, {0, 0, 0, 100}, {0, 0, 0, 0}, r, false);
}
drawBaseRects(renderer, rect, color, border_color, r);
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);

auto drawPoints = [renderer, rect, color, border_color, r](int r_x, int r_y) {
// std::cout << "Call to drawPoints:\t" << r_x << "\t" << r_y << "\n";
SDL_RenderDrawPoint(renderer, rect.x + rect.w - r + r_x, rect.y + r - r_y - 1); // FIRST QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + r - r_x - 1, rect.y + r - r_y - 1); // SECOND QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + r - r_x - 1, rect.y + rect.h - r + r_y); // THIRD QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + rect.w - r + r_x, rect.y + rect.h - r + r_y); // FOURTH QUADRANT
};

for(int r_x {0}; r_x < r; r_x++) {
for(int r_y {0}; r_y < r; r_y++) {
if(pow(r_x,2) + pow(r_y,2) <= pow(r,2)) {
drawPoints(r_x, r_y);
}
}
}
}

void drawCutRect(SDL_Renderer* renderer, const SDL_Rect& rect, const SDL_Color& color, const SDL_Color& border_color, int r, bool shadow) {
drawBaseRects(renderer, rect, color, border_color, r);
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
auto drawPoints = [renderer, rect, color, border_color, r](int r_x, int r_y) {
// std::cout << "Call to drawPoints:\t" << r_x << "\t" << r_y << "\n";
SDL_RenderDrawPoint(renderer, rect.x + rect.w - r + r_x, rect.y + r - r_y - 1); // FIRST QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + r - r_x - 1, rect.y + r - r_y - 1); // SECOND QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + r - r_x - 1, rect.y + rect.h - r + r_y); // THIRD QUADRANT
SDL_RenderDrawPoint(renderer, rect.x + rect.w - r + r_x, rect.y + rect.h - r + r_y); // FOURTH QUADRANT
};

int y_bound { 0 };
auto getBound = [r, &y_bound](int r_x, int r_y) {
y_bound = static_cast<int>(sqrt(pow(r-1, 2)-pow(r_x,2)));
return y_bound;
};

int r_x {0}, r_y {r - 1};
while(r_x < r) {
while(r_y >= 0) {
drawPoints(r_x, r_y);
r_y--;
}
r_y = r - 1 - r_x;
r_x++;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/ui/end_menu.hpp
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/ui/game_window.hpp
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/ui/options_pannel.hpp
Empty file.
File renamed without changes.
File renamed without changes.
Empty file removed src/ui/pause_menu.hpp
Empty file.
Empty file removed src/ui/start_menu.hpp
Empty file.
74 changes: 0 additions & 74 deletions src/ui/test_menu.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/ui/test_menu.hpp

This file was deleted.

45 changes: 0 additions & 45 deletions src/ui/test_menu_old.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions src/ui/test_menu_old.hpp

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions src/ui/ui.hpp

This file was deleted.

21 changes: 11 additions & 10 deletions src/engine/ui/ui_element.cpp → src/ui/ui_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ void UI_Element::render() {
// SDL_RenderCopy(texture, )
}
else if(color.a != 0 && !hidden) {
if(r < 1) {
SDL_SetRenderDrawColor(context->renderer, color.r, color.g, color.b, color.a);
SDL_RenderFillRect(context->renderer, &(this->rect));
// if(r < 1) {
// SDL_SetRenderDrawColor(context->renderer, color.r, color.g, color.b, color.a);
// SDL_RenderFillRect(context->renderer, &(this->rect));

if(border_color.a != 0) {
SDL_SetRenderDrawColor(context->renderer, border_color.r, border_color.g, border_color.b, border_color.a);
SDL_RenderDrawRect(context->renderer, &(this->rect));
}
// if(border_color.a != 0) {
// SDL_SetRenderDrawColor(context->renderer, border_color.r, border_color.g, border_color.b, border_color.a);
// SDL_RenderDrawRect(context->renderer, &(this->rect));
// }

return;
}
// return;
// }

drawRoundedRect(context->renderer, this->rect, this->color, this->border_color, 5, true);

drawCutRect(context->renderer, this->rect, this->color, this->border_color, r, shadow);
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit 67910bc

Please sign in to comment.