forked from jaildesigner-jailgames/jaildoctors_dilemma
canviat Options de struct a namespace
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
#include <string> // Para string, basic_string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "external/jail_audio.h" // Para JA_PlaySound
|
||||
#include "game/gameplay/options.hpp" // Para Options, options, NotificationPosition
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "external/jail_audio.h" // Para JA_PlaySound
|
||||
#include "game/gameplay/options.hpp" // Para Options, options, NotificationPosition
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
|
||||
// [SINGLETON]
|
||||
Notifier* Notifier::notifier_ = nullptr;
|
||||
@@ -38,7 +38,7 @@ Notifier* Notifier::get() {
|
||||
Notifier::Notifier(const std::string& icon_file, const std::string& text)
|
||||
: icon_surface_(!icon_file.empty() ? Resource::get()->getSurface(icon_file) : nullptr),
|
||||
text_(Resource::get()->getText(text)),
|
||||
bg_color_(options.notifications.color),
|
||||
bg_color_(Options::notifications.color),
|
||||
stack_(false),
|
||||
has_icons_(!icon_file.empty()) {}
|
||||
|
||||
@@ -62,7 +62,7 @@ void Notifier::update() {
|
||||
|
||||
switch (notification.state) {
|
||||
case NotificationStatus::RISING: {
|
||||
const int DIRECTION = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? 1 : -1;
|
||||
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
|
||||
notification.rect.y += DIRECTION;
|
||||
|
||||
if (notification.rect.y == notification.y) {
|
||||
@@ -80,7 +80,7 @@ void Notifier::update() {
|
||||
}
|
||||
|
||||
case NotificationStatus::VANISHING: {
|
||||
const int DIRECTION = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? -1 : 1;
|
||||
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? -1 : 1;
|
||||
notification.rect.y += DIRECTION;
|
||||
|
||||
if (notification.rect.y == notification.y - notification.travel_dist) {
|
||||
@@ -140,23 +140,23 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
const auto PADDING_IN_V = text_size / 2;
|
||||
const int ICON_SPACE = icon >= 0 ? ICON_SIZE_ + PADDING_IN_H : 0;
|
||||
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
|
||||
const float WIDTH = options.game.width - (PADDING_OUT_ * 2);
|
||||
const float WIDTH = Options::game.width - (PADDING_OUT_ * 2);
|
||||
const float HEIGHT = (text_size * texts.size()) + (PADDING_IN_V * 2);
|
||||
const auto SHAPE = NotificationShape::SQUARED;
|
||||
|
||||
// Posición horizontal
|
||||
float desp_h = 0;
|
||||
switch (options.notifications.getHorizontalPosition()) {
|
||||
case NotificationPosition::LEFT:
|
||||
switch (Options::notifications.getHorizontalPosition()) {
|
||||
case Options::NotificationPosition::LEFT:
|
||||
desp_h = PADDING_OUT_;
|
||||
break;
|
||||
|
||||
case NotificationPosition::CENTER:
|
||||
desp_h = ((options.game.width / 2) - (WIDTH / 2));
|
||||
case Options::NotificationPosition::CENTER:
|
||||
desp_h = ((Options::game.width / 2) - (WIDTH / 2));
|
||||
break;
|
||||
|
||||
case NotificationPosition::RIGHT:
|
||||
desp_h = options.game.width - WIDTH - PADDING_OUT_;
|
||||
case Options::NotificationPosition::RIGHT:
|
||||
desp_h = Options::game.width - WIDTH - PADDING_OUT_;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -165,11 +165,11 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
}
|
||||
|
||||
// Posición vertical
|
||||
const int DESP_V = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? PADDING_OUT_ : options.game.height - HEIGHT - PADDING_OUT_;
|
||||
const int DESP_V = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? PADDING_OUT_ : Options::game.height - HEIGHT - PADDING_OUT_;
|
||||
|
||||
// Offset
|
||||
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT_;
|
||||
const int TRAVEL_MOD = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? 1 : -1;
|
||||
const int TRAVEL_MOD = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
|
||||
const int OFFSET = !notifications_.empty() ? notifications_.back().y + TRAVEL_MOD * notifications_.back().travel_dist : DESP_V;
|
||||
|
||||
// Crea la notificacion
|
||||
@@ -183,7 +183,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
n.texts = texts;
|
||||
n.shape = SHAPE;
|
||||
n.display_duration = display_duration;
|
||||
const float Y_POS = OFFSET + ((options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? -TRAVEL_DIST : TRAVEL_DIST);
|
||||
const float Y_POS = OFFSET + ((Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? -TRAVEL_DIST : TRAVEL_DIST);
|
||||
n.rect = {desp_h, Y_POS, WIDTH, HEIGHT};
|
||||
|
||||
// Crea la textura
|
||||
|
||||
Reference in New Issue
Block a user