[prev in list] [next in list] [prev in thread] [next in thread] 

List:       atlantik-devel
Subject:    [atlantik-devel] CVS: kdeaddons/atlantikdesigner/designer boardinfo.cpp,1.2,1.3 boardinfo.h,1.1,1.2
From:       kde () office ! kde ! org
Date:       2002-06-10 4:08:08
[Download RAW message or body]

Update of /home/kde/kdeaddons/atlantikdesigner/designer
In directory office:/tmp/cvs-serv11265/designer

Modified Files:
	boardinfo.cpp boardinfo.h designer.cpp designer.h editor.cpp 
	editor.h group.cpp group.h 
Log Message:
make load/save work and fix bugs


Index: boardinfo.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/boardinfo.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- boardinfo.cpp	2002/04/20 12:51:37	1.2
+++ boardinfo.cpp	2002/06/10 04:08:05	1.3
@@ -5,6 +5,7 @@
 #include <qptrlist.h>
 #include <qlabel.h>
 
+#include <kcolorbutton.h>
 #include <kdialogbase.h>
 #include <klocale.h>
 #include <kdebug.h>
@@ -15,7 +16,7 @@
 #include "boardinfo.h"
 
 BoardInfoDlg::BoardInfoDlg(bool editable, BoardInfo *info, QWidget *parent, char \
                *_name, bool modal)
-	: KDialogBase(KDialogBase::Tabbed, i18n("Gameboard Information"), (editable? \
Ok|Cancel : Close), (editable? Ok : Close), parent, _name, modal) +	: \
KDialogBase(KDialogBase::Tabbed, i18n("Gameboard Information"), (editable? \
Ok|Apply|Cancel : Close), (editable? Ok : Close), parent, _name, modal)  {
 	if (!info)
 		return;
@@ -63,6 +64,16 @@
 		description->setReadOnly(true);
 	}
 
+	if (editable)
+	{
+		QHBoxLayout *bgLayout = new QHBoxLayout(aboutLayout, spacingHint());
+		bgLayout->addWidget(new QLabel(i18n("Background Color"), about));
+		bgColor = new KColorButton(info->bgColor, about);
+		bgLayout->addWidget(bgColor);
+	}
+	else
+		bgColor = 0;
+
 	QFrame *authorsFrame = addPage(i18n("&Authors"));
 	QVBoxLayout *authorsLayout = new QVBoxLayout(authorsFrame, spacingHint());
 	authorsLayout->addWidget(authors = new LotsaEdits(editable, info->authors, \
authorsFrame)); @@ -72,7 +83,7 @@
 	creditsLayout->addWidget(credits = new LotsaEdits(editable, info->credits, \
creditsFrame));  }
 
-void BoardInfoDlg::slotOk()
+void BoardInfoDlg::slotApply()
 {
 	info->name = name->text();
 	info->description = description->text();
@@ -80,6 +91,17 @@
 	info->url = url->text();
 	info->authors = authors->save();
 	info->credits = credits->save();
+
+	if (bgColor)
+		info->bgColor = bgColor->color().name();
+
+	emit okClicked();
+	KDialogBase::slotApply();
+}
+
+void BoardInfoDlg::slotOk()
+{
+	slotApply();
 
 	KDialogBase::slotOk();
 }

Index: boardinfo.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/boardinfo.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- boardinfo.h	2001/12/24 03:04:48	1.1
+++ boardinfo.h	2002/06/10 04:08:05	1.2
@@ -1,24 +1,30 @@
 #ifndef ATLANTIK_BOARDINFO_H
 #define ATLANTIK_BOARDINFO_H
 
+#include <qcolor.h>
 #include <qstring.h>
 #include <qstringlist.h>
 #include <qptrlist.h>
 #include <qwidget.h>
+
 #include <kdialogbase.h>
 
+class KColorButton;
 class KLineEdit;
 class KURLLabel;
+
 class QVBoxLayout;
 
 struct BoardInfo
 {
+	BoardInfo() { bgColor = Qt::lightGray; }
 	QString name;
 	QStringList authors;
 	QStringList credits;
 	QString description;
 	QString url;
 	QString version;
+	QColor bgColor;
 };
 
 class LotsaEdits : public QWidget
@@ -50,12 +56,14 @@
 
 	protected slots:
 	void slotOk();
+	void slotApply();
 
 	private:
 	KLineEdit *name;
 	KLineEdit *url;
 	KLineEdit *version;
 	KLineEdit *description;
+	KColorButton *bgColor;
 
 	LotsaEdits *authors;
 	LotsaEdits *credits;

Index: designer.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- designer.cpp	2002/06/09 07:18:46	1.36
+++ designer.cpp	2002/06/10 04:08:05	1.37
@@ -69,15 +69,19 @@
 
 	createGUI("atlantikdesignerui.rc");
 
+	KConfig *config = kapp->config();
+	config->setGroup("General");
+	defaultBg = config->readColorEntry("alternateBackground", &black);
+	config->setGroup("WM");
+	defaultFg = config->readColorEntry("activeBackground", &black);
+
 	// these MUST match up to the ones in editor.cpp!
 	types.append("street");
-	types.append("utility");
 	types.append("cards");
 	types.append("freeparking");
 	types.append("tojail");
 	types.append("tax");
 	types.append("jail");
-	types.append("TODO");
 
 	isMod = false;
 	openNew();
@@ -97,8 +101,18 @@
 {
 	estates.clear();
 	cards.clear();
+	groups.clear();
 
 	boardInfo = BoardInfo();
+
+	for (ConfigEstateGroupList::Iterator it =  groups.begin(); it != groups.end(); \
++it) +		if ((*it).name() == i18n("Default"))
+			return;
+
+	ConfigEstateGroup defaultGroup(i18n("Default"));
+	defaultGroup.setBgColor(defaultBg);
+	defaultGroup.setFgColor(defaultFg);
+	groups.append(defaultGroup);
 }
 
 void AtlanticDesigner::initBoard()
@@ -117,6 +131,7 @@
 	setCentralWidget(board);
 	layout = new QVBoxLayout(board->centerWidget());
 	editor = new EstateEdit(&groups, &estates, &cards, board->centerWidget(), "Estate \
Editor"); +	connect(editor, SIGNAL(updateBackground()), this, \
SLOT(updateBackground()));  layout->addWidget(editor);
 
 	editor->setReady(false);
@@ -133,6 +148,7 @@
 
 	max = 40;
 
+	initMembers();
 	initBoard();
 
 	for(int i = 0; i < 40; ++i)
@@ -140,30 +156,24 @@
 		(void) newEstate(i);
 	}
 
-	isMod = false;
 	doCaption(false);
 	updateJumpMenu();
 
+	groupsChanged();
+	updateBackground();
+
+	isMod = false;
 	QTimer::singleShot(500, this, SLOT(setPlayerAtBeginning()));
 }
 
 ConfigEstate *AtlanticDesigner::newEstate(int i)
 {
-	KConfig *config = kapp->config();
-	QColor fg, bg;
-	config->setGroup("General");
-	bg = config->readColorEntry("alternateBackground", &black);
-	config->setGroup("WM");
-	fg = config->readColorEntry("activeBackground", &black);
 	ConfigEstate *estate = new ConfigEstate(i);
 	estate->setName(i18n("New Estate"));
-	estate->setColor(fg);
-	estate->setBgColor(bg);
 	estate->setPrice(100);
 	for (int j = 0; j < 6; ++j)
 		estate->setRent(j, 10 * (j + 1));
 	estate->setChanged(false);
-	//estates.append(estate);
 	estates.insert(i, estate);
 
 	connect(estate, SIGNAL(LMBClicked(Estate *)), this, SLOT(changeEstate(Estate *)));
@@ -222,7 +232,7 @@
 
 void AtlanticDesigner::openFile(const QString &filename)
 {
-	enum ParseMode { General, Board, Estates, Cards, Other, Meta };
+	enum ParseMode { Parse_Nothing, Parse_General, Parse_Cards, Parse_EstateGroups, \
Parse_Estates };  QFile f(filename);
 	if (!f.open(IO_ReadOnly))
 		return;
@@ -231,18 +241,18 @@
 
 	QTextStream t(&f);
 	QString s = t.readLine();
-	ParseMode parseMode = Other;
+	int parseMode = Parse_Nothing;
 
+	CardStack *curCardStack = 0;
+
+	int goEstate = 0;
 	int i;
 	for (i = 0; !t.atEnd();)
 	{
-		//if (i < 500)
-		//kdDebug() << "s is [" << s << "]" << endl;
 		s = s.stripWhiteSpace();
 
 		if (s.isEmpty())
 		{
-			//kdDebug() << "thats empty, reading new line" << endl;
 			s = t.readLine();
 			continue;
 		}
@@ -252,132 +262,134 @@
 		if (s.left(1) == "<")
 		{
 			//kdDebug() << "setting parsemode for s [" << s << "]" << endl;
-			if (s == "<Estates>")
-				parseMode = Estates;
+			if (s == "<General>")
+				parseMode = Parse_General;
+			else if (s == "<EstateGroups>")
+				parseMode = Parse_EstateGroups;
 			else if (s == "<Cards>")
-				parseMode = Cards;
-			else if (s == "<Meta>")
-				parseMode = Meta;
-			else
-				parseMode = Other;
+				parseMode = Parse_Cards;
+			else if (s == "<Estates>")
+				parseMode = Parse_Estates;
 
 			s = t.readLine();
 			continue;
 		}
 
+		// this for outside-of-[]-settings
+		int eqSign = s.find("=");
+		if (eqSign >= 0)
+		{
+			QString key = s.left(eqSign);
+			QString value = s.right(s.length() - eqSign - 1);
+
+			if (parseMode == Parse_Cards)
+			{
+				if (key == "groupname")
+				{
+					cards.append(CardStack(value));
+					curCardStack = &cards.last();
+				}
+			}
+
+			s = t.readLine();
+			continue;
+		}
+
 		name = s.left(s.find("]"));
 		name = name.right(name.length() - name.find("[") - 1);
 
 		if (name.isEmpty())
 			name = i18n("No Name");
-		//kdDebug() << "name is " << name << endl;
 
-		//// for estates
-		QColor color = QColor("zzzzzz"), bgColor = QColor("zzzzzz");
-		int type = 0;
-		int group = -1;
+		// for estates
+		int type = FreeParking;
+		QString group, takeCard;
 		int price = -1;
 		int rent[6] = {-1, -1, -1, -1, -1, -1};
 		int tax = -1;
 		int taxPercentage = -1;
-		//// for cards
+
+		// for groups
+		QColor color, bgColor;
+		QString rentMath, rentVar;
+		int housePrice = -1;
+		int globalPrice = -1;
+
+		// for cards
 		QStringList keys;
 		QValueList<int> values;
 
-		CardStack *curCardStack = 0;
-
 		while (true)
 		{
 			if (t.atEnd())
 				break;
-			s = t.readLine().stripWhiteSpace();
 
-			//kdDebug() << "s is " << s << endl;
+			s = t.readLine().stripWhiteSpace();
 
 			if (s.left(1) == "[" || s.left(1) == "<")
-			{
-				//kdDebug() << "breaking\n";
 				break;
-			}
 
 			int eqSign = s.find("=");
-			if (eqSign == -1)
-			{
+			if (eqSign < 0)
 				continue;
-			}
 
 			QString key = s.left(eqSign);
 			QString value = s.right(s.length() - eqSign - 1);
 
 			//////////////////////////////// ESTATES
-			if (parseMode == Estates)
+			if (parseMode == Parse_Estates)
 			{
-				if (key == "type")
-				{
-					//kdDebug() << "its a type!\n";
-					int j = 0;
-					for (QStringList::Iterator it = types.begin(); it != types.end(); ++it)
-					{
-						//kdDebug() << (*it) << ", " << value << endl;
-						if ((*it) == value)
-						{
-							type = j;
-							break;
-						}
-						j++;
-					}
-					//kdDebug() << "type is " << type << endl;
-				}
-				else if (key == "price")
-				{
+				if (key == "price")
 					price = value.toInt();
-				}
 				else if (key.left(4) == "rent")
 				{
 					int houses = key.right(1).toInt();
 					if (houses < 0 || houses > 5)
-					{
 						continue;
-					}
+
 					rent[houses] = value.toInt();
 				}
 				else if (key == "tax")
 				{
 					tax = value.toInt();
+					type = Tax;
 				}
 				else if (key == "taxpercentage")
-				{
 					taxPercentage = value.toInt();
-				}
 				else if (key == "group")
 				{
-					group = value.toInt();
+					group = value;
+					type = Street;
 				}
-				else if (key == "color")
+				else if (key == "tojail")
+					type = ToJail;
+				else if (key == "jail")
+					type = Jail;
+				else if (key == "freeparking")
+					type = FreeParking;
+				else if (key == "takecard")
 				{
-					color.setNamedColor(value);
-					//kdDebug() << "color is " << color.name() << endl;
+					takeCard = value;
+					type = Cards;
 				}
+			}
+			else if (parseMode == Parse_EstateGroups)
+			{
+				if (key == "color")
+					color.setNamedColor(value);
 				else if (key == "bgcolor")
-				{
 					bgColor.setNamedColor(value);
-					//kdDebug() << "bgcolor is " << bgColor.name() << endl;
-				}
-			} ///////////////////////////// END ESTATES
-
-			///////////////////////////// CARDS
-			else if (parseMode == Cards)
+				else if (key == "houseprice")
+					housePrice = value.toInt();
+				else if (key == "price")
+					globalPrice = value.toInt();
+				else if (key == "rentmath")
+					rentMath = value;
+				else if (key == "rentvar")
+					rentVar = value;
+			}
+			else if (parseMode == Parse_Cards)
 			{
-				//kdDebug() << "in card area\n";
-
-				if (key == "groupname")
-					for (QValueList<CardStack>::Iterator it = cards.begin(); it != cards.end(); \
                ++it)
-						if ((*it).name() == value)
-						{
-							curCardStack = &(*it);
-							continue;
-						}
-
 				bool ok;
 				int v = value.toInt(&ok);
 				if (!ok)
@@ -388,12 +400,12 @@
 					v *= -1;
 					key = "collect";
 				}
-				if (key == "payeach" && v < 0)
+				else if (key == "payeach" && v < 0)
 				{
 					v *= -1;
 					key = "collecteach";
 				}
-				if (key == "advance" && v < 0)
+				else if (key == "advance" && v < 0)
 				{
 					v *= -1;
 					key = "goback";
@@ -403,12 +415,14 @@
 				keys.append(key);
 				values.append(v);
 			}
-			else if (parseMode == Meta)
+			else if (parseMode == Parse_General)
 			{
-				if (name == "About")
+				if (name == "Meta")
 				{
 					if (key == "name")
+					{
 						boardInfo.name = value;
+					}
 					else if (key == "description")
 						boardInfo.description = value;
 					else if (key == "version")
@@ -420,45 +434,58 @@
 					else if (key == "credits")
 						boardInfo.credits = QStringList::split(",", value);
 				}
+				else if (name == "Board")
+				{
+					if (key == "go")
+						goEstate = value.toInt();
+					else if (key == "bgcolor")
+						boardInfo.bgColor.setNamedColor(value);
+				}
 			}
-			//else
-			//kdDebug() << "ignoring line, unknown parseMode" << endl;
 		}
 
-		if (parseMode == Estates)
+		if (parseMode == Parse_Estates)
 		{
-			//kdDebug() << "making estate (" << i << ")\n";
 			ConfigEstate *estate = new ConfigEstate(i);
 			estate->setName(name);
-			estate->setColor(color);
-			estate->setBgColor(bgColor);
 			estate->setType(type);
+			if (!group.isEmpty())
+				estate->setGroup(group);
+			estate->setTakeCard(takeCard);
 			estate->setPrice(price);
 			for (int j = 0; j < 6; j++)
 				estate->setRent(j, rent[j]);
 			estate->setTax(tax);
 			estate->setTaxPercentage(taxPercentage);
-			estate->setChanged(false);
 			estates.append(estate);
 
 			connect(estate, SIGNAL(LMBClicked(Estate *)), this, SLOT(changeEstate(Estate \
*)));  connect(estate, SIGNAL(changed()), this, SLOT(modified()));
-
-			//kdDebug() << "incrementing i\n";
 			i++;
 		}
-		else if (parseMode == Cards)
+		else if (parseMode == Parse_Cards)
 		{
-			//kdDebug() << "making new card" << endl;
 			Card card;
 			card.name = name;
 			card.keys = keys;
 			card.values = values;
-			curCardStack->append(card);
+			if (curCardStack)
+				curCardStack->append(card);
 		}
+		else if (parseMode == Parse_EstateGroups)
+		{
+			ConfigEstateGroup group(name);
+			group.setHousePrice(housePrice);
+			group.setGlobalPrice(globalPrice);
+			group.setFgColor(color);
+			group.setBgColor(bgColor);
+			group.setRentMath(rentMath);
+			group.setRentVar(rentVar);
+			groups.append(group);
+		}
 	}
 
-	if (i < 4)
+	if (i < 8)
 	{
 		KMessageBox::detailedSorry(this, i18n("This board file is invalid; cannot open."), \
i18n("There are only %1 estates specified in this file.").arg(i));  if \
(this->filename.isNull()) @@ -470,14 +497,17 @@
 	initBoard();
 	ConfigEstate *estate = 0;
 	for (estate = estates.first(); estate; estate = estates.next())
-	{
 		board->addEstateView(estate);
-	}
 
-	isMod = false;
+	if (goEstate > 0 && goEstate < max)
+		estates.at(goEstate - 1)->setGo(true);
+
+	groupsChanged();
+	updateBackground();
 	doCaption(false);
 	updateJumpMenu();
-	//kdDebug() << "ending openFile\n";
+
+	isMod = false;
 
 	QTimer::singleShot(500, this, SLOT(setPlayerAtBeginning()));
 }
@@ -496,17 +526,31 @@
 	// our superstar!
 	m_player = new Player;
 	board->addToken(m_player);
-	movePlayer(estates.first());
-	editor->setEstate(estates.first());
+
+	ConfigEstate *go = 0;
+	for (go = estates.first(); go; go = estates.next())
+		if (go->go())
+			break;
+
+	if (!go)
+		go = estates.first();
+
+	movePlayer(go);
+	editor->setEstate(go);
 }
 
 void AtlanticDesigner::saveAs()
 {
 	QString oldfilename = filename;
 	filename = QString::null;
+
 	save();
+
 	if (filename.isNull())
+	{
 		filename = oldfilename;
+		return;
+	}
 	else
 		recentAct->addURL(QString("file:") + filename);
 }
@@ -525,67 +569,45 @@
 		return;
 	}
 
-	//QStringList allNames;
-
 	QFile f(filename);
 	if (!f.open(IO_WriteOnly))
 		return;
 
 	QTextStream t(&f);
 
-	t << QString("<Estates>") << endl << endl;
+	t << "<General>" << endl << endl;
+	t << "[Board]" << endl;
 
 	ConfigEstate *estate = 0;
 	for (estate = estates.first(); estate; estate = estates.next())
 	{
-		/*
-		if (!allNames.grep(estate->name()).empty())
+		if (estate->go())
 		{
-			KMessageBox::detailedSorry(this, i18n("There are duplicate names on your \
gameboard. Thus, it can not be saved correctly; aborting."), i18n("%1 (number %1) has \
                a duplicate name.").arg(estate->name()).arg(estate->estateId()));
-			return;
+			t << "go=" << estate->estateId() + 1 << endl;
+			break;
 		}
-		*/
-
-		EstateType type = (EstateType)estate->type();
-
-		t << QString("[%1]").arg(estate->name()) << endl;
-
-		if (estate->price() >= 0 && type == Street)
-			t << "price=" << estate->price() << endl;
-		if (estate->tax() >= 0 && type == Tax)
-			t << "tax=" << estate->tax() << endl;
-		if (estate->taxPercentage() >= 0 && type == Tax)
-			t << "taxpercentage=" << estate->taxPercentage() << endl;
+	}
 
-		if (type == Street)
-			for (int i = 0; i < 6; i++)
-				if (estate->rent(i) >= 0)
-					t << "rent" << i << "=" << estate->rent(i) << endl;
+	t << "bgcolor=" << boardInfo.bgColor.name() << endl;
+	t << endl;
 
-		t << endl;
+	t << QString("[Meta]\nname=%2\ndescription=%3\nurl=%4\nversion=%5\nauthors=%6\ncredi \
ts=%7\n").arg(boardInfo.name).arg(boardInfo.description).arg(boardInfo.url).arg(boardInfo.version).arg(boardInfo.authors.join(",")).arg(boardInfo.credits.join(","));
  
-		//allNames.append(estate->name());
-	}
+	t << endl << endl;
 
 	// now do the cards
 	
 	t << "<Cards>" << endl << endl;
 
-	CardStack *stack = 0;
 	for (QValueList<CardStack>::Iterator it = cards.begin(); it != cards.end(); ++it)
 	{
-		stack = &(*it);
-
-		t << "groupname=" << stack->name() << endl << endl;
+		t << "groupname=" << (*it).name() << endl;
 
-		Card *card = 0;
-		for (CardStack::Iterator cit = stack->begin(); cit != stack->end(); ++cit)
+		for (CardStack::Iterator cit = (*it).begin(); cit != (*it).end(); ++cit)
 		{
-			card = &(*cit);
-
-			t << endl << "[" << card->name << "]" << endl;
-			QValueList<int>::Iterator vit = card->values.begin();
-			for (QStringList::Iterator it = card->keys.begin(); it != card->keys.end(); ++it, \
++vit) +			t << endl << "[" << (*cit).name << "]" << endl;
+			QValueList<int>::Iterator vit = (*cit).values.begin();
+			for (QStringList::Iterator it = (*cit).keys.begin(); it != (*cit).keys.end(); \
++it, ++vit)  {
 				QString key = (*it);
 				int value = (*vit);
@@ -614,10 +636,90 @@
 		}
 	}
 
-	// now save information
-	t << endl << endl; 
-	t << QString("<Meta>\n[About]\nname=%2\ndescription=%3\nurl=%4\nversion=%5\nauthors= \
%6\ncredits=%7\n").arg(boardInfo.name).arg(boardInfo.description).arg(boardInfo.url).a \
rg(boardInfo.version).arg(boardInfo.authors.join(",")).arg(boardInfo.credits.join(","));
 +	t << endl;
+
+	t << "<EstateGroups>" << endl;
+
+	for (ConfigEstateGroupList::Iterator it =  groups.begin(); it != groups.end(); \
++it) +	{
+		if ((*it).name() == i18n("Default"))
+			continue;
+
+		t << endl << QString("[%1]").arg((*it).name()) << endl;
+		if ((*it).housePrice() > 0)
+			t << "houseprice=" << (*it).housePrice() << endl;
+		if ((*it).globalPrice() > 0)
+			t << "price=" << (*it).globalPrice() << endl;
+
+		if ((*it).fgColor().isValid())
+			t << "color=" << (*it).fgColor().name() << endl;
+
+		t << "bgcolor=" << (*it).bgColor().name() << endl;
+
+		if (!(*it).rentMath().isEmpty())
+			t << "rentmath=" << (*it).rentMath() << endl;
+		if (!(*it).rentVar().isEmpty())
+			t << "rentvar=" << (*it).rentVar() << endl;
+	}
+
+	t << endl;
+
+	t << "<Estates>" << endl;
+
+	for (estate = estates.first(); estate; estate = estates.next())
+	{
+		/*
+		if (!allNames.grep(estate->name()).empty())
+		{
+			KMessageBox::detailedSorry(this, i18n("There are duplicate names on your \
gameboard. Thus, it can not be saved correctly; aborting."), i18n("%1 (number %1) has \
a duplicate name.").arg(estate->name()).arg(estate->estateId())); +			return;
+		}
+		*/
+
+		t << endl << QString("[%1]").arg(estate->name()) << endl;
+
+		switch (estate->type())
+		{
+			case Street:
+				if (!estate->group().isNull() && estate->group() != i18n("Default"))
+					t << "group=" << estate->group() << endl;
 
+				t << "price=" << estate->price() << endl;
+
+				for (int i = 0; i < 6; i++)
+				{
+					if (estate->rent(i) > 0)
+						t << "rent" << i << "=" << estate->rent(i) << endl;
+				}
+				break;
+
+			case Tax:
+				t << "tax=" << estate->tax() << endl;
+				t << "taxpercentage=" << estate->taxPercentage() << endl;
+				break;
+
+			case Jail:
+				t << "jail=1" << endl;
+				break;
+
+			case ToJail:
+				t << "tojail=1" << endl;
+				break;
+
+			case Cards:
+				t << "takecard=" << estate->takeCard() << endl;
+				break;
+
+			case FreeParking:
+				t << "freeparking=1" << endl;
+				break;
+		}
+
+		t << endl;
+
+		//allNames.append(estate->name());
+	}
+
 	f.flush();
 	isMod = false;
 	doCaption(false);
@@ -711,6 +813,8 @@
 
 	isMod = true;
 	updateJumpMenu();
+	groupsChanged();
+	updateBackground();
 	QTimer::singleShot(500, this, SLOT(setPlayerAtBeginning()));
 }
 
@@ -750,6 +854,8 @@
 
 	isMod = true;
 	updateJumpMenu();
+	groupsChanged();
+	updateBackground();
 	QTimer::singleShot(500, this, SLOT(setPlayerAtBeginning()));
 }
 
@@ -784,15 +890,11 @@
 	ConfigEstate *curEstate = 0;
 	for (curEstate = estates.first(); curEstate; curEstate = estates.next())
 	{
-		// skip estate currently being edited
-		if (curEstate == editor->theEstate())
-			continue;
-
 		for (ConfigEstateGroupList::Iterator it =  groups.begin(); it != groups.end(); \
++it)  {
-			if ((*it).name() == curEstate->group())
+			if ((*it).name() == curEstate->group() && curEstate->type() == Street)
 			{
-				curEstate->setBgColor((*it).bgColor());
+				curEstate->setBgColor((*it).bgColor().isValid()? (*it).bgColor() : \
boardInfo.bgColor);  curEstate->setColor((*it).fgColor());
 				curEstate->update();
 				break;
@@ -801,9 +903,25 @@
 	}
 }
 
+void AtlanticDesigner::updateBackground()
+{
+	ConfigEstate *curEstate = 0;
+	for (curEstate = estates.first(); curEstate; curEstate = estates.next())
+	{
+		if (curEstate->type() != Street || (curEstate->type() == Street && \
curEstate->group().isNull())) +		{
+			curEstate->setColor(QColor());
+			curEstate->setBgColor(boardInfo.bgColor);
+			curEstate->update();
+		}
+	}
+}
+
 void AtlanticDesigner::info()
 {
-	(new BoardInfoDlg(true, &boardInfo, this))->show();
+	BoardInfoDlg *dlg = new BoardInfoDlg(true, &boardInfo, this);
+	connect(dlg, SIGNAL(okClicked()), this, SLOT(updateBackground()));
+	dlg->show();
 }
 
 // now some fun functions ;)

Index: designer.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- designer.h	2002/06/09 07:18:46	1.14
+++ designer.h	2002/06/10 04:08:05	1.15
@@ -1,12 +1,14 @@
 #ifndef ATLANTK_DESIGNER_H
 #define ATLANTK_DESIGNER_H
 
-#include <kmainwindow.h>
-#include <qstring.h>
+#include <qcolor.h>
+#include <qguardedptr.h>
 #include <qptrlist.h>
+#include <qstring.h>
 #include <qvaluelist.h>
-#include <qguardedptr.h>
 
+#include <kmainwindow.h>
+
 #include "boardinfo.h"
 #include "group.h"
 #include "editor.h"
@@ -49,6 +51,7 @@
 	void info();
 	void editGroups();
 	void groupsChanged();
+	void updateBackground();
 
 	void up();
 	void down();
@@ -92,6 +95,9 @@
 	Player *m_player;
 
 	bool isMod;
+
+	QColor defaultFg;
+	QColor defaultBg;
 };
 
 #endif

Index: editor.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- editor.cpp	2002/06/09 07:18:46	1.23
+++ editor.cpp	2002/06/10 04:08:05	1.24
@@ -28,7 +28,9 @@
 ConfigEstate::ConfigEstate(int estateId) : Estate(estateId)
 {
 	m_rent[0] = m_rent[1] = m_rent[2] = m_rent[3] = m_rent[4] = m_rent[5] = 0;
-	m_type = 0;
+	m_type = m_price = m_tax = m_taxPercentage = 0;
+	m_go = false;
+	m_group = i18n("Default");
 }
 
 void ConfigEstate::setChanged(bool b)
@@ -108,24 +110,6 @@
 	}
 }
 
-void ConfigEstate::setRentMath(const QString &rentMath)
-{
-	if (m_rentMath != rentMath)
-	{
-		m_rentMath = rentMath;
-		m_changed = true;
-	}
-}
-
-void ConfigEstate::setRentVar(const QString &rentVar)
-{
-	if (m_rentVar != rentVar)
-	{
-		m_rentVar = rentVar;
-		m_changed = true;
-	}
-}
-
 void ConfigEstate::setGo(const bool go)
 {
 	if (m_go != go)
@@ -184,19 +168,18 @@
 	typeCombo = new KComboBox(false, this, "Type Combo");
 	typeLayout->addWidget(typeCombo);
 	connect(typeCombo, SIGNAL(activated(int)), this, SIGNAL(somethingChanged()));
+	connect(typeCombo, SIGNAL(activated(int)), this, SIGNAL(updateBackground()));
 
-	goCheck = new QCheckBox(i18n("This estate is a Go"), this);
+	goCheck = new QCheckBox(i18n("This estate is Go"), this);
 	connect(goCheck, SIGNAL(toggled(bool)), this, SIGNAL(somethingChanged()));
 	layout->addWidget(goCheck, 4, 0);
 
 	QStringList estateTypes(i18n("Street"));
-	estateTypes.append(i18n("Utility"));
 	estateTypes.append(i18n("Cards"));
 	estateTypes.append(i18n("Free Parking"));
 	estateTypes.append(i18n("Go to jail"));
 	estateTypes.append(i18n("Tax"));
 	estateTypes.append(i18n("Jail"));
-	estateTypes.append("TODO");
 	typeCombo->insertStringList(estateTypes);
 }
 
@@ -295,6 +278,8 @@
 	}
 
 	confDlg->slotUpdate(estate);
+
+	connect(confDlg, SIGNAL(updateBackground()), this, SIGNAL(updateBackground()));
 	
 	layout->addWidget(confDlg, 1, 0);
 	confDlg->show();
@@ -440,7 +425,13 @@
 
 void CardsDlg::update()
 {
-	cards->setCurrentText(estate->takeCard());
+	if (!estate->takeCard().isNull())
+	{
+		cards->setCurrentText(estate->takeCard());
+		updateView(estate->takeCard());
+	}
+	else
+		cards->setCurrentItem(-1);
 }
 
 /////////////////////////////////
@@ -595,6 +586,8 @@
 	List = new KListBox(this);
 	layout->addWidget(List);
 	connect(List, SIGNAL(highlighted(int)), this, SLOT(selected(int)));
+
+	layout->setStretchFactor(List, 3);
 
 	hlayout = new QHBoxLayout(layout);
 	moreButton = new KPushButton(i18n("&More Properties"), this);

Index: editor.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- editor.h	2002/06/09 07:18:46	1.18
+++ editor.h	2002/06/10 04:08:05	1.19
@@ -19,7 +19,7 @@
 class KListBox;
 class KPushButton;
 
-enum EstateType { Street = 0, Utility, Cards, FreeParking, ToJail, Tax, Jail, Other \
}; +enum EstateType { Street = 0, Cards, FreeParking, ToJail, Tax, Jail };
 
 class ConfigEstate : public Estate
 {
@@ -40,10 +40,6 @@
 	void setTaxPercentage(const int);
 	const QString &takeCard() { return m_takeCard; }
 	void setTakeCard(const QString &);
-	const QString &rentMath() { return m_rentMath; }
-	void setRentMath(const QString &);
-	const QString &rentVar() { return m_rentVar; }
-	void setRentVar(const QString &);
 	bool go() { return m_go; }
 	void setGo(const bool);
 
@@ -57,8 +53,6 @@
 	int m_tax;
 	int m_taxPercentage;
 	QString m_takeCard;
-	QString m_rentMath;
-	QString m_rentVar;
 	bool m_go;
 };
 typedef QPtrList<ConfigEstate> EstateList;
@@ -90,6 +84,9 @@
 	public:
 	EstateDlg(QWidget *parent = 0, char *name = 0) : QWidget(parent, name) { estate = \
0; };  
+	signals:
+	void updateBackground();
+
 	public slots:
 	virtual void slotOk() { save(); }
 	void slotUpdate(ConfigEstate *newEstate) { estate = newEstate; if (estate) \
update(); } @@ -124,6 +121,7 @@
 	signals:
 	void somethingChanged();
 	void modified();
+	void updateBackground();
 	
 	private slots:
 	void configure();

Index: group.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/group.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- group.cpp	2002/06/09 07:18:46	1.2
+++ group.cpp	2002/06/10 04:08:05	1.3
@@ -1,3 +1,4 @@
+#include <qcombobox.h>
 #include <qframe.h>
 #include <qvgroupbox.h>
 #include <qlabel.h>
@@ -8,6 +9,7 @@
 
 #include <kcolorbutton.h>
 #include <kdebug.h>
+#include <klineedit.h>
 #include <klineeditdlg.h>
 #include <klistbox.h>
 #include <klocale.h>
@@ -52,15 +54,29 @@
 	pricesGroupBox = new QVGroupBox(i18n("&Prices"), page);
 	vlayout->addWidget(pricesGroupBox);
 
-	QWidget *pricesDummy = new QWidget(pricesGroupBox);
-	QHBoxLayout *housePriceLayout = new QHBoxLayout(pricesDummy, spacingHint());
-	housePriceLayout->addWidget(new QLabel(i18n("House price"), pricesDummy), 1, 0);
-	housePriceLayout->addWidget(housePrice = new QSpinBox(0, 3000, 25, pricesDummy));
+	pricesWidget = new QWidget(pricesGroupBox);
+	QHBoxLayout *housePriceLayout = new QHBoxLayout(pricesWidget, 0, spacingHint());
+	housePriceLayout->addWidget(new QLabel(i18n("House price"), pricesWidget), 1, 0);
+	housePriceLayout->addWidget(housePrice = new QSpinBox(0, 3000, 25, pricesWidget));
 	housePrice->setSuffix(i18n("$"));
 	connect(housePrice, SIGNAL(valueChanged(int)), this, SLOT(housePriceChanged(int)));
 
-	//vlayout->addWidget(new KSeparator(page));
+	mathWidget = new QWidget(pricesGroupBox);
+	QGridLayout *mathLayout = new QGridLayout(mathWidget, 2, 2, 0, spacingHint());
+	mathLayout->addWidget(new QLabel(i18n("Rent variable"), mathWidget), 0, 0);
+	mathLayout->addWidget(new QLabel(i18n("Expression:"), mathWidget), 1, 0);
+
+	rentVarCombo = new QComboBox(mathWidget);
+	QStringList vars;
+	vars << "ownedbyplayer";
+	rentVarCombo->insertStringList(vars);
+	connect(rentVarCombo, SIGNAL(activated(const QString &)), this, \
SLOT(rentVarChanged(const QString &))); +	mathLayout->addWidget(rentVarCombo, 0, 1);
 
+	rentMathEdit = new KLineEdit(mathWidget);
+	connect(rentMathEdit, SIGNAL(textChanged(const QString &)), this, \
SLOT(rentMathChanged(const QString &))); +	mathLayout->addWidget(rentMathEdit, 1, 1);
+
 	QHBoxLayout *buttonlayout = new QHBoxLayout(vlayout, spacingHint());
 	removeB = new KPushButton(i18n("&Remove"), page);
 	buttonlayout->addWidget(removeB);
@@ -123,6 +139,9 @@
 			fgButton->setColor((*it).fgColor());
 			bgButton->setColor((*it).bgColor());
 			housePrice->setValue((*it).housePrice());
+			rentMathEdit->setText((*it).rentMath());
+			if (!(*it).rentVar().isNull())
+				rentVarCombo->setCurrentText((*it).rentVar());
 			break;
 		}
 	}
@@ -160,6 +179,20 @@
 	ConfigEstateGroup *group = currentGroup();
 	if (group)
 		group->setHousePrice(newValue);
+}
+
+void GroupEditor::rentVarChanged(const QString &newValue)
+{
+	ConfigEstateGroup *group = currentGroup();
+	if (group)
+		group->setRentVar(newValue);
+}
+
+void GroupEditor::rentMathChanged(const QString &newValue)
+{
+	ConfigEstateGroup *group = currentGroup();
+	if (group)
+		group->setRentMath(newValue);
 }
 
 void GroupEditor::slotApply()

Index: group.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/group.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- group.h	2002/06/09 07:18:46	1.2
+++ group.h	2002/06/10 04:08:05	1.3
@@ -1,17 +1,19 @@
 #ifndef GROUP_H
 #define GROUP_H
 
-#include <qptrlist.h>
 #include <qcolor.h>
+#include <qptrlist.h>
 
 #include <kdialogbase.h>
 
 #include <atlantic/estategroup.h>
 
 class KColorButton;
+class KLineEdit;
 class KListBox;
 class KPushButton;
 
+class QComboBox;
 class QListBoxItem;
 class QSpinBox;
 class QVGroupBox;
@@ -25,6 +27,13 @@
 
 	void setHousePrice(int newPrice) { m_housePrice = newPrice; }
 	int housePrice() { return m_housePrice; }
+	void setGlobalPrice(int newGlobalPrice) { m_globalPrice = newGlobalPrice; }
+	int globalPrice() { return m_globalPrice; }
+	const QString &rentMath() { return m_rentMath; }
+	void setRentMath(const QString &newMath) { m_rentMath = newMath; }
+	const QString &rentVar() { return m_rentVar; }
+	void setRentVar(const QString &newVar) { m_rentVar = newVar; }
+	bool dynamicRent() { return !m_rentVar.isEmpty() || !m_rentMath.isEmpty(); }
 	void setName(const QString &name) { m_name = name; }
 	const QString &name() { return m_name; }
 
@@ -36,7 +45,10 @@
 	private:
 	QColor m_fgColor;
 	QColor m_bgColor;
+	QString m_rentMath;
+	QString m_rentVar;
 	int m_housePrice;
+	int m_globalPrice;
 	QString m_name;
 };
 typedef QValueList<ConfigEstateGroup> ConfigEstateGroupList;
@@ -61,14 +73,20 @@
 	void fgChanged(const QColor &);
 	void bgChanged(const QColor &);
 	void housePriceChanged(int);
+	void rentVarChanged(const QString &);
+	void rentMathChanged(const QString &);
 	void add();
 	void remove();
 	void selectionChanged();
 
 	private:
 	KListBox *groups;
+	KLineEdit *rentMathEdit;
+	QComboBox *rentVarCombo;
 	KColorButton *fgButton;
 	KColorButton *bgButton;
+	QWidget *pricesWidget;
+	QWidget *mathWidget;
 	QSpinBox *housePrice;
 	QVGroupBox *colorGroupBox;
 	QVGroupBox *pricesGroupBox;

_______________________________________________
atlantik-devel mailing list
atlantik-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic