Update new project generation to match wizard
This commit is contained in:
+21
-14
@@ -295,11 +295,23 @@ class NWProject():
|
|||||||
# and a number of chapters and scenes selected in the
|
# and a number of chapters and scenes selected in the
|
||||||
# wizard's custom page.
|
# wizard's custom page.
|
||||||
|
|
||||||
|
noteTitles = {
|
||||||
|
nwItemClass.PLOT: self.tr("Main Plot"),
|
||||||
|
nwItemClass.CHARACTER: self.tr("Protagonist"),
|
||||||
|
nwItemClass.WORLD: self.tr("Main Location"),
|
||||||
|
}
|
||||||
|
|
||||||
# Create root folders
|
# Create root folders
|
||||||
nHandle = self.newRoot(self.tr("Novel"), nwItemClass.NOVEL)
|
nHandle = self.newRoot(self.tr("Novel"), nwItemClass.NOVEL)
|
||||||
|
addNotes = projData.get("addNotes", False)
|
||||||
for newRoot in projData.get("addRoots", []):
|
for newRoot in projData.get("addRoots", []):
|
||||||
if newRoot in nwItemClass:
|
if newRoot in nwItemClass:
|
||||||
self.newRoot(trConst(nwLabels.CLASS_NAME[newRoot]), newRoot)
|
rHandle = self.newRoot(nwLabels.CLASS_NAME[newRoot], newRoot)
|
||||||
|
if addNotes:
|
||||||
|
aHandle = self.newFile(noteTitles[newRoot], rHandle)
|
||||||
|
ntTag = simplified(noteTitles[newRoot]).replace(" ", "")
|
||||||
|
aDoc = NWDoc(self, aHandle)
|
||||||
|
aDoc.writeDocument(f"# {noteTitles[newRoot]}\n\n@tag: {ntTag}\n\n")
|
||||||
|
|
||||||
# Create a title page
|
# Create a title page
|
||||||
tHandle = self.newFile(self.tr("Title Page"), nHandle)
|
tHandle = self.newFile(self.tr("Title Page"), nHandle)
|
||||||
@@ -310,38 +322,33 @@ class NWProject():
|
|||||||
# Create chapters and scenes
|
# Create chapters and scenes
|
||||||
numChapters = projData.get("numChapters", 0)
|
numChapters = projData.get("numChapters", 0)
|
||||||
numScenes = projData.get("numScenes", 0)
|
numScenes = projData.get("numScenes", 0)
|
||||||
chFolders = projData.get("chFolders", False)
|
|
||||||
|
chSynop = self.tr("Summary of the chapter.")
|
||||||
|
scSynop = self.tr("Summary of the scene.")
|
||||||
|
|
||||||
# Create chapters
|
# Create chapters
|
||||||
if numChapters > 0:
|
if numChapters > 0:
|
||||||
for ch in range(numChapters):
|
for ch in range(numChapters):
|
||||||
chTitle = self.tr("Chapter {0}").format(f"{ch+1:d}")
|
chTitle = self.tr("Chapter {0}").format(f"{ch+1:d}")
|
||||||
pHandle = nHandle
|
cHandle = self.newFile(chTitle, nHandle)
|
||||||
if chFolders:
|
|
||||||
pHandle = self.newFolder(chTitle, nHandle)
|
|
||||||
|
|
||||||
cHandle = self.newFile(chTitle, pHandle)
|
|
||||||
|
|
||||||
aDoc = NWDoc(self, cHandle)
|
aDoc = NWDoc(self, cHandle)
|
||||||
aDoc.writeDocument("## %s\n\n" % chTitle)
|
aDoc.writeDocument(f"## {chTitle}\n\n% Synopsis: {chSynop}\n\n")
|
||||||
|
|
||||||
# Create chapter scenes
|
# Create chapter scenes
|
||||||
if numScenes > 0:
|
if numScenes > 0:
|
||||||
for sc in range(numScenes):
|
for sc in range(numScenes):
|
||||||
scTitle = self.tr("Scene {0}").format(f"{ch+1:d}.{sc+1:d}")
|
scTitle = self.tr("Scene {0}").format(f"{ch+1:d}.{sc+1:d}")
|
||||||
sHandle = self.newFile(scTitle, pHandle)
|
sHandle = self.newFile(scTitle, cHandle)
|
||||||
|
|
||||||
aDoc = NWDoc(self, sHandle)
|
aDoc = NWDoc(self, sHandle)
|
||||||
aDoc.writeDocument("### %s\n\n" % scTitle)
|
aDoc.writeDocument(f"### {scTitle}\n\n% Synopsis: {scSynop}\n\n")
|
||||||
|
|
||||||
# Create scenes (no chapters)
|
# Create scenes (no chapters)
|
||||||
elif numScenes > 0:
|
elif numScenes > 0:
|
||||||
for sc in range(numScenes):
|
for sc in range(numScenes):
|
||||||
scTitle = self.tr("Scene {0}").format(f"{sc+1:d}")
|
scTitle = self.tr("Scene {0}").format(f"{sc+1:d}")
|
||||||
sHandle = self.newFile(scTitle, nHandle)
|
sHandle = self.newFile(scTitle, nHandle)
|
||||||
|
|
||||||
aDoc = NWDoc(self, sHandle)
|
aDoc = NWDoc(self, sHandle)
|
||||||
aDoc.writeDocument("### %s\n\n" % scTitle)
|
aDoc.writeDocument(f"### {scTitle}\n\n% Synopsis: {scSynop}\n\n")
|
||||||
|
|
||||||
# Finalise
|
# Finalise
|
||||||
if popCustom or popMinimal:
|
if popCustom or popMinimal:
|
||||||
|
|||||||
@@ -1440,9 +1440,9 @@ class GuiMain(QMainWindow):
|
|||||||
"popMinimal": newProj.field("popMinimal"),
|
"popMinimal": newProj.field("popMinimal"),
|
||||||
"popCustom": newProj.field("popCustom"),
|
"popCustom": newProj.field("popCustom"),
|
||||||
"addRoots": [],
|
"addRoots": [],
|
||||||
|
"addNotes": False,
|
||||||
"numChapters": 0,
|
"numChapters": 0,
|
||||||
"numScenes": 0,
|
"numScenes": 0,
|
||||||
"chFolders": False,
|
|
||||||
}
|
}
|
||||||
if newProj.field("popCustom"):
|
if newProj.field("popCustom"):
|
||||||
addRoots = []
|
addRoots = []
|
||||||
@@ -1452,16 +1452,10 @@ class GuiMain(QMainWindow):
|
|||||||
addRoots.append(nwItemClass.CHARACTER)
|
addRoots.append(nwItemClass.CHARACTER)
|
||||||
if newProj.field("addWorld"):
|
if newProj.field("addWorld"):
|
||||||
addRoots.append(nwItemClass.WORLD)
|
addRoots.append(nwItemClass.WORLD)
|
||||||
if newProj.field("addTime"):
|
|
||||||
addRoots.append(nwItemClass.TIMELINE)
|
|
||||||
if newProj.field("addObject"):
|
|
||||||
addRoots.append(nwItemClass.OBJECT)
|
|
||||||
if newProj.field("addEntity"):
|
|
||||||
addRoots.append(nwItemClass.ENTITY)
|
|
||||||
projData["addRoots"] = addRoots
|
projData["addRoots"] = addRoots
|
||||||
|
projData["addNotes"] = newProj.field("addNotes")
|
||||||
projData["numChapters"] = newProj.field("numChapters")
|
projData["numChapters"] = newProj.field("numChapters")
|
||||||
projData["numScenes"] = newProj.field("numScenes")
|
projData["numScenes"] = newProj.field("numScenes")
|
||||||
projData["chFolders"] = newProj.field("chFolders")
|
|
||||||
|
|
||||||
return projData
|
return projData
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user