Awesome patch from TheException - adds editing of weapon delay and crate count. Tiy might want to tweak the crate graphic, could make be smaller or less overlappy.
authornemo
Thu, 25 Feb 2010 04:04:26 +0000
changeset 2860 13a53315ae18
parent 2859 d44ae883896b
child 2861 76542612ca91
Awesome patch from TheException - adds editing of weapon delay and crate count. Tiy might want to tweak the crate graphic, could make be smaller or less overlappy.
QTfrontend/hedgewars.qrc
QTfrontend/hwconsts.cpp.in
QTfrontend/res/ammopicbox.png
QTfrontend/res/ammopicdelay.png
QTfrontend/selectWeapon.cpp
QTfrontend/selectWeapon.h
hedgewars/uAmmos.pas
hedgewars/uGears.pas
--- a/QTfrontend/hedgewars.qrc	Wed Feb 24 16:41:35 2010 +0000
+++ b/QTfrontend/hedgewars.qrc	Thu Feb 25 04:04:26 2010 +0000
@@ -79,5 +79,7 @@
     <file>res/chat_default_off.png</file>
     <file>res/chat_ignore_off.png</file>
     <file>res/chat_friend_off.png</file>
+	<file>res/ammopicbox.png</file>
+	<file>res/ammopicdelay.png</file>
 </qresource>
 </RCC>
--- a/QTfrontend/hwconsts.cpp.in	Wed Feb 24 16:41:35 2010 +0000
+++ b/QTfrontend/hwconsts.cpp.in	Thu Feb 25 04:04:26 2010 +0000
@@ -33,27 +33,39 @@
 QString * cDefaultAmmoStore = new QString(
 		"9391929422199121032235111001201000000211"
 		"0404000441400444645644444774776112211144"
+		"0000000000000205500000040007004000000000"
+		"1311111312111111123114111111111111111211"
 		);
-int cAmmoNumber = cDefaultAmmoStore->size() / 2;
+int cAmmoNumber = cDefaultAmmoStore->size() / 4;
 
 QList< QPair<QString, QString> > cDefaultAmmos =
 	QList< QPair<QString, QString> >()
 	<< qMakePair(QString("Default"), *cDefaultAmmoStore)
 	<< qMakePair(QString("Crazy"),     QString(
 		"9999999999999999992999999999999999299999"
-		"1111111111111111111111111111111111111111"))
+		"1111111111111111111111111111111111111111"
+		"0000000000000205500000040007004000000000"
+		"1311111312111111123114111111111111111211"))
 	<< qMakePair(QString("Pro mode"),  QString(
 		"9090009000000000000009000000000000000000"
-		"0000000000000000000000000000000000000000"))
+		"0000000000000000000000000000000000000000"
+		"0000000000000205500000040007004000000000"
+		"1111111111111111111111111111111111111111"))
 	<< qMakePair(QString("Shoppa"),    QString(
 		"0000009900000000000000000000000000000000"
-		"4444410044244402210112121222422000000002"))
+		"4444410044244402210112121222422000000002"
+		"0000000000000205500000040007004000000000"
+		"1111111111111111111111111111111111111111"))
 	<< qMakePair(QString("Basketball"),QString(
 		"0000009000000900000000000000000000000000"
-		"0000000000000000000000000000000000000000"))
+		"0000000000000000000000000000000000000000"
+		"0000000000000005500000040007004000000000"
+		"1111111111111111111111111111111111111111"))
 	<< qMakePair(QString("Minefield"), QString(
 		"0000009900090000000300000000000000000000"
-		"0000000000000000000000000000000000000000"))
+		"0000000000000000000000000000000000000000"
+		"0000000000000205500000040007004000000000"
+		"1111111111111111111111111111111111111111"))
 	;
 
 QColor * color1 = new QColor(221,   0,   0);
Binary file QTfrontend/res/ammopicbox.png has changed
Binary file QTfrontend/res/ammopicdelay.png has changed
--- a/QTfrontend/selectWeapon.cpp	Wed Feb 24 16:41:35 2010 +0000
+++ b/QTfrontend/selectWeapon.cpp	Thu Feb 25 04:04:26 2010 +0000
@@ -40,7 +40,7 @@
 	return ammo.copy(x, y, 32, 32);
 }
 
-SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QWidget* parent) :
+SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QWidget* parent) :
 	QWidget(parent)
 {
 	QHBoxLayout* hbLayout = new QHBoxLayout(this);
@@ -53,7 +53,7 @@
 	lbl->setGeometry(0, 0, 30, 30);
 	hbLayout->addWidget(lbl);
 
-	item = new WeaponItem(QImage(":/res/ammopic.png"), this);
+	item = new WeaponItem(image, this);
 	item->setItemsNum(wNum);
 	item->setInfinityState(allowInfinite);
 	hbLayout->addWidget(item);
@@ -101,9 +101,19 @@
 	p2Layout = new QGridLayout(page2);
 	p2Layout->setSpacing(1);
 	p2Layout->setMargin(1);
+	QWidget * page3 = new QWidget(this);
+	p3Layout = new QGridLayout(page3);
+	p3Layout->setSpacing(1);
+	p3Layout->setMargin(1);
+	QWidget * page4 = new QWidget(this);
+	p4Layout = new QGridLayout(page4);
+	p4Layout->setSpacing(1);
+	p4Layout->setMargin(1);
 
 	tbw->addTab(page1, tr("Weapon set"));
 	tbw->addTab(page2, tr("Probabilities"));
+	tbw->addTab(page4, tr("Ammo in boxes"));
+	tbw->addTab(page3, tr("Delays"));
 
 	QGridLayout * pageLayout = new QGridLayout(this);
 	pageLayout->addWidget(tbw);
@@ -114,13 +124,21 @@
 	for(; i < m_numItems; ++i) {
 		if (i == 6) continue;
 		if (k % 4 == 0) ++j;
-		SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), this);
+		SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), this);
 		weaponItems[i].append(swi);
 		p1Layout->addWidget(swi, j, k % 4);
 
-		SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), this);
+		SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), QImage(":/res/ammopicbox.png"), this);
 		weaponItems[i].append(pwi);
 		p2Layout->addWidget(pwi, j, k % 4);
+		
+		SelWeaponItem * dwi = new SelWeaponItem(false, i, currentState[numItems*2 + i].digitValue(), QImage(":/res/ammopicdelay.png"), this);
+		weaponItems[i].append(dwi);
+		p3Layout->addWidget(dwi, j, k % 4);
+		
+		SelWeaponItem * awi = new SelWeaponItem(false, i, currentState[numItems*3 + i].digitValue(), QImage(":/res/ammopic.png"), this);
+		weaponItems[i].append(awi);
+		p4Layout->addWidget(awi, j, k % 4);
 
 		++k;
 	}
@@ -137,6 +155,8 @@
 		if (it == weaponItems.end()) continue;
 		it.value()[0]->setItemsNum(ammo[i].digitValue());
 		it.value()[1]->setItemsNum(ammo[m_numItems + i].digitValue());
+		it.value()[2]->setItemsNum(ammo[m_numItems*2 + i].digitValue());
+		it.value()[3]->setItemsNum(ammo[m_numItems*3 + i].digitValue());
 	}
 	update();
 }
@@ -158,6 +178,8 @@
 
 	QString state1;
 	QString state2;
+	QString state3;
+	QString state4;
 
 	for(int i = 0; i < m_numItems; ++i) {
 		twi::const_iterator it = weaponItems.find(i);
@@ -165,12 +187,16 @@
 		state1.append(QString::number(num));
 		int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum();
 		state2.append(QString::number(prob));
+		int del = it == weaponItems.end() ? 0 : it.value()[2]->getItemsNum();
+		state3.append(QString::number(del));
+		int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum();
+		state4.append(QString::number(am));
 	}
 	if (curWeaponsName != "") {
 		// remove old entry
 		wconf->remove(curWeaponsName);
 	}
-	wconf->setValue(m_name->text(), state1 + state2);
+	wconf->setValue(m_name->text(), state1 + state2 + state3 + state4);
 	emit weaponsChanged();
 }
 
--- a/QTfrontend/selectWeapon.h	Wed Feb 24 16:41:35 2010 +0000
+++ b/QTfrontend/selectWeapon.h	Thu Feb 25 04:04:26 2010 +0000
@@ -33,7 +33,7 @@
   Q_OBJECT
 
 public:
-  SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QWidget* parent=0);
+  SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QWidget* parent=0);
 
   unsigned char getItemsNum() const;
   void setItemsNum(const unsigned char num);
@@ -77,6 +77,8 @@
   twi weaponItems;
   QGridLayout* p1Layout;
   QGridLayout* p2Layout;
+  QGridLayout* p3Layout;
+  QGridLayout* p4Layout;
 };
 
 #endif // _SELECT_WEAPON_INCLUDED
--- a/hedgewars/uAmmos.pas	Wed Feb 24 16:41:35 2010 +0000
+++ b/hedgewars/uAmmos.pas	Thu Feb 25 04:04:26 2010 +0000
@@ -88,7 +88,7 @@
     ammos: TAmmoCounts;
     substr: shortstring; // TEMPORARY
 begin
-TryDo(byte(s[0]) = byte(ord(High(TAmmoType))) * 2, 'Invalid ammo scheme (incompatible frontend)', true);
+TryDo(byte(s[0]) = byte(ord(High(TAmmoType))) * 4, 'Invalid ammo scheme (incompatible frontend)', true);
 
 // FIXME - TEMPORARY hardcoded check on shoppa pending creation of crate *type* probability editor
 substr:= Copy(s,1,15);
@@ -106,6 +106,8 @@
     if a <> amNothing then
         begin
         Ammoz[a].Probability:= probability[byte(s[ord(a) + ord(High(TAmmoType))]) - byte('0')];
+        Ammoz[a].SkipTurns:= (byte(s[ord(a) + ord(High(TAmmoType)) + ord(High(TAmmoType))]) - byte('0'));
+        Ammoz[a].NumberInCase:= (byte(s[ord(a) + ord(High(TAmmoType)) + ord(High(TAmmoType)) + ord(High(TAmmoType))]) - byte('0'));
 		if (TrainingFlags and tfIgnoreDelays) <> 0 then Ammoz[a].SkipTurns:= 0;
         cnt:= byte(s[ord(a)]) - byte('0');
         // avoid things we already have infinite number
@@ -114,6 +116,8 @@
             cnt:= AMMO_INFINITE;
             Ammoz[a].Probability:= 0
             end;
+        if Ammoz[a].NumberInCase = 0 then Ammoz[a].Probability:= 0;
+
         // avoid things we already have by scheme
         // merge this into DisableSomeWeapons ?
         if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or
@@ -125,7 +129,6 @@
             Ammoz[a].Probability:= 0
             end;
         ammos[a]:= cnt;
-        if shoppa then Ammoz[a].NumberInCase:= 1;  // FIXME - TEMPORARY remove when crate number in case editor is added
 
         if ((GameFlags and gfKing) <> 0) and ((GameFlags and gfPlaceHog) = 0) and (Ammoz[a].SkipTurns = 0) and (a <> amTeleport) and (a <> amSkip) then 
             Ammoz[a].SkipTurns:= 1;
--- a/hedgewars/uGears.pas	Wed Feb 24 16:41:35 2010 +0000
+++ b/hedgewars/uGears.pas	Thu Feb 25 04:04:26 2010 +0000
@@ -1969,7 +1969,7 @@
 
 FollowGear:= nil;
 
-if shoppa then  // FIXME -  TEMPORARY  REMOVE WHEN CRATE PROBABILITY IS ADDED
+if shoppa then  // FIXME -  TEMPORARY  REMOVE WHEN CRATE PROBABILITY IS ADDED, INCLUDING DISABLING OF HEALTH CRATES
     t:= 7
 else
     t:= getrandom(20);