afegit SDL_ScaleMode scale_mode a VideoOptions
This commit is contained in:
@@ -313,7 +313,7 @@ void Game::updateGameStateGameOver()
|
||||
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
||||
{
|
||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
||||
/*JA_FadeOutMusic(1000);*/
|
||||
JA_FadeOutMusic(1000);
|
||||
balloon_manager_->setSounds(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ void Logo::render()
|
||||
void Logo::run()
|
||||
{
|
||||
// Detiene la música
|
||||
/*JA_FadeOutMusic(300);*/
|
||||
JA_FadeOutMusic(300);
|
||||
|
||||
while (section::name == section::Name::LOGO)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include "options.h"
|
||||
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogWarn
|
||||
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError
|
||||
#include <algorithm> // Para clamp
|
||||
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::...
|
||||
#include <utility> // Para swap
|
||||
#include <vector> // Para vector
|
||||
#include "input.h" // Para InputDeviceToUse
|
||||
#include "lang.h" // Para Code
|
||||
#include "screen.h" // Para ScreenFilter
|
||||
#include "utils.h" // Para boolToString, stringToBool, getFileName
|
||||
|
||||
// Variables
|
||||
@@ -23,7 +22,7 @@ void initOptions()
|
||||
|
||||
// Opciones de video
|
||||
options.video.fullscreen = false;
|
||||
options.video.filter = ScreenFilter::NEAREST;
|
||||
options.video.scale_mode = SDL_ScaleMode::SDL_SCALEMODE_NEAREST;
|
||||
options.video.v_sync = true;
|
||||
options.video.integer_scale = true;
|
||||
options.video.shaders = false;
|
||||
@@ -118,12 +117,12 @@ bool saveOptionsFile(std::string file_path)
|
||||
|
||||
// Opciones de video
|
||||
file << "## VIDEO\n";
|
||||
file << "## video.filter [" << static_cast<int>(ScreenFilter::NEAREST) << ": nearest, " << static_cast<int>(ScreenFilter::LINEAL) << ": lineal]\n";
|
||||
file << "## video.scale_mode [" << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_NEAREST) << ": nearest, " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_LINEAR) << ": lineal]\n";
|
||||
file << "\n";
|
||||
|
||||
file << "window.zoom=" << options.window.zoom << "\n";
|
||||
file << "video.fullscreen=" << boolToString(options.video.fullscreen) << "\n";
|
||||
file << "video.filter=" << static_cast<int>(options.video.filter) << "\n";
|
||||
file << "video.scale_mode=" << static_cast<int>(options.video.scale_mode) << "\n";
|
||||
file << "video.v_sync=" << boolToString(options.video.v_sync) << "\n";
|
||||
file << "video.integer_scale=" << boolToString(options.video.integer_scale) << "\n";
|
||||
file << "video.shaders=" << boolToString(options.video.shaders) << "\n";
|
||||
@@ -190,14 +189,10 @@ bool setOptions(const std::string &var, const std::string &value)
|
||||
else if (var == "window.zoom")
|
||||
{
|
||||
options.window.zoom = std::stoi(value);
|
||||
if ((options.window.zoom < 1) || (options.window.zoom > 4))
|
||||
{
|
||||
options.window.zoom = 3;
|
||||
}
|
||||
}
|
||||
else if (var == "video.filter")
|
||||
else if (var == "video.scale_mode")
|
||||
{
|
||||
options.video.filter = static_cast<ScreenFilter>(std::stoi(value));
|
||||
options.video.scale_mode = static_cast<SDL_ScaleMode>(std::stoi(value));
|
||||
}
|
||||
else if (var == "video.shaders")
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_gamepad.h> // Para SDL_GamepadButton
|
||||
#include <SDL3/SDL_surface.h> // Para SDL_ScaleMode
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
#include "input.h" // Para InputAction, InputDeviceToUse
|
||||
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||
enum class ScreenFilter : int; // lines 8-8
|
||||
namespace lang
|
||||
{
|
||||
enum class Code : int;
|
||||
@@ -30,12 +30,12 @@ struct WindowOptions
|
||||
// Estructura con opciones para el video
|
||||
struct VideoOptions
|
||||
{
|
||||
ScreenFilter filter; // Filtro usado para el escalado de la imagen
|
||||
bool fullscreen; // Contiene el valor del modo de pantalla completa
|
||||
bool v_sync; // Indica si se quiere usar vsync o no
|
||||
bool integer_scale; // Indica si se va a usar el escalado entero
|
||||
bool shaders; // Indica si se van a usar shaders para los filtros de video
|
||||
std::string info; // Información sobre el modo de video
|
||||
SDL_ScaleMode scale_mode; // Filtro usado para el escalado de la imagen
|
||||
bool fullscreen; // Contiene el valor del modo de pantalla completa
|
||||
bool v_sync; // Indica si se quiere usar vsync o no
|
||||
bool integer_scale; // Indica si se va a usar el escalado entero
|
||||
bool shaders; // Indica si se van a usar shaders para los filtros de video
|
||||
std::string info; // Información sobre el modo de video
|
||||
};
|
||||
|
||||
// Estructura para las opciones de musica
|
||||
|
||||
@@ -317,12 +317,6 @@ bool Screen::initSDL()
|
||||
|
||||
getDisplayInfo();
|
||||
|
||||
// Establece el filtro de la textura
|
||||
/*if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
|
||||
{
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: texture filtering not enabled!");
|
||||
}*/
|
||||
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
||||
{
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: opengl not enabled!");
|
||||
|
||||
@@ -9,12 +9,6 @@
|
||||
#include "param.h" // Para Param, ParamGame, param
|
||||
#include "utils.h" // Para Color
|
||||
|
||||
enum class ScreenFilter : int
|
||||
{
|
||||
NEAREST = 0,
|
||||
LINEAL = 1,
|
||||
};
|
||||
|
||||
class Screen
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -302,28 +302,28 @@ bool stringInVector(const std::vector<std::string> &vec, const std::string &str)
|
||||
// Imprime por pantalla una línea de texto de tamaño fijo rellena con puntos
|
||||
void printWithDots(const std::string &text1, const std::string &text2, const std::string &text3)
|
||||
{
|
||||
const size_t TOTAL_WIDTH = 50;
|
||||
constexpr size_t TOTAL_WIDTH = 52;
|
||||
|
||||
// Calcula el ancho del campo para text2 restando la longitud de text1 y text3
|
||||
size_t fieldWidth = TOTAL_WIDTH > (text1.size() + text3.size())
|
||||
size_t field_width = TOTAL_WIDTH > (text1.size() + text3.size())
|
||||
? TOTAL_WIDTH - text1.size() - text3.size()
|
||||
: 0;
|
||||
|
||||
// Prepara el bloque a imprimir a partir de text2
|
||||
std::string fieldText;
|
||||
if (text2.size() < fieldWidth)
|
||||
std::string field_text;
|
||||
if (text2.size() < field_width)
|
||||
{
|
||||
// Si text2 es más corto, lo rellenamos a la derecha con puntos
|
||||
fieldText = text2 + std::string(fieldWidth - text2.size(), '.');
|
||||
field_text = text2 + std::string(field_width - text2.size(), '.');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si es demasiado largo, lo cortamos
|
||||
fieldText = text2.substr(0, fieldWidth);
|
||||
field_text = text2.substr(0, field_width);
|
||||
}
|
||||
|
||||
// Concatena todo
|
||||
std::string formatted_text = text1 + fieldText + text3;
|
||||
std::string formatted_text = text1 + field_text + text3;
|
||||
|
||||
// Imprime la línea formateada usando SDL_LogInfo
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", formatted_text.c_str());
|
||||
|
||||
Reference in New Issue
Block a user