mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Changed the handling of blank game name entries in the metadata editor.
This commit is contained in:
parent
99b1acfb9f
commit
3f8e5a001b
|
@ -70,7 +70,9 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
// Populate list.
|
// Populate list.
|
||||||
for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) {
|
for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) {
|
||||||
std::shared_ptr<GuiComponent> ed;
|
std::shared_ptr<GuiComponent> ed;
|
||||||
std::string originalValue;
|
std::string currentKey = iter->key;
|
||||||
|
std::string originalValue = mMetaData->get(iter->key);
|
||||||
|
std::string gamePath;
|
||||||
|
|
||||||
// Don't add statistics.
|
// Don't add statistics.
|
||||||
if (iter->isStatistic)
|
if (iter->isStatistic)
|
||||||
|
@ -159,8 +161,6 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
bool multiLine = false;
|
bool multiLine = false;
|
||||||
const std::string title = iter->displayPrompt;
|
const std::string title = iter->displayPrompt;
|
||||||
|
|
||||||
originalValue = mMetaData->get(iter->key);
|
|
||||||
|
|
||||||
// OK callback (apply new value to ed).
|
// OK callback (apply new value to ed).
|
||||||
auto updateVal = [ed, originalValue](const std::string& newVal) {
|
auto updateVal = [ed, originalValue](const std::string& newVal) {
|
||||||
ed->setValue(newVal);
|
ed->setValue(newVal);
|
||||||
|
@ -201,15 +201,27 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
bool multiLine = iter->type == MD_MULTILINE_STRING;
|
bool multiLine = iter->type == MD_MULTILINE_STRING;
|
||||||
const std::string title = iter->displayPrompt;
|
const std::string title = iter->displayPrompt;
|
||||||
|
|
||||||
originalValue = mMetaData->get(iter->key);
|
gamePath = Utils::FileSystem::getStem(mScraperParams.game->getPath());
|
||||||
|
|
||||||
// OK callback (apply new value to ed).
|
// OK callback (apply new value to ed).
|
||||||
auto updateVal = [ed, originalValue](const std::string& newVal) {
|
auto updateVal = [ed, currentKey, originalValue, gamePath]
|
||||||
|
(const std::string& newVal) {
|
||||||
|
// If the user has entered a blank game name, then set the name to the ROM
|
||||||
|
// filename (minus the extension).
|
||||||
|
if (currentKey == "name" && newVal == "") {
|
||||||
|
ed->setValue(gamePath);
|
||||||
|
if (gamePath == originalValue)
|
||||||
|
ed->setColor(DEFAULT_TEXTCOLOR);
|
||||||
|
else
|
||||||
|
ed->setColor(TEXTCOLOR_USERMARKED);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ed->setValue(newVal);
|
ed->setValue(newVal);
|
||||||
if (newVal == originalValue)
|
if (newVal == originalValue)
|
||||||
ed->setColor(DEFAULT_TEXTCOLOR);
|
ed->setColor(DEFAULT_TEXTCOLOR);
|
||||||
else
|
else
|
||||||
ed->setColor(TEXTCOLOR_USERMARKED);
|
ed->setColor(TEXTCOLOR_USERMARKED);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
|
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
|
||||||
|
@ -342,16 +354,8 @@ void GuiMetaDataEd::save()
|
||||||
mEditors.at(i)->getValue() != mMetaData->get("hidden"))
|
mEditors.at(i)->getValue() != mMetaData->get("hidden"))
|
||||||
hideGameWhileHidden = true;
|
hideGameWhileHidden = true;
|
||||||
|
|
||||||
// If the user has entered a blank game name, then set the name to the ROM
|
|
||||||
// filename (minus the extension).
|
|
||||||
if (mMetaDataDecl.at(i).key == "name" && mEditors.at(i)->getValue() == "") {
|
|
||||||
mMetaData->set(mMetaDataDecl.at(i).key,
|
|
||||||
Utils::FileSystem::getStem(mScraperParams.game->getPath()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mMetaData->set(mMetaDataDecl.at(i).key, mEditors.at(i)->getValue());
|
mMetaData->set(mMetaDataDecl.at(i).key, mEditors.at(i)->getValue());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If hidden games are not shown and the hide flag was set for the game, then write the
|
// If hidden games are not shown and the hide flag was set for the game, then write the
|
||||||
// metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file
|
// metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file
|
||||||
|
|
|
@ -160,8 +160,7 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
|
||||||
// Number of entries that can fit on the screen simultaniously.
|
// Number of entries that can fit on the screen simultaniously.
|
||||||
int screenCount = (int)(mSize.y() / entrySize + 0.5f);
|
int screenCount = (int)(mSize.y() / entrySize + 0.5f);
|
||||||
|
|
||||||
if (size() >= screenCount)
|
if (size() >= screenCount) {
|
||||||
{
|
|
||||||
startEntry = mCursor - screenCount/2;
|
startEntry = mCursor - screenCount/2;
|
||||||
if (startEntry < 0)
|
if (startEntry < 0)
|
||||||
startEntry = 0;
|
startEntry = 0;
|
||||||
|
|
Loading…
Reference in a new issue