# Stage 1.9
- Add AppInit Flags and AppFlags to COntrol some Individual Stuff (Not using default can run into a crash report if things get used that are disabled) - Create a Test Settings Menu - Make Some Menu functions Public - Add ScrollTo Animation - Make ContainerApi fully public - Remove an else statement (now need to find a way to not set the pos twice) -
This commit is contained in:
@ -34,6 +34,27 @@ namespace PD {
|
||||
/// @brief Template Class for User Application
|
||||
class App {
|
||||
public:
|
||||
using AppFlags = u32;
|
||||
enum AppFlags_ {
|
||||
AppFlags_None = 0,
|
||||
AppFLags_UserLoop = 1 << 0,
|
||||
AppFlags_HandleOverlays = 1 << 1,
|
||||
AppFlags_HandleMessageMgr = 1 << 2,
|
||||
AppFlags_HandleRendering = 1 << 3,
|
||||
AppFlags_Default = AppFlags_HandleMessageMgr | AppFlags_HandleOverlays |
|
||||
AppFlags_HandleRendering | AppFLags_UserLoop,
|
||||
};
|
||||
using AppInitFlags = u32;
|
||||
enum AppInitFlags_ {
|
||||
AppInitFlags_None = 0,
|
||||
AppInitFlags_MountRomfs = 1 << 0,
|
||||
AppInitFlags_InitGraphics = 1 << 1,
|
||||
AppInitFlags_New3dsMode = 1 << 2,
|
||||
AppInitFlags_InitGraphicsNoC3D = 1 << 3,
|
||||
AppInitFlags_InitLithium = 1 << 4,
|
||||
AppInitFlags_Default = AppInitFlags_MountRomfs | AppInitFlags_InitGraphics |
|
||||
AppInitFlags_New3dsMode | AppInitFlags_InitLithium,
|
||||
};
|
||||
App() {
|
||||
if (too) {
|
||||
Error("Only one App can be created at the same time!");
|
||||
@ -66,11 +87,19 @@ class App {
|
||||
Hid::Ref Input() { return input_mgr; }
|
||||
float GetFps() const { return fps; }
|
||||
|
||||
void FeatureEnable(AppFlags flags) { runtimeflags |= flags; }
|
||||
void FeatureDisable(AppFlags flags) { runtimeflags &= ~flags; }
|
||||
AppFlags& GetFeatureSet() { return runtimeflags; }
|
||||
|
||||
protected:
|
||||
Screen::Ref Top;
|
||||
Screen::Ref Bottom;
|
||||
AppInitFlags InitFlags = AppInitFlags_Default;
|
||||
|
||||
private:
|
||||
AppFlags runtimeflags = AppFlags_Default;
|
||||
/// @brief Safe Copy to prevent from editing befor Deinit
|
||||
AppInitFlags SafeInitFlags = AppInitFlags_Default;
|
||||
void PreInit();
|
||||
void PostDeinit();
|
||||
LI::Renderer::Ref renderer;
|
||||
|
@ -23,19 +23,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/common/app.hpp>
|
||||
#include <pd/controls/hid.hpp>
|
||||
#include <pd/maths/tween.hpp>
|
||||
#include <pd/overlays/overlay.hpp>
|
||||
#include <pd/controls/hid.hpp>
|
||||
#include <pd/ui7/ui7.hpp>
|
||||
|
||||
namespace PD {
|
||||
class SettingsMenu : public Overlay {
|
||||
public:
|
||||
SettingsMenu() {
|
||||
SettingsMenu(PD::App* app) {
|
||||
too++;
|
||||
if (too > 1) {
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
app_ref = app;
|
||||
app->FeatureDisable(PD::App::AppFLags_UserLoop);
|
||||
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
|
||||
}
|
||||
~SettingsMenu() { too--; }
|
||||
@ -44,10 +48,12 @@ class SettingsMenu : public Overlay {
|
||||
|
||||
void Rem() {
|
||||
rem = true;
|
||||
app_ref->FeatureEnable(App::AppFLags_UserLoop);
|
||||
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
|
||||
}
|
||||
|
||||
private:
|
||||
PD::App* app_ref = nullptr;
|
||||
/// Section is used to determinate what
|
||||
/// should be displayed on the top screen
|
||||
int section = 0;
|
||||
@ -57,5 +63,8 @@ class SettingsMenu : public Overlay {
|
||||
// Some Animation
|
||||
bool rem = false;
|
||||
Tween<vec2> flymgr;
|
||||
|
||||
// Custom UI7 Context
|
||||
UI7::Context::Ref ctx;
|
||||
};
|
||||
} // namespace PD
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/controls/hid.hpp>
|
||||
#include <pd/maths/tween.hpp>
|
||||
#include <pd/ui7/containers.hpp>
|
||||
#include <pd/ui7/drawlist.hpp>
|
||||
#include <pd/ui7/flags.hpp>
|
||||
@ -73,6 +74,31 @@ class Menu : public SmartCtor<Menu> {
|
||||
cursor = bcursor;
|
||||
bcursor = vec2();
|
||||
}
|
||||
bool HasVerticalScrollbar() { return scrollbar[1]; }
|
||||
bool HasHorizontalScrollbar() { return scrollbar[0]; }
|
||||
float TitleBarHeight() { return tbh; }
|
||||
/// @brief Set a Custom Titlebar heigt
|
||||
/// @note Could destroy some basic functionality
|
||||
void TitleBarHeight(float v) { tbh = v; }
|
||||
/// @brief Init the Cursor
|
||||
/// @note Useful when using with a Custom TitlebarHeight
|
||||
void CursorInit() { Cursor(vec2(5, tbh + 5)); }
|
||||
void CursorMove(const vec2& szs);
|
||||
|
||||
vec4 ViewArea() const { return view_area; }
|
||||
vec4 MainArea() const { return main_area; }
|
||||
void MainArea(const vec4& v) { main_area = v; }
|
||||
vec2 ScrollOffset() const { return scrolling_off; }
|
||||
void ScrollTo(vec2 pos) {
|
||||
scroll_anim.From(scrolling_off)
|
||||
.To(pos)
|
||||
.In(1.f)
|
||||
.As(scroll_anim.EaseInOutSine);
|
||||
}
|
||||
|
||||
/// Objects API
|
||||
Container::Ref ObjectPush(Container::Ref obj);
|
||||
Container::Ref FindIDObj(u32 id);
|
||||
|
||||
/// Draw Lists
|
||||
DrawList::Ref BackList() { return back; }
|
||||
@ -94,27 +120,17 @@ class Menu : public SmartCtor<Menu> {
|
||||
void PreHandler(UI7MenuFlags flags);
|
||||
void PostHandler();
|
||||
/// Basic Settings
|
||||
vec2 BackupCursor() const { return bcursor; }
|
||||
void BackupCursor(const vec2& v) { bcursor = v; }
|
||||
vec2 SameLineCursor() const { return slcursor; }
|
||||
void SameLineCursor(const vec2& v) { slcursor = v; }
|
||||
vec4 ViewArea() const { return view_area; }
|
||||
void ViewArea(const vec4& v) { view_area = v; }
|
||||
vec2 ScrollOffset() const { return scrolling_off; }
|
||||
void ScrollOffset(const vec2& v) { scrolling_off = v; }
|
||||
vec2 ScrollMod() const { return scroll_mod; }
|
||||
void ScrollMod(const vec2& v) { scroll_mod = v; }
|
||||
|
||||
/// Advanced
|
||||
void CursorMove(const vec2& szs);
|
||||
|
||||
/// Internal Processing
|
||||
void Update(float delta);
|
||||
|
||||
/// Objects API
|
||||
Container::Ref ObjectPush(Container::Ref obj);
|
||||
Container::Ref FindIDObj(u32 id);
|
||||
|
||||
/// This ability is crazy useful
|
||||
friend class Context;
|
||||
|
||||
@ -126,6 +142,7 @@ class Menu : public SmartCtor<Menu> {
|
||||
vec2 bcursor;
|
||||
vec2 slcursor;
|
||||
vec4 view_area;
|
||||
vec4 main_area;
|
||||
vec2 scrolling_off;
|
||||
bool scrolling[2];
|
||||
vec2 scroll_mod;
|
||||
@ -158,6 +175,9 @@ class Menu : public SmartCtor<Menu> {
|
||||
|
||||
// Input Reference
|
||||
Hid::Ref inp;
|
||||
|
||||
// Animations System
|
||||
Tween<vec2> scroll_anim;
|
||||
};
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -58,7 +58,12 @@ class Context : public SmartCtor<Context> {
|
||||
DrawList::Ref BackList() { return back; }
|
||||
DrawList::Ref FrontList() { return front; }
|
||||
|
||||
void RootLayer(int l) { root_layer = l; }
|
||||
int RootLayer() const { return root_layer; }
|
||||
|
||||
private:
|
||||
// Used in Overlays
|
||||
int root_layer = 0;
|
||||
// Linked Renderer / Hid
|
||||
LI::Renderer::Ref ren;
|
||||
Hid::Ref inp;
|
||||
|
Reference in New Issue
Block a user