Skip to content

Commit

Permalink
Switched gui to use borealis instead of pu
Browse files Browse the repository at this point in the history
Gui now has settings instead of hardcoded in Arguments
Gui can also change video mode of a given game (1.5 software video mode)
  • Loading branch information
capsterx committed Nov 3, 2020
1 parent e879837 commit ee26708
Show file tree
Hide file tree
Showing 22 changed files with 607 additions and 1,829 deletions.
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ DATA := data
INCLUDES := include include/solarus include/solarus/core include/solarus/hero include/solarus/entities \
include/solarus/lowlevel include/solarus/lua include/solarus/movements \
include/solarus/containers include/solarus/third_party/snes_spc \
include/solarus/third_party/mojoAL/AL include/solarus/third_party/lua include/solarus/third_party
include/solarus/third_party/mojoAL/AL include/solarus/third_party/lua \
include/solarus/third_party
EXEFS_SRC := exefs_src

APP_TITLE := Solarus Engine
Expand All @@ -61,7 +62,7 @@ CXXFLAGS := $(CFLAGS) -frtti -fexceptions -std=c++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lSDL2_ttf -lglad -lglapi -lfreetype -lbz2 -lSDL2_image -lpng -lz -ljpeg -lSDL2 \
LIBS := -lSDL2_ttf -lglapi -lfreetype -lbz2 -lSDL2_image -lpng -lz -ljpeg -lSDL2 \
-lphysfs -lmodplug -lvorbisfile -lvorbis -logg \
-lwebp -lEGL -lglapi -ldrm_nouveau -lnx
#SWITCH_GUI := 1
Expand All @@ -75,13 +76,17 @@ LIBDIRS := $(PORTLIBS) $(LIBNX)

ifneq ($(strip $(SWITCH_GUI)),)
SOURCES += src/switch
INCLUDES += include/solarus/switch Plutonium/Plutonium/Include
INCLUDES += include/solarus/switch
CFLAGS += -DSOLARUS_SWITCH_GUI
CXXFLAGS += -DSOLARUS_SWITCH_GUI -std=c++17
SOLARUS_SWITCH_GUI=switch_gui
LIBDIRS += $(CURDIR)/Plutonium/Plutonium/Output
TMP_LIB=$(LIBS)
LIBS := -lpu -lSDL2_gfx -lSDL2_mixer -lopusfile -lopus -lmpg123 $(LIBS)
ROMFS:=$(TOPDIR)/resources
BOREALIS_RESOURCES:=romfs:/
BOREALIS_PATH:=borealis
CXXFLAGS += -DSOLARUS_SWITCH_GUI -std=c++17 -DBOREALIS_RESOURCES="\"$(BOREALIS_RESOURCES)\""
include $(TOPDIR)/$(BOREALIS_PATH)/library/borealis.mk
#SOLARUS_SWITCH_GUI=switch_gui
#LIBDIRS += $(CURDIR)/Plutonium/Plutonium/Output
#TMP_LIB=$(LIBS)
#LIBS := -lpu -lSDL2_gfx -lSDL2_mixer -lopusfile -lopus -lmpg123 $(LIBS)
else
ifeq ($(strip $(EMBEDED_TARGET)),)
$(error no EMBEDED_TARGET set and SWITCH_GUI is not set)
Expand Down
2 changes: 1 addition & 1 deletion borealis/library/lib/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void ListItem::layout(NVGcontext* vg, Style* style, FontStash* stash)
if (this->thumbnailView)
{
Style* style = Application::getStyle();
unsigned thumbnailSize = height - style->List.Item.thumbnailPadding * 2;
unsigned thumbnailSize = style->List.Item.height - style->List.Item.thumbnailPadding * 2;

this->thumbnailView->setBoundaries(
x + style->List.Item.thumbnailPadding,
Expand Down
1 change: 1 addition & 0 deletions include/solarus/core/Arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SOLARUS_API Arguments {

Arguments();
Arguments(int argc, char** argv);
Arguments(std::vector<std::string> const &);

const std::string& get_program_name() const;
void set_program_name(const std::string& program_name);
Expand Down
2 changes: 2 additions & 0 deletions include/solarus/graphics/Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ namespace Video {
void invalidate(const SurfaceImpl &texture);
SurfacePtr& get_screen_surface();

extern size_t default_video_mode_index;

} // namespace Video

} // namespace Solarus
Expand Down
10 changes: 10 additions & 0 deletions include/solarus/switch/AboutTab.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <borealis.hpp>

class AboutTab : public brls::List
{
public:
AboutTab();
View * getDefaultFocus() override;
};
15 changes: 15 additions & 0 deletions include/solarus/switch/TabOptionsFrame.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <borealis.hpp>
#include <solarus/switch/Title.hpp>

using GameSettings = std::map<std::string, std::string>;

class TabOptionsFrame : public brls::TabFrame
{
public:
TabOptionsFrame(std::shared_ptr<GameSettings> const &, std::string & path, std::vector<Title> const & titles);

private:
std::vector<Title> titles_;
};
14 changes: 14 additions & 0 deletions include/solarus/switch/Title.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <string>
#include <vector>
#include <solarus/core/QuestProperties.h>

struct Title
{
Solarus::QuestProperties properties;
std::string path;
std::string icon;
};

std::vector<Title> getTitles(std::string const & path);
45 changes: 45 additions & 0 deletions include/solarus/switch/bak/switch_gui.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

#pragma once

// Include Plutonium's main header
#include <pu/Plutonium>

// Define your main layout as a class inheriting from pu::Layout
class Solarus_GUI : public pu::ui::Layout
{
public:

Solarus_GUI();

// Have ::Ref alias and ::New() static constructor
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
//
PU_SMART_CTOR(Solarus_GUI)

private:

// An easy way to keep objects is to have them as private members
// Using ::Ref (of a Plutonium built-in object or any class having PU_SMART_CTOR) is an alias to a shared_ptr of the instance.
std::vector<std::string> paths_;
pu::ui::elm::Menu::Ref menu;

public:
std::string get_path() const;
static std::string selected_path_;
};

// Define your application (can't instantiate base class, so need to make a derived one)
class MainApplication : public pu::ui::Application
{
public:
using Application::Application;
PU_SMART_CTOR(MainApplication)

// We need to define this, and use it to initialize everything
void OnLoad() override;

private:

// Layout instance
Solarus_GUI::Ref layout;
};
Loading

0 comments on commit ee26708

Please sign in to comment.