Skip to content

Commit

Permalink
+ brightness options can be changed from the settings menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanduriel committed Sep 28, 2018
1 parent ed5dc55 commit 1e8222a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
4 changes: 3 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ AccBackward [S]
AdjustTargetAcc[Shift] - hold in combination with AccForward/AccBackward
to change the target speed that will be held
Brake[Tab] - Set the target speed to zero
Fire[LeftMouse] - fires all weapons targeting the ray of the cursor
Fire[LeftMouse] - fires weapons in the first group targeting the ray of the cursor
FireOther[RightMouse] - fires weapons in the second group
RollCW[Q] - rolls the ship around the forward axis
RollCCW[E]
Inventory [I] - opens/closes the inventory
SwitchTactical[Space] - once unlocked switches to the tactical targeting
mode that allows usage of special weapons
LockTarget[R] - locks on a ship closest to the center of the screen
Pause[P] - opens the pause menu

MECHANICS ##############################
Expand Down
11 changes: 10 additions & 1 deletion src/gamestates/basicmenustate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ namespace GameStates {
BasicMenuState()
: m_grid(ei::Vec3(0.f, 0.f, 30.f),
Utils::Color32F(0.f, 1.f, 0.f, 0.5f), 3.5f, 3.5f, 80.f,
Game::GridComponent::TransitionInfo(20000.f, 1.f, &Game::GridComponent::Random))
Game::GridComponent::TransitionInfo(20000.f, 1.f, &Game::GridComponent::Random)),
m_oldCamera(Control::g_camera)
{
m_grid.Rotate(ei::Quaternion(ei::normalize(ei::Vec3(1.f, 0.f, 0.f)), ei::PI * 0.5f));
m_grid.Process(0.f);
}

~BasicMenuState()
{
Control::g_camera = m_oldCamera;
}

void Process(float _deltaTime) override
{
m_grid.ProcessComponent(_deltaTime);
Expand All @@ -33,6 +39,8 @@ namespace GameStates {
void OnActivate() override
{
using namespace Control;
m_oldCamera = g_camera;

g_camera.SetPosition(ei::Vec3(0.f, 0.f, -25.f));
g_camera.SetRotation(ei::qidentity());
g_camera.FixRotation(g_camera.GetRotation(), g_camera.GetPosition());
Expand All @@ -44,5 +52,6 @@ namespace GameStates {
}
private:
Game::Grid m_grid;
Control::Camera m_oldCamera;
};
}
12 changes: 10 additions & 2 deletions src/gamestates/huds/settingshud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ namespace GameStates {
label2.SetDefaultSize(0.6f);
// label2.SetPosition(Vec2(-label2.GetRectangle().x, 0.f));

m_masterVolume = &CreateScreenElement<EditField>(PixelOffset(0, -20), PixelOffset(140, 50), DefP::TopLeft, Anchor(DefP::BotLeft, m_frameCountTarget));
TextRender& label3 = CreateScreenElement<TextRender>(Vec2(0.f), Anchor(DefP::MidLeft, m_masterVolume), nullptr, "master volume: ", DefP::MidRight);
m_brightness = &CreateScreenElement<EditField>(PixelOffset(0, -20), PixelOffset(140, 50), DefP::TopLeft, Anchor(DefP::BotLeft, m_frameCountTarget));
TextRender& label3 = CreateScreenElement<TextRender>(Vec2(0.f), Anchor(DefP::MidLeft, m_brightness), nullptr, "brightness: ", DefP::MidRight);
label3.SetDefaultSize(0.6f);

m_contrast = &CreateScreenElement<EditField>(PixelOffset(0, -20), PixelOffset(140, 50), DefP::TopLeft, Anchor(DefP::BotLeft, m_brightness));
TextRender& label4 = CreateScreenElement<TextRender>(Vec2(0.f), Anchor(DefP::MidLeft, m_contrast), nullptr, "contrast: ", DefP::MidRight);
label4.SetDefaultSize(0.6f);

m_masterVolume = &CreateScreenElement<EditField>(PixelOffset(0, -20), PixelOffset(140, 50), DefP::TopLeft, Anchor(DefP::BotLeft, m_contrast));
TextRender& label5 = CreateScreenElement<TextRender>(Vec2(0.f), Anchor(DefP::MidLeft, m_masterVolume), nullptr, "master volume: ", DefP::MidRight);
label5.SetDefaultSize(0.6f);

TextRender& note = CreateScreenElement<TextRender>(Vec2(0.f), Anchor(DefP::TopLeft, m_applyButton), nullptr, "|changes to video settings require a restart", DefP::BotLeft);
note.SetDefaultSize(18_px);
}
Expand Down
3 changes: 3 additions & 0 deletions src/gamestates/huds/settingshud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ namespace GameStates {
Graphic::Button* m_fullScreenButton;
Graphic::EditField* m_frameCountTarget;

Graphic::EditField* m_brightness;
Graphic::EditField* m_contrast;

Graphic::EditField* m_masterVolume;

friend class SettingsState;
Expand Down
22 changes: 21 additions & 1 deletion src/gamestates/settingsstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "control/input.hpp"
#include "GLFW/glfw3.h"
#include "graphic/core/device.hpp"
#include "graphic/core/uniformbuffer.hpp"
#include "control/playercontroller.hpp"
#include "game.hpp"
#include "gameplay/elements/audiocomponent.hpp"
Expand All @@ -25,14 +26,22 @@ namespace GameStates {
auto& cgraphics = config["Graphics"s];

// load current values and display
std::string s = std::to_string(config["Graphics"s]["TargetFPS"s].Get(144.f));
std::string s = std::to_string(cgraphics["TargetFPS"s].Get(144.f));
s.resize(5);
m_hud.m_frameCountTarget->SetText(s);

s = std::to_string(InputManager::GetMouseSensitivity());
s.resize(5);
m_hud.m_mouseSensitivity->SetText(s);

s = std::to_string(cgraphics["Brightness"s].Get(0.f));
s.resize(5);
m_hud.m_brightness->SetText(s);

s = std::to_string(cgraphics["Contrast"s].Get(1.f));
s.resize(5);
m_hud.m_contrast->SetText(s);

// volume
s = std::to_string(Game::AudioSystem::GetVolume());
s.resize(5);
Expand Down Expand Up @@ -87,6 +96,17 @@ namespace GameStates {
f = std::stof(m_hud.m_masterVolume->GetText());
Game::AudioSystem::SetVolume(f);

// brightness params can be updated live
const float brightness = std::stof(m_hud.m_brightness->GetText());
cgraphics["Brightness"s] = (double)brightness;

const float contrast = std::stof(m_hud.m_contrast->GetText());
cgraphics["Contrast"s] = (double)contrast;

Graphic::UniformBuffer& ubo = Graphic::Resources::GetUBO(Graphic::UniformBuffers::BRIGHTNESS_PARAMS);
ubo["Brightness"] = brightness;
ubo["Contrast"] = contrast;

f = std::stof(m_hud.m_frameCountTarget->GetText());
f = std::clamp(f, 30.f, 10000.f);
cgraphics["TargetFPS"s] = (double)std::clamp(f, 30.f, 10000.f);
Expand Down

0 comments on commit 1e8222a

Please sign in to comment.