diff --git a/src/Application/Core/controller.cc b/src/Application/Core/controller.cc index 60bf50cc..207fa28d 100644 --- a/src/Application/Core/controller.cc +++ b/src/Application/Core/controller.cc @@ -1,11 +1,13 @@ #include "controller.h" #include +#include +#include #include #include -#include "Core/renderer.h" -#include "Core/window.h" +#include + #include "Editor/editor.h" namespace yaze { @@ -15,8 +17,9 @@ namespace Core { bool Controller::isActive() const { return active_; } void Controller::onEntry() { - window_.Create(); - renderer_.Create(window_.Get()); + CreateWindow(); + CreateRenderer(); + CreateGuiContext(); ImGuiIO &io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Backspace] = SDL_GetScancodeFromKey(SDLK_BACKSPACE); io.KeyMap[ImGuiKey_Enter] = SDL_GetScancodeFromKey(SDLK_RETURN); @@ -94,17 +97,88 @@ void Controller::onInput() { void Controller::onLoad() { editor_.UpdateScreen(); } -void Controller::doRender() { renderer_.Render(); } +void Controller::doRender() { + SDL_RenderClear(sdl_renderer_.get()); + ImGui::Render(); + ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); + SDL_RenderPresent(sdl_renderer_.get()); +} void Controller::onExit() { ImGui_ImplSDLRenderer_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); - window_.Destroy(); - renderer_.Destroy(); SDL_Quit(); } +void Controller::CreateWindow() { + if (SDL_Init(SDL_INIT_EVERYTHING)) { + SDL_Log("SDL_Init: %s\n", SDL_GetError()); + } else { + sdl_window_ = std::unique_ptr( + SDL_CreateWindow("Yet Another Zelda3 Editor", // window title + SDL_WINDOWPOS_UNDEFINED, // initial x position + SDL_WINDOWPOS_UNDEFINED, // initial y position + 1200, // width, in pixels + 800, // height, in pixels + SDL_WINDOW_RESIZABLE), + sdl_deleter()); + } +} + +void Controller::CreateRenderer() { + if (sdl_window_ == nullptr) { + SDL_Log("SDL_CreateWindow: %s\n", SDL_GetError()); + SDL_Quit(); + } else { + sdl_renderer_ = std::unique_ptr( + SDL_CreateRenderer( + sdl_window_.get(), -1, + SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + sdl_deleter()); + if (sdl_renderer_ == nullptr) { + SDL_Log("SDL_CreateRenderer: %s\n", SDL_GetError()); + SDL_Quit(); + } else { + SDL_SetRenderDrawBlendMode(sdl_renderer_.get(), SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(sdl_renderer_.get(), 0x00, 0x00, 0x00, 0x00); + } + } +} + +void Controller::CreateGuiContext() { + // Create the ImGui and ImPlot contexts + ImGui::CreateContext(); + + // Initialize ImGui for SDL + ImGui_ImplSDL2_InitForSDLRenderer(sdl_window_.get(), sdl_renderer_.get()); + ImGui_ImplSDLRenderer_Init(sdl_renderer_.get()); + + // Load available fonts + const ImGuiIO &io = ImGui::GetIO(); + 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}; + ImFontConfig icons_config; + icons_config.MergeMode = true; + icons_config.GlyphOffset.y = 5.0f; + icons_config.GlyphMinAdvanceX = 13.0f; + icons_config.PixelSnapH = true; + io.Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_MD, 18.0f, &icons_config, + 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); + + // Set the default style + Style::ColorsYaze(); + + // Build a new ImGui frame + ImGui_ImplSDLRenderer_NewFrame(); + ImGui_ImplSDL2_NewFrame(sdl_window_.get()); +} + } // namespace Core } // namespace Application } // namespace yaze \ No newline at end of file diff --git a/src/Application/Core/controller.h b/src/Application/Core/controller.h index 038085c1..201311fb 100644 --- a/src/Application/Core/controller.h +++ b/src/Application/Core/controller.h @@ -3,14 +3,16 @@ #define SDL_MAIN_HANDLED #include +#include +#include #include #include -#include "Core/renderer.h" -#include "Core/window.h" #include "Editor/editor.h" +#include "Graphics/icons.h" +#include "Graphics/style.h" -int main(int argc, char** argv); +int main(int argc, char **argv); namespace yaze { namespace Application { @@ -28,13 +30,22 @@ class Controller { void onExit(); private: + void CreateWindow(); + void CreateRenderer(); + void CreateGuiContext(); inline void quit() { active_ = false; } - friend int ::main(int argc, char** argv); + friend int ::main(int argc, char **argv); + + struct sdl_deleter { + void operator()(SDL_Window *p) const { SDL_DestroyWindow(p); } + void operator()(SDL_Renderer *p) const { SDL_DestroyRenderer(p); } + void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); } + }; bool active_; - Window window_; - Renderer renderer_; Editor::Editor editor_; + std::shared_ptr sdl_window_; + std::shared_ptr sdl_renderer_; }; } // namespace Core diff --git a/src/Application/Core/input.cc b/src/Application/Core/input.cc new file mode 100644 index 00000000..e4dba475 --- /dev/null +++ b/src/Application/Core/input.cc @@ -0,0 +1,25 @@ +#include "input.h" + +#include +#include + +namespace yaze { +namespace Gui { + +const int kStepOneHex = 0x01; +const int kStepFastHex = 0x0F; + +bool InputHex(const char* label, int* data) { + return ImGui::InputScalar(label, ImGuiDataType_U64, data, &kStepOneHex, + &kStepFastHex, "%06X", + ImGuiInputTextFlags_CharsHexadecimal); +} + +bool InputHexShort(const char* label, int* data) { + return ImGui::InputScalar(label, ImGuiDataType_U32, data, &kStepOneHex, + &kStepFastHex, "%06X", + ImGuiInputTextFlags_CharsHexadecimal); +} + +} // namespace Gui +} // namespace yaze diff --git a/src/Application/Core/input.h b/src/Application/Core/input.h new file mode 100644 index 00000000..0c5313cc --- /dev/null +++ b/src/Application/Core/input.h @@ -0,0 +1,19 @@ +#ifndef YAZE_APPLICATION_CORE_INPUT_H +#define YAZE_APPLICATION_CORE_INPUT_H + +#include +#include + +#include +#include + +namespace yaze { +namespace Gui { + +IMGUI_API bool InputHex(const char* label, int* data); +IMGUI_API bool InputHexShort(const char* label, int* data); + +} // namespace Gui +} // namespace yaze + +#endif \ No newline at end of file diff --git a/src/Application/Core/renderer.cc b/src/Application/Core/renderer.cc deleted file mode 100644 index a0fe28a3..00000000 --- a/src/Application/Core/renderer.cc +++ /dev/null @@ -1,77 +0,0 @@ -#include "renderer.h" - -#include -#include -#include -#include - -#include "Graphics/icons.h" -#include "Graphics/style.h" - -namespace yaze { -namespace Application { -namespace Core { - -void Renderer::Create(SDL_Window* window) { - if (window == nullptr) { - SDL_Log("SDL_CreateWindow: %s\n", SDL_GetError()); - SDL_Quit(); - } else { - renderer = SDL_CreateRenderer( - window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); - if (renderer == nullptr) { - SDL_Log("SDL_CreateRenderer: %s\n", SDL_GetError()); - SDL_Quit(); - } else { - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); - SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); - } - } - - // Create the ImGui and ImPlot contexts - ImGui::CreateContext(); - - // Initialize ImGui for SDL - ImGui_ImplSDL2_InitForSDLRenderer(window, renderer); - ImGui_ImplSDLRenderer_Init(renderer); - - // Load available fonts - const ImGuiIO& io = ImGui::GetIO(); - 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}; - ImFontConfig icons_config; - icons_config.MergeMode = true; - icons_config.GlyphOffset.y = 5.0f; - icons_config.GlyphMinAdvanceX = 13.0f; - icons_config.PixelSnapH = true; - io.Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_MD, 18.0f, &icons_config, - 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); - - // Set the default style - Style::ColorsYaze(); - - // Build a new ImGui frame - ImGui_ImplSDLRenderer_NewFrame(); - ImGui_ImplSDL2_NewFrame(window); -} - -void Renderer::Render() { - SDL_RenderClear(renderer); - ImGui::Render(); - ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); - SDL_RenderPresent(renderer); -} - -void Renderer::Destroy() { - SDL_DestroyRenderer(renderer); - renderer = nullptr; -} - -} // namespace Core -} // namespace Application -} // namespace yaze \ No newline at end of file diff --git a/src/Application/Core/renderer.h b/src/Application/Core/renderer.h deleted file mode 100644 index b5758357..00000000 --- a/src/Application/Core/renderer.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef YAZE_APPLICATION_CORE_RENDERER_H -#define YAZE_APPLICATION_CORE_RENDERER_H - -#include -#include -#include -#include - -#include "Graphics/icons.h" -#include "Graphics/style.h" - -namespace yaze { -namespace Application { -namespace Core { - -static SDL_Renderer* renderer = nullptr; - -class Renderer { - public: - void Create(SDL_Window* window); - void Render(); - void Destroy(); -}; - -} // namespace Core -} // namespace Application -} // namespace yaze - -#endif // YAZE_APPLICATION_CORE_RENDERER_H \ No newline at end of file diff --git a/src/Application/Core/window.cc b/src/Application/Core/window.cc deleted file mode 100644 index b2815876..00000000 --- a/src/Application/Core/window.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include "window.h" - -#include - -namespace yaze { -namespace Application { -namespace Core { - -// TODO: pass in the size of the window as argument -void Window::Create() { - if (SDL_Init(SDL_INIT_EVERYTHING)) { - SDL_Log("SDL_Init: %s\n", SDL_GetError()); - } else { - window = SDL_CreateWindow("Yet Another Zelda3 Editor", // window title - SDL_WINDOWPOS_UNDEFINED, // initial x position - SDL_WINDOWPOS_UNDEFINED, // initial y position - 1200, // width, in pixels - 800, // height, in pixels - SDL_WINDOW_RESIZABLE // window flags - ); - } -} - -SDL_Window* Window::Get() { return window; } - -void Window::Destroy() { - SDL_DestroyWindow(window); - window = nullptr; -} - -} // namespace Core -} // namespace Application -} // namespace yaze \ No newline at end of file diff --git a/src/Application/Core/window.h b/src/Application/Core/window.h deleted file mode 100644 index 3bc9d7c0..00000000 --- a/src/Application/Core/window.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef YAZE_APPLICATION_CORE_WINDOW_H -#define YAZE_APPLICATION_CORE_WINDOW_H - -#include - -namespace yaze { -namespace Application { -namespace Core { - -class Window { - public: - void Create(); - void Destroy(); - SDL_Window* Get(); - - private: - SDL_Window* window = nullptr; -}; - -} // namespace Core -} // namespace Application -} // namespace yaze - -#endif \ No newline at end of file diff --git a/src/Application/Data/rom.cc b/src/Application/Data/rom.cc index 74dedf09..0bc79697 100644 --- a/src/Application/Data/rom.cc +++ b/src/Application/Data/rom.cc @@ -38,8 +38,8 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { std::cout << "Extracting tiles..." << std::endl; uint filePos = 0; uint size_out = 0; - uint size = preset.length; - int tilePos = preset.pcTilesLocation; + uint size = preset.length_; + int tilePos = preset.pc_tiles_location_; std::vector rawTiles; filePos = GetRomPosition(preset, tilePos, preset.SNESTilesLocation); std::cout << "ROM Position: " << filePos << " from " @@ -51,7 +51,7 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { data = alttp_decompress_gfx(data, 0, size, &size_out, &compressed_size_); std::cout << "size: " << size << std::endl; std::cout << "lastCompressedSize: " << compressed_size_ << std::endl; - if (data == NULL) { + if (data == nullptr) { std::cout << alttp_decompression_error << std::endl; return rawTiles; } @@ -59,8 +59,9 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { // unpack the tiles based on their depth unsigned tileCpt = 0; std::cout << "Unpacking tiles..." << std::endl; - for (unsigned int tilePos = 0; tilePos < size; tilePos += preset.bpp * 8) { - tile8 newTile = unpack_bpp_tile(data, tilePos, preset.bpp); + for (unsigned int tilePos = 0; tilePos < size; + tilePos += preset.bits_per_pixel_ * 8) { + tile8 newTile = unpack_bpp_tile(data, tilePos, preset.bits_per_pixel_); newTile.id = tileCpt; rawTiles.push_back(newTile); tileCpt++; @@ -72,10 +73,10 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { } Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) { - unsigned int filePos = GetRomPosition(preset, preset.pcPaletteLocation, + unsigned int filePos = GetRomPosition(preset, preset.pc_palette_location_, preset.SNESPaletteLocation); std::cout << "Palette pos : " << filePos << std::endl; // TODO: make this hex - unsigned int palette_size = pow(2, preset.bpp); // - 1; + unsigned int palette_size = pow(2, preset.bits_per_pixel_); // - 1; char *ab = (char *)malloc(sizeof(char) * (palette_size * 2)); memcpy(ab, current_rom_ + filePos, palette_size * 2); @@ -86,7 +87,7 @@ Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) { const char *data = ab; Graphics::SNESPalette pal(ab); - if (preset.paletteNoZeroColor) { + if (preset.no_zero_color_) { Graphics::SNESColor col; col.setRgb(ImVec4(153, 153, 153, 255)); diff --git a/src/Application/Editor/editor.cc b/src/Application/Editor/editor.cc index 5f02100e..9893e893 100644 --- a/src/Application/Editor/editor.cc +++ b/src/Application/Editor/editor.cc @@ -59,11 +59,11 @@ Editor::Editor() { asm_editor_.SetLanguageDefinition(language_65816_); asm_editor_.SetPalette(TextEditor::GetDarkPalette()); - current_set_.bpp = 4; - current_set_.pcTilesLocation = 0x80000; + current_set_.bits_per_pixel_ = 4; + current_set_.pc_tiles_location_ = 0x80000; current_set_.SNESTilesLocation = 0x0000; - current_set_.length = 28672; - current_set_.pcPaletteLocation = 906022; + current_set_.length_ = 28672; + current_set_.pc_palette_location_ = 906022; current_set_.SNESPaletteLocation = 0; } @@ -263,22 +263,20 @@ void Editor::DrawProjectEditor() { ImGui::Text("Version: %d", rom_.getVersion()); ImGui::Text("ROM Size: %ld", rom_.getSize()); - ImGui::InputScalar("Bits per Pixel", ImGuiDataType_U32, - (void *)¤t_set_.bpp); + ImGui::InputInt("Bits per Pixel", ¤t_set_.bits_per_pixel_); - ImGui::InputInt("PC Tile Location", ¤t_set_.pcTilesLocation); - // 1, 100, ImGuiInputTextFlags_CharsHexadecimal + yaze::Gui::InputHex("PC Tile Location", ¤t_set_.pc_tiles_location_); - ImGui::InputScalar("SNES Tile Location", ImGuiDataType_U16, - (void *)¤t_set_.SNESTilesLocation); + yaze::Gui::InputHex("SNES Tile Location", + ¤t_set_.SNESTilesLocation); - ImGui::InputScalar("Tile Preset Length", ImGuiDataType_U32, - (void *)¤t_set_.length); + ImGui::InputInt("Tile Preset Length", ¤t_set_.length_); - ImGui::InputInt("PC Palette Location", ¤t_set_.pcPaletteLocation); + ImGui::InputInt("PC Palette Location", + ¤t_set_.pc_palette_location_); - ImGui::InputScalar("SNES Palette Location", ImGuiDataType_U16, - (void *)¤t_set_.SNESPaletteLocation); + yaze::Gui::InputHex("SNES Palette Location", + ¤t_set_.SNESPaletteLocation); BASIC_BUTTON("ExtractTiles") { if (rom_.isLoaded()) { diff --git a/src/Application/Editor/editor.h b/src/Application/Editor/editor.h index 0b1f8ac1..b3310f66 100644 --- a/src/Application/Editor/editor.h +++ b/src/Application/Editor/editor.h @@ -8,6 +8,7 @@ #include #include "Core/constants.h" +#include "Core/input.h" #include "Data/rom.h" #include "Editor/overworld_editor.h" #include "Graphics/icons.h" diff --git a/src/Application/Editor/tile_editor.cc b/src/Application/Editor/tile_editor.cc new file mode 100644 index 00000000..0731b965 --- /dev/null +++ b/src/Application/Editor/tile_editor.cc @@ -0,0 +1,10 @@ +#include "tile_editor.h" + +namespace yaze { +namespace Application { +namespace Editor { + +void TileEditor::UpdateScreen() {} +} // namespace Editor +} // namespace Application +} // namespace yaze \ No newline at end of file diff --git a/src/Application/Editor/tile_editor.h b/src/Application/Editor/tile_editor.h new file mode 100644 index 00000000..daba96f1 --- /dev/null +++ b/src/Application/Editor/tile_editor.h @@ -0,0 +1,15 @@ +#ifndef YAZE_APPLICATION_EDITOR_TILEEDITOR_H +#define YAZE_APPLICATION_EDITOR_TILEEDITOR_H + +namespace yaze { +namespace Application { +namespace Editor { +class TileEditor { + public: + void UpdateScreen(); +}; +} // namespace Editor +} // namespace Application +} // namespace yaze + +#endif \ No newline at end of file diff --git a/src/Application/Graphics/palette.cc b/src/Application/Graphics/palette.cc index 0a18bbc7..acb7642f 100644 --- a/src/Application/Graphics/palette.cc +++ b/src/Application/Graphics/palette.cc @@ -73,14 +73,18 @@ char* SNESPalette::encode() { } SDL_Palette* SNESPalette::GetSDL_Palette() { + std::cout << "Converting SNESPalette to SDL_Palette" << std::endl; auto sdl_palette = std::make_shared(); sdl_palette->ncolors = size_; - + auto* sdl_colors = new SDL_Color[size_]; for (int i = 0; i < size_; i++) { sdl_colors[i].r = (uint8_t)colors[i].rgb.x * 100; sdl_colors[i].g = (uint8_t)colors[i].rgb.y * 100; sdl_colors[i].b = (uint8_t)colors[i].rgb.z * 100; + std::cout << "Color " << i << " added (R:" << sdl_colors[i].r + << " G:" << sdl_colors[i].g << " B:" << sdl_colors[i].b << ")" + << std::endl; } sdl_palette->colors = sdl_colors; diff --git a/src/Application/Graphics/scene.cc b/src/Application/Graphics/scene.cc index 3f31dc55..c3f99738 100644 --- a/src/Application/Graphics/scene.cc +++ b/src/Application/Graphics/scene.cc @@ -6,7 +6,6 @@ #include #include -#include "Core/renderer.h" #include "Graphics/tile.h" namespace yaze { @@ -23,59 +22,32 @@ void Scene::buildSurface(const std::vector& tiles, SNESPalette& mPalette, for (unsigned int i = 0; i < arrangedTiles[0].size(); i++) { tile8 tile = arrangedTiles[j][i]; // SDL_PIXELFORMAT_RGB888 ? - SDL_Surface* newImage = SDL_CreateRGBSurfaceWithFormat( + SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormat( 0, 8, 8, SDL_BITSPERPIXEL(3), SDL_PIXELFORMAT_RGB444); - SDL_PixelFormat* format = newImage->format; + if (surface == nullptr) { + SDL_Log("SDL_CreateRGBSurfaceWithFormat() failed: %s", SDL_GetError()); + exit(1); + } + SDL_PixelFormat* format = surface->format; format->palette = mPalette.GetSDL_Palette(); + char* ptr = (char*)surface->pixels; - char* ptr = (char*)newImage->pixels; - - for (int i = 0; i < 8; i++) { - for (int j = 0; j < 8; j++) { - ptr[i * 8 + j] = (char)tile.data[i * 8 + j]; + for (int k = 0; k < 8; k++) { + for (int l = 0; l < 8; l++) { + ptr[k * 8 + l] = tile.data[k * 8 + l]; } } - SDL_Texture* texture = - SDL_CreateTextureFromSurface(Core::renderer, newImage); - imagesCache[tile.id] = texture; + // SDL_Texture* texture = + // SDL_CreateTextureFromSurface(Core::renderer, surface); + // if (texture == nullptr) { + // std::cout << "Error: " << SDL_GetError() << std::endl; + // } + // imagesCache[tile.id] = texture; } } } -void Scene::buildScene(const std::vector& tiles, - const SNESPalette mPalette, const TilesPattern& tp) { - arrangedTiles = TilesPattern::transform(tp, tiles); - tilesPattern = tp; - allTiles = tiles; - for (unsigned int j = 0; j < arrangedTiles.size(); j++) { - for (unsigned int i = 0; i < arrangedTiles[0].size(); i++) { - tile8 tile = arrangedTiles[j][i]; - // QImage newImage(8, 8, QImage::Format_Indexed8); - // newImage.setColorCount(mPalette.size); - // for (int i = 0; i < mPalette.size; i++) { - // newImage.setColor(i, mPalette.colors.at(i).rgb); - // } - // for (int i = 0; i < 8; i++) { - // for (int j = 0; j < 8; j++) - // newImage.setPixel(i, j, tile.data[i + j * 8]); - // } - // QPixmap m; - // m.convertFromImage(newImage); - // imagesCache[tile.id] = m; - // GraphicsTileItem *newTileItem = new GraphicsTileItem(m, tile); - // addItem(newTileItem); - // newTileItem->setTileZoom(tilesZoom); - // newTileItem->setPos(i * newTileItem->boundingRect().width() + i, - // j * newTileItem->boundingRect().width() + j); - } - } - // unsigned max_w = items()[0]->boundingRect().width() * - // arrangedTiles[0].size() + arrangedTiles[0].size(); unsigned max_h = - // items()[0]->boundingRect().width() * arrangedTiles.size() + - // arrangedTiles.size(); setSceneRect(QRect(0, 0, max_w, max_h)); -} - void Scene::updateScene() { std::cout << "Update scene"; unsigned int itemCpt = 0; @@ -92,13 +64,6 @@ void Scene::updateScene() { itemCpt++; } } - // unsigned max_w = - // items()[0]->boundingRect().width() * arrangedTiles[0].size() + - // arrangedTiles[0].size(); - // unsigned max_h = items()[0]->boundingRect().width() * arrangedTiles.size() - // + - // arrangedTiles.size(); - // setSceneRect(QRect(0, 0, max_w, max_h)); } void Scene::setTilesZoom(unsigned int tileZoom) { diff --git a/src/Application/Graphics/scene.h b/src/Application/Graphics/scene.h index 7fee6200..d209286c 100644 --- a/src/Application/Graphics/scene.h +++ b/src/Application/Graphics/scene.h @@ -7,7 +7,6 @@ #include #include -#include "Core/renderer.h" #include "Graphics/tile.h" namespace yaze { @@ -17,9 +16,6 @@ namespace Graphics { class Scene { public: Scene() = default; - void buildScene(const std::vector& tiles, const SNESPalette mPalette, - const TilesPattern& tp); - void buildSurface(const std::vector& tiles, SNESPalette& mPalette, const TilesPattern& tp); diff --git a/src/Application/Graphics/tile.h b/src/Application/Graphics/tile.h index d2aba7e9..872f7837 100644 --- a/src/Application/Graphics/tile.h +++ b/src/Application/Graphics/tile.h @@ -91,12 +91,12 @@ class TilePreset { TilePreset() = default; TilesPattern tilesPattern; bool no_zero_color_ = false; - int pc_tiles_location_ = -1; + int pc_tiles_location_ = 0; int pc_palette_location_ = 0; - uint32_t length_ = 0; - uint32_t bits_per_pixel_ = 0; - uint16_t SNESTilesLocation = 0; - uint16_t SNESPaletteLocation = 0; + int bits_per_pixel_ = 0; + int length_ = 0; + int SNESTilesLocation = 0; + int SNESPaletteLocation = 0; }; } // namespace Graphics