Browse Source

Combine game context and boot state into single game class. Make game class members follow RAII principles. Add state suffix to game states and remove state namespace

master
C. J. Howard 1 year ago
parent
commit
127c1aa490
64 changed files with 2133 additions and 2366 deletions
  1. +1
    -1
      CMakeLists.txt
  2. +6
    -6
      src/engine/app/sdl/sdl-window-manager.cpp
  3. +1
    -1
      src/engine/app/sdl/sdl-window-manager.hpp
  4. +15
    -15
      src/engine/app/sdl/sdl-window.hpp
  5. +2
    -1
      src/engine/app/window-manager.hpp
  6. +2
    -2
      src/game/ant/swarm.cpp
  7. +3
    -3
      src/game/ant/swarm.hpp
  8. +15
    -16
      src/game/controls.cpp
  9. +14
    -14
      src/game/controls.hpp
  10. +1
    -1
      src/game/fonts.cpp
  11. +2
    -2
      src/game/fonts.hpp
  12. +1340
    -0
      src/game/game.cpp
  13. +127
    -97
      src/game/game.hpp
  14. +7
    -7
      src/game/graphics.cpp
  15. +7
    -7
      src/game/graphics.hpp
  16. +1
    -1
      src/game/load.cpp
  17. +2
    -2
      src/game/load.hpp
  18. +4
    -9
      src/game/main.cpp
  19. +20
    -21
      src/game/menu.cpp
  20. +17
    -17
      src/game/menu.hpp
  21. +2
    -2
      src/game/settings.hpp
  22. +3
    -3
      src/game/spawn.cpp
  23. +4
    -4
      src/game/spawn.hpp
  24. +0
    -1384
      src/game/state/boot.cpp
  25. +0
    -74
      src/game/state/boot.hpp
  26. +0
    -36
      src/game/state/controls-menu.hpp
  27. +0
    -36
      src/game/state/options-menu.hpp
  28. +6
    -10
      src/game/states/collection-menu-state.cpp
  29. +7
    -10
      src/game/states/collection-menu-state.hpp
  30. +10
    -14
      src/game/states/controls-menu-state.cpp
  31. +7
    -10
      src/game/states/controls-menu-state.hpp
  32. +7
    -10
      src/game/states/credits-state.cpp
  33. +7
    -10
      src/game/states/credits-state.hpp
  34. +8
    -11
      src/game/states/extras-menu-state.cpp
  35. +7
    -10
      src/game/states/extras-menu-state.hpp
  36. +4
    -6
      src/game/states/game-state.cpp
  37. +8
    -13
      src/game/states/game-state.hpp
  38. +9
    -12
      src/game/states/gamepad-config-menu-state.cpp
  39. +7
    -9
      src/game/states/gamepad-config-menu-state.hpp
  40. +7
    -12
      src/game/states/graphics-menu-state.cpp
  41. +7
    -10
      src/game/states/graphics-menu-state.hpp
  42. +8
    -12
      src/game/states/keyboard-config-menu-state.cpp
  43. +7
    -10
      src/game/states/keyboard-config-menu-state.hpp
  44. +7
    -11
      src/game/states/language-menu-state.cpp
  45. +7
    -11
      src/game/states/language-menu-state.hpp
  46. +16
    -20
      src/game/states/main-menu-state.cpp
  47. +7
    -10
      src/game/states/main-menu-state.hpp
  48. +15
    -17
      src/game/states/nest-selection-state.cpp
  49. +7
    -10
      src/game/states/nest-selection-state.hpp
  50. +19
    -23
      src/game/states/nuptial-flight-state.cpp
  51. +7
    -10
      src/game/states/nuptial-flight-state.hpp
  52. +16
    -20
      src/game/states/options-menu-state.cpp
  53. +33
    -0
      src/game/states/options-menu-state.hpp
  54. +9
    -13
      src/game/states/pause-menu-state.cpp
  55. +10
    -8
      src/game/states/pause-menu-state.hpp
  56. +7
    -10
      src/game/states/sound-menu-state.cpp
  57. +7
    -10
      src/game/states/sound-menu-state.hpp
  58. +217
    -221
      src/game/states/splash-state.cpp
  59. +7
    -10
      src/game/states/splash-state.hpp
  60. +1
    -1
      src/game/strings.cpp
  61. +2
    -2
      src/game/strings.hpp
  62. +0
    -1
      src/game/systems/render-system.cpp
  63. +19
    -19
      src/game/world.cpp
  64. +8
    -8
      src/game/world.hpp

+ 1
- 1
CMakeLists.txt View File

@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.25)
option(APPLICATION_NAME "Application name" "Antkeeper")
option(APPLICATION_VERSION "Application version string" "0.0.0")
option(APPLICATION_AUTHOR "Application author" "C. J. Howard")
@ -9,6 +8,7 @@ option(APPLICATION_AUTHOR "Application author" "C. J. Howard")
string(TOLOWER ${APPLICATION_NAME} APPLICATION_SLUG)
string(REPLACE " " "-" APPLICATION_SLUG ${APPLICATION_SLUG})
project(${APPLICATION_SLUG} VERSION ${APPLICATION_VERSION} LANGUAGES CXX)
set(APPLICATION_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})

+ 6
- 6
src/engine/app/sdl/sdl-window-manager.cpp View File

@ -92,7 +92,7 @@ sdl_window_manager::~sdl_window_manager()
debug::log::trace("Quit SDL video subsystem");
}
window* sdl_window_manager::create_window
std::shared_ptr<window> sdl_window_manager::create_window
(
const std::string& title,
const math::vector<int, 2>& windowed_position,
@ -103,7 +103,7 @@ window* sdl_window_manager::create_window
)
{
// Create new window
app::sdl_window* window = new app::sdl_window
std::shared_ptr<app::sdl_window> window = std::make_shared<app::sdl_window>
(
title,
windowed_position,
@ -114,7 +114,7 @@ window* sdl_window_manager::create_window
);
// Map internal SDL window to window
window_map[window->internal_window] = window;
window_map[window->internal_window] = window.get();
return window;
}
@ -394,16 +394,16 @@ void sdl_window_manager::update()
sdl_window* sdl_window_manager::get_window(SDL_Window* internal_window)
{
sdl_window* window = nullptr;
if (auto i = window_map.find(internal_window); i != window_map.end())
{
window = i->second;
return i->second;
}
else
{
throw std::runtime_error("SDL window unrecognized by SDL window manager");
}
return window;
return nullptr;
}
std::size_t sdl_window_manager::get_display_count() const

+ 1
- 1
src/engine/app/sdl/sdl-window-manager.hpp View File

@ -49,7 +49,7 @@ public:
virtual void update();
/// @copydoc window::window()
[[nodiscard]] virtual window* create_window
[[nodiscard]] virtual std::shared_ptr<window> create_window
(
const std::string& title,
const math::vector<int, 2>& windowed_position,

+ 15
- 15
src/engine/app/sdl/sdl-window.hpp View File

@ -31,6 +31,21 @@ namespace app {
class sdl_window: public window
{
public:
sdl_window
(
const std::string& title,
const math::vector<int, 2>& windowed_position,
const math::vector<int, 2>& windowed_size,
bool maximized,
bool fullscreen,
bool v_sync
);
sdl_window(const sdl_window&) = delete;
sdl_window(sdl_window&&) = delete;
sdl_window& operator=(const sdl_window&) = delete;
sdl_window& operator=(sdl_window&&) = delete;
virtual ~sdl_window();
virtual void set_title(const std::string& title);
virtual void set_position(const math::vector<int, 2>& position);
@ -51,21 +66,6 @@ public:
private:
friend class sdl_window_manager;
sdl_window
(
const std::string& title,
const math::vector<int, 2>& windowed_position,
const math::vector<int, 2>& windowed_size,
bool maximized,
bool fullscreen,
bool v_sync
);
sdl_window(const sdl_window&) = delete;
sdl_window(sdl_window&&) = delete;
sdl_window& operator=(const sdl_window&) = delete;
sdl_window& operator=(sdl_window&&) = delete;
SDL_Window* internal_window;
SDL_GLContext internal_context;
gl::rasterizer* rasterizer;

+ 2
- 1
src/engine/app/window-manager.hpp View File

@ -23,6 +23,7 @@
#include <engine/app/display.hpp>
#include <engine/app/window.hpp>
#include <engine/math/vector.hpp>
#include <memory>
#include <string>
namespace app {
@ -56,7 +57,7 @@ public:
* @param fullscreen `true` if the window should start fullscreen, `false` otherwise.
* @param v_sync `true` if v-sync should be enabled, `false` otherwise.
*/
[[nodiscard]] virtual window* create_window
[[nodiscard]] virtual std::shared_ptr<window> create_window
(
const std::string& title,
const math::vector<int, 2>& windowed_position,

+ 2
- 2
src/game/ant/swarm.cpp View File

@ -48,7 +48,7 @@ static math::vector3 sphere_random(Generator& rng)
return math::normalize(position) * std::cbrt(distribution(rng));
}
entity::id create_swarm(::context& ctx)
entity::id create_swarm(::game& ctx)
{
// Determine swarm properties
const float3 swarm_center = {0, 100, 0};
@ -166,7 +166,7 @@ entity::id create_swarm(::context& ctx)
return swarm_eid;
}
void destroy_swarm(::context& ctx, entity::id swarm_eid)
void destroy_swarm(::game& ctx, entity::id swarm_eid)
{
// Destroy alates
auto view = ctx.entity_registry->view<::steering_component>();

+ 3
- 3
src/game/ant/swarm.hpp View File

@ -20,13 +20,13 @@
#ifndef ANTKEEPER_GAME_ANT_SWARM_HPP
#define ANTKEEPER_GAME_ANT_SWARM_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include <engine/entity/id.hpp>
namespace ant {
entity::id create_swarm(::context& ctx);
void destroy_swarm(::context& ctx, entity::id swarm_eid);
entity::id create_swarm(::game& ctx);
void destroy_swarm(::game& ctx, entity::id swarm_eid);
} // namespace ant

+ 15
- 16
src/game/controls.cpp View File

@ -21,7 +21,7 @@
#include "game/graphics.hpp"
#include "game/menu.hpp"
#include "game/control-profile.hpp"
#include "game/state/pause-menu.hpp"
#include "game/states/pause-menu-state.hpp"
#include <engine/resources/resource-manager.hpp>
#include <engine/resources/json.hpp>
#include <engine/input/modifier-key.hpp>
@ -29,7 +29,6 @@
using namespace hash::literals;
void reset_control_profile(::control_profile& profile)
{
auto& mappings = profile.mappings;
@ -133,7 +132,7 @@ void reset_control_profile(::control_profile& profile)
mappings.emplace("pick_mate"_fnv1a32, new input::mouse_button_mapping(nullptr, input::mouse_button::right));
}
void apply_control_profile(::context& ctx, const ::control_profile& profile)
void apply_control_profile(::game& ctx, const ::control_profile& profile)
{
auto add_mappings = [&profile](input::action_map& map, input::action& action, std::uint32_t key)
{
@ -173,7 +172,7 @@ void apply_control_profile(::context& ctx, const ::control_profile& profile)
add_mappings(ctx.nuptial_flight_action_map, ctx.pick_mate_action, "pick_mate"_fnv1a32);
}
void update_control_profile(::context& ctx, ::control_profile& profile)
void update_control_profile(::game& ctx, ::control_profile& profile)
{
auto add_mappings = [&profile](const input::action_map& map, const input::action& action, std::uint32_t key)
{
@ -238,7 +237,7 @@ void update_control_profile(::context& ctx, ::control_profile& profile)
add_mappings(ctx.nuptial_flight_action_map, ctx.pick_mate_action, "pick_mate"_fnv1a32);
}
void setup_window_controls(::context& ctx)
void setup_window_controls(::game& ctx)
{
// Setup fullscreen control
ctx.window_action_subscriptions.emplace_back
@ -265,7 +264,7 @@ void setup_window_controls(::context& ctx)
);
}
void setup_menu_controls(::context& ctx)
void setup_menu_controls(::game& ctx)
{
// Setup menu controls
ctx.menu_action_subscriptions.emplace_back
@ -355,7 +354,7 @@ void setup_menu_controls(::context& ctx)
ctx.menu_right_action.set_threshold_function(menu_action_threshold);
}
void setup_game_controls(::context& ctx)
void setup_game_controls(::game& ctx)
{
// Setup pause control
ctx.movement_action_subscriptions.emplace_back
@ -375,7 +374,7 @@ void setup_game_controls(::context& ctx)
::disable_game_controls(ctx);
// Push pause menu state
ctx.state_machine.emplace(new ::state::pause_menu(ctx));
ctx.state_machine.emplace(std::make_unique<pause_menu_state>(ctx));
}
);
@ -391,12 +390,12 @@ void setup_game_controls(::context& ctx)
);
}
void enable_window_controls(::context& ctx)
void enable_window_controls(::game& ctx)
{
ctx.window_action_map.enable();
}
void enable_menu_controls(::context& ctx)
void enable_menu_controls(::game& ctx)
{
ctx.menu_action_map.enable();
@ -497,22 +496,22 @@ void enable_menu_controls(::context& ctx)
);
}
void enable_game_controls(::context& ctx)
void enable_game_controls(::game& ctx)
{
ctx.movement_action_map.enable();
}
void enable_nuptial_flight_controls(::context& ctx)
void enable_nuptial_flight_controls(::game& ctx)
{
ctx.nuptial_flight_action_map.enable();
}
void disable_window_controls(::context& ctx)
void disable_window_controls(::game& ctx)
{
ctx.window_action_map.disable();
}
void disable_menu_controls(::context& ctx)
void disable_menu_controls(::game& ctx)
{
ctx.menu_action_map.disable();
@ -527,7 +526,7 @@ void disable_menu_controls(::context& ctx)
ctx.menu_modifier_action.reset();
}
void disable_game_controls(::context& ctx)
void disable_game_controls(::game& ctx)
{
ctx.movement_action_map.disable();
@ -540,7 +539,7 @@ void disable_game_controls(::context& ctx)
ctx.pause_action.reset();
}
void disable_nuptial_flight_controls(::context& ctx)
void disable_nuptial_flight_controls(::game& ctx)
{
ctx.nuptial_flight_action_map.disable();

+ 14
- 14
src/game/controls.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_CONTROLS_HPP
#define ANTKEEPER_GAME_CONTROLS_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include <engine/resources/json.hpp>
#include <engine/input/gamepad.hpp>
#include <filesystem>
@ -39,7 +39,7 @@ void reset_control_profile(::control_profile& profile);
* @param ctx Game context.
* @param profile Control profile to apply.
*/
void apply_control_profile(::context& ctx, const ::control_profile& profile);
void apply_control_profile(::game& ctx, const ::control_profile& profile);
/**
* Updates a control profile after actions have been remapped.
@ -47,21 +47,21 @@ void apply_control_profile(::context& ctx, const ::control_profile& profile);
* @param ctx Game context.
* @param profile Control profile to update.
*/
void update_control_profile(::context& ctx, ::control_profile& profile);
void update_control_profile(::game& ctx, ::control_profile& profile);
void setup_window_controls(::context& ctx);
void setup_menu_controls(::context& ctx);
void setup_game_controls(::context& ctx);
void setup_window_controls(::game& ctx);
void setup_menu_controls(::game& ctx);
void setup_game_controls(::game& ctx);
void enable_window_controls(::context& ctx);
void enable_menu_controls(::context& ctx);
void enable_game_controls(::context& ctx);
void enable_nuptial_flight_controls(::context& ctx);
void enable_window_controls(::game& ctx);
void enable_menu_controls(::game& ctx);
void enable_game_controls(::game& ctx);
void enable_nuptial_flight_controls(::game& ctx);
void disable_window_controls(::context& ctx);
void disable_menu_controls(::context& ctx);
void disable_game_controls(::context& ctx);
void disable_nuptial_flight_controls(::context& ctx);
void disable_window_controls(::game& ctx);
void disable_menu_controls(::game& ctx);
void disable_game_controls(::game& ctx);
void disable_nuptial_flight_controls(::game& ctx);
#endif // ANTKEEPER_GAME_CONTROLS_HPP

+ 1
- 1
src/game/fonts.cpp View File

@ -68,7 +68,7 @@ static void build_bitmap_font(const type::typeface& typeface, float size, const
material.set_shader_program(shader_program);
}
void load_fonts(::context& ctx)
void load_fonts(::game& ctx)
{
// Load dyslexia-friendly typeface (if enabled)
bool dyslexia_font_loaded = false;

+ 2
- 2
src/game/fonts.hpp View File

@ -20,10 +20,10 @@
#ifndef ANTKEEPER_GAME_FONTS_HPP
#define ANTKEEPER_GAME_FONTS_HPP
#include "game/context.hpp"
#include "game/game.hpp"
void load_fonts(::context& ctx);
void load_fonts(::game& ctx);
#endif // ANTKEEPER_GAME_FONTS_HPP

+ 1340
- 0
src/game/game.cpp
File diff suppressed because it is too large
View File


src/game/context.hpp → src/game/game.hpp View File

@ -17,18 +17,20 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_CONTEXT_HPP
#define ANTKEEPER_GAME_CONTEXT_HPP
#ifndef ANTKEEPER_GAME_HPP
#define ANTKEEPER_GAME_HPP
#include "game/ecoregion.hpp"
#include "game/loop.hpp"
#include "game/states/game-state.hpp"
#include <AL/al.h>
#include <AL/alc.h>
#include <engine/animation/tween.hpp>
#include <engine/app/input-manager.hpp>
#include <engine/app/window-manager.hpp>
#include <engine/entity/id.hpp>
#include <engine/entity/registry.hpp>
#include <engine/event/subscription.hpp>
#include "game/ecoregion.hpp"
#include "game/loop.hpp"
#include "game/state/base.hpp"
#include <engine/geom/aabb.hpp>
#include <engine/gl/framebuffer.hpp>
#include <engine/gl/rasterizer.hpp>
@ -50,8 +52,6 @@
#include <engine/utility/dict.hpp>
#include <engine/utility/fundamental-types.hpp>
#include <engine/utility/state-machine.hpp>
#include <AL/al.h>
#include <AL/alc.h>
#include <entt/entt.hpp>
#include <filesystem>
#include <memory>
@ -92,31 +92,47 @@ namespace render
}
// Forward declaration of system types.
class subterrain_system;
class terrain_system;
class spatial_system;
// Forward declarations of system types.
class astronomy_system;
class blackbody_system;
class atmosphere_system;
class orbit_system;
class behavior_system;
class blackbody_system;
class camera_system;
class collision_system;
class constraint_system;
class locomotion_system;
class camera_system;
class nest_system;
class orbit_system;
class render_system;
class steering_system;
class spatial_system;
class spring_system;
class steering_system;
class subterrain_system;
class terrain_system;
struct control_profile;
/// Container for data shared between game states.
struct context
class game
{
context();
~context();
public:
/**
* Boots up the game.
*
* @param argc Command line argument count.
* @param argv Command line argument vector.
*/
game(int argc, const char* const* argv);
/**
* Boots down the game.
*/
~game();
/**
* Executes the game.
*/
void execute();
// Command-line options
std::optional<bool> option_continue;
@ -129,7 +145,7 @@ struct context
std::optional<bool> option_windowed;
// Resource management and paths
resource_manager* resource_manager;
std::unique_ptr<resource_manager> resource_manager;
std::filesystem::path data_package_path;
std::filesystem::path mods_path;
std::filesystem::path local_config_path;
@ -139,17 +155,17 @@ struct context
std::filesystem::path controls_path;
// Persistent settings
dict<std::uint32_t>* settings;
std::shared_ptr<dict<std::uint32_t>> settings;
// Window management and window event handling
app::window_manager* window_manager;
app::window* window;
std::unique_ptr<app::window_manager> window_manager;
std::shared_ptr<app::window> window;
bool closed;
std::shared_ptr<::event::subscription> window_closed_subscription;
std::shared_ptr<::event::subscription> window_resized_subscription;
// Input management and input event handling
app::input_manager* input_manager;
std::unique_ptr<app::input_manager> input_manager;
std::shared_ptr<::event::subscription> application_quit_subscription;
std::shared_ptr<::event::subscription> gamepad_axis_moved_subscription;
std::shared_ptr<::event::subscription> gamepad_button_pressed_subscription;
@ -207,11 +223,12 @@ struct context
// Debugging
scene::text* frame_time_text;
debug::cli* cli;
math::moving_average<float, 30> average_frame_time;
std::unique_ptr<scene::text> frame_time_text;
std::unique_ptr<debug::cli> cli;
// Hierarchichal state machine
hsm::state_machine<::state::base> state_machine;
hsm::state_machine<game_state> state_machine;
std::function<void()> resume_callback;
// Queue for scheduling "next frame" function calls
@ -237,42 +254,45 @@ struct context
gl::framebuffer* shadow_map_framebuffer;
// Rendering
gl::rasterizer* rasterizer;
render::renderer* renderer;
//gl::rasterizer* rasterizer;
int2 render_resolution;
float render_scale;
int shadow_map_resolution;
gl::vertex_buffer* billboard_vbo;
gl::vertex_array* billboard_vao;
std::unique_ptr<gl::vertex_buffer> billboard_vbo;
std::unique_ptr<gl::vertex_array> billboard_vao;
render::material* fallback_material;
// Compositing
render::clear_pass* ui_clear_pass;
render::material_pass* ui_material_pass;
render::compositor* ui_compositor;
render::bloom_pass* bloom_pass;
render::final_pass* common_final_pass;
render::fxaa_pass* fxaa_pass;
render::resample_pass* resample_pass;
render::clear_pass* underground_clear_pass;
render::material_pass* underground_material_pass;
render::compositor* underground_compositor;
render::clear_pass* surface_shadow_map_clear_pass;
render::shadow_map_pass* surface_shadow_map_pass;
render::clear_pass* surface_clear_pass;
render::sky_pass* sky_pass;
render::material_pass* surface_material_pass;
render::outline_pass* surface_outline_pass;
render::compositor* surface_compositor;
render::ground_pass* ground_pass;
std::unique_ptr<render::clear_pass> ui_clear_pass;
std::unique_ptr<render::material_pass> ui_material_pass;
std::unique_ptr<render::compositor> ui_compositor;
std::unique_ptr<render::bloom_pass> bloom_pass;
std::unique_ptr<render::final_pass> common_final_pass;
std::unique_ptr<render::fxaa_pass> fxaa_pass;
std::unique_ptr<render::resample_pass> resample_pass;
std::unique_ptr<render::clear_pass> underground_clear_pass;
std::unique_ptr<render::material_pass> underground_material_pass;
std::unique_ptr<render::compositor> underground_compositor;
std::unique_ptr<render::clear_pass> surface_shadow_map_clear_pass;
std::unique_ptr<render::shadow_map_pass> surface_shadow_map_pass;
std::unique_ptr<render::clear_pass> surface_clear_pass;
std::unique_ptr<render::sky_pass> sky_pass;
std::unique_ptr<render::material_pass> surface_material_pass;
std::unique_ptr<render::outline_pass> surface_outline_pass;
std::unique_ptr<render::compositor> surface_compositor;
std::unique_ptr<render::ground_pass> ground_pass;
std::unique_ptr<render::renderer> renderer;
// Scene utilities
scene::collection* active_scene;
// UI
scene::collection* ui_scene;
scene::camera* ui_camera;
scene::billboard* camera_flash_billboard;
std::unique_ptr<scene::collection> ui_scene;
std::unique_ptr<scene::camera> ui_camera;
std::unique_ptr<scene::billboard> menu_bg_billboard;
render::material menu_bg_material;
std::unique_ptr<animation<float>> menu_fade_animation;
std::unique_ptr<animation<float>> menu_bg_fade_in_animation;
std::unique_ptr<animation<float>> menu_bg_fade_out_animation;
float font_scale;
bool dyslexia_font;
float debug_font_size_pt;
@ -286,33 +306,26 @@ struct context
std::vector<std::tuple<scene::text*, scene::text*>> menu_item_texts;
std::unordered_map<std::string, int> menu_item_indices;
int* menu_item_index;
scene::billboard* menu_bg_billboard;
animation<float>* menu_fade_animation;
animation<float>* menu_bg_fade_in_animation;
animation<float>* menu_bg_fade_out_animation;
// Surface scene
scene::collection* surface_scene;
scene::camera* surface_camera;
// Underground scene
scene::collection* underground_scene;
scene::camera* underground_camera;
scene::ambient_light* underground_ambient_light;
scene::spot_light* flashlight_spot_light;
// Scene
std::unique_ptr<scene::collection> surface_scene;
std::unique_ptr<scene::camera> surface_camera;
std::unique_ptr<scene::collection> underground_scene;
std::unique_ptr<scene::camera> underground_camera;
std::unique_ptr<scene::ambient_light> underground_ambient_light;
std::unique_ptr<scene::spot_light> flashlight_spot_light;
// Animation
timeline* timeline;
animator* animator;
animation<float>* radial_transition_in;
animation<float>* radial_transition_out;
screen_transition* fade_transition;
std::unique_ptr<timeline> timeline;
std::unique_ptr<animator> animator;
std::unique_ptr<animation<float>> radial_transition_in;
std::unique_ptr<animation<float>> radial_transition_out;
std::unique_ptr<screen_transition> fade_transition;
render::material_property<float3>* fade_transition_color;
screen_transition* radial_transition_inner;
screen_transition* radial_transition_outer;
animation<float>* equip_tool_animation;
animation<float>* unequip_tool_animation;
animation<float>* camera_flash_animation;
std::unique_ptr<screen_transition> radial_transition_inner;
std::unique_ptr<screen_transition> radial_transition_outer;
std::unique_ptr<animation<float>> equip_tool_animation;
std::unique_ptr<animation<float>> unequip_tool_animation;
// Sound
ALCdevice* alc_device;
@ -325,34 +338,51 @@ struct context
float captions_size;
// Entities
entity::registry* entity_registry;
std::unique_ptr<entity::registry> entity_registry;
std::unordered_map<std::string, entity::id> entities;
// Systems
::behavior_system* behavior_system;
::camera_system* camera_system;
::collision_system* collision_system;
::constraint_system* constraint_system;
::locomotion_system* locomotion_system;
::steering_system* steering_system;
::render_system* render_system;
::subterrain_system* subterrain_system;
::terrain_system* terrain_system;
::spring_system* spring_system;
::spatial_system* spatial_system;
::blackbody_system* blackbody_system;
::atmosphere_system* atmosphere_system;
::astronomy_system* astronomy_system;
::orbit_system* orbit_system;
std::unique_ptr<::orbit_system> unique_orbit;
std::unique_ptr<::behavior_system> behavior_system;
std::unique_ptr<::camera_system> camera_system;
std::unique_ptr<::collision_system> collision_system;
std::unique_ptr<::constraint_system> constraint_system;
std::unique_ptr<::locomotion_system> locomotion_system;
std::unique_ptr<::steering_system> steering_system;
std::unique_ptr<::render_system> render_system;
std::unique_ptr<::subterrain_system> subterrain_system;
std::unique_ptr<::terrain_system> terrain_system;
std::unique_ptr<::spring_system> spring_system;
std::unique_ptr<::spatial_system> spatial_system;
std::unique_ptr<::blackbody_system> blackbody_system;
std::unique_ptr<::atmosphere_system> atmosphere_system;
std::unique_ptr<::astronomy_system> astronomy_system;
std::unique_ptr<::orbit_system> orbit_system;
double3 rgb_wavelengths;
const ecoregion* active_ecoregion;
render::anti_aliasing_method anti_aliasing_method;
private:
void parse_options(int argc, const char* const* argv);
void setup_resources();
void load_settings();
void setup_window();
void setup_input();
void load_strings();
void setup_rendering();
void setup_audio();
void setup_scenes();
void setup_animation();
void setup_ui();
void setup_entities();
void setup_systems();
void setup_controls();
void setup_debugging();
void setup_loop();
void shutdown_audio();
};
#endif // ANTKEEPER_GAME_CONTEXT_HPP
#endif // ANTKEEPER_GAME_HPP

+ 7
- 7
src/game/graphics.cpp View File

@ -37,9 +37,9 @@
namespace graphics {
static void reroute_framebuffers(::context& ctx);
static void reroute_framebuffers(::game& ctx);
void create_framebuffers(::context& ctx)
void create_framebuffers(::game& ctx)
{
debug::log::trace("Creating framebuffers...");
@ -87,7 +87,7 @@ void create_framebuffers(::context& ctx)
debug::log::trace("Created framebuffers");
}
void destroy_framebuffers(::context& ctx)
void destroy_framebuffers(::game& ctx)
{
debug::log::trace("Destroying framebuffers...");
@ -119,7 +119,7 @@ void destroy_framebuffers(::context& ctx)
debug::log::trace("Destroyed framebuffers");
}
void change_render_resolution(::context& ctx, float scale)
void change_render_resolution(::game& ctx, float scale)
{
debug::log::trace("Changing render resolution to {}...", scale);
@ -160,7 +160,7 @@ void change_render_resolution(::context& ctx, float scale)
debug::log::trace("Changed render resolution to {}", scale);
}
void save_screenshot(::context& ctx)
void save_screenshot(::game& ctx)
{
// Determine timestamped screenshot filename
const auto time = std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now());
@ -198,7 +198,7 @@ void save_screenshot(::context& ctx)
}
void select_anti_aliasing_method(::context& ctx, render::anti_aliasing_method method)
void select_anti_aliasing_method(::game& ctx, render::anti_aliasing_method method)
{
// Switch AA method
switch (method)
@ -222,7 +222,7 @@ void select_anti_aliasing_method(::context& ctx, render::anti_aliasing_method me
ctx.anti_aliasing_method = method;
}
void reroute_framebuffers(::context& ctx)
void reroute_framebuffers(::game& ctx)
{
if (ctx.fxaa_pass->is_enabled())
{

+ 7
- 7
src/game/graphics.hpp View File

@ -20,17 +20,17 @@
#ifndef ANTKEEPER_GAME_GRAPHICS_HPP
#define ANTKEEPER_GAME_GRAPHICS_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include <engine/render/anti-aliasing-method.hpp>
namespace graphics {
void create_framebuffers(::context& ctx);
void destroy_framebuffers(::context& ctx);
void change_render_resolution(::context& ctx, float scale);
void save_screenshot(::context& ctx);
void toggle_bloom(::context& ctx, bool enabled);
void select_anti_aliasing_method(::context& ctx, render::anti_aliasing_method method);
void create_framebuffers(::game& ctx);
void destroy_framebuffers(::game& ctx);
void change_render_resolution(::game& ctx, float scale);
void save_screenshot(::game& ctx);
void toggle_bloom(::game& ctx, bool enabled);
void select_anti_aliasing_method(::game& ctx, render::anti_aliasing_method method);
} // namespace graphics

+ 1
- 1
src/game/load.cpp View File

@ -24,7 +24,7 @@
namespace load {
void colony(::context& ctx, const std::filesystem::path& path)
void colony(::game& ctx, const std::filesystem::path& path)
{
const std::string path_string = path.string();

+ 2
- 2
src/game/load.hpp View File

@ -20,14 +20,14 @@
#ifndef ANTKEEPER_GAME_LOAD_HPP
#define ANTKEEPER_GAME_LOAD_HPP
#include "game/context.hpp"
#include "game/game.hpp"
namespace load {
/**
* Loads a colony
*/
void colony(::context& ctx, const std::filesystem::path& path);
void colony(::game& ctx, const std::filesystem::path& path);
} // namespace load

+ 4
- 9
src/game/main.cpp View File

@ -17,17 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/game.hpp"
#include <SDL2/SDL.h>
#include <chrono>
#include <engine/config.hpp>
#include <engine/debug/console.hpp>
#include <engine/debug/log.hpp>
#include "game/context.hpp"
#include "game/state/boot.hpp"
#include <engine/utility/ansi.hpp>
#include <engine/utility/paths.hpp>
#include <chrono>
#include <fstream>
#include <iostream>
#include <SDL2/SDL.h>
#include <set>
#include <stdexcept>
#include <syncstream>
@ -201,11 +200,7 @@ int main(int argc, char* argv[])
try
{
// Allocate game context
::context ctx;
// Enter boot state
ctx.state_machine.emplace(new ::state::boot(ctx, argc, argv));
game(argc, argv).execute();
}
catch (const std::exception& e)
{

+ 20
- 21
src/game/menu.cpp View File

@ -30,7 +30,7 @@ using namespace math::glsl;
namespace menu {
void init_menu_item_index(::context& ctx, const std::string& menu_name)
void init_menu_item_index(::game& ctx, const std::string& menu_name)
{
if (auto it = ctx.menu_item_indices.find(menu_name); it != ctx.menu_item_indices.end())
{
@ -43,7 +43,7 @@ void init_menu_item_index(::context& ctx, const std::string& menu_name)
}
}
void update_text_font(::context& ctx)
void update_text_font(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -58,7 +58,7 @@ void update_text_font(::context& ctx)
}
}
void update_text_color(::context& ctx)
void update_text_color(::game& ctx)
{
for (std::size_t i = 0; i < ctx.menu_item_texts.size(); ++i)
{
@ -72,7 +72,7 @@ void update_text_color(::context& ctx)
}
}
void update_text_tweens(::context& ctx)
void update_text_tweens(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -82,7 +82,7 @@ void update_text_tweens(::context& ctx)
}
}
void align_text(::context& ctx, bool center, bool has_back, float anchor_y)
void align_text(::game& ctx, bool center, bool has_back, float anchor_y)
{
@ -165,7 +165,7 @@ void align_text(::context& ctx, bool center, bool has_back, float anchor_y)
}
}
void refresh_text(::context& ctx)
void refresh_text(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -175,7 +175,7 @@ void refresh_text(::context& ctx)
}
}
void add_text_to_ui(::context& ctx)
void add_text_to_ui(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -185,7 +185,7 @@ void add_text_to_ui(::context& ctx)
}
}
void remove_text_from_ui(::context& ctx)
void remove_text_from_ui(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -195,7 +195,7 @@ void remove_text_from_ui(::context& ctx)
}
}
void delete_text(::context& ctx)
void delete_text(::game& ctx)
{
for (auto [name, value]: ctx.menu_item_texts)
{
@ -206,14 +206,13 @@ void delete_text(::context& ctx)
ctx.menu_item_texts.clear();
}
void delete_animations(::context& ctx)
void delete_animations(::game& ctx)
{
ctx.animator->remove_animation(ctx.menu_fade_animation);
delete ctx.menu_fade_animation;
ctx.menu_fade_animation = nullptr;
ctx.animator->remove_animation(ctx.menu_fade_animation.get());
ctx.menu_fade_animation.reset();
}
void clear_callbacks(::context& ctx)
void clear_callbacks(::game& ctx)
{
// Clear menu item callbacks
ctx.menu_left_callbacks.clear();
@ -222,9 +221,9 @@ void clear_callbacks(::context& ctx)
ctx.menu_back_callback = nullptr;
}
void setup_animations(::context& ctx)
void setup_animations(::game& ctx)
{
ctx.menu_fade_animation = new animation<float>();
ctx.menu_fade_animation = std::make_unique<animation<float>>();
animation_channel<float>* opacity_channel = ctx.menu_fade_animation->add_channel(0);
ctx.menu_fade_animation->set_frame_callback
@ -246,10 +245,10 @@ void setup_animations(::context& ctx)
}
);
ctx.animator->add_animation(ctx.menu_fade_animation);
ctx.animator->add_animation(ctx.menu_fade_animation.get());
}
void fade_in(::context& ctx, const std::function<void()>& end_callback)
void fade_in(::game& ctx, const std::function<void()>& end_callback)
{
ctx.menu_fade_animation->set_interpolator(ease<float>::out_cubic);
animation_channel<float>* opacity_channel = ctx.menu_fade_animation->get_channel(0);
@ -281,7 +280,7 @@ void fade_in(::context& ctx, const std::function& end_callback)
ctx.menu_fade_animation->play();
}
void fade_out(::context& ctx, const std::function<void()>& end_callback)
void fade_out(::game& ctx, const std::function<void()>& end_callback)
{
ctx.menu_fade_animation->set_interpolator(ease<float>::out_cubic);
animation_channel<float>* opacity_channel = ctx.menu_fade_animation->get_channel(0);
@ -294,14 +293,14 @@ void fade_out(::context& ctx, const std::function& end_callback)
ctx.menu_fade_animation->play();
}
void fade_in_bg(::context& ctx)
void fade_in_bg(::game& ctx)
{
ctx.menu_bg_fade_out_animation->stop();
ctx.menu_bg_fade_in_animation->stop();
ctx.menu_bg_fade_in_animation->play();
}
void fade_out_bg(::context& ctx)
void fade_out_bg(::game& ctx)
{
ctx.menu_bg_fade_in_animation->stop();
ctx.menu_bg_fade_out_animation->stop();

+ 17
- 17
src/game/menu.hpp View File

@ -20,32 +20,32 @@
#ifndef ANTKEEPER_GAME_MENU_HPP
#define ANTKEEPER_GAME_MENU_HPP
#include "game/context.hpp"
#include "game/game.hpp"
namespace menu {
void init_menu_item_index(::context& ctx, const std::string& menu_name);
void setup_animations(::context& ctx);
void init_menu_item_index(::game& ctx, const std::string& menu_name);
void setup_animations(::game& ctx);
void clear_callbacks(::context& ctx);
void remove_text_from_ui(::context& ctx);
void delete_text(::context& ctx);
void delete_animations(::context& ctx);
void clear_callbacks(::game& ctx);
void remove_text_from_ui(::game& ctx);
void delete_text(::game& ctx);
void delete_animations(::game& ctx);
void fade_in(::context& ctx, const std::function<void()>& end_callback);
void fade_out(::context& ctx, const std::function<void()>& end_callback);
void fade_in(::game& ctx, const std::function<void()>& end_callback);
void fade_out(::game& ctx, const std::function<void()>& end_callback);
void fade_in_bg(::context& ctx);
void fade_out_bg(::context& ctx);
void fade_in_bg(::game& ctx);
void fade_out_bg(::game& ctx);
void update_text_color(::context& ctx);
void update_text_font(::context& ctx);
void update_text_tweens(::context& ctx);
void align_text(::context& ctx, bool center = false, bool has_back = true, float anchor_y = 0.0f);
void refresh_text(::context& ctx);
void add_text_to_ui(::context& ctx);
void update_text_color(::game& ctx);
void update_text_font(::game& ctx);
void update_text_tweens(::game& ctx);
void align_text(::game& ctx, bool center = false, bool has_back = true, float anchor_y = 0.0f);
void refresh_text(::game& ctx);
void add_text_to_ui(::game& ctx);
} // namespace menu

+ 2
- 2
src/game/settings.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_SETTINGS_HPP
#define ANTKEEPER_GAME_SETTINGS_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include <engine/debug/log.hpp>
@ -36,7 +36,7 @@
* @return `true` if the setting was read, `false` if the setting was written.
*/
template <class T>
bool read_or_write_setting(::context& ctx, std::uint32_t key, T& value)
bool read_or_write_setting(::game& ctx, std::uint32_t key, T& value)
{
if (auto i = ctx.settings->find(key); i != ctx.settings->end())
{

+ 3
- 3
src/game/spawn.cpp View File

@ -22,7 +22,7 @@
#include "game/components/model-component.hpp"
entity::id spawn_ant_egg(::context& ctx, const ant::genome& genome, bool fertilized, const float3& position)
entity::id spawn_ant_egg(::game& ctx, const ant::genome& genome, bool fertilized, const float3& position)
{
// Create entity
entity::id egg_eid = ctx.entity_registry->create();
@ -45,7 +45,7 @@ entity::id spawn_ant_egg(::context& ctx, const ant::genome& genome, bool fertili
return egg_eid;
}
entity::id spawn_ant_larva(::context& ctx, const ant::genome& genome, const float3& position)
entity::id spawn_ant_larva(::game& ctx, const ant::genome& genome, const float3& position)
{
// Create entity
entity::id larva_eid = ctx.entity_registry->create();
@ -68,7 +68,7 @@ entity::id spawn_ant_larva(::context& ctx, const ant::genome& genome, const floa
return larva_eid;
}
entity::id spawn_worker_ant(::context& ctx, const ant::genome& genome, const float3& position)
entity::id spawn_worker_ant(::game& ctx, const ant::genome& genome, const float3& position)
{
return entt::null;
}

+ 4
- 4
src/game/spawn.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_SPAWN_HPP
#define ANTKEEPER_GAME_SPAWN_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include "game/ant/genome.hpp"
#include <engine/utility/fundamental-types.hpp>
@ -35,7 +35,7 @@
*
* @return Entity ID of the spawned ant egg.
*/
entity::id spawn_ant_egg(::context& ctx, const ant::genome& genome, bool fertilized, const float3& position);
entity::id spawn_ant_egg(::game& ctx, const ant::genome& genome, bool fertilized, const float3& position);
/**
* Spawns an ant larva.
@ -46,7 +46,7 @@ entity::id spawn_ant_egg(::context& ctx, const ant::genome& genome, bool fertili
*
* @return Entity ID of the spawned ant larva.
*/
entity::id spawn_ant_larva(::context& ctx, const ant::genome& genome, const float3& position);
entity::id spawn_ant_larva(::game& ctx, const ant::genome& genome, const float3& position);
/**
* Spawns a worker ant.
@ -57,7 +57,7 @@ entity::id spawn_ant_larva(::context& ctx, const ant::genome& genome, const floa
*
* @return Entity ID of the spawned worker ant.
*/
entity::id spawn_worker_ant(::context& ctx, const ant::genome& genome, const float3& position);
entity::id spawn_worker_ant(::game& ctx, const ant::genome& genome, const float3& position);
#endif // ANTKEEPER_GAME_SPAWN_HPP

+ 0
- 1384
src/game/state/boot.cpp
File diff suppressed because it is too large
View File


+ 0
- 74
src/game/state/boot.hpp View File

@ -1,74 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_BOOT_HPP
#define ANTKEEPER_GAME_STATE_BOOT_HPP
#include "game/state/base.hpp"
#include "game/context.hpp"
#include <optional>
namespace state {
/**
* Boots the game up on construction, and down on destruction.
*/
class boot: public ::state::base
{
public:
/**
* Boots up the game.
*
* @param ctx Game context.
* @param argc Command line argument count.
* @param argv Command line argument vector.
*/
boot(::context& ctx, int argc, const char* const* argv);
/**
* Boots down the game.
*/
virtual ~boot();
private:
void parse_options(int argc, const char* const* argv);
void setup_resources();
void load_settings();
void setup_window();
void setup_input();
void load_strings();
void setup_rendering();
void setup_audio();
void setup_scenes();
void setup_animation();
void setup_entities();
void setup_systems();
void setup_controls();
void setup_ui();
void setup_debugging();
void setup_loop();
void loop();
void shutdown_audio();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_BOOT_HPP

+ 0
- 36
src/game/state/controls-menu.hpp View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_CONTROLS_MENU_HPP
#define ANTKEEPER_GAME_STATE_CONTROLS_MENU_HPP
#include "game/state/base.hpp"
namespace state {
class controls_menu: public ::state::base
{
public:
controls_menu(::context& ctx);
virtual ~controls_menu();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_CONTROLS_MENU_HPP

+ 0
- 36
src/game/state/options-menu.hpp View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_OPTIONS_MENU_HPP
#define ANTKEEPER_GAME_STATE_OPTIONS_MENU_HPP
#include "game/state/base.hpp"
namespace state {
class options_menu: public ::state::base
{
public:
options_menu(::context& ctx);
virtual ~options_menu();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_OPTIONS_MENU_HPP

src/game/state/collection-menu.cpp → src/game/states/collection-menu-state.cpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/collection-menu.hpp"
#include "game/state/main-menu.hpp"
#include "game/states/collection-menu-state.hpp"
#include "game/states/main-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -32,10 +32,8 @@
using namespace hash::literals;
namespace state {
collection_menu::collection_menu(::context& ctx):
::state::base(ctx)
collection_menu_state::collection_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering collection menu state...");
@ -132,7 +130,7 @@ collection_menu::collection_menu(::context& ctx):
debug::log::trace("Entered collection menu state");
}
collection_menu::~collection_menu()
collection_menu_state::~collection_menu_state()
{
debug::log::trace("Exiting collection menu state...");
@ -142,7 +140,7 @@ collection_menu::~collection_menu()
debug::log::trace("Exited collection menu state");
}
void collection_menu::resize_box()
void collection_menu_state::resize_box()
{
const float padding = 64.0f;
const auto viewport_size = float2(ctx.window->get_viewport_size());
@ -175,5 +173,3 @@ void collection_menu::resize_box()
);
selection_billboard.update_tweens();
}
} // namespace state

src/game/state/collection-menu.hpp → src/game/states/collection-menu-state.hpp View File

@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_COLLECTION_MENU_HPP
#define ANTKEEPER_GAME_STATE_COLLECTION_MENU_HPP
#ifndef ANTKEEPER_COLLECTION_MENU_STATE_HPP
#define ANTKEEPER_COLLECTION_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/event/subscription.hpp>
#include <engine/render/material.hpp>
#include <engine/scene/billboard.hpp>
@ -28,13 +28,12 @@
#include <engine/geom/primitive/rectangle.hpp>
#include <memory>
namespace state {
class collection_menu: public ::state::base
class collection_menu_state: public game_state
{
public:
collection_menu(::context& ctx);
virtual ~collection_menu();
collection_menu_state(::game& ctx);
virtual ~collection_menu_state();
private:
void resize_box();
@ -58,6 +57,4 @@ private:
float selection_size;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_COLLECTION_MENU_HPP
#endif // ANTKEEPER_COLLECTION_MENU_STATE_HPP

src/game/state/controls-menu.cpp → src/game/states/controls-menu-state.cpp View File

@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/controls-menu.hpp"
#include "game/state/keyboard-config-menu.hpp"
#include "game/state/gamepad-config-menu.hpp"
#include "game/state/options-menu.hpp"
#include "game/states/controls-menu-state.hpp"
#include "game/states/keyboard-config-menu-state.hpp"
#include "game/states/gamepad-config-menu-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -30,10 +30,8 @@
using namespace hash::literals;
namespace state {
controls_menu::controls_menu(::context& ctx):
::state::base(ctx)
controls_menu_state::controls_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering controls menu state...");
@ -79,7 +77,7 @@ controls_menu::controls_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::keyboard_config_menu(ctx));
ctx.state_machine.emplace(std::make_unique<keyboard_config_menu_state>(ctx));
}
);
}
@ -101,7 +99,7 @@ controls_menu::controls_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::gamepad_config_menu(ctx));
ctx.state_machine.emplace(std::make_unique<gamepad_config_menu_state>(ctx));
}
);
}
@ -123,7 +121,7 @@ controls_menu::controls_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -157,7 +155,7 @@ controls_menu::controls_menu(::context& ctx):
debug::log::trace("Entered controls menu state");
}
controls_menu::~controls_menu()
controls_menu_state::~controls_menu_state()
{
debug::log::trace("Exiting options menu state...");
@ -170,5 +168,3 @@ controls_menu::~controls_menu()
debug::log::trace("Exited controls menu state");
}
} // namespace state

src/game/state/pause-menu.hpp → src/game/states/controls-menu-state.hpp View File

@ -17,20 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_PAUSE_MENU_HPP
#define ANTKEEPER_GAME_STATE_PAUSE_MENU_HPP
#ifndef ANTKEEPER_CONTROLS_MENU_STATE_HPP
#define ANTKEEPER_CONTROLS_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
namespace state {
class pause_menu: public ::state::base
class controls_menu_state: public game_state
{
public:
pause_menu(::context& ctx);
virtual ~pause_menu();
controls_menu_state(::game& ctx);
virtual ~controls_menu_state();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_PAUSE_MENU_HPP
#endif // ANTKEEPER_CONTROLS_MENU_STATE_HPP

src/game/state/credits.cpp → src/game/states/credits-state.cpp View File

@ -17,9 +17,9 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/credits.hpp"
#include "game/state/extras-menu.hpp"
#include "game/context.hpp"
#include "game/states/credits-state.hpp"
#include "game/states/extras-menu-state.hpp"
#include "game/game.hpp"
#include <engine/animation/ease.hpp>
#include <engine/animation/animation.hpp>
#include <engine/animation/animator.hpp>
@ -32,10 +32,8 @@
using namespace hash::literals;
using namespace math::glsl;
namespace state {
credits::credits(::context& ctx):
::state::base(ctx)
credits_state::credits_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering credits state...");
@ -101,7 +99,7 @@ credits::credits(::context& ctx):
{
// Change to extras menu state
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::extras_menu(ctx));
ctx.state_machine.emplace(std::make_unique<extras_menu_state>(ctx));
}
);
};
@ -143,7 +141,7 @@ credits::credits(::context& ctx):
debug::log::trace("Entered credits state");
}
credits::~credits()
credits_state::~credits_state()
{
debug::log::trace("Exiting credits state...");
@ -160,4 +158,3 @@ credits::~credits()
debug::log::trace("Exited credits state");
}
} // namespace state

src/game/state/credits.hpp → src/game/states/credits-state.hpp View File

@ -17,22 +17,21 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_CREDITS_HPP
#define ANTKEEPER_GAME_STATE_CREDITS_HPP
#ifndef ANTKEEPER_CREDITS_STATE_HPP
#define ANTKEEPER_CREDITS_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/scene/text.hpp>
#include <engine/animation/animation.hpp>
#include <engine/event/subscription.hpp>
#include <vector>
namespace state {
class credits: public ::state::base
class credits_state: public game_state
{
public:
credits(::context& ctx);
virtual ~credits();
credits_state(::game& ctx);
virtual ~credits_state();
private:
scene::text credits_text;
@ -42,6 +41,4 @@ private:
std::shared_ptr<event::subscription> window_resized_subscription;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_CREDITS_HPP
#endif // ANTKEEPER_CREDITS_STATE_HPP

src/game/state/extras-menu.cpp → src/game/states/extras-menu-state.cpp View File

@ -17,9 +17,9 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/extras-menu.hpp"
#include "game/state/main-menu.hpp"
#include "game/state/credits.hpp"
#include "game/states/extras-menu-state.hpp"
#include "game/states/main-menu-state.hpp"
#include "game/states/credits-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -30,10 +30,8 @@
using namespace hash::literals;
namespace state {
extras_menu::extras_menu(::context& ctx):
::state::base(ctx)
extras_menu_state::extras_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering extras menu state...");
@ -76,7 +74,7 @@ extras_menu::extras_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::credits(ctx));
ctx.state_machine.emplace(std::make_unique<credits_state>(ctx));
}
);
}
@ -98,7 +96,7 @@ extras_menu::extras_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::main_menu(ctx, false));
ctx.state_machine.emplace(std::make_unique<main_menu_state>(ctx, false));
}
);
}
@ -129,7 +127,7 @@ extras_menu::extras_menu(::context& ctx):
debug::log::trace("Entered extras menu state");
}
extras_menu::~extras_menu()
extras_menu_state::~extras_menu_state()
{
debug::log::trace("Exiting extras menu state...");
@ -143,4 +141,3 @@ extras_menu::~extras_menu()
debug::log::trace("Exited extras menu state");
}
} // namespace state

src/game/state/extras-menu.hpp → src/game/states/extras-menu-state.hpp View File

@ -17,20 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_EXTRAS_MENU_HPP
#define ANTKEEPER_GAME_STATE_EXTRAS_MENU_HPP
#ifndef ANTKEEPER_EXTRAS_MENU_STATE_HPP
#define ANTKEEPER_EXTRAS_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
namespace state {
class extras_menu: public ::state::base
class extras_menu_state: public game_state
{
public:
extras_menu(::context& ctx);
virtual ~extras_menu();
extras_menu_state(::game& ctx);
virtual ~extras_menu_state();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_EXTRAS_MENU_HPP
#endif // ANTKEEPER_EXTRAS_MENU_STATE_HPP

src/game/context.cpp → src/game/states/game-state.cpp View File

@ -17,13 +17,11 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/context.hpp"
#include "game/systems/orbit-system.hpp"
#include "game/states/game-state.hpp"
context::context()
game_state::game_state(::game& ctx):
ctx(ctx)
{}
context::~context()
game_state::~game_state()
{}

src/game/state/base.hpp → src/game/states/game-state.hpp View File

@ -17,18 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_BASE_HPP
#define ANTKEEPER_GAME_STATE_BASE_HPP
#ifndef ANTKEEPER_GAME_STATE_HPP
#define ANTKEEPER_GAME_STATE_HPP
struct context;
namespace state {
class game;
/**
* Abstract base class for game states.
*/
class base
class game_state
{
public:
/**
@ -36,17 +33,15 @@ public:
*
* @param ctx Reference to the game context on which this state will operate.
*/
base(::context& ctx);
game_state(::game& ctx);
/**
* Destructs a game state.
*/
virtual ~base() = 0;
virtual ~game_state() = 0;
protected:
::context& ctx;
::game& ctx;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_BASE_HPP
#endif // ANTKEEPER_GAME_STATE_HPP

src/game/state/gamepad-config-menu.cpp → src/game/states/gamepad-config-menu-state.cpp View File

@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/gamepad-config-menu.hpp"
#include "game/state/controls-menu.hpp"
#include "game/states/gamepad-config-menu-state.hpp"
#include "game/states/controls-menu-state.hpp"
#include "game/controls.hpp"
#include "game/context.hpp"
#include "game/game.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
#include <engine/resources/resource-manager.hpp>
@ -31,10 +31,9 @@
using namespace hash::literals;
namespace state {
gamepad_config_menu::gamepad_config_menu(::context& ctx):
::state::base(ctx),
gamepad_config_menu_state::gamepad_config_menu_state(::game& ctx):
game_state(ctx),
action_remapped(false)
{
debug::log::trace("Entering gamepad config menu state...");
@ -84,7 +83,7 @@ gamepad_config_menu::gamepad_config_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::controls_menu(ctx));
ctx.state_machine.emplace(std::make_unique<controls_menu_state>(ctx));
}
);
}
@ -112,7 +111,7 @@ gamepad_config_menu::gamepad_config_menu(::context& ctx):
debug::log::trace("Entered gamepad config menu state");
}
gamepad_config_menu::~gamepad_config_menu()
gamepad_config_menu_state::~gamepad_config_menu_state()
{
debug::log::trace("Exiting gamepad config menu state...");
@ -136,7 +135,7 @@ gamepad_config_menu::~gamepad_config_menu()
debug::log::trace("Exited gamepad config menu state");
}
std::string gamepad_config_menu::get_mapping_string(const input::action_map& action_map, const input::action& control)
std::string gamepad_config_menu_state::get_mapping_string(const input::action_map& action_map, const input::action& control)
{
std::string mapping_string;
@ -288,7 +287,7 @@ std::string gamepad_config_menu::get_mapping_string(const input::action_map& act
return mapping_string;
}
void gamepad_config_menu::add_control_item(input::action_map& action_map, input::action& control, std::uint32_t control_name_hash)
void gamepad_config_menu_state::add_control_item(input::action_map& action_map, input::action& control, std::uint32_t control_name_hash)
{
// Construct texts
scene::text* name_text = new scene::text();
@ -369,5 +368,3 @@ void gamepad_config_menu::add_control_item(input::action_map& action_map, input:
ctx.menu_left_callbacks.push_back(nullptr);
ctx.menu_right_callbacks.push_back(nullptr);
}
} // namespace state

src/game/state/gamepad-config-menu.hpp → src/game/states/gamepad-config-menu-state.hpp View File

@ -17,23 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_GAMEPAD_CONFIG_MENU_HPP
#define ANTKEEPER_GAME_STATE_GAMEPAD_CONFIG_MENU_HPP
#ifndef ANTKEEPER_GAMEPAD_CONFIG_MENU_STATE_HPP
#define ANTKEEPER_GAMEPAD_CONFIG_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/input/action.hpp>
#include <engine/input/action-map.hpp>
#include <engine/event/subscription.hpp>
#include <cstdint>
#include <memory>
namespace state {
class gamepad_config_menu: public ::state::base
class gamepad_config_menu_state: public game_state
{
public:
gamepad_config_menu(::context& ctx);
virtual ~gamepad_config_menu();
gamepad_config_menu_state(::game& ctx);
virtual ~gamepad_config_menu_state();
private:
std::string get_mapping_string(const input::action_map& action_map, const input::action& control);
@ -46,6 +45,5 @@ private:
bool action_remapped;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_GAMEPAD_CONFIG_MENU_HPP
#endif // ANTKEEPER_GAMEPAD_CONFIG_MENU_STATE_HPP

src/game/state/graphics-menu.cpp → src/game/states/graphics-menu-state.cpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/graphics-menu.hpp"
#include "game/state/options-menu.hpp"
#include "game/states/graphics-menu-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -31,12 +31,9 @@
using namespace hash::literals;
namespace state {
static void update_value_text_content(::context* ctx);
graphics_menu::graphics_menu(::context& ctx):
::state::base(ctx)
graphics_menu_state::graphics_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering graphics menu state...");
@ -309,7 +306,7 @@ graphics_menu::graphics_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -355,7 +352,7 @@ graphics_menu::graphics_menu(::context& ctx):
debug::log::trace("Entered graphics menu state");
}
graphics_menu::~graphics_menu()
graphics_menu_state::~graphics_menu_state()
{
debug::log::trace("Exiting graphics menu state...");
@ -369,7 +366,7 @@ graphics_menu::~graphics_menu()
debug::log::trace("Exited graphics menu state");
}
void graphics_menu::update_value_text_content()
void graphics_menu_state::update_value_text_content()
{
const bool fullscreen = ctx.window->is_fullscreen();
const float render_scale = ctx.render_scale;
@ -404,5 +401,3 @@ void graphics_menu::update_value_text_content()
std::get<1>(ctx.menu_item_texts[4])->set_content(std::to_string(static_cast<int>(std::round(font_scale * 100.0f))) + "%");
std::get<1>(ctx.menu_item_texts[5])->set_content((dyslexia_font) ? string_on : string_off);
}
} // namespace state

src/game/state/sound-menu.hpp → src/game/states/graphics-menu-state.hpp View File

@ -17,23 +17,20 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_SOUND_MENU_HPP
#define ANTKEEPER_GAME_STATE_SOUND_MENU_HPP
#ifndef ANTKEEPER_GRAPHICS_MENU_STATE_HPP
#define ANTKEEPER_GRAPHICS_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
namespace state {
class sound_menu: public ::state::base
class graphics_menu_state: public game_state
{
public:
sound_menu(::context& ctx);
virtual ~sound_menu();
graphics_menu_state(::game& ctx);
virtual ~graphics_menu_state();
private:
void update_value_text_content();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_SOUND_MENU_HPP
#endif // ANTKEEPER_GRAPHICS_MENU_STATE_HPP

src/game/state/keyboard-config-menu.cpp → src/game/states/keyboard-config-menu-state.cpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/keyboard-config-menu.hpp"
#include "game/state/controls-menu.hpp"
#include "game/states/keyboard-config-menu-state.hpp"
#include "game/states/controls-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -32,10 +32,8 @@
using namespace hash::literals;
namespace state {
keyboard_config_menu::keyboard_config_menu(::context& ctx):
::state::base(ctx),
keyboard_config_menu_state::keyboard_config_menu_state(::game& ctx):
game_state(ctx),
action_remapped(false)
{
debug::log::trace("Entering keyboard config menu state...");
@ -85,7 +83,7 @@ keyboard_config_menu::keyboard_config_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::controls_menu(ctx));
ctx.state_machine.emplace(std::make_unique<controls_menu_state>(ctx));
}
);
}
@ -113,7 +111,7 @@ keyboard_config_menu::keyboard_config_menu(::context& ctx):
debug::log::trace("Entered keyboard config menu state");
}
keyboard_config_menu::~keyboard_config_menu()
keyboard_config_menu_state::~keyboard_config_menu_state()
{
debug::log::trace("Exiting keyboard config menu state...");
@ -137,7 +135,7 @@ keyboard_config_menu::~keyboard_config_menu()
debug::log::trace("Exited keyboard config menu state...");
}
std::string keyboard_config_menu::get_mapping_string(const input::action_map& action_map, const input::action& control)
std::string keyboard_config_menu_state::get_mapping_string(const input::action_map& action_map, const input::action& control)
{
std::string mapping_string;
@ -211,7 +209,7 @@ std::string keyboard_config_menu::get_mapping_string(const input::action_map& ac
return mapping_string;
}
void keyboard_config_menu::add_control_item(input::action_map& action_map, input::action& control, std::uint32_t control_name_hash)
void keyboard_config_menu_state::add_control_item(input::action_map& action_map, input::action& control, std::uint32_t control_name_hash)
{
// Construct texts
scene::text* name_text = new scene::text();
@ -294,5 +292,3 @@ void keyboard_config_menu::add_control_item(input::action_map& action_map, input
ctx.menu_left_callbacks.push_back(nullptr);
ctx.menu_right_callbacks.push_back(nullptr);
}
} // namespace state

src/game/state/keyboard-config-menu.hpp → src/game/states/keyboard-config-menu-state.hpp View File

@ -17,23 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_KEYBOARD_CONFIG_MENU_HPP
#define ANTKEEPER_GAME_STATE_KEYBOARD_CONFIG_MENU_HPP
#ifndef ANTKEEPER_KEYBOARD_CONFIG_MENU_STATE_HPP
#define ANTKEEPER_KEYBOARD_CONFIG_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/input/action.hpp>
#include <engine/input/action-map.hpp>
#include <engine/event/subscription.hpp>
#include <cstdint>
#include <memory>
namespace state {
class keyboard_config_menu: public ::state::base
class keyboard_config_menu_state: public game_state
{
public:
keyboard_config_menu(::context& ctx);
virtual ~keyboard_config_menu();
keyboard_config_menu_state(::game& ctx);
virtual ~keyboard_config_menu_state();
private:
std::string get_mapping_string(const input::action_map& action_map, const input::action& control);
@ -46,6 +45,4 @@ private:
bool action_remapped;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_KEYBOARD_CONFIG_MENU_HPP
#endif // ANTKEEPER_KEYBOARD_CONFIG_MENU_STATE_HPP

src/game/state/language-menu.cpp → src/game/states/language-menu-state.cpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/language-menu.hpp"
#include "game/state/options-menu.hpp"
#include "game/states/language-menu-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -32,10 +32,8 @@
using namespace hash::literals;
namespace state {
language_menu::language_menu(::context& ctx):
::state::base(ctx)
language_menu_state::language_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering language menu state...");
@ -155,7 +153,7 @@ language_menu::language_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -186,7 +184,7 @@ language_menu::language_menu(::context& ctx):
debug::log::trace("Entered language menu state");
}
language_menu::~language_menu()
language_menu_state::~language_menu_state()
{
debug::log::trace("Exiting language menu state...");
@ -200,7 +198,7 @@ language_menu::~language_menu()
debug::log::trace("Exited language menu state");
}
void language_menu::update_text_content()
void language_menu_state::update_text_content()
{
auto [language_name, language_value] = ctx.menu_item_texts[0];
auto [back_name, back_value] = ctx.menu_item_texts[1];
@ -209,5 +207,3 @@ void language_menu::update_text_content()
language_value->set_content(get_string(ctx, "language_name_native"_fnv1a32));
back_name->set_content(get_string(ctx, "back"_fnv1a32));
}
} // namespace state

src/game/state/language-menu.hpp → src/game/states/language-menu-state.hpp View File

@ -17,20 +17,19 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_LANGUAGE_MENU_HPP
#define ANTKEEPER_GAME_STATE_LANGUAGE_MENU_HPP
#ifndef ANTKEEPER_LANGUAGE_MENU_STATE_HPP
#define ANTKEEPER_LANGUAGE_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <string>
#include <vector>
namespace state {
class language_menu: public ::state::base
class language_menu_state: public game_state
{
public:
language_menu(::context& ctx);
virtual ~language_menu();
language_menu_state(::game& ctx);
virtual ~language_menu_state();
private:
void update_text_content();
@ -39,7 +38,4 @@ private:
std::size_t language_index;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_LANGUAGE_MENU_HPP
#endif // ANTKEEPER_LANGUAGE_MENU_STATE_HPP

src/game/state/main-menu.cpp → src/game/states/main-menu-state.cpp View File

@ -17,7 +17,7 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/main-menu.hpp"
#include "game/states/main-menu-state.hpp"
#include <engine/animation/animation.hpp>
#include <engine/animation/animator.hpp>
#include <engine/animation/ease.hpp>
@ -29,11 +29,11 @@
#include "game/controls.hpp"
#include "game/ecoregion.hpp"
#include "game/menu.hpp"
#include "game/state/collection-menu.hpp"
#include "game/state/extras-menu.hpp"
#include "game/state/nuptial-flight.hpp"
#include "game/state/nest-selection.hpp"
#include "game/state/options-menu.hpp"
#include "game/states/collection-menu-state.hpp"
#include "game/states/extras-menu-state.hpp"
#include "game/states/nuptial-flight-state.hpp"
#include "game/states/nest-selection-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/strings.hpp"
#include "game/world.hpp"
#include <engine/math/glsl.hpp>
@ -51,10 +51,8 @@
using namespace hash::literals;
using namespace math::glsl;
namespace state {
main_menu::main_menu(::context& ctx, bool fade_in):
::state::base(ctx)
main_menu_state::main_menu_state(::game& ctx, bool fade_in):
game_state(ctx)
{
debug::log::trace("Entering main menu state...");
@ -133,9 +131,9 @@ main_menu::main_menu(::context& ctx, bool fade_in):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::nuptial_flight(ctx));
//ctx.state_machine.emplace(new ::state::collection_menu(ctx));
//ctx.state_machine.emplace(new ::state::nest_selection(ctx));
ctx.state_machine.emplace(std::make_unique<nuptial_flight_state>(ctx));
//ctx.state_machine.emplace(std::make_unique<collection_menu_state>(ctx));
//ctx.state_machine.emplace(std::make_unique<nest_selection_state>(ctx));
}
);
};
@ -171,7 +169,7 @@ main_menu::main_menu(::context& ctx, bool fade_in):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -197,7 +195,7 @@ main_menu::main_menu(::context& ctx, bool fade_in):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::extras_menu(ctx));
ctx.state_machine.emplace(std::make_unique<extras_menu_state>(ctx));
}
);
}
@ -310,7 +308,7 @@ main_menu::main_menu(::context& ctx, bool fade_in):
debug::log::trace("Entered main menu state");
}
main_menu::~main_menu()
main_menu_state::~main_menu_state()
{
debug::log::trace("Exiting main menu state...");
@ -333,7 +331,7 @@ main_menu::~main_menu()
debug::log::trace("Exited main menu state");
}
void main_menu::fade_in_title()
void main_menu_state::fade_in_title()
{
animation_channel<float>* opacity_channel = title_fade_animation.get_channel(0);
opacity_channel->remove_keyframes();
@ -343,7 +341,7 @@ void main_menu::fade_in_title()
title_fade_animation.play();
}
void main_menu::fade_out_title()
void main_menu_state::fade_out_title()
{
animation_channel<float>* opacity_channel = title_fade_animation.get_channel(0);
opacity_channel->remove_keyframes();
@ -352,5 +350,3 @@ void main_menu::fade_out_title()
title_fade_animation.stop();
title_fade_animation.play();
}
} // namespace state

src/game/state/main-menu.hpp → src/game/states/main-menu-state.hpp View File

@ -17,23 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_MAIN_MENU_HPP
#define ANTKEEPER_GAME_STATE_MAIN_MENU_HPP
#ifndef ANTKEEPER_MAIN_MENU_STATE_HPP
#define ANTKEEPER_MAIN_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/scene/text.hpp>
#include <engine/animation/animation.hpp>
#include <engine/entity/id.hpp>
#include <engine/event/subscription.hpp>
#include <memory>
namespace state {
class main_menu: public ::state::base
class main_menu_state: public game_state
{
public:
main_menu(::context& ctx, bool fade_in);
virtual ~main_menu();
main_menu_state(::game& ctx, bool fade_in);
virtual ~main_menu_state();
private:
void fade_in_title();
@ -45,6 +44,4 @@ private:
std::shared_ptr<event::subscription> window_resized_subscription;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_MAIN_MENU_HPP
#endif // ANTKEEPER_MAIN_MENU_STATE_HPP

src/game/state/nest-selection.cpp → src/game/states/nest-selection-state.cpp View File

@ -45,8 +45,8 @@
#include "game/constraints/track-to-constraint.hpp"
#include "game/controls.hpp"
#include "game/spawn.hpp"
#include "game/state/nest-selection.hpp"
#include "game/state/pause-menu.hpp"
#include "game/states/nest-selection-state.hpp"
#include "game/states/pause-menu-state.hpp"
#include "game/systems/astronomy-system.hpp"
#include "game/systems/atmosphere-system.hpp"
#include "game/systems/camera-system.hpp"
@ -67,10 +67,9 @@
using namespace ::ant;
namespace state {
nest_selection::nest_selection(::context& ctx):
::state::base(ctx)
nest_selection_state::nest_selection_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering nest selection state...");
@ -202,12 +201,12 @@ nest_selection::nest_selection(::context& ctx):
// Queue fade in
ctx.fade_transition_color->set_value({0, 0, 0});
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, 1.0f, true, ease<float>::out_sine, true, nullptr));
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition.get(), 1.0f, true, ease<float>::out_sine, true, nullptr));
debug::log::trace("Entered nest selection state");
}
nest_selection::~nest_selection()
nest_selection_state::~nest_selection_state()
{
debug::log::trace("Exiting nest selection state...");
@ -219,7 +218,7 @@ nest_selection::~nest_selection()
debug::log::trace("Exited nest selection state");
}
void nest_selection::create_first_person_camera_rig()
void nest_selection_state::create_first_person_camera_rig()
{
// Construct first person camera rig spring rotation constraint
spring_rotation_constraint first_person_camera_rig_spring_rotation;
@ -270,7 +269,7 @@ void nest_selection::create_first_person_camera_rig()
// Construct first person camera rig camera component
camera_component first_person_camera_rig_camera;
first_person_camera_rig_camera.object = ctx.surface_camera;
first_person_camera_rig_camera.object = ctx.surface_camera.get();
// Construct first person camera rig entity
first_person_camera_rig_eid = ctx.entity_registry->create();
@ -300,7 +299,7 @@ void nest_selection::create_first_person_camera_rig()
set_first_person_camera_rig_pedestal(first_person_camera_rig_pedestal);
}
void nest_selection::destroy_first_person_camera_rig()
void nest_selection_state::destroy_first_person_camera_rig()
{
ctx.entity_registry->destroy(first_person_camera_rig_eid);
ctx.entity_registry->destroy(first_person_camera_rig_spring_translation_eid);
@ -308,7 +307,7 @@ void nest_selection::destroy_first_person_camera_rig()
ctx.entity_registry->destroy(first_person_camera_rig_fov_spring_eid);
}
void nest_selection::set_first_person_camera_rig_pedestal(float pedestal)
void nest_selection_state::set_first_person_camera_rig_pedestal(float pedestal)
{
first_person_camera_rig_pedestal = pedestal;
const float elevation = math::log_lerp(first_person_camera_rig_min_elevation, first_person_camera_rig_max_elevation, first_person_camera_rig_pedestal);
@ -333,7 +332,7 @@ void nest_selection::set_first_person_camera_rig_pedestal(float pedestal)
);
}
void nest_selection::move_first_person_camera_rig(const float2& direction, float factor)
void nest_selection_state::move_first_person_camera_rig(const float2& direction, float factor)
{
const float speed = math::log_lerp(first_person_camera_near_speed, first_person_camera_far_speed, first_person_camera_rig_pedestal) * factor;
@ -353,7 +352,7 @@ void nest_selection::move_first_person_camera_rig(const float2& direction, float
);
}
void nest_selection::satisfy_first_person_camera_rig_constraints()
void nest_selection_state::satisfy_first_person_camera_rig_constraints()
{
// Satisfy first person camera rig spring translation constraint
ctx.entity_registry->patch<spring_translation_constraint>
@ -389,7 +388,7 @@ void nest_selection::satisfy_first_person_camera_rig_constraints()
);
}
void nest_selection::enable_controls()
void nest_selection_state::enable_controls()
{
/*
// Reset mouse look
@ -714,7 +713,7 @@ void nest_selection::enable_controls()
};
// Push pause menu state
ctx.state_machine.emplace(new ::state::pause_menu(ctx));
ctx.state_machine.emplace(std::make_unique<pause_menu_state>(ctx));
}
);
@ -740,7 +739,7 @@ void nest_selection::enable_controls()
*/
}
void nest_selection::disable_controls()
void nest_selection_state::disable_controls()
{
/*
if (mouse_look)
@ -777,4 +776,3 @@ void nest_selection::disable_controls()
*/
}
} // namespace state

src/game/state/nest-selection.hpp → src/game/states/nest-selection-state.hpp View File

@ -17,20 +17,19 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_NEST_SELECTION_HPP
#define ANTKEEPER_GAME_STATE_NEST_SELECTION_HPP
#ifndef ANTKEEPER_NEST_SELECTION_STATE_HPP
#define ANTKEEPER_NEST_SELECTION_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/entity/id.hpp>
#include <engine/utility/fundamental-types.hpp>
namespace state {
class nest_selection: public ::state::base
class nest_selection_state: public game_state
{
public:
nest_selection(::context& ctx);
virtual ~nest_selection();
nest_selection_state(::game& ctx);
virtual ~nest_selection_state();
private:
void create_first_person_camera_rig();
@ -59,6 +58,4 @@ private:
bool mouse_look;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_NEST_SELECTION_HPP
#endif // ANTKEEPER_NEST_SELECTION_STATE_HPP

src/game/state/nuptial-flight.cpp → src/game/states/nuptial-flight-state.cpp View File

@ -17,9 +17,9 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/nuptial-flight.hpp"
#include "game/state/pause-menu.hpp"
#include "game/state/nest-selection.hpp"
#include "game/states/nuptial-flight-state.hpp"
#include "game/states/pause-menu-state.hpp"
#include "game/states/nest-selection-state.hpp"
#include "game/ant/swarm.hpp"
#include <engine/entity/archetype.hpp>
#include "game/systems/camera-system.hpp"
@ -68,10 +68,8 @@
using namespace hash::literals;
namespace state {
nuptial_flight::nuptial_flight(::context& ctx):
::state::base(ctx)
nuptial_flight_state::nuptial_flight_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering nuptial flight state...");
@ -174,12 +172,12 @@ nuptial_flight::nuptial_flight(::context& ctx):
// Queue fade in
ctx.fade_transition_color->set_value({0, 0, 0});
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, 1.0f, true, ease<float>::out_sine, true, nullptr));
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition.get(), 1.0f, true, ease<float>::out_sine, true, nullptr));
debug::log::trace("Entered nuptial flight state");
}
nuptial_flight::~nuptial_flight()
nuptial_flight_state::~nuptial_flight_state()
{
debug::log::trace("Exiting nuptial flight state...");
@ -200,7 +198,7 @@ nuptial_flight::~nuptial_flight()
debug::log::trace("Exited nuptial flight state");
}
void nuptial_flight::create_camera_rig()
void nuptial_flight_state::create_camera_rig()
{
// Construct camera rig focus ease to constraint
ease_to_constraint camera_rig_focus_ease_to;
@ -312,7 +310,7 @@ void nuptial_flight::create_camera_rig()
// Construct camera rig camera component
camera_component camera_rig_camera;
camera_rig_camera.object = ctx.surface_camera;
camera_rig_camera.object = ctx.surface_camera.get();
// Construct camera rig entity
camera_rig_eid = ctx.entity_registry->create();
@ -342,7 +340,7 @@ void nuptial_flight::create_camera_rig()
set_camera_rig_zoom(0.25f);
}
void nuptial_flight::destroy_camera_rig()
void nuptial_flight_state::destroy_camera_rig()
{
ctx.entity_registry->destroy(camera_rig_eid);
ctx.entity_registry->destroy(camera_rig_spring_translation_eid);
@ -356,7 +354,7 @@ void nuptial_flight::destroy_camera_rig()
ctx.entity_registry->destroy(camera_rig_fov_spring_eid);
}
void nuptial_flight::set_camera_rig_zoom(float zoom)
void nuptial_flight_state::set_camera_rig_zoom(float zoom)
{
camera_rig_zoom = zoom;
@ -381,7 +379,7 @@ void nuptial_flight::set_camera_rig_zoom(float zoom)
);
}
void nuptial_flight::satisfy_camera_rig_constraints()
void nuptial_flight_state::satisfy_camera_rig_constraints()
{
// Satisfy camera rig focus ease to constraint
ctx.entity_registry->patch<ease_to_constraint>
@ -427,7 +425,7 @@ void nuptial_flight::satisfy_camera_rig_constraints()
);
}
void nuptial_flight::setup_controls()
void nuptial_flight_state::setup_controls()
{
action_subscriptions.emplace_back
(
@ -462,7 +460,7 @@ void nuptial_flight::setup_controls()
);
}
void nuptial_flight::enable_controls()
void nuptial_flight_state::enable_controls()
{
/*
// Reset mouse look
@ -763,7 +761,7 @@ void nuptial_flight::enable_controls()
// Change to nest selection state
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::nest_selection(ctx));
ctx.state_machine.emplace(std::make_unique<nest_selection_state>(ctx));
}
);
@ -813,7 +811,7 @@ void nuptial_flight::enable_controls()
};
// Push pause menu state
ctx.state_machine.emplace(new ::state::pause_menu(ctx));
ctx.state_machine.emplace(std::make_unique<pause_menu_state>(ctx));
}
);
@ -839,7 +837,7 @@ void nuptial_flight::enable_controls()
*/
}
void nuptial_flight::disable_controls()
void nuptial_flight_state::disable_controls()
{
/*
if (mouse_look)
@ -876,7 +874,7 @@ void nuptial_flight::disable_controls()
*/
}
void nuptial_flight::select_entity(entity::id entity_id)
void nuptial_flight_state::select_entity(entity::id entity_id)
{
if (entity_id != selected_eid)
{
@ -962,7 +960,7 @@ void nuptial_flight::select_entity(entity::id entity_id)
}
}
void nuptial_flight::select_nearest_entity(const float3& direction)
void nuptial_flight_state::select_nearest_entity(const float3& direction)
{
if (!ctx.entity_registry->valid(selected_eid))
return;
@ -982,5 +980,3 @@ void nuptial_flight::select_nearest_entity(const float3& direction)
select_entity(picked_eid);
}
}
} // namespace state

src/game/state/nuptial-flight.hpp → src/game/states/nuptial-flight-state.hpp View File

@ -17,23 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_NUPTIAL_FLIGHT_HPP
#define ANTKEEPER_GAME_STATE_NUPTIAL_FLIGHT_HPP
#ifndef ANTKEEPER_NUPTIAL_FLIGHT_STATE_HPP
#define ANTKEEPER_NUPTIAL_FLIGHT_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/entity/id.hpp>
#include <engine/utility/fundamental-types.hpp>
#include <engine/event/subscription.hpp>
#include <engine/scene/text.hpp>
#include <memory>
namespace state {
class nuptial_flight: public ::state::base
class nuptial_flight_state: public game_state
{
public:
nuptial_flight(::context& ctx);
virtual ~nuptial_flight();
nuptial_flight_state(::game& ctx);
virtual ~nuptial_flight_state();
private:
void create_camera_rig();
@ -84,6 +83,4 @@ private:
std::vector<std::shared_ptr<::event::subscription>> action_subscriptions;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_NUPTIAL_FLIGHT_HPP
#endif // ANTKEEPER_NUPTIAL_FLIGHT_STATE_HPP

src/game/state/options-menu.cpp → src/game/states/options-menu-state.cpp View File

@ -17,13 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/options-menu.hpp"
#include "game/state/main-menu.hpp"
#include "game/state/controls-menu.hpp"
#include "game/state/graphics-menu.hpp"
#include "game/state/sound-menu.hpp"
#include "game/state/language-menu.hpp"
#include "game/state/pause-menu.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/states/main-menu-state.hpp"
#include "game/states/controls-menu-state.hpp"
#include "game/states/graphics-menu-state.hpp"
#include "game/states/sound-menu-state.hpp"
#include "game/states/language-menu-state.hpp"
#include "game/states/pause-menu-state.hpp"
#include "game/menu.hpp"
#include "game/controls.hpp"
#include <engine/animation/ease.hpp>
@ -36,10 +36,8 @@
using namespace hash::literals;
namespace state {
options_menu::options_menu(::context& ctx):
::state::base(ctx)
options_menu_state::options_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering options menu state...");
@ -92,7 +90,7 @@ options_menu::options_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::controls_menu(ctx));
ctx.state_machine.emplace(std::make_unique<controls_menu_state>(ctx));
}
);
}
@ -115,7 +113,7 @@ options_menu::options_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::graphics_menu(ctx));
ctx.state_machine.emplace(std::make_unique<graphics_menu_state>(ctx));
}
);
}
@ -138,7 +136,7 @@ options_menu::options_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::sound_menu(ctx));
ctx.state_machine.emplace(std::make_unique<sound_menu_state>(ctx));
}
);
}
@ -161,7 +159,7 @@ options_menu::options_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::language_menu(ctx));
ctx.state_machine.emplace(std::make_unique<language_menu_state>(ctx));
}
);
}
@ -187,9 +185,9 @@ options_menu::options_menu(::context& ctx):
{
ctx.state_machine.pop();
if (ctx.resume_callback)
ctx.state_machine.emplace(new ::state::pause_menu(ctx));
ctx.state_machine.emplace(std::make_unique<pause_menu_state>(ctx));
else
ctx.state_machine.emplace(new ::state::main_menu(ctx, false));
ctx.state_machine.emplace(std::make_unique<main_menu_state>(ctx, false));
}
);
}
@ -221,7 +219,7 @@ options_menu::options_menu(::context& ctx):
debug::log::trace("Entered options menu state");
}
options_menu::~options_menu()
options_menu_state::~options_menu_state()
{
debug::log::trace("Exiting options menu state...");
@ -234,5 +232,3 @@ options_menu::~options_menu()
debug::log::trace("Exited options menu state");
}
} // namespace state

+ 33
- 0
src/game/states/options-menu-state.hpp View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_OPTIONS_MENU_STATE_HPP
#define ANTKEEPER_OPTIONS_MENU_STATE_HPP
#include "game/states/game-state.hpp"
class options_menu_state: public game_state
{
public:
options_menu_state(::game& ctx);
virtual ~options_menu_state();
};
#endif // ANTKEEPER_OPTIONS_MENU_STATE_HPP

src/game/state/pause-menu.cpp → src/game/states/pause-menu-state.cpp View File

@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/pause-menu.hpp"
#include "game/state/main-menu.hpp"
#include "game/state/options-menu.hpp"
#include "game/state/nuptial-flight.hpp"
#include "game/states/pause-menu-state.hpp"
#include "game/states/main-menu-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/states/nuptial-flight-state.hpp"
#include "game/menu.hpp"
#include "game/controls.hpp"
#include <engine/animation/ease.hpp>
@ -35,10 +35,8 @@
using namespace hash::literals;
namespace state {
pause_menu::pause_menu(::context& ctx):
::state::base(ctx)
pause_menu_state::pause_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering pause menu state...");
@ -115,7 +113,7 @@ pause_menu::pause_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -142,7 +140,7 @@ pause_menu::pause_menu(::context& ctx):
ctx.menu_bg_billboard->set_active(false);
ctx.state_machine.pop();
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::main_menu(ctx, true));
ctx.state_machine.emplace(std::make_unique<main_menu_state>(ctx, true));
}
);
};
@ -212,7 +210,7 @@ pause_menu::pause_menu(::context& ctx):
debug::log::trace("Entered pause menu state");
}
pause_menu::~pause_menu()
pause_menu_state::~pause_menu_state()
{
debug::log::trace("Exiting pause menu state...");
@ -225,5 +223,3 @@ pause_menu::~pause_menu()
debug::log::trace("Exited pause menu state");
}
} // namespace state

src/game/state/base.cpp → src/game/states/pause-menu-state.hpp View File

@ -17,15 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/base.hpp"
#ifndef ANTKEEPER_PAUSE_MENU_STATE_HPP
#define ANTKEEPER_PAUSE_MENU_STATE_HPP
namespace state {
#include "game/states/game-state.hpp"
base::base(::context& ctx):
ctx(ctx)
{}
base::~base()
{}
class pause_menu_state: public game_state
{
public:
pause_menu_state(::game& ctx);
virtual ~pause_menu_state();
};
} // namespace state
#endif // ANTKEEPER_PAUSE_MENU_STATE_HPP

src/game/state/sound-menu.cpp → src/game/states/sound-menu-state.cpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/sound-menu.hpp"
#include "game/state/options-menu.hpp"
#include "game/states/sound-menu-state.hpp"
#include "game/states/options-menu-state.hpp"
#include "game/controls.hpp"
#include <engine/scene/text.hpp>
#include <engine/debug/log.hpp>
@ -28,10 +28,9 @@
using namespace hash::literals;
namespace state {
sound_menu::sound_menu(::context& ctx):
::state::base(ctx)
sound_menu_state::sound_menu_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering sound menu state...");
@ -180,7 +179,7 @@ sound_menu::sound_menu(::context& ctx):
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::options_menu(ctx));
ctx.state_machine.emplace(std::make_unique<options_menu_state>(ctx));
}
);
}
@ -226,7 +225,7 @@ sound_menu::sound_menu(::context& ctx):
debug::log::trace("Entered sound menu state");
}
sound_menu::~sound_menu()
sound_menu_state::~sound_menu_state()
{
debug::log::trace("Exiting sound menu state...");
@ -240,7 +239,7 @@ sound_menu::~sound_menu()
debug::log::trace("Exited sound menu state");
}
void sound_menu::update_value_text_content()
void sound_menu_state::update_value_text_content()
{
const std::string string_on = get_string(ctx, "on"_fnv1a32);
const std::string string_off = get_string(ctx, "off"_fnv1a32);
@ -252,5 +251,3 @@ void sound_menu::update_value_text_content()
std::get<1>(ctx.menu_item_texts[4])->set_content((ctx.captions) ? string_on : string_off);
std::get<1>(ctx.menu_item_texts[5])->set_content(std::to_string(static_cast<int>(std::round(ctx.captions_size * 100.0f))) + "%");
}
} // namespace state

src/game/state/graphics-menu.hpp → src/game/states/sound-menu-state.hpp View File

@ -17,23 +17,20 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_GRAPHICS_MENU_HPP
#define ANTKEEPER_GAME_STATE_GRAPHICS_MENU_HPP
#ifndef ANTKEEPER_SOUND_MENU_STATE_HPP
#define ANTKEEPER_SOUND_MENU_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
namespace state {
class graphics_menu: public ::state::base
class sound_menu_state: public game_state
{
public:
graphics_menu(::context& ctx);
virtual ~graphics_menu();
sound_menu_state(::game& ctx);
virtual ~sound_menu_state();
private:
void update_value_text_content();
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_GRAPHICS_MENU_HPP
#endif // ANTKEEPER_SOUND_MENU_STATE_HPP

src/game/state/splash.cpp → src/game/states/splash-state.cpp View File

@ -1,221 +1,217 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/state/splash.hpp"
#include <engine/animation/animation.hpp>
#include <engine/animation/animator.hpp>
#include <engine/animation/ease.hpp>
#include <engine/animation/screen-transition.hpp>
#include <engine/debug/log.hpp>
#include "game/context.hpp"
#include "game/state/main-menu.hpp"
#include <engine/math/linear-algebra.hpp>
#include <engine/render/material-flags.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/resources/resource-manager.hpp>
#include <engine/math/glsl.hpp>
using namespace math::glsl;
namespace state {
splash::splash(::context& ctx):
::state::base(ctx)
{
debug::log::trace("Entering splash state...");
const vec2 viewport_size = vec2(ctx.window->get_viewport_size());
const vec2 viewport_center = viewport_size * 0.5f;
// Enable color buffer clearing in UI pass
ctx.ui_clear_pass->set_cleared_buffers(true, true, false);
// Load splash texture
const gl::texture_2d* splash_texture = ctx.resource_manager->load<gl::texture_2d>("splash.tex");
// Get splash texture dimensions
auto splash_dimensions = splash_texture->get_dimensions();
// Construct splash billboard material
splash_billboard_material.set_blend_mode(render::blend_mode::translucent);
splash_billboard_material.set_shader_program(ctx.resource_manager->load<gl::shader_program>("ui-element-textured.glsl"));
splash_billboard_material.add_property<const gl::texture_2d*>("background")->set_value(splash_texture);
render::material_property<float4>* splash_tint = splash_billboard_material.add_property<float4>("tint");
splash_tint->set_value(float4{1, 1, 1, 0});
splash_billboard_material.update_tweens();
// Construct splash billboard
splash_billboard.set_material(&splash_billboard_material);
splash_billboard.set_scale({(float)std::get<0>(splash_dimensions) * 0.5f, (float)std::get<1>(splash_dimensions) * 0.5f, 1.0f});
splash_billboard.set_translation({std::round(viewport_center.x()), std::round(viewport_center.y()), 0.0f});
splash_billboard.update_tweens();
// Add splash billboard to UI scene
ctx.ui_scene->add_object(&splash_billboard);
// Load animation timing configuration
const double splash_fade_in_duration = 0.5;
const double splash_duration = 2.0;
const double splash_fade_out_duration = 0.5;
// Construct splash fade in animation
splash_fade_in_animation.set_interpolator(ease<float>::out_cubic);
animation_channel<float>* splash_fade_in_opacity_channel = splash_fade_in_animation.add_channel(0);
splash_fade_in_opacity_channel->insert_keyframe({0.0, 0.0f});
splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration, 1.0f});
splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration + splash_duration, 1.0f});
// Build splash fade out animation
splash_fade_out_animation.set_interpolator(ease<float>::out_cubic);
animation_channel<float>* splash_fade_out_opacity_channel = splash_fade_out_animation.add_channel(0);
splash_fade_out_opacity_channel->insert_keyframe({0.0, 1.0f});
splash_fade_out_opacity_channel->insert_keyframe({splash_fade_out_duration, 0.0f});
// Setup animation frame callbacks
auto set_splash_opacity = [splash_tint](int channel, const float& opacity)
{
splash_tint->set_value(float4{1, 1, 1, opacity});
};
splash_fade_in_animation.set_frame_callback(set_splash_opacity);
splash_fade_out_animation.set_frame_callback(set_splash_opacity);
// Trigger splash fade out animation when splash fade in animation ends
splash_fade_in_animation.set_end_callback
(
[this]()
{
this->splash_fade_out_animation.play();
}
);
// Trigger a state change when the splash fade out animation ends
splash_fade_out_animation.set_end_callback
(
[&ctx]()
{
// Queue change to main menu state
ctx.function_queue.push
(
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::main_menu(ctx, true));
}
);
}
);
// Add splash fade animations to animator
ctx.animator->add_animation(&splash_fade_in_animation);
ctx.animator->add_animation(&splash_fade_out_animation);
// Start splash fade in animation
splash_fade_in_animation.play();
// Setup window resized callback
window_resized_subscription = ctx.window->get_resized_channel().subscribe
(
[&](const auto& event)
{
const vec2 viewport_size = vec2(event.window->get_viewport_size());
const vec2 viewport_center = viewport_size * 0.5f;
splash_billboard.set_translation({std::round(viewport_center.x()), std::round(viewport_center.y()), 0.0f});
splash_billboard.update_tweens();
}
);
// Construct splash skip function
auto skip = [&](const auto& event)
{
ctx.function_queue.emplace
(
[&]()
{
// Black out screen
ctx.window->get_rasterizer()->set_clear_color(0.0f, 0.0f, 0.0f, 1.0f);
ctx.window->get_rasterizer()->clear_framebuffer(true, false, false);
ctx.window->swap_buffers();
// Change to main menu state
ctx.state_machine.pop();
ctx.state_machine.emplace(new ::state::main_menu(ctx, true));
}
);
};
// Set up splash skippers
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_gamepad_button_mapped_channel().subscribe
(
skip
)
);
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_key_mapped_channel().subscribe
(
skip
)
);
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_mouse_button_mapped_channel().subscribe
(
skip
)
);
// Enable splash skippers next frame
ctx.function_queue.push
(
[&]()
{
ctx.input_mapper.connect(ctx.input_manager->get_event_queue());
}
);
debug::log::trace("Entered splash state");
}
splash::~splash()
{
debug::log::trace("Exiting splash state...");
// Disable splash skippers
ctx.input_mapper.disconnect();
input_mapped_subscriptions.clear();
// Remove splash fade animations from animator
ctx.animator->remove_animation(&splash_fade_in_animation);
ctx.animator->remove_animation(&splash_fade_out_animation);
// Remove splash billboard from UI scene
ctx.ui_scene->remove_object(&splash_billboard);
// Unload splash texture
ctx.resource_manager->unload("splash.tex");
// Disable color buffer clearing in UI pass
ctx.ui_clear_pass->set_cleared_buffers(false, true, false);
debug::log::trace("Exited splash state");
}
} // namespace state
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "game/states/splash-state.hpp"
#include "game/game.hpp"
#include "game/states/main-menu-state.hpp"
#include <engine/animation/animation.hpp>
#include <engine/animation/animator.hpp>
#include <engine/animation/ease.hpp>
#include <engine/animation/screen-transition.hpp>
#include <engine/debug/log.hpp>
#include <engine/math/glsl.hpp>
#include <engine/math/linear-algebra.hpp>
#include <engine/render/material-flags.hpp>
#include <engine/render/passes/clear-pass.hpp>
#include <engine/resources/resource-manager.hpp>
using namespace math::glsl;
splash_state::splash_state(::game& ctx):
game_state(ctx)
{
debug::log::trace("Entering splash state...");
const vec2 viewport_size = vec2(ctx.window->get_viewport_size());
const vec2 viewport_center = viewport_size * 0.5f;
// Enable color buffer clearing in UI pass
ctx.ui_clear_pass->set_cleared_buffers(true, true, false);
// Load splash texture
const gl::texture_2d* splash_texture = ctx.resource_manager->load<gl::texture_2d>("splash.tex");
// Get splash texture dimensions
auto splash_dimensions = splash_texture->get_dimensions();
// Construct splash billboard material
splash_billboard_material.set_blend_mode(render::blend_mode::translucent);
splash_billboard_material.set_shader_program(ctx.resource_manager->load<gl::shader_program>("ui-element-textured.glsl"));
splash_billboard_material.add_property<const gl::texture_2d*>("background")->set_value(splash_texture);
render::material_property<float4>* splash_tint = splash_billboard_material.add_property<float4>("tint");
splash_tint->set_value(float4{1, 1, 1, 0});
splash_billboard_material.update_tweens();
// Construct splash billboard
splash_billboard.set_material(&splash_billboard_material);
splash_billboard.set_scale({(float)std::get<0>(splash_dimensions) * 0.5f, (float)std::get<1>(splash_dimensions) * 0.5f, 1.0f});
splash_billboard.set_translation({std::round(viewport_center.x()), std::round(viewport_center.y()), 0.0f});
splash_billboard.update_tweens();
// Add splash billboard to UI scene
ctx.ui_scene->add_object(&splash_billboard);
// Load animation timing configuration
const double splash_fade_in_duration = 0.5;
const double splash_duration = 2.0;
const double splash_fade_out_duration = 0.5;
// Construct splash fade in animation
splash_fade_in_animation.set_interpolator(ease<float>::out_cubic);
animation_channel<float>* splash_fade_in_opacity_channel = splash_fade_in_animation.add_channel(0);
splash_fade_in_opacity_channel->insert_keyframe({0.0, 0.0f});
splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration, 1.0f});
splash_fade_in_opacity_channel->insert_keyframe({splash_fade_in_duration + splash_duration, 1.0f});
// Build splash fade out animation
splash_fade_out_animation.set_interpolator(ease<float>::out_cubic);
animation_channel<float>* splash_fade_out_opacity_channel = splash_fade_out_animation.add_channel(0);
splash_fade_out_opacity_channel->insert_keyframe({0.0, 1.0f});
splash_fade_out_opacity_channel->insert_keyframe({splash_fade_out_duration, 0.0f});
// Setup animation frame callbacks
auto set_splash_opacity = [splash_tint](int channel, const float& opacity)
{
splash_tint->set_value(float4{1, 1, 1, opacity});
};
splash_fade_in_animation.set_frame_callback(set_splash_opacity);
splash_fade_out_animation.set_frame_callback(set_splash_opacity);
// Trigger splash fade out animation when splash fade in animation ends
splash_fade_in_animation.set_end_callback
(
[this]()
{
this->splash_fade_out_animation.play();
}
);
// Trigger a state change when the splash fade out animation ends
splash_fade_out_animation.set_end_callback
(
[&ctx]()
{
// Queue change to main menu state
ctx.function_queue.push
(
[&ctx]()
{
ctx.state_machine.pop();
ctx.state_machine.emplace(std::make_unique<main_menu_state>(ctx, true));
}
);
}
);
// Add splash fade animations to animator
ctx.animator->add_animation(&splash_fade_in_animation);
ctx.animator->add_animation(&splash_fade_out_animation);
// Start splash fade in animation
splash_fade_in_animation.play();
// Setup window resized callback
window_resized_subscription = ctx.window->get_resized_channel().subscribe
(
[&](const auto& event)
{
const vec2 viewport_size = vec2(event.window->get_viewport_size());
const vec2 viewport_center = viewport_size * 0.5f;
splash_billboard.set_translation({std::round(viewport_center.x()), std::round(viewport_center.y()), 0.0f});
splash_billboard.update_tweens();
}
);
// Construct splash skip function
auto skip = [&](const auto& event)
{
ctx.function_queue.emplace
(
[&]()
{
// Black out screen
ctx.window->get_rasterizer()->set_clear_color(0.0f, 0.0f, 0.0f, 1.0f);
ctx.window->get_rasterizer()->clear_framebuffer(true, false, false);
ctx.window->swap_buffers();
// Change to main menu state
ctx.state_machine.pop();
ctx.state_machine.emplace(std::make_unique<main_menu_state>(ctx, true));
}
);
};
// Set up splash skippers
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_gamepad_button_mapped_channel().subscribe
(
skip
)
);
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_key_mapped_channel().subscribe
(
skip
)
);
input_mapped_subscriptions.emplace_back
(
ctx.input_mapper.get_mouse_button_mapped_channel().subscribe
(
skip
)
);
// Enable splash skippers next frame
ctx.function_queue.push
(
[&]()
{
ctx.input_mapper.connect(ctx.input_manager->get_event_queue());
}
);
debug::log::trace("Entered splash state");
}
splash_state::~splash_state()
{
debug::log::trace("Exiting splash state...");
// Disable splash skippers
ctx.input_mapper.disconnect();
input_mapped_subscriptions.clear();
// Remove splash fade animations from animator
ctx.animator->remove_animation(&splash_fade_in_animation);
ctx.animator->remove_animation(&splash_fade_out_animation);
// Remove splash billboard from UI scene
ctx.ui_scene->remove_object(&splash_billboard);
// Unload splash texture
ctx.resource_manager->unload("splash.tex");
// Disable color buffer clearing in UI pass
ctx.ui_clear_pass->set_cleared_buffers(false, true, false);
debug::log::trace("Exited splash state");
}

src/game/state/splash.hpp → src/game/states/splash-state.hpp View File

@ -17,23 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GAME_STATE_SPLASH_HPP
#define ANTKEEPER_GAME_STATE_SPLASH_HPP
#ifndef ANTKEEPER_SPLASH_STATE_HPP
#define ANTKEEPER_SPLASH_STATE_HPP
#include "game/state/base.hpp"
#include "game/states/game-state.hpp"
#include <engine/render/material.hpp>
#include <engine/scene/billboard.hpp>
#include <engine/animation/animation.hpp>
#include <engine/event/subscription.hpp>
#include <vector>
namespace state {
class splash: public ::state::base
class splash_state: public game_state
{
public:
splash(::context& ctx);
virtual ~splash();
splash_state(::game& ctx);
virtual ~splash_state();
private:
render::material splash_billboard_material;
@ -44,6 +43,4 @@ private:
std::shared_ptr<event::subscription> window_resized_subscription;
};
} // namespace state
#endif // ANTKEEPER_GAME_STATE_SPLASH_HPP
#endif // ANTKEEPER_SPLASH_STATE_HPP

+ 1
- 1
src/game/strings.cpp View File

@ -21,7 +21,7 @@
#include <format>
std::string get_string(const ::context& ctx, std::uint32_t key)
std::string get_string(const ::game& ctx, std::uint32_t key)
{
if (auto i = ctx.string_map->find(key); i != ctx.string_map->end())
{

+ 2
- 2
src/game/strings.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_STRINGS_HPP
#define ANTKEEPER_GAME_STRINGS_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include <cstdint>
#include <string>
@ -34,7 +34,7 @@
*
* @return `true` if the string was found, `false` otherwise.
*/
[[nodiscard]] std::string get_string(const ::context& ctx, std::uint32_t key);
[[nodiscard]] std::string get_string(const ::game& ctx, std::uint32_t key);
#endif // ANTKEEPER_GAME_STRINGS_HPP

+ 0
- 1
src/game/systems/render-system.cpp View File

@ -289,4 +289,3 @@ void render_system::on_light_destroy(entity::registry& registry, entity::id enti
delete light;
}
}

+ 19
- 19
src/game/world.cpp View File

@ -73,24 +73,24 @@
namespace world {
/// Loads an ephemeris.
static void load_ephemeris(::context& ctx);
static void load_ephemeris(::game& ctx);
/// Creates the fixed stars.
static void create_stars(::context& ctx);
static void create_stars(::game& ctx);
/// Creates the Sun.
static void create_sun(::context& ctx);
static void create_sun(::game& ctx);
/// Creates the Earth-Moon system.
static void create_earth_moon_system(::context& ctx);
static void create_earth_moon_system(::game& ctx);
/// Creates the Earth.
static void create_earth(::context& ctx);
static void create_earth(::game& ctx);
/// Creates the Moon.
static void create_moon(::context& ctx);
static void create_moon(::game& ctx);
void cosmogenesis(::context& ctx)
void cosmogenesis(::game& ctx)
{
debug::log::trace("Generating cosmos...");
@ -102,7 +102,7 @@ void cosmogenesis(::context& ctx)
debug::log::trace("Generated cosmos");
}
void create_observer(::context& ctx)
void create_observer(::game& ctx)
{
debug::log::trace("Creating observer...");
@ -138,7 +138,7 @@ void create_observer(::context& ctx)
debug::log::trace("Created observer");
}
void set_location(::context& ctx, double elevation, double latitude, double longitude)
void set_location(::game& ctx, double elevation, double latitude, double longitude)
{
if (auto it = ctx.entities.find("observer"); it != ctx.entities.end())
{
@ -161,7 +161,7 @@ void set_location(::context& ctx, double elevation, double latitude, double long
}
}
void set_time(::context& ctx, double t)
void set_time(::game& ctx, double t)
{
try
{
@ -176,7 +176,7 @@ void set_time(::context& ctx, double t)
}
}
void set_time(::context& ctx, int year, int month, int day, int hour, int minute, double second)
void set_time(::game& ctx, int year, int month, int day, int hour, int minute, double second)
{
double longitude = 0.0;
@ -201,7 +201,7 @@ void set_time(::context& ctx, int year, int month, int day, int hour, int minute
set_time(ctx, t);
}
void set_time_scale(::context& ctx, double scale)
void set_time_scale(::game& ctx, double scale)
{
// Convert time scale from seconds to days
const double astronomical_scale = scale / physics::time::seconds_per_day<double>;
@ -210,12 +210,12 @@ void set_time_scale(::context& ctx, double scale)
ctx.astronomy_system->set_time_scale(astronomical_scale);
}
void load_ephemeris(::context& ctx)
void load_ephemeris(::game& ctx)
{
ctx.orbit_system->set_ephemeris(ctx.resource_manager->load<physics::orbit::ephemeris<double>>("de421.eph"));
}
void create_stars(::context& ctx)
void create_stars(::game& ctx)
{
debug::log::trace("Generating fixed stars...");
@ -352,7 +352,7 @@ void create_stars(::context& ctx)
debug::log::trace("Generated fixed stars");
}
void create_sun(::context& ctx)
void create_sun(::game& ctx)
{
debug::log::trace("Generating Sun...");
@ -398,7 +398,7 @@ void create_sun(::context& ctx)
debug::log::trace("Generated Sun");
}
void create_earth_moon_system(::context& ctx)
void create_earth_moon_system(::game& ctx)
{
debug::log::trace("Generating Earth-Moon system...");
@ -418,7 +418,7 @@ void create_earth_moon_system(::context& ctx)
debug::log::trace("Generated Earth-Moon system");
}
void create_earth(::context& ctx)
void create_earth(::game& ctx)
{
debug::log::trace("Generating Earth...");
@ -435,7 +435,7 @@ void create_earth(::context& ctx)
debug::log::trace("Generated Earth");
}
void create_moon(::context& ctx)
void create_moon(::game& ctx)
{
debug::log::trace("Generating Moon...");
@ -466,7 +466,7 @@ void create_moon(::context& ctx)
debug::log::trace("Generated Moon");
}
void enter_ecoregion(::context& ctx, const ecoregion& ecoregion)
void enter_ecoregion(::game& ctx, const ecoregion& ecoregion)
{
/*
image img;

+ 8
- 8
src/game/world.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_WORLD_HPP
#define ANTKEEPER_GAME_WORLD_HPP
#include "game/context.hpp"
#include "game/game.hpp"
#include "game/ecoregion.hpp"
@ -28,10 +28,10 @@
namespace world {
/// Creates the cosmos.
void cosmogenesis(::context& ctx);
void cosmogenesis(::game& ctx);
/// Creates the observer.
void create_observer(::context& ctx);
void create_observer(::game& ctx);
/**
* Sets the location of the observer.
@ -41,7 +41,7 @@ void create_observer(::context& ctx);
* @param latitude Latitude, in radians.
* @param longitude Longitude, in radians.
*/
void set_location(::context& ctx, double elevation, double latitude, double longitude);
void set_location(::game& ctx, double elevation, double latitude, double longitude);
/**
* Sets the current time.
@ -49,7 +49,7 @@ void set_location(::context& ctx, double elevation, double latitude, double long
* @param ctx Game context.
* @param t UT1 time, in days.
*/
void set_time(::context& ctx, double t);
void set_time(::game& ctx, double t);
/**
* Sets the current time.
@ -62,7 +62,7 @@ void set_time(::context& ctx, double t);
* @param minute Minute number on `[0, 59]`.
* @param second Fractional second on `[0.0, 60.0)`.
*/
void set_time(::context& ctx, int year, int month, int day, int hour, int minute, double second);
void set_time(::game& ctx, int year, int month, int day, int hour, int minute, double second);
/**
* Sets rate at which time passes.
@ -70,7 +70,7 @@ void set_time(::context& ctx, int year, int month, int day, int hour, int minute
* @param ctx Game context.
* @param scale Time scale.
*/
void set_time_scale(::context& ctx, double scale);
void set_time_scale(::game& ctx, double scale);
/**
* Enters a ecoregion.
@ -78,7 +78,7 @@ void set_time_scale(::context& ctx, double scale);
* @param ctx Game context.
* @param ecoregion Ecoregion to enter.
*/
void enter_ecoregion(::context& ctx, const ecoregion& ecoregion);
void enter_ecoregion(::game& ctx, const ecoregion& ecoregion);
} // namespace menu

Loading…
Cancel
Save