mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
First version of the system select menu.
This commit is contained in:
parent
abb568aa6e
commit
7152ca6246
|
@ -197,6 +197,8 @@ set(ES_HEADERS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/DetailedGameListView.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GameListView.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GridGameListView.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemListView.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/Animation.h
|
||||
|
@ -272,6 +274,8 @@ set(ES_SOURCES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/DetailedGameListView.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GameListView.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GridGameListView.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemListView.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/AnimationController.cpp
|
||||
|
|
|
@ -122,6 +122,8 @@ Pretty much any image format is supported.
|
|||
|
||||
`<verticalDividerImage>` - No default.
|
||||
|
||||
`<systemImage>` - No default. Large image, shown in the system select menu.
|
||||
|
||||
`<fastSelectBackgroundImage>` - Nine patch. Default is the "button.png" resource.
|
||||
|
||||
Sounds
|
||||
|
|
|
@ -28,7 +28,8 @@ std::map<std::string, ImageDef> ThemeData::sDefaultImages = boost::assign::map_l
|
|||
("headerImage", ImageDef("", false))
|
||||
("infoBackgroundImage", ImageDef("", false))
|
||||
("verticalDividerImage", ImageDef("", false))
|
||||
("fastSelectBackgroundImage", ImageDef(":/button.png", false));
|
||||
("fastSelectBackgroundImage", ImageDef(":/button.png", false))
|
||||
("systemImage", ImageDef("", false));
|
||||
|
||||
std::map<std::string, SoundDef> ThemeData::sDefaultSounds = boost::assign::map_list_of
|
||||
("scrollSound", SoundDef(""))
|
||||
|
|
|
@ -169,12 +169,12 @@ bool BasicGameListView::input(InputConfig* config, Input input)
|
|||
}else if(config->isMappedTo("right", input))
|
||||
{
|
||||
mList.stopScrolling();
|
||||
mWindow->getViewController()->goToNextSystem();
|
||||
mWindow->getViewController()->goToNextGameList();
|
||||
return true;
|
||||
}else if(config->isMappedTo("left", input))
|
||||
{
|
||||
mList.stopScrolling();
|
||||
mWindow->getViewController()->goToPrevSystem();
|
||||
mWindow->getViewController()->goToPrevGameList();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
78
src/views/SystemListView.cpp
Normal file
78
src/views/SystemListView.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
#include "SystemListView.h"
|
||||
#include "../Renderer.h"
|
||||
#include "../SystemData.h"
|
||||
#include "../animations/MoveCameraAnimation.h"
|
||||
#include "../Window.h"
|
||||
#include "ViewController.h"
|
||||
|
||||
SystemListView::SystemListView(Window* window) : GuiComponent(window), mCamera(Eigen::Affine3f::Identity()), mCurrentSystem(NULL)
|
||||
{
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
|
||||
goToSystem(SystemData::sSystemVector.at(0));
|
||||
}
|
||||
|
||||
void SystemListView::goToSystem(SystemData* system)
|
||||
{
|
||||
std::shared_ptr<SystemView> view = getSystemView(system);
|
||||
mCurrentView = view;
|
||||
mCurrentSystem = system;
|
||||
setAnimation(new MoveCameraAnimation(mCamera, view->getPosition()));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<SystemView> SystemListView::getSystemView(SystemData* system)
|
||||
{
|
||||
auto exists = mSystemViews.find(system);
|
||||
if(exists != mSystemViews.end())
|
||||
return exists->second;
|
||||
|
||||
const std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
||||
int id = std::find(sysVec.begin(), sysVec.end(), system) - sysVec.begin();
|
||||
|
||||
std::shared_ptr<SystemView> view = std::shared_ptr<SystemView>(new SystemView(mWindow, system));
|
||||
view->setPosition(id * (float)Renderer::getScreenWidth(), 0);
|
||||
|
||||
mSystemViews[system] = view;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
bool SystemListView::input(InputConfig* config, Input input)
|
||||
{
|
||||
if(input.value != 0)
|
||||
{
|
||||
int id = std::find(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(), mCurrentSystem) - SystemData::sSystemVector.begin();
|
||||
if(config->isMappedTo("left", input))
|
||||
{
|
||||
id--;
|
||||
if(id < 0)
|
||||
id += SystemData::sSystemVector.size();
|
||||
goToSystem(SystemData::sSystemVector.at(id));
|
||||
return true;
|
||||
}
|
||||
if(config->isMappedTo("right", input))
|
||||
{
|
||||
id = (id + 1) % SystemData::sSystemVector.size();
|
||||
goToSystem(SystemData::sSystemVector.at(id));
|
||||
return true;
|
||||
}
|
||||
if(config->isMappedTo("a", input))
|
||||
{
|
||||
mWindow->getViewController()->goToGameList(mCurrentSystem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return GuiComponent::input(config, input);
|
||||
}
|
||||
|
||||
void SystemListView::render(const Eigen::Affine3f& parentTrans)
|
||||
{
|
||||
Eigen::Affine3f trans = mCamera * getTransform() * parentTrans;
|
||||
|
||||
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
|
||||
{
|
||||
it->second->render(trans);
|
||||
}
|
||||
}
|
23
src/views/SystemListView.h
Normal file
23
src/views/SystemListView.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "SystemView.h"
|
||||
|
||||
class SystemListView : public GuiComponent
|
||||
{
|
||||
public:
|
||||
SystemListView(Window* window);
|
||||
|
||||
void goToSystem(SystemData* system);
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void render(const Eigen::Affine3f& parentTrans) override;
|
||||
|
||||
private:
|
||||
Eigen::Affine3f mCamera;
|
||||
|
||||
std::shared_ptr<SystemView> mCurrentView;
|
||||
SystemData* mCurrentSystem;
|
||||
std::shared_ptr<SystemView> getSystemView(SystemData* system);
|
||||
|
||||
std::map< SystemData*, std::shared_ptr<SystemView> > mSystemViews;
|
||||
};
|
47
src/views/SystemView.cpp
Normal file
47
src/views/SystemView.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "SystemView.h"
|
||||
#include "../SystemData.h"
|
||||
#include "../Renderer.h"
|
||||
#include "../Log.h"
|
||||
|
||||
SystemView::SystemView(Window* window, SystemData* system) : GuiComponent(window),
|
||||
mSystem(system),
|
||||
|
||||
mHeaderImage(window),
|
||||
mHeaderText(window),
|
||||
mImage(window)
|
||||
{
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
|
||||
mHeaderImage.setOrigin(0.5f, 0.0f);
|
||||
mHeaderImage.setPosition(mSize.x() / 2, 0);
|
||||
mHeaderImage.setResize(0, mSize.y() * 0.2f, true);
|
||||
|
||||
mHeaderText.setSize(mSize.x(), 0);
|
||||
mHeaderText.setCentered(true);
|
||||
|
||||
mImage.setOrigin(0.5f, 0.5f);
|
||||
mImage.setPosition(mSize.x() / 2, mSize.y() / 2);
|
||||
|
||||
addChild(&mImage);
|
||||
addChild(&mHeaderText);
|
||||
addChild(&mHeaderImage);
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
void SystemView::updateData()
|
||||
{
|
||||
// header
|
||||
if(mSystem->getTheme()->getImage("headerImage").path.empty())
|
||||
{
|
||||
// use text
|
||||
mHeaderImage.setImage("");
|
||||
mHeaderText.setText(mSystem->getFullName());
|
||||
}else{
|
||||
// use image
|
||||
mHeaderText.setText("");
|
||||
mHeaderImage.setImage(mSystem->getTheme()->getImage("headerImage").getTexture());
|
||||
}
|
||||
|
||||
mImage.setImage(mSystem->getTheme()->getImage("systemImage").getTexture());
|
||||
}
|
23
src/views/SystemView.h
Normal file
23
src/views/SystemView.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "../GuiComponent.h"
|
||||
#include "../components/ImageComponent.h"
|
||||
#include "../components/TextComponent.h"
|
||||
#include "../components/ScrollableContainer.h"
|
||||
|
||||
class SystemData;
|
||||
|
||||
class SystemView : public GuiComponent
|
||||
{
|
||||
public:
|
||||
SystemView(Window* window, SystemData* system);
|
||||
|
||||
void updateData();
|
||||
|
||||
private:
|
||||
SystemData* mSystem;
|
||||
|
||||
TextComponent mHeaderText;
|
||||
ImageComponent mHeaderImage;
|
||||
ImageComponent mImage;
|
||||
};
|
|
@ -17,8 +17,9 @@ ViewController::ViewController(Window* window)
|
|||
void ViewController::goToSystemSelect()
|
||||
{
|
||||
mState.viewing = SYSTEM_SELECT;
|
||||
goToSystem(SystemData::sSystemVector.at(0));
|
||||
//playViewTransition();
|
||||
mCurrentView = getSystemListView();
|
||||
playViewTransition();
|
||||
LOG(LogInfo) << "going to system select";
|
||||
}
|
||||
|
||||
SystemData* getSystemCyclic(SystemData* from, bool reverse)
|
||||
|
@ -43,7 +44,7 @@ SystemData* getSystemCyclic(SystemData* from, bool reverse)
|
|||
}
|
||||
}
|
||||
|
||||
void ViewController::goToNextSystem()
|
||||
void ViewController::goToNextGameList()
|
||||
{
|
||||
assert(mState.viewing == SYSTEM);
|
||||
|
||||
|
@ -51,10 +52,10 @@ void ViewController::goToNextSystem()
|
|||
if(system == NULL)
|
||||
return;
|
||||
|
||||
goToSystem(getSystemCyclic(system, false));
|
||||
goToGameList(getSystemCyclic(system, false));
|
||||
}
|
||||
|
||||
void ViewController::goToPrevSystem()
|
||||
void ViewController::goToPrevGameList()
|
||||
{
|
||||
assert(mState.viewing == SYSTEM);
|
||||
|
||||
|
@ -62,15 +63,15 @@ void ViewController::goToPrevSystem()
|
|||
if(system == NULL)
|
||||
return;
|
||||
|
||||
goToSystem(getSystemCyclic(system, true));
|
||||
goToGameList(getSystemCyclic(system, true));
|
||||
}
|
||||
|
||||
void ViewController::goToSystem(SystemData* system)
|
||||
void ViewController::goToGameList(SystemData* system)
|
||||
{
|
||||
mState.viewing = SYSTEM;
|
||||
mState.viewing = GAME_LIST;
|
||||
mState.data.system = system;
|
||||
|
||||
mCurrentView = getSystemView(system);
|
||||
mCurrentView = getGameListView(system);
|
||||
playViewTransition();
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ void ViewController::playViewTransition()
|
|||
|
||||
void ViewController::onFileChanged(FileData* file, FileChangeType change)
|
||||
{
|
||||
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
|
||||
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
|
||||
{
|
||||
it->second->onFileChanged(file, change);
|
||||
}
|
||||
|
@ -108,11 +109,11 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
|
|||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<GameListView> ViewController::getSystemView(SystemData* system)
|
||||
std::shared_ptr<GameListView> ViewController::getGameListView(SystemData* system)
|
||||
{
|
||||
//if we already made one, return that one
|
||||
auto exists = mSystemViews.find(system);
|
||||
if(exists != mSystemViews.end())
|
||||
auto exists = mGameListViews.find(system);
|
||||
if(exists != mGameListViews.end())
|
||||
return exists->second;
|
||||
|
||||
//if we didn't, make it, remember it, and return it
|
||||
|
@ -146,12 +147,22 @@ std::shared_ptr<GameListView> ViewController::getSystemView(SystemData* system)
|
|||
|
||||
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
||||
int id = std::find(sysVec.begin(), sysVec.end(), system) - sysVec.begin();
|
||||
view->setPosition(id * (float)Renderer::getScreenWidth(), 0);
|
||||
view->setPosition(id * (float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight() * 2);
|
||||
|
||||
mSystemViews[system] = view;
|
||||
mGameListViews[system] = view;
|
||||
return view;
|
||||
}
|
||||
|
||||
std::shared_ptr<SystemListView> ViewController::getSystemListView()
|
||||
{
|
||||
if(!mSystemListView)
|
||||
{
|
||||
mSystemListView = std::shared_ptr<SystemListView>(new SystemListView(mWindow));
|
||||
mSystemListView->setPosition(0, (float)Renderer::getScreenHeight());
|
||||
}
|
||||
|
||||
return mSystemListView;
|
||||
}
|
||||
|
||||
|
||||
bool ViewController::input(InputConfig* config, Input input)
|
||||
|
@ -180,8 +191,11 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
|
|||
Eigen::Vector3f viewStart = trans.inverse().translation();
|
||||
Eigen::Vector3f viewEnd = trans.inverse() * Eigen::Vector3f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight(), 0);
|
||||
|
||||
// draw systems
|
||||
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
|
||||
// draw systemlist
|
||||
mSystemListView->render(trans);
|
||||
|
||||
// draw gamelists
|
||||
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
|
||||
{
|
||||
// clipping
|
||||
Eigen::Vector3f guiStart = it->second->getPosition();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameListView.h"
|
||||
#include "SystemListView.h"
|
||||
|
||||
class SystemData;
|
||||
|
||||
|
@ -10,9 +11,9 @@ public:
|
|||
ViewController(Window* window);
|
||||
|
||||
// Navigation.
|
||||
void goToNextSystem();
|
||||
void goToPrevSystem();
|
||||
void goToSystem(SystemData* system);
|
||||
void goToNextGameList();
|
||||
void goToPrevGameList();
|
||||
void goToGameList(SystemData* system);
|
||||
void goToSystemSelect();
|
||||
|
||||
void onFileChanged(FileData* file, FileChangeType change);
|
||||
|
@ -29,14 +30,14 @@ public:
|
|||
{
|
||||
START_SCREEN,
|
||||
SYSTEM_SELECT,
|
||||
SYSTEM
|
||||
GAME_LIST
|
||||
};
|
||||
|
||||
struct State
|
||||
{
|
||||
ViewMode viewing;
|
||||
|
||||
inline SystemData* getSystem() const { assert(viewing == SYSTEM); return data.system; }
|
||||
inline SystemData* getSystem() const { assert(viewing == GAME_LIST); return data.system; }
|
||||
|
||||
private:
|
||||
friend ViewController;
|
||||
|
@ -50,11 +51,13 @@ public:
|
|||
|
||||
private:
|
||||
void playViewTransition();
|
||||
std::shared_ptr<GameListView> getSystemView(SystemData* system);
|
||||
|
||||
std::shared_ptr<GameListView> getGameListView(SystemData* system);
|
||||
std::shared_ptr<SystemListView> getSystemListView();
|
||||
|
||||
std::shared_ptr<GuiComponent> mCurrentView;
|
||||
std::map< SystemData*, std::shared_ptr<GameListView> > mSystemViews;
|
||||
|
||||
std::map< SystemData*, std::shared_ptr<GameListView> > mGameListViews;
|
||||
std::shared_ptr<SystemListView> mSystemListView;
|
||||
|
||||
Eigen::Affine3f mCamera;
|
||||
float mFadeOpacity;
|
||||
|
||||
|
|
Loading…
Reference in a new issue