Skip to content

Commit

Permalink
Fix bugs found by MuerteFR
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Dec 21, 2024
1 parent 1131633 commit 2e32486
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 165 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ set(MAIN_SOURCES
src/screenComponents/shieldFreqencySelect.cpp
src/screenComponents/jumpControls.cpp
src/screenComponents/impulseControls.cpp
src/screenComponents/infoDisplay.cpp
src/screenComponents/frequencyCurve.cpp
src/screenComponents/noiseOverlay.cpp
src/screenComponents/powerDamageIndicator.cpp
Expand Down Expand Up @@ -573,6 +574,7 @@ set(MAIN_SOURCES
src/screenComponents/hackingDialog.h
src/screenComponents/helpOverlay.h
src/screenComponents/impulseControls.h
src/screenComponents/infoDisplay.h
src/screenComponents/impulseSound.h
src/screenComponents/indicatorOverlays.h
src/screenComponents/jumpControls.h
Expand Down
2 changes: 2 additions & 0 deletions scripts/api/entity/spacestation.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__default_station_faction = "Independent"

--- A SpaceStation is an immobile ship-like object that repairs, resupplies, and recharges ships that dock with it.
--- It sets several ShipTemplateBasedObject properties upon creation:
Expand All @@ -13,5 +14,6 @@ function SpaceStation()
transform = {rotation=random(0, 360)},
callsign = {callsign=generateRandomCallSign("DS")},
}
e:setFaction(__default_station_faction)
return e
end
1 change: 0 additions & 1 deletion scripts/api/gm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ function getSpawnableGMObjects()
result[#result+1] = {function() return WarpJammer() end, _("create", "Warp Jammer"), _("create", "Various")}
result[#result+1] = {function() return Mine() end, _("create", "Mine"), _("create", "Various")}
result[#result+1] = {function() return SupplyDrop():setEnergy(500):setWeaponStorage('Nuke', 1):setWeaponStorage('Homing', 4):setWeaponStorage('Mine', 2):setWeaponStorage('EMP', 1) end, _("create", "Supply Drop"), _("create", "Various")}
result[#result+1] = {function() return Asteroid() end, _("create", "Mine"), _("create", "Various")}
result[#result+1] = {function() return Asteroid() end, _("create", "Asteroid"), _("create", "Various")}
result[#result+1] = {function() return VisualAsteroid() end, _("create", "Visual Asteroid"), _("create", "Various")}
result[#result+1] = {function() return Planet() end, _("create", "Planet"), _("create", "Various")}
Expand Down
39 changes: 8 additions & 31 deletions src/screens/crew1/singlePilotScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "screenComponents/beamFrequencySelector.h"
#include "screenComponents/beamTargetSelector.h"
#include "screenComponents/powerDamageIndicator.h"
#include "screenComponents/infoDisplay.h"

#include "screenComponents/openCommsButton.h"
#include "screenComponents/commsOverlay.h"
Expand Down Expand Up @@ -88,14 +89,14 @@ SinglePilotScreen::SinglePilotScreen(GuiContainer* owner)

auto stats = new GuiElement(this, "STATS");
stats->setPosition(-20, -20, sp::Alignment::BottomRight)->setSize(240, 160)->setAttribute("layout", "vertical");
energy_display = new GuiKeyValueDisplay(stats, "ENERGY_DISPLAY", 0.45, tr("Energy"), "");
auto energy_display = new EnergyInfoDisplay(stats, "ENERGY_DISPLAY", 0.45);
energy_display->setIcon("gui/icons/energy")->setTextSize(20)->setSize(240, 40);
heading_display = new GuiKeyValueDisplay(stats, "HEADING_DISPLAY", 0.45, tr("Heading"), "");
heading_display->setIcon("gui/icons/heading")->setTextSize(20)->setSize(240, 40);
velocity_display = new GuiKeyValueDisplay(stats, "VELOCITY_DISPLAY", 0.45, tr("Speed"), "");
velocity_display->setIcon("gui/icons/speed")->setTextSize(20)->setSize(240, 40);
shields_display = new GuiKeyValueDisplay(stats, "SHIELDS_DISPLAY", 0.45, tr("Shields"), "");
shields_display->setIcon("gui/icons/shields")->setTextSize(20)->setSize(240, 40);
auto heading_display = new HeadingInfoDisplay(stats, "HEADING_DISPLAY", 0.45);
heading_display->setSize(240, 40);
auto velocity_display = new VelocityInfoDisplay(stats, "VELOCITY_DISPLAY", 0.45);
velocity_display->setSize(240, 40);
auto shields_display = new ShieldsInfoDisplay(stats, "SHIELDS_DISPLAY", 0.45);
shields_display->setSize(240, 40);

// Unlocked missile aim dial and lock controls.
missile_aim = new AimLock(this, "MISSILE_AIM", radar, -90, 360 - 90, 0, [this](float value){
Expand Down Expand Up @@ -143,33 +144,9 @@ void SinglePilotScreen::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
auto reactor = my_spaceship.getComponent<Reactor>();
energy_display->setVisible(reactor);
if (reactor)
energy_display->setValue(string(int(reactor->energy)));
auto transform = my_spaceship.getComponent<sp::Transform>();
auto physics = my_spaceship.getComponent<sp::Physics>();
if (transform)
heading_display->setValue(string(transform->getRotation() - 270, 1));
if (physics) {
float velocity = glm::length(physics->getVelocity()) / 1000 * 60;
velocity_display->setValue(tr("{value} {unit}/min").format({{"value", string(velocity, 1)}, {"unit", DISTANCE_UNIT_1K}}));
}

warp_controls->setVisible(my_spaceship.hasComponent<WarpDrive>());
jump_controls->setVisible(my_spaceship.hasComponent<JumpDrive>());

auto shields = my_spaceship.getComponent<Shields>();
if (shields) {
string shields_value = "";
for(auto& shield : shields->entries)
shields_value += string(shield.level * 100.0f / shield.max, 0) + "% ";
shields_display->show();
shields_display->setValue(shields_value);
} else {
shields_display->hide();
}

missile_aim->setVisible(tube_controls->getManualAim());

auto target = my_spaceship.getComponent<Target>();
Expand Down
4 changes: 0 additions & 4 deletions src/screens/crew1/singlePilotScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class SinglePilotScreen : public GuiOverlay
private:
GuiOverlay* background_crosses;

GuiKeyValueDisplay* energy_display;
GuiKeyValueDisplay* heading_display;
GuiKeyValueDisplay* velocity_display;
GuiKeyValueDisplay* shields_display;
GuiElement* warp_controls;
GuiElement* jump_controls;
GuiCombatManeuver* combat_maneuver;
Expand Down
39 changes: 9 additions & 30 deletions src/screens/crew4/tacticalScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "screenComponents/dockingButton.h"
#include "screenComponents/alertOverlay.h"
#include "screenComponents/customShipFunctions.h"
#include "screenComponents/infoDisplay.h"

#include "screenComponents/missileTubeControls.h"
#include "screenComponents/aimLock.h"
Expand Down Expand Up @@ -80,14 +81,14 @@ TacticalScreen::TacticalScreen(GuiContainer* owner)
stats->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(240, 160)->setAttribute("layout", "vertical");

// Ship statistics in the top left corner.
energy_display = new GuiKeyValueDisplay(stats, "ENERGY_DISPLAY", 0.45, tr("Energy"), "");
energy_display->setIcon("gui/icons/energy")->setTextSize(20)->setSize(240, 40);
heading_display = new GuiKeyValueDisplay(stats, "HEADING_DISPLAY", 0.45, tr("Heading"), "");
heading_display->setIcon("gui/icons/heading")->setTextSize(20)->setSize(240, 40);
velocity_display = new GuiKeyValueDisplay(stats, "VELOCITY_DISPLAY", 0.45, tr("Speed"), "");
velocity_display->setIcon("gui/icons/speed")->setTextSize(20)->setSize(240, 40);
shields_display = new GuiKeyValueDisplay(stats, "SHIELDS_DISPLAY", 0.45, tr("Shields"), "");
shields_display->setIcon("gui/icons/shields")->setTextSize(20)->setSize(240, 40);
auto energy_display = new EnergyInfoDisplay(stats, "ENERGY_DISPLAY", 0.45);
energy_display->setSize(240, 40);
auto heading_display = new HeadingInfoDisplay(stats, "HEADING_DISPLAY", 0.45);
heading_display->setSize(240, 40);
auto velocity_display = new VelocityInfoDisplay(stats, "VELOCITY_DISPLAY", 0.45);
velocity_display->setSize(240, 40);
auto shields_display = new ShieldsInfoDisplay(stats, "SHIELDS_DISPLAY", 0.45);
shields_display->setSize(240, 40);

// Weapon tube loading controls in the bottom left corner.
tube_controls = new GuiMissileTubeControls(this, "MISSILE_TUBES");
Expand Down Expand Up @@ -129,31 +130,9 @@ void TacticalScreen::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
auto reactor = my_spaceship.getComponent<Reactor>();
energy_display->setVisible(reactor);
if (reactor)
energy_display->setValue(string(int(reactor->energy)));
if (auto transform = my_spaceship.getComponent<sp::Transform>())
heading_display->setValue(string(transform->getRotation() - 270.0f, 1));
if (auto physics = my_spaceship.getComponent<sp::Physics>()) {
float velocity = glm::length(physics->getVelocity()) / 1000 * 60;
velocity_display->setValue(tr("{value} {unit}/min").format({{"value", string(velocity, 1)}, {"unit", DISTANCE_UNIT_1K}}));
}

warp_controls->setVisible(my_spaceship.hasComponent<WarpDrive>());
jump_controls->setVisible(my_spaceship.hasComponent<JumpDrive>());

auto shields = my_spaceship.getComponent<Shields>();
if (shields && shields->entries.size() > 0) {
string shields_value = string(shields->entries[0].percentage()) + "%";
if (shields->entries.size() > 1)
shields_value += " " + string(shields->entries[1].percentage()) + "%";
shields_display->setValue(shields_value);
shields_display->show();
} else {
shields_display->hide();
}

auto target = my_spaceship.getComponent<Target>();
targets.set(target ? target->entity : sp::ecs::Entity{});
}
Expand Down
4 changes: 0 additions & 4 deletions src/screens/crew4/tacticalScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ class TacticalScreen : public GuiOverlay
private:
GuiOverlay* background_crosses;

GuiKeyValueDisplay* energy_display;
GuiKeyValueDisplay* heading_display;
GuiKeyValueDisplay* velocity_display;
GuiKeyValueDisplay* shields_display;
GuiElement* warp_controls;
GuiElement* jump_controls;

Expand Down
74 changes: 10 additions & 64 deletions src/screens/crew6/engineeringScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "screenComponents/selfDestructButton.h"
#include "screenComponents/alertOverlay.h"
#include "screenComponents/customShipFunctions.h"
#include "screenComponents/infoDisplay.h"

#include "gui/gui2_keyvaluedisplay.h"
#include "gui/gui2_togglebutton.h"
Expand All @@ -42,16 +43,16 @@ EngineeringScreen::EngineeringScreen(GuiContainer* owner, CrewPosition crew_posi
auto stats = new GuiElement(this, "ENGINEER_STATS");
stats->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(240, 200)->setAttribute("layout", "vertical");

energy_display = new GuiKeyValueDisplay(stats, "ENERGY_DISPLAY", 0.45, tr("Energy"), "");
auto energy_display = new EnergyInfoDisplay(stats, "ENERGY_DISPLAY", 0.45, true);
energy_display->setIcon("gui/icons/energy")->setTextSize(20)->setSize(240, 40);
hull_display = new GuiKeyValueDisplay(stats, "HULL_DISPLAY", 0.45, tr("health","Hull"), "");
hull_display->setIcon("gui/icons/hull")->setTextSize(20)->setSize(240, 40);
front_shield_display = new GuiKeyValueDisplay(stats, "SHIELDS_DISPLAY", 0.45, tr("shields", "Front"), "");
front_shield_display->setIcon("gui/icons/shields-fore")->setTextSize(20)->setSize(240, 40);
rear_shield_display = new GuiKeyValueDisplay(stats, "SHIELDS_DISPLAY", 0.45, tr("shields", "Rear"), "");
rear_shield_display->setIcon("gui/icons/shields-aft")->setTextSize(20)->setSize(240, 40);
coolant_display = new GuiKeyValueDisplay(stats, "COOLANT_DISPLAY", 0.45, tr("total","Coolant"), "");
coolant_display->setIcon("gui/icons/coolant")->setTextSize(20)->setSize(240, 40);
auto hull_display = new HullInfoDisplay(stats, "HULL_DISPLAY", 0.45);
hull_display->setTextSize(20)->setSize(240, 40);
auto front_shield_display = new ShieldsInfoDisplay(stats, "SHIELDS_DISPLAY", 0.45, 0);
front_shield_display->setSize(240, 40);
auto rear_shield_display = new ShieldsInfoDisplay(stats, "SHIELDS_DISPLAY", 0.45, 1);
rear_shield_display->setSize(240, 40);
auto coolant_display = new CoolantInfoDisplay(stats, "COOLANT_DISPLAY", 0.45);
coolant_display->setSize(240, 40);

self_destruct_button = new GuiSelfDestructButton(this, "SELF_DESTRUCT");
self_destruct_button->setPosition(20, 20, sp::Alignment::TopLeft)->setSize(240, 100)->setVisible(my_spaceship && my_spaceship.hasComponent<SelfDestruct>());
Expand Down Expand Up @@ -186,65 +187,12 @@ EngineeringScreen::EngineeringScreen(GuiContainer* owner, CrewPosition crew_posi
(new GuiShipInternalView(system_row_layouts, "SHIP_INTERNAL_VIEW", 48.0f))->setShip(my_spaceship)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

(new GuiCustomShipFunctions(this, crew_position, ""))->setPosition(-20, 120, sp::Alignment::TopRight)->setSize(250, GuiElement::GuiSizeMax);

previous_energy_level = 0.0f;
average_energy_delta = 0.0f;
previous_energy_measurement = 0.0f;
}

void EngineeringScreen::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
auto reactor = my_spaceship.getComponent<Reactor>();
if (reactor) {
// Update the energy usage.
if (previous_energy_measurement == 0.0f)
{
previous_energy_level = reactor->energy;
previous_energy_measurement = engine->getElapsedTime();
}else{
if (previous_energy_measurement != engine->getElapsedTime())
{
float delta_t = engine->getElapsedTime() - previous_energy_measurement;
float delta_e = reactor->energy - previous_energy_level;
float delta_e_per_second = delta_e / delta_t;
average_energy_delta = average_energy_delta * 0.99f + delta_e_per_second * 0.01f;

previous_energy_level = reactor->energy;
previous_energy_measurement = engine->getElapsedTime();
}
}
energy_display->setValue(toNearbyIntString(reactor->energy) + " (" + tr("{energy}/min").format({{"energy", toNearbyIntString(average_energy_delta * 60.0f)}}) + ")");
if (reactor->energy < 100.0f)
energy_display->setColor(glm::u8vec4(255, 0, 0, 255));
else
energy_display->setColor(glm::u8vec4{255,255,255,255});
}

auto hull = my_spaceship.getComponent<Hull>();
if (hull) {
hull_display->setValue(toNearbyIntString(100.0f * hull->current / hull->max) + "%");
if (hull->current < hull->max / 4.0f)
hull_display->setColor(glm::u8vec4(255, 0, 0, 255));
else
hull_display->setColor(glm::u8vec4{255,255,255,255});
}
auto shields = my_spaceship.getComponent<Shields>();
if (shields && shields->entries.size() > 0)
{
front_shield_display->setValue(string(shields->entries[0].percentage()) + "%");
front_shield_display->show();
} else {
front_shield_display->hide();
}
if (shields && shields->entries.size() > 1)
{
rear_shield_display->setValue(string(shields->entries[1].percentage()) + "%");
rear_shield_display->show();
} else {
rear_shield_display->hide();
}
float total_coolant_used = 0.0f;
for(int n=0; n<ShipSystem::COUNT; n++)
{
Expand Down Expand Up @@ -293,10 +241,8 @@ void EngineeringScreen::onDraw(sp::RenderTarget& renderer)
}

auto coolant = my_spaceship.getComponent<Coolant>();
coolant_display->setVisible(coolant);
coolant_remaining_bar->setVisible(coolant);
if (coolant) {
coolant_display->setValue(toNearbyIntString(coolant->max * 100.0f / coolant->max_coolant_per_system) + "%");
coolant_remaining_bar->setRange(0, coolant->max);
coolant_remaining_bar->setValue(coolant->max - total_coolant_used);
}
Expand Down
9 changes: 0 additions & 9 deletions src/screens/crew6/engineeringScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class EngineeringScreen : public GuiOverlay
private:
GuiOverlay* background_crosses;

GuiKeyValueDisplay* energy_display;
GuiKeyValueDisplay* hull_display;
GuiKeyValueDisplay* front_shield_display;
GuiKeyValueDisplay* rear_shield_display;
GuiKeyValueDisplay* coolant_display;
GuiSelfDestructButton* self_destruct_button;
GuiLabel* power_label;
GuiSlider* power_slider;
Expand Down Expand Up @@ -52,10 +47,6 @@ class EngineeringScreen : public GuiOverlay
unsigned int system_effects_index;
ShipSystem::Type selected_system;

float previous_energy_measurement;
float previous_energy_level;
float average_energy_delta;

bool set_power_active[ShipSystem::COUNT] = {false};
bool set_coolant_active[ShipSystem::COUNT] = {false};

Expand Down
24 changes: 7 additions & 17 deletions src/screens/crew6/helmsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "screenComponents/dockingButton.h"
#include "screenComponents/alertOverlay.h"
#include "screenComponents/customShipFunctions.h"
#include "screenComponents/infoDisplay.h"

#include "gui/gui2_label.h"
#include "gui/gui2_togglebutton.h"
Expand Down Expand Up @@ -77,12 +78,12 @@ HelmsScreen::HelmsScreen(GuiContainer* owner)
heading_hint = new GuiLabel(this, "HEADING_HINT", "", 30);
heading_hint->setAlignment(sp::Alignment::Center)->setSize(0, 0);

energy_display = new GuiKeyValueDisplay(this, "ENERGY_DISPLAY", 0.45, tr("Energy"), "");
energy_display->setIcon("gui/icons/energy")->setTextSize(20)->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(240, 40);
heading_display = new GuiKeyValueDisplay(this, "HEADING_DISPLAY", 0.45, tr("Heading"), "");
heading_display->setIcon("gui/icons/heading")->setTextSize(20)->setPosition(20, 140, sp::Alignment::TopLeft)->setSize(240, 40);
velocity_display = new GuiKeyValueDisplay(this, "VELOCITY_DISPLAY", 0.45, tr("Speed"), "");
velocity_display->setIcon("gui/icons/speed")->setTextSize(20)->setPosition(20, 180, sp::Alignment::TopLeft)->setSize(240, 40);
auto energy_display = new EnergyInfoDisplay(this, "ENERGY_DISPLAY", 0.45);
energy_display->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(240, 40);
auto heading_display = new HeadingInfoDisplay(this, "HEADING_DISPLAY", 0.45);
heading_display->setPosition(20, 140, sp::Alignment::TopLeft)->setSize(240, 40);
auto velocity_display = new GuiKeyValueDisplay(this, "VELOCITY_DISPLAY", 0.45, tr("Speed"), "");
velocity_display->setPosition(20, 180, sp::Alignment::TopLeft)->setSize(240, 40);

GuiElement* engine_layout = new GuiElement(this, "ENGINE_LAYOUT");
engine_layout->setPosition(20, -100, sp::Alignment::BottomLeft)->setSize(GuiElement::GuiSizeMax, 300)->setAttribute("layout", "horizontal");
Expand All @@ -100,17 +101,6 @@ void HelmsScreen::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
auto reactor = my_spaceship.getComponent<Reactor>();
energy_display->setVisible(reactor);
if (reactor)
energy_display->setValue(string(int(reactor->energy)));
if (auto transform = my_spaceship.getComponent<sp::Transform>())
heading_display->setValue(string(transform->getRotation() - 270.0f, 1));
if (auto physics = my_spaceship.getComponent<sp::Physics>()) {
float velocity = glm::length(physics->getVelocity()) / 1000 * 60;
velocity_display->setValue(tr("{value} {unit}/min").format({{"value", string(velocity, 1)}, {"unit", DISTANCE_UNIT_1K}}));
}

warp_controls->setVisible(my_spaceship.hasComponent<WarpDrive>());
jump_controls->setVisible(my_spaceship.hasComponent<JumpDrive>());
}
Expand Down
3 changes: 0 additions & 3 deletions src/screens/crew6/helmsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class HelmsScreen : public GuiOverlay
private:
GuiOverlay* background_crosses;

GuiKeyValueDisplay* energy_display;
GuiKeyValueDisplay* heading_display;
GuiKeyValueDisplay* velocity_display;
GuiElement* warp_controls;
GuiElement* jump_controls;
GuiLabel* heading_hint;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/gm/objectCreationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GuiObjectCreationView::GuiObjectCreationView(GuiContainer* owner)
}
}
});
object_list->setPosition(320, 20)->setSize(300, 600);
object_list->setTextSize(20)->setButtonHeight(30)->setPosition(320, 20)->setSize(300, 600);
for(const auto& info : spawn_list) {
if (info.category == category_selector->getSelectionValue()) {
object_list->addEntry(info.label, info.label);
Expand Down
Loading

1 comment on commit 2e32486

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 2e32486 Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[/home/tinyci/builds/daid/EmptyEpsilon/_build_native:cmake .. -G Ninja -DSERIOUS_PROTON_DIR=../../SeriousProton -DCMAKE_BUILD_TYPE=RelWithDebInfo] returned [1]:


-- GLM version used: BUNDLED

-- opus version used: BUNDLED

-- Freetype 2 version used: BUNDLED

-- Not using steam SDK

-- Configuring done

CMake Error at CMakeLists.txt:672 (add_executable):

  Cannot find source file:



    src/screenComponents/infoDisplay.cpp



  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h

  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc





-- Generating done

CMake Generate step failed.  Build files cannot be regenerated correctly.

Please sign in to comment.