bsnes/phoenix/core/core.cpp

1948 lines
39 KiB
C++
Raw Normal View History

#if defined(PHOENIX_WINDOWS)
#include "../windows/header.hpp"
#elif defined(PHOENIX_QT)
#include "../qt/header.hpp"
#elif defined(PHOENIX_GTK)
#include "../gtk/header.hpp"
#elif defined(PHOENIX_COCOA)
#include "../cocoa/header.hpp"
#elif defined(PHOENIX_REFERENCE)
#include "../reference/header.hpp"
#endif
#include "core.hpp"
using namespace nall;
namespace phoenix {
#include "state.hpp"
#include "layout/fixed-layout.cpp"
#include "layout/horizontal-layout.cpp"
#include "layout/vertical-layout.cpp"
}
Update to v075r12 release. byuu says: phoenix has been completely rewritten from scratch, and bsnes/ui + bsnes/ui-gameboy have been updated to use the new API. Debugger works too. Currently, only phoenix/Qt is completed, and there are two known issues: 1: font sizes of menu items are wrong, I can fix this easily enough 2: there's some sort of multi-second lag when loading games, not sure what's happening there yet The new phoenix isn't exactly complete yet, still making some key changes, and then I'll start on phoenix/Windows and phoenix/GTK+. The most noticeable difference is that you don't have to give all of the header paths and PHOENIX_PLATFORM defines when compiling individual GUI object files. It's only needed for phoenix.cpp itself. The overall structure of the phoenix source folder is much saner as well for sync.sh. I'm really surprised things are working as well as they are for a two-day power rewrite of an entire phoenix target. The other targets won't be as bad insofar as the core stuff is completed this time. And thank god for that, I was about ready to kill myself after writing dozens of lines like this: HorizontalSlider::HorizontalSlider() : state(*new State), base_from_member<pHorizontalSlider&>(*new pHorizontalSlider(*this)), Widget(base_from_member<pHorizontalSlider&>::value), p(base_from_member<pHorizontalSlider&>::value) {} But each platform does have some new, unique problems. phoenix/GTK+ was acting screwy prior to the rewrite, and will most likely still have issues. Even more important, one of the major points of this rewrite was having the new phoenix/core cache widget settings/data, so that I can destroy and recreate widgets rather than relying on SetParent. This means that simple copying of the old phoenix/Windows won't work, and this new method is significantly more involved.
2011-02-15 12:22:37 +00:00
#if defined(PHOENIX_WINDOWS)
#include "../windows/platform.cpp"
#elif defined(PHOENIX_QT)
#include "../qt/platform.cpp"
#elif defined(PHOENIX_GTK)
#include "../gtk/platform.cpp"
#elif defined(PHOENIX_COCOA)
#include "../cocoa/platform.cpp"
#elif defined(PHOENIX_REFERENCE)
#include "../reference/platform.cpp"
Update to v075r12 release. byuu says: phoenix has been completely rewritten from scratch, and bsnes/ui + bsnes/ui-gameboy have been updated to use the new API. Debugger works too. Currently, only phoenix/Qt is completed, and there are two known issues: 1: font sizes of menu items are wrong, I can fix this easily enough 2: there's some sort of multi-second lag when loading games, not sure what's happening there yet The new phoenix isn't exactly complete yet, still making some key changes, and then I'll start on phoenix/Windows and phoenix/GTK+. The most noticeable difference is that you don't have to give all of the header paths and PHOENIX_PLATFORM defines when compiling individual GUI object files. It's only needed for phoenix.cpp itself. The overall structure of the phoenix source folder is much saner as well for sync.sh. I'm really surprised things are working as well as they are for a two-day power rewrite of an entire phoenix target. The other targets won't be as bad insofar as the core stuff is completed this time. And thank god for that, I was about ready to kill myself after writing dozens of lines like this: HorizontalSlider::HorizontalSlider() : state(*new State), base_from_member<pHorizontalSlider&>(*new pHorizontalSlider(*this)), Widget(base_from_member<pHorizontalSlider&>::value), p(base_from_member<pHorizontalSlider&>::value) {} But each platform does have some new, unique problems. phoenix/GTK+ was acting screwy prior to the rewrite, and will most likely still have issues. Even more important, one of the major points of this rewrite was having the new phoenix/core cache widget settings/data, so that I can destroy and recreate widgets rather than relying on SetParent. This means that simple copying of the old phoenix/Windows won't work, and this new method is significantly more involved.
2011-02-15 12:22:37 +00:00
#endif
namespace phoenix {
//Application
//===========
function<void ()> Application::main;
function<void ()> Application::Windows::onModalBegin;
function<void ()> Application::Windows::onModalEnd;
function<void ()> Application::Cocoa::onAbout;
function<void ()> Application::Cocoa::onActivate;
function<void ()> Application::Cocoa::onPreferences;
function<void ()> Application::Cocoa::onQuit;
void Application::run() {
return pApplication::run();
}
bool Application::pendingEvents() {
return pApplication::pendingEvents();
}
void Application::processEvents() {
return pApplication::processEvents();
}
void Application::quit() {
applicationState.quit = true;
return pApplication::quit();
}
void Application::setName(const string& name) {
applicationState.name = name;
}
void Application::initialize() {
static bool initialized = false;
if(initialized == false) {
initialized = true;
return pApplication::initialize();
}
}
//Color
//=====
uint32_t Color::rgb() const {
return (255 << 24) + (red << 16) + (green << 8) + (blue << 0);
}
uint32_t Color::argb() const {
return (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
}
//Geometry
//========
Position Geometry::position() const {
return {x, y};
}
Size Geometry::size() const {
return {width, height};
}
string Geometry::text() const {
return {x, ",", y, ",", width, ",", height};
}
Geometry::Geometry(const string& text) {
lstring part = text.split(",");
x = integer(part(0, "256"));
y = integer(part(1, "256"));
width = decimal(part(2, "256"));
height = decimal(part(3, "256"));
}
//Font
//====
string Font::serif(unsigned size, const string& style) {
return pFont::serif(size, style);
}
string Font::sans(unsigned size, const string& style) {
return pFont::sans(size, style);
}
string Font::monospace(unsigned size, const string& style) {
return pFont::monospace(size, style);
}
Size Font::size(const string& font, const string& text) {
return pFont::size(font, text);
}
//Desktop
//=======
Size Desktop::size() {
return pDesktop::size();
}
Geometry Desktop::workspace() {
return pDesktop::workspace();
}
//Monitor
//=======
unsigned Monitor::count() {
return pMonitor::count();
}
Geometry Monitor::geometry(unsigned monitor) {
return pMonitor::geometry(monitor);
}
unsigned Monitor::primary() {
return pMonitor::primary();
}
//Keyboard
//========
bool Keyboard::pressed(Keyboard::Scancode scancode) {
return pKeyboard::pressed(scancode);
}
bool Keyboard::released(Keyboard::Scancode scancode) {
return !pressed(scancode);
}
vector<bool> Keyboard::state() {
return pKeyboard::state();
}
//Mouse
//=====
Position Mouse::position() {
return pMouse::position();
}
bool Mouse::pressed(Mouse::Button button) {
return pMouse::pressed(button);
}
bool Mouse::released(Mouse::Button button) {
return !pressed(button);
}
//BrowserWindow
//=============
string BrowserWindow::directory() {
return pBrowserWindow::directory(state);
}
string BrowserWindow::open() {
return pBrowserWindow::open(state);
}
string BrowserWindow::save() {
return pBrowserWindow::save(state);
}
BrowserWindow& BrowserWindow::setFilters(const lstring& filters) {
state.filters = filters;
return *this;
}
BrowserWindow& BrowserWindow::setParent(Window& parent) {
state.parent = &parent;
return *this;
}
BrowserWindow& BrowserWindow::setPath(const string& path) {
state.path = path;
return *this;
}
BrowserWindow& BrowserWindow::setTitle(const string& title) {
state.title = title;
return *this;
}
BrowserWindow::BrowserWindow():
state(*new State) {
}
BrowserWindow::~BrowserWindow() {
delete &state;
}
//MessageWindow
//=============
MessageWindow::Response MessageWindow::error(MessageWindow::Buttons buttons) {
state.buttons = buttons;
return pMessageWindow::error(state);
}
MessageWindow::Response MessageWindow::information(MessageWindow::Buttons buttons) {
state.buttons = buttons;
return pMessageWindow::information(state);
}
MessageWindow::Response MessageWindow::question(MessageWindow::Buttons buttons) {
state.buttons = buttons;
return pMessageWindow::question(state);
}
MessageWindow& MessageWindow::setParent(Window& parent) {
state.parent = &parent;
return *this;
}
MessageWindow& MessageWindow::setText(const string& text) {
state.text = text;
return *this;
}
MessageWindow& MessageWindow::setTitle(const string& title) {
state.title = title;
return *this;
}
MessageWindow::Response MessageWindow::warning(MessageWindow::Buttons buttons) {
state.buttons = buttons;
return pMessageWindow::warning(state);
}
MessageWindow::MessageWindow(const string& text):
state(*new State) {
state.text = text;
}
MessageWindow::~MessageWindow() {
delete &state;
}
//Object
//======
Object::Object(pObject& p):
p(p) {
Application::initialize();
p.constructor();
}
Object::~Object() {
p.destructor();
delete &p;
}
//Timer
//=====
bool Timer::enabled() const {
return state.enabled;
}
unsigned Timer::interval() const {
return state.interval;
}
void Timer::setEnabled(bool enabled) {
state.enabled = enabled;
return p.setEnabled(enabled);
}
void Timer::setInterval(unsigned interval) {
state.interval = interval;
return p.setInterval(interval);
}
Timer::Timer():
state(*new State),
base_from_member<pTimer&>(*new pTimer(*this)),
Object(base_from_member<pTimer&>::value),
p(base_from_member<pTimer&>::value) {
p.constructor();
}
Timer::~Timer() {
p.destructor();
delete &state;
}
//Window
//======
void Window::append(Layout& layout) {
if(state.layout.append(layout)) {
layout.Sizable::state.parent = nullptr;
layout.Sizable::state.window = this;
p.append(layout);
layout.synchronizeLayout();
}
}
void Window::append(Menu& menu) {
if(state.menu.append(menu)) {
menu.Action::state.window = this;
p.append(menu);
}
}
void Window::append(Widget& widget) {
if(state.widget.append(widget)) {
widget.Sizable::state.window = this;
p.append(widget);
widget.synchronizeLayout();
}
}
Color Window::backgroundColor() const {
return state.backgroundColor;
}
bool Window::droppable() const {
return state.droppable;
}
Geometry Window::frameGeometry() {
Geometry geometry = p.geometry();
Geometry margin = p.frameMargin();
return {
geometry.x - margin.x, geometry.y - margin.y,
geometry.width + margin.width, geometry.height + margin.height
};
}
Geometry Window::frameMargin() {
return p.frameMargin();
}
bool Window::focused() {
return p.focused();
}
bool Window::fullScreen() const {
Update to v082r16 release. byuu says: Binary output is once again called bsnes. No versioning on the title without a system cartridge loaded. Still saving config files to .config/batch for now. Finally fixed NES APU frame IRQ clearing on $4015 reads. Added mouse button/axis binding through buttons on the input capture window. Added advanced settings window with driver selection and focus policy settings. Will show your default driver properly if none are selected now, unlike old bsnes. That exposed a small bug where phoenix isn't removing widgets on Layout::remove, worked around it for now by hiding the panels. Damn, sick of working on phoenix. Added all missing input controllers, which can all now be mapped, and bound them to the main menu, and added NES support for selecting "no connected controller." Added mouse capture and the requisite tools menu option for it. Added WindowManager class that keeps track of both position and size now (eg full geometry), so now you can resize your windows and save the settings, unlike old bsnes. WindowManager has more stringent geometry checks. The *client area* (not the window border) can't be below 0,0 or above the width/height of three 30" monitors. If you have 4+ 30" monitors, then fuck you :P settings.cfg is now also saved, captures all currently available settings. Right now, there's only one path for the file browser to remember. I will probably make this per-system later. FileBrowser has been made a bit more friendly. The bottom left tells you what type of files the list is filtered by (so you see "*.sfc" for SNES), and the bottom right has an open button that can enter folders or load files. Added video shader support. Fixed nall/dsp variadic-channel support, was only outputting the left channel.
2011-09-19 12:25:56 +00:00
return state.fullScreen;
}
Geometry Window::geometry() {
return p.geometry();
}
string Window::menuFont() const {
return state.menuFont;
}
bool Window::menuVisible() const {
return state.menuVisible;
}
bool Window::modal() const {
return state.modal;
}
void Window::remove(Layout& layout) {
if(state.layout.remove(layout)) {
p.remove(layout);
layout.Sizable::state.window = nullptr;
}
}
void Window::remove(Menu& menu) {
if(state.menu.remove(menu)) {
p.remove(menu);
menu.Action::state.window = nullptr;
}
}
void Window::remove(Widget& widget) {
if(state.widget.remove(widget)) {
p.remove(widget);
widget.Sizable::state.window = nullptr;
}
}
bool Window::resizable() const {
return state.resizable;
}
void Window::setBackgroundColor(Color color) {
state.backgroundColorOverride = true;
state.backgroundColor = color;
return p.setBackgroundColor(color);
}
void Window::setDroppable(bool droppable) {
state.droppable = droppable;
return p.setDroppable(droppable);
}
void Window::setFrameGeometry(Geometry geometry) {
Geometry margin = p.frameMargin();
return setGeometry({
geometry.x + margin.x, geometry.y + margin.y,
geometry.width - margin.width, geometry.height - margin.height
});
}
void Window::setFocused() {
return p.setFocused();
}
void Window::setFullScreen(bool fullScreen) {
state.fullScreen = fullScreen;
return p.setFullScreen(fullScreen);
}
void Window::setGeometry(Geometry geometry) {
state.geometry = geometry;
return p.setGeometry(geometry);
}
void Window::setMenuFont(const string& font) {
state.menuFont = font;
return p.setMenuFont(font);
}
void Window::setMenuVisible(bool visible) {
state.menuVisible = visible;
return p.setMenuVisible(visible);
}
Update to v088r11 release. byuu says: Changelog: - phoenix has added Window::setModal(bool modal = true); - file dialog is now modal. This allows emulation cores to request data and get it immediately before continuing the loading process - save data is hooked up for most systems, still need to handle subsystem slot saves (Sufami Turbo, basically.) - toggle fullscreen key binding added (Alt+Enter for now. I think F11 is probably better though, Enter is often mapped to game start button.) - video scaling is in (center, scale, stretch), works the same in windowed and fullscreen mode (stretch hides resize window option), all in the settings menu now - enough structure to map all saved paths for the browser and to load BS-X slotted carts, BS-X carts, single Sufami Turbo carts Caveats / Missing: - Super Game Boy input doesn't work yet (due to change in callback binding) - doesn't load secondary Sufami Turbo slot yet - BS-X BIOS isn't show the data pack games to load for some reason (ugh, I hate the shit out of debugging BS-X stuff ...) - need mute audio, sync audio+video toggle, save/load state menu and quick keys, XML mapping information window - need cheat editor and cheat database - need state manager - need to sort subsystems below main systems in load menu (basically just see if media.slot.size() > 0) - need video shaders (will probably leave off filters for the time being ... due to that 24/30-bit thing) - need video adjustments (contrast etc, overscan masks) - need audio adjustments (frequency, latency, resampler, volume, per-system frequency) - need driver selection and input focus policy (driver crash detection would be nice too) - need NSS DIP switch settings (that one will be really fun) - need to save and load window geometry settings - need to hook up controller selection (won't be fun), create a map to hide controllers with no inputs to reassign
2012-05-03 12:36:47 +00:00
void Window::setModal(bool modal) {
state.modal = modal;
return p.setModal(modal);
}
void Window::setResizable(bool resizable) {
state.resizable = resizable;
return p.setResizable(resizable);
}
void Window::setStatusFont(const string& font) {
state.statusFont = font;
return p.setStatusFont(font);
}
void Window::setStatusText(const string& text) {
state.statusText = text;
return p.setStatusText(text);
}
void Window::setStatusVisible(bool visible) {
state.statusVisible = visible;
return p.setStatusVisible(visible);
}
void Window::setTitle(const string& text) {
state.title = text;
return p.setTitle(text);
}
void Window::setVisible(bool visible) {
state.visible = visible;
synchronizeLayout();
return p.setVisible(visible);
}
void Window::setWidgetFont(const string& font) {
state.widgetFont = font;
return p.setWidgetFont(font);
}
void Window::setWindowGeometry(Geometry geometry) {
Geometry margin = p.frameMargin();
return setGeometry({
geometry.x + margin.x, geometry.y + margin.y,
geometry.width, geometry.height
});
}
string Window::statusFont() const {
return state.statusFont;
}
string Window::statusText() const {
return state.statusText;
}
bool Window::statusVisible() const {
return state.statusVisible;
}
void Window::synchronizeLayout() {
if(visible() && applicationState.quit == false) setGeometry(geometry());
}
string Window::title() const {
return state.title;
}
bool Window::visible() const {
return state.visible;
}
string Window::widgetFont() const {
return state.widgetFont;
}
Window::Window():
state(*new State),
base_from_member<pWindow&>(*new pWindow(*this)),
Object(base_from_member<pWindow&>::value),
p(base_from_member<pWindow&>::value) {
p.constructor();
}
Window::~Window() {
p.destructor();
delete &state;
}
//Action
//======
bool Action::enabled() const {
return state.enabled;
}
void Action::setEnabled(bool enabled) {
state.enabled = enabled;
return p.setEnabled(enabled);
}
void Action::setVisible(bool visible) {
state.visible = visible;
return p.setVisible(visible);
}
bool Action::visible() const {
return state.visible;
}
Action::Action(pAction& p):
state(*new State),
Object(p),
p(p) {
p.constructor();
}
Action::~Action() {
p.destructor();
delete &state;
}
//Menu
//====
void Menu::append(const group<Action>& list) {
for(auto& action : list) {
if(state.action.append(action)) {
action.state.menu = this;
p.append(action);
}
}
}
image Menu::image() const {
return state.image;
}
void Menu::remove(const group<Action>& list) {
for(auto& action : list) {
if(state.action.remove(action)) {
action.state.menu = nullptr;
return p.remove(action);
}
}
}
void Menu::setImage(const nall::image& image) {
state.image = image;
return p.setImage(image);
}
void Menu::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string Menu::text() const {
return state.text;
}
Menu::Menu():
state(*new State),
base_from_member<pMenu&>(*new pMenu(*this)),
Action(base_from_member<pMenu&>::value),
p(base_from_member<pMenu&>::value) {
p.constructor();
}
Menu::~Menu() {
p.destructor();
delete &state;
}
//Separator
//=========
Separator::Separator():
base_from_member<pSeparator&>(*new pSeparator(*this)),
Action(base_from_member<pSeparator&>::value),
p(base_from_member<pSeparator&>::value) {
p.constructor();
}
Separator::~Separator() {
p.destructor();
}
//Item
//====
image Item::image() const {
return state.image;
}
void Item::setImage(const nall::image& image) {
state.image = image;
return p.setImage(image);
}
void Item::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string Item::text() const {
return state.text;
}
Item::Item():
state(*new State),
base_from_member<pItem&>(*new pItem(*this)),
Action(base_from_member<pItem&>::value),
p(base_from_member<pItem&>::value) {
p.constructor();
}
Item::~Item() {
p.destructor();
delete &state;
}
//CheckItem
//=========
bool CheckItem::checked() const {
return state.checked;
}
void CheckItem::setChecked(bool checked) {
state.checked = checked;
return p.setChecked(checked);
}
void CheckItem::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string CheckItem::text() const {
return state.text;
}
CheckItem::CheckItem():
state(*new State),
base_from_member<pCheckItem&>(*new pCheckItem(*this)),
Action(base_from_member<pCheckItem&>::value),
p(base_from_member<pCheckItem&>::value) {
p.constructor();
}
CheckItem::~CheckItem() {
p.destructor();
delete &state;
}
//RadioItem
//=========
void RadioItem::group(const nall::group<RadioItem>& list) {
for(auto& item : list) item.p.setGroup(item.state.group = list);
if(list.size()) list.first().setChecked();
}
bool RadioItem::checked() const {
return state.checked;
}
void RadioItem::setChecked() {
for(auto& item : state.group) item.state.checked = false;
state.checked = true;
return p.setChecked();
}
void RadioItem::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string RadioItem::text() const {
Update to v088r14 release. byuu says: Changelog: - added NSS DIP switch settings window (when loading NSS carts with appropriate manifest.xml file) - added video shader selection (they go in ~/.config/bsnes/Video Shaders/ now) - added driver selection - added timing settings (not only allows video/audio settings, also has code to dynamically compute the values for you ... and it actually works pretty good!) - moved "None" controller device to bottom of list (it is the least likely to be used, after all) - added Interface::path() to support MSU1, USART, Link - input and hotkey mappings remember list position after assignment - and more! target-ethos now has all of the functionality of target-ui, and more. Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui). A ~67% reduction in code size, yet it does even more! And you can add or remove an entire system with only three lines of code (Makefile include, header include, interface append.) The only problem left is that the BS-X BIOS won't load the BS Zelda no Densetsu file. I can't figure out why it's not working, would appreciate any assistance, but otherwise I'm probably just going to leave it broken for v089, sorry. So the show stoppers for a new release at this point are: - fix laevateinn to compile with the new interface changes (shouldn't be too hard, it'll still use the old, direct interface.) - clean up Emulator::Interface as much as possible (trim down Information, mediaRequest should use an alternate struct designed to load firmware / slots separately) - enhance purify to strip SNES ROM headers, and it really needs a GUI interface - it would be highly desirable to make a launcher that can create a cartridge folder from an existing ROM set (* ethos will need to accept command-line arguments for this.) - probably need to remember which controller was selected in each port for each system across runs - need to fix the cursor for Super Scope / Justifier games (move from 19-bit to 32-bit colors broke it) - have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
return state.text;
}
RadioItem::RadioItem():
state(*new State),
base_from_member<pRadioItem&>(*new pRadioItem(*this)),
Action(base_from_member<pRadioItem&>::value),
p(base_from_member<pRadioItem&>::value) {
p.constructor();
}
RadioItem::~RadioItem() {
for(auto& item : state.group) {
if(&item != this) item.state.group.remove(*this);
}
p.destructor();
delete &state;
}
//Sizable
//=======
bool Sizable::enabled() const {
return state.enabled;
}
bool Sizable::enabledToAll() const {
if(state.enabled == false) return false;
if(state.parent) return state.parent->enabledToAll();
return true;
}
Layout* Sizable::layout() const {
if(state.parent && dynamic_cast<Layout*>(state.parent)) return (Layout*)state.parent;
return nullptr;
}
Sizable* Sizable::parent() const {
return state.parent;
}
bool Sizable::visible() const {
return state.visible;
}
bool Sizable::visibleToAll() const {
if(state.visible == false) return false;
if(state.parent) return state.parent->visibleToAll();
return true;
}
Window* Sizable::window() const {
return state.window;
}
Sizable::Sizable(pSizable& p):
state(*new State),
Object(p),
p(p) {
p.constructor();
}
Sizable::~Sizable() {
if(layout()) layout()->remove(*this);
p.destructor();
delete &state;
}
//Layout
//======
void Layout::append(Sizable& sizable) {
sizable.state.parent = this;
sizable.state.window = Sizable::state.window;
if(dynamic_cast<Layout*>(&sizable)) {
Layout& layout = (Layout&)sizable;
layout.synchronizeLayout();
}
if(dynamic_cast<Widget*>(&sizable)) {
Widget& widget = (Widget&)sizable;
if(sizable.window()) sizable.window()->append(widget);
}
}
void Layout::remove(Sizable& sizable) {
if(dynamic_cast<Widget*>(&sizable)) {
Widget& widget = (Widget&)sizable;
if(sizable.window()) sizable.window()->remove(widget);
}
sizable.state.parent = nullptr;
sizable.state.window = nullptr;
}
void Layout::reset() {
}
Layout::Layout():
state(*new State),
base_from_member<pLayout&>(*new pLayout(*this)),
Sizable(base_from_member<pLayout&>::value),
p(base_from_member<pLayout&>::value) {
}
Layout::Layout(pLayout& p):
state(*new State),
base_from_member<pLayout&>(p),
Sizable(p),
p(p) {
}
Layout::~Layout() {
if(layout()) layout()->remove(*this);
if(window()) window()->remove(*this);
p.destructor();
delete &state;
}
//Widget
//======
Update to higan v091r14 and ananke v00r03 releases. byuu says: higan changelog: - generates title displayed in emulator window by asking the core - core builds title solely from "information/title" ... if it's not there, you don't get a title at all - sub-system load menu is gone ... since there are multiple revisions of the SGB, this never really worked well anyway - to load an SGB, BS-X or ST cartridge, load the base cartridge first - "File->Load Game" moved to "Load->Import Game" ... may cause a bit of confusion to new users, but I don't like having a single-item menu, we'll just have to explain it to new users - browser window redone to look like ananke - home button here goes to ~/Emulation rather than just ~ like ananke, since this is the home of game folders - game folder icon is now the executable icon for the Tango theme (orange diamond), meant to represent a complete game rather than a game file or archive ananke changelog: - outputs GBC games to "Game Boy Color/" instead of "Game Boy/" - adds the file basename to "information/title" Known issues: - using ananke to load a GB game trips the Super Famicom SGB mode and fails (need to make the full-path auto-detection ignore non-bootable systems) - need to dump and test some BS-X media before releasing - ananke lacks BS-X Satellaview cartridge support - v092 isn't going to let you retarget the ananke/higan game folder path of ~/Emulation, you will have to wait for a future version if that bothers you so greatly [Later, after the v092 release, byuu posted this additional changelog: - kill laevateinn - add title() - add bootable, remove load - combine file, library - combine [][][] paths - fix SFC subtype handling XML->BML - update file browser to use buttons - update file browser keyboard handling - update system XML->BML - fix sufami turbo hashing - remove Cartridge::manifest ]
2012-12-25 05:31:55 +00:00
bool Widget::focused() {
return p.focused();
}
string Widget::font() const {
return state.font;
}
Geometry Widget::geometry() const {
return state.geometry;
}
Size Widget::minimumSize() {
return p.minimumSize();
}
void Widget::setEnabled(bool enabled) {
Sizable::state.enabled = enabled;
return p.setEnabled(enabled);
}
void Widget::setFocused() {
return p.setFocused();
}
void Widget::setFont(const string& font) {
state.font = font;
return p.setFont(font);
}
void Widget::setGeometry(Geometry geometry) {
state.geometry = geometry;
return p.setGeometry(geometry);
}
void Widget::setVisible(bool visible) {
Sizable::state.visible = visible;
return p.setVisible(visible);
}
void Widget::synchronizeLayout() {
}
Widget::Widget():
state(*new State),
base_from_member<pWidget&>(*new pWidget(*this)),
Sizable(base_from_member<pWidget&>::value),
p(base_from_member<pWidget&>::value) {
state.abstract = true;
p.constructor();
}
Widget::Widget(pWidget& p):
state(*new State),
base_from_member<pWidget&>(p),
Sizable(base_from_member<pWidget&>::value),
p(base_from_member<pWidget&>::value) {
p.constructor();
}
Widget::~Widget() {
p.destructor();
delete &state;
}
//Button
//======
image Button::image() const {
return state.image;
}
Orientation Button::orientation() const {
return state.orientation;
}
void Button::setImage(const nall::image& image, Orientation orientation) {
state.image = image;
state.orientation = orientation;
return p.setImage(image, orientation);
}
void Button::setText(const string& text) {
state.text = text;
return p.setText(text);
}
nall::string Button::text() const {
return state.text;
}
Button::Button():
state(*new State),
base_from_member<pButton&>(*new pButton(*this)),
Widget(base_from_member<pButton&>::value),
p(base_from_member<pButton&>::value) {
p.constructor();
}
Button::~Button() {
p.destructor();
delete &state;
}
//Canvas
//======
Color Canvas::color() const {
return state.color;
}
uint32_t* Canvas::data() const {
return state.data;
}
bool Canvas::droppable() const {
return state.droppable;
}
vector<Color> Canvas::gradient() const {
return state.gradient;
}
image Canvas::image() const {
return state.image;
}
Canvas::Mode Canvas::mode() const {
return state.mode;
}
void Canvas::setColor(Color color) {
state.color = color;
return setMode(Canvas::Mode::Color);
}
void Canvas::setData() {
if(state.width == 0 || state.height == 0) return; //dynamic sizing not supported in Mode::Data
return setMode(Canvas::Mode::Data);
}
void Canvas::setDroppable(bool droppable) {
state.droppable = droppable;
return p.setDroppable(droppable);
}
void Canvas::setGradient(Color topLeft, Color topRight, Color bottomLeft, Color bottomRight) {
state.gradient[0] = topLeft;
state.gradient[1] = topRight;
state.gradient[2] = bottomLeft;
state.gradient[3] = bottomRight;
return setMode(Canvas::Mode::Gradient);
}
void Canvas::setHorizontalGradient(Color left, Color right) {
state.gradient[0] = state.gradient[2] = left;
state.gradient[1] = state.gradient[3] = right;
return setMode(Canvas::Mode::Gradient);
}
void Canvas::setImage(const nall::image& image) {
state.image = image;
return setMode(Canvas::Mode::Image);
}
void Canvas::setMode(Mode mode) {
state.mode = mode;
return p.setMode(mode);
}
void Canvas::setSize(Size size) {
if(size.width == Size::Maximum) size.width = 0;
if(size.height == Size::Maximum) size.height = 0;
state.width = size.width;
state.height = size.height;
delete[] state.data;
state.data = new uint32_t[state.width * state.height]();
return setMode(state.mode);
}
void Canvas::setVerticalGradient(Color top, Color bottom) {
state.gradient[0] = state.gradient[1] = top;
state.gradient[2] = state.gradient[3] = bottom;
return setMode(Canvas::Mode::Gradient);
}
Size Canvas::size() const {
return {state.width, state.height};
}
Canvas::Canvas():
state(*new State),
base_from_member<pCanvas&>(*new pCanvas(*this)),
Widget(base_from_member<pCanvas&>::value),
p(base_from_member<pCanvas&>::value) {
state.data = new uint32_t[state.width * state.height]();
p.constructor();
}
Canvas::~Canvas() {
p.destructor();
delete[] state.data;
delete &state;
}
//CheckButton
//===========
bool CheckButton::checked() const {
return state.checked;
}
image CheckButton::image() const {
return state.image;
}
void CheckButton::setChecked(bool checked) {
state.checked = checked;
return p.setChecked(checked);
}
void CheckButton::setImage(const nall::image& image, Orientation orientation) {
state.image = image;
state.orientation = orientation;
return p.setImage(image, orientation);
}
void CheckButton::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string CheckButton::text() const {
return state.text;
}
CheckButton::CheckButton():
state(*new State),
base_from_member<pCheckButton&>(*new pCheckButton(*this)),
Widget(base_from_member<pCheckButton&>::value),
p(base_from_member<pCheckButton&>::value) {
p.constructor();
}
CheckButton::~CheckButton() {
p.destructor();
delete &state;
}
//CheckLabel
//==========
bool CheckLabel::checked() const {
return state.checked;
}
void CheckLabel::setChecked(bool checked) {
state.checked = checked;
return p.setChecked(checked);
}
void CheckLabel::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string CheckLabel::text() const {
return state.text;
}
CheckLabel::CheckLabel():
state(*new State),
base_from_member<pCheckLabel&>(*new pCheckLabel(*this)),
Widget(base_from_member<pCheckLabel&>::value),
p(base_from_member<pCheckLabel&>::value) {
p.constructor();
}
CheckLabel::~CheckLabel() {
p.destructor();
delete &state;
}
//ComboButton
//===========
void ComboButton::append(const string& text) {
state.text.append(text);
return p.append(text);
}
void ComboButton::remove(unsigned selection) {
if(selection >= state.text.size()) return;
state.text.remove(selection);
p.remove(selection);
}
void ComboButton::reset() {
state.selection = 0;
state.text.reset();
return p.reset();
}
unsigned ComboButton::rows() const {
return state.text.size();
}
unsigned ComboButton::selection() const {
return state.selection;
}
void ComboButton::setSelection(unsigned selection) {
if(selection >= state.text.size()) return;
state.selection = selection;
return p.setSelection(selection);
}
void ComboButton::setText(unsigned selection, const string& text) {
if(selection >= state.text.size()) return;
state.text[selection] = text;
p.setText(selection, text);
Update to v088r14 release. byuu says: Changelog: - added NSS DIP switch settings window (when loading NSS carts with appropriate manifest.xml file) - added video shader selection (they go in ~/.config/bsnes/Video Shaders/ now) - added driver selection - added timing settings (not only allows video/audio settings, also has code to dynamically compute the values for you ... and it actually works pretty good!) - moved "None" controller device to bottom of list (it is the least likely to be used, after all) - added Interface::path() to support MSU1, USART, Link - input and hotkey mappings remember list position after assignment - and more! target-ethos now has all of the functionality of target-ui, and more. Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui). A ~67% reduction in code size, yet it does even more! And you can add or remove an entire system with only three lines of code (Makefile include, header include, interface append.) The only problem left is that the BS-X BIOS won't load the BS Zelda no Densetsu file. I can't figure out why it's not working, would appreciate any assistance, but otherwise I'm probably just going to leave it broken for v089, sorry. So the show stoppers for a new release at this point are: - fix laevateinn to compile with the new interface changes (shouldn't be too hard, it'll still use the old, direct interface.) - clean up Emulator::Interface as much as possible (trim down Information, mediaRequest should use an alternate struct designed to load firmware / slots separately) - enhance purify to strip SNES ROM headers, and it really needs a GUI interface - it would be highly desirable to make a launcher that can create a cartridge folder from an existing ROM set (* ethos will need to accept command-line arguments for this.) - probably need to remember which controller was selected in each port for each system across runs - need to fix the cursor for Super Scope / Justifier games (move from 19-bit to 32-bit colors broke it) - have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
}
string ComboButton::text() const {
if(state.text.empty()) return "";
return state.text[state.selection];
}
string ComboButton::text(unsigned selection) const {
if(selection >= state.text.size()) return "";
return state.text[selection];
Update to v088r14 release. byuu says: Changelog: - added NSS DIP switch settings window (when loading NSS carts with appropriate manifest.xml file) - added video shader selection (they go in ~/.config/bsnes/Video Shaders/ now) - added driver selection - added timing settings (not only allows video/audio settings, also has code to dynamically compute the values for you ... and it actually works pretty good!) - moved "None" controller device to bottom of list (it is the least likely to be used, after all) - added Interface::path() to support MSU1, USART, Link - input and hotkey mappings remember list position after assignment - and more! target-ethos now has all of the functionality of target-ui, and more. Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui). A ~67% reduction in code size, yet it does even more! And you can add or remove an entire system with only three lines of code (Makefile include, header include, interface append.) The only problem left is that the BS-X BIOS won't load the BS Zelda no Densetsu file. I can't figure out why it's not working, would appreciate any assistance, but otherwise I'm probably just going to leave it broken for v089, sorry. So the show stoppers for a new release at this point are: - fix laevateinn to compile with the new interface changes (shouldn't be too hard, it'll still use the old, direct interface.) - clean up Emulator::Interface as much as possible (trim down Information, mediaRequest should use an alternate struct designed to load firmware / slots separately) - enhance purify to strip SNES ROM headers, and it really needs a GUI interface - it would be highly desirable to make a launcher that can create a cartridge folder from an existing ROM set (* ethos will need to accept command-line arguments for this.) - probably need to remember which controller was selected in each port for each system across runs - need to fix the cursor for Super Scope / Justifier games (move from 19-bit to 32-bit colors broke it) - have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
}
ComboButton::ComboButton():
state(*new State),
base_from_member<pComboButton&>(*new pComboButton(*this)),
Widget(base_from_member<pComboButton&>::value),
p(base_from_member<pComboButton&>::value) {
p.constructor();
}
ComboButton::~ComboButton() {
p.destructor();
delete &state;
}
//Console
//=======
void Console::print(const string& text) {
return p.print(text);
}
void Console::reset() {
return p.reset();
}
Console::Console():
state(*new State),
base_from_member<pConsole&>(*new pConsole(*this)),
Widget(base_from_member<pConsole&>::value),
p(base_from_member<pConsole&>::value) {
p.constructor();
}
Console::~Console() {
p.destructor();
delete &state;
}
//Frame
//=====
void Frame::setLayout(Layout& layout) {
state.layout = &layout;
synchronizeLayout();
}
void Frame::setText(const string& text) {
state.text = text;
return p.setText(text);
}
void Frame::synchronizeLayout() {
if(state.layout == nullptr) return;
state.layout->Sizable::state.window = Sizable::state.window;
state.layout->Sizable::state.parent = this;
state.layout->state.widget = this;
state.layout->synchronizeLayout();
}
string Frame::text() const {
return state.text;
}
Frame::Frame():
state(*new State),
base_from_member<pFrame&>(*new pFrame(*this)),
Widget(base_from_member<pFrame&>::value),
p(base_from_member<pFrame&>::value) {
p.constructor();
}
Frame::~Frame() {
p.destructor();
delete &state;
}
//HexEdit
//=======
unsigned HexEdit::columns() const {
return state.columns;
}
unsigned HexEdit::length() const {
return state.length;
}
unsigned HexEdit::offset() const {
return state.offset;
}
unsigned HexEdit::rows() const {
return state.rows;
}
void HexEdit::setColumns(unsigned columns) {
state.columns = columns;
return p.setColumns(columns);
}
void HexEdit::setLength(unsigned length) {
state.length = length;
return p.setLength(length);
}
void HexEdit::setOffset(unsigned offset) {
state.offset = offset;
return p.setOffset(offset);
}
void HexEdit::setRows(unsigned rows) {
state.rows = rows;
return p.setRows(rows);
}
void HexEdit::update() {
return p.update();
}
HexEdit::HexEdit():
state(*new State),
base_from_member<pHexEdit&>(*new pHexEdit(*this)),
Widget(base_from_member<pHexEdit&>::value),
p(base_from_member<pHexEdit&>::value) {
p.constructor();
}
HexEdit::~HexEdit() {
p.destructor();
delete &state;
}
//HorizontalScroller
//==================
unsigned HorizontalScroller::length() const {
Update to v082r18 release. byuu says: There we go, the GUI is nearly feature-complete once again. All cores now output their native video format (NES={emphasis}{palette}, SNES=BGR555, GameBoy={ bright, normal, darker, darkest }), and are transformed to RGB555 data that is passed to the video renderer. The video renderer then uses its internal palette to apply brightness/contrast/gamma/ramp adjustments and outputs in RGB888 color space. This does add in another rendering pass, unfortunately, but it's a necessary one for universal support. The plan is to adapt all filters to take RGB555 input, and output RGB555 data as well. By doing this, it will be possible to stack filters. However, it's a bit complicated: I need to plan how the stacking should occur (eg we never want to apply scanlines before HQ2x, etc.) Added input frequency adjustments for all three systems. I can easily get perfect video/audio sync on all three now, hooray. Long-term, it seems like we only really need one, and we can do a video/audio delta to get an adjusted value. But for now, this gets the job done. Added audio volume adjust. I left out the balance for now, since it's obviously impossible to balance the NES' single channel audio (I can duplicate the channel, and do twice the filtering work, but ... why?) I replaced NTSC/PAL TV mode selection with an "Enable Overscan" checkbox. On, you get 240 lines on NES+SNES. Off, you get 224 lines on NES+SNES. Also added aspect correction box back. I don't do that gross PAL distortion shit anymore, sorry PAL people. I just scale up the 54/47*(240/224) aspect correction for overscan off mode. All memory is loaded and saved now, for all three systems (hooray, now you can actually play Zelda 1&2.) Added all of the old bsnes hotkeys, with the exception of capture screenshot. May add again later. May come up with something a bit different for extra features. Re-added the NSS DIP switch setting window. Since geometry is saved, I didn't want to auto-hide rows, so now you'll see all eight possible DIPs, and the ones not used are grayed out. Ultimately, nobody will notice since we only have DIPs for ActRaiser NSS, and nobody's probably even using the XML file for that anyway. Whatever, it's nice to have anyway. Took FitzRoy's advice and single-item combo boxes on the input selection are disabled, so the user doesn't waste time checking them. I wanted to leave text so that you know there's not a problem. Qt disabled radio box items look almost exactly like enabled ones. Fixed lots of issues in phoenix and extended it a bit. But I was still having trouble with radio box grouping, so I said fuck it and made the panels show/hide based instead of append/remove based. That's all for stuff off the checklist, I did a bunch of other things I don't recall. So yeah, I'd say the GUI is 100% usable now. This is my opinion on how multi-platform GUIs should be done =) Oh, I figure I should mention, but the NES core is GPLv3, and all future SNES+GB releases will be as well. It's a move against Microsoft's Metro store.
2011-09-20 14:04:43 +00:00
return state.length;
}
unsigned HorizontalScroller::position() const {
return state.position;
}
void HorizontalScroller::setLength(unsigned length) {
state.length = length;
return p.setLength(length);
}
void HorizontalScroller::setPosition(unsigned position) {
state.position = position;
return p.setPosition(position);
}
HorizontalScroller::HorizontalScroller():
state(*new State),
base_from_member<pHorizontalScroller&>(*new pHorizontalScroller(*this)),
Widget(base_from_member<pHorizontalScroller&>::value),
p(base_from_member<pHorizontalScroller&>::value) {
p.constructor();
}
HorizontalScroller::~HorizontalScroller() {
p.destructor();
delete &state;
}
//HorizontalSlider
//================
unsigned HorizontalSlider::length() const {
Update to v082r18 release. byuu says: There we go, the GUI is nearly feature-complete once again. All cores now output their native video format (NES={emphasis}{palette}, SNES=BGR555, GameBoy={ bright, normal, darker, darkest }), and are transformed to RGB555 data that is passed to the video renderer. The video renderer then uses its internal palette to apply brightness/contrast/gamma/ramp adjustments and outputs in RGB888 color space. This does add in another rendering pass, unfortunately, but it's a necessary one for universal support. The plan is to adapt all filters to take RGB555 input, and output RGB555 data as well. By doing this, it will be possible to stack filters. However, it's a bit complicated: I need to plan how the stacking should occur (eg we never want to apply scanlines before HQ2x, etc.) Added input frequency adjustments for all three systems. I can easily get perfect video/audio sync on all three now, hooray. Long-term, it seems like we only really need one, and we can do a video/audio delta to get an adjusted value. But for now, this gets the job done. Added audio volume adjust. I left out the balance for now, since it's obviously impossible to balance the NES' single channel audio (I can duplicate the channel, and do twice the filtering work, but ... why?) I replaced NTSC/PAL TV mode selection with an "Enable Overscan" checkbox. On, you get 240 lines on NES+SNES. Off, you get 224 lines on NES+SNES. Also added aspect correction box back. I don't do that gross PAL distortion shit anymore, sorry PAL people. I just scale up the 54/47*(240/224) aspect correction for overscan off mode. All memory is loaded and saved now, for all three systems (hooray, now you can actually play Zelda 1&2.) Added all of the old bsnes hotkeys, with the exception of capture screenshot. May add again later. May come up with something a bit different for extra features. Re-added the NSS DIP switch setting window. Since geometry is saved, I didn't want to auto-hide rows, so now you'll see all eight possible DIPs, and the ones not used are grayed out. Ultimately, nobody will notice since we only have DIPs for ActRaiser NSS, and nobody's probably even using the XML file for that anyway. Whatever, it's nice to have anyway. Took FitzRoy's advice and single-item combo boxes on the input selection are disabled, so the user doesn't waste time checking them. I wanted to leave text so that you know there's not a problem. Qt disabled radio box items look almost exactly like enabled ones. Fixed lots of issues in phoenix and extended it a bit. But I was still having trouble with radio box grouping, so I said fuck it and made the panels show/hide based instead of append/remove based. That's all for stuff off the checklist, I did a bunch of other things I don't recall. So yeah, I'd say the GUI is 100% usable now. This is my opinion on how multi-platform GUIs should be done =) Oh, I figure I should mention, but the NES core is GPLv3, and all future SNES+GB releases will be as well. It's a move against Microsoft's Metro store.
2011-09-20 14:04:43 +00:00
return state.length;
}
unsigned HorizontalSlider::position() const {
return state.position;
}
void HorizontalSlider::setLength(unsigned length) {
state.length = length;
return p.setLength(length);
}
void HorizontalSlider::setPosition(unsigned position) {
state.position = position;
return p.setPosition(position);
}
HorizontalSlider::HorizontalSlider():
state(*new State),
base_from_member<pHorizontalSlider&>(*new pHorizontalSlider(*this)),
Widget(base_from_member<pHorizontalSlider&>::value),
p(base_from_member<pHorizontalSlider&>::value) {
p.constructor();
}
HorizontalSlider::~HorizontalSlider() {
p.destructor();
delete &state;
}
//Label
//=====
void Label::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string Label::text() const {
return state.text;
}
Label::Label():
state(*new State),
base_from_member<pLabel&>(*new pLabel(*this)),
Widget(base_from_member<pLabel&>::value),
p(base_from_member<pLabel&>::value) {
p.constructor();
}
Label::~Label() {
p.destructor();
delete &state;
}
//LineEdit
//========
bool LineEdit::editable() const {
return state.editable;
}
void LineEdit::setEditable(bool editable) {
state.editable = editable;
return p.setEditable(editable);
}
void LineEdit::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string LineEdit::text() {
return p.text();
}
LineEdit::LineEdit():
state(*new State),
base_from_member<pLineEdit&>(*new pLineEdit(*this)),
Widget(base_from_member<pLineEdit&>::value),
p(base_from_member<pLineEdit&>::value) {
p.constructor();
}
LineEdit::~LineEdit() {
p.destructor();
delete &state;
}
//ListView
//========
void ListView::append(const lstring& text) {
state.checked.append(false);
state.image.append({});
state.text.append(text);
return p.append(text);
}
void ListView::autoSizeColumns() {
return p.autoSizeColumns();
}
bool ListView::checkable() const {
return state.checkable;
}
bool ListView::checked(unsigned selection) const {
if(selection >= state.text.size()) return false;
return state.checked[selection];
}
unsigned ListView::columns() const {
return max(1u, state.headerText.size());
}
bool ListView::headerVisible() const {
return state.headerVisible;
}
image ListView::image(unsigned selection, unsigned position) const {
if(selection >= state.text.size()) return {};
return state.image[selection](position);
}
void ListView::remove(unsigned selection) {
if(selection >= state.text.size()) return;
state.checked.remove(selection);
state.image.remove(selection);
state.text.remove(selection);
return p.remove(selection);
}
void ListView::reset() {
state.checked.reset();
state.image.reset();
state.selected = false;
state.selection = 0;
state.text.reset();
return p.reset();
}
unsigned ListView::rows() const {
return state.text.size();
}
bool ListView::selected() const {
return state.selected;
}
unsigned ListView::selection() const {
return state.selection;
}
void ListView::setCheckable(bool checkable) {
state.checkable = checkable;
return p.setCheckable(checkable);
}
void ListView::setChecked(unsigned selection, bool checked) {
if(selection >= state.text.size()) return;
state.checked[selection] = checked;
return p.setChecked(selection, checked);
}
void ListView::setHeaderText(const lstring& text) {
state.headerText = text;
return p.setHeaderText(text);
}
void ListView::setHeaderVisible(bool visible) {
state.headerVisible = visible;
return p.setHeaderVisible(visible);
}
void ListView::setImage(unsigned selection, unsigned position, const nall::image& image) {
if(selection >= state.text.size()) return;
state.image[selection](position) = image;
return p.setImage(selection, position, image);
}
void ListView::setSelected(bool selected) {
state.selected = selected;
return p.setSelected(selected);
}
void ListView::setSelection(unsigned selection) {
if(selection >= state.text.size()) return;
state.selected = true;
state.selection = selection;
return p.setSelection(selection);
}
void ListView::setText(unsigned selection, const lstring& text) {
if(selection >= state.text.size()) return;
for(unsigned position = 0; position < text.size(); position++) {
setText(selection, position, text[position]);
}
}
void ListView::setText(unsigned selection, unsigned position, const string& text) {
if(selection >= state.text.size()) return;
state.text[selection](position) = text;
return p.setText(selection, position, text);
}
string ListView::text(unsigned selection, unsigned position) const {
if(selection >= state.text.size()) return "";
return state.text[selection](position);
}
ListView::ListView():
state(*new State),
base_from_member<pListView&>(*new pListView(*this)),
Widget(base_from_member<pListView&>::value),
p(base_from_member<pListView&>::value) {
p.constructor();
}
ListView::~ListView() {
p.destructor();
delete &state;
}
//ProgressBar
//===========
unsigned ProgressBar::position() const {
return state.position;
}
void ProgressBar::setPosition(unsigned position) {
state.position = position;
return p.setPosition(position);
}
ProgressBar::ProgressBar():
state(*new State),
base_from_member<pProgressBar&>(*new pProgressBar(*this)),
Widget(base_from_member<pProgressBar&>::value),
p(base_from_member<pProgressBar&>::value) {
p.constructor();
}
ProgressBar::~ProgressBar() {
p.destructor();
delete &state;
}
//RadioButton
//===========
void RadioButton::group(const nall::group<RadioButton>& list) {
for(auto& item : list) item.p.setGroup(item.state.group = list);
if(list.size()) list.first().setChecked();
}
bool RadioButton::checked() const {
return state.checked;
}
image RadioButton::image() const {
return state.image;
}
void RadioButton::setChecked() {
for(auto& item : state.group) item.state.checked = false;
state.checked = true;
return p.setChecked();
}
void RadioButton::setImage(const nall::image& image, Orientation orientation) {
state.image = image;
state.orientation = orientation;
return p.setImage(image, orientation);
}
void RadioButton::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string RadioButton::text() const {
return state.text;
}
RadioButton::RadioButton():
state(*new State),
base_from_member<pRadioButton&>(*new pRadioButton(*this)),
Widget(base_from_member<pRadioButton&>::value),
p(base_from_member<pRadioButton&>::value) {
p.constructor();
}
RadioButton::~RadioButton() {
for(auto& item : state.group) {
if(&item != this) item.state.group.remove(*this);
}
p.destructor();
delete &state;
}
//RadioLabel
//==========
void RadioLabel::group(const nall::group<RadioLabel>& list) {
for(auto& item : list) item.p.setGroup(item.state.group = list);
if(list.size()) list.first().setChecked();
}
bool RadioLabel::checked() const {
return state.checked;
}
void RadioLabel::setChecked() {
for(auto &item : state.group) item.state.checked = false;
state.checked = true;
return p.setChecked();
}
void RadioLabel::setText(const string& text) {
state.text = text;
return p.setText(text);
}
string RadioLabel::text() const {
return state.text;
}
RadioLabel::RadioLabel():
state(*new State),
base_from_member<pRadioLabel&>(*new pRadioLabel(*this)),
Widget(base_from_member<pRadioLabel&>::value),
p(base_from_member<pRadioLabel&>::value) {
p.constructor();
}
RadioLabel::~RadioLabel() {
for(auto& item : state.group) {
if(&item != this) item.state.group.remove(*this);
}
p.destructor();
delete &state;
}
//TabFrame
//========
void TabFrame::append(const string& text, const nall::image& image) {
state.image.append(image);
state.layout.append(nullptr);
state.text.append(text);
return p.append(text, image);
}
image TabFrame::image(unsigned selection) const {
if(selection >= state.text.size()) return {};
return state.image[selection];
}
void TabFrame::remove(unsigned selection) {
if(selection >= state.text.size()) return;
state.image.remove(selection);
state.layout.remove(selection);
state.text.remove(selection);
return p.remove(selection);
}
unsigned TabFrame::selection() const {
return state.selection;
}
void TabFrame::setImage(unsigned selection, const nall::image& image) {
if(selection >= state.text.size()) return;
state.image[selection] = image;
return p.setImage(selection, image);
}
void TabFrame::setLayout(unsigned selection, Layout& layout) {
if(selection >= state.text.size()) return;
state.layout[selection] = &layout;
synchronizeLayout();
}
void TabFrame::setSelection(unsigned selection) {
state.selection = selection;
return p.setSelection(selection);
}
void TabFrame::setText(unsigned selection, const string& text) {
if(selection >= state.text.size()) return;
state.text[selection] = text;
return p.setText(selection, text);
}
void TabFrame::synchronizeLayout() {
for(unsigned n = 0; n < state.layout.size(); n++) {
Layout* layout = state.layout[n];
if(layout == nullptr) continue;
layout->Sizable::state.parent = this;
layout->Sizable::state.window = Sizable::state.window;
layout->state.widget = this;
layout->state.widgetSelection = n;
layout->synchronizeLayout();
}
}
unsigned TabFrame::tabs() const {
return state.text.size();
}
string TabFrame::text(unsigned selection) const {
if(selection >= state.text.size()) return "";
return state.text[selection];
}
TabFrame::TabFrame():
state(*new State),
base_from_member<pTabFrame&>(*new pTabFrame(*this)),
Widget(base_from_member<pTabFrame&>::value),
p(base_from_member<pTabFrame&>::value) {
p.constructor();
}
TabFrame::~TabFrame() {
p.destructor();
delete &state;
}
//TextEdit
//========
bool TextEdit::editable() const {
return state.editable;
}
void TextEdit::setCursorPosition(unsigned position) {
state.cursorPosition = position;
return p.setCursorPosition(position);
}
void TextEdit::setEditable(bool editable) {
state.editable = editable;
return p.setEditable(editable);
}
void TextEdit::setText(const string& text) {
state.text = text;
return p.setText(text);
}
void TextEdit::setWordWrap(bool wordWrap) {
state.wordWrap = wordWrap;
return p.setWordWrap(wordWrap);
}
string TextEdit::text() {
return p.text();
}
bool TextEdit::wordWrap() const {
return state.wordWrap;
}
TextEdit::TextEdit():
state(*new State),
base_from_member<pTextEdit&>(*new pTextEdit(*this)),
Widget(base_from_member<pTextEdit&>::value),
p(base_from_member<pTextEdit&>::value) {
p.constructor();
}
TextEdit::~TextEdit() {
p.destructor();
delete &state;
}
//VerticalScroller
//================
unsigned VerticalScroller::length() const {
Update to v082r18 release. byuu says: There we go, the GUI is nearly feature-complete once again. All cores now output their native video format (NES={emphasis}{palette}, SNES=BGR555, GameBoy={ bright, normal, darker, darkest }), and are transformed to RGB555 data that is passed to the video renderer. The video renderer then uses its internal palette to apply brightness/contrast/gamma/ramp adjustments and outputs in RGB888 color space. This does add in another rendering pass, unfortunately, but it's a necessary one for universal support. The plan is to adapt all filters to take RGB555 input, and output RGB555 data as well. By doing this, it will be possible to stack filters. However, it's a bit complicated: I need to plan how the stacking should occur (eg we never want to apply scanlines before HQ2x, etc.) Added input frequency adjustments for all three systems. I can easily get perfect video/audio sync on all three now, hooray. Long-term, it seems like we only really need one, and we can do a video/audio delta to get an adjusted value. But for now, this gets the job done. Added audio volume adjust. I left out the balance for now, since it's obviously impossible to balance the NES' single channel audio (I can duplicate the channel, and do twice the filtering work, but ... why?) I replaced NTSC/PAL TV mode selection with an "Enable Overscan" checkbox. On, you get 240 lines on NES+SNES. Off, you get 224 lines on NES+SNES. Also added aspect correction box back. I don't do that gross PAL distortion shit anymore, sorry PAL people. I just scale up the 54/47*(240/224) aspect correction for overscan off mode. All memory is loaded and saved now, for all three systems (hooray, now you can actually play Zelda 1&2.) Added all of the old bsnes hotkeys, with the exception of capture screenshot. May add again later. May come up with something a bit different for extra features. Re-added the NSS DIP switch setting window. Since geometry is saved, I didn't want to auto-hide rows, so now you'll see all eight possible DIPs, and the ones not used are grayed out. Ultimately, nobody will notice since we only have DIPs for ActRaiser NSS, and nobody's probably even using the XML file for that anyway. Whatever, it's nice to have anyway. Took FitzRoy's advice and single-item combo boxes on the input selection are disabled, so the user doesn't waste time checking them. I wanted to leave text so that you know there's not a problem. Qt disabled radio box items look almost exactly like enabled ones. Fixed lots of issues in phoenix and extended it a bit. But I was still having trouble with radio box grouping, so I said fuck it and made the panels show/hide based instead of append/remove based. That's all for stuff off the checklist, I did a bunch of other things I don't recall. So yeah, I'd say the GUI is 100% usable now. This is my opinion on how multi-platform GUIs should be done =) Oh, I figure I should mention, but the NES core is GPLv3, and all future SNES+GB releases will be as well. It's a move against Microsoft's Metro store.
2011-09-20 14:04:43 +00:00
return state.length;
}
unsigned VerticalScroller::position() const {
return state.position;
}
void VerticalScroller::setLength(unsigned length) {
state.length = length;
return p.setLength(length);
}
void VerticalScroller::setPosition(unsigned position) {
state.position = position;
return p.setPosition(position);
}
VerticalScroller::VerticalScroller():
state(*new State),
base_from_member<pVerticalScroller&>(*new pVerticalScroller(*this)),
Widget(base_from_member<pVerticalScroller&>::value),
p(base_from_member<pVerticalScroller&>::value) {
p.constructor();
}
VerticalScroller::~VerticalScroller() {
p.destructor();
delete &state;
}
//VerticalSlider
//==============
unsigned VerticalSlider::length() const {
Update to v082r18 release. byuu says: There we go, the GUI is nearly feature-complete once again. All cores now output their native video format (NES={emphasis}{palette}, SNES=BGR555, GameBoy={ bright, normal, darker, darkest }), and are transformed to RGB555 data that is passed to the video renderer. The video renderer then uses its internal palette to apply brightness/contrast/gamma/ramp adjustments and outputs in RGB888 color space. This does add in another rendering pass, unfortunately, but it's a necessary one for universal support. The plan is to adapt all filters to take RGB555 input, and output RGB555 data as well. By doing this, it will be possible to stack filters. However, it's a bit complicated: I need to plan how the stacking should occur (eg we never want to apply scanlines before HQ2x, etc.) Added input frequency adjustments for all three systems. I can easily get perfect video/audio sync on all three now, hooray. Long-term, it seems like we only really need one, and we can do a video/audio delta to get an adjusted value. But for now, this gets the job done. Added audio volume adjust. I left out the balance for now, since it's obviously impossible to balance the NES' single channel audio (I can duplicate the channel, and do twice the filtering work, but ... why?) I replaced NTSC/PAL TV mode selection with an "Enable Overscan" checkbox. On, you get 240 lines on NES+SNES. Off, you get 224 lines on NES+SNES. Also added aspect correction box back. I don't do that gross PAL distortion shit anymore, sorry PAL people. I just scale up the 54/47*(240/224) aspect correction for overscan off mode. All memory is loaded and saved now, for all three systems (hooray, now you can actually play Zelda 1&2.) Added all of the old bsnes hotkeys, with the exception of capture screenshot. May add again later. May come up with something a bit different for extra features. Re-added the NSS DIP switch setting window. Since geometry is saved, I didn't want to auto-hide rows, so now you'll see all eight possible DIPs, and the ones not used are grayed out. Ultimately, nobody will notice since we only have DIPs for ActRaiser NSS, and nobody's probably even using the XML file for that anyway. Whatever, it's nice to have anyway. Took FitzRoy's advice and single-item combo boxes on the input selection are disabled, so the user doesn't waste time checking them. I wanted to leave text so that you know there's not a problem. Qt disabled radio box items look almost exactly like enabled ones. Fixed lots of issues in phoenix and extended it a bit. But I was still having trouble with radio box grouping, so I said fuck it and made the panels show/hide based instead of append/remove based. That's all for stuff off the checklist, I did a bunch of other things I don't recall. So yeah, I'd say the GUI is 100% usable now. This is my opinion on how multi-platform GUIs should be done =) Oh, I figure I should mention, but the NES core is GPLv3, and all future SNES+GB releases will be as well. It's a move against Microsoft's Metro store.
2011-09-20 14:04:43 +00:00
return state.length;
}
unsigned VerticalSlider::position() const {
return state.position;
}
void VerticalSlider::setLength(unsigned length) {
state.length = length;
return p.setLength(length);
}
void VerticalSlider::setPosition(unsigned position) {
state.position = position;
return p.setPosition(position);
}
VerticalSlider::VerticalSlider():
state(*new State),
base_from_member<pVerticalSlider&>(*new pVerticalSlider(*this)),
Widget(base_from_member<pVerticalSlider&>::value),
p(base_from_member<pVerticalSlider&>::value) {
p.constructor();
}
VerticalSlider::~VerticalSlider() {
p.destructor();
delete &state;
}
//Viewport
//========
bool Viewport::droppable() const {
return state.droppable;
}
uintptr_t Viewport::handle() {
return p.handle();
}
void Viewport::setDroppable(bool droppable) {
state.droppable = droppable;
return p.setDroppable(droppable);
}
Viewport::Viewport():
state(*new State),
base_from_member<pViewport&>(*new pViewport(*this)),
Widget(base_from_member<pViewport&>::value),
p(base_from_member<pViewport&>::value) {
p.constructor();
}
Viewport::~Viewport() {
p.destructor();
delete &state;
}
}