1. minirop
  2. KVNS

Commits

minirop  committed de0a40d

save/load working

  • Participants
  • Parent commits e9d62fe
  • Branches default

Comments (0)

Files changed (4)

File GameWidget.cpp

View file
 		Character * c = ii.value();
 		
 		QDomElement characterNode = saveXML.createElement("character");
-		characterNode.setAttribute("name", c->getName());
+		characterNode.setAttribute("name", ii.key());
 		characterNode.setAttribute("expression", c->getExpression());
 		characterNode.setAttribute("x", QString::number(c->x()));
 		characterNode.setAttribute("y", QString::number(c->y()));
 	
 	if(!file.open(QIODevice::ReadOnly))
 	{
-		QMessageBox::critical(this, "Error", "Can't open this savegame for reading. exiting");
-		QTimer::singleShot(0, qApp, SLOT(quit()));
-		MainWindow::isClosing = true;
+		//QMessageBox::critical(this, "Error", "Can't open this savegame for reading. exiting");
+		//QTimer::singleShot(0, qApp, SLOT(quit()));
+		//MainWindow::isClosing = true;
 		return;
 	}
 	if(!doc.setContent(&file))
 		else if(elems.tagName() == "saved")
 		{
 			QStringList pushed = elems.attribute("values").split(",");
-			qDebug() << "saved element" << elems.attribute("values") << pushed;
 			foreach(QString push, pushed)
 			{
 				savedPositions.push_back(push.toInt());
 	}
 	currentSavedPos = 0;
 	
+	m_textbox->loadedText();
+	
 	/*
 	loadArc();
 	if(!MainWindow::isClosing)
 void GameWidget::evaluateList(QDomNodeList list, int nested)
 {
 	uint i = 0;
-	qDebug() << savedPositions;
 	if(currentSavedPos < savedPositions.size())
 	{
 		i = savedPositions[ currentSavedPos ];
-		qDebug() << currentSavedPos << "=>" << i;
-		currentSavedPos++;
+		//currentSavedPos++;
 	}
 	else
 	{
 					evaluateTransition(e);
 				else if(name == "goto")
 				{
-					currentSavedPos++;
 					evaluateGoto(e);
-					currentSavedPos--;
 					i = list.length();
 				}
 				/*else if(name == "gosub")
 		}
 	}
 	
-	savedPositions.pop_back();
+	if(!savedPositions.isEmpty())
+		savedPositions.pop_back();
 	
 	if(!currentArc.isEmpty()) // needed for <goto>
 	{
-		start();
+		loadArc();
+		if(!MainWindow::isClosing)
+			evaluate();
 	}
 	else if(!nested /*&& !gosubDepth*/)
 	{
 {
 	currentArc = parseVariable(elem.attribute("name"));
 	lastLoadedArc = currentArc;
+	
+	savedPositions.clear();
+	currentSavedPos = 0;
 }
 
 void GameWidget::evaluateTransition(QDomElement elem)

File GameWidget.h

View file
 	bool loadArcs(QDomElement elem);
 	
 	// evaluators
-	// return true on an arc change, to stop continuation of the current arc.
+	// return true if the value of the variable named "name" is the content of "equals"
 	bool evaluateIf(QDomElement elem);
 	
 	void evaluateList(QDomNodeList list, int nested = 0);

File Textbox.cpp

View file
 	m_autoConf = autoConf;
 	setText(m_tmpText);
 	
+	if(m_nextIsStopped)
+	{
+		setText(m_tmpText + text);
+		//QTimer::singleShot(0, this, SIGNAL(textFinished()));
+		m_nextIsStopped = false;
+		return;
+	}
+	
 	if(sound.isEmpty() || CTRL_IS_DOWN)
 	{
 		m_music = 0;
 	}
 }
 
+void Textbox::loadedText()
+{
+	m_nextIsStopped = true;
+}
+
 void Textbox::stopText()
 {
 	if(m_music)

File Textbox.h

View file
 	~Textbox();
 	
 	void setSpeech(const QString& name, const QString& text, const QString& sound, bool autoConf);
+	void loadedText();
 
 private slots:
 	void nextLetter();
 
 private:
 	void stopText();
+	bool m_nextIsStopped;
 	
 	QString m_name;
 	QString m_text;