File mode progress.

This commit is contained in:
J-D-K
2025-09-03 15:54:54 -04:00
parent 75303dcebb
commit a072c28dfb
82 changed files with 1489 additions and 372 deletions

View File

@@ -43,14 +43,17 @@ namespace ui
/// @param hasFocus This is ignored.
void render(sdl::SharedTexture &target, bool hasFocus) override;
/// @brief Sets the X and coords for the dialog box.
void set_xy(int x, int y);
/// @brief Sets the X render coord.
void set_x(int x);
/// @brief Sets the width and height of the dialog.
void set_width_height(int width, int height);
/// @brief Sets the X render coord.
void set_y(int y);
/// @brief Pass with the set functions to not change.
static inline constexpr int NO_SET = -1;
/// @brief Sets the width.
void set_width(int width);
/// @brief Sets the height.
void set_height(int height);
private:
/// @brief X render coord.

61
include/ui/Frame.hpp Normal file
View File

@@ -0,0 +1,61 @@
#pragma once
#include "sdl.hpp"
#include "ui/Element.hpp"
#include <memory>
namespace ui
{
class Frame final : public ui::Element
{
public:
/// @brief Constructs a new frame.
Frame(int x, int y, int width, int height);
/// @brief Doesn't need to do anything because modern C++.
~Frame() {};
/// @brief Inline function to make constructing nicer.
static inline std::shared_ptr<ui::Frame> create(int x, int y, int width, int height)
{
return std::make_shared<ui::Frame>(x, y, width, height);
}
/// @brief Doesn't need to do anything for this.
void update(bool hasFocus) override {};
/// @brief Renders the frame to the target passed.
void render(sdl::SharedTexture &target, bool hasFocus) override;
/// @brief Sets the X coord.
void set_x(int x);
/// @brief Sets the Y coord.
void set_y(int y);
/// @brief Sets the width of the frame.
void set_width(int width);
/// @brief Sets the height of the frame.
void set_height(int height);
private:
/// @brief X rendering coord.
int m_x{};
/// @brief Y rendering coord.
int m_y{};
/// @brief Rendering width.
int m_width{};
/// @brief Rendering height.
int m_height{};
/// @brief This texture is shared by all instances.
static inline sdl::SharedTexture sm_frameCorners{};
/// @brief Ensures the texture is loading if it hasn't been.
void initialize_static_members();
};
}

View File

@@ -61,6 +61,15 @@ namespace ui
/// @param width New width of the menu in pixels.
void set_width(int width);
/// @brief Updates the X render coordinate.
void set_x(int x);
/// @brief Updates the Y render coordinate.
void set_y(int y);
/// @brief Returns if the menu has no options.
bool is_empty() const;
/// @brief Resets the menu and returns it to an empty, default state.
void reset();

View File

@@ -35,6 +35,9 @@ namespace ui
/// @param hasFocus Whether or not the calling state has focus.
void update(bool hasFocus) override;
/// @brief Sub update routine. Allows the panel to hide and unhide itself even when not in focus.
void sub_update();
/// @brief Runs the render routine.
/// @param target Target to render to.
/// @param hasFocus Whether or the the calling state has focus.
@@ -49,6 +52,12 @@ namespace ui
/// @brief Closes the panel.
void close();
/// @brief Hides the panel temporarily.
void hide();
/// @brief Unhides the panel.
void unhide();
/// @brief Returns if the panel is fully open.
/// @return If the panel is fully open.
bool is_open() const;
@@ -57,6 +66,9 @@ namespace ui
/// @return If the panel is fully closed.
bool is_closed();
/// @brief Returns whether or not the panel is hidden.
bool is_hidden() const;
/// @brief Pushes a new element to the element vector.
/// @param newElement New element to push.
void push_new_element(std::shared_ptr<ui::Element> newElement);
@@ -75,6 +87,9 @@ namespace ui
/// @brief Whether or not to close panel.
bool m_closePanel{};
/// @brief Whether or not to hide the panel.
bool m_hidePanel{};
/// @brief Current X coordinate to render to. Panels are always 720 pixels in height so no Y is required.
double m_x{};
@@ -93,10 +108,16 @@ namespace ui
/// @brief Vector of elements.
std::vector<std::shared_ptr<ui::Element>> m_elements{};
/// @brief Handles sliding out logic.
void slide_out();
/// @brief Slides the panel out from the left side.
void slide_out_left();
/// @brief Slides the panel out from the right side.
void slide_out_right();
int get_absolute_x_distance();
/// @brief Contains the logic for hiding/closing the panel.
void close_hide_panel();
};
} // namespace ui

View File

@@ -3,6 +3,7 @@
#include "ui/ColorMod.hpp"
#include "ui/DialogBox.hpp"
#include "ui/Element.hpp"
#include "ui/Frame.hpp"
#include "ui/IconMenu.hpp"
#include "ui/Menu.hpp"
#include "ui/PopMessageManager.hpp"