Make Renderer presets static

This commit is contained in:
Tamás Bálint Misius 2024-08-20 23:19:32 +02:00
parent f52e047037
commit 77edec62d1
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
4 changed files with 72 additions and 71 deletions

View File

@ -55,7 +55,7 @@ public:
uint32_t renderMode = 0;
uint32_t colorMode = 0;
uint32_t displayMode = 0;
std::vector<RenderPreset> renderModePresets;
static const std::vector<RenderPreset> renderModePresets;
//
unsigned char fire_r[YCELLS][XCELLS];
unsigned char fire_g[YCELLS][XCELLS];

View File

@ -5,6 +5,75 @@
#include "simulation/ElementClasses.h"
#include "simulation/ElementGraphics.h"
const std::vector<RenderPreset> Renderer::renderModePresets = {
{
"Alternative Velocity Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRC,
0,
},
{
"Velocity Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRV,
0,
},
{
"Pressure Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRP,
0,
},
{
"Persistent Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_PERS,
0,
},
{
"Fire Display",
RENDER_FIRE | RENDER_SPRK | RENDER_EFFE | RENDER_BASC,
0,
0,
},
{
"Blob Display",
RENDER_FIRE | RENDER_SPRK | RENDER_EFFE | RENDER_BLOB,
0,
0,
},
{
"Heat Display",
RENDER_BASC,
DISPLAY_AIRH,
COLOUR_HEAT,
},
{
"Fancy Display",
RENDER_FIRE | RENDER_SPRK | RENDER_GLOW | RENDER_BLUR | RENDER_EFFE | RENDER_BASC,
DISPLAY_WARP,
0,
},
{
"Nothing Display",
RENDER_BASC,
0,
0,
},
{
"Heat Gradient Display",
RENDER_BASC,
0,
COLOUR_GRAD,
},
{
"Life Gradient Display",
RENDER_BASC,
0,
COLOUR_LIFE,
},
};
void Renderer::clearScreen()
{
if(displayMode & DISPLAY_PERS)
@ -130,74 +199,6 @@ Renderer::Renderer():
//Set defauly display modes
ResetModes();
//Render mode presets. Possibly load from config in future?
renderModePresets.push_back({
"Alternative Velocity Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRC,
0,
});
renderModePresets.push_back({
"Velocity Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRV,
0,
});
renderModePresets.push_back({
"Pressure Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_AIRP,
0,
});
renderModePresets.push_back({
"Persistent Display",
RENDER_EFFE | RENDER_BASC,
DISPLAY_PERS,
0,
});
renderModePresets.push_back({
"Fire Display",
RENDER_FIRE | RENDER_SPRK | RENDER_EFFE | RENDER_BASC,
0,
0,
});
renderModePresets.push_back({
"Blob Display",
RENDER_FIRE | RENDER_SPRK | RENDER_EFFE | RENDER_BLOB,
0,
0,
});
renderModePresets.push_back({
"Heat Display",
RENDER_BASC,
DISPLAY_AIRH,
COLOUR_HEAT,
});
renderModePresets.push_back({
"Fancy Display",
RENDER_FIRE | RENDER_SPRK | RENDER_GLOW | RENDER_BLUR | RENDER_EFFE | RENDER_BASC,
DISPLAY_WARP,
0,
});
renderModePresets.push_back({
"Nothing Display",
RENDER_BASC,
0,
0,
});
renderModePresets.push_back({
"Heat Gradient Display",
RENDER_BASC,
0,
COLOUR_GRAD,
});
renderModePresets.push_back({
"Life Gradient Display",
RENDER_BASC,
0,
COLOUR_LIFE,
});
prepare_alpha(CELL, 1.0f);
}

View File

@ -852,7 +852,7 @@ void GameController::ToggleNewtonianGravity()
void GameController::LoadRenderPreset(int presetNum)
{
Renderer * renderer = gameModel->GetRenderer();
RenderPreset preset = renderer->renderModePresets[presetNum];
RenderPreset preset = Renderer::renderModePresets[presetNum];
gameModel->SetInfoTip(preset.Name);
renderer->SetRenderMode(preset.renderMode);
renderer->SetDisplayMode(preset.displayMode);

View File

@ -65,7 +65,7 @@ uint32_t RenderModel::GetColorMode()
void RenderModel::LoadRenderPreset(int presetNum)
{
RenderPreset preset = renderer->renderModePresets[presetNum];
RenderPreset preset = Renderer::renderModePresets[presetNum];
SetRenderMode(preset.renderMode);
SetDisplayMode(preset.displayMode);
SetColorMode(preset.colorMode);