1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* CPreGame's buttons less ugly

* fixed sorting maps
* minor stuff
This commit is contained in:
Michał W. Urbańczyk 2007-07-28 23:01:25 +00:00
parent 060dc4c785
commit b38a8c9557
8 changed files with 116 additions and 53 deletions

View File

@ -21,12 +21,12 @@ struct PlayerState
vector<vector<bool> > fogOfWarMap; vector<vector<bool> > fogOfWarMap;
std::vector<int> resources; std::vector<int> resources;
std::vector<CHeroInstance> heroes; std::vector<CHeroInstance> heroes;
std::vector<CTownInstance> heroes; std::vector<CTownInstance> towns;
} };
class CGameState class CGameState
{ {
std::map<int,PlayerState> players; //color <-> playerstate
} };
#endif //CGAMESTATE_H #endif //CGAMESTATE_H

View File

@ -9,7 +9,6 @@
class CHeroClass; class CHeroClass;
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHEMIST, HERO_WIZARD, HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD, HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
class CHero class CHero
{ {
@ -44,10 +43,18 @@ public:
class CHeroInstance class CHeroInstance
{ {
public: public:
int owner;
int exp; //experience point
int level; //current level of hero
std::string name; //may be custom
std::string biography; //may be custom
int portrait; //may be custom
CHero type; CHero type;
int3 pos; int3 pos; //position on adventure map
CCreatureSet army; //army CCreatureSet army; //army
//TODO: armia, artefakty, itd. int mana; // remaining spell points
int movement; //remaining movement points
//TODO: artifacts, primary and secondary skills, known spells, commander, blessings, curses, morale/luck modifiers
}; };
class CHeroHandler class CHeroHandler

View File

@ -14,19 +14,58 @@ extern SDL_Surface * ekran;
extern TTF_Font * TNRB16, *TNR, *GEOR13; extern TTF_Font * TNRB16, *TNR, *GEOR13;
SDL_Color genRGB(int r, int g, int b, int a=0); SDL_Color genRGB(int r, int g, int b, int a=0);
//void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2); //void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2);
extern CPreGame * CPG;
bool isItIn(const SDL_Rect * rect, int x, int y); bool isItIn(const SDL_Rect * rect, int x, int y);
using namespace NMessage;
namespace NMessage
{
std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
SDL_Surface * background = NULL;
}
CMessage::CMessage() CMessage::CMessage()
{ {
piecesOfBox = CGI->spriteh->giveDef("DIALGBOX.DEF"); if (!NMessage::background)
background = CGI->bitmaph->loadBitmap("DIBOXBCK.BMP"); init();
SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255));
} }
CMessage::~CMessage() void CMessage::init()
{ {
delete piecesOfBox; {
for (int i=0;i<PLAYER_LIMIT;i++)
{
CDefHandler * bluePieces = CGI->spriteh->giveDef("DIALGBOX.DEF");
std::vector<SDL_Surface *> n;
piecesOfBox.push_back(n);
if (i==1)
{
for (int j=0;j<bluePieces->ourImages.size();j++)
{
piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
}
}
for (int j=0;j<bluePieces->ourImages.size();j++)
{
CSDL_Ext::blueToPlayersAdv(bluePieces->ourImages[j].bitmap,i);
piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
}
}
NMessage::background = CGI->bitmaph->loadBitmap("DIBOXBCK.BMP");
SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255));
}
}
void CMessage::dispose()
{
for (int i=0;i<PLAYER_LIMIT;i++)
{
for (int j=0;j<piecesOfBox[i].size();j++)
{
SDL_FreeSurface(piecesOfBox[i][j]);
}
}
SDL_FreeSurface(background); SDL_FreeSurface(background);
} }
SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor)
@ -38,43 +77,32 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor)
for (int j=0; j<w; j+=background->w-1) for (int j=0; j<w; j+=background->w-1)
SDL_BlitSurface(background,&genRect(background->h,background->w-1,1,0),ret,&genRect(h,w,j,i)); SDL_BlitSurface(background,&genRect(background->h,background->w-1,1,0),ret,&genRect(h,w,j,i));
} }
//SDL_Flip(ekran);
//CSDL_Ext::update(ekran);
std::vector<SDL_Surface*> pieces;
for (int i=0;i<piecesOfBox->ourImages.size();i++)
{
pieces.push_back(piecesOfBox->ourImages[i].bitmap);
if (playerColor!=1)
{
CSDL_Ext::blueToPlayersAdv(pieces[pieces.size()-1],playerColor);
}
}
//obwodka I-szego rzedu pozioma //obwodka I-szego rzedu pozioma
for (int i=0; i<w; i+=pieces[6]->w) for (int i=0; i<w; i+=piecesOfBox[playerColor][6]->w)
{ {
SDL_BlitSurface SDL_BlitSurface
(pieces[6],NULL,ret,&genRect(pieces[6]->h,pieces[6]->w,i,0)); (piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,i,0));
SDL_BlitSurface SDL_BlitSurface
(pieces[7],NULL,ret,&genRect(pieces[7]->h,pieces[7]->w,i,h-pieces[7]->h)); (piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,i,h-piecesOfBox[playerColor][7]->h));
} }
//obwodka I-szego rzedu pionowa //obwodka I-szego rzedu pionowa
for (int i=0; i<h; i+=piecesOfBox->ourImages[4].bitmap->h) for (int i=0; i<h; i+=piecesOfBox[playerColor][4]->h)
{ {
SDL_BlitSurface SDL_BlitSurface
(pieces[4],NULL,ret,&genRect(pieces[4]->h,pieces[4]->w,0,i)); (piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,0,i));
SDL_BlitSurface SDL_BlitSurface
(pieces[5],NULL,ret,&genRect(pieces[5]->h,pieces[5]->w,w-pieces[5]->w,i)); (piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,w-piecesOfBox[playerColor][5]->w,i));
} }
//corners //corners
SDL_BlitSurface SDL_BlitSurface
(pieces[0],NULL,ret,&genRect(pieces[0]->h,pieces[0]->w,0,0)); (piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,0,0));
SDL_BlitSurface SDL_BlitSurface
(pieces[1],NULL,ret,&genRect(pieces[1]->h,pieces[1]->w,w-pieces[1]->w,0)); (piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,w-piecesOfBox[playerColor][1]->w,0));
SDL_BlitSurface SDL_BlitSurface
(pieces[2],NULL,ret,&genRect(pieces[2]->h,pieces[2]->w,0,h-pieces[2]->h)); (piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,0,h-piecesOfBox[playerColor][2]->h));
SDL_BlitSurface SDL_BlitSurface
(pieces[3],NULL,ret,&genRect(pieces[3]->h,pieces[3]->w,w-pieces[3]->w,h-pieces[3]->h)); (piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,w-piecesOfBox[playerColor][3]->w,h-piecesOfBox[playerColor][3]->h));
//box gotowy! //box gotowy!
return ret; return ret;
} }

View File

@ -2,26 +2,34 @@
#define CMESSAGE_H #define CMESSAGE_H
#include "SDL_TTF.h" #include "SDL_TTF.h"
#include "SDL.h"
#include "CSemiDefHandler.h" #include "CSemiDefHandler.h"
#include "CDefHandler.h" #include "CDefHandler.h"
#include "CGameInterface.h" #include "CGameInterface.h"
#include "CGameInfo.h"
#include "SDL_Extensions.h"
#define CGI (CGameInfo::mainObj)
enum EWindowType {infoOnly, infoOK, yesOrNO}; enum EWindowType {infoOnly, infoOK, yesOrNO};
class CPreGame; class CPreGame;
class MapSel; class MapSel;
namespace NMessage
{
extern std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
extern SDL_Surface * background ;
}
class CMessage class CMessage
{ {
public: public:
static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true); //line - chars per line static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
CDefHandler * piecesOfBox;
SDL_Surface * background;
SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL); std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
SDL_Surface * drawBox1(int w, int h, int playerColor=1); static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true); //line - chars per line
CMessage(); CMessage();
~CMessage(); void init();
void dispose();
}; };
// //
#endif //CMESSAGE_H #endif //CMESSAGE_H

View File

@ -47,7 +47,7 @@ template <class T=ttt> struct SetrButton: public Button<T>
{ {
int key, * poin; int key, * poin;
virtual void press(bool down=true); virtual void press(bool down=true);
SetrButton(){type=0;selectable=selected=false;state=0;highlightable=false;} SetrButton(){type=1;selectable=selected=false;state=0;highlightable=false;}
}; };
template<class T=CPreGame> class Slider template<class T=CPreGame> class Slider
{ // { //
@ -79,19 +79,17 @@ public:
int key; int key;
int * what; int * what;
IntBut(){type=2;fun=NULL;highlightable=false;}; IntBut(){type=2;fun=NULL;highlightable=false;};
IntBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel, int Key, int * What)
: Button(Pos,Fun,Imgs,Sel,gr),key(My),key(Key),what(What){ourGroup=gr;type=2;fun=NULL;};
void set(){*what=key;}; void set(){*what=key;};
}; };
template<class T=ttt> struct IntSelBut: public Button<T> template<class T=ttt> struct IntSelBut: public Button<T>
{ {
public: public:
CPoinGroup<T> * ourGroup; CPoinGroup<T> * ourPoinGroup;
int key; int key;
IntSelBut(){}; IntSelBut(){};
IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1) IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1)
: Button(Pos,Fun,Imgs,Sel,gr),key(My){ourGroup=gr;type=1;}; : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;};
void select(bool on=true) {(*this).Button::select(on);ourGroup->setYour(this);} void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this);}
}; };
template <class T=ttt> class CPoinGroup :public CGroup<T> template <class T=ttt> class CPoinGroup :public CGroup<T>
{ {

View File

@ -1,7 +1,9 @@
#ifndef CTOWNHANDLER_H #ifndef CTOWNHANDLER_H
#define CTOWNHANDLER_H #define CTOWNHANDLER_H
#include "CDefHandler.h" #include "CDefHandler.h"
#include "CCreatureHandler.h"
#include "SDL.h" #include "SDL.h"
#include "int3.h"
#include <string> #include <string>
#include <vector> #include <vector>
class CTown class CTown
@ -22,8 +24,19 @@ public:
}; };
class CTownInstance class CTownInstance
{ {
int type; int type; //type of town
std::string name; int owner; //ID of owner
int3 pos; //position
CTown * town;
std::string name; // name of town
CCreatureSet garrison;
int builded; //how many buildings has been built this turn
int destroyed; //how many buildings has been destroyed this turn
//TODO:
//buildings
//creatures to be recruited
//hero in garrison
//spells in mage guild
}; };
#endif //CTOWNHANDLER_H #endif //CTOWNHANDLER_H

View File

@ -14,8 +14,12 @@ enum Eriver {clearRiver=1, icyRiver, muddyRiver, lavaRiver};
enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad}; enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c}; enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c};
enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero, enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255}; captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255}; enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHEMIST, HERO_WIZARD,
HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
const int F_NUMBER = 9; //factions quantity const int F_NUMBER = 9; //factions quantity
const int PLAYER_LIMIT = 8; //player limit per map const int PLAYER_LIMIT = 8; //player limit per map

5
int3.h
View File

@ -1,3 +1,6 @@
#ifndef INT3_H
#define INT3_H
class int3 class int3
{ {
int x,y,z; int x,y,z;
@ -59,3 +62,5 @@ class int3
return false; return false;
} }
}; };
#endif //INT3_H