mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-30 01:55:39 +00:00
Began working on GuiBox for theming of boxes (a revolutionary concept).
This commit is contained in:
parent
a3c128f4ce
commit
aea93748d5
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
||||||
CC=g++
|
CC=g++
|
||||||
CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_RPI_
|
CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_RPI_
|
||||||
LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
||||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp pugiXML/pugixml.cpp
|
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp components/GuiBox.cpp pugiXML/pugixml.cpp
|
||||||
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
||||||
OBJECTS=$(SOURCES:.cpp=.o)
|
OBJECTS=$(SOURCES:.cpp=.o)
|
||||||
EXECUTABLE=emulationstation
|
EXECUTABLE=emulationstation
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
CC=g++
|
CC=g++
|
||||||
CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ -g
|
CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ -g
|
||||||
LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
|
||||||
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp pugiXML/pugixml.cpp
|
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp components/GuiBox.cpp pugiXML/pugixml.cpp
|
||||||
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
||||||
OBJECTS=$(SOURCES:.cpp=.o)
|
OBJECTS=$(SOURCES:.cpp=.o)
|
||||||
EXECUTABLE=emulationstation
|
EXECUTABLE=emulationstation
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
October 5
|
October 5
|
||||||
-GuiFastSelect is working, but ugly.
|
-GuiFastSelect is working, but ugly.
|
||||||
|
-Began work on GuiBox for theming the fast select dialog.
|
||||||
|
|
||||||
September 30
|
September 30
|
||||||
-Began implementing GuiFastSelect, currently invoked by holding F2. Unfortunately, it doesn't do anything yet.
|
-Began implementing GuiFastSelect, currently invoked by holding F2. Unfortunately, it doesn't do anything yet.
|
||||||
|
|
|
@ -35,7 +35,7 @@ void GuiComponent::removeChild(GuiComponent* comp)
|
||||||
if(mChildren.at(i) == comp)
|
if(mChildren.at(i) == comp)
|
||||||
{
|
{
|
||||||
mChildren.erase(mChildren.begin() + i);
|
mChildren.erase(mChildren.begin() + i);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void setOffsetY(int val);
|
void setOffsetY(int val);
|
||||||
|
|
||||||
static void processTicks(int deltaTime);
|
static void processTicks(int deltaTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mOffsetX, mOffsetY;
|
int mOffsetX, mOffsetY;
|
||||||
|
|
||||||
|
|
53
src/components/GuiBox.cpp
Normal file
53
src/components/GuiBox.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include "GuiBox.h"
|
||||||
|
|
||||||
|
GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height)
|
||||||
|
{
|
||||||
|
setOffsetX(offsetX);
|
||||||
|
setOffsetY(offsetY);
|
||||||
|
|
||||||
|
mWidth = width;
|
||||||
|
mHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::setHorizontalImage(std::string path, bool tiled)
|
||||||
|
{
|
||||||
|
mHorizontalImage.setImage(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::setVerticalImage(std::string path, bool tiled)
|
||||||
|
{
|
||||||
|
mVerticalImage.setImage(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::setBackgroundImage(std::string path, bool tiled)
|
||||||
|
{
|
||||||
|
mBackgroundImage.setImage(path);
|
||||||
|
mBackgroundImage.setTiling(tiled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::onRender()
|
||||||
|
{
|
||||||
|
//left border
|
||||||
|
mHorizontalImage.setOffsetX(getOffsetX());
|
||||||
|
mHorizontalImage.setOffsetY(getOffsetY());
|
||||||
|
mHorizontalImage.setOrigin(0.5, 0);
|
||||||
|
mHorizontalImage.setResize(12, mHeight, true);
|
||||||
|
mHorizontalImage.render();
|
||||||
|
|
||||||
|
//right border
|
||||||
|
mHorizontalImage.setOffsetX(getOffsetX() + mWidth);
|
||||||
|
mHorizontalImage.setOffsetY(getOffsetY());
|
||||||
|
mHorizontalImage.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::onInit()
|
||||||
|
{
|
||||||
|
mHorizontalImage.init();
|
||||||
|
mVerticalImage.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBox::onDeinit()
|
||||||
|
{
|
||||||
|
mHorizontalImage.deinit();
|
||||||
|
mVerticalImage.deinit();
|
||||||
|
}
|
27
src/components/GuiBox.h
Normal file
27
src/components/GuiBox.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef _GUIBOX_H_
|
||||||
|
#define _GUIBOX_H_
|
||||||
|
|
||||||
|
#include "../GuiComponent.h"
|
||||||
|
#include "GuiImage.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class GuiBox : public GuiComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height);
|
||||||
|
|
||||||
|
void setBackgroundImage(std::string path, bool tiled = true);
|
||||||
|
void setHorizontalImage(std::string path, bool tiled = false);
|
||||||
|
void setVerticalImage(std::string path, bool tiled = false);
|
||||||
|
|
||||||
|
void onRender();
|
||||||
|
|
||||||
|
void onInit();
|
||||||
|
void onDeinit();
|
||||||
|
private:
|
||||||
|
GuiImage mBackgroundImage, mHorizontalImage, mVerticalImage;
|
||||||
|
|
||||||
|
unsigned int mWidth, mHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -22,6 +22,13 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
|
||||||
mScrollTimer = 0;
|
mScrollTimer = 0;
|
||||||
mScrollOffset = 0;
|
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);
|
||||||
|
addChild(mBox);
|
||||||
|
|
||||||
|
//set test mBox info
|
||||||
|
//mBox->setHorizontalImage("test.jpg");
|
||||||
|
|
||||||
mParent->pause();
|
mParent->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +37,15 @@ GuiFastSelect::~GuiFastSelect()
|
||||||
Renderer::unregisterComponent(this);
|
Renderer::unregisterComponent(this);
|
||||||
InputManager::unregisterComponent(this);
|
InputManager::unregisterComponent(this);
|
||||||
|
|
||||||
|
removeChild(mBox);
|
||||||
|
delete mBox;
|
||||||
|
|
||||||
mParent->resume();
|
mParent->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiFastSelect::onRender()
|
void GuiFastSelect::onRender()
|
||||||
{
|
{
|
||||||
int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
|
||||||
|
|
||||||
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0);
|
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0);
|
||||||
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), 0xFF0000, Renderer::LARGE);
|
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), 0xFF0000, Renderer::LARGE);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../SystemData.h"
|
#include "../SystemData.h"
|
||||||
#include "../FolderData.h"
|
#include "../FolderData.h"
|
||||||
#include "GuiList.h"
|
#include "GuiList.h"
|
||||||
|
#include "GuiBox.h"
|
||||||
|
|
||||||
class GuiFastSelect : GuiComponent
|
class GuiFastSelect : GuiComponent
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,8 @@ private:
|
||||||
size_t mLetterID;
|
size_t mLetterID;
|
||||||
GuiComponent* mParent;
|
GuiComponent* mParent;
|
||||||
|
|
||||||
|
GuiBox* mBox;
|
||||||
|
|
||||||
int mScrollTimer, mScrollOffset;
|
int mScrollTimer, mScrollOffset;
|
||||||
bool mScrolling;
|
bool mScrolling;
|
||||||
};
|
};
|
||||||
|
|
|
@ -236,6 +236,7 @@ void GuiGameList::onPause()
|
||||||
|
|
||||||
void GuiGameList::onResume()
|
void GuiGameList::onResume()
|
||||||
{
|
{
|
||||||
|
updateDetailData();
|
||||||
InputManager::registerComponent(this);
|
InputManager::registerComponent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int resi
|
||||||
mOriginX = 0.5;
|
mOriginX = 0.5;
|
||||||
mOriginY = 0.5;
|
mOriginY = 0.5;
|
||||||
|
|
||||||
mWidth = 0;
|
mWidth = mDrawWidth = 0;
|
||||||
mHeight = 0;
|
mHeight = mDrawHeight = 0;
|
||||||
|
|
||||||
mTiled = false;
|
mTiled = false;
|
||||||
|
|
||||||
|
@ -160,6 +160,14 @@ void GuiImage::loadImage(std::string path)
|
||||||
//free the memory from that pointer
|
//free the memory from that pointer
|
||||||
delete[] imageRGBA;
|
delete[] imageRGBA;
|
||||||
|
|
||||||
|
resize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiImage::resize()
|
||||||
|
{
|
||||||
|
mDrawWidth = mWidth;
|
||||||
|
mDrawHeight = mHeight;
|
||||||
|
|
||||||
//(we don't resize tiled images)
|
//(we don't resize tiled images)
|
||||||
if(!mTiled)
|
if(!mTiled)
|
||||||
{
|
{
|
||||||
|
@ -184,12 +192,10 @@ void GuiImage::loadImage(std::string path)
|
||||||
resizeScaleX = resizeScaleY;
|
resizeScaleX = resizeScaleY;
|
||||||
|
|
||||||
if(resizeScaleX)
|
if(resizeScaleX)
|
||||||
mWidth *= resizeScaleX;
|
mDrawWidth *= resizeScaleX;
|
||||||
if(resizeScaleY)
|
if(resizeScaleY)
|
||||||
mHeight *= resizeScaleY;
|
mDrawHeight *= resizeScaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::cout << "Image load successful, w: " << mWidth << " h: " << mHeight << " texID: " << mTextureID << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiImage::unloadImage()
|
void GuiImage::unloadImage()
|
||||||
|
@ -229,6 +235,14 @@ void GuiImage::setTiling(bool tile)
|
||||||
mResizeExact = false;
|
mResizeExact = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiImage::setResize(unsigned int width, unsigned int height, bool resizeExact)
|
||||||
|
{
|
||||||
|
mResizeWidth = width;
|
||||||
|
mResizeHeight = height;
|
||||||
|
mResizeExact = resizeExact;
|
||||||
|
resize();
|
||||||
|
}
|
||||||
|
|
||||||
void GuiImage::onRender()
|
void GuiImage::onRender()
|
||||||
{
|
{
|
||||||
if(mTextureID)
|
if(mTextureID)
|
||||||
|
@ -246,7 +260,7 @@ void GuiImage::onRender()
|
||||||
{
|
{
|
||||||
for(unsigned int y = 0; y < yCount; y++)
|
for(unsigned int y = 0; y < yCount; y++)
|
||||||
{
|
{
|
||||||
buildImageArray(getOffsetX() + x*mWidth, getOffsetY() + y*mHeight, points + (12 * (x*yCount + y)), texs + (12 * (x*yCount + y)));
|
buildImageArray(getOffsetX() + x*mDrawWidth, getOffsetY() + y*mDrawHeight, points + (12 * (x*yCount + y)), texs + (12 * (x*yCount + y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawImageArray(points, texs, xCount * yCount * 6);
|
drawImageArray(points, texs, xCount * yCount * 6);
|
||||||
|
@ -262,13 +276,13 @@ void GuiImage::onRender()
|
||||||
|
|
||||||
void GuiImage::buildImageArray(int posX, int posY, GLfloat* points, GLfloat* texs)
|
void GuiImage::buildImageArray(int posX, int posY, GLfloat* points, GLfloat* texs)
|
||||||
{
|
{
|
||||||
points[0] = posX - (mWidth * mOriginX); points[1] = posY - (mHeight * mOriginY);
|
points[0] = posX - (mDrawWidth * mOriginX); points[1] = posY - (mDrawHeight * mOriginY);
|
||||||
points[2] = posX - (mWidth * mOriginX); points[3] = posY + (mHeight * (1 - mOriginY));
|
points[2] = posX - (mDrawWidth * mOriginX); points[3] = posY + (mDrawHeight * (1 - mOriginY));
|
||||||
points[4] = posX + (mWidth * (1 - mOriginX)); points[5] = posY - (mHeight * mOriginY);
|
points[4] = posX + (mDrawWidth * (1 - mOriginX)); points[5] = posY - (mDrawHeight * mOriginY);
|
||||||
|
|
||||||
points[6] = posX + (mWidth * (1 - mOriginX)); points[7] = posY - (mHeight * mOriginY);
|
points[6] = posX + (mDrawWidth * (1 - mOriginX)); points[7] = posY - (mDrawHeight * mOriginY);
|
||||||
points[8] = posX - (mWidth * mOriginX); points[9] = posY + (mHeight * (1 - mOriginY));
|
points[8] = posX - (mDrawWidth * mOriginX); points[9] = posY + (mDrawHeight * (1 - mOriginY));
|
||||||
points[10] = posX + (mWidth * (1 -mOriginX)); points[11] = posY + (mHeight * (1 - mOriginY));
|
points[10] = posX + (mDrawWidth * (1 -mOriginX)); points[11] = posY + (mDrawHeight * (1 - mOriginY));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
void setImage(std::string path); //Loads the image at the given filepath.
|
void setImage(std::string path); //Loads the image at the given filepath.
|
||||||
void setOrigin(float originX, float originY); //Sets the origin as a percentage of this image (e.g. (0, 0) is top left, (0.5, 0.5) is the center)
|
void setOrigin(float originX, float originY); //Sets the origin as a percentage of this image (e.g. (0, 0) is top left, (0.5, 0.5) is the center)
|
||||||
void setTiling(bool tile); //Enables or disables tiling. Must be called before loading an image or resizing will be weird.
|
void setTiling(bool tile); //Enables or disables tiling. Must be called before loading an image or resizing will be weird.
|
||||||
|
void setResize(unsigned int width, unsigned int height, bool resizeExact);
|
||||||
|
|
||||||
unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width.
|
unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width.
|
||||||
unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height.
|
unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height.
|
||||||
|
@ -35,6 +36,7 @@ private:
|
||||||
bool mResizeExact, mTiled;
|
bool mResizeExact, mTiled;
|
||||||
|
|
||||||
void loadImage(std::string path);
|
void loadImage(std::string path);
|
||||||
|
void resize();
|
||||||
void buildImageArray(int x, int y, GLfloat* points, GLfloat* texs); //writes 12 GLfloat points and 12 GLfloat texture coordinates to a given array at a given position
|
void buildImageArray(int x, int y, GLfloat* points, GLfloat* texs); //writes 12 GLfloat points and 12 GLfloat texture coordinates to a given array at a given position
|
||||||
void drawImageArray(GLfloat* points, GLfloat* texs, unsigned int count = 6); //draws the given set of points and texture coordinates, number of coordinate pairs may be specified (default 6)
|
void drawImageArray(GLfloat* points, GLfloat* texs, unsigned int count = 6); //draws the given set of points and texture coordinates, number of coordinate pairs may be specified (default 6)
|
||||||
void unloadImage();
|
void unloadImage();
|
||||||
|
@ -42,6 +44,7 @@ private:
|
||||||
std::string mPath;
|
std::string mPath;
|
||||||
|
|
||||||
unsigned int mWidth, mHeight; //Our rendered size.
|
unsigned int mWidth, mHeight; //Our rendered size.
|
||||||
|
unsigned int mDrawWidth, mDrawHeight;
|
||||||
|
|
||||||
GLuint mTextureID;
|
GLuint mTextureID;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue