mirror of
https://github.com/zetaPRIME/libstarlight.git
synced 2025-06-26 05:32:46 +00:00
convert "starlauncher" miscellany into proper library testbed
This commit is contained in:
parent
3774089a70
commit
093031dfa8
43
.gitignore
vendored
43
.gitignore
vendored
@ -1,4 +1,47 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.elf
|
||||
*.3dsx
|
||||
# ...and icons
|
||||
*.smdh
|
||||
|
||||
# section-specifics
|
||||
|
||||
# libstarlight main
|
||||
libstarlight/build/
|
||||
libstarlight/lib/
|
||||
libstarlight/include/
|
||||
libstarlight/lib*.tar.bz2
|
||||
|
||||
# testbed
|
||||
testbed/build/
|
||||
|
@ -203,6 +203,16 @@ void ThemeManager::LoadProc() {
|
||||
string ThemeManager::ResolveAssetPath(const string& id) {
|
||||
struct stat buf;
|
||||
string path(id.length() + 64, ' '); // preallocate buffer space
|
||||
|
||||
static const string pfxLocal = "app:/";
|
||||
if (id.compare(0, pfxLocal.length(), pfxLocal)) {
|
||||
// app-local asset
|
||||
// check if present in theme/app/[appname]/, else check in romfs
|
||||
}
|
||||
else {
|
||||
// theme asset; check in each theme from selected to most-fallback
|
||||
}
|
||||
|
||||
path.clear(); path.append("romfs:/"); path.append(id); path.append(".json");
|
||||
printf("attempt: %s\n", path.c_str());
|
||||
if (stat(path.c_str(), &buf) == 0) return path;
|
||||
@ -225,4 +235,3 @@ string ThemeManager::ResolveFontPath(const string& id) { // this needs redone, b
|
||||
|
||||
return string();
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ void Button::SetText(const std::string& text) {
|
||||
void Button::Draw() {
|
||||
static auto font = ThemeManager::GetFont("default.12");
|
||||
|
||||
static auto idle = ThemeManager::GetAsset("button.idle");
|
||||
static auto press = ThemeManager::GetAsset("button.press");
|
||||
static auto idle = ThemeManager::GetAsset("controls/button.idle");
|
||||
static auto press = ThemeManager::GetAsset("controls/button.press");
|
||||
|
||||
auto rect = (this->rect + GFXManager::GetOffset()).IntSnap();
|
||||
|
||||
|
@ -73,12 +73,6 @@ implement this to replace weak_ptr parent if it ends up impacting performance to
|
||||
|
||||
maybe implement this: https://probablydance.com/2013/01/13/a-faster-implementation-of-stdfunction/
|
||||
|
||||
split stuff into libstarlight {
|
||||
namespaces (done except for a couple manager classes)
|
||||
actual lib split once everything's working I guess
|
||||
"" to <> (???)
|
||||
}
|
||||
|
||||
// notes {
|
||||
bitmap font converter - https://github.com/playcanvas/fonts/blob/master/fnt_to_json.py
|
||||
}
|
||||
|
11
maketest.sh
Normal file
11
maketest.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
function abort {
|
||||
echo Make failed
|
||||
exit
|
||||
}
|
||||
cd libstarlight
|
||||
make install || abort
|
||||
cd ../testbed
|
||||
make clean
|
||||
make send || abort
|
||||
cd ..
|
230
testbed/Makefile
Normal file
230
testbed/Makefile
Normal file
@ -0,0 +1,230 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := starlight-testbed
|
||||
BUILD := build
|
||||
SOURCES := $(sort $(dir $(wildcard source/*/ source/*/*/ source/*/*/*/ source/*/*/*/*/ source/*/*/*/*/*/)))
|
||||
#SOURCES := source \
|
||||
# source/starlight \
|
||||
# source/starlight/datatypes \
|
||||
# source/starlight/gfx \
|
||||
# source/starlight/ui
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
ROMFS := ../themes/default
|
||||
#ROMFS := romfs
|
||||
|
||||
APP_TITLE := Starlight Testbed
|
||||
APP_DESCRIPTION := Test application for libstarlight
|
||||
APP_AUTHOR := zetaPRIME
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
# was gnu++11; -fno-rtti -fno-exceptions (why no-exceptions???)
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++14
|
||||
# on second thought, let's not use -D_GLIBCXX_USE_C99
|
||||
#CXXFLAGS := $(CFLAGS) -std=gnu++14
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
|
||||
|
||||
#LIBS := -lsftd -lfreetype -lpng -lz -lsf2d -lcitro3d -lctru -lm
|
||||
LIBS := -lstarlight -lcitro3d -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(DEVKITPRO)/libstarlight $(CTRULIB) $(PORTLIBS)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
||||
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := -I$(CURDIR)/source $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||
endif
|
||||
|
||||
ifneq ($(ROMFS),)
|
||||
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(TARGET)-strip.elf $(TARGET).cia $(TARGET).3ds
|
||||
#---------------------------------------------------------------------------------
|
||||
$(TARGET)-strip.elf: $(BUILD)
|
||||
@$(STRIP) --strip-all $(TARGET).elf -o $(TARGET)-strip.elf
|
||||
#---------------------------------------------------------------------------------
|
||||
cci: $(TARGET)-strip.elf
|
||||
@makerom -f cci -rsf resources/$(TARGET).rsf -target d -exefslogo -elf $(TARGET)-strip.elf -o $(TARGET).3ds
|
||||
@echo "built ... sf2d_sample.3ds"
|
||||
#---------------------------------------------------------------------------------
|
||||
cia: $(TARGET)-strip.elf
|
||||
@makerom -f cia -o $(TARGET).cia -elf $(TARGET)-strip.elf -rsf resources/$(TARGET).rsf -icon resources/icon.icn -banner resources/banner.bnr -exefslogo -target t
|
||||
@echo "built ... $(TARGET).cia"
|
||||
#---------------------------------------------------------------------------------
|
||||
send: $(BUILD)
|
||||
@3dslink $(TARGET).3dsx || 3dslink $(TARGET).3dsx || 3dslink $(TARGET).3dsx || 3dslink $(TARGET).3dsx || 3dslink $(TARGET).3dsx
|
||||
#---------------------------------------------------------------------------------
|
||||
run: $(BUILD)
|
||||
@citra $(TARGET).3dsx
|
||||
#---------------------------------------------------------------------------------
|
||||
copy_cia: $(TARGET).cia
|
||||
@cp $(TARGET).cia /mnt/3DS
|
||||
sync
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
|
||||
else
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# rules for assembling GPU shaders
|
||||
#---------------------------------------------------------------------------------
|
||||
define shader-as
|
||||
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
|
||||
picasso -o $(CURBIN) $1
|
||||
bin2s $(CURBIN) | $(AS) -o $@
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
endef
|
||||
|
||||
%.shbin.o : %.v.pica %.g.pica
|
||||
@echo $(notdir $^)
|
||||
@$(call shader-as,$^)
|
||||
|
||||
%.shbin.o : %.v.pica
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$<)
|
||||
|
||||
%.shbin.o : %.shlist
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
80
testbed/source/Core.cpp
Normal file
80
testbed/source/Core.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include "Core.h"
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include "starlight/InputManager.h"
|
||||
#include "starlight/ThemeManager.h"
|
||||
#include "starlight/GFXManager.h"
|
||||
#include "starlight/gfx/RenderCore.h"
|
||||
|
||||
#include "starlight/ui/ParallaxLayer.h"
|
||||
#include "starlight/ui/ScrollField.h"
|
||||
#include "starlight/ui/Button.h"
|
||||
#include "starlight/ui/Label.h"
|
||||
|
||||
using starlight::Vector2;
|
||||
using starlight::VRect;
|
||||
using starlight::Color;
|
||||
using starlight::InputManager;
|
||||
using starlight::GFXManager;
|
||||
using starlight::ThemeManager;
|
||||
using starlight::gfx::RenderCore;
|
||||
|
||||
using starlight::Application;
|
||||
|
||||
void Core::Init() {
|
||||
//consoleInit(GFX_TOP, consoleGetDefault());
|
||||
|
||||
auto container = std::make_shared<sl::ui::ScrollField>(VRect(0,0,320-0,240-0));
|
||||
touchScreen->Add(container);
|
||||
|
||||
auto label = std::make_shared<sl::ui::Label>(VRect(0,0,320,0));
|
||||
label->autoSizeV = true;
|
||||
//label->justification = Vector2::zero;
|
||||
//label->SetText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
|
||||
label->SetText("~libstardust UI test~\n\nHello. I'm a label.\nI have multiple lines and can resize to fit my content. Did you know that miles per gallon is actually a measure of volume?");
|
||||
//label->SetFont("default.16");
|
||||
//label->SetFont("default.12");
|
||||
container->Add(label);
|
||||
|
||||
auto button = std::make_shared<sl::ui::Button>(VRect(64,80,128,32));
|
||||
button->SetText("I'm a button.");
|
||||
button->eOnTap = [label](auto& btn){
|
||||
label->SetFont("default.16");
|
||||
btn.SetText("I was pressed!");
|
||||
btn.eOnTap = [label](auto& btn){
|
||||
label->borderColor = Color::black;
|
||||
btn.SetText("Event swap!");
|
||||
btn.eOnTap = [label](auto& btn){
|
||||
label->SetFont("default.12");
|
||||
btn.SetText("Clicked again!\nBunch of lines!\nNow testing scrollarea fling with some extra size!\n\n\nPotato.\nCalamari sandwich on rye with a side of octagonal pimento; a jar of butter?");
|
||||
btn.rect.size.y = 573;
|
||||
};
|
||||
};
|
||||
};
|
||||
container->Add(button);
|
||||
|
||||
//
|
||||
|
||||
auto parallax = std::make_shared<sl::ui::ParallaxLayer>();
|
||||
parallax->depth = 5;
|
||||
topScreen->Add(parallax);
|
||||
|
||||
auto pipf = std::make_shared<sl::ui::Label>(VRect(0,0,400,240));
|
||||
pipf->SetFont("default.16"); pipf->borderColor = Color::black;
|
||||
pipf->SetText("I am the very model of something on the top screen. :D\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
|
||||
parallax->Add(pipf);
|
||||
|
||||
clearColor = Color(0.0f, 0.5f, 0.5f);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
void Core::End() {
|
||||
|
||||
}
|
||||
|
||||
void Core::Update() {
|
||||
if (InputManager::Held(KEY_Y) || InputManager::Pressed(KEY_START)) Application::Quit();
|
||||
}
|
||||
|
17
testbed/source/Core.h
Normal file
17
testbed/source/Core.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "starlight/Application.h"
|
||||
|
||||
using starlight::Application;
|
||||
|
||||
class Core : public Application {
|
||||
public:
|
||||
Core() : Application("starlauncher") { }
|
||||
~Core() override = default;
|
||||
|
||||
void Init() override;
|
||||
void End() override;
|
||||
void Update() override;
|
||||
|
||||
};
|
||||
|
251
testbed/source/main.cpp
Normal file
251
testbed/source/main.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <3ds.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "starlight/InputManager.h"
|
||||
#include "starlight/datatypes/Vector2.h"
|
||||
|
||||
#include "starlight/ThemeManager.h"
|
||||
#include "starlight/gfx/ThemeRef.h"
|
||||
|
||||
#include "starlight/ui/TouchScreenCanvas.h"
|
||||
#include "starlight/ui/ScrollField.h"
|
||||
#include "starlight/ui/Button.h"
|
||||
|
||||
#include "starlight/gfx/DrawableTest.h"
|
||||
#include "starlight/gfx/DrawContextTouchscreen.h"
|
||||
#include "starlight/gfx/DrawContextCanvas.h"
|
||||
#include "starlight/GFXManager.h"
|
||||
|
||||
#include "starlight/gfx/RenderCore.h"
|
||||
|
||||
#define CONFIG_3D_SLIDERSTATE (*(float *)0x1FF81080)
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
using starlight::Vector2;
|
||||
using starlight::VRect;
|
||||
using starlight::Color;
|
||||
using starlight::InputManager;
|
||||
using starlight::GFXManager;
|
||||
using starlight::ThemeManager;
|
||||
using starlight::gfx::RenderCore;
|
||||
|
||||
/*Handle *signalEvent = NULL;
|
||||
Handle *resumeEvent = NULL;
|
||||
|
||||
Handle *nssHandle = NULL;//*/
|
||||
|
||||
//aptMessageCb callback = {NULL, APPID_HOMEMENU, "boop", sizeof("boop")};
|
||||
|
||||
/*void __appInit() {
|
||||
srvInit();
|
||||
hidInit();
|
||||
|
||||
fsInit();
|
||||
sdmcInit();
|
||||
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
}//*/
|
||||
|
||||
float fRand() {
|
||||
return static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
|
||||
}
|
||||
|
||||
bool quit = false;
|
||||
int main()
|
||||
{
|
||||
Core().Run();
|
||||
return 0;
|
||||
/*printf("does this draw\n");
|
||||
APT_Initialize(APPID_HOMEMENU, aptMakeAppletAttr(APTPOS_SYS, true, true), signalEvent, resumeEvent);
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
u32 k = hidKeysDown();
|
||||
if (k & KEY_A) printf("this is a test\n");
|
||||
if (k & KEY_START) return 0;
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
}*/
|
||||
|
||||
|
||||
// Set the random seed based on the time
|
||||
srand(time(NULL));
|
||||
|
||||
romfsInit();
|
||||
|
||||
RenderCore::Open();
|
||||
|
||||
float offset3d = 0.0f;
|
||||
float rad = 0.0f;
|
||||
u16 touch_x = 320/2;
|
||||
u16 touch_y = 240/2;
|
||||
touchPosition touch;
|
||||
circlePosition circle;
|
||||
u32 held;
|
||||
|
||||
Vector2 circpos (16.0f, 16.0f);
|
||||
|
||||
char sbuf[100];
|
||||
|
||||
// stuff!
|
||||
auto touchscreen = std::make_shared<starlight::ui::TouchScreenCanvas>();
|
||||
//auto container = std::make_shared<starlight::ui::UIContainer>(VRect(32,32,320-32,240-32));
|
||||
//auto container = std::make_shared<starlight::ui::UICanvas>(VRect(32,32,320-32,240-32));
|
||||
auto container = std::make_shared<starlight::ui::ScrollField>(VRect(0,0,320-0,240-0));
|
||||
auto button = std::make_shared<starlight::ui::Button>(VRect(4,80,128,32));
|
||||
//auto button = std::make_shared<starlight::ui::Button>(VRect(0,0,320-32,240-32));
|
||||
touchscreen->Add(container);
|
||||
container->Add(button);
|
||||
button->label = "I'm a button.";
|
||||
button->eOnTap = [](auto& btn){
|
||||
btn.label = "I was pressed!";
|
||||
btn.eOnTap = [](auto& btn){
|
||||
btn.label = "Event swap!";
|
||||
btn.eOnTap = [](auto& btn){
|
||||
//quit = true;
|
||||
btn.label = "Clicked again!\nBunch of lines!\nNow testing scrollarea fling with some extra size!\n\n\nPotato.";
|
||||
btn.rect.size.y = 573;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Color bgColor = Color(0,0,0);
|
||||
|
||||
consoleInit(GFX_TOP, consoleGetDefault());
|
||||
|
||||
while (aptMainLoop()) {
|
||||
if (quit) break;
|
||||
|
||||
InputManager::Update();
|
||||
held = hidKeysHeld();
|
||||
|
||||
Vector2 cpad = InputManager::CirclePad();
|
||||
|
||||
if (held & (KEY_Y | KEY_START)) {
|
||||
break;
|
||||
} else if (held & KEY_TOUCH) {
|
||||
hidTouchRead(&touch);
|
||||
touch_x = touch.px;
|
||||
touch_y = touch.py;
|
||||
} else if (held & (KEY_L | KEY_R)) {
|
||||
//sf2d_set_clear_color(RGBA8(rand()%255, rand()%255, rand()%255, 255));
|
||||
bgColor = Color(fRand(), fRand(), fRand());
|
||||
} else if (held & KEY_Y) rad = 0;
|
||||
|
||||
//if (InputManager::Held(KEY_TOUCH))
|
||||
circpos = circpos + InputManager::TouchDelta();
|
||||
|
||||
offset3d = CONFIG_3D_SLIDERSTATE * 30.0f;
|
||||
|
||||
/*sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
||||
sf2d_draw_fill_circle(offset3d + 60, 100, 35, RGBA8(0x00, 0xFF, 0x00, 0xFF));
|
||||
sf2d_draw_fill_circle(circpos.x + cpad.x * 20.0f, circpos.y + cpad.y * 20.0f, 55, RGBA8(0xFF, 0xFF, 0x00, (int)(0xFF * (0.75f * cpad.Length() + 0.25f))));
|
||||
|
||||
sf2d_draw_rectangle_rotate(offset3d + 260, 20, 40, 40, RGBA8(0xFF, 0xFF, 0x00, 0xFF), -2.0f*rad);
|
||||
sf2d_draw_rectangle(offset3d + 20, 60, 40, 40, RGBA8(0xFF, 0x00, 0x00, 0xFF));
|
||||
sf2d_draw_rectangle(offset3d + 5, 5, 30, 30, RGBA8(0x00, 0xFF, 0xFF, 0xFF));
|
||||
//sf2d_draw_texture_rotate(tex1, offset3d + 400/2 + circle.dx, 240/2 - circle.dy, rad);
|
||||
sf2d_end_frame();//*/
|
||||
|
||||
/*static int ct = 0;
|
||||
static u32 c1 = starlight::Color(1,0,0);
|
||||
static u32 c2 = starlight::Color(0,0,1);
|
||||
ct = ++ct % 3;
|
||||
if (ct == 0) {
|
||||
//std::swap(c1, c2);
|
||||
c1 = RGBA8(rand()%255, rand()%255, rand()%255, 255);
|
||||
c2 = RGBA8(rand()%255, rand()%255, rand()%255, 255);
|
||||
if (offset3d == 0) c1 = 0;
|
||||
}
|
||||
sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
||||
sf2d_draw_rectangle(0,0,400,240,c1);
|
||||
sf2d_end_frame();
|
||||
|
||||
sf2d_start_frame(GFX_TOP, GFX_RIGHT);
|
||||
sf2d_draw_rectangle(0,0,400,240,c2);
|
||||
//sftd_draw_text(font, 3, 1, RGBA8(255,255,255,255), 16, "THEY'RE MOULDY YOU PILLOCK\nWelcome to the secret text~");
|
||||
|
||||
sf2d_end_frame();*/
|
||||
|
||||
/*sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); {
|
||||
|
||||
const int tileSize = 48;
|
||||
const int tileSpace = 3;
|
||||
for (int iy = 0; iy < 4; iy++) {
|
||||
for (int ix = 0; ix < 5; ix++) {
|
||||
sf2d_draw_rectangle(34 + ix * (tileSize+tileSpace), 3 + iy * (tileSize+tileSpace), tileSize, tileSize, RGBA8(0x7F, 0xBF, 0xFF, 0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 test (circle.dx, circle.dy);
|
||||
test = test * .5f;
|
||||
|
||||
Vector2 tdrag = InputManager::TouchDelta();
|
||||
|
||||
sprintf(sbuf, "Circle pad: %f, %f\nTouch: %f, %f\nVec: %f", cpad.x, cpad.y, tdrag.x, tdrag.y, test.x);
|
||||
sftd_draw_text(font, 3, 3, RGBA8(0xff, 0xff, 0xff, 0xff), 16, sbuf);
|
||||
|
||||
|
||||
} sf2d_end_frame();*/
|
||||
|
||||
/*using starlight::GFXManager;
|
||||
static auto drw = starlight::ThemeManager::GetAsset("whatever");
|
||||
static auto tgt = std::make_shared<starlight::gfx::DrawContextCanvas>(starlight::VRect(0,0,32*3,32*3));
|
||||
|
||||
GFXManager::PushContext(con.get());
|
||||
tgt->Clear(starlight::Color(1,0,0,0.5f));
|
||||
GFXManager::PushContext(static_cast<starlight::gfx::DrawContext*>(tgt.get()));
|
||||
|
||||
drw->Draw(Vector2(0, 0));
|
||||
drw->Draw(Vector2(24, 8));
|
||||
|
||||
drw->Draw(Vector2(0, 63));
|
||||
drw->Draw(Vector2(48, 63));
|
||||
drw->Draw(Vector2(63, 48));
|
||||
|
||||
GFXManager::PopContext();
|
||||
tgt->Draw(Vector2(200, 50), nullptr, nullptr, nullptr, rad*0.1f);
|
||||
|
||||
drw->Draw(Vector2(0, 0));
|
||||
drw->Draw(Vector2(24, 8));
|
||||
|
||||
auto rect = starlight::VRect(32, 32, 64, 32);
|
||||
for (int q = 0; q < 5; q++) {
|
||||
drw->Draw(rect, nullptr, starlight::Color(1,1,1));
|
||||
drw->Draw(rect.Expand(Vector2::one * -0.5f, Vector2::one), nullptr, starlight::Color(0.5f,0.5f,0.5f));
|
||||
drw->Draw(rect.Expand(Vector2::one * -1), nullptr, starlight::Color(0.75f,0.75f,0.75f));
|
||||
rect.pos.y += 34;
|
||||
}
|
||||
GFXManager::PopContext();*/
|
||||
|
||||
RenderCore::BeginFrame();
|
||||
//RenderCore::targetTopLeft->Clear(Color(0,0,0));
|
||||
//RenderCore::targetTopLeft->BindTarget();
|
||||
RenderCore::targetBottom->Clear(bgColor);
|
||||
//container->rect += InputManager::TouchDelta();
|
||||
button->rect += InputManager::CirclePad() * 5.0f;
|
||||
|
||||
touchscreen->Update();
|
||||
touchscreen->PreDraw();
|
||||
touchscreen->Draw();
|
||||
|
||||
rad += 0.2f;
|
||||
|
||||
RenderCore::EndFrame();
|
||||
ThemeManager::LoadProc();
|
||||
}
|
||||
|
||||
RenderCore::Close();//sf2d_fini();
|
||||
return 0;
|
||||
}
|
7
testbed/starlight-testbed.xml
Normal file
7
testbed/starlight-testbed.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<targets selectable="false">
|
||||
<title mediatype="0">0004001000020900</title>
|
||||
<title mediatype="0">0004001000021900</title>
|
||||
<title mediatype="0">0004001000022900</title>
|
||||
<title mediatype="0">0004001000027900</title>
|
||||
<title mediatype="0">0004001000028900</title>
|
||||
</targets>
|
Loading…
x
Reference in New Issue
Block a user