mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-09 10:26:28 +02:00
Update to v103r13 release.
byuu says: Changelog: - gb/interface: fix Game Boy Color extension to be "gbc" and not "gb" [hex\_usr] - ms/interface: move Master System hardware controls below controller ports - sfc/ppu: improve latching behavior of BGnHOFS registers (not hardware verified) [AWJ] - tomoko/input: rework port/device mapping to support non-sequential ports and devices¹ - todo: should add move() to inputDevice.mappings.append and inputPort.devices.append - note: there's a weird GCC 4.9 bug with brace initialization of InputEmulator; have to assign each field separately - tomoko: all windows sans the main presentation window can be dismissed with the escape key - icarus: the single file selection dialog ("Load ROM Image...") can be dismissed with the escape key - tomoko: do not pause emulation when FocusLoss/Pause is set during exclusive fullscreen mode - hiro/(windows,gtk,qt): implemented Window::setDismissable() function (missing from cocoa port, sorry) - nall/string: fixed printing of largest possible negative numbers (eg `INT_MIN`) [Sintendo] - only took eight months! :D ¹: When I tried to move the Master System hardware port below the controller ports, I ran into a world of pain. The input settings list expects every item in the `InputEmulator<InputPort<InputDevice<InputMapping>>>>` arrays to be populated with valid results. But these would be sparsely populated based on the port and device IDs from inside higan. And that is done so that the Interface::inputPoll can have O(1) lookup of ports and devices. This worked because all the port and device IDs were sequential (they left no gaps in the maps upon creating the lists.) Unfortunately by changing the expectation of port ID to how it appears in the list, inputs would not poll correctly. By leaving them alone and just moving Hardware to the third position, the Game Gear would be missing port IDs of 0 and 1 (the controller ports of the Master System). Even by trying to make separate MasterSystemHardware and GameGearHardware ports, things still fractured when the devices were no longer contigious. I got pretty sick of this and just decided to give up on O(1) port/device lookup, and moved to O(n) lookup. It only knocked the framerate down by maybe one frame per second, enough to be in the margin of error. Inputs aren't polled *that* often for loops that usually terminate after 1-2 cycles to be too detrimental to performance. So the new input system now allows non-sequential port and device IDs. Remember that I killed input IDs a while back. There's never any reason for those to need IDs ... it was easier to just order the inputs in the order you want to see them in the user interface. So the input lookup is still O(1). Only now, everything's safer and I return a maybe<InputMapping&>, and won't crash out the program trying to use a mapping that isn't found for some reason. Errata: the escape key isn't working on the browser/message dialogs on Windows, because of course nothing can ever just be easy and work for me. If anyone else wouldn't mind looking into that, I'd greatly appreciate it. Having the `WM_KEYDOWN` test inside the main `Application_sharedProc`, it seems to not respond to the escape key on modal dialogs. If I put the `WM_KEYDOWN` test in the main window proc, then it doesn't seem to get called for `VK_ESCAPE` at all, and doesn't get called period for modal windows. So I'm at a loss and it's past 4AM here >_>
This commit is contained in:
@@ -12,7 +12,7 @@ using namespace nall;
|
|||||||
|
|
||||||
namespace Emulator {
|
namespace Emulator {
|
||||||
static const string Name = "higan";
|
static const string Name = "higan";
|
||||||
static const string Version = "103.12";
|
static const string Version = "103.13";
|
||||||
static const string Author = "byuu";
|
static const string Author = "byuu";
|
||||||
static const string License = "GPLv3";
|
static const string License = "GPLv3";
|
||||||
static const string Website = "http://byuu.org/";
|
static const string Website = "http://byuu.org/";
|
||||||
|
@@ -3,7 +3,7 @@ GameBoyColorInterface::GameBoyColorInterface() {
|
|||||||
information.name = "Game Boy Color";
|
information.name = "Game Boy Color";
|
||||||
information.overscan = false;
|
information.overscan = false;
|
||||||
|
|
||||||
media.append({ID::GameBoyColor, "Game Boy Color", "gb"});
|
media.append({ID::GameBoyColor, "Game Boy Color", "gbc"});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GameBoyColorInterface::videoColors() -> uint32 {
|
auto GameBoyColorInterface::videoColors() -> uint32 {
|
||||||
|
@@ -5,15 +5,9 @@ MasterSystemInterface::MasterSystemInterface() {
|
|||||||
|
|
||||||
media.append({ID::MasterSystem, "Master System", "ms"});
|
media.append({ID::MasterSystem, "Master System", "ms"});
|
||||||
|
|
||||||
Port hardware{ID::Port::Hardware, "Hardware"};
|
|
||||||
Port controllerPort1{ID::Port::Controller1, "Controller Port 1"};
|
Port controllerPort1{ID::Port::Controller1, "Controller Port 1"};
|
||||||
Port controllerPort2{ID::Port::Controller2, "Controller Port 2"};
|
Port controllerPort2{ID::Port::Controller2, "Controller Port 2"};
|
||||||
|
Port hardware{ID::Port::Hardware, "Hardware"};
|
||||||
{ Device device{ID::Device::MasterSystemControls, "Controls"};
|
|
||||||
device.inputs.append({0, "Reset"});
|
|
||||||
device.inputs.append({0, "Pause"});
|
|
||||||
hardware.devices.append(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ Device device{ID::Device::None, "None"};
|
{ Device device{ID::Device::None, "None"};
|
||||||
controllerPort1.devices.append(device);
|
controllerPort1.devices.append(device);
|
||||||
@@ -31,9 +25,15 @@ MasterSystemInterface::MasterSystemInterface() {
|
|||||||
controllerPort2.devices.append(device);
|
controllerPort2.devices.append(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
ports.append(move(hardware));
|
{ Device device{ID::Device::MasterSystemControls, "Controls"};
|
||||||
|
device.inputs.append({0, "Reset"});
|
||||||
|
device.inputs.append({0, "Pause"});
|
||||||
|
hardware.devices.append(device);
|
||||||
|
}
|
||||||
|
|
||||||
ports.append(move(controllerPort1));
|
ports.append(move(controllerPort1));
|
||||||
ports.append(move(controllerPort2));
|
ports.append(move(controllerPort2));
|
||||||
|
ports.append(move(hardware));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MasterSystemInterface::videoResolution() -> VideoResolution {
|
auto MasterSystemInterface::videoResolution() -> VideoResolution {
|
||||||
|
@@ -293,8 +293,9 @@ auto PPU::writeIO(uint24 addr, uint8 data) -> void {
|
|||||||
io.hoffsetMode7 = data << 8 | latch.mode7;
|
io.hoffsetMode7 = data << 8 | latch.mode7;
|
||||||
latch.mode7 = data;
|
latch.mode7 = data;
|
||||||
|
|
||||||
bg1.io.hoffset = data << 8 | (latch.bgofs & ~7) | (bg1.io.hoffset >> 8 & 7);
|
bg1.io.hoffset = data << 8 | (latch.bgofsPPU1 & ~7) | (latch.bgofsPPU2 & 7);
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
|
latch.bgofsPPU2 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,50 +304,53 @@ auto PPU::writeIO(uint24 addr, uint8 data) -> void {
|
|||||||
io.voffsetMode7 = data << 8 | latch.mode7;
|
io.voffsetMode7 = data << 8 | latch.mode7;
|
||||||
latch.mode7 = data;
|
latch.mode7 = data;
|
||||||
|
|
||||||
bg1.io.voffset = data << 8 | latch.bgofs;
|
bg1.io.voffset = data << 8 | latch.bgofsPPU1;
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG2HOFS
|
//BG2HOFS
|
||||||
case 0x210f: {
|
case 0x210f: {
|
||||||
bg2.io.hoffset = data << 8 | (latch.bgofs & ~7) | (bg2.io.hoffset >> 8 & 7);
|
bg2.io.hoffset = data << 8 | (latch.bgofsPPU1 & ~7) | (latch.bgofsPPU2 & 7);
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
|
latch.bgofsPPU2 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG2VOFS
|
//BG2VOFS
|
||||||
case 0x2110: {
|
case 0x2110: {
|
||||||
bg2.io.voffset = data << 8 | latch.bgofs;
|
bg2.io.voffset = data << 8 | latch.bgofsPPU1;
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG3HOFS
|
//BG3HOFS
|
||||||
case 0x2111: {
|
case 0x2111: {
|
||||||
bg3.io.hoffset = data << 8 | (latch.bgofs & ~7) | (bg3.io.hoffset >> 8 & 7);
|
bg3.io.hoffset = data << 8 | (latch.bgofsPPU1 & ~7) | (latch.bgofsPPU2 & 7);
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
|
latch.bgofsPPU2 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG3VOFS
|
//BG3VOFS
|
||||||
case 0x2112: {
|
case 0x2112: {
|
||||||
bg3.io.voffset = data << 8 | latch.bgofs;
|
bg3.io.voffset = data << 8 | latch.bgofsPPU1;
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG4HOFS
|
//BG4HOFS
|
||||||
case 0x2113: {
|
case 0x2113: {
|
||||||
bg4.io.hoffset = data << 8 | (latch.bgofs & ~7) | (bg4.io.hoffset >> 8 & 7);
|
bg4.io.hoffset = data << 8 | (latch.bgofsPPU1 & ~7) | (latch.bgofsPPU2 & 7);
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
|
latch.bgofsPPU2 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BG4VOFS
|
//BG4VOFS
|
||||||
case 0x2114: {
|
case 0x2114: {
|
||||||
bg4.io.voffset = data << 8 | latch.bgofs;
|
bg4.io.voffset = data << 8 | latch.bgofsPPU1;
|
||||||
latch.bgofs = data;
|
latch.bgofsPPU1 = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,7 +103,8 @@ auto PPU::power() -> void {
|
|||||||
latch.vram = random(0x0000);
|
latch.vram = random(0x0000);
|
||||||
latch.oam = random(0x00);
|
latch.oam = random(0x00);
|
||||||
latch.cgram = random(0x00);
|
latch.cgram = random(0x00);
|
||||||
latch.bgofs = random(0x00);
|
latch.bgofsPPU1 = random(0x00);
|
||||||
|
latch.bgofsPPU2 = random(0x00);
|
||||||
latch.mode7 = random(0x00);
|
latch.mode7 = random(0x00);
|
||||||
latch.counters = false;
|
latch.counters = false;
|
||||||
latch.hcounter = 0;
|
latch.hcounter = 0;
|
||||||
|
@@ -55,7 +55,8 @@ private:
|
|||||||
uint16 vram;
|
uint16 vram;
|
||||||
uint8 oam;
|
uint8 oam;
|
||||||
uint8 cgram;
|
uint8 cgram;
|
||||||
uint8 bgofs;
|
uint8 bgofsPPU1;
|
||||||
|
uint3 bgofsPPU2;
|
||||||
uint8 mode7;
|
uint8 mode7;
|
||||||
uint1 counters;
|
uint1 counters;
|
||||||
uint1 hcounter;
|
uint1 hcounter;
|
||||||
|
@@ -29,7 +29,8 @@ auto PPU::serialize(serializer& s) -> void {
|
|||||||
s.integer(latch.vram);
|
s.integer(latch.vram);
|
||||||
s.integer(latch.oam);
|
s.integer(latch.oam);
|
||||||
s.integer(latch.cgram);
|
s.integer(latch.cgram);
|
||||||
s.integer(latch.bgofs);
|
s.integer(latch.bgofsPPU1);
|
||||||
|
s.integer(latch.bgofsPPU2);
|
||||||
s.integer(latch.mode7);
|
s.integer(latch.mode7);
|
||||||
s.integer(latch.counters);
|
s.integer(latch.counters);
|
||||||
s.integer(latch.hcounter);
|
s.integer(latch.hcounter);
|
||||||
|
@@ -96,7 +96,8 @@ auto InputManager::appendHotkeys() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto InputManager::pollHotkeys() -> void {
|
auto InputManager::pollHotkeys() -> void {
|
||||||
if(program->allowInput(true)) {
|
if(!program->focused()) return;
|
||||||
|
|
||||||
for(auto& hotkey : hotkeys) {
|
for(auto& hotkey : hotkeys) {
|
||||||
int16 state = hotkey->poll();
|
int16 state = hotkey->poll();
|
||||||
if(hotkey->state == 0 && state == 1 && hotkey->press) hotkey->press();
|
if(hotkey->state == 0 && state == 1 && hotkey->press) hotkey->press();
|
||||||
@@ -104,4 +105,3 @@ auto InputManager::pollHotkeys() -> void {
|
|||||||
hotkey->state = state;
|
hotkey->state = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@@ -192,27 +192,29 @@ InputManager::InputManager() {
|
|||||||
frequency = max(1u, settings["Input/Frequency"].natural());
|
frequency = max(1u, settings["Input/Frequency"].natural());
|
||||||
|
|
||||||
for(auto& emulator : program->emulators) {
|
for(auto& emulator : program->emulators) {
|
||||||
auto& inputEmulator = emulators(emulators.size());
|
InputEmulator inputEmulator;
|
||||||
inputEmulator.interface = emulator;
|
inputEmulator.interface = emulator;
|
||||||
inputEmulator.name = emulator->information.name;
|
inputEmulator.name = emulator->information.name;
|
||||||
|
|
||||||
for(auto& port : emulator->ports) {
|
for(auto& port : emulator->ports) {
|
||||||
auto& inputPort = inputEmulator.ports(port.id);
|
InputPort inputPort{port.id, port.name};
|
||||||
inputPort.name = port.name;
|
|
||||||
for(auto& device : port.devices) {
|
for(auto& device : port.devices) {
|
||||||
auto& inputDevice = inputPort.devices(device.id);
|
InputDevice inputDevice{device.id, device.name};
|
||||||
inputDevice.name = device.name;
|
|
||||||
for(auto& input : device.inputs) {
|
for(auto& input : device.inputs) {
|
||||||
auto& inputMapping = inputDevice.mappings(inputDevice.mappings.size());
|
InputMapping inputMapping;
|
||||||
inputMapping.name = input.name;
|
inputMapping.name = input.name;
|
||||||
inputMapping.type = input.type;
|
inputMapping.type = input.type;
|
||||||
|
|
||||||
inputMapping.path = string{inputEmulator.name, "/", inputPort.name, "/", inputDevice.name, "/", inputMapping.name}.replace(" ", "");
|
inputMapping.path = string{inputEmulator.name, "/", inputPort.name, "/", inputDevice.name, "/", inputMapping.name}.replace(" ", "");
|
||||||
inputMapping.assignment = settings(inputMapping.path).text();
|
inputMapping.assignment = settings(inputMapping.path).text();
|
||||||
inputMapping.bind();
|
inputMapping.bind();
|
||||||
|
|
||||||
|
inputDevice.mappings.append(inputMapping);
|
||||||
}
|
}
|
||||||
|
inputPort.devices.append(inputDevice);
|
||||||
}
|
}
|
||||||
|
inputEmulator.ports.append(move(inputPort));
|
||||||
}
|
}
|
||||||
|
emulators.append(move(inputEmulator));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendHotkeys();
|
appendHotkeys();
|
||||||
@@ -278,6 +280,19 @@ auto InputManager::quit() -> void {
|
|||||||
hotkeys.reset();
|
hotkeys.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto InputManager::mapping(uint port, uint device, uint input) -> maybe<InputMapping&> {
|
||||||
|
if(!emulator) return nothing;
|
||||||
|
for(auto& inputPort : emulator->ports) {
|
||||||
|
if(inputPort.id != port) continue;
|
||||||
|
for(auto& inputDevice : inputPort.devices) {
|
||||||
|
if(inputDevice.id != device) continue;
|
||||||
|
if(input >= inputDevice.mappings.size()) return nothing;
|
||||||
|
return inputDevice.mappings[input];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
auto InputManager::findMouse() -> shared_pointer<HID::Device> {
|
auto InputManager::findMouse() -> shared_pointer<HID::Device> {
|
||||||
for(auto& device : devices) {
|
for(auto& device : devices) {
|
||||||
if(device->isMouse()) return device;
|
if(device->isMouse()) return device;
|
||||||
|
@@ -39,11 +39,13 @@ struct InputHotkey : InputMapping {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct InputDevice {
|
struct InputDevice {
|
||||||
|
uint id;
|
||||||
string name;
|
string name;
|
||||||
vector<InputMapping> mappings;
|
vector<InputMapping> mappings;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InputPort {
|
struct InputPort {
|
||||||
|
uint id;
|
||||||
string name;
|
string name;
|
||||||
vector<InputDevice> devices;
|
vector<InputDevice> devices;
|
||||||
};
|
};
|
||||||
@@ -62,6 +64,7 @@ struct InputManager {
|
|||||||
auto onChange(shared_pointer<HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void;
|
auto onChange(shared_pointer<HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void;
|
||||||
auto quit() -> void;
|
auto quit() -> void;
|
||||||
|
|
||||||
|
auto mapping(uint port, uint device, uint input) -> maybe<InputMapping&>;
|
||||||
auto findMouse() -> shared_pointer<HID::Device>;
|
auto findMouse() -> shared_pointer<HID::Device>;
|
||||||
|
|
||||||
//hotkeys.cpp
|
//hotkeys.cpp
|
||||||
|
@@ -23,4 +23,5 @@ AboutWindow::AboutWindow() {
|
|||||||
setResizable(false);
|
setResizable(false);
|
||||||
setSize(layout.minimumSize());
|
setSize(layout.minimumSize());
|
||||||
setCentered();
|
setCentered();
|
||||||
|
setDismissable();
|
||||||
}
|
}
|
||||||
|
@@ -96,18 +96,20 @@ auto Program::audioSample(const double* samples, uint channels) -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto Program::inputPoll(uint port, uint device, uint input) -> int16 {
|
auto Program::inputPoll(uint port, uint device, uint input) -> int16 {
|
||||||
if(allowInput()) {
|
if(focused() || settings["Input/FocusLoss/AllowInput"].boolean()) {
|
||||||
inputManager->poll();
|
inputManager->poll();
|
||||||
auto& mapping = inputManager->emulator->ports[port].devices[device].mappings[input];
|
if(auto mapping = inputManager->mapping(port, device, input)) {
|
||||||
return mapping.poll();
|
return mapping->poll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Program::inputRumble(uint port, uint device, uint input, bool enable) -> void {
|
auto Program::inputRumble(uint port, uint device, uint input, bool enable) -> void {
|
||||||
if(allowInput() || !enable) {
|
if(focused() || settings["Input/FocusLoss/AllowInput"].boolean() || !enable) {
|
||||||
auto& mapping = inputManager->emulator->ports[port].devices[device].mappings[input];
|
if(auto mapping = inputManager->mapping(port, device, input)) {
|
||||||
return mapping.rumble(enable);
|
return mapping->rumble(enable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ auto Program::main() -> void {
|
|||||||
inputManager->poll();
|
inputManager->poll();
|
||||||
inputManager->pollHotkeys();
|
inputManager->pollHotkeys();
|
||||||
|
|
||||||
if(!emulator || !emulator->loaded() || pause || (!presentation->focused() && settings["Input/FocusLoss/Pause"].boolean())) {
|
if(!emulator || !emulator->loaded() || pause || (!focused() && settings["Input/FocusLoss/Pause"].boolean())) {
|
||||||
audio->clear();
|
audio->clear();
|
||||||
usleep(20 * 1000);
|
usleep(20 * 1000);
|
||||||
return;
|
return;
|
||||||
|
@@ -35,7 +35,7 @@ struct Program : Emulator::Platform {
|
|||||||
auto updateVideoShader() -> void;
|
auto updateVideoShader() -> void;
|
||||||
auto updateAudioDriver() -> void;
|
auto updateAudioDriver() -> void;
|
||||||
auto updateAudioEffects() -> void;
|
auto updateAudioEffects() -> void;
|
||||||
auto allowInput(bool hotkey = false) -> bool;
|
auto focused() -> bool;
|
||||||
|
|
||||||
bool hasQuit = false;
|
bool hasQuit = false;
|
||||||
bool pause = false;
|
bool pause = false;
|
||||||
|
@@ -93,7 +93,7 @@ auto Program::updateAudioEffects() -> void {
|
|||||||
Emulator::audio.setReverb(reverbEnable);
|
Emulator::audio.setReverb(reverbEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Program::allowInput(bool hotkey) -> bool {
|
auto Program::focused() -> bool {
|
||||||
//exclusive mode creates its own top-level window: presentation window will not have focus
|
//exclusive mode creates its own top-level window: presentation window will not have focus
|
||||||
if(video->cap(Video::Exclusive)) {
|
if(video->cap(Video::Exclusive)) {
|
||||||
auto value = video->get(Video::Exclusive);
|
auto value = video->get(Video::Exclusive);
|
||||||
@@ -102,7 +102,5 @@ auto Program::allowInput(bool hotkey) -> bool {
|
|||||||
|
|
||||||
if(presentation && presentation->focused()) return true;
|
if(presentation && presentation->focused()) return true;
|
||||||
|
|
||||||
if(!hotkey && settings["Input/FocusLoss/AllowInput"].boolean()) return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ SettingsManager::SettingsManager() {
|
|||||||
setTitle("Configuration Settings");
|
setTitle("Configuration Settings");
|
||||||
setSize({600, 405});
|
setSize({600, 405});
|
||||||
setAlignment({0.0, 1.0});
|
setAlignment({0.0, 1.0});
|
||||||
|
setDismissable();
|
||||||
|
|
||||||
onSize([&] {
|
onSize([&] {
|
||||||
input.mappingList.resizeColumns();
|
input.mappingList.resizeColumns();
|
||||||
|
@@ -12,6 +12,7 @@ CheatDatabase::CheatDatabase() {
|
|||||||
|
|
||||||
setSize({800, 400});
|
setSize({800, 400});
|
||||||
setAlignment({0.5, 1.0});
|
setAlignment({0.5, 1.0});
|
||||||
|
setDismissable();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CheatDatabase::findCodes() -> void {
|
auto CheatDatabase::findCodes() -> void {
|
||||||
|
@@ -14,6 +14,7 @@ ToolsManager::ToolsManager() {
|
|||||||
setTitle("Tools");
|
setTitle("Tools");
|
||||||
setSize({600, 405});
|
setSize({600, 405});
|
||||||
setAlignment({1.0, 1.0});
|
setAlignment({1.0, 1.0});
|
||||||
|
setDismissable();
|
||||||
|
|
||||||
onSize([&] {
|
onSize([&] {
|
||||||
cheatEditor.cheatList.resizeColumns();
|
cheatEditor.cheatList.resizeColumns();
|
||||||
|
@@ -243,6 +243,10 @@ auto pWindow::setBackgroundColor(Color color) -> void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pWindow::setDismissable(bool dismissable) -> void {
|
||||||
|
//todo: not implemented
|
||||||
|
}
|
||||||
|
|
||||||
auto pWindow::setDroppable(bool droppable) -> void {
|
auto pWindow::setDroppable(bool droppable) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if(droppable) {
|
if(droppable) {
|
||||||
@@ -404,15 +408,6 @@ auto pWindow::_geometry() -> Geometry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
auto pWindow::remove(Widget& widget) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
[widget.p.cocoaView removeFromSuperview];
|
|
||||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -39,6 +39,7 @@ struct pWindow : pObject {
|
|||||||
auto remove(sMenuBar menuBar) -> void;
|
auto remove(sMenuBar menuBar) -> void;
|
||||||
auto remove(sStatusBar statusBar) -> void;
|
auto remove(sStatusBar statusBar) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
auto setDismissable(bool dismissable) -> void;
|
||||||
auto setDroppable(bool droppable) -> void;
|
auto setDroppable(bool droppable) -> void;
|
||||||
auto setFocused() -> void override;
|
auto setFocused() -> void override;
|
||||||
auto setFullScreen(bool fullScreen) -> void;
|
auto setFullScreen(bool fullScreen) -> void;
|
||||||
|
@@ -672,6 +672,7 @@ struct mWindow : mObject {
|
|||||||
auto append(sMenuBar menuBar) -> type&;
|
auto append(sMenuBar menuBar) -> type&;
|
||||||
auto append(sStatusBar statusBar) -> type&;
|
auto append(sStatusBar statusBar) -> type&;
|
||||||
auto backgroundColor() const -> Color;
|
auto backgroundColor() const -> Color;
|
||||||
|
auto dismissable() const -> bool;
|
||||||
auto doClose() const -> void;
|
auto doClose() const -> void;
|
||||||
auto doDrop(string_vector) const -> void;
|
auto doDrop(string_vector) const -> void;
|
||||||
auto doKeyPress(signed) const -> void;
|
auto doKeyPress(signed) const -> void;
|
||||||
@@ -699,6 +700,7 @@ struct mWindow : mObject {
|
|||||||
auto setAlignment(Alignment alignment) -> type&;
|
auto setAlignment(Alignment alignment) -> type&;
|
||||||
auto setBackgroundColor(Color color = {}) -> type&;
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
auto setCentered(sWindow parent = {}) -> type&;
|
auto setCentered(sWindow parent = {}) -> type&;
|
||||||
|
auto setDismissable(bool dismissable = true) -> type&;
|
||||||
auto setDroppable(bool droppable = true) -> type&;
|
auto setDroppable(bool droppable = true) -> type&;
|
||||||
auto setFrameGeometry(Geometry geometry) -> type&;
|
auto setFrameGeometry(Geometry geometry) -> type&;
|
||||||
auto setFramePosition(Position position) -> type&;
|
auto setFramePosition(Position position) -> type&;
|
||||||
@@ -716,6 +718,7 @@ struct mWindow : mObject {
|
|||||||
//private:
|
//private:
|
||||||
struct State {
|
struct State {
|
||||||
Color backgroundColor;
|
Color backgroundColor;
|
||||||
|
bool dismissable = false;
|
||||||
bool droppable = false;
|
bool droppable = false;
|
||||||
bool fullScreen = false;
|
bool fullScreen = false;
|
||||||
Geometry geometry = {128, 128, 256, 256};
|
Geometry geometry = {128, 128, 256, 256};
|
||||||
|
@@ -936,6 +936,7 @@ struct Window : sWindow {
|
|||||||
auto append(sMenuBar menuBar) { return self().append(menuBar), *this; }
|
auto append(sMenuBar menuBar) { return self().append(menuBar), *this; }
|
||||||
auto append(sStatusBar statusBar) { return self().append(statusBar), *this; }
|
auto append(sStatusBar statusBar) { return self().append(statusBar), *this; }
|
||||||
auto backgroundColor() const { return self().backgroundColor(); }
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto dismissable() const { return self().dismissable(); }
|
||||||
auto doClose() const { return self().doClose(); }
|
auto doClose() const { return self().doClose(); }
|
||||||
auto doDrop(string_vector names) const { return self().doDrop(names); }
|
auto doDrop(string_vector names) const { return self().doDrop(names); }
|
||||||
auto doKeyPress(signed key) const { return self().doKeyPress(key); }
|
auto doKeyPress(signed key) const { return self().doKeyPress(key); }
|
||||||
@@ -963,6 +964,7 @@ struct Window : sWindow {
|
|||||||
auto setAlignment(Alignment alignment) { return self().setAlignment(alignment), *this; }
|
auto setAlignment(Alignment alignment) { return self().setAlignment(alignment), *this; }
|
||||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
auto setCentered(sWindow parent = {}) { return self().setCentered(parent), *this; }
|
auto setCentered(sWindow parent = {}) { return self().setCentered(parent), *this; }
|
||||||
|
auto setDismissable(bool dismissable = true) { return self().setDismissable(dismissable), *this; }
|
||||||
auto setDroppable(bool droppable = true) { return self().setDroppable(droppable), *this; }
|
auto setDroppable(bool droppable = true) { return self().setDroppable(droppable), *this; }
|
||||||
auto setFrameGeometry(Geometry geometry) { return self().setFrameGeometry(geometry), *this; }
|
auto setFrameGeometry(Geometry geometry) { return self().setFrameGeometry(geometry), *this; }
|
||||||
auto setFramePosition(Position position) { return self().setFramePosition(position), *this; }
|
auto setFramePosition(Position position) { return self().setFramePosition(position), *this; }
|
||||||
|
@@ -43,6 +43,10 @@ auto mWindow::backgroundColor() const -> Color {
|
|||||||
return state.backgroundColor;
|
return state.backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mWindow::dismissable() const -> bool {
|
||||||
|
return state.dismissable;
|
||||||
|
}
|
||||||
|
|
||||||
auto mWindow::doClose() const -> void {
|
auto mWindow::doClose() const -> void {
|
||||||
if(state.onClose) return state.onClose();
|
if(state.onClose) return state.onClose();
|
||||||
}
|
}
|
||||||
@@ -188,6 +192,12 @@ auto mWindow::setCentered(sWindow parent) -> type& {
|
|||||||
return setFrameGeometry({x, y, geometry.width(), geometry.height()});
|
return setFrameGeometry({x, y, geometry.width(), geometry.height()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mWindow::setDismissable(bool dismissable) -> type& {
|
||||||
|
state.dismissable = dismissable;
|
||||||
|
signal(setDismissable, dismissable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
auto mWindow::setDroppable(bool droppable) -> type& {
|
auto mWindow::setDroppable(bool droppable) -> type& {
|
||||||
state.droppable = droppable;
|
state.droppable = droppable;
|
||||||
signal(setDroppable, droppable);
|
signal(setDroppable, droppable);
|
||||||
|
@@ -153,6 +153,7 @@ auto BrowserDialogWindow::run() -> BrowserDialog::Response {
|
|||||||
window.setTitle(state.title);
|
window.setTitle(state.title);
|
||||||
window.setSize({640, 480});
|
window.setSize({640, 480});
|
||||||
window.setCentered(state.parent);
|
window.setCentered(state.parent);
|
||||||
|
window.setDismissable();
|
||||||
window.setVisible();
|
window.setVisible();
|
||||||
view.setFocused();
|
view.setFocused();
|
||||||
window.setModal();
|
window.setModal();
|
||||||
|
@@ -71,6 +71,7 @@ auto MessageDialog::_run() -> string {
|
|||||||
window.setResizable(false);
|
window.setResizable(false);
|
||||||
window.setSize({width, layout.minimumSize().height()});
|
window.setSize({width, layout.minimumSize().height()});
|
||||||
window.setCentered(state.parent);
|
window.setCentered(state.parent);
|
||||||
|
window.setDismissable();
|
||||||
window.setVisible();
|
window.setVisible();
|
||||||
window.setModal();
|
window.setModal();
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
|
@@ -89,6 +89,14 @@ static auto Window_keyPress(GtkWidget* widget, GdkEventKey* event, pWindow* p) -
|
|||||||
if(auto key = pKeyboard::_translate(event->keyval)) {
|
if(auto key = pKeyboard::_translate(event->keyval)) {
|
||||||
p->self().doKeyPress(key);
|
p->self().doKeyPress(key);
|
||||||
}
|
}
|
||||||
|
if(p->state().dismissable && event->keyval == GDK_Escape) {
|
||||||
|
if(p->state().onClose) {
|
||||||
|
p->self().doClose();
|
||||||
|
} else {
|
||||||
|
p->self().setVisible(false);
|
||||||
|
}
|
||||||
|
if(p->state().modal && !p->pObject::state().visible) p->self().setModal(false);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +242,9 @@ auto pWindow::setBackgroundColor(Color color) -> void {
|
|||||||
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pWindow::setDismissable(bool dismissable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
auto pWindow::setDroppable(bool droppable) -> void {
|
auto pWindow::setDroppable(bool droppable) -> void {
|
||||||
gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, nullptr, 0, GDK_ACTION_COPY);
|
gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, nullptr, 0, GDK_ACTION_COPY);
|
||||||
if(droppable) gtk_drag_dest_add_uri_targets(widget);
|
if(droppable) gtk_drag_dest_add_uri_targets(widget);
|
||||||
|
@@ -14,6 +14,7 @@ struct pWindow : pObject {
|
|||||||
auto remove(sMenuBar menuBar) -> void;
|
auto remove(sMenuBar menuBar) -> void;
|
||||||
auto remove(sStatusBar statusBar) -> void;
|
auto remove(sStatusBar statusBar) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
auto setDismissable(bool dismissable) -> void;
|
||||||
auto setDroppable(bool droppable) -> void;
|
auto setDroppable(bool droppable) -> void;
|
||||||
auto setEnabled(bool enabled) -> void override;
|
auto setEnabled(bool enabled) -> void override;
|
||||||
auto setFocused() -> void override;
|
auto setFocused() -> void override;
|
||||||
|
@@ -100,6 +100,9 @@ auto pWindow::setBackgroundColor(Color color) -> void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pWindow::setDismissable(bool dismissable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
auto pWindow::setDroppable(bool droppable) -> void {
|
auto pWindow::setDroppable(bool droppable) -> void {
|
||||||
qtWindow->setAcceptDrops(droppable);
|
qtWindow->setAcceptDrops(droppable);
|
||||||
}
|
}
|
||||||
@@ -144,10 +147,6 @@ auto pWindow::setGeometry(Geometry geometry) -> void {
|
|||||||
qtContainer->setMinimumSize(1, 1);
|
qtContainer->setMinimumSize(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(auto& layout : window.state.layout) {
|
|
||||||
// geometry.x = geometry.y = 0;
|
|
||||||
// layout.setGeometry(geometry);
|
|
||||||
// }
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,20 +193,6 @@ auto pWindow::setVisible(bool visible) -> void {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if(!widget.font() && window.state.widgetFont) {
|
|
||||||
widget.setFont(window.state.widgetFont);
|
|
||||||
}
|
|
||||||
if(!widget.font()) widget.p.setFont(Font::sans(8));
|
|
||||||
if(GetParentWidget(&widget)) {
|
|
||||||
widget.p.qtWidget->setParent(GetParentWidget(&widget)->p.container(widget));
|
|
||||||
} else {
|
|
||||||
widget.p.qtWidget->setParent(qtContainer);
|
|
||||||
}
|
|
||||||
widget.setVisible(widget.visible());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
auto pWindow::_append(mWidget& widget) -> void {
|
auto pWindow::_append(mWidget& widget) -> void {
|
||||||
if(auto self = widget.self()) {
|
if(auto self = widget.self()) {
|
||||||
self->qtWidget->setParent(qtContainer);
|
self->qtWidget->setParent(qtContainer);
|
||||||
@@ -276,6 +261,12 @@ auto QtWindow::dropEvent(QDropEvent* event) -> void {
|
|||||||
auto QtWindow::keyPressEvent(QKeyEvent* event) -> void {
|
auto QtWindow::keyPressEvent(QKeyEvent* event) -> void {
|
||||||
//Keyboard::Keycode sym = Keysym(event->nativeVirtualKey());
|
//Keyboard::Keycode sym = Keysym(event->nativeVirtualKey());
|
||||||
//if(sym != Keyboard::Keycode::None && self.window.onKeyPress) self.window.onKeyPress(sym);
|
//if(sym != Keyboard::Keycode::None && self.window.onKeyPress) self.window.onKeyPress(sym);
|
||||||
|
|
||||||
|
if(p.state().dismissable && event->key() == Qt::Key_Escape) {
|
||||||
|
if(p.state().onClose) p.self().doClose();
|
||||||
|
else p.self().setVisible(false);
|
||||||
|
if(p.state().modal && !p.self().visible()) p.self().setModal(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtWindow::keyReleaseEvent(QKeyEvent* event) -> void {
|
auto QtWindow::keyReleaseEvent(QKeyEvent* event) -> void {
|
||||||
|
@@ -14,6 +14,7 @@ struct pWindow : pObject {
|
|||||||
auto remove(sMenuBar menuBar) -> void;
|
auto remove(sMenuBar menuBar) -> void;
|
||||||
auto remove(sStatusBar statusBar) -> void;
|
auto remove(sStatusBar statusBar) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
auto setDismissable(bool dismissable) -> void;
|
||||||
auto setDroppable(bool droppable) -> void;
|
auto setDroppable(bool droppable) -> void;
|
||||||
auto setEnabled(bool enabled) -> void override;
|
auto setEnabled(bool enabled) -> void override;
|
||||||
auto setFocused() -> void override;
|
auto setFocused() -> void override;
|
||||||
|
@@ -146,8 +146,15 @@ static auto Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
|||||||
if(auto self = window->self()) {
|
if(auto self = window->self()) {
|
||||||
if(!self->_modalityDisabled()) {
|
if(!self->_modalityDisabled()) {
|
||||||
if(auto code = pKeyboard::_translate(wparam, lparam)) {
|
if(auto code = pKeyboard::_translate(wparam, lparam)) {
|
||||||
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) window->doKeyPress(code);
|
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) {
|
||||||
if(msg == WM_KEYUP || msg == WM_SYSKEYUP) window->doKeyRelease(code);
|
window->doKeyPress(code);
|
||||||
|
}
|
||||||
|
if(msg == WM_KEYUP || msg == WM_SYSKEYUP) {
|
||||||
|
window->doKeyRelease(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(window->state.dismissable && msg == WM_KEYDOWN && wparam == VK_ESCAPE) {
|
||||||
|
self->onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,6 +67,9 @@ auto pWindow::setBackgroundColor(Color color) -> void {
|
|||||||
if(color) hbrush = CreateSolidBrush(hbrushColor);
|
if(color) hbrush = CreateSolidBrush(hbrushColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pWindow::setDismissable(bool dismissable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
auto pWindow::setDroppable(bool droppable) -> void {
|
auto pWindow::setDroppable(bool droppable) -> void {
|
||||||
DragAcceptFiles(hwnd, droppable);
|
DragAcceptFiles(hwnd, droppable);
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@ struct pWindow : pObject {
|
|||||||
auto remove(sMenuBar menuBar) -> void;
|
auto remove(sMenuBar menuBar) -> void;
|
||||||
auto remove(sStatusBar statusBar) -> void;
|
auto remove(sStatusBar statusBar) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
auto setDismissable(bool dismissable) -> void;
|
||||||
auto setDroppable(bool droppable) -> void;
|
auto setDroppable(bool droppable) -> void;
|
||||||
auto setEnabled(bool enabled) -> void;
|
auto setEnabled(bool enabled) -> void;
|
||||||
auto setFocused() -> void;
|
auto setFocused() -> void;
|
||||||
|
@@ -94,14 +94,14 @@ auto slice(string_view self, int offset, int length) -> string {
|
|||||||
|
|
||||||
template<typename T> auto fromInteger(char* result, T value) -> char* {
|
template<typename T> auto fromInteger(char* result, T value) -> char* {
|
||||||
bool negative = value < 0;
|
bool negative = value < 0;
|
||||||
if(negative) value = -value;
|
if(!negative) value = -value; //negate positive integers to support eg INT_MIN
|
||||||
|
|
||||||
char buffer[1 + sizeof(T) * 3];
|
char buffer[1 + sizeof(T) * 3];
|
||||||
uint size = 0;
|
uint size = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint n = value % 10;
|
int n = value % 10; //-0 to -9
|
||||||
buffer[size++] = '0' + n;
|
buffer[size++] = '0' - n; //'0' to '9'
|
||||||
value /= 10;
|
value /= 10;
|
||||||
} while(value);
|
} while(value);
|
||||||
if(negative) buffer[size++] = '-';
|
if(negative) buffer[size++] = '-';
|
||||||
|
Reference in New Issue
Block a user