Skip to content

Commit 63280dc

Browse files
committed
Update ToM.groovy
Added 'show tutorials from Map' Added 'getMapFromPath'
1 parent 9e092d7 commit 63280dc

1 file changed

Lines changed: 64 additions & 11 deletions

File tree

Tutorial-o-Matic/src/main/groovy/ToM.groovy

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ class ToM{
114114
}
115115
}
116116

117-
def static addPageTitle(myP,nodo){
118-
//TODO: agregar título
119-
def html = "<html><style>h1 {color: rgb(240, 240, 240);background-color: rgb(100, 100, 150);display: block;padding: 10px;}</style><body><h1>${nodo.text}</h1></body></html>"
117+
def static addPageTitle(myP, String texto){
118+
def html = "<html><style>h1 {color: rgb(240, 240, 240);background-color: rgb(100, 100, 150);display: block;padding: 10px;}</style><body><h1>${texto}</h1></body></html>"
120119
myP.add(tomui.createInstructionsPane(html), tomui.GBC)
121-
120+
}
121+
122+
def static addPageTitle(myP, nodo){
123+
addPageTitle(myP, nodo.text)
122124
}
123125

124126
def static addNextPagePane(myP, lastNode, boolean included = false){
@@ -141,13 +143,6 @@ class ToM{
141143
}
142144

143145

144-
def static showTOC(myP,nodo){
145-
myP.removeAll()
146-
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
147-
addTOCPane(myP,nodo)
148-
tomui.adjustHeight(myP, true)
149-
}
150-
151146
def static addShowMenuItemPane(myP, nodos){
152147
nodos.findAll{n -> toma.hasAction(n)}.each{nodo ->
153148
def infoAccion = toma.getActionInfoMap(nodo)
@@ -181,6 +176,13 @@ class ToM{
181176
}
182177
}
183178

179+
def static showTOC(myP,nodo){
180+
myP.removeAll()
181+
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
182+
addTOCPane(myP,nodo)
183+
tomui.adjustHeight(myP, true)
184+
}
185+
184186
def static addTOCPane(myP,nodo){
185187
def titleNodes = getNewPageNodes(getTutorialNode(nodo))
186188
def pane = tomui.createEmptyGridBagPanel()
@@ -193,6 +195,48 @@ class ToM{
193195
myP.add(pane, tomui.GBC)
194196
}
195197

198+
def static showTutorials(mapa){
199+
def myP = tomui.getContentPaneFromMyTab(tabName, true)
200+
myP.removeAll()
201+
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
202+
addTutorialsPane(myP, mapa)
203+
tomui.adjustHeight(myP, true)
204+
}
205+
206+
def static addTutorialsPane(myP, mapa){
207+
def nodosTutoriales = mapa.root.find{it.style.name == styles.tutorial}
208+
if ( nodosTutoriales.size() > 1 ){
209+
def pane = tomui.createEmptyGridBagPanel()
210+
addPageTitle(myP, "Tutorials present in '${mapa.name}' map".toString())
211+
nodosTutoriales.each{ nT ->
212+
def title = nT.text
213+
def bttnAction = { e ->
214+
def tutNodes = getTutNodes(nT)
215+
if(tutNodes) {
216+
fillContentPane(myP, tutNodes)
217+
} else {
218+
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
219+
}
220+
}
221+
def button = tomui.createButton(title, bttnAction)
222+
pane.add(button, tomui.GBC)
223+
}
224+
def stopButton = tomui.createButton('Exit tutorial', {tomui.closeTab(tabName)})
225+
pane.add(stopButton, tomui.GBC)
226+
myP.add(pane, tomui.GBC)
227+
} else if ( nodosTutoriales.size() == 1 ) {
228+
def nT = nodosTutoriales[0]
229+
def tutNodes = getTutNodes(nT)
230+
if(tutNodes) {
231+
fillContentPane(myP, tutNodes)
232+
} else {
233+
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
234+
}
235+
} else {
236+
ui.informationMessage( "no tutorial found in '${mapa.name}' map".toString())
237+
}
238+
}
239+
196240
def static addGotoPane(myP, nodos){
197241
nodos.findAll{n -> n.link.node?true:false}.each{nodo ->
198242
def targetNode = nodo.link.node
@@ -268,6 +312,15 @@ class ToM{
268312
return !iconos.contains('emoji-1F56F')
269313
}
270314

315+
def static getMapFromPath(filePath, withView){
316+
if(exists(filePath)){
317+
def m = c.mapLoader(filePath)
318+
if(withView) m.withView()
319+
return m.load()
320+
}
321+
}
322+
323+
def static exists(String path){new File(path).isFile()}
271324

272325
// end:
273326

0 commit comments

Comments
 (0)