ES-DE/es-app/src/views/gamelist/IGameListView.cpp

56 lines
1.5 KiB
C++
Raw Normal View History

#include "views/gamelist/IGameListView.h"
2017-11-01 22:21:10 +00:00
#include "guis/GuiGamelistOptions.h"
#include "views/ViewController.h"
#include "Sound.h"
2017-11-01 22:21:10 +00:00
#include "Window.h"
bool IGameListView::input(InputConfig* config, Input input)
{
// select to open GuiGamelistOptions
if(config->isMappedTo("select", input) && input.value)
{
Sound::getFromTheme(mTheme, getName(), "menuOpen")->play();
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem()));
return true;
// Ctrl-R to reload a view when debugging
}else if(Settings::getInstance()->getBool("Debug") && config->getDeviceId() == DEVICE_KEYBOARD &&
(SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && input.value != 0)
{
LOG(LogDebug) << "reloading view";
ViewController::get()->reloadGameListView(this, true);
return true;
}
return GuiComponent::input(config, input);
}
void IGameListView::setTheme(const std::shared_ptr<ThemeData>& theme)
{
mTheme = theme;
onThemeChanged(theme);
}
HelpStyle IGameListView::getHelpStyle()
{
HelpStyle style;
style.applyTheme(mTheme, getName());
return style;
}
void IGameListView::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
float scaleX = trans.r0().x();
float scaleY = trans.r1().y();
Vector2i pos(trans.translation()[0], trans.translation()[1]);
Vector2i size(mSize.x() * scaleX, mSize.y() * scaleY);
Renderer::pushClipRect(pos, size);
renderChildren(trans);
Renderer::popClipRect();
}