Changed filenames to match google style and adjusted some header includes

This commit is contained in:
Justin Scofield
2022-06-12 20:21:42 -04:00
parent 7721e321a4
commit 1822a07e6f
20 changed files with 220 additions and 186 deletions

View File

@@ -1,23 +1,30 @@
#include "Controller.h"
#include "controller.h"
#include <SDL2/SDL.h>
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
#include "core/renderer.h"
#include "core/window.h"
#include "editor/editor.h"
namespace yaze {
namespace Application {
namespace Core {
bool Controller::isActive() const { return active; }
bool Controller::isActive() const { return active_; }
void Controller::onEntry() noexcept(false) {
window.Create();
renderer.Create(window.Get());
void Controller::onEntry() {
window_.Create();
renderer_.Create(window_.Get());
ImGuiIO &io = ImGui::GetIO();
io.KeyMap[ImGuiKey_Backspace] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
io.KeyMap[ImGuiKey_Enter] = SDL_GetScancodeFromKey(SDLK_RETURN);
io.KeyMap[ImGuiKey_UpArrow] = SDL_GetScancodeFromKey(SDLK_UP);
io.KeyMap[ImGuiKey_DownArrow] = SDL_GetScancodeFromKey(SDLK_DOWN);
io.KeyMap[ImGuiKey_Tab] = SDL_GetScancodeFromKey(SDLK_TAB);
io.KeyMap[ImGuiKey_LeftCtrl] = SDL_GetScancodeFromKey(SDLK_LCTRL);
active = true;
active_ = true;
}
void Controller::onInput() {
@@ -55,7 +62,7 @@ void Controller::onInput() {
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE:
active = false;
active_ = false;
break;
case SDL_WINDOWEVENT_SIZE_CHANGED:
io.DisplaySize.x = static_cast<float>(event.window.data1);
@@ -86,19 +93,19 @@ void Controller::onInput() {
io.MouseWheel = static_cast<float>(wheel);
}
void Controller::onLoad() { editor.UpdateScreen(); }
void Controller::onLoad() { editor_.UpdateScreen(); }
void Controller::doRender() {
SDL_Delay(10);
renderer.Render();
renderer_.Render();
}
void Controller::onExit() {
ImGui_ImplSDLRenderer_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
window.Destroy();
renderer.Destroy();
window_.Destroy();
renderer_.Destroy();
SDL_Quit();
}

View File

@@ -3,17 +3,12 @@
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
#include <memory>
#include "Editor/Editor.h"
#include "Renderer.h"
#include "Window.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_sdlrenderer.h"
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "imgui/misc/cpp/imgui_stdlib.h"
#include "core/renderer.h"
#include "core/window.h"
#include "editor/editor.h"
int main(int argc, char** argv);
@@ -26,7 +21,6 @@ class Controller {
Controller() = default;
bool isActive() const;
void onEntry();
void onInput();
void onLoad();
@@ -34,12 +28,13 @@ class Controller {
void onExit();
private:
Window window;
Renderer renderer;
Editor::Editor editor;
bool active = false;
void quit() { active = false; }
inline void quit() { active_ = false; }
friend int ::main(int argc, char** argv);
bool active_;
Window window_;
Renderer renderer_;
Editor::Editor editor_;
};
} // namespace Core

View File

@@ -1,5 +1,13 @@
#include "Renderer.h"
#include <SDL2/SDL.h>
#include <imgui/backends/imgui_impl_sdl.h>
#include <imgui/backends/imgui_impl_sdlrenderer.h>
#include <imgui/imgui.h>
#include "graphics/icons.h"
#include "graphics/style.h"
namespace yaze {
namespace Application {
namespace Core {
@@ -29,7 +37,7 @@ void Renderer::Create(SDL_Window* window) {
// Load available fonts
const ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("assets/Fonts/Karla-Regular.ttf", 14.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/Karla-Regular.ttf", 14.0f);
// merge in icons from Google Material Design
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
@@ -42,10 +50,10 @@ void Renderer::Create(SDL_Window* window) {
icons_ranges);
io.Fonts->AddFontFromFileTTF("assets/Fonts/Roboto-Medium.ttf", 14.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/Cousine-Regular.ttf", 14.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/DroidSans.ttf", 16.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/DroidSans.ttf", 16.0f);
Style::StyleColorsYaze();
// Set the default style
Style::ColorsYaze();
// Build a new ImGui frame
ImGui_ImplSDLRenderer_NewFrame();

View File

@@ -2,13 +2,12 @@
#define YAZE_APPLICATION_CORE_RENDERER_H
#include <SDL2/SDL.h>
#include "Graphics/Icons.h"
#include "Graphics/Style.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_sdlrenderer.h"
#include <imgui/backends/imgui_impl_sdl.h>
#include <imgui/backends/imgui_impl_sdlrenderer.h>
#include <imgui/imgui.h>
// #include "imgui/imgui_internal.h"
#include "graphics/icons.h"
#include "graphics/style.h"
namespace yaze {
namespace Application {

View File

@@ -1,11 +1,10 @@
#ifndef YAZE_APPLICATION_CONTROLLER_ENTRYPOINT_H
#define YAZE_APPLICATION_CONTROLLER_ENTRYPOINT_H
#include "Controller.h"
#include "controller.h"
int main(int argc, char** argv) {
yaze::Application::Core::Controller controller;
controller.onEntry();
while (controller.isActive()) {
controller.onInput();
@@ -13,7 +12,6 @@ int main(int argc, char** argv) {
controller.doRender();
}
controller.onExit();
return EXIT_SUCCESS;
}