Sistema de notificacions amb presets (F4, llisca des de dalt) (v0.9.0)
This commit is contained in:
1 parent
96cbdf96b6
commit
1b430500f4
10 files changed
+208
-10
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "core/rendering/notifier.hpp"
|
||||
#include "core/rendering/render_info.hpp"
|
||||
#include "core/rendering/screen.hpp"
|
||||
#include "core/resources/resource_cache.hpp"
|
||||
@@ -35,17 +36,20 @@ void GameScene::update(int delta_ms) {
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
if (event.key.scancode == SDL_SCANCODE_ESCAPE) { wants_quit_ = true; }
|
||||
if (event.key.scancode == SDL_SCANCODE_F3) { RenderInfo::get().toggle(); }
|
||||
if (event.key.scancode == SDL_SCANCODE_F4) { Notifier::get().notify("notificacio de prova"); }
|
||||
}
|
||||
}
|
||||
|
||||
const float DT = static_cast<float>(delta_ms) / 1000.0F;
|
||||
for (auto& player : players_) { player->update(DT); }
|
||||
RenderInfo::get().update(delta_ms);
|
||||
Notifier::get().update(delta_ms);
|
||||
}
|
||||
|
||||
void GameScene::render() {
|
||||
Screen::get().clear(0x00, 0x00, 0x00);
|
||||
for (auto& player : players_) { player->render(); }
|
||||
Notifier::get().render();
|
||||
RenderInfo::get().render();
|
||||
Screen::get().present();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
// Temes per a les notificacions de pantalla. Un "preset" captura els dos
|
||||
// colors (text i fons, índexs sobre la paleta "ui") i el temps de visibilitat
|
||||
// en mil·lisegons. Qualsevol component que cride Notifier::notify(text)
|
||||
// rebrà l'estil DEFAULT; si necessita un altre look, pot passar el preset per
|
||||
// nom o especificar els camps un a un.
|
||||
namespace Notification {
|
||||
|
||||
struct Preset {
|
||||
Uint8 text_color;
|
||||
Uint8 bg_color;
|
||||
int time_ms;
|
||||
};
|
||||
|
||||
// Tema per defecte: text clar sobre fons fosc, 2 segons de visibilitat.
|
||||
// Per a ajustar l'aparença global de totes les notificacions sense
|
||||
// presetejar-les manualment, toca només aquest bloc.
|
||||
constexpr Preset DEFAULT{
|
||||
.text_color = 15,
|
||||
.bg_color = 0,
|
||||
.time_ms = 2000,
|
||||
};
|
||||
|
||||
} // namespace Notification
|
||||
Reference in new issue
Block a user