Update to bsnes v107r4 beta release.

byuu says:

  - bsnes: added video filters from bsnes v082
  - bsnes: added ZSNES snow effect option when games paused or unloaded
    (no, I'm not joking)
  - bsnes: added 7-zip support (LZMA 19.00 SDK)

[Recent higan WIPs have also mentioned bsnes changes, although the higan code
no longer includes the bsnes code. These changes include:

  - higan, bsnes: added EXLOROM, EXLOROM-RAM, EXHIROM mappings
  - higan, bsnes: focus the viewport after leaving fullscreen exclusive
    mode
  - bsnes: re-added mightymo's cheat code database
  - bsnes: improved make install rules for the game and cheat code
    databases
  - bsnes: delayed construction of hiro::Window objects to properly show
    bsnes window icons

- Ed.]
This commit is contained in:
Tim Allen
2019-07-07 19:44:09 +10:00
parent becbca47d4
commit d87a0f633d
280 changed files with 120826 additions and 1521 deletions

View File

@@ -5,7 +5,6 @@ namespace hiro {
auto pCanvas::construct() -> void {
hwnd = CreateWindow(L"hiroWidget", L"", WS_CHILD, 0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0);
pWidget::construct();
setDroppable(state().droppable);
update();
}
@@ -30,6 +29,10 @@ auto pCanvas::setDroppable(bool droppable) -> void {
DragAcceptFiles(hwnd, droppable);
}
auto pCanvas::setFocusable(bool focusable) -> void {
//handled by windowProc()
}
auto pCanvas::setGeometry(Geometry geometry) -> void {
pWidget::setGeometry(geometry);
update();
@@ -64,6 +67,10 @@ auto pCanvas::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> m
return false;
}
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN || msg == WM_KEYUP || msg == WM_SYSKEYUP) {
if(self().focusable()) return true;
}
if(msg == WM_GETDLGCODE) {
return DLGC_STATIC | DLGC_WANTCHARS;
}
@@ -73,20 +80,8 @@ auto pCanvas::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> m
return msg == WM_ERASEBKGND;
}
if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
switch(msg) {
case WM_LBUTTONDOWN: self().doMousePress(Mouse::Button::Left); break;
case WM_MBUTTONDOWN: self().doMousePress(Mouse::Button::Middle); break;
case WM_RBUTTONDOWN: self().doMousePress(Mouse::Button::Right); break;
}
}
if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
switch(msg) {
case WM_LBUTTONUP: self().doMouseRelease(Mouse::Button::Left); break;
case WM_MBUTTONUP: self().doMouseRelease(Mouse::Button::Middle); break;
case WM_RBUTTONUP: self().doMouseRelease(Mouse::Button::Right); break;
}
if(msg == WM_LBUTTONDOWN) {
if(self().focusable()) setFocused();
}
return pWidget::windowProc(hwnd, msg, wparam, lparam);

View File

@@ -8,7 +8,8 @@ struct pCanvas : pWidget {
auto minimumSize() const -> Size override;
auto setAlignment(Alignment) -> void;
auto setColor(Color color) -> void;
auto setDroppable(bool droppable) -> void;
auto setDroppable(bool droppable) -> void override;
auto setFocusable(bool focusable) -> void override;
auto setGeometry(Geometry geometry) -> void override;
auto setGradient(Gradient gradient) -> void;
auto setIcon(const image& icon) -> void;

View File

@@ -12,7 +12,7 @@ auto pTextEdit::construct() -> void {
setBackgroundColor(state().backgroundColor);
setEditable(state().editable);
setText(state().text);
setCursor(state().cursor);
setTextCursor(state().textCursor);
}
auto pTextEdit::destruct() -> void {
@@ -27,14 +27,6 @@ auto pTextEdit::setBackgroundColor(Color color) -> void {
InvalidateRect(hwnd, 0, true);
}
auto pTextEdit::setCursor(Cursor cursor) -> void {
signed end = GetWindowTextLength(hwnd);
signed offset = max(0, min(end, cursor.offset()));
signed length = max(0, min(end, cursor.offset() + cursor.length()));
Edit_SetSel(hwnd, offset, length);
Edit_ScrollCaret(hwnd);
}
auto pTextEdit::setEditable(bool editable) -> void {
SendMessage(hwnd, EM_SETREADONLY, editable == false, (LPARAM)0);
}
@@ -50,6 +42,14 @@ auto pTextEdit::setText(string text) -> void {
SetWindowText(hwnd, utf16_t(text));
}
auto pTextEdit::setTextCursor(TextCursor cursor) -> void {
signed end = GetWindowTextLength(hwnd);
signed offset = max(0, min(end, cursor.offset()));
signed length = max(0, min(end, cursor.offset() + cursor.length()));
Edit_SetSel(hwnd, offset, length);
Edit_ScrollCaret(hwnd);
}
auto pTextEdit::setWordWrap(bool wordWrap) -> void {
//ES_AUTOHSCROLL cannot be changed after widget creation.
//As a result, we must destroy and re-create widget to change this setting.
@@ -66,6 +66,10 @@ auto pTextEdit::text() const -> string {
return text;
}
auto pTextEdit::textCursor() const -> TextCursor {
return state().textCursor;
}
//
auto pTextEdit::onChange() -> void {

View File

@@ -6,12 +6,13 @@ struct pTextEdit : pWidget {
Declare(TextEdit, Widget)
auto setBackgroundColor(Color color) -> void;
auto setCursor(Cursor cursor) -> void;
auto setEditable(bool editable) -> void;
auto setForegroundColor(Color color) -> void;
auto setText(string text) -> void;
auto setTextCursor(TextCursor textCursor) -> void;
auto setWordWrap(bool wordWrap) -> void;
auto text() const -> string;
auto textCursor() const -> TextCursor;
auto onChange() -> void;
auto windowProc(HWND, UINT, WPARAM, LPARAM) -> maybe<LRESULT> override;

View File

@@ -7,7 +7,6 @@ auto pViewport::construct() -> void {
WS_CHILD | WS_DISABLED,
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0);
pWidget::construct();
setDroppable(state().droppable);
}
auto pViewport::destruct() -> void {
@@ -22,6 +21,10 @@ auto pViewport::setDroppable(bool droppable) -> void {
DragAcceptFiles(hwnd, droppable);
}
auto pViewport::setFocusable(bool focusable) -> void {
//handled by windowProc()
}
//
auto pViewport::doMouseLeave() -> void {
@@ -38,16 +41,23 @@ auto pViewport::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) ->
return false;
}
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN || msg == WM_KEYUP || msg == WM_SYSKEYUP) {
if(self().focusable()) return true;
}
if(msg == WM_ERASEBKGND) {
//this will cause flickering during window resize
/*PAINTSTRUCT ps;
return false;
}
if(msg == WM_PAINT) {
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
auto brush = CreateSolidBrush(RGB(0, 0, 0));
RECT rc{};
GetClientRect(hwnd, &rc);
FillRect(ps.hdc, &rc, brush);
DeleteObject(brush);
EndPaint(hwnd, &ps);*/
EndPaint(hwnd, &ps);
return true;
}
@@ -55,20 +65,8 @@ auto pViewport::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) ->
return DLGC_STATIC | DLGC_WANTCHARS;
}
if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
switch(msg) {
case WM_LBUTTONDOWN: self().doMousePress(Mouse::Button::Left); break;
case WM_MBUTTONDOWN: self().doMousePress(Mouse::Button::Middle); break;
case WM_RBUTTONDOWN: self().doMousePress(Mouse::Button::Right); break;
}
}
if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
switch(msg) {
case WM_LBUTTONUP: self().doMouseRelease(Mouse::Button::Left); break;
case WM_MBUTTONUP: self().doMouseRelease(Mouse::Button::Middle); break;
case WM_RBUTTONUP: self().doMouseRelease(Mouse::Button::Right); break;
}
if(msg == WM_LBUTTONDOWN) {
if(self().focusable()) setFocused();
}
return pWidget::windowProc(hwnd, msg, wparam, lparam);

View File

@@ -6,7 +6,8 @@ struct pViewport : pWidget {
Declare(Viewport, Widget)
auto handle() const -> uintptr_t;
auto setDroppable(bool droppable) -> void;
auto setDroppable(bool droppable) -> void override;
auto setFocusable(bool focusable) -> void override;
auto doMouseLeave() -> void override;
auto doMouseMove(int x, int y) -> void override;

View File

@@ -42,6 +42,10 @@ auto pWidget::minimumSize() -> Size {
return {0, 0};
}
auto pWidget::setDroppable(bool droppable) -> void {
//TODO
}
auto pWidget::setEnabled(bool enabled) -> void {
if(!self().parentWindow(true)) enabled = false;
if(!self().enabled(true)) enabled = false;
@@ -49,6 +53,10 @@ auto pWidget::setEnabled(bool enabled) -> void {
EnableWindow(hwnd, enabled);
}
auto pWidget::setFocusable(bool focusable) -> void {
//TODO
}
auto pWidget::setFocused() -> void {
SetFocus(hwnd);
}
@@ -69,6 +77,10 @@ auto pWidget::setGeometry(Geometry geometry) -> void {
pSizable::setGeometry(geometry);
}
auto pWidget::setMouseCursor(const MouseCursor& mouseCursor) -> void {
//TODO
}
auto pWidget::setToolTip(const string& toolTipText) -> void {
if(toolTipText) {
toolTip = new pToolTip{toolTipText};
@@ -97,6 +109,39 @@ auto pWidget::doMouseMove(int x, int y) -> void {
}
auto pWidget::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> maybe<LRESULT> {
if(msg == WM_SETCURSOR) {
if(auto cursor = self().mouseCursor()) {
maybe<LPWSTR> cursorID;
if(cursor.name() == MouseCursor::Hand) cursorID = IDC_HAND;
if(cursor.name() == MouseCursor::HorizontalResize) cursorID = IDC_SIZEWE;
if(cursor.name() == MouseCursor::VerticalResize) cursorID = IDC_SIZENS;
if(cursorID) return SetCursor(LoadCursor(0, cursorID())), true;
}
}
if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
//if using a (Horizontal,Vertical)ResizeGrip, it's possible to move the cursor off the widget momentarily.
//ordinarily, this will cause the cursor to revert to the newly hovered Widget.
//by capturing the mouse until the mouse button is released, this prevents said cursor flickering.
//if(msg == WM_LBUTTONDOWN && self().mouseCursor()) SetCapture(hwnd);
switch(msg) {
case WM_LBUTTONDOWN: self().doMousePress(Mouse::Button::Left); break;
case WM_MBUTTONDOWN: self().doMousePress(Mouse::Button::Middle); break;
case WM_RBUTTONDOWN: self().doMousePress(Mouse::Button::Right); break;
}
}
if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
//if(msg == WM_LBUTTONUP && self().mouseCursor() && GetCapture() == hwnd) ReleaseCapture();
switch(msg) {
case WM_LBUTTONUP: self().doMouseRelease(Mouse::Button::Left); break;
case WM_MBUTTONUP: self().doMouseRelease(Mouse::Button::Middle); break;
case WM_RBUTTONUP: self().doMouseRelease(Mouse::Button::Right); break;
}
}
if(msg == WM_MOUSEMOVE) {
TRACKMOUSEEVENT event{sizeof(TRACKMOUSEEVENT)};
event.hwndTrack = hwnd;
@@ -147,8 +192,11 @@ auto pWidget::_parentWindow() -> maybe<pWindow&> {
}
auto pWidget::_setState() -> void {
setDroppable(self().droppable());
setEnabled(self().enabled());
setFocusable(self().focusable());
setFont(self().font());
setMouseCursor(self().mouseCursor());
setToolTip(self().toolTip());
setVisible(self().visible());
}

View File

@@ -7,10 +7,13 @@ struct pWidget : pSizable {
auto focused() const -> bool override;
virtual auto minimumSize() -> Size;
virtual auto setDroppable(bool droppable) -> void;
auto setEnabled(bool enabled) -> void override;
virtual auto setFocusable(bool focusable) -> void;
auto setFocused() -> void;
auto setFont(const Font& font) -> void override;
virtual auto setGeometry(Geometry geometry) -> void;
auto setMouseCursor(const MouseCursor& mouseCursor) -> void;
auto setToolTip(const string& toolTip) -> void;
auto setVisible(bool visible) -> void override;