2015-04-21 11:51:57 +00:00
|
|
|
StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) {
|
2016-01-07 08:14:33 +00:00
|
|
|
setIcon(Icon::Application::FileManager);
|
2015-04-21 11:51:57 +00:00
|
|
|
setText("State Manager");
|
|
|
|
|
|
|
|
layout.setMargin(5);
|
Update to v094r40 release.
byuu says:
Changelog:
- updated to newest hiro API
- SFC performance profile builds once again
- hiro: Qt port completed
Errata 1: the hiro/Qt target won't run tomoko just yet. Starts by
crashing inside InputSettings because hiro/Qt isn't forcefully selecting
the first item added to a ComboButton just yet. Even with a monkey patch
to get around that, the UI is incredibly unstable. Lots of geometry
calculation bugs, and a crash when you try and access certain folders in
the browser dialog. Lots of work left to be done there, sadly.
Errata 2: the hiro/Windows port has black backgrounds on all ListView
items. It's because I need to test for unassigned colors and grab the
default Windows brush colors in those cases.
Note: alternating row colors on multi-column ListView widgets is gone
now. Not a bug. May add it back later, but I'm not sure. It doesn't
interact nicely with per-cell background colors.
Things left to do:
First, I have to fix the Windows and Qt target bugs.
Next, I need to go through and revise the hiro API even more (nothing
too major.)
Next, I need to update icarus to use the new hiro API, and add support
for the SFC games database.
Next, I have to rewrite my TSV->BML cheat code tool.
Next, I need to post a final WIP of higan+icarus publicly and wait a few
days.
Next, I need to fix any bugs reported from the final WIP that I can.
Finally, I should be able to release v095.
2015-08-18 10:18:00 +00:00
|
|
|
stateList.append(ListViewHeader().setVisible()
|
|
|
|
.append(ListViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
|
|
|
.append(ListViewColumn().setText("Description").setExpandable())
|
|
|
|
);
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto slot : range(Slots)) {
|
|
|
|
stateList.append(ListViewItem()
|
|
|
|
.append(ListViewCell().setText(1 + slot))
|
|
|
|
.append(ListViewCell())
|
|
|
|
);
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
stateList.onActivate([&] { doLoad(); });
|
2015-06-18 10:48:53 +00:00
|
|
|
stateList.onChange([&] { doChangeSelected(); });
|
2015-04-21 11:51:57 +00:00
|
|
|
descriptionLabel.setText("Description:");
|
2015-06-18 10:48:53 +00:00
|
|
|
descriptionValue.onChange([&] { doChangeDescription(); });
|
2015-04-21 11:51:57 +00:00
|
|
|
saveButton.setText("Save").onActivate([&] { doSave(); });
|
|
|
|
loadButton.setText("Load").onActivate([&] { doLoad(); });
|
|
|
|
resetButton.setText("Reset").onActivate([&] { doReset(); });
|
|
|
|
eraseButton.setText("Erase").onActivate([&] { doErase(); });
|
2015-07-02 10:22:24 +00:00
|
|
|
|
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doUpdateControls() -> void {
|
2016-02-16 09:27:55 +00:00
|
|
|
vector<uint8_t> buffer;
|
2015-04-21 11:51:57 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(buffer.size() >= 584) {
|
2015-06-18 10:48:53 +00:00
|
|
|
descriptionValue.setEnabled(true);
|
2015-04-21 11:51:57 +00:00
|
|
|
loadButton.setEnabled(true);
|
|
|
|
eraseButton.setEnabled(true);
|
|
|
|
} else {
|
2015-07-02 10:22:24 +00:00
|
|
|
descriptionValue.setEnabled(false).setText("");
|
2015-04-21 11:51:57 +00:00
|
|
|
loadButton.setEnabled(false);
|
|
|
|
eraseButton.setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doChangeSelected() -> void {
|
2016-02-16 09:27:55 +00:00
|
|
|
vector<uint8_t> buffer;
|
2015-06-18 10:48:53 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
|
|
|
buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-07-02 10:22:24 +00:00
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description;
|
|
|
|
description.reserve(512);
|
2015-08-02 06:23:13 +00:00
|
|
|
memory::copy(description.get(), buffer.data() + 72, 512);
|
2015-07-02 10:22:24 +00:00
|
|
|
description.resize(description.length());
|
|
|
|
descriptionValue.setEnabled(true).setText(description);
|
|
|
|
return doUpdateControls();
|
|
|
|
}
|
2015-06-18 10:48:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 10:22:24 +00:00
|
|
|
descriptionValue.setEnabled(false).setText("");
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
|
|
|
}
|
|
|
|
|
2015-04-21 11:51:57 +00:00
|
|
|
auto StateManager::doRefresh() -> void {
|
2015-06-18 10:48:53 +00:00
|
|
|
for(auto slot : range(Slots)) {
|
2015-04-21 11:51:57 +00:00
|
|
|
auto buffer = file::read(program->stateName(1 + slot, true));
|
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description;
|
|
|
|
description.reserve(512);
|
2015-08-02 06:23:13 +00:00
|
|
|
memory::copy(description.get(), buffer.data() + 72, 512);
|
2015-04-21 11:51:57 +00:00
|
|
|
description.resize(description.length());
|
2015-06-18 10:48:53 +00:00
|
|
|
stateList.item(slot).cell(1).setText(description).setForegroundColor({0, 0, 0});
|
2015-04-21 11:51:57 +00:00
|
|
|
} else {
|
2015-06-18 10:48:53 +00:00
|
|
|
stateList.item(slot).cell(1).setText("(empty)").setForegroundColor({128, 128, 128});
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto StateManager::doChangeDescription() -> void {
|
2015-04-21 11:51:57 +00:00
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
auto buffer = file::read(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
if(buffer.size() >= 584) {
|
|
|
|
string description = descriptionValue.text();
|
|
|
|
description.reserve(512);
|
|
|
|
memory::copy(buffer.data() + 72, description.data(), 512);
|
2015-06-18 10:48:53 +00:00
|
|
|
file::write(program->stateName(1 + item.offset(), true), buffer);
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doLoad() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
program->loadState(1 + item.offset(), true);
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doSave() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
program->saveState(1 + item.offset(), true);
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
|
|
|
descriptionValue.setText("").setFocused();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doReset() -> void {
|
Update to v094r23 release.
byuu says:
The library window is gone, and replaced with
hiro::BrowserWindow::openFolder(). This gives navigation capabilities to
game loading, and it also completes our slotted cart selection code. As
an added bonus, it's less code this way, too.
I also set the window size to consistent sizes between all emulated
systems, so that switching between SFC and GB don't cause the window
size to keep changing, and so that the scaling size is consistent (eg at
normal scale, GB @ 3x is closer to SNES @ 2x.) This means black borders
in GB/GBA mode, but it doesn't look that bad, and it's not like many
people ever use these modes anyway.
Finally, added the placeholder tabs for video, audio and timing. I don't
intend to add the timing calculator code to v095 (it might be better as
a separate tool), but I'll add the ability to set video/audio rates, at
least.
Glitch 1: despite selecting the first item in the BrowserDialog list, if
you press enter when the window appears, it doesn't activate the item
until you press an arrow key first.
Glitch 2: in Game Boy mode, if you set the 4x window size, it's not
honoring the full requested height because the viewport is smaller than
the window. 8+ years of trying to get GTK+ and Qt to simply set the god
damned window size I ask for, and I still can't get them to do it
reliably.
Remaining issues:
- finish configuration panels (video, audio, timing)
- fix ruby driver compilation on Windows
- add DIP switch selection window (NSS) [I may end up punting this one
to v096]
2015-05-30 11:39:09 +00:00
|
|
|
if(MessageDialog().setParent(*toolsManager).setText("Permanently erase all slots?").question() == "Yes") {
|
2015-04-21 11:51:57 +00:00
|
|
|
for(auto slot : range(Slots)) file::remove(program->stateName(1 + slot, true));
|
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto StateManager::doErase() -> void {
|
|
|
|
if(auto item = stateList.selected()) {
|
2015-06-18 10:48:53 +00:00
|
|
|
file::remove(program->stateName(1 + item.offset(), true));
|
2015-04-21 11:51:57 +00:00
|
|
|
doRefresh();
|
2015-06-18 10:48:53 +00:00
|
|
|
doUpdateControls();
|
2015-04-21 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|