Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
82bf6f1
fix warnings
psyinf Dec 28, 2024
1f06759
IconFonts and ImGui version bump
psyinf Dec 28, 2024
6fc04ca
Gui works
psyinf Dec 28, 2024
ff3e4ce
Warning fix
psyinf Dec 29, 2024
f8500d0
Switch to FontAwesome6
psyinf Dec 29, 2024
f2f06fc
move starsystem name/pos generation to component
psyinf Dec 29, 2024
d624d21
Gui work
psyinf Dec 29, 2024
2497e14
Options menu with galaxyConfig binding
psyinf Dec 31, 2024
e4a3ede
cached Markov name map
psyinf Dec 31, 2024
9b5ee98
re-added marker rendering
psyinf Dec 31, 2024
fa6fa60
Options menu for number of stars
psyinf Jan 2, 2025
b2e9587
gui-refactoring
psyinf Jan 2, 2025
8e2883d
gui-refactoring
psyinf Jan 2, 2025
fde533e
Warning fixes
psyinf Jan 2, 2025
92be72a
attempted warning setup for 3rd party
psyinf Jan 2, 2025
0224883
refactoring menu system
psyinf Jan 2, 2025
bf581e6
renaming and include hygiene
psyinf Jan 2, 2025
dd82ff3
renaming and include hygiene
psyinf Jan 3, 2025
9df1bf8
Fix Asteroids game
psyinf Jan 3, 2025
c5de8c1
more cleaning
psyinf Jan 3, 2025
52d2d2f
move options menu into separate file
psyinf Jan 3, 2025
15b2bc7
options overhaul
psyinf Jan 4, 2025
9532b66
config improvements
psyinf Jan 4, 2025
132f189
ScopeBeginEndWrapper utility
psyinf Jan 4, 2025
58c48e6
renamed guiElements
psyinf Jan 4, 2025
e48d22b
move style stack and ImGui BeginEnd wrappers to separate file
psyinf Jan 4, 2025
37b9f8b
using ScopedBeginEnd wrappers
psyinf Jan 4, 2025
3d22316
minimal typeRegistrar documentation
psyinf Jan 4, 2025
6902b36
Fixed ScopeBeginEndWrapper ParameterInstance to allow generic types
psyinf Jan 5, 2025
d324b56
Void return variant for ScopeBeginEndWrapper
psyinf Jan 5, 2025
d8b1530
OptionsMenu with factions
psyinf Jan 5, 2025
3d2c386
faction config and handling
psyinf Jan 5, 2025
0fc1375
cleanup and fixed menu background music
messers2 Jan 7, 2025
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ endif()
include(cmake/stacktrace.cmake)
include(cmake/setup_cpm.cmake)
include(cmake/deps_cpm.cmake)

include(cmake/disable_3rd_party_warnings.cmake)
make_all_targets_system()


enable_testing()
Expand Down
5 changes: 4 additions & 1 deletion apps/_template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ if (ENABLE_COVERAGE)
enable_coverage(${PROJECT_NAME})
endif()

install(TARGETS ${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME})

target_compile_options(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/W4>)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -pedantic>)
4 changes: 4 additions & 0 deletions apps/asteroids/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <systems/SoundSystem.hpp>

#include <pgGame/systems/SystemsRegistry.hpp>
#include <pgGame/events/GameEvents.hpp>

int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
try
Expand All @@ -37,6 +38,9 @@ try
"dynamicsSystem",
"soundSystem"}});
game.switchScene("start");
// send start event
game.getGlobalDispatcher().enqueue<pg::game::events::PlayPauseEvent>(
{.state = pg::game::events::PlayPauseEvent::State::Play});

// TODO: from external config
game.getCurrentScene().addSingleton<asteroids::RenderConfig>(
Expand Down
4 changes: 1 addition & 3 deletions apps/asteroids/systems/Asteroids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include <pgEngine/math/Bounds.hpp>
#include <pgEngine/math/Transform.hpp>
#include <pgEngine/math/VecUtils.hpp>
#include <pgEngine/primitives/BackgoundSprite.hpp>
#include <pgGame/core/Game.hpp>
#include <pgGame/core/RegistryHelper.hpp>
#include <pgGame/components/Drawable.hpp>
#include <algorithm>
#include <random>

#include <systems/Lasers.h>
Expand Down Expand Up @@ -195,7 +193,7 @@ void asteroids::Asteroids::createExplosion(pg::fVec2& position)
if (frame_number >= max_frames)
{
//
_game.getDispatcher().enqueue<pg::game::events::DestroyEntityEvent>({.entity = entity});
_game.getGlobalDispatcher().enqueue<pg::game::events::DestroyEntityEvent>({.entity = entity});
}
}));
pg::game::addComponents<pg::game::Drawable>(_game.getGlobalRegistry(), entity, pg::game::Drawable{animation});
Expand Down
1 change: 0 additions & 1 deletion apps/asteroids/systems/Asteroids.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include <array>
#include <deque>
#include <entt/entt.hpp>
#include <events/Collision.h>
Expand Down
1 change: 0 additions & 1 deletion apps/asteroids/systems/Collisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <pgGame/core/Game.hpp>
#include <components/Entities.h>
#include <events/Collision.h>
#include <iostream>

void asteroids::Collisions::setup(std::string_view /*scene_id*/) {}

Expand Down
1 change: 0 additions & 1 deletion apps/asteroids/systems/Collisions.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <entt/entt.hpp>
#include <events/LaserFired.h>
#include <pgGame/systems/SystemInterface.hpp>

namespace asteroids {
Expand Down
8 changes: 7 additions & 1 deletion apps/galaxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_link_libraries(${PROJECT_NAME}
BT::behaviortree_cpp
soundEngine::soundEngine
pgf::pgf
IconFontCppHeaders
INTERFACE
pgFoundation::pgFoundation
${ADDITION_LIBS}
Expand All @@ -32,4 +33,9 @@ if (ENABLE_COVERAGE)
enable_coverage(${PROJECT_NAME})
endif()

install(TARGETS ${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME})

target_compile_options(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/W4>)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -pedantic>)

set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME} )
24 changes: 14 additions & 10 deletions apps/galaxy/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Star

struct StartingParameters
{
uint64_t start_cycle{0};
uint64_t start_offset_seconds{0};
uint8_t num_start_drones{1};
};

Expand All @@ -27,6 +27,7 @@ struct DroneParameters

struct Faction
{
bool active{false};
std::string name;
pg::Color color{0, 0, 255, 255};
StartingParameters startParams;
Expand All @@ -51,21 +52,24 @@ struct Debugging
bool draw_quadtree{false};
};

struct Creation
{
uint32_t stars_seed{0};
uint32_t num_stars{15000};
};

struct Galaxy
{
Star star;
// TODO: split into runtime and serialized config
BackgoundParameters background;
ZoomParameters zoom;
Debugging debugging;
uint64_t stars_seed{0};
uint32_t num_stars{15000};
Creation creation;
std::vector<Faction> factions = {
{.name{"Terra"}, .color{0, 0, 255, 255}},
//{.name{"Vogons"}, .color{255, 0, 0, 255}},
//{.name{"Grays"}, .color{255, 255, 0, 255}},
//{.name{"Vogons"}, .color{255, 0, 0, 255}},
//{.name{"Grays"}, .color{255, 255, 0, 255}},
//{.name{"Drifters"}, .color{0, 255, 255, 255}, .startParams{.start_cycle{}, .num_start_drones{}}}
{.active = true, .name{"Terra"}, .color{0, 0, 255, 255}},
{.name{"Vogons"}, .color{255, 0, 0, 255}},
{.name{"Grays"}, .color{255, 255, 0, 255}},
{.name{"Drifters"}, .color{0, 255, 255, 255}, .startParams{.start_offset_seconds{}, .num_start_drones{}}}
//
};
};
Expand Down
25 changes: 16 additions & 9 deletions apps/galaxy/Galaxy.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include "Galaxy.hpp"
#include <scenes/GalaxyScene.hpp>
#include <scenes/SplashScreen.hpp>
#include <scenes/MainMenuScene.hpp>

#include <scenes/LoadResourcesScene.hpp>
#include <systems/RenderSystem.hpp>
#include <systems/SoundSystem.hpp>
#include <systems/GuiRenderSystem.hpp>
#include <systems/UpdateCurrentSystem.hpp>
#include <scenes/SystemScene.hpp>
#include <components/GameState.hpp>

#include <pgGame/components/singletons/RegisteredPreloaders.hpp>
#include <systems/DroneSystem.hpp>
#include <systems/LifetimeSystem.hpp>
#include <systems/BehaviorSystem.hpp>
#include <systems/StatsSystem.hpp>

galaxy::GalacticCore::GalacticCore()
: game(std::make_unique<pg::game::Game>())
Expand All @@ -37,7 +39,7 @@ void galaxy::GalacticCore::setup()
// we also need some loader abstraction/way to report progress -> LoaderProgressInterface

game->getConfig().addPerSceneConfig<galaxy::SceneSoundScape>(
"splashScreen",
"mainMenu",
"soundScape",
{.background_music{.music_list{{"../data/music/dead-space-style-ambient-music-184793.mp3"}}},
.event_sounds = {event_sound_cfg}});
Expand All @@ -60,9 +62,13 @@ void galaxy::GalacticCore::setup()
pg::game::SystemsFactory::registerSystem<galaxy::SoundSystem>("soundSystem");
pg::game::SystemsFactory::registerSystem<galaxy::GuiRenderSystem>("guiSystem");
pg::game::SystemsFactory::registerSystem<galaxy::TaggedRenderSystem<pg::tags::GalaxyRenderTag>>(
"galaxyRenderSystem", false);
"galaxyRenderSystem", RenderSystemConfig{.perScene{false}});
pg::game::SystemsFactory::registerSystem<galaxy::TaggedRenderSystem<pg::tags::MarkerTag>>(
"galaxyMarkers", RenderSystemConfig{.perScene{true}, .clear{false}});

pg::game::SystemsFactory::registerSystem<
galaxy::TaggedRenderSystem<pg::tags::SystemRenderTag, pg::tags::SelectedItemTag>>("systemRenderSystem", true);
galaxy::TaggedRenderSystem<pg::tags::SystemRenderTag, pg::tags::SelectedItemTag>>("systemRenderSystem",
RenderSystemConfig{});

pg::game::SystemsFactory::registerSystem<galaxy::UpdateStarsSystem>("updateStarsSystem");
pg::game::SystemsFactory::registerSystem<galaxy::UpdateCurrentSystem>("updateCurrentSystem");
Expand All @@ -73,12 +79,13 @@ void galaxy::GalacticCore::setup()
pg::game::SystemsFactory::registerSystem<galaxy::StatsSystem>("statsSystem");

// scenes
game->createScene<galaxy::SplashScreen>(
{.scene_id = "splashScreen", .systems = {"soundSystem", "guiSystem"}, .followUpScene = "galaxy"});
game->createScene<galaxy::MainMenuScene>(
{.scene_id = "mainMenu", .systems = {"soundSystem", "guiSystem"}, .followUpScene = "galaxy"});
game->createScene<galaxy::LoadResourcesScene>({.scene_id = "loadGalaxy", .systems = {"guiSystem"}}, "galaxy");
game->createScene<galaxy::GalaxyScene>({.scene_id = "galaxy",
.systems = {"soundSystem",
"galaxyRenderSystem",
"galaxyMarkers",
"guiSystem",
"updateStarsSystem",
"pickingSystem",
Expand All @@ -95,7 +102,7 @@ void galaxy::GalacticCore::setup()
game->addSingleton_as<pg::game::SystemInterface::Config>(
"guiSystem.system.config", pg::game::SystemInterface::Config{{"standalone", "false"}});

auto& scene = game->switchScene("splashScreen");
auto& scene = game->switchScene("mainMenu");
scene.start();
}

Expand Down
1 change: 1 addition & 0 deletions apps/galaxy/behaviors/FindNextSystem.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <behaviors/utils/BehaviorActionNode.hpp>
#include <pgEngine/math/Quadtree.hpp>

namespace behavior {

Expand Down
2 changes: 2 additions & 0 deletions apps/galaxy/behaviors/MakeDrone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <helpers/GalaxyHelpers.hpp>
#include <fmt/core.h>
#include <components/Tags.hpp>
#include <components/Lifetime.hpp>
#include <pgGame/components/RenderState.hpp>

namespace behavior {

Expand Down
1 change: 1 addition & 0 deletions apps/galaxy/components/Faction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ struct Faction
std::string name;
pg::Color systemColor;
pg::Color entityColor;
bool started{false};
};
} // namespace galaxy
36 changes: 35 additions & 1 deletion apps/galaxy/components/StarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include <array>
#include <pgOrbit/StarParameters.hpp>

#include <pgEngine/math/Trigonometric.hpp>
#include <pgEngine/core/Constants.hpp>
#include <magic_enum.hpp>

namespace galaxy {
Expand All @@ -23,4 +24,37 @@ struct StarSystemState
std::vector<entt::entity> orbits;
};

// some helper functions
inline auto sectorNameFromAngle(float angle_deg) -> std::string
{ // 0° is up
angle_deg += 90.0f;
// adjust for sector 0 starting at -15 degrees
angle_deg += 15.0f;

// normalize angle to 0-360
angle_deg = std::fmod(angle_deg + 360.0f, 360.0f);

// every 30 degrees, starting at -15 degrees. First sector is alpha, last is omega

// first sector is between -15 and +15
auto sector = static_cast<int>(std::floor((angle_deg) / 30.0f));

return pg::constants::greek_letter_names.at(sector);
}

// the remainder-angle inside a sector
inline auto inSectorAngle(float angle_deg) -> float
{
return std::fmod(angle_deg + 15.0f, 30.0f);
}

inline auto buildSystemPositionStr(pg::fVec2 pos) -> std::string
{
auto polar_pos = pg::math::toPolar(pos);

auto sector_name = sectorNameFromAngle(pg::math::toDegrees(std::get<1>(polar_pos)));
auto sector_angle = 10 * inSectorAngle(std::get<1>(polar_pos));
// name is sector - angle_in_sector:distance
return fmt::format("{}-{:.0f}:{:.0f}", sector_name, sector_angle, 10 * std::get<0>(polar_pos));
}
} // namespace galaxy
30 changes: 17 additions & 13 deletions apps/galaxy/gui/MainBarWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@ class MainBarWidget : public galaxy::gui::GameGuiWidget

void draw([[maybe_unused]] pg::Gui& gui) override
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{12.0f, 12.0f});
// make
auto timeStamp = getGame().getCurrentTimeStamp();
auto gameStamp = getGame().getCurrentGameState();
ImGui::BeginMainMenuBar();
// Add menu bar items here
ImGui::EndMainMenuBar();

ImGui::Begin("System Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Main Info");
ImGui::Text("Frame: %d", timeStamp.frameNumber);
ImGui::Text("Game Tick: %d", timeStamp.gameTick);
ImGui::Text("Seconds: %f", timeStamp.time.getFractionalSeconds());
ImGui::Text("Time Passed: %f", timeStamp.getRealTimePassed_sec());
ImGui::Text("Galaxy Time: %s", timeStamp.formatTime().c_str());

// add some play/pause button
// play/pause event

// set main menu bar height
ImGui::SetWindowSize(ImVec2(0, 120));
if (ImGui::Button("Pause"))
{
auto event = pg::game::events::PlayPauseEvent{.state = pg::game::events::PlayPauseEvent::State::Pause};
Expand Down Expand Up @@ -61,7 +51,21 @@ class MainBarWidget : public galaxy::gui::GameGuiWidget
getGame().getGlobalDispatcher().enqueue<pg::game::events::TimeScaleEvent>(event);
}

ImGui::EndMainMenuBar();

ImGui::Begin("System Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Main Info");
ImGui::Text("Frame: %d", timeStamp.frameNumber);
ImGui::Text("Game Tick: %d", timeStamp.gameTick);
ImGui::Text("Seconds: %f", timeStamp.time.getFractionalSeconds());
ImGui::Text("Time Passed: %f", timeStamp.getRealTimePassed_sec());
ImGui::Text("Galaxy Time: %s", timeStamp.formatTime().c_str());

// add some play/pause button
// play/pause event

ImGui::End();
ImGui::PopStyleVar();
}
};

Expand Down
Loading
Loading