浏览代码

* [new] sorting maps in map selection screen (still may be buggy)
* minor improvements

Michał W. Urbańczyk 18 年之前
父节点
当前提交
70156a179b
共有 5 个文件被更改,包括 25 次插入3 次删除
  1. 7 1
      CMessage.h
  2. 1 0
      CMusicHandler.cpp
  3. 二进制
      CPreGame.cpp
  4. 4 1
      CPreGame.h
  5. 13 1
      map.h

+ 7 - 1
CMessage.h

@@ -26,12 +26,18 @@ template <class T=ttt> struct Button: public OverButton
 	CGroup<T> * ourGroup;
 	Button( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CGroup<T>* gr=NULL, int id=-1)
 		:fun(Fun),ourGroup(gr){type=0;imgs=Imgs;selectable=Sel;selected=false;state=0;pos=Pos;ID=id;};
-	Button(){};
+	Button(){ourGroup=NULL;};
 	bool selectable, selected;
 	bool highlightable, highlighted;
 	virtual	void hover(bool on=true);
 	virtual void select(bool on=true);
 };	
+template <class T=ttt> struct SetrButton: public Button<T>
+{
+	int key, * poin;
+	virtual void press(bool down=true);
+	SetrButton(){type=0;selectable=selected=false;state=0;}
+};
 template<class T=CPreGame>  class Slider
 { //
 public:

+ 1 - 0
CMusicHandler.cpp

@@ -1,3 +1,4 @@
+#include "stdafx.h"
 #include "CMusicHandler.h"
 
 void CMusicHandler::initMusics()

二进制
CPreGame.cpp


+ 4 - 1
CPreGame.h

@@ -16,9 +16,11 @@ struct RanSel
 			size[4], twoLevel, showRand;
 	CGroup<> *Ghorcpl, *Ghorcte, *Gconpl, *Gconte, *Gwater, *Gmonster, *Gsize;
 };
+
 class MapSel
 {
 public:
+	ESortBy sortBy;
 	bool showed;
 	SDL_Surface * bg;
 	int selected;
@@ -29,7 +31,7 @@ public:
 	int current;
 	std::vector<CMapInfo> ourMaps;
 	IntBut<> small, medium, large, xlarge, all;
-	Button<> nrplayer, mapsize, type, name, viccon, loscon;
+	SetrButton<> nrplayer, mapsize, type, name, viccon, loscon;
 	Slider<>  *slid, *descslid;
 	int sizeFilter;
 	int whichWL(int nr);
@@ -110,6 +112,7 @@ public:
 	void showAskBox (std::string data, void(*f1)(),void(*f2)());
 	void hideBox ();
 	void printMapsFrom(int from);
+	void sortMaps();
 };
 
 #endif //CPREGAME_H

+ 13 - 1
map.h

@@ -242,7 +242,19 @@ public:
 			return (a.lossCondition.typeOfLossCon<b.lossCondition.typeOfLossCon);
 			break;
 		case ESortBy::playerAm:
-			//TODO
+			int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
+			playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
+			for (int i=0;i<8;i++)
+			{
+				if (a.players[i].canHumanPlay) {playerAmntA++;humenPlayersA++;}
+				else if (a.players[i].canComputerPlay) {playerAmntA++;}
+				if (b.players[i].canHumanPlay) {playerAmntB++;humenPlayersB++;}
+				else if (b.players[i].canComputerPlay) {playerAmntB++;}
+			}
+			if (playerAmntB!=playerAmntA)
+				return (playerAmntA<playerAmntB);
+			else
+				return (humenPlayersA<humenPlayersB);
 			break;
 		case ESortBy::size:
 			return (a.width<b.width);