From b38a8c955726284e2a4bd63d64591136f22b8f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 28 Jul 2007 23:01:25 +0000 Subject: [PATCH] * CPreGame's buttons less ugly * fixed sorting maps * minor stuff --- CGameState.h | 8 ++--- CHeroHandler.h | 13 ++++++-- CMessage.cpp | 84 +++++++++++++++++++++++++++++++++----------------- CMessage.h | 22 ++++++++----- CPreGame.h | 10 +++--- CTownHandler.h | 19 ++++++++++-- global.h | 6 +++- int3.h | 7 ++++- 8 files changed, 116 insertions(+), 53 deletions(-) diff --git a/CGameState.h b/CGameState.h index afe634879..7b4b9e789 100644 --- a/CGameState.h +++ b/CGameState.h @@ -21,12 +21,12 @@ struct PlayerState vector > fogOfWarMap; std::vector resources; std::vector heroes; - std::vector heroes; -} + std::vector towns; +}; class CGameState { - -} + std::map players; //color <-> playerstate +}; #endif //CGAMESTATE_H \ No newline at end of file diff --git a/CHeroHandler.h b/CHeroHandler.h index 4650deee2..7c650580a 100644 --- a/CHeroHandler.h +++ b/CHeroHandler.h @@ -9,7 +9,6 @@ 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 { @@ -44,10 +43,18 @@ public: class CHeroInstance { 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; - int3 pos; + int3 pos; //position on adventure map 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 diff --git a/CMessage.cpp b/CMessage.cpp index 065e05665..9352fa422 100644 --- a/CMessage.cpp +++ b/CMessage.cpp @@ -14,19 +14,58 @@ extern SDL_Surface * ekran; extern TTF_Font * TNRB16, *TNR, *GEOR13; 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); -extern CPreGame * CPG; bool isItIn(const SDL_Rect * rect, int x, int y); +using namespace NMessage; + + +namespace NMessage +{ + std::vector > piecesOfBox; //in colors of all players + SDL_Surface * background = NULL; +} CMessage::CMessage() { - piecesOfBox = CGI->spriteh->giveDef("DIALGBOX.DEF"); - background = CGI->bitmaph->loadBitmap("DIBOXBCK.BMP"); - SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255)); + if (!NMessage::background) + init(); } -CMessage::~CMessage() +void CMessage::init() { - delete piecesOfBox; + { + for (int i=0;ispriteh->giveDef("DIALGBOX.DEF"); + std::vector n; + piecesOfBox.push_back(n); + if (i==1) + { + for (int j=0;jourImages.size();j++) + { + piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap); + } + } + for (int j=0;jourImages.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;iw-1) 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 pieces; - for (int i=0;iourImages.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 - for (int i=0; iw) + for (int i=0; iw) { 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 - (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 - for (int i=0; iourImages[4].bitmap->h) + for (int i=0; ih) { 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 - (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 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 - (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 - (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 - (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! return ret; } diff --git a/CMessage.h b/CMessage.h index e497ec6b7..841659fd6 100644 --- a/CMessage.h +++ b/CMessage.h @@ -2,26 +2,34 @@ #define CMESSAGE_H #include "SDL_TTF.h" +#include "SDL.h" #include "CSemiDefHandler.h" #include "CDefHandler.h" #include "CGameInterface.h" +#include "CGameInfo.h" +#include "SDL_Extensions.h" +#define CGI (CGameInfo::mainObj) enum EWindowType {infoOnly, infoOK, yesOrNO}; class CPreGame; class MapSel; +namespace NMessage +{ + extern std::vector > piecesOfBox; //in colors of all players + extern SDL_Surface * background ; +} + class CMessage { public: - static std::vector * breakText(std::string text, int line=30, bool userBreak=true); //line - chars per line - CDefHandler * piecesOfBox; - SDL_Surface * background; - SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, + static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, std::vector *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 * breakText(std::string text, int line=30, bool userBreak=true); //line - chars per line CMessage(); - ~CMessage(); + void init(); + void dispose(); }; - // #endif //CMESSAGE_H \ No newline at end of file diff --git a/CPreGame.h b/CPreGame.h index bb7d0c890..d9eb7cb5a 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -47,7 +47,7 @@ template struct SetrButton: public Button { int key, * poin; 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 Slider { // @@ -79,19 +79,17 @@ public: int key; int * what; 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;}; }; template struct IntSelBut: public Button { public: - CPoinGroup * ourGroup; + CPoinGroup * ourPoinGroup; int key; IntSelBut(){}; IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup* gr=NULL, int My=-1) - : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourGroup=gr;type=1;}; - void select(bool on=true) {(*this).Button::select(on);ourGroup->setYour(this);} + : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;}; + void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this);} }; template class CPoinGroup :public CGroup { diff --git a/CTownHandler.h b/CTownHandler.h index 897bda2b8..17fbf6cad 100644 --- a/CTownHandler.h +++ b/CTownHandler.h @@ -1,7 +1,9 @@ #ifndef CTOWNHANDLER_H #define CTOWNHANDLER_H #include "CDefHandler.h" +#include "CCreatureHandler.h" #include "SDL.h" +#include "int3.h" #include #include class CTown @@ -22,8 +24,19 @@ public: }; class CTownInstance { - int type; - std::string name; - + int type; //type of town + 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 \ No newline at end of file diff --git a/global.h b/global.h index d947855f3..569daa644 100644 --- a/global.h +++ b/global.h @@ -14,8 +14,12 @@ enum Eriver {clearRiver=1, icyRiver, muddyRiver, lavaRiver}; enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad}; enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c}; 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 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 PLAYER_LIMIT = 8; //player limit per map diff --git a/int3.h b/int3.h index 767f02f8a..0eeae9a8c 100644 --- a/int3.h +++ b/int3.h @@ -1,3 +1,6 @@ +#ifndef INT3_H +#define INT3_H + class int3 { int x,y,z; @@ -58,4 +61,6 @@ class int3 return false; return false; } -}; \ No newline at end of file +}; + +#endif //INT3_H \ No newline at end of file