2021-06-12 15:59:42 +05:30
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_WIDGETS_GRID_H
|
|
|
|
#define GUI_WIDGETS_GRID_H
|
|
|
|
|
|
|
|
#include "gui/dialog.h"
|
|
|
|
#include "gui/widget.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/array.h"
|
|
|
|
#include "image/bmp.h"
|
|
|
|
#include "image/png.h"
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
const Graphics::ManagedSurface *scaleGfx(Graphics::ManagedSurface *gfx, int w, int h);
|
|
|
|
|
|
|
|
enum Platform {
|
|
|
|
kPlatformDOS,
|
|
|
|
kPlatformAmiga,
|
|
|
|
kPlatformApple2,
|
|
|
|
kPlatformUnknown = -1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GridItemInfo
|
|
|
|
{
|
|
|
|
Common::String engineid;
|
|
|
|
Common::String gameid;
|
|
|
|
Common::String language;
|
|
|
|
Common::String title;
|
2021-06-15 18:11:31 +05:30
|
|
|
Platform platform;
|
2021-06-12 15:59:42 +05:30
|
|
|
Common::String thumbPath;
|
|
|
|
|
|
|
|
GridItemInfo(Common::String &eid, Common::String &gid, Common::String &t, Common::String &l, Common::String &p) :
|
2021-06-15 18:11:31 +05:30
|
|
|
gameid(gid), engineid(eid), title(t), language(l) {
|
|
|
|
if (p == "pc")
|
|
|
|
platform = kPlatformDOS;
|
|
|
|
else if (p == "amiga")
|
|
|
|
platform = kPlatformAmiga;
|
|
|
|
else if (p == "apple2")
|
|
|
|
platform = kPlatformApple2;
|
|
|
|
else
|
|
|
|
platform = kPlatformUnknown;
|
|
|
|
|
2021-06-12 15:59:42 +05:30
|
|
|
thumbPath = Common::String::format("%s-%s.png", engineid.c_str(), gameid.c_str());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class GridItemWidget;
|
|
|
|
|
|
|
|
/* GridWidget */
|
|
|
|
class GridWidget : public ContainerWidget {
|
|
|
|
private:
|
|
|
|
Common::Array<const Graphics::ManagedSurface *> _platformIcons;
|
|
|
|
// _gridItems should be reserved to hold few more than visible items
|
|
|
|
Common::Array<GridItemWidget *> _gridItems;
|
|
|
|
Common::Array<GridItemInfo> _allEntries;
|
|
|
|
Common::Array<GridItemInfo> _visibleEntries;
|
|
|
|
Common::HashMap<Common::String, const Graphics::ManagedSurface *> _loadedSurfaces;
|
|
|
|
|
|
|
|
Common::Array<Common::Array<GridItemWidget *>> _grid;
|
|
|
|
|
|
|
|
ScrollBarWidget *_scrollBar;
|
|
|
|
|
|
|
|
uint16 _scrollWindowHeight, _scrollWindowWidth, _scrollSpeed;
|
|
|
|
uint16 _innerHeight, _innerWidth;
|
|
|
|
uint16 _thumbnailHeight, _thumbnailWidth;
|
|
|
|
uint16 _gridItemHeight, _gridItemWidth;
|
2021-06-15 15:45:56 +05:30
|
|
|
uint16 _minGridXSpacing, _minGridYSpacing;
|
2021-06-14 13:20:54 +05:30
|
|
|
uint16 _gridXSpacing, _gridYSpacing;
|
2021-06-12 15:59:42 +05:30
|
|
|
|
|
|
|
int _scrollPos;
|
|
|
|
int _itemsPerRow;
|
|
|
|
int _firstVisibleItem;
|
|
|
|
int _itemsOnScreen;
|
|
|
|
|
|
|
|
bool _titlesVisible;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
GridWidget(GuiObject *boss, int x, int y, int w, int h);
|
|
|
|
GridWidget(GuiObject *boss, const Common::String &name);
|
|
|
|
|
|
|
|
const Graphics::ManagedSurface * filenameToSurface(Common::String &name);
|
|
|
|
const Graphics::ManagedSurface * platformToSurface(Platform platformCode);
|
|
|
|
|
|
|
|
|
|
|
|
bool calcVisibleEntries(void);
|
|
|
|
void setEntryList(Common::Array<GridItemInfo> *list);
|
|
|
|
void destroyItems();
|
|
|
|
void loadPlatformIcons();
|
|
|
|
void updateGrid(void);
|
|
|
|
void gridFromGameList();
|
|
|
|
int getLoadedNumber(void) {return _loadedSurfaces.size();}
|
|
|
|
void reloadThumbnails();
|
|
|
|
void handleMouseWheel(int x, int y, int direction) override;
|
|
|
|
void reflowLayout() override;
|
|
|
|
|
|
|
|
|
|
|
|
int selectedEntry;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kThumbnailWidth = 192,
|
|
|
|
kThumbnailHeight = 192
|
|
|
|
};
|
|
|
|
|
|
|
|
/* EntryContainerWidget */
|
|
|
|
class GridItemWidget : public ContainerWidget {
|
|
|
|
public:
|
|
|
|
GridWidget *_grid;
|
|
|
|
|
|
|
|
Common::Array<GridItemInfo> _attachedEntries;
|
|
|
|
GridItemInfo *_activeEntry;
|
|
|
|
|
|
|
|
bool isHighlighted;
|
|
|
|
void setActiveEntry(GridItemInfo &entry);
|
|
|
|
|
|
|
|
public:
|
2021-06-15 18:11:31 +05:30
|
|
|
Graphics::ManagedSurface _thumbGfx;
|
|
|
|
|
2021-06-12 15:59:42 +05:30
|
|
|
GridItemWidget(GridWidget *boss, int x, int y, int w, int h);
|
2021-06-15 18:11:31 +05:30
|
|
|
GridItemWidget(GridWidget *boss);
|
2021-06-12 15:59:42 +05:30
|
|
|
|
|
|
|
void attachEntry(Common::String key, Common::String description, Common::ConfigManager::Domain *domain);
|
|
|
|
void attachEntry(GridItemInfo &entry);
|
|
|
|
void attachEntries(Common::Array<GridItemInfo> entry);
|
|
|
|
void setActiveEntry(int i) {setActiveEntry(_attachedEntries[i]);};
|
|
|
|
void update();
|
|
|
|
void updateThumb();
|
|
|
|
void drawWidget() override;
|
2021-06-15 18:13:20 +05:30
|
|
|
void handleMouseWheel(int x, int y, int direction) override;
|
2021-06-16 22:51:59 +05:30
|
|
|
void move(int x, int y);
|
2021-06-12 15:59:42 +05:30
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace GUI
|
|
|
|
|
|
|
|
#endif
|