This repository has been archived on 2026-11-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-11-05 02:19:09 +01:00

96 lines
1.9 KiB
C++

#pragma once
namespace window
{
namespace fl
{
constexpr char invalid = 1 << 0;
constexpr char none = 1 << 1;
constexpr char draggable = 1 << 3;
constexpr char dragging = 1 << 4;
}
class c_base
{
public:
void declare(const math::position_t<int>& pos, const math::dimension_t<int>& dim)
{
m_position = pos;
m_dimension = dim;
}
virtual void paint() { __noop(); };
auto& _position() { return m_position; }
auto& _dimension() { return m_dimension; }
const auto has_flag(int f) noexcept { return (m_flags & f); }
auto set_flag(int f, bool s) noexcept
{
if (s == true)
m_flags |= f;
else
m_flags &= ~f;
}
protected:
int32_t m_flags;
math::position_t<int> m_position;
math::dimension_t<int> m_dimension;
private:
};
class c_manager
{
public:
template <typename _t>
[[nodiscard]] bool in_range(const math::position_t<int> cursor_position,
const std::pair<math::position_t<_t>, math::dimension_t<_t>> target_position) const
{
const auto x0 = static_cast<int>(target_position.first.x), y0 = static_cast<int>(target_position.first.y);
const auto x1 = x0 + static_cast<int>(target_position.second.w), y1 = y0 + static_cast<int>(target_position
.second.h);
if (cursor_position.x < x0 || cursor_position.x > x1)
{
return false;
}
if (cursor_position.y < y0 || cursor_position.y > y1)
{
return false;
}
return true;
}
void paint();
template < typename T >
void add(const math::position_t<int>& pos, const math::dimension_t<int>& dim)
{
T* wnd = new T();
if (wnd == nullptr)
{
log_info_("failed to allocate/construct a window.");
return;
}
wnd->declare(pos, dim);
m_list.insert(wnd);
}
private:
stl::c_linked_list<c_base*> m_list;
};
}
#include "ui.h"
#include "menu.h"
#include "info_panel.h"
#include "radar.h"
#include "spectator_list.h"