mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
More work.
This commit is contained in:
parent
04841ca436
commit
4747d70e1f
|
@ -2,7 +2,7 @@ CXX=g++
|
|||
CXXFLAGS=-Wall -g -O2
|
||||
LDFLAGS=
|
||||
|
||||
SRC_SOURCES=AudioManager.cpp InputConfig.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp Gui.cpp InputManager.cpp main.cpp MathExp.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiInputConfig.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SRC_SOURCES=AudioManager.cpp Window.cpp InputConfig.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp Gui.cpp InputManager.cpp main.cpp MathExp.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiInputConfig.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SOURCES=$(addprefix src/,$(SRC_SOURCES))
|
||||
OBJECTS=$(SOURCES:.cpp=.o)
|
||||
DEPS=$(SOURCES:.cpp=.d)
|
||||
|
|
|
@ -9,3 +9,9 @@ Gui::~Gui()
|
|||
{
|
||||
mWindow->removeGui(this);
|
||||
}
|
||||
|
||||
void Gui::setOffset(int x, int y) { mOffsetX = x; mOffsetY = y; }
|
||||
void Gui::setOffsetX(int x) { mOffsetX = x; }
|
||||
void Gui::setOffsetY(int y) { mOffsetY = y; }
|
||||
int Gui::getOffsetX() { return mOffsetX; }
|
||||
int Gui::getOffsetY() { return mOffsetY; }
|
||||
|
|
12
src/Gui.h
12
src/Gui.h
|
@ -14,7 +14,19 @@ public:
|
|||
virtual void input(InputConfig* config, Input input) { };
|
||||
virtual void update(int deltaTime) { };
|
||||
virtual void render() { };
|
||||
|
||||
virtual void init() { };
|
||||
virtual void deinit() { };
|
||||
|
||||
void setOffsetX(int x);
|
||||
void setOffsetY(int y);
|
||||
void setOffset(int x, int y);
|
||||
int getOffsetX();
|
||||
int getOffsetY();
|
||||
protected:
|
||||
int mOffsetX;
|
||||
int mOffsetY;
|
||||
|
||||
Window* mWindow;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,16 +14,8 @@ class Font;
|
|||
//Defined in multiple files - Renderer.cpp has the GuiComponent stuff, Renderer_draw_* includes renderer-specific drawing implementations, and Renderer_init_* includes renderer-specific init/deinit.
|
||||
namespace Renderer
|
||||
{
|
||||
void registerComponent(GuiComponent* comp);
|
||||
void unregisterComponent(GuiComponent* comp);
|
||||
void deleteAll();
|
||||
|
||||
bool init(int w, int h);
|
||||
void onInit();
|
||||
void deinit();
|
||||
void onDeinit();
|
||||
|
||||
void render();
|
||||
|
||||
unsigned int getScreenWidth();
|
||||
unsigned int getScreenHeight();
|
||||
|
|
|
@ -80,14 +80,11 @@ namespace Renderer
|
|||
glOrtho(0, display_width, display_height, 0, -1.0, 1.0);
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
onInit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void deinit()
|
||||
{
|
||||
onDeinit();
|
||||
destroySurface();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -47,6 +47,22 @@ void Window::render()
|
|||
}
|
||||
}
|
||||
|
||||
void Window::init()
|
||||
{
|
||||
for(unsigned int i = 0; i < mGuiStack.size(); i++)
|
||||
{
|
||||
mGuiStack.at(i)->init();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::deinit()
|
||||
{
|
||||
for(unsigned int i = 0; i < mGuiStack.size(); i++)
|
||||
{
|
||||
mGuiStack.at(i)->deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::input(InputConfig* config, Input input)
|
||||
{
|
||||
if(peekGui())
|
||||
|
@ -63,8 +79,3 @@ InputManager* Window::getInputManager()
|
|||
{
|
||||
return mInputManager;
|
||||
}
|
||||
|
||||
asIScriptEngine* Window::getScriptEngine()
|
||||
{
|
||||
return mScriptEngine;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ public:
|
|||
void update(int deltaTime);
|
||||
void render();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
|
||||
InputManager* getInputManager();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "GuiBox.h"
|
||||
|
||||
GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height)
|
||||
GuiBox::GuiBox(Window* window, int offsetX, int offsetY, unsigned int width, unsigned int height) : Gui(window), mBackgroundImage(window),
|
||||
mHorizontalImage(window), mVerticalImage(window), mCornerImage(window)
|
||||
{
|
||||
setOffsetX(offsetX);
|
||||
setOffsetY(offsetY);
|
||||
|
@ -112,14 +113,10 @@ void GuiBox::render()
|
|||
|
||||
void GuiBox::onInit()
|
||||
{
|
||||
mHorizontalImage.init();
|
||||
mVerticalImage.init();
|
||||
}
|
||||
|
||||
void GuiBox::onDeinit()
|
||||
{
|
||||
mHorizontalImage.deinit();
|
||||
mVerticalImage.deinit();
|
||||
}
|
||||
|
||||
int GuiBox::getHorizontalBorderWidth()
|
||||
|
|
|
@ -16,10 +16,10 @@ struct GuiBoxData
|
|||
std::string cornerPath;
|
||||
};
|
||||
|
||||
class GuiBox
|
||||
class GuiBox : public Gui
|
||||
{
|
||||
public:
|
||||
GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height);
|
||||
GuiBox(Window* window, int offsetX, int offsetY, unsigned int width, unsigned int height);
|
||||
|
||||
void setData(GuiBoxData data);
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "GuiFastSelect.h"
|
||||
#include "../Renderer.h"
|
||||
#include <iostream>
|
||||
#include "GuiGameList.h"
|
||||
|
||||
const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const int GuiFastSelect::SCROLLSPEED = 100;
|
||||
const int GuiFastSelect::SCROLLDELAY = 507;
|
||||
|
||||
GuiFastSelect::GuiFastSelect(Window* window, GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data,
|
||||
GuiFastSelect::GuiFastSelect(Window* window, GuiGameList* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data,
|
||||
int textcolor, Sound* scrollsound, Font* font) : Gui(window)
|
||||
{
|
||||
mLetterID = LETTERS.find(toupper(startLetter));
|
||||
|
@ -23,7 +24,7 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiComponent* parent, GuiList<FileD
|
|||
mScrollOffset = 0;
|
||||
|
||||
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
||||
mBox = new GuiBox(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6);
|
||||
mBox = new GuiBox(window, sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6);
|
||||
mBox->setData(data);
|
||||
|
||||
mTextColor = textcolor;
|
||||
|
@ -31,6 +32,7 @@ GuiFastSelect::GuiFastSelect(Window* window, GuiComponent* parent, GuiList<FileD
|
|||
|
||||
GuiFastSelect::~GuiFastSelect()
|
||||
{
|
||||
mParent->updateDetailData();
|
||||
delete mBox;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
#include "GuiList.h"
|
||||
#include "GuiBox.h"
|
||||
|
||||
class GuiGameList;
|
||||
|
||||
class GuiFastSelect : Gui
|
||||
{
|
||||
public:
|
||||
GuiFastSelect(Window* window, GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font);
|
||||
GuiFastSelect(Window* window, GuiGameList* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font);
|
||||
~GuiFastSelect();
|
||||
|
||||
void input(InputConfig* config, Input input);
|
||||
|
@ -29,7 +31,7 @@ private:
|
|||
GuiList<FileData*>* mList;
|
||||
|
||||
size_t mLetterID;
|
||||
GuiComponent* mParent;
|
||||
GuiGameList* mParent;
|
||||
|
||||
GuiBox* mBox;
|
||||
int mTextColor;
|
||||
|
|
|
@ -22,11 +22,10 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : Gui(window)
|
|||
mScreenshot = new GuiImage(mWindow, Renderer::getScreenWidth() * mTheme->getFloat("gameImageOffsetX"), Renderer::getScreenHeight() * mTheme->getFloat("gameImageOffsetY"), "", mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false);
|
||||
mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY"));
|
||||
|
||||
//the animation renders the screenshot
|
||||
mImageAnimation = new GuiAnimation();
|
||||
mImageAnimation->addChild(mScreenshot);
|
||||
}else{
|
||||
mList = new GuiList<FileData*>(0, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
|
||||
mList = new GuiList<FileData*>(mWindow, 0, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
|
||||
mScreenshot = NULL;
|
||||
mImageAnimation = NULL;
|
||||
}
|
||||
|
@ -97,7 +96,11 @@ void GuiGameList::render()
|
|||
if(!desc.empty())
|
||||
Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03), mTheme->getColor("description"), mTheme->getDescriptionFont());
|
||||
}
|
||||
|
||||
mScreenshot->render();
|
||||
}
|
||||
|
||||
mList->render();
|
||||
}
|
||||
|
||||
void GuiGameList::input(InputConfig* config, Input input)
|
||||
|
@ -119,7 +122,7 @@ void GuiGameList::input(InputConfig* config, Input input)
|
|||
//wait for the sound to finish or we'll never hear it...
|
||||
while(mTheme->getSound("menuSelect")->isPlaying());
|
||||
|
||||
mSystem->launchGame((GameData*)file);
|
||||
mSystem->launchGame(mWindow, (GameData*)file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +154,7 @@ void GuiGameList::input(InputConfig* config, Input input)
|
|||
//open the "start menu"
|
||||
if(config->isMappedTo("menu", input) && input.value != 0)
|
||||
{
|
||||
new GuiMenu(this);
|
||||
new GuiMenu(mWindow, this);
|
||||
}
|
||||
|
||||
//open the fast select menu
|
||||
|
@ -297,5 +300,7 @@ GuiGameList* GuiGameList::create(Window* window)
|
|||
}
|
||||
}
|
||||
|
||||
return new GuiGameList(window, detailed);
|
||||
GuiGameList* list = new GuiGameList(window, detailed);
|
||||
window->pushGui(list);
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
class GuiGameList : public Gui
|
||||
{
|
||||
public:
|
||||
GuiGameList(bool useDetail = false);
|
||||
GuiGameList(Window* window, bool useDetail = false);
|
||||
~GuiGameList();
|
||||
|
||||
void setSystemId(int id);
|
||||
|
@ -28,13 +28,14 @@ public:
|
|||
void onInit();
|
||||
void onDeinit();
|
||||
|
||||
void updateDetailData();
|
||||
|
||||
static GuiGameList* create(Window* window);
|
||||
|
||||
static const float sInfoWidth;
|
||||
private:
|
||||
void updateList();
|
||||
void updateTheme();
|
||||
void updateDetailData();
|
||||
void clearDetailData();
|
||||
std::string getThemeFile();
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
#include <boost/filesystem.hpp>
|
||||
#include <math.h>
|
||||
#include "../Log.h"
|
||||
#include "../Renderer.h"
|
||||
|
||||
unsigned int GuiImage::getWidth() { return mDrawWidth; }
|
||||
unsigned int GuiImage::getHeight() { return mDrawHeight; }
|
||||
|
||||
GuiImage::GuiImage(GuiWindow* window, int offsetX, int offsetY, std::string path, unsigned int resizeWidth, unsigned int resizeHeight, bool resizeExact) : Gui(window)
|
||||
GuiImage::GuiImage(Window* window, int offsetX, int offsetY, std::string path, unsigned int resizeWidth, unsigned int resizeHeight, bool resizeExact) : Gui(window)
|
||||
{
|
||||
mTextureID = 0;
|
||||
|
||||
mOffsetX = offsetX;
|
||||
mOffsetY = offsetY;
|
||||
setOffset(offsetX, offsetY);
|
||||
|
||||
//default origin is the center of image
|
||||
mOriginX = 0.5;
|
||||
|
@ -369,8 +369,5 @@ bool GuiImage::hasImage()
|
|||
return !mPath.empty();
|
||||
}
|
||||
|
||||
int GuiImage::getOffsetX() { return mOffsetX; }
|
||||
int GuiImage::getOffsetY() { return mOffsetY; }
|
||||
unsigned char GuiImage::getOpacity() { return mOpacity; }
|
||||
void GuiImage::setOffset(int x, int y) { mOffsetX = x; mOffsetY = y; }
|
||||
void GuiImage::setOpacity(unsigned char opacity) { mOpacity = opacity; }
|
||||
|
|
|
@ -35,11 +35,8 @@ public:
|
|||
void onInit();
|
||||
void onDeinit();
|
||||
|
||||
int getOffsetX();
|
||||
int getOffsetY();
|
||||
unsigned char getOpacity();
|
||||
void setOpacity(unsigned char opacity);
|
||||
void setOffset(int x, int y);
|
||||
private:
|
||||
unsigned int mResizeWidth, mResizeHeight;
|
||||
float mOriginX, mOriginY;
|
||||
|
|
|
@ -11,47 +11,15 @@ int GuiInputConfig::sInputCount = 10;
|
|||
|
||||
GuiInputConfig::GuiInputConfig(Window* window) : Gui(window)
|
||||
{
|
||||
mInputNum = 0;
|
||||
mDone = false;
|
||||
|
||||
if(SDL_NumJoysticks() < 1)
|
||||
{
|
||||
std::cerr << "Error - GuiInputConfig found no SDL joysticks!\n";
|
||||
mJoystick = NULL;
|
||||
mDone = true;
|
||||
return;
|
||||
}else{
|
||||
LOG(LogInfo) << "Opening joystick \"" << SDL_JoystickName(0) << "\" for configuration...";
|
||||
mJoystick = SDL_JoystickOpen(0);
|
||||
}
|
||||
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
}
|
||||
|
||||
GuiInputConfig::~GuiInputConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void GuiInputConfig::onRender()
|
||||
void GuiInputConfig::render()
|
||||
{
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0xFFFFFFFF);
|
||||
|
||||
Font* font = Renderer::getDefaultFont(Renderer::MEDIUM);
|
||||
|
||||
int height = font->getHeight() + 6;
|
||||
|
||||
|
||||
Renderer::drawCenteredText("It looks like you have a joystick plugged in!", 0, 2, 0x000000FF, font);
|
||||
Renderer::drawCenteredText("POV hats (some D-Pads) are automatically mapped to directions.", 0, height, 0x000000FF, font);
|
||||
Renderer::drawCenteredText("You can press a keyboard key to skip any input.", 0, height * 2, 0x000000FF, font);
|
||||
Renderer::drawCenteredText("If you want to remap later, delete ~/.emulationstation/es_input.cfg.", 0, height * 3, 0x000000FF, font);
|
||||
Renderer::drawCenteredText("This interface only configures the first joystick plugged in.", 0, height * 4, 0x000000FF, font);
|
||||
Renderer::drawCenteredText("Remember - you'll need to set up your emulator separately!", 0, Renderer::getScreenHeight() - height, 0x000000FF, font);
|
||||
|
||||
if(mDone)
|
||||
Renderer::drawCenteredText("All done! Press a key or button to save.", 0, height * 5, 0x00BB00FF, font);
|
||||
else
|
||||
Renderer::drawCenteredText("Please press the axis/button for " + sInputs[mInputNum], 0, height * 5, 0x00C000FF, font);
|
||||
Renderer::drawCenteredText("IN DEVELOPMENT", 0, 2, 0x000000FF, Renderer::getDefaultFont(Renderer::MEDIUM));
|
||||
}
|
||||
|
||||
void GuiInputConfig::input(InputConfig* config, Input input)
|
||||
|
|
|
@ -147,8 +147,6 @@ void GuiTheme::deleteComponents()
|
|||
|
||||
mComponentVector.clear();
|
||||
|
||||
clearChildren();
|
||||
|
||||
//deletes fonts if any were created
|
||||
setDefaults();
|
||||
}
|
||||
|
@ -260,11 +258,11 @@ void GuiTheme::readXML(std::string path)
|
|||
}
|
||||
|
||||
//recursively creates components (with proper parenting)
|
||||
void GuiTheme::createComponentChildren(pugi::xml_node node, GuiComponent* parent)
|
||||
void GuiTheme::createComponentChildren(pugi::xml_node node, Gui* parent)
|
||||
{
|
||||
for(pugi::xml_node data = node.child("component"); data; data = data.next_sibling("component"))
|
||||
{
|
||||
GuiComponent* nextComp = createElement(data, parent);
|
||||
Gui* nextComp = createElement(data, parent);
|
||||
|
||||
if(nextComp)
|
||||
createComponentChildren(data, nextComp);
|
||||
|
@ -272,7 +270,7 @@ void GuiTheme::createComponentChildren(pugi::xml_node node, GuiComponent* parent
|
|||
}
|
||||
|
||||
//takes an XML element definition and creates an object from it
|
||||
GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
|
||||
Gui* GuiTheme::createElement(pugi::xml_node data, Gui* parent)
|
||||
{
|
||||
std::string type = data.child("type").text().get();
|
||||
|
||||
|
@ -316,7 +314,6 @@ GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
|
|||
comp->setTiling(tiled);
|
||||
comp->setImage(path);
|
||||
|
||||
parent->addChild(comp);
|
||||
mComponentVector.push_back(comp);
|
||||
return comp;
|
||||
}
|
||||
|
@ -426,3 +423,11 @@ Font* GuiTheme::resolveFont(pugi::xml_node node, std::string defaultPath, unsign
|
|||
|
||||
return new Font(path, size);
|
||||
}
|
||||
|
||||
void GuiTheme::render()
|
||||
{
|
||||
for(unsigned int i = 0; i < mComponentVector.size(); i++)
|
||||
{
|
||||
mComponentVector.at(i)->render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "../Sound.h"
|
||||
#include "../Font.h"
|
||||
|
||||
//This class loads an XML-defined list of GuiComponents.
|
||||
class GuiTheme : Gui
|
||||
//This class loads an XML-defined list of Guis.
|
||||
class GuiTheme : public Gui
|
||||
{
|
||||
public:
|
||||
GuiTheme(Window* window, bool detailed, std::string path = "");
|
||||
|
@ -18,6 +18,8 @@ public:
|
|||
|
||||
GuiBoxData getBoxData();
|
||||
|
||||
void render();
|
||||
|
||||
unsigned int getColor(std::string name);
|
||||
bool getBool(std::string name);
|
||||
float getFloat(std::string name);
|
||||
|
@ -30,8 +32,8 @@ public:
|
|||
private:
|
||||
void setDefaults();
|
||||
void deleteComponents();
|
||||
void createComponentChildren(pugi::xml_node node, GuiComponent* parent);
|
||||
GuiComponent* createElement(pugi::xml_node data, GuiComponent* parent);
|
||||
void createComponentChildren(pugi::xml_node node, Gui* parent);
|
||||
Gui* createElement(pugi::xml_node data, Gui* parent);
|
||||
|
||||
//utility functions
|
||||
std::string expandPath(std::string path);
|
||||
|
|
Loading…
Reference in a new issue