Skip to content

Commit

Permalink
UI Separate Line, Todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuria-Shikibe committed Jun 4, 2024
1 parent 66ba1cf commit d4ae57a
Show file tree
Hide file tree
Showing 25 changed files with 463 additions and 218 deletions.
78 changes: 78 additions & 0 deletions doc-export/TodoList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!-- TOC -->
* [Core](#core)
* [Audio Engine Transplant](#audio-engine-transplant)
* [Graphic API Transplant](#graphic-api-transplant)
* [Clean up to MainLoopManager](#clean-up-to-mainloopmanager)
* [Async Load Refactor](#async-load-refactor)
* [Async Assets Load](#async-assets-load)
* [Font Pack](#font-pack)
* [Texture Pack](#texture-pack)
* [Misc Task Manager](#misc-task-manager)
* [UI](#ui)
* [Elements](#elements)
* [Node Graph Editor](#node-graph-editor)
* [Chamber Grid Editor](#chamber-grid-editor)
* [Hitbox Editor](#hitbox-editor)
* [Game](#game)
* [Async Manager (Maybe Basic Consumer Mode Temp)](#async-manager-maybe-basic-consumer-mode-temp)
* [Render Pipe](#render-pipe)
* [Light Source](#light-source)
* [Normal Texture](#normal-texture)
* [Fx](#fx)
* [Transparent Draw](#transparent-draw)
* [Entity](#entity)
* [SpaceCraft Chamber Grid System](#spacecraft-chamber-grid-system)
* [Chamber Grid System](#chamber-grid-system)
* [Misc](#misc)
<!-- TOC -->

# Core

## Audio Engine Transplant

## Graphic API Transplant

## Clean up to MainLoopManager

## Async Load Refactor
## Async Assets Load
* support hot reload

### Font Pack
* Using shared texture packer

### Texture Pack
* support async bitmap load
* support AST dependency load

### Misc Task Manager
* Support staged task manage
> ig: Misc Init Load ...<tasks>... texture pack ...<tasks>... Misc End Load
# UI
## Elements
### Node Graph Editor
### Chamber Grid Editor
### Hitbox Editor

# Game
## Async Manager (Maybe Basic Consumer Mode Temp)

## Render Pipe
### Light Source
### Normal Texture
### Fx
### Transparent Draw

## Entity
### SpaceCraft Chamber Grid System
* SpaceCraft Customization Support
### Chamber Grid System
* Turret Customization Support

# Misc
* Remove Unnecessary Hook Call
* TextureNineRegion Scaled Draw
* Namespace & Module Rename
* Reflection Cleanup
* Json Optimization
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ int main(const int argc, char* argv[]){
// std::println("{}", GL::getDrawCallCount());
// std::cout.flush();
// });
Core::loopManager->updateTaskEnd();

Core::renderer->blit();

Core::loopManager->updateTaskEnd();
}

//Application Exit
Expand Down
Binary file modified raw-assets/elem-s1-edge.psd
Binary file not shown.
78 changes: 55 additions & 23 deletions src/arc-impl/TextureNineRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,63 @@ import Graphic.Draw;
using namespace Graphic;

void GL::TextureNineRegion::render_RelativeExter(const float x, const float y, const float width, const float height) const {
//TODO clamp
Align::Spacing tempEdge = edge;
if(width < edge.getWidth()){
const float remain = edge.getWidth() - width;
tempEdge.left -= remain * 0.5f;
tempEdge.right -= remain * 0.5f;
}
static constexpr auto EdgeScale = Align::Scale::bounded;

auto botLftSize = edge.bot_lft();
auto topRitSize = edge.top_rit();

const auto cornerSize = botLftSize + topRitSize;
const auto scale = Align::embedTo(EdgeScale, cornerSize, {width, height}) / cornerSize;

botLftSize *= scale;
topRitSize *= scale;

Geom::Vec2 anchorBotLft{botLftSize};
Geom::Vec2 anchorTopRit{Geom::Vec2{width, height} - topRitSize};

anchorBotLft.add(x, y);
anchorTopRit.add(x, y);

[[assume(anchorBotLft.x <= anchorTopRit.x)]];
[[assume(anchorBotLft.y <= anchorTopRit.y)]];

[[assume(x <= anchorBotLft.x)]];
[[assume(y <= anchorBotLft.y)]];

if(height < edge.getHeight()){
const float remain = edge.getHeight() - height;
tempEdge.bottom -= remain * 0.5f;
tempEdge.top -= remain * 0.5f;
[[assume(anchorTopRit.x <= x + width)]];
[[assume(anchorTopRit.y <= y + height)]];

const Rect center{anchorBotLft, anchorTopRit};

const Rect bot_lft{{x, y}, center.vert_00()};
const Rect bot_rit{center.vert_10(), {x + width, y}};
const Rect bot{bot_lft.vert_10(), bot_rit.vert_01()};

const Rect lft{bot_lft.vert_01(), center.vert_01()};
const Rect rit{bot_rit.vert_11(), center.vert_11()};

const Rect top_rit{center.vert_11(), {x + width, y + height}};
const Rect top_lft{center.vert_01(), {x, y + height}};
const Rect top{top_lft.vert_10(), top_rit.vert_01()};

if(centerScale != Align::Scale::fill){
const auto centerSize = Align::embedTo(centerScale, innerSize, center.getSize());
auto [cx, cy] = Align::getOffsetOf(Align::Layout::center, centerSize, center);

Draw::Overlay::Fill::rectOrtho(regions[ID_center], cx, cy, centerSize.x, centerSize.y);
}else{
Draw::Overlay::Fill::rectOrtho(regions[ID_center], center);
}

Draw::Overlay::Fill::rectOrtho(regions[ID_center], x + tempEdge.left, y + tempEdge.bottom, width - tempEdge.getWidth(), height - tempEdge.getHeight());

Draw::Overlay::Fill::rectOrtho(regions[ID_right], x + width - tempEdge.right, y + tempEdge.bottom, tempEdge.right, height - tempEdge.bottom - tempEdge.top);
Draw::Overlay::Fill::rectOrtho(regions[ID_top], x + tempEdge.left, y + height - tempEdge.top, width - tempEdge.left - tempEdge.right, tempEdge.top);
Draw::Overlay::Fill::rectOrtho(regions[ID_left], x, y + tempEdge.bottom, tempEdge.left, height - tempEdge.bottom - tempEdge.top);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottom], x + tempEdge.left, y, width - tempEdge.left - tempEdge.right, tempEdge.bottom);

Draw::Overlay::Fill::rectOrtho(regions[ID_topRight], x + width - tempEdge.right, y + height - tempEdge.top, tempEdge.right, tempEdge.top);
Draw::Overlay::Fill::rectOrtho(regions[ID_topLeft], x, y + height - tempEdge.top, tempEdge.left, tempEdge.top);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottomLeft], x, y, tempEdge.left, tempEdge.bottom);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottomRight], x + width - tempEdge.right, y, tempEdge.right, tempEdge.bottom);

Draw::Overlay::Fill::rectOrtho(regions[ID_right], rit);
Draw::Overlay::Fill::rectOrtho(regions[ID_top], top);
Draw::Overlay::Fill::rectOrtho(regions[ID_left], lft);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottom], bot);

Draw::Overlay::Fill::rectOrtho(regions[ID_topRight], top_rit);
Draw::Overlay::Fill::rectOrtho(regions[ID_topLeft], top_lft);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottomLeft], bot_lft);
Draw::Overlay::Fill::rectOrtho(regions[ID_bottomRight], bot_rit);
}

void GL::TextureNineRegion::render_RelativeInner(const float x, const float y, const float width,
Expand Down
15 changes: 15 additions & 0 deletions src/arc-impl/ui/Creation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module UI.Creation;

import UI.Styles;
import UI.RegionDrawable;

void UI::Create::LineCreater::operator()(ImageRegion& image) const{
image.setEmptyDrawer();
image.color = defColor;
image.setDrawable(TextureNineRegionDrawable{&UI::Styles::tex_elem_s1_back});
image.scaling = Align::Scale::stretch;
}

void UI::Create::LineCreater::operator()(LayoutCell& cell) const{
if(clearMargin)cell.setMargin(0.f);
}
14 changes: 7 additions & 7 deletions src/arc/Event.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ export namespace Event {
};

void fire(const T signal) {
for (const auto& listener : events[static_cast<SignalType>(signal)]) {
for (const auto& listener : events[std::to_underlying(signal)]) {
listener();
}
}

void on(const T signal, Concepts::Invokable<void(const T&)> auto&& func){
events[static_cast<SignalType>(signal)].emplace_back(std::forward<decltype(func)>(func));
void on(const T signal, Concepts::Invokable<void()> auto&& func){
events[std::to_underlying(signal)].emplace_back(std::forward<decltype(func)>(func));
}

template <T signal>
template <T signal, Concepts::Invokable<void()> Func>
requires isValid<signal>
void on(Concepts::Invokable<void(const T&)> auto&& func){
events[static_cast<SignalType>(signal)].emplace_back(std::forward<decltype(func)>(func));
void on(Func&& func){
events[std::to_underlying(signal)].emplace_back(std::forward<Func>(func));
}

template <T signal>
requires isValid<signal>
void fire(){
for (const auto& listener : events[static_cast<SignalType>(signal)]) {
for (const auto& listener : events[std::to_underlying(signal)]) {
listener();
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/arc/core/Global.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ export import OS.FileTree;
export import OS.Ctrl;

export namespace Core{
/* Almost Done */
inline Input input{};
/* Basically Done */

//TODO is ptr necessary?
inline Camera2D* camera = nullptr;
/* Basically Done */

inline BatchGroup batchGroup{};
/* Basically Done */

inline Renderer* renderer = nullptr;
/* 88.00% */

inline OS::FileTree rootFileTree{};

//TODO main components... maybe more

/* 0.00% */
inline Audio* audio = nullptr;
/* 90.00% */

inline Assets::Manager* assetsManager = nullptr;
/* 0.00% */

inline Settings* settings = nullptr;
/* 3.00% */

inline UI::Root* uiRoot = nullptr;
/* 0.00% */

inline Assets::Bundle bundle{};
/* 30.00% */

inline Log* log = nullptr;

inline std::unique_ptr<PlatformHandle> platform{};
Expand Down
4 changes: 2 additions & 2 deletions src/arc/core/MainLoopManager.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ export namespace Core{
std::jthread taskThread{&MainLoopManager::updateTask, this};

void updateTask(){
while(true){
while(!taskThread.get_stop_token().stop_requested()){
updateBeginSemaphore.acquire();
if(taskThread.get_stop_token().stop_requested())break;
if(gameCore)gameCore->update(getDeltaTick());
updateEndSemaphore.release();
}
}

public:
~MainLoopManager(){
gameCore = nullptr;
updateBeginSemaphore.release();
}

Expand Down
45 changes: 36 additions & 9 deletions src/arc/core/Unit.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,50 @@ export namespace Core{
struct DirectAccessTimeUnit : std::chrono::duration<T, Ratio>{
using std::chrono::duration<T, Ratio>::count;
using std::chrono::duration<T, Ratio>::rep;
using std::chrono::duration<T, Ratio>::duration;
[[nodiscard]] constexpr DirectAccessTimeUnit() noexcept = default;

[[nodiscard]] constexpr DirectAccessTimeUnit(const T _Val) noexcept
: std::chrono::duration<T, Ratio>(_Val) {}

template <class Rep>
[[nodiscard]] constexpr explicit DirectAccessTimeUnit(const Rep& _Val) noexcept(std::is_arithmetic_v<rep> && std::is_arithmetic_v<Rep>) // strengthened
: std::chrono::duration<T, Ratio>(static_cast<rep>(_Val)) {}

template <class Rep, class Period>
[[nodiscard]] explicit constexpr DirectAccessTimeUnit(const std::chrono::duration<Rep, Period>& _Dur) noexcept(
std::is_arithmetic_v<rep>&& std::is_arithmetic_v<Rep>) // strengthened
: std::chrono::duration<T, Ratio>(std::chrono::duration_cast<std::chrono::duration<T, Ratio>>(_Dur).count()) {}

[[nodiscard]] constexpr operator T() const noexcept{
return this->count();
}

using std::chrono::duration<T, Ratio>::operator++;
using std::chrono::duration<T, Ratio>::operator--;

using std::chrono::duration<T, Ratio>::operator%=;

using std::chrono::duration<T, Ratio>::operator+=;
using std::chrono::duration<T, Ratio>::operator-=;
using std::chrono::duration<T, Ratio>::operator*=;
using std::chrono::duration<T, Ratio>::operator/=;

using std::chrono::duration<T, Ratio>::operator+;
using std::chrono::duration<T, Ratio>::operator-;

constexpr DirectAccessTimeUnit& operator++() noexcept(std::is_arithmetic_v<rep>) /* strengthened */ {
this->std::chrono::duration<T, Ratio>::operator++();
return *this;
}

constexpr DirectAccessTimeUnit operator++(int) noexcept(std::is_arithmetic_v<rep>) /* strengthened */ {
auto t = *this;
this->operator++();
return t;
}

constexpr DirectAccessTimeUnit& operator--() noexcept(std::is_arithmetic_v<rep>) /* strengthened */ {
this->std::chrono::duration<T, Ratio>::operator--();
return *this;
}

constexpr DirectAccessTimeUnit operator--(int) noexcept(std::is_arithmetic_v<rep>) /* strengthened */ {
auto t = *this;
this->operator--();
return t;
}
};

using Tick = DirectAccessTimeUnit<float, TickRatio>;
Expand Down
4 changes: 1 addition & 3 deletions src/arc/graphic/Color.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,8 @@ export namespace Graphic{
constexpr Color SKY{ 0x87ceebff };

constexpr Color AQUA{ 0x85A2F3ff };

constexpr Color AQUA_SKY = Color::createLerp(0.5f, AQUA, SKY);

constexpr Color BLUE_SKY = Color::createLerp(0.745f, BLUE, SKY);
constexpr Color AQUA_SKY = Color::createLerp(0.5f, AQUA, SKY);

constexpr Color CYAN{ 0, 1, 1, 1 };
constexpr Color TEAL{ 0, 0.5f, 0.5f, 1 };
Expand Down
Loading

0 comments on commit d4ae57a

Please sign in to comment.