Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ set(MAIN_SOURCES
src/screens/windowScreen.cpp
src/screens/mainScreen.cpp
src/screens/spectatorScreen.cpp
src/screens/baseShipScreen.cpp
src/screens/crew4/operationsScreen.cpp
src/screens/crew4/engineeringAdvancedScreen.cpp
src/screens/crew4/tacticalScreen.cpp
Expand Down
18 changes: 18 additions & 0 deletions resources/gui/default.theme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# Background color and images
[background] {
color: #1F252D
[background.red_alert] {
color: #401216
}
[background.yellow_alert] {
color: #404016
}
[background.crosses] {
image: gui/background/crosses.png
}
Expand Down Expand Up @@ -151,6 +157,12 @@
color: #FF0000
color.disabled: #A08080
}
[button.yellow_alert.back] {
color: #FFFF00
}
[button.red_alert.back] {
color: #FF0000
}
[button.toggle.off.back] {
}
[button.toggle.on.back] {
Expand All @@ -172,6 +184,12 @@
color.active: #120000
color.disabled: #FF00004D
}
[button.yellow_alert.front] {
color: #FFFF00
}
[button.red_alert.front] {
color: #FF0000
}
[button.toggle.off.front] {
}
[button.toggle.on.front] {
Expand Down
39 changes: 35 additions & 4 deletions src/screenComponents/alertLevelButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,49 @@
#include "playerInfo.h"
#include "gui/gui2_togglebutton.h"

string styleForLevel(AlertLevel level) {
switch (level) {
case AlertLevel::YellowAlert:
return "button.yellow_alert";
case AlertLevel::RedAlert:
return "button.red_alert";
default:
return "button";
}
}

GuiAlertLevelSelect::GuiAlertLevelSelect(GuiContainer* owner, string id)
: GuiElement(owner, id)
: GuiElement(owner, id), last_level(AlertLevel::Normal)
{
// Alert level buttons.
auto alert_level_button = new GuiToggleButton(this, "", tr("Alert level"), [this](bool value)
alert_level_button = new GuiToggleButton(this, "", tr("Alert level"), [this](bool value)
{
for(GuiButton* button : alert_level_buttons)
button->setVisible(value);
});
alert_level_button->setValue(false);
alert_level_button->setStyle(styleForLevel(AlertLevel::Normal));
alert_level_button->setSize(GuiElement::GuiSizeMax, 50);

for(int level=int(AlertLevel::Normal); level < int(AlertLevel::MAX); level++)
{
GuiButton* alert_button = new GuiButton(this, "", alertLevelToLocaleString(AlertLevel(level)), [this, level, alert_level_button]()
auto text = alertLevelToLocaleString(AlertLevel(level));
auto mainText = AlertLevel(level) == AlertLevel::Normal ? tr("Alert level") : text;
auto style = styleForLevel(AlertLevel(level));

GuiButton* alert_button = new GuiButton(this, "", text, [this, level, mainText, style]()
{
if (my_spaceship)
my_player_info->commandSetAlertLevel(AlertLevel(level));
for(GuiButton* button : alert_level_buttons)
button->setVisible(false);
alert_level_button->setValue(false);
alert_level_button->setText(mainText);
alert_level_button->setStyle(style);
});
alert_button->setVisible(false);
alert_button->setSize(GuiElement::GuiSizeMax, 50);
alert_button->setStyle(style);
alert_level_buttons.push_back(alert_button);
}
}
Expand All @@ -43,5 +61,18 @@ void GuiAlertLevelSelect::onUpdate()
my_player_info->commandSetAlertLevel(AlertLevel::YellowAlert);
if (keys.relay_alert_level_red.getDown())
my_player_info->commandSetAlertLevel(AlertLevel::RedAlert);

if (auto pc = my_spaceship.getComponent<PlayerControl>()) {
if (last_level != pc->alert_level) {
last_level = pc->alert_level;

alert_level_button->setStyle(styleForLevel(pc->alert_level));
alert_level_button->setText(
pc->alert_level == AlertLevel::Normal
? tr("Alert level")
: alertLevelToLocaleString(pc->alert_level)
);
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/screenComponents/alertLevelButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define ALERT_LEVEL_BUTTON_H

#include "gui/gui2_button.h"
#include "gui/gui2_togglebutton.h"
#include "components/player.h"

class GuiAlertLevelSelect : public GuiElement
{
Expand All @@ -12,6 +14,8 @@ class GuiAlertLevelSelect : public GuiElement

private:
std::vector<GuiButton*> alert_level_buttons;
GuiToggleButton* alert_level_button;
AlertLevel last_level;
};

#endif//ALERT_LEVEL_BUTTON_H
25 changes: 0 additions & 25 deletions src/screenComponents/indicatorOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ void GuiIndicatorOverlays::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
drawAlertLevel(renderer);

float shield_hit = 0.0;
bool low_shields = false;
auto shields = my_spaceship.getComponent<Shields>();
Expand Down Expand Up @@ -166,26 +164,3 @@ bool GuiIndicatorOverlays::onMouseDown(sp::io::Pointer::Button button, glm::vec2
return true;
return false;
}

void GuiIndicatorOverlays::drawAlertLevel(sp::RenderTarget& renderer)
{
glm::u8vec4 multiply_color{255,255,255,255};

auto pc = my_spaceship.getComponent<PlayerControl>();
if (!pc) return;

switch(pc->alert_level)
{
case AlertLevel::RedAlert:
multiply_color = glm::u8vec4(255, 192, 192, 255);
break;
case AlertLevel::YellowAlert:
multiply_color = glm::u8vec4(255, 255, 192, 255);
break;
case AlertLevel::Normal:
default:
return;
}

renderer.drawRectColorMultiply(rect, multiply_color);
}
2 changes: 0 additions & 2 deletions src/screenComponents/indicatorOverlays.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class GuiIndicatorOverlays : public GuiElement
virtual bool onMouseDown(sp::io::Pointer::Button button, glm::vec2 position, sp::io::Pointer::ID id) override;

void hasGlobalMessage() { has_global_message = true; }
private:
void drawAlertLevel(sp::RenderTarget& renderer);
};

#endif//INDICATOR_OVERLAYS_H
37 changes: 37 additions & 0 deletions src/screens/baseShipScreen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "screens/baseShipScreen.h"
#include "components/player.h"
#include "gui/theme.h"
#include "playerInfo.h"
#include "screenComponents/alertOverlay.h"

BaseShipScreen::BaseShipScreen(GuiContainer* owner, string id)
: GuiOverlay(owner, id, GuiTheme::getColor("background")),
bg_default(GuiTheme::getColor("background")),
bg_yellow(GuiTheme::getColor("background.yellow_alert")),
bg_red(GuiTheme::getColor("background.red_alert"))
{
background_crosses = new GuiOverlay(this, "BACKGROUND_CROSSES", glm::u8vec4{255,255,255,255});
background_crosses->setTextureTiledThemed("background.crosses");

new AlertLevelOverlay(this);
}

void BaseShipScreen::onUpdate() {
auto level = AlertLevel::Normal;

if (my_spaceship)
if (auto pc = my_spaceship.getComponent<PlayerControl>())
level = pc->alert_level;

switch (level) {
case AlertLevel::RedAlert:
setColor(bg_red);
break;
case AlertLevel::YellowAlert:
setColor(bg_yellow);
break;
default:
setColor(bg_default);
break;
}
}
17 changes: 17 additions & 0 deletions src/screens/baseShipScreen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "gui/gui2_overlay.h"

class BaseShipScreen : public GuiOverlay
{
public:
glm::ivec4 bg_default;
glm::ivec4 bg_yellow;
glm::ivec4 bg_red;

GuiOverlay* background_crosses;

BaseShipScreen(GuiContainer* owner, string id);

virtual void onUpdate() override;
};
11 changes: 3 additions & 8 deletions src/screens/crew1/singlePilotScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,12 @@
#include "gui/gui2_label.h"

SinglePilotScreen::SinglePilotScreen(GuiContainer* owner)
: GuiOverlay(owner, "SINGLEPILOT_SCREEN", GuiTheme::getColor("background"))
: BaseShipScreen(owner, "SINGLEPILOT_SCREEN")
{
// setColor(GuiTheme::getColor("background"));
// Render the radar shadow and background decorations.
(new GuiImage(this, "BACKGROUND_GRADIENT", ""))->setTextureThemed("background.gradient_single")->setPosition(glm::vec2(0, 0), sp::Alignment::Center)->setSize(1200, 900);

background_crosses = new GuiOverlay(this, "BACKGROUND_CROSSES", glm::u8vec4{255,255,255,255});
background_crosses->setTextureTiledThemed("background.crosses");

// Render the alert level color overlay.
(new AlertLevelOverlay(this));

// 5U tactical radar with piloting features.
radar = new GuiRadarView(this, "TACTICAL_RADAR", &targets);
radar->setPosition(0, 0, sp::Alignment::Center)->setSize(GuiElement::GuiSizeMatchHeight, 650);
Expand Down Expand Up @@ -157,11 +151,12 @@ void SinglePilotScreen::onDraw(sp::RenderTarget& renderer)
else
targets.set(sp::ecs::Entity{});
}
GuiOverlay::onDraw(renderer);
BaseShipScreen::onDraw(renderer);
}

void SinglePilotScreen::onUpdate()
{
BaseShipScreen::onUpdate();
if (my_spaceship && isVisible())
{
auto angle = (keys.helms_turn_right.getValue() - keys.helms_turn_left.getValue()) * 5.0f;
Expand Down
6 changes: 2 additions & 4 deletions src/screens/crew1/singlePilotScreen.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SINGLE_PILOT_SCREEN_H
#define SINGLE_PILOT_SCREEN_H

#include "gui/gui2_overlay.h"
#include "screens/baseShipScreen.h"
#include "screenComponents/targetsContainer.h"
#include "gui/joystickConfig.h"

Expand All @@ -13,11 +13,9 @@ class GuiToggleButton;
class GuiRotationDial;
class GuiCombatManeuver;

class SinglePilotScreen : public GuiOverlay
class SinglePilotScreen : public BaseShipScreen
{
private:
GuiOverlay* background_crosses;

GuiElement* warp_controls;
GuiElement* jump_controls;
GuiCombatManeuver* combat_maneuver;
Expand Down
11 changes: 3 additions & 8 deletions src/screens/crew4/tacticalScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@
#include "gui/gui2_rotationdial.h"

TacticalScreen::TacticalScreen(GuiContainer* owner)
: GuiOverlay(owner, "TACTICAL_SCREEN", GuiTheme::getColor("background"))
: BaseShipScreen(owner, "TACTICAL_SCREEN")
{
// Render the radar shadow and background decorations.
(new GuiImage(this, "BACKGROUND_GRADIENT", ""))->setTextureThemed("background.gradient_single")->setPosition(glm::vec2(0, 0), sp::Alignment::Center)->setSize(1200, 900);

background_crosses = new GuiOverlay(this, "BACKGROUND_CROSSES", glm::u8vec4{255,255,255,255});
background_crosses->setTextureTiledThemed("background.crosses");

// Render the alert level color overlay.
(new AlertLevelOverlay(this));

// Short-range tactical radar with a 5U range.
radar = new GuiRadarView(this, "TACTICAL_RADAR", &targets);
radar->setPosition(0, 0, sp::Alignment::Center)->setSize(GuiElement::GuiSizeMatchHeight, 750);
Expand Down Expand Up @@ -137,11 +131,12 @@ void TacticalScreen::onDraw(sp::RenderTarget& renderer)
auto target = my_spaceship.getComponent<Target>();
targets.set(target ? target->entity : sp::ecs::Entity{});
}
GuiOverlay::onDraw(renderer);
BaseShipScreen::onDraw(renderer);
}

void TacticalScreen::onUpdate()
{
BaseShipScreen::onUpdate();
if (my_spaceship && isVisible())
{
auto angle = (keys.helms_turn_right.getValue() - keys.helms_turn_left.getValue()) * 5.0f;
Expand Down
6 changes: 2 additions & 4 deletions src/screens/crew4/tacticalScreen.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TACTICAL_SCREEN_H
#define TACTICAL_SCREEN_H

#include "gui/gui2_overlay.h"
#include "screens/baseShipScreen.h"
#include "screenComponents/targetsContainer.h"
#include "gui/joystickConfig.h"

Expand All @@ -11,11 +11,9 @@ class GuiKeyValueDisplay;
class GuiToggleButton;
class GuiRotationDial;

class TacticalScreen : public GuiOverlay
class TacticalScreen : public BaseShipScreen
{
private:
GuiOverlay* background_crosses;

GuiElement* warp_controls;
GuiElement* jump_controls;

Expand Down
11 changes: 3 additions & 8 deletions src/screens/crew6/engineeringScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,11 @@
#include "gui/gui2_panel.h"

EngineeringScreen::EngineeringScreen(GuiContainer* owner, CrewPosition crew_position)
: GuiOverlay(owner, "ENGINEERING_SCREEN", GuiTheme::getColor("background"))
: BaseShipScreen(owner, "ENGINEERING_SCREEN")
{
slider_tick_style = theme->getStyle("slider.tick");
overlay_damaged_style = theme->getStyle("overlay.damaged");
overlay_overheating_style = theme->getStyle("overlay.overheating");
// Render the background decorations.
background_crosses = new GuiOverlay(this, "BACKGROUND_CROSSES", glm::u8vec4{255,255,255,255});
background_crosses->setTextureTiledThemed("background.crosses");

// Render the alert level color overlay.
(new AlertLevelOverlay(this));

auto stats = new GuiElement(this, "ENGINEER_STATS");
stats->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(240, 200)->setAttribute("layout", "vertical");
Expand Down Expand Up @@ -372,11 +366,12 @@ void EngineeringScreen::onDraw(sp::RenderTarget& renderer)
}
}
}
GuiOverlay::onDraw(renderer);
BaseShipScreen::onDraw(renderer);
}

void EngineeringScreen::onUpdate()
{
BaseShipScreen::onUpdate();
if (my_spaceship && isVisible())
{
auto coolant = my_spaceship.getComponent<Coolant>();
Expand Down
Loading
Loading