diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index cac2e9ca8..dc9697a16 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -80,7 +80,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) void ViewManager::InitMP1(MP1::CMain& main) { - main.Init(m_fileStoreManager, m_voiceEngine.get(), *m_amuseAllocWrapper); + main.Init(m_fileStoreManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper); } void ViewManager::TestGameView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) @@ -363,14 +363,6 @@ void ViewManager::init(boo::IApplication* app) break; } } - - /* - CGraphics::InitializeBoo(gf, m_mainWindow->getCommandQueue(), root->renderTex()); - CModelShaders::Initialize(m_fileStoreManager, gf); - CElementGen::Initialize(); - CMoviePlayer::Initialize(); - CLineRenderer::Initialize(); - */ } bool ViewManager::proc() diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 344946a83..7a20254c4 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -39,6 +39,13 @@ add_subdirectory(MP1) add_subdirectory(MP2) add_subdirectory(MP3) +if(APPLE) + set_source_files_properties(MP1/CFrontEndUITouchBarMac.mm + PROPERTIES COMPILE_FLAGS -fobjc-arc) + bintoc(startButton.c Resources/startButton@2x.png START_BUTTON_2X) + list(APPEND PLAT_SRCS startButton.c) +endif() + add_library(RuntimeCommon RetroTypes.hpp RetroTypes.cpp ${CLIENT_SOURCES} diff --git a/Runtime/IMain.hpp b/Runtime/IMain.hpp index fa3702fe9..bbd1c9314 100644 --- a/Runtime/IMain.hpp +++ b/Runtime/IMain.hpp @@ -34,11 +34,13 @@ class IMain public: virtual ~IMain() = default; virtual void Init(const hecl::Runtime::FileStoreManager& storeMgr, - boo::IAudioVoiceEngine* voiceEngine, - amuse::IBackendVoiceAllocator& backend)=0; + boo::IWindow* window, + boo::IAudioVoiceEngine* voiceEngine, + amuse::IBackendVoiceAllocator& backend)=0; virtual void Draw()=0; virtual bool Proc()=0; virtual void Shutdown()=0; + virtual boo::IWindow* GetMainWindow() const=0; }; } diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index c1a41fd16..533427995 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -74,8 +74,8 @@ void CFrontEndUI::PlayAdvanceSfx() CSfxManager::SfxStart(1091, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); } -CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveUI* sui, u32 rnd) -: x0_rnd(rnd), x4_saveUI(sui) +CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveUI* sui, u32 rnd, CFrontEndUITouchBar& touchBar) +: x0_rnd(rnd), x4_saveUI(sui), m_touchBar(touchBar) { x10_frme = g_SimplePool->GetObj("FRME_NewFileSelect"); } @@ -182,7 +182,7 @@ void CFrontEndUI::SNewFileSelectFrame::Update(float dt) } CFrontEndUI::SNewFileSelectFrame::EAction -CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input) +CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input, CFrontEndUITouchBar::EAction tbAction) { xc_action = EAction::None; @@ -196,7 +196,28 @@ CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input) return xc_action; if (x10c_saveReady) + { x1c_loadedFrame->ProcessUserInput(input); + if (tbAction >= CFrontEndUITouchBar::EAction::FileA && + tbAction <= CFrontEndUITouchBar::EAction::ImageGallery) + { + switch (tbAction) + { + case CFrontEndUITouchBar::EAction::FileA: + case CFrontEndUITouchBar::EAction::FileB: + case CFrontEndUITouchBar::EAction::FileC: + x20_tablegroup_fileselect->SetUserSelection(int(tbAction) - int(CFrontEndUITouchBar::EAction::FileA)); + break; + case CFrontEndUITouchBar::EAction::FusionBonus: + case CFrontEndUITouchBar::EAction::ImageGallery: + x20_tablegroup_fileselect->SetUserSelection(int(tbAction) - int(CFrontEndUITouchBar::EAction::FusionBonus) + 4); + break; + default: break; + } + HandleActiveChange(x20_tablegroup_fileselect); + DoFileMenuAdvance(x20_tablegroup_fileselect); + } + } if (x10d_needsExistingToggle) { @@ -234,9 +255,29 @@ void CFrontEndUI::SNewFileSelectFrame::HandleActiveChange(CGuiTableGroup* active zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f}); if (active == x20_tablegroup_fileselect) + { x24_model_erase->SetLocalTransform(zeus::CTransform::Translate( zeus::CVector3f{0.f, 0.f, active->GetUserSelection() * x104_rowPitch} + xf8_model_erase_position)); + /* Set Touch Bar contents here */ + CFrontEndUITouchBar::SFileSelectDetail tbDetails[3] = {}; + for (int i=0 ; i<3 ; ++i) + { + if (const CGameState::GameFileStateInfo* data = x4_saveUI->GetGameData(i)) + { + tbDetails[i].state = data->x20_hardMode ? CFrontEndUITouchBar::EFileState::Hard : + CFrontEndUITouchBar::EFileState::Normal; + tbDetails[i].percent = data->x18_itemPercent; + } + } + m_touchBar.SetFileSelectPhase(tbDetails, x8_subMenu == ESubMenu::EraseGame, + CSlideShow::SlideShowGalleryFlags()); + } + else + { + m_touchBar.SetPhase(CFrontEndUITouchBar::EPhase::None); + } + if (x8_subMenu == ESubMenu::Root || x8_subMenu == ESubMenu::NewGamePopup) x24_model_erase->SetIsVisible(false); else @@ -356,19 +397,20 @@ void CFrontEndUI::SNewFileSelectFrame::ActivateErase() x28_textpane_erase.x0_panes[0]->TextSupport()->SetFontColor(color); x38_textpane_gba.x0_panes[0]->TextSupport()->SetFontColor(color); x30_textpane_cheats.x0_panes[0]->TextSupport()->SetFontColor(color); + x38_textpane_gba.x0_panes[0]->SetIsSelectable(false); + x30_textpane_cheats.x0_panes[0]->SetIsSelectable(false); for (int i=2 ; i>=0 ; --i) { SFileMenuOption& fileOpt = x64_fileSelections[i]; - const CGameState::GameFileStateInfo* data = x4_saveUI->GetGameData(i); - if (data) + if (x4_saveUI->GetGameData(i)) { - fileOpt.x4_textpanes[0].x0_panes[0]->SetIsSelectable(true); + fileOpt.x0_base->SetIsSelectable(true); x20_tablegroup_fileselect->SetUserSelection(i); } else { - fileOpt.x4_textpanes[0].x0_panes[0]->SetIsSelectable(false); + fileOpt.x0_base->SetIsSelectable(false); } } @@ -577,8 +619,7 @@ void CFrontEndUI::SNewFileSelectFrame::DoFileMenuAdvance(CGuiTableGroup* caller) { if (x8_subMenu == ESubMenu::EraseGame) { - const CGameState::GameFileStateInfo* data = x4_saveUI->GetGameData(userSel); - if (data) + if (x4_saveUI->GetGameData(userSel)) { PlayAdvanceSfx(); x10d_needsExistingToggle = true; @@ -586,9 +627,11 @@ void CFrontEndUI::SNewFileSelectFrame::DoFileMenuAdvance(CGuiTableGroup* caller) } else { - const CGameState::GameFileStateInfo* data = x4_saveUI->GetGameData(userSel); - if (data) + if (x4_saveUI->GetGameData(userSel)) + { + m_touchBar.SetPhase(CFrontEndUITouchBar::EPhase::None); x4_saveUI->StartGame(userSel); + } else x10e_needsNewToggle = true; } @@ -1760,6 +1803,9 @@ CFrontEndUI::CFrontEndUI() for (int i=0 ; CDvdFile::FileExists(GetAttractMovieFileName(i).c_str()) ; ++i) ++xc0_attractCount; + + m_touchBar = NewFrontEndUITouchBar(); + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None); } void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue) @@ -2113,9 +2159,13 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& if (x14_phase != EPhase::DisplayFrontEnd || input.ControllerIdx() != 0) return; + /* Pop most recent action from Touch Bar */ + CFrontEndUITouchBar::EAction touchBarAction = m_touchBar->PopAction(); + if (x50_curScreen != x54_nextScreen) { - if (x54_nextScreen == EScreen::AttractMovie && (input.PStart() || input.PA())) + if (x54_nextScreen == EScreen::AttractMovie && (input.PStart() || input.PA() || + touchBarAction == CFrontEndUITouchBar::EAction::Start)) { /* Player wants to return to opening credits from attract movie */ SetFadeBlackTimer(std::min(1.f, x58_fadeBlackTimer)); @@ -2123,7 +2173,7 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& return; } - if (input.PA() || input.PStart()) + if (input.PA() || input.PStart() || touchBarAction == CFrontEndUITouchBar::EAction::Start) { if (x50_curScreen == EScreen::OpenCredits && x54_nextScreen == EScreen::Title && x58_fadeBlackTimer > 1.f) @@ -2139,13 +2189,14 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& { if (x50_curScreen == EScreen::Title) { - if (input.PStart() || input.PA()) + if (input.PStart() || input.PA() || touchBarAction == CFrontEndUITouchBar::EAction::Start) { if (x58_fadeBlackTimer < 30.f - g_tweakGame->GetPressStartDelay()) { /* Proceed to file select UI */ CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][1], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None); StartStateTransition(EScreen::FileSelect); return; } @@ -2165,15 +2216,18 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& else if (xe0_frontendCardFrme) { /* Control FrontEnd with memory card */ - switch (xe0_frontendCardFrme->ProcessUserInput(input)) + switch (xe0_frontendCardFrme->ProcessUserInput(input, touchBarAction)) { case SNewFileSelectFrame::EAction::FusionBonus: + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None); StartStateTransition(EScreen::FusionBonus); return; case SNewFileSelectFrame::EAction::GameOptions: + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None); xf0_optionsFrme = std::make_unique(); return; case SNewFileSelectFrame::EAction::SlideShow: + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None); xd2_deferSlideShow = true; StartSlideShow(queue); return; @@ -2291,7 +2345,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue) /* Poll loading DGRP resources */ if (PumpLoad()) { - xe0_frontendCardFrme = std::make_unique(xdc_saveUI.get(), x1c_rndB); + xe0_frontendCardFrme = std::make_unique(xdc_saveUI.get(), x1c_rndB, *m_touchBar); xe4_fusionBonusFrme = std::make_unique(); xe8_frontendNoCardFrme = std::make_unique(x1c_rndB); x38_pressStart.GetObj(); @@ -2337,6 +2391,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue) { /* Ready to display FrontEnd */ x14_phase = EPhase::DisplayFrontEnd; + m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::PressStart); StartStateTransition(EScreen::Title); } else diff --git a/Runtime/MP1/CFrontEndUI.hpp b/Runtime/MP1/CFrontEndUI.hpp index 480a3546c..a5b5aee3b 100644 --- a/Runtime/MP1/CFrontEndUI.hpp +++ b/Runtime/MP1/CFrontEndUI.hpp @@ -13,6 +13,7 @@ #include "GuiSys/CGuiTextSupport.hpp" #include "Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Graphics/Shaders/CColoredQuadFilter.hpp" +#include "CFrontEndUITouchBar.hpp" namespace urde { @@ -142,12 +143,14 @@ public: bool x10d_needsExistingToggle = false; bool x10e_needsNewToggle = false; - SNewFileSelectFrame(CSaveUI* sui, u32 rnd); + CFrontEndUITouchBar& m_touchBar; + + SNewFileSelectFrame(CSaveUI* sui, u32 rnd, CFrontEndUITouchBar& touchBar); void FinishedLoading(); bool PumpLoad(); bool IsTextDoneAnimating() const; void Update(float dt); - EAction ProcessUserInput(const CFinalInput& input); + EAction ProcessUserInput(const CFinalInput& input, CFrontEndUITouchBar::EAction tbAction); void Draw() const; void HandleActiveChange(CGuiTableGroup* active); @@ -408,6 +411,8 @@ private: CColoredQuadFilter m_fadeToBlack = {CCameraFilterPass::EFilterType::Blend}; std::experimental::optional m_pressStartQuad; + std::unique_ptr m_touchBar; + void SetFadeBlackWithMovie() { x58_fadeBlackTimer = 1000000.f; diff --git a/Runtime/MP1/CFrontEndUITouchBar.cpp b/Runtime/MP1/CFrontEndUITouchBar.cpp new file mode 100644 index 000000000..9254eddb1 --- /dev/null +++ b/Runtime/MP1/CFrontEndUITouchBar.cpp @@ -0,0 +1,19 @@ +#include "CFrontEndUITouchBar.hpp" + +namespace urde +{ + +CFrontEndUITouchBar::~CFrontEndUITouchBar() {} +void CFrontEndUITouchBar::SetPhase(EPhase ph) {} +void CFrontEndUITouchBar::SetFileSelectPhase(const SFileSelectDetail details[3], + bool eraseGame, bool galleryActive) {} +CFrontEndUITouchBar::EAction CFrontEndUITouchBar::PopAction() { return EAction::None; } + +#ifndef __APPLE__ +std::unique_ptr NewFrontEndUITouchBar() +{ + return std::make_unique(); +} +#endif + +} diff --git a/Runtime/MP1/CFrontEndUITouchBar.hpp b/Runtime/MP1/CFrontEndUITouchBar.hpp new file mode 100644 index 000000000..e87912ed6 --- /dev/null +++ b/Runtime/MP1/CFrontEndUITouchBar.hpp @@ -0,0 +1,54 @@ +#ifndef __URDE_CFRONTENDUITOUCHBAR_HPP__ +#define __URDE_CFRONTENDUITOUCHBAR_HPP__ + +#include + +namespace urde +{ + +class CFrontEndUITouchBar +{ +public: + enum class EPhase + { + None, + PressStart, + BackConfirm, + FileSelect + }; + enum class EAction + { + None, + Start, + Back, + Confirm, + FileA, + FileB, + FileC, + FusionBonus, + ImageGallery + }; + enum class EFileState + { + New, + Normal, + Hard + }; + struct SFileSelectDetail + { + EFileState state; + int percent; + }; + + virtual ~CFrontEndUITouchBar(); + virtual void SetPhase(EPhase ph); + virtual void SetFileSelectPhase(const SFileSelectDetail details[3], + bool eraseGame, bool galleryActive); + virtual EAction PopAction(); +}; + +std::unique_ptr NewFrontEndUITouchBar(); + +} + +#endif // __URDE_CFRONTENDUITOUCHBAR_HPP__ diff --git a/Runtime/MP1/CFrontEndUITouchBarMac.mm b/Runtime/MP1/CFrontEndUITouchBarMac.mm new file mode 100644 index 000000000..aba0c9edb --- /dev/null +++ b/Runtime/MP1/CFrontEndUITouchBarMac.mm @@ -0,0 +1,258 @@ +#include +#include "CFrontEndUITouchBar.hpp" +#include "GameGlobalObjects.hpp" +#include "MP1/MP1.hpp" + +#if !__has_feature(objc_arc) +#error ARC Required +#endif + +extern "C" uint8_t START_BUTTON_2X[]; +extern "C" size_t START_BUTTON_2X_SZ; + +@interface FrontEndUITouchBarPressStart : NSObject +{ +@public + BOOL _startPressed; +} +-(IBAction)onPressStart:(id)sender; +@end + +@implementation FrontEndUITouchBarPressStart +- (NSTouchBar*)makeTouchBar +{ + NSTouchBar* touchBar = [NSTouchBar new]; + touchBar.delegate = self; + id items = @[@"pressStartGroup"]; + touchBar.customizationRequiredItemIdentifiers = items; + touchBar.defaultItemIdentifiers = items; + touchBar.principalItemIdentifier = @"pressStartGroup"; + return touchBar; +} +-(NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar + makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier +{ + if ([identifier isEqualToString:@"pressStartGroup"]) + { + NSGroupTouchBarItem* group = [[NSGroupTouchBarItem alloc] initWithIdentifier:identifier]; + NSTouchBar* touchBar = [NSTouchBar new]; + touchBar.delegate = self; + id items = @[@"pressStart"]; + touchBar.customizationRequiredItemIdentifiers = items; + touchBar.defaultItemIdentifiers = items; + group.groupTouchBar = touchBar; + return group; + } + else if ([identifier isEqualToString:@"pressStart"]) + { + NSData* imgData = [NSData dataWithBytesNoCopy:START_BUTTON_2X length:START_BUTTON_2X_SZ freeWhenDone:NO]; + NSImage* img = [[NSImage alloc] initWithData:imgData]; + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:@"Start" image:img target:self action:@selector(onPressStart:)]; + button.imageHugsTitle = YES; + pressStart.view = button; + return pressStart; + } + return nil; +} +-(IBAction)onPressStart:(id)sender +{ + _startPressed = YES; +} +@end + +static NSString* GetFileSelectTitle(const urde::CFrontEndUITouchBar::SFileSelectDetail& detail, char letter) +{ + switch (detail.state) + { + case urde::CFrontEndUITouchBar::EFileState::New: + return [NSString stringWithFormat:@"[New Game %c]", letter]; + case urde::CFrontEndUITouchBar::EFileState::Normal: + return [NSString stringWithFormat:@"[Samus %c] %d%%", letter, detail.percent]; + case urde::CFrontEndUITouchBar::EFileState::Hard: + return [NSString stringWithFormat:@"[Hard %c] %d%%", letter, detail.percent]; + } + return @""; +} + +@interface FrontEndUITouchBarFileSelect : NSObject +{ +@public + urde::CFrontEndUITouchBar::SFileSelectDetail _details[3]; + urde::CFrontEndUITouchBar::EAction _action; + BOOL _eraseGame; + BOOL _galleryActive; +} +-(IBAction)onFileA:(id)sender; +-(IBAction)onFileB:(id)sender; +-(IBAction)onFileC:(id)sender; +-(IBAction)onFusionBonus:(id)sender; +-(IBAction)onImageGallery:(id)sender; +@end + +@implementation FrontEndUITouchBarFileSelect +- (NSTouchBar*)makeTouchBar +{ + NSTouchBar* touchBar = [NSTouchBar new]; + touchBar.delegate = self; + id items = @[@"fileSelectGroup"]; + touchBar.customizationRequiredItemIdentifiers = items; + touchBar.defaultItemIdentifiers = items; + touchBar.principalItemIdentifier = @"fileSelectGroup"; + return touchBar; +} +-(NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar + makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier +{ + if ([identifier isEqualToString:@"fileSelectGroup"]) + { + NSGroupTouchBarItem* group = [[NSGroupTouchBarItem alloc] initWithIdentifier:identifier]; + NSTouchBar* touchBar = [NSTouchBar new]; + touchBar.delegate = self; + id items = @[@"fileA", @"fileB", @"fileC", @"fusionBonus", @"imageGallery"]; + touchBar.customizationRequiredItemIdentifiers = items; + touchBar.defaultItemIdentifiers = items; + group.groupTouchBar = touchBar; + return group; + } + else if ([identifier isEqualToString:@"fileA"]) + { + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:GetFileSelectTitle(_details[0], 'A') target:self action:@selector(onFileA:)]; + button.enabled = !_eraseGame || _details[0].state != urde::CFrontEndUITouchBar::EFileState::New; + pressStart.view = button; + return pressStart; + } + else if ([identifier isEqualToString:@"fileB"]) + { + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:GetFileSelectTitle(_details[1], 'B') target:self action:@selector(onFileB:)]; + button.enabled = !_eraseGame || _details[1].state != urde::CFrontEndUITouchBar::EFileState::New; + pressStart.view = button; + return pressStart; + } + else if ([identifier isEqualToString:@"fileC"]) + { + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:GetFileSelectTitle(_details[2], 'C') target:self action:@selector(onFileC:)]; + button.enabled = !_eraseGame || _details[2].state != urde::CFrontEndUITouchBar::EFileState::New; + pressStart.view = button; + return pressStart; + } + else if ([identifier isEqualToString:@"fusionBonus"]) + { + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:@"Fusion Bonuses" target:self action:@selector(onFusionBonus:)]; + button.enabled = !_eraseGame; + pressStart.view = button; + return pressStart; + } + else if ([identifier isEqualToString:@"imageGallery"]) + { + NSCustomTouchBarItem* pressStart = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSButton* button = [NSButton buttonWithTitle:@"Image Gallery" target:self action:@selector(onImageGallery:)]; + button.enabled = !_eraseGame && _galleryActive; + pressStart.view = button; + return pressStart; + } + return nil; +} +-(IBAction)onFileA:(id)sender +{ + _action = urde::CFrontEndUITouchBar::EAction::FileA; +} +-(IBAction)onFileB:(id)sender +{ + _action = urde::CFrontEndUITouchBar::EAction::FileB; +} +-(IBAction)onFileC:(id)sender +{ + _action = urde::CFrontEndUITouchBar::EAction::FileC; +} +-(IBAction)onFusionBonus:(id)sender +{ + _action = urde::CFrontEndUITouchBar::EAction::FusionBonus; +} +-(IBAction)onImageGallery:(id)sender +{ + _action = urde::CFrontEndUITouchBar::EAction::ImageGallery; +} +@end + +namespace urde +{ + +class CFrontEndUITouchBarMac : public CFrontEndUITouchBar +{ + EPhase m_phase = EPhase::None; + FrontEndUITouchBarPressStart* m_pressStartBar; + FrontEndUITouchBarFileSelect* m_fileSelectBar; + + void Activate() + { + id provider = nil; + switch (m_phase) + { + case EPhase::PressStart: + provider = m_pressStartBar; + break; + case EPhase::FileSelect: + provider = m_fileSelectBar; + break; + default: break; + } + g_Main->GetMainWindow()->setTouchBarProvider((__bridge_retained void*)provider); + } + +public: + CFrontEndUITouchBarMac() + { + m_pressStartBar = [FrontEndUITouchBarPressStart new]; + m_fileSelectBar = [FrontEndUITouchBarFileSelect new]; + } + void SetPhase(EPhase ph) + { + m_phase = ph; + Activate(); + } + void SetFileSelectPhase(const SFileSelectDetail details[3], bool eraseGame, bool galleryActive) + { + m_fileSelectBar->_details[0] = details[0]; + m_fileSelectBar->_details[1] = details[1]; + m_fileSelectBar->_details[2] = details[2]; + m_fileSelectBar->_eraseGame = eraseGame; + m_fileSelectBar->_galleryActive = galleryActive; + m_phase = EPhase::FileSelect; + Activate(); + } + EAction PopAction() + { + switch (m_phase) + { + case EPhase::PressStart: + if (m_pressStartBar->_startPressed) + { + m_pressStartBar->_startPressed = NO; + return EAction::Start; + } + break; + case EPhase::FileSelect: + if (m_fileSelectBar->_action != EAction::None) + { + EAction action = m_fileSelectBar->_action; + m_fileSelectBar->_action = EAction::None; + return action; + } + break; + default: break; + } + return EAction::None; + } +}; + +std::unique_ptr NewFrontEndUITouchBar() +{ + return std::make_unique(); +} + +} diff --git a/Runtime/MP1/CMakeLists.txt b/Runtime/MP1/CMakeLists.txt index 925da93e9..95d8b2b6f 100644 --- a/Runtime/MP1/CMakeLists.txt +++ b/Runtime/MP1/CMakeLists.txt @@ -1,6 +1,10 @@ include_directories(. ..) add_subdirectory(World) +if(APPLE) + set(MP1_PLAT_SOURCES CFrontEndUITouchBarMac.mm) +endif() + set(MP1_SOURCES CTweaks.hpp CTweaks.cpp CInGameTweakManager.hpp CInGameTweakManager.cpp @@ -10,6 +14,7 @@ set(MP1_SOURCES CMFGame.hpp CMFGame.cpp CPlayMovie.hpp CPlayMovie.cpp CFrontEndUI.hpp CFrontEndUI.cpp + CFrontEndUITouchBar.hpp CFrontEndUITouchBar.cpp CPreFrontEnd.hpp CPreFrontEnd.cpp CSlideShow.hpp CSlideShow.cpp CSaveUI.hpp CSaveUI.cpp @@ -19,6 +24,7 @@ set(MP1_SOURCES CStateSetterFlow.hpp CStateSetterFlow.cpp CAudioStateWin.hpp CAudioStateWin.cpp MP1.hpp MP1.cpp + ${MP1_PLAT_SOURCES} ${MP1_WORLD_SOURCES}) runtime_add_list(MP1 MP1_SOURCES) diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 53d53f700..0414ceb63 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -29,7 +29,8 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTextSupportShader) namespace MP1 { -CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, +CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, + boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) : m_parent(parent), x0_audioSys(voiceEngine, backend, 0,0,0,0,0), @@ -254,9 +255,11 @@ void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx) } void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, + boo::IWindow* window, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) { + m_mainWindow = window; InitializeSubsystems(storeMgr); x128_globalObjects.PostInitialize(); x70_tweaks.RegisterTweaks(); @@ -320,6 +323,11 @@ void CMain::Shutdown() TMultiBlendShader::Shutdown(); } +boo::IWindow* CMain::GetMainWindow() const +{ + return m_mainWindow; +} + #if MP1_USE_BOO int CMain::appMain(boo::IApplication* app) diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 2702bb1dd..c49691149 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -134,7 +134,8 @@ class CGameArchitectureSupport } public: - CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, + CGameArchitectureSupport(CMain& parent, + boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend); ~CGameArchitectureSupport(); @@ -235,6 +236,8 @@ private: std::unique_ptr x164_archSupport; + boo::IWindow* m_mainWindow = nullptr; + void InitializeSubsystems(const hecl::Runtime::FileStoreManager& storeMgr); public: @@ -249,11 +252,13 @@ public: //int RsMain(int argc, const boo::SystemChar* argv[]); void Init(const hecl::Runtime::FileStoreManager& storeMgr, + boo::IWindow* window, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend); bool Proc(); void Draw(); void Shutdown(); + boo::IWindow* GetMainWindow() const; void MemoryCardInitializePump() { diff --git a/Runtime/Resources/startButton@2x.png b/Runtime/Resources/startButton@2x.png new file mode 100644 index 000000000..82635d819 Binary files /dev/null and b/Runtime/Resources/startButton@2x.png differ diff --git a/hecl b/hecl index 532fd0ede..4ab6eab56 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 532fd0ede4078a0c3cf88868a53932a46f575676 +Subproject commit 4ab6eab5641b4f77e187e602d812db4c43be8106