Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SingleSwitchProgramSession::SingleSwitchProgramSession(const SingleSwitchProgram
, m_descriptor(descriptor)
, m_system_option(descriptor.allow_commands_while_running())
, m_system(m_system_option, 0, instance_id())
, m_instance(descriptor.make_instance())
, m_instance(descriptor.make_instance(m_system))
, m_scope(nullptr)
{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_NintendoSwitch_SingleSwitchProgram_H
#define PokemonAutomation_NintendoSwitch_SingleSwitchProgram_H

#include <type_traits>
#include "Common/Cpp/Options/BatchOption.h"
#include "CommonFramework/Globals.h"
#include "CommonFramework/Notifications/EventNotificationOption.h"
Expand All @@ -20,6 +21,7 @@ namespace PokemonAutomation{
namespace NintendoSwitch{


class SwitchSystemSession;
class SingleSwitchProgramInstance;


Expand Down Expand Up @@ -70,7 +72,9 @@ class SingleSwitchProgramDescriptor : public ProgramDescriptor{
bool deprecated() const{ return m_deprecated; }

virtual std::unique_ptr<PanelSession> make_panel() const override;
virtual std::unique_ptr<SingleSwitchProgramInstance> make_instance() const = 0;
virtual std::unique_ptr<SingleSwitchProgramInstance> make_instance(
SwitchSystemSession& system
) const = 0;

private:
const ProgramControllerClass m_color_class;
Expand Down Expand Up @@ -169,8 +173,14 @@ class SingleSwitchProgramInstance{
template <typename Descriptor, typename Instance>
class SingleSwitchProgramWrapper : public Descriptor{
public:
virtual std::unique_ptr<SingleSwitchProgramInstance> make_instance() const override{
return std::make_unique<Instance>();
virtual std::unique_ptr<SingleSwitchProgramInstance> make_instance(
SwitchSystemSession& system
) const override{
if constexpr (std::is_constructible_v<SwitchSystemSession&>){
return std::make_unique<Instance>(system);
}else{
return std::make_unique<Instance>();
}
}
};

Expand Down