millores en la pantalla de càrrega de recursos
This commit is contained in:
@@ -8,19 +8,19 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/text.hpp" // Para Text, loadTextFile
|
||||
#include "core/resources/asset.hpp" // Para AssetType, Asset
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/text.hpp" // Para Text, loadTextFile
|
||||
#include "core/resources/asset.hpp" // Para AssetType, Asset
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_Loa...
|
||||
#include "game/gameplay/room.hpp" // Para RoomData, loadRoomFile, loadRoomTileFile
|
||||
#include "game/options.hpp" // Para Options, OptionsGame, options
|
||||
#include "game/defaults.hpp" // Para GameDefaults::VERSION
|
||||
#include "utils/defines.hpp" // Para WINDOW_CAPTION
|
||||
#include "utils/utils.hpp" // Para getFileName, printWithDots, PaletteColor
|
||||
#include "version.h" // Para Version::GIT_HASH
|
||||
struct JA_Music_t; // lines 17-17
|
||||
struct JA_Sound_t; // lines 18-18
|
||||
#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_Loa...
|
||||
#include "game/defaults.hpp" // Para GameDefaults::VERSION
|
||||
#include "game/gameplay/room.hpp" // Para RoomData, loadRoomFile, loadRoomTileFile
|
||||
#include "game/options.hpp" // Para Options, OptionsGame, options
|
||||
#include "utils/defines.hpp" // Para WINDOW_CAPTION
|
||||
#include "utils/utils.hpp" // Para getFileName, printWithDots, PaletteColor
|
||||
#include "version.h" // Para Version::GIT_HASH
|
||||
struct JA_Music_t; // lines 17-17
|
||||
struct JA_Sound_t; // lines 18-18
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Resource* Resource::resource = nullptr;
|
||||
@@ -406,21 +406,23 @@ void Resource::calculateTotal() {
|
||||
|
||||
// Muestra el progreso de carga
|
||||
void Resource::renderProgress() {
|
||||
constexpr float X_PADDING = 10;
|
||||
constexpr float Y_PADDING = 10;
|
||||
constexpr float BAR_HEIGHT = 10;
|
||||
constexpr float X_PADDING = 60.0F;
|
||||
constexpr float Y_PADDING = 10.0F;
|
||||
constexpr float BAR_HEIGHT = 5.0F;
|
||||
|
||||
const float BAR_POSITION = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
||||
Screen::get()->start();
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
const Uint8 TEXT_COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
const Uint8 TEXT_COLOR = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE);
|
||||
const Uint8 BAR_COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
const int TEXT_HEIGHT = loading_text_->getCharacterSize();
|
||||
const int CENTER_X = Options::game.width / 2;
|
||||
const int CENTER_Y = Options::game.height / 2;
|
||||
|
||||
// Draw APP_NAME centered above center
|
||||
const std::string APP_NAME = WINDOW_CAPTION;
|
||||
const std::string APP_NAME = spaceBetweenLetters(Version::APP_NAME);
|
||||
loading_text_->writeColored(
|
||||
CENTER_X - (loading_text_->lenght(APP_NAME) / 2),
|
||||
CENTER_Y - TEXT_HEIGHT,
|
||||
@@ -437,13 +439,13 @@ void Resource::renderProgress() {
|
||||
|
||||
// Draw progress bar border
|
||||
const float WIRED_BAR_WIDTH = Options::game.width - (X_PADDING * 2);
|
||||
SDL_FRect rect_wired = {X_PADDING, BAR_POSITION, WIRED_BAR_WIDTH, X_PADDING};
|
||||
surface->drawRectBorder(&rect_wired, TEXT_COLOR);
|
||||
SDL_FRect rect_wired = {X_PADDING, BAR_POSITION, WIRED_BAR_WIDTH, BAR_HEIGHT};
|
||||
surface->drawRectBorder(&rect_wired, BAR_COLOR);
|
||||
|
||||
// Draw progress bar fill
|
||||
const float FULL_BAR_WIDTH = WIRED_BAR_WIDTH * count_.getPercentage();
|
||||
SDL_FRect rect_full = {X_PADDING, BAR_POSITION, FULL_BAR_WIDTH, X_PADDING};
|
||||
surface->fillRect(&rect_full, TEXT_COLOR);
|
||||
SDL_FRect rect_full = {X_PADDING, BAR_POSITION, FULL_BAR_WIDTH, BAR_HEIGHT};
|
||||
surface->fillRect(&rect_full, BAR_COLOR);
|
||||
|
||||
Screen::get()->render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user