mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
Use placeholder text for new map/layout names
This commit is contained in:
parent
90c904ecb9
commit
f4c0cb2d2d
|
|
@ -68,6 +68,9 @@
|
|||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The constant that will be used to refer to this layout. It cannot be the same as any other existing layout.</p></body></html></string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>LAYOUT_MY_NEW_LAYOUT</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
@ -92,6 +95,9 @@
|
|||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the new layout. The name cannot be the same as any other existing layout.</p></body></html></string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>MyNewLayout</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -185,6 +185,9 @@
|
|||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the new map. The name cannot be the same as any other existing map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>MyNewMap</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -133,8 +133,6 @@ public:
|
|||
NewMapSettings newMapSettings;
|
||||
Layout::Settings newLayoutSettings;
|
||||
|
||||
QString getNewMapName() const;
|
||||
QString getNewLayoutName() const;
|
||||
void initNewMapSettings();
|
||||
void initNewLayoutSettings();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ void Layout::copyFrom(const Layout *other) {
|
|||
this->border = other->border;
|
||||
}
|
||||
|
||||
// When we create a layout automatically for a new map we add this suffix to differentiate the layout name from the map name.
|
||||
QString Layout::defaultSuffix() {
|
||||
return "_Layout";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1995,28 +1995,8 @@ QString Project::toUniqueIdentifier(const QString &identifier) const {
|
|||
return uniqueIdentifier;
|
||||
}
|
||||
|
||||
QString Project::getNewMapName() const {
|
||||
// Ensure default name/ID doesn't already exist.
|
||||
int suffix = 1;
|
||||
QString newMapName;
|
||||
do {
|
||||
newMapName = QString("NewMap%1").arg(suffix++);
|
||||
} while (!isIdentifierUnique(newMapName) || !isIdentifierUnique(Map::mapConstantFromName(newMapName)));
|
||||
return newMapName;
|
||||
}
|
||||
|
||||
QString Project::getNewLayoutName() const {
|
||||
// Ensure default name/ID doesn't already exist.
|
||||
int suffix = 1;
|
||||
QString newLayoutName;
|
||||
do {
|
||||
newLayoutName = QString("NewLayout%1").arg(suffix++);
|
||||
} while (!isIdentifierUnique(newLayoutName) || !isIdentifierUnique(Layout::layoutConstantFromName(newLayoutName)));
|
||||
return newLayoutName;
|
||||
}
|
||||
|
||||
void Project::initNewMapSettings() {
|
||||
this->newMapSettings.name = getNewMapName();
|
||||
this->newMapSettings.name = QString();
|
||||
this->newMapSettings.group = this->groupNames.at(0);
|
||||
this->newMapSettings.canFlyTo = false;
|
||||
|
||||
|
|
@ -2044,7 +2024,7 @@ void Project::initNewMapSettings() {
|
|||
}
|
||||
|
||||
void Project::initNewLayoutSettings() {
|
||||
this->newLayoutSettings.name = getNewLayoutName();
|
||||
this->newLayoutSettings.name = QString();
|
||||
this->newLayoutSettings.id = Layout::layoutConstantFromName(this->newLayoutSettings.name);
|
||||
this->newLayoutSettings.width = getDefaultMapDimension();
|
||||
this->newLayoutSettings.height = getDefaultMapDimension();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ NewLayoutDialog::NewLayoutDialog(Project *project, const Layout *layoutToCopy, Q
|
|||
if (this->layoutToCopy && !this->layoutToCopy->name.isEmpty()) {
|
||||
settings->name = project->toUniqueIdentifier(this->layoutToCopy->name);
|
||||
} else {
|
||||
settings->name = project->getNewLayoutName();
|
||||
settings->name = QString();
|
||||
}
|
||||
// Generate a unique Layout constant
|
||||
settings->id = project->toUniqueIdentifier(Layout::layoutConstantFromName(settings->name));
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ NewMapDialog::NewMapDialog(Project *project, const Map *mapToCopy, QWidget *pare
|
|||
settings->name = project->toUniqueIdentifier(this->mapToCopy->name());
|
||||
|
||||
} else {
|
||||
// Not duplicating a map, get a generic new map name.
|
||||
// The rest of the settings are preserved in the project between sessions.
|
||||
settings->name = project->getNewMapName();
|
||||
// Clear the previously-used map name. The rest of the settings are preserved between sessions.
|
||||
settings->name = QString();
|
||||
}
|
||||
// Generate a unique Layout constant
|
||||
settings->layout.id = project->toUniqueIdentifier(Layout::layoutConstantFromName(settings->name));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user