Skip to content

Commit

Permalink
moved ghost enums to common/type.h
Browse files Browse the repository at this point in the history
  • Loading branch information
raicool committed Aug 18, 2023
1 parent defaaa8 commit 3f3b455
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 89 deletions.
18 changes: 9 additions & 9 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@

void app::init()
{
sdlwindow.init(this, "MK7 Spotpass Ghost Manager v0.2.2", 848, 480, 0, SDL_WINDOW_MAXIMIZED | SDL_WINDOW_RESIZABLE);
main_window.init(this, "MK7 Spotpass Ghost Manager v0.2.2", 848, 480, 0, SDL_WINDOW_MAXIMIZED | SDL_WINDOW_RESIZABLE);

logger::init_logger();

texture_manager.current_renderer = sdlwindow.sdlrenderer;
texture_manager.current_renderer = main_window.sdlrenderer;
texture_manager.load_ghost_textures();
}

int app::update()
{
while (1)
{
sdlwindow.deltatime.before = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
main_window.deltatime.before = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();

SDL_PollEvent(&sdlwindow.sdlevent);
ImGui_ImplSDL2_ProcessEvent(&sdlwindow.sdlevent);
SDL_PollEvent(&main_window.sdlevent);
ImGui_ImplSDL2_ProcessEvent(&main_window.sdlevent);

switch (sdlwindow.sdlevent.type)
switch (main_window.sdlevent.type)
{
case SDL_QUIT:
return 0;
}

sdlwindow.update();
main_window.update();

SDL_RenderPresent(sdlwindow.sdlrenderer);
SDL_RenderPresent(main_window.sdlrenderer);

sdlwindow.deltatime.apply_delay((uint32_t)((1.0f / sdlwindow.framerate) * 1000.0f));
main_window.deltatime.apply_delay((uint32_t)((1.0f / main_window.framerate) * 1000.0f));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

struct app
{
window sdlwindow;
window main_window;
texture texture_manager;

spotpass* spotpass_files[8]{ nullptr }; // 8 file managers for 8 different spotpass cups
Expand Down
68 changes: 68 additions & 0 deletions src/common/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,72 @@ struct rgb
struct rgba
{
uint8_t r, g, b, a;
};

enum character
{
CHAR_BOWSER = 0x00,
CHAR_DAISY = 0x01,
CHAR_DONKEY_KONG = 0x02,
CHAR_HONEY_QUEEN = 0x03,
CHAR_KOOPA_TROOPA = 0x04,
CHAR_LAKITU = 0x05,
CHAR_LUIGI = 0x06,
CHAR_MARIO = 0x07,
CHAR_METAL_MARIO = 0x08,
CHAR_MII_MALE = 0x09,
CHAR_MII_FEMALE = 0x0a,
CHAR_PEACH = 0x0b,
CHAR_ROSALINA = 0x0c,
CHAR_SHY_GUY = 0x0d,
CHAR_TOAD = 0x0e,
CHAR_WARIO = 0x0f,
CHAR_WIGGLER = 0x10,
CHAR_YOSHI = 0x11
};

enum kart
{
KART_STANDARD = 0x00,
KART_BOLT_BUGGY = 0x01,
KART_BIRTHDAY_GIRL = 0x02,
KART_EGG_1 = 0x03,
KART_BDASHER = 0x04,
KART_ZUCCHINI = 0x05,
KART_KOOPA_CLOWN = 0x06,
KART_TINY_TUG = 0x07,
KART_BUMBLE_V = 0x08,
KART_CACT_X = 0x09,
KART_BRUISER = 0x0a,
KART_PIPE_FRAME = 0x0b,
KART_BARREL_TRAIN = 0x0c,
KART_CLOUD_9 = 0x0d,
KART_BLUE_SEVEN = 0x0e,
KART_SODA_JET = 0x0f,
KART_GOLD_STANDARD = 0x10,
};

enum tire
{
TIRE_STANDARD = 0x00,
TIRE_MONSTER = 0x01,
TIRE_ROLLER = 0x02,
TIRE_SLICK = 0x03,
TIRE_SLIM = 0x04,
TIRE_SPONGE = 0x05,
TIRE_GOLD_TIRES = 0x06,
TIRE_WOOD = 0x07,
TIRE_RED_MONSTER = 0x08,
TIRE_MUSHROOM = 0x09,
};

enum glider
{
WING_SUPER_GLIDER = 0x00,
WING_PARAGLIDER = 0x01,
WING_PEACH_PARASOL = 0x02,
WING_FLOWER_GLIDER = 0x03,
WING_SWOOPER = 0x04,
WING_BEAST_GLIDER = 0x05,
WING_GOLD_GLIDER = 0x06,
};
2 changes: 1 addition & 1 deletion src/core/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void panel::render()
{
static int w;
static int h;
SDL_GetWindowSize(window_ptr->sdlwindow, &w, &h);
SDL_GetWindowSize(window_ptr->main_window, &w, &h);

if (panel_flags & panels::PANEL_MENU_BAR)
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ enum panels

struct panel
{
panel(window* sdlwindow)
: window_ptr(sdlwindow) {};
panel(window* main_window)
: window_ptr(main_window) {};

panel() {};

Expand Down
10 changes: 5 additions & 5 deletions src/core/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ void window::init(app* application, const char* window_title, uint16_t win_width
height = win_height;
framerate = win_framerate;

sdlwindow = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, win_width, win_height, flags);
sdlrenderer = SDL_CreateRenderer(sdlwindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
main_window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, win_width, win_height, flags);
sdlrenderer = SDL_CreateRenderer(main_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, "overscan");

if (!sdlwindow)
if (!main_window)
{
// LOG_ERROR("SDL Window could not be created {}", SDL_GetError());
}
Expand All @@ -25,7 +25,7 @@ void window::init(app* application, const char* window_title, uint16_t win_width

ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui_ImplSDL2_InitForSDLRenderer(sdlwindow, sdlrenderer);
ImGui_ImplSDL2_InitForSDLRenderer(main_window, sdlrenderer);
ImGui_ImplSDLRenderer2_Init(sdlrenderer);

// TODO: find 3ds' entire unicode range
Expand All @@ -50,7 +50,7 @@ void window::update()

void window::render_panels()
{
ImGui_ImplSDL2_NewFrame(sdlwindow);
ImGui_ImplSDL2_NewFrame(main_window);
ImGui_ImplSDLRenderer2_NewFrame();
ImGui::NewFrame();

Expand Down
2 changes: 1 addition & 1 deletion src/core/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct window
panel* panels;

SDL_Event sdlevent;
SDL_Window* sdlwindow;
SDL_Window* main_window;
SDL_Renderer* sdlrenderer;

frame deltatime;
Expand Down
68 changes: 0 additions & 68 deletions src/file/ghost.h
Original file line number Diff line number Diff line change
@@ -1,73 +1,5 @@
#pragma once

enum character
{
CHAR_BOWSER = 0x00,
CHAR_DAISY = 0x01,
CHAR_DONKEY_KONG = 0x02,
CHAR_HONEY_QUEEN = 0x03,
CHAR_KOOPA_TROOPA = 0x04,
CHAR_LAKITU = 0x05,
CHAR_LUIGI = 0x06,
CHAR_MARIO = 0x07,
CHAR_METAL_MARIO = 0x08,
CHAR_MII_MALE = 0x09,
CHAR_MII_FEMALE = 0x0a,
CHAR_PEACH = 0x0b,
CHAR_ROSALINA = 0x0c,
CHAR_SHY_GUY = 0x0d,
CHAR_TOAD = 0x0e,
CHAR_WARIO = 0x0f,
CHAR_WIGGLER = 0x10,
CHAR_YOSHI = 0x11
};

enum kart
{
KART_STANDARD = 0x00,
KART_BOLT_BUGGY = 0x01,
KART_BIRTHDAY_GIRL = 0x02,
KART_EGG_1 = 0x03,
KART_BDASHER = 0x04,
KART_ZUCCHINI = 0x05,
KART_KOOPA_CLOWN = 0x06,
KART_TINY_TUG = 0x07,
KART_BUMBLE_V = 0x08,
KART_CACT_X = 0x09,
KART_BRUISER = 0x0a,
KART_PIPE_FRAME = 0x0b,
KART_BARREL_TRAIN = 0x0c,
KART_CLOUD_9 = 0x0d,
KART_BLUE_SEVEN = 0x0e,
KART_SODA_JET = 0x0f,
KART_GOLD_STANDARD = 0x10,
};

enum tire
{
TIRE_STANDARD = 0x00,
TIRE_MONSTER = 0x01,
TIRE_ROLLER = 0x02,
TIRE_SLICK = 0x03,
TIRE_SLIM = 0x04,
TIRE_SPONGE = 0x05,
TIRE_GOLD_TIRES = 0x06,
TIRE_WOOD = 0x07,
TIRE_RED_MONSTER = 0x08,
TIRE_MUSHROOM = 0x09,
};

enum glider
{
WING_SUPER_GLIDER = 0x00,
WING_PARAGLIDER = 0x01,
WING_PEACH_PARASOL = 0x02,
WING_FLOWER_GLIDER = 0x03,
WING_SWOOPER = 0x04,
WING_BEAST_GLIDER = 0x05,
WING_GOLD_GLIDER = 0x06,
};

struct ghost
{
uint32_t file_offset = 0; //< where ghost's data starts in spotpass file (if applicable)
Expand Down
1 change: 0 additions & 1 deletion src/file/spotpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ uint8_t spotpass::load(const char* dir)
{
uint32_t offset = 0;
uint32_t u32buffer = 0;
uint8_t buffer = 0;

file_directory = dir;

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "texture.h"

#include "common/log.h"
#include "file/ghost.h"
#include "common/type.h"

void texture::load_ghost_textures()
{
Expand Down

0 comments on commit 3f3b455

Please sign in to comment.